import { type AutomationScheduleDefinition } from '../automation/schedules.js';
import { ArtifactStore } from '../artifacts/index.js';
import type { MemoryRegistry } from '../state/index.js';
import type { RuntimeEventBus } from '../runtime/events/index.js';
import { KnowledgeConnectorRegistry } from './connectors.js';
import { type KnowledgeMapRenderOptions } from './map.js';
import { KnowledgeSemanticService } from './semantic/index.js';
import { KnowledgeStore } from './store.js';
import type { BrowserKnowledgeIngestOptions, BrowserKnowledgeProfile } from './browser-history/index.js';
import type { KnowledgeBatchIngestResult, KnowledgeBookmarkSeed, KnowledgeConnector, KnowledgeConnectorDoctorReport, KnowledgeConsolidationCandidateRecord, KnowledgeConsolidationReportRecord, KnowledgeEdgeRecord, KnowledgeExtractionRecord, KnowledgeIssueRecord, KnowledgeJobMode, KnowledgeJobRecord, KnowledgeJobRunRecord, KnowledgeMaterializedProjection, KnowledgeItemView, KnowledgeMapResult, KnowledgeNodeRecord, KnowledgePacket, KnowledgePacketDetail, KnowledgeProjectionBundle, KnowledgeProjectionTarget, KnowledgeProjectionTargetKind, KnowledgeRefinementTaskRecord, KnowledgeRefinementTaskState, KnowledgeScheduleRecord, KnowledgeSearchResult, KnowledgeSourceRecord, KnowledgeSourceType, KnowledgeStatus, KnowledgeUsageRecord } from './types.js';
import { type KnowledgeIssueReviewInput, type KnowledgeIssueReviewResult } from './review.js';
import { type KnowledgeSpaceScopeInput } from './spaces.js';
export interface KnowledgeServiceConfig {
    readonly configManager?: {
        getControlPlaneConfigDir?: (() => string) | undefined;
    };
    readonly memoryRegistry: Pick<MemoryRegistry, 'add' | 'getAll' | 'getStore'>;
    readonly runtimeBus?: RuntimeEventBus | null | undefined;
    readonly semanticService?: KnowledgeSemanticService | undefined;
}
export interface KnowledgeServiceStatus extends KnowledgeStatus {
    readonly note: string;
}
export declare class KnowledgeService {
    private readonly store;
    private readonly artifactStore;
    private readonly connectorRegistry;
    private readonly options;
    private readonly projectionService;
    private readonly scheduleService;
    private readonly semanticService;
    private runtimeBus;
    constructor(store: KnowledgeStore, artifactStore: ArtifactStore, connectorRegistry: KnowledgeConnectorRegistry | undefined, options: KnowledgeServiceConfig);
    private getIngestContext;
    private getPacketContext;
    private getConsolidationContext;
    attachRuntimeBus(runtimeBus: RuntimeEventBus | null | undefined): void;
    getStatus(scope?: KnowledgeSpaceScopeInput): Promise<KnowledgeServiceStatus>;
    listUsageRecords(limit?: number, input?: {
        readonly targetKind?: KnowledgeUsageRecord['targetKind'] | undefined;
        readonly targetId?: string | undefined;
        readonly usageKind?: KnowledgeUsageRecord['usageKind'] | undefined;
    }): readonly KnowledgeUsageRecord[];
    listConsolidationCandidates(limit?: number, input?: {
        readonly status?: KnowledgeConsolidationCandidateRecord['status'] | undefined;
        readonly subjectKind?: KnowledgeConsolidationCandidateRecord['subjectKind'] | undefined;
        readonly subjectId?: string | undefined;
    }): readonly KnowledgeConsolidationCandidateRecord[];
    getConsolidationCandidate(id: string): KnowledgeConsolidationCandidateRecord | null;
    listConsolidationReports(limit?: number): readonly KnowledgeConsolidationReportRecord[];
    getConsolidationReport(id: string): KnowledgeConsolidationReportRecord | null;
    listSchedules(limit?: number): readonly KnowledgeScheduleRecord[];
    getSchedule(id: string): KnowledgeScheduleRecord | null;
    listSources(limit?: number): KnowledgeSourceRecord[];
    querySources(input?: {
        readonly limit?: number | undefined;
        readonly offset?: number | undefined;
        readonly knowledgeSpaceId?: string | undefined;
        readonly includeAllSpaces?: boolean | undefined;
        readonly status?: string | undefined;
        readonly connectorId?: string | undefined;
        readonly sourceType?: string | undefined;
        readonly tag?: string | undefined;
        readonly query?: string | undefined;
    }): {
        total: number;
        items: KnowledgeSourceRecord[];
    };
    listNodes(limit?: number): KnowledgeNodeRecord[];
    queryNodes(input?: {
        readonly limit?: number | undefined;
        readonly offset?: number | undefined;
        readonly knowledgeSpaceId?: string | undefined;
        readonly includeAllSpaces?: boolean | undefined;
        readonly kind?: string | undefined;
        readonly status?: string | undefined;
        readonly query?: string | undefined;
    }): {
        total: number;
        items: KnowledgeNodeRecord[];
    };
    listIssues(limit?: number): KnowledgeIssueRecord[];
    queryIssues(input?: {
        readonly limit?: number | undefined;
        readonly offset?: number | undefined;
        readonly knowledgeSpaceId?: string | undefined;
        readonly includeAllSpaces?: boolean | undefined;
        readonly severity?: string | undefined;
        readonly status?: string | undefined;
        readonly code?: string | undefined;
        readonly query?: string | undefined;
    }): {
        total: number;
        items: KnowledgeIssueRecord[];
    };
    reviewIssue(input: KnowledgeIssueReviewInput): Promise<KnowledgeIssueReviewResult>;
    listExtractions(limit?: number, sourceId?: string, scope?: KnowledgeSpaceScopeInput): KnowledgeExtractionRecord[];
    getExtraction(id: string): KnowledgeExtractionRecord | null;
    getSourceExtraction(sourceId: string): KnowledgeExtractionRecord | null;
    listConnectors(): readonly KnowledgeConnector[];
    getConnector(id: string): KnowledgeConnector | null;
    doctorConnector(id: string): Promise<KnowledgeConnectorDoctorReport | null>;
    registerConnector(connector: KnowledgeConnector, options?: {
        replace?: boolean;
    }): void;
    getItem(id: string): KnowledgeItemView | null;
    getItemScoped(id: string, scope?: KnowledgeSpaceScopeInput): KnowledgeItemView | null;
    getItems(ids: readonly string[]): KnowledgeItemView[];
    private edgeInKnowledgeSpaceScope;
    private recordReferenceInKnowledgeSpaceScope;
    private recordMatchesKnowledgeSpaceScope;
    private nodeMatchesKnowledgeSpaceScope;
    private issueMatchesKnowledgeSpaceScope;
    private getScopeLookup;
    recordUsage(input: {
        readonly targetKind: KnowledgeUsageRecord['targetKind'];
        readonly targetId: string;
        readonly usageKind: KnowledgeUsageRecord['usageKind'];
        readonly task?: string | undefined;
        readonly sessionId?: string | undefined;
        readonly score?: number | undefined;
        readonly metadata?: Record<string, unknown> | undefined;
    }): Promise<KnowledgeUsageRecord>;
    getNeighbors(kind: 'source' | 'node', id: string, input?: {
        readonly relation?: string | undefined;
        readonly limit?: number | undefined;
    }): {
        readonly edges: readonly KnowledgeEdgeRecord[];
        readonly sources: readonly KnowledgeSourceRecord[];
        readonly nodes: readonly KnowledgeNodeRecord[];
    };
    ingestUrl(input: {
        readonly url: string;
        readonly title?: string | undefined;
        readonly tags?: readonly string[] | undefined;
        readonly folderPath?: string | undefined;
        readonly sessionId?: string | undefined;
        readonly sourceType?: KnowledgeSourceType | undefined;
        readonly connectorId?: string | undefined;
        readonly allowPrivateHosts?: boolean | undefined;
        readonly metadata?: Record<string, unknown> | undefined;
    }): Promise<{
        source: KnowledgeSourceRecord;
        artifactId?: string;
        extraction?: KnowledgeExtractionRecord;
        issues: readonly KnowledgeIssueRecord[];
    }>;
    ingestArtifact(input: {
        readonly artifactId?: string | undefined;
        readonly path?: string | undefined;
        readonly uri?: string | undefined;
        readonly title?: string | undefined;
        readonly tags?: readonly string[] | undefined;
        readonly folderPath?: string | undefined;
        readonly sessionId?: string | undefined;
        readonly sourceType?: KnowledgeSourceType | undefined;
        readonly connectorId?: string | undefined;
        readonly allowPrivateHosts?: boolean | undefined;
        readonly metadata?: Record<string, unknown> | undefined;
    }): Promise<{
        source: KnowledgeSourceRecord;
        artifactId?: string;
        extraction?: KnowledgeExtractionRecord;
        issues: readonly KnowledgeIssueRecord[];
    }>;
    importBookmarksFromFile(input: {
        readonly path: string;
        readonly sessionId?: string | undefined;
        readonly allowPrivateHosts?: boolean | undefined;
    }): Promise<KnowledgeBatchIngestResult>;
    importUrlsFromFile(input: {
        readonly path: string;
        readonly sessionId?: string | undefined;
        readonly allowPrivateHosts?: boolean | undefined;
    }): Promise<KnowledgeBatchIngestResult>;
    ingestBookmarkSeeds(seeds: readonly KnowledgeBookmarkSeed[], sessionId?: string, sourceType?: KnowledgeSourceType, connectorId?: string, allowPrivateHosts?: boolean): Promise<KnowledgeBatchIngestResult>;
    ingestWithConnector(connectorId: string, input: unknown, sessionId?: string, allowPrivateHosts?: boolean): Promise<KnowledgeBatchIngestResult>;
    ingestConnectorInput(input: {
        readonly connectorId: string;
        readonly input?: unknown | undefined;
        readonly content?: string | undefined;
        readonly path?: string | undefined;
        readonly sessionId?: string | undefined;
        readonly allowPrivateHosts?: boolean | undefined;
    }): Promise<KnowledgeBatchIngestResult>;
    syncBrowserHistory(input?: BrowserKnowledgeIngestOptions): Promise<KnowledgeBatchIngestResult & {
        readonly profiles: readonly BrowserKnowledgeProfile[];
    }>;
    listProjectionTargets(limit?: number, scope?: KnowledgeSpaceScopeInput): Promise<KnowledgeProjectionTarget[]>;
    renderProjection(input: {
        readonly kind: KnowledgeProjectionTargetKind;
        readonly id?: string | undefined;
        readonly limit?: number | undefined;
        readonly knowledgeSpaceId?: string | undefined;
        readonly includeAllSpaces?: boolean | undefined;
    }): Promise<KnowledgeProjectionBundle>;
    materializeProjection(input: {
        readonly kind: KnowledgeProjectionTargetKind;
        readonly id?: string | undefined;
        readonly limit?: number | undefined;
        readonly filename?: string | undefined;
        readonly knowledgeSpaceId?: string | undefined;
        readonly includeAllSpaces?: boolean | undefined;
    }): Promise<KnowledgeMaterializedProjection>;
    map(input?: KnowledgeMapRenderOptions): Promise<KnowledgeMapResult>;
    reindex(): Promise<{
        status: KnowledgeStatus;
        issues: readonly KnowledgeIssueRecord[];
    }>;
    search(query: string, limit?: number): KnowledgeSearchResult[];
    searchScoped(input: {
        readonly query: string;
        readonly limit?: number | undefined;
        readonly knowledgeSpaceId?: string | undefined;
        readonly includeAllSpaces?: boolean | undefined;
    }): KnowledgeSearchResult[];
    ask(input: {
        readonly query: string;
        readonly limit?: number | undefined;
        readonly mode?: 'concise' | 'standard' | 'detailed' | undefined;
        readonly knowledgeSpaceId?: string | undefined;
        readonly includeSources?: boolean | undefined;
        readonly includeConfidence?: boolean | undefined;
        readonly includeLinkedObjects?: boolean | undefined;
    }): Promise<import("./semantic/types.js").KnowledgeSemanticAnswerResult>;
    buildPacket(task: string, writeScope?: readonly string[], limit?: number, options?: {
        readonly detail?: KnowledgePacketDetail;
        readonly budgetLimit?: number;
    } & KnowledgeSpaceScopeInput): Promise<KnowledgePacket>;
    buildPacketSync(task: string, writeScope?: readonly string[], limit?: number, options?: {
        readonly detail?: KnowledgePacketDetail;
        readonly budgetLimit?: number;
    } & KnowledgeSpaceScopeInput): KnowledgePacket | null;
    buildPromptPacketSync(task: string, writeScope?: readonly string[], limit?: number, options?: {
        readonly detail?: KnowledgePacketDetail;
        readonly budgetLimit?: number;
    } & KnowledgeSpaceScopeInput): string | null;
    buildPromptPacket(task: string, writeScope?: readonly string[], limit?: number, options?: {
        readonly detail?: KnowledgePacketDetail;
        readonly budgetLimit?: number;
    } & KnowledgeSpaceScopeInput): Promise<string | null>;
    listJobs(): readonly KnowledgeJobRecord[];
    getJob(id: string): KnowledgeJobRecord | null;
    saveSchedule(input: {
        readonly id?: string | undefined;
        readonly jobId: string;
        readonly label?: string | undefined;
        readonly enabled?: boolean | undefined;
        readonly schedule: AutomationScheduleDefinition;
        readonly metadata?: Record<string, unknown> | undefined;
    }): Promise<KnowledgeScheduleRecord>;
    deleteSchedule(id: string): Promise<boolean>;
    setScheduleEnabled(id: string, enabled: boolean): Promise<KnowledgeScheduleRecord | null>;
    decideConsolidationCandidate(id: string, decision: 'accept' | 'reject' | 'supersede', input?: {
        readonly decidedBy?: string | undefined;
        readonly memoryClass?: string | undefined;
        readonly scope?: string | undefined;
        readonly detail?: string | undefined;
    }): Promise<KnowledgeConsolidationCandidateRecord>;
    listJobRuns(limit?: number, jobId?: string): readonly KnowledgeJobRunRecord[];
    listRefinementTasks(limit?: number, input?: {
        readonly spaceId?: string | undefined;
        readonly state?: KnowledgeRefinementTaskState | string | undefined;
        readonly subjectKind?: string | undefined;
        readonly subjectId?: string | undefined;
        readonly gapId?: string | undefined;
    }): readonly KnowledgeRefinementTaskRecord[];
    getRefinementTask(id: string): KnowledgeRefinementTaskRecord | null;
    cancelRefinementTask(id: string): Promise<KnowledgeRefinementTaskRecord | null>;
    runRefinement(input?: {
        readonly knowledgeSpaceId?: string | undefined;
        readonly gapIds?: readonly string[] | undefined;
        readonly sourceIds?: readonly string[] | undefined;
        readonly limit?: number | undefined;
        readonly maxRunMs?: number | undefined;
        readonly force?: boolean | undefined;
    }): Promise<import("./semantic/types.js").KnowledgeSemanticSelfImproveResult>;
    runJob(id: string, input?: {
        readonly mode?: KnowledgeJobMode | undefined;
        readonly sourceIds?: readonly string[] | undefined;
        readonly limit?: number | undefined;
    }): Promise<KnowledgeJobRunRecord>;
    private runJobByKind;
    private deferUsage;
    private syncReviewedMemory;
    private dispose;
    lint(): Promise<readonly KnowledgeIssueRecord[]>;
    private emitIfReady;
}
export declare function buildCuratedKnowledgePromptSync(service: Pick<KnowledgeService, 'buildPromptPacketSync'>, task: string, writeScope?: readonly string[]): string | null;
//# sourceMappingURL=service.d.ts.map