UNPKG

@mastra/core

Version:
59 lines • 2.69 kB
import type { KnowledgePage, KnowledgeStorage } from '../storage/domains/knowledge/index.js'; import type { ToolAction } from '../tools/index.js'; import { KnowledgeRun } from './run.js'; import type { KnowledgeScopeRuntime } from './scope-runtime.js'; import type { KnowledgeSemanticIndex } from './semantic.js'; /** What the page tools need from their Knowledge. @internal */ export interface KnowledgePageToolHost { runtime: KnowledgeScopeRuntime; getStorage(): Promise<KnowledgeStorage>; /** Set when Knowledge has a vector store and embedder: search is hybrid and writes are embedded. */ semantic?: KnowledgeSemanticIndex; warn?: (message: string) => void; /** Most estimated tokens one read, match or list result returns; defaults to {@link KNOWLEDGE_READ_BODY_TOKENS}. */ maxTokens?: number; } /** Which tools to build. `pins` adds `knowledge_pin`. @internal */ export interface KnowledgePageToolGroups { read: boolean; write: boolean; pins: boolean; } type Tools = Record<string, ToolAction<any, any, any>>; /** One entry of a `knowledge_list` result. */ export interface ListEntry { ref: string; name: string; description?: string; /** 1 for the starting point's children, 2 for theirs, and so on. */ depth: number; /** Readable child pages, plus readable child scopes for a scope. */ children: number; scope?: true; } /** What {@link listKnowledgeTree} found: the entries in tree order, and where the listing stopped. */ export interface KnowledgeTreeListing { /** The starting point's ref; absent when listing the run's own scopes. */ originRef?: string; entries: ListEntry[]; /** More entries at depth 1, for the next call's `cursor` (`s<n>` or `p<store cursor>`). */ nextCursor?: string; /** Deeper levels stopped at `limit` entries. */ truncated: boolean; } /** * The readable page tree under `origin` (or the run's own scopes without one), `depth` levels down * and at most `limit` entries: each with its ref, name and readable child count. A scope's readable * child scopes come before its child pages. Store calls grow with depth, not with entries. */ export declare function listKnowledgeTree(run: KnowledgeRun, { origin, depth, limit, cursor, descriptions, }: { origin?: KnowledgePage; depth: number; limit: number; cursor?: string; descriptions?: boolean; }): Promise<KnowledgeTreeListing>; /** The schema-4 Knowledge tools. @internal */ export declare function buildKnowledgePageTools(host: KnowledgePageToolHost, groups: KnowledgePageToolGroups, onPinChange?: (context: unknown) => void): Tools; export {}; //# sourceMappingURL=page-tools.d.ts.map