UNPKG

@mastra/core

Version:
107 lines • 4.63 kB
import type { KnowledgeStorage } from '../storage/domains/knowledge/base.js'; import type { KnowledgeNote, KnowledgePage, MoveKnowledgePageInput } from '../storage/domains/knowledge/pages.js'; import type { KnowledgeScopeRuntime } from './scope-runtime.js'; import type { KnowledgeSemanticIndex } from './semantic.js'; /** * A page an app writes from outside an agent run, e.g. a doc synced from a docs site. * @experimental */ export interface KnowledgeUpsertPageInput { /** Canonical scope address the page lives in, e.g. `docs:acme`. Created on first write. */ scope: string; /** * Key path below the scope, e.g. `guides/install`. It is the page's identity: writing the same path * again updates that page. Keys can't contain `#` or `%`. A leading, trailing or doubled `/` is * dropped (`guides/` is `guides`). Missing pages along the path are created with their key as name. */ path: string; name: string; /** At most 100 tokens. Left as it is when omitted. */ description?: string; /** Left as it is when omitted. */ body?: string; /** Recorded as the writer. Default `host`. */ author?: string; } /** @experimental */ export interface KnowledgeUpsertPageResult { page: KnowledgePage; /** `unchanged` writes nothing: no new version, no change event, no re-embedding. */ status: 'created' | 'updated' | 'unchanged'; } /** @experimental */ export interface KnowledgeRemovePageInput { scope: string; path: string; author?: string; } /** @experimental */ export interface KnowledgeMovePageInput { /** Scope address and key path of the page to move, as in {@link KnowledgeUpsertPageInput}. */ scope: string; path: string; /** Key path of the new parent in the destination scope. Left out or empty: the top of the scope. */ parent?: string; /** Destination scope address. Default `scope`. Created on first write, like `upsertPage`. */ toScope?: string; /** The page's version as you read it. Default: its current version. */ expectedVersion?: number; author?: string; } /** * A note an app adds to a page from outside an agent run, e.g. a comment synced from a docs site. * @experimental */ export interface KnowledgeAddNoteInput { /** Scope address and key path of the page, as in {@link KnowledgeUpsertPageInput}. */ scope: string; path: string; /** At most 250 tokens. `[[scope#path]]` mentions link to that page; other `[[...]]` stay text. */ text: string; /** When the note's fact happened or applies. */ when?: Date; /** Scope addresses whose readers see the note. Default: the page's scope. */ stamps?: string[]; author?: string; } /** @experimental */ export interface KnowledgeUpdateNoteInput { /** The note's id, from `addNote`. */ id: string; text: string; /** Left as they were when omitted. */ when?: Date; stamps?: string[]; author?: string; } /** @internal */ export interface KnowledgeHostWriter { runtime: KnowledgeScopeRuntime; getStorage(): Promise<KnowledgeStorage>; semantic?: KnowledgeSemanticIndex; warn(message: string): void; } /** @internal */ export declare function upsertKnowledgePage(host: KnowledgeHostWriter, input: KnowledgeUpsertPageInput): Promise<KnowledgeUpsertPageResult>; /** @internal */ export declare function removeKnowledgePage(host: KnowledgeHostWriter, input: KnowledgeRemovePageInput): Promise<KnowledgePage | null>; /** * Moves a page and its subtree under `parentId`, then re-resolves links: the subtree's * `scope#key/key` paths changed, so links by an old path stop resolving and new ones may. The page * keeps its id, notes, pins and vectors (the index holds ids only). Shared by the host and the * `knowledge_page` tool. * @internal */ export declare function moveKnowledgePageAndRelink(storage: KnowledgeStorage, warn: ((message: string) => void) | undefined, input: MoveKnowledgePageInput): Promise<KnowledgePage>; /** @internal */ export declare function moveKnowledgePage(host: KnowledgeHostWriter, input: KnowledgeMovePageInput): Promise<KnowledgePage>; /** @internal */ export declare function addKnowledgeNote(host: KnowledgeHostWriter, input: KnowledgeAddNoteInput): Promise<KnowledgeNote>; /** @internal */ export declare function updateKnowledgeNote(host: KnowledgeHostWriter, input: KnowledgeUpdateNoteInput): Promise<KnowledgeNote>; /** @internal */ export declare function removeKnowledgeNote(host: KnowledgeHostWriter, input: { id: string; author?: string; }): Promise<KnowledgeNote | null>; //# sourceMappingURL=host-writes.d.ts.map