import { KnowledgeService, type KnowledgeServiceOptions } from './service.js'; import type { KnowledgeItem } from './store.js'; import type { ItemStore, ItemCreateInput, ItemPatch, ItemListOptions, ItemListResult } from './item-store.js'; import type { KnowledgeProjectInverseRequest, KnowledgeProjectItemBindingRequest, KnowledgeProjectReceiptLookupRequest, KnowledgeProjectRegistrationRequest, KnowledgeProjectResourceKind, KnowledgeProjectResourceListOptions } from './project-links.js'; /** * The unified knowledge-item Store surface, mirrored on the SDK so app code * routes item CRUD through the SAME Store as the CLI and MCP: the on-box * db.json store, or HTTP whenever the shared @hasna/contracts credential chain * resolves a key. No SDK item method touches sqlite or the raw HTTP client * directly — the Store resolves the transport, freshly, per call. */ export interface KnowledgeItemsSdk { /** The resolved Store for this scope (`kind: 'local' | 'api'`). */ readonly store: () => ItemStore; readonly list: (options?: ItemListOptions) => Promise; readonly get: (idOrShort: string) => Promise; readonly create: (input: ItemCreateInput) => Promise; readonly update: (idOrShort: string, patch: ItemPatch) => Promise; readonly delete: (idOrShort: string) => Promise; readonly deleteMany: (idsOrShorts: string[]) => Promise; } export interface KnowledgeProjectLinksSdk { readonly capability: () => ReturnType['capability']>; readonly registerCollection: (request: KnowledgeProjectRegistrationRequest) => ReturnType['registerCollection']>; readonly readCollection: (collectionId: string) => ReturnType['readCollection']>; readonly lookupReceipt: (request: KnowledgeProjectReceiptLookupRequest) => ReturnType['lookupReceipt']>; readonly compensateRegistration: (request: KnowledgeProjectInverseRequest) => ReturnType['compensateRegistration']>; readonly verifyRegistrationInverse: (request: KnowledgeProjectInverseRequest) => ReturnType['verifyRegistrationInverse']>; readonly bindItem: (request: KnowledgeProjectItemBindingRequest) => ReturnType['bindItem']>; readonly readItemBinding: (collectionId: string, itemId: string) => ReturnType['readItemBinding']>; readonly compensateItemBinding: (request: KnowledgeProjectInverseRequest) => ReturnType['compensateItemBinding']>; readonly verifyItemBindingInverse: (request: KnowledgeProjectInverseRequest) => ReturnType['verifyItemBindingInverse']>; readonly listResources: (projectId: string, options?: KnowledgeProjectResourceListOptions) => ReturnType['listProjectResources']>; readonly readResource: (projectId: string, kind: KnowledgeProjectResourceKind, resourceId: string) => ReturnType['readProjectResource']>; readonly readAllResources: (projectId: string, options?: Omit) => ReturnType['readAllProjectResources']>; } export type KnowledgeClientOptions = KnowledgeServiceOptions; export type KnowledgeSetupOptions = Parameters[0]; export type KnowledgeAuthInput = Parameters[0]; export type KnowledgeAskOptions = Omit[0], 'prompt'>; export type KnowledgeSearchOptions = Parameters[0]; export type KnowledgeContextOptions = Parameters[0]; export type KnowledgeAgentContextPackOptions = Parameters[0]; export type KnowledgeWebSearchOptions = Parameters[0]; export type KnowledgeInventoryOptions = Parameters[0]; export type KnowledgeSyncSnapshotOptions = Parameters[0]; export type KnowledgeSyncDoctorOptions = Parameters[0]; export type KnowledgeSyncBundleOptions = Parameters[0]; export type KnowledgeSyncImportOptions = Parameters[0]; export type KnowledgePeerSyncOptions = Parameters[0]; export type KnowledgeRemotePeerSyncOptions = Parameters[0]; export type KnowledgeRulesProvenanceOptions = Parameters[0]; export type KnowledgeAppWikiInitOptions = Parameters[0]; export type KnowledgeAppWikiNoteInput = Parameters[0]; export type KnowledgeAppWikiSourceInput = Parameters[0]; export type KnowledgeAppWikiSearchOptions = Parameters[0]; export type KnowledgeAppWikiQueryOptions = Parameters[0]; export interface KnowledgeAppWikiScopeOptions extends KnowledgeClientOptions { allowGlobal?: boolean; } export interface KnowledgeAppWikiSdk { readonly paths: () => ReturnType; readonly init: (options?: KnowledgeAppWikiInitOptions) => ReturnType; readonly notes: { readonly add: (input: KnowledgeAppWikiNoteInput) => ReturnType; readonly list: (options?: Parameters[0]) => ReturnType; readonly get: (id: string, options?: Parameters[1]) => ReturnType; }; readonly sources: { readonly add: (input: KnowledgeAppWikiSourceInput) => ReturnType; }; readonly search: (options: KnowledgeAppWikiSearchOptions) => ReturnType; readonly query: (options: KnowledgeAppWikiQueryOptions) => ReturnType; } export interface KnowledgeClient { /** * Escape hatch for advanced integrations. Prefer the grouped SDK methods for * app-facing code; this service may expose lower-level operations over time. */ readonly unstable_service: KnowledgeService; readonly paths: () => ReturnType; readonly setup: (options?: KnowledgeSetupOptions) => ReturnType; readonly auth: { readonly status: (env?: Record) => ReturnType; readonly login: (input: KnowledgeAuthInput, env?: Record) => ReturnType; readonly logout: (env?: Record) => ReturnType; }; readonly storage: { readonly status: () => ReturnType; readonly validate: () => ReturnType; readonly migrateLegacyPath: (options?: Parameters[0]) => ReturnType; readonly migrateProjectPath: (options?: Parameters[0]) => ReturnType; readonly mergeLegacyPath: (options?: Parameters[0]) => ReturnType; readonly artifactStore: () => ReturnType; }; readonly sync: { readonly status: () => ReturnType; readonly doctor: (options?: KnowledgeSyncDoctorOptions) => ReturnType; readonly snapshot: (options?: KnowledgeSyncSnapshotOptions) => ReturnType; readonly conflicts: (options?: Parameters[0]) => ReturnType; readonly conflict: (id: string) => ReturnType; readonly proposeConflictResolution: (id: string) => ReturnType; readonly proposeConflictResolutionAi: (options: Parameters[0]) => ReturnType; readonly resolveConflict: (options: Parameters[0]) => ReturnType; readonly machines: () => ReturnType; readonly exportBundle: (options?: KnowledgeSyncBundleOptions) => ReturnType; readonly importBundle: (options: KnowledgeSyncImportOptions) => ReturnType; readonly peer: (options: KnowledgePeerSyncOptions) => ReturnType; readonly remotePeer: (options: KnowledgeRemotePeerSyncOptions) => ReturnType; }; /** * Knowledge-item CRUD routed through the unified Store. Identical behavior to * the `knowledge add/list/get/update/delete` CLI commands over either transport. */ readonly items: KnowledgeItemsSdk; /** Project collection registration, explicit membership, receipts, and complete resource enumeration. */ readonly projectLinks: KnowledgeProjectLinksSdk; /** * Inventory of the knowledge corpus. Routes to the shared API item corpus in * the HTTP API when selected and the on-box sqlite/JSON catalog otherwise, so the SDK never * diverges from the CLI/MCP. Always async. */ readonly inventory: (options?: KnowledgeInventoryOptions) => ReturnType; readonly db: { readonly init: () => ReturnType; readonly stats: () => ReturnType; }; readonly wiki: { readonly init: () => ReturnType; readonly compile: (options?: Parameters[0]) => ReturnType; readonly fileAnswer: (options: Parameters[0]) => ReturnType; readonly lint: () => ReturnType; }; readonly appWiki: KnowledgeAppWikiSdk; readonly ingest: { readonly manifest: (input: string) => ReturnType; readonly source: (sourceRef: string, purpose?: string) => ReturnType; readonly rules: (options?: KnowledgeRulesProvenanceOptions) => ReturnType; }; readonly sources: { readonly resolve: (sourceRef: string, options?: Parameters[1]) => ReturnType; readonly consumeOutbox: (input: string) => ReturnType; }; readonly reindex: { readonly health: (options?: Parameters[0]) => ReturnType; readonly enqueue: (options?: Parameters[0]) => ReturnType; readonly refreshEmbeddings: (options?: Parameters[0]) => ReturnType; }; readonly providers: { readonly status: (env?: Record) => ReturnType; readonly models: () => ReturnType; }; readonly embeddings: { readonly status: () => ReturnType; readonly index: (options?: Parameters[0]) => ReturnType; readonly search: (options: Parameters[0]) => ReturnType; }; readonly search: (options: KnowledgeSearchOptions) => ReturnType; readonly retrieveContext: (options: KnowledgeContextOptions) => ReturnType; readonly contextPack: (options: KnowledgeAgentContextPackOptions) => ReturnType; readonly context: { readonly pack: (options: KnowledgeAgentContextPackOptions) => ReturnType; }; readonly ask: (prompt: string, options?: KnowledgeAskOptions) => ReturnType; readonly build: (prompt: string, options?: KnowledgeAskOptions) => ReturnType; readonly web: { readonly search: (options: KnowledgeWebSearchOptions) => ReturnType; }; } export declare function createKnowledgeClient(options?: KnowledgeClientOptions): KnowledgeClient; export declare const createKnowledgeSdk: typeof createKnowledgeClient; export declare function createAppWikiScope(options?: KnowledgeAppWikiScopeOptions): KnowledgeAppWikiSdk; export declare function openProjectWiki(options?: Omit): KnowledgeAppWikiSdk; export declare function openGlobalWiki(options: Omit & { allowGlobal: true; }): KnowledgeAppWikiSdk;