ktx/packages/context/src/wiki/ports.ts

76 lines
2.2 KiB
TypeScript
Raw Normal View History

2026-05-10 23:51:24 +02:00
import type { KtxFileStorePort } from '../core/file-store.js';
2026-05-10 23:12:26 +02:00
export interface UpsertPageParams {
scope: string;
scopeId: string | null;
pageKey: string;
summary: string;
usageMode: string;
sortOrder: number;
searchText: string;
embedding: number[] | null;
contentHash?: string | null;
sourceRunId?: string | null;
}
feat(context): add warehouse verification tools (#46) * feat(context): add warehouse dialect dispatch * feat(context): read warehouse scan catalog * feat(context): add entity details verification tool * feat(context): add ingest SQL verification tool * feat(context): add raw warehouse discovery tool * feat(context): expose warehouse verification tools to ingest * docs(context): add ingest identifier verification protocol * test(context): guard ingest identifier verification prompts * chore(context): verify warehouse verification tools * docs: add warehouse verification tools plan and spec * fix(context): expose target warehouses to Notion ingest * fix(context): update ingest prompts for warehouse verification tools * fix(context): scope raw schema discovery to allowed connections * fix(context): verify warehouse column display targets * docs: add notion warehouse verification gap closure plan * fix(context): include raw discovery connection names * fix(context): expose warehouse targets for LookML and MetricFlow * fix(context): pass connection config to ingest query executors * fix(cli): enable read-only SQL probes for local ingest * docs: add warehouse verification final v1 closure plan * fix(context): align warehouse sql probe prompt shape * docs: add warehouse verification prompt shape closure plan * test(context): catch connectionless sql execution prompt examples * fix(context): include connection name in sl capture sql example * docs: add warehouse verification sql example closure plan * fix(context): report structured entity detail misses * docs: add warehouse verification structured target miss closure plan * fix: report untracked squash merge conflicts * feat: require ingest verification ledger * fix: stabilize ingest wiki references
2026-05-13 13:43:23 +02:00
export interface KnowledgeIndexPageListing {
id?: string;
page_key: string;
summary: string;
scope: string;
scope_id: string | null;
tags: string[];
}
2026-05-10 23:12:26 +02:00
export interface KnowledgeIndexPort {
upsertPage(params: UpsertPageParams): Promise<void>;
applyDiffTransactional(params: {
runId: string;
upserts: UpsertPageParams[];
deletes: Array<{ scope: string; scopeId: string | null; pageKey: string }>;
}): Promise<void>;
getExistingSearchTexts(
scope: string,
scopeId: string | null,
): Promise<Map<string, { searchText: string; hasEmbedding: boolean }>>;
deleteStale(scope: string, scopeId: string | null, keepKeys: string[]): Promise<number>;
deleteByScope(scope: string, scopeId: string | null): Promise<number>;
deleteByKey(scope: string, scopeId: string | null, pageKey: string): Promise<number>;
2026-05-10 23:12:26 +02:00
findPageByKey(
scope: string,
scopeId: string | null,
pageKey: string,
): Promise<{ id?: string; page_key: string } | null | undefined>;
feat(context): add warehouse verification tools (#46) * feat(context): add warehouse dialect dispatch * feat(context): read warehouse scan catalog * feat(context): add entity details verification tool * feat(context): add ingest SQL verification tool * feat(context): add raw warehouse discovery tool * feat(context): expose warehouse verification tools to ingest * docs(context): add ingest identifier verification protocol * test(context): guard ingest identifier verification prompts * chore(context): verify warehouse verification tools * docs: add warehouse verification tools plan and spec * fix(context): expose target warehouses to Notion ingest * fix(context): update ingest prompts for warehouse verification tools * fix(context): scope raw schema discovery to allowed connections * fix(context): verify warehouse column display targets * docs: add notion warehouse verification gap closure plan * fix(context): include raw discovery connection names * fix(context): expose warehouse targets for LookML and MetricFlow * fix(context): pass connection config to ingest query executors * fix(cli): enable read-only SQL probes for local ingest * docs: add warehouse verification final v1 closure plan * fix(context): align warehouse sql probe prompt shape * docs: add warehouse verification prompt shape closure plan * test(context): catch connectionless sql execution prompt examples * fix(context): include connection name in sl capture sql example * docs: add warehouse verification sql example closure plan * fix(context): report structured entity detail misses * docs: add warehouse verification structured target miss closure plan * fix: report untracked squash merge conflicts * feat: require ingest verification ledger * fix: stabilize ingest wiki references
2026-05-13 13:43:23 +02:00
listPagesForUser(userId: string): Promise<KnowledgeIndexPageListing[]>;
2026-05-10 23:12:26 +02:00
getUserPageCount(userId: string): Promise<number>;
incrementUsageCount(pageIds: string[]): Promise<void>;
searchRRF(
userId: string,
queryEmbedding: number[] | null,
queryText: string,
limit: number,
): Promise<Array<{ pageKey: string; summary: string; rrfScore: number }>>;
}
export interface KnowledgeEventPort {
createEvent(params: {
blockId: string | null;
eventType: string;
actorId: string;
chatId?: string | null;
messageId?: string | null;
payload: Record<string, unknown>;
}): Promise<unknown>;
}
export interface KnowledgeGitDiffPort {
diffNameStatus(
fromSha: string,
toSha: string,
pathPrefix?: string,
): Promise<Array<{ status: string; path: string }>>;
getFileAtCommit(path: string, sha: string): Promise<string>;
}
2026-05-10 23:51:24 +02:00
export type WikiFileStorePort = KtxFileStorePort<WikiFileStorePort>;