UNPKG

@mastra/core

Version:
115 lines • 5.89 kB
/** * Default most estimated tokens one `knowledge_read` or `knowledge_list` result returns; the rest * comes by `from` or `cursor`. Set per Knowledge with `tools.read.maxTokens`. */ export declare const KNOWLEDGE_READ_BODY_TOKENS = 1000; /** * Most estimated tokens of notes, or of mentioning notes, a whole-page read carries inline. Past it * the list is left out with a count, and read on its own with `notes` or `mentionedIn`. */ export declare const KNOWLEDGE_READ_INLINE_TOKENS = 1000; /** Most headings one outline lists. */ export declare const KNOWLEDGE_READ_OUTLINE_ENTRIES = 200; /** Most estimated tokens of headings a first read cut short lists for the part of the body it did not reach. */ export declare const KNOWLEDGE_READ_REST_OUTLINE_TOKENS = 500; /** A markdown heading's section: from its heading line to the next heading at its level or above. */ export interface KnowledgeBodySection { level: number; title: string; /** Character range in the body, heading line included. */ start: number; end: number; } /** Markdown sections by ATX heading, in body order; headings inside fenced code are ignored. */ export declare function knowledgeBodySections(body: string): KnowledgeBodySection[]; /** Each heading with its section's size, for an agent to pick one. */ export declare function knowledgeBodyOutline(body: string): { level: number; title: string; line: number; tokens: number; }[]; /** The section titled `title`: an exact (case-insensitive) title first, else the only title containing it. */ export declare function knowledgeBodySection(body: string, title: string): { section: KnowledgeBodySection; } | { candidates: string[]; }; /** A place in a body: a 1-based line, and optionally a 0-based character column in it. */ export interface KnowledgeLinePosition { line: number; col?: number; } /** * Part of a body by line. Without columns it is whole lines, `start.line` through `end.line`. * `start.col` is the first character it covers and `end.col` the character after its last. */ export interface KnowledgeLineRange { start: KnowledgeLinePosition; end: KnowledgeLinePosition; } /** A body's lines: split on `\n`, a final newline not counting as one more, empty body none. */ export declare class KnowledgeBodyLines { #private; readonly body: string; readonly starts: number[]; constructor(body: string); get count(): number; /** Character offset where line `n`'s text ends, before its newline. */ lineEnd(n: number): number; /** The line holding character `offset`; an offset at a line's end belongs to that line. */ lineAt(offset: number): number; /** Where a range starts, as a body offset; throws when it isn't in the body. */ startOffset(at: KnowledgeLinePosition): number; /** Where a range ends, as a body offset: without a column, the end of that line's text. */ endOffset(at: KnowledgeLinePosition): number; /** The position of a start offset: its line, with a column only when it isn't the line's start. */ startPosition(offset: number): KnowledgeLinePosition; /** The position of an end offset: its line, with a column only when it isn't the line's end. */ endPosition(offset: number): KnowledgeLinePosition; /** Body characters `start` to `end`, each line prefixed with its number: `12│text`. */ numbered(start: number, end: number): string; } /** * What one read returns from body character `start`, up to `limit`: at most `maxTokens` * (default {@link KNOWLEDGE_READ_BODY_TOKENS}), ended at the last whole line that fits. Only a line too long * for one read is cut inside it, never splitting a surrogate pair. `next` is where the rest starts. */ export declare function knowledgeBodyWindow(lines: KnowledgeBodyLines, start: number, limit?: number, maxTokens?: number): { start: number; end: number; next?: number; }; /** A line longer than this shows only the characters around a match. */ export declare const KNOWLEDGE_READ_MATCH_LINE_CHARS = 400; /** * The lines that contain any of `terms` (case-insensitive), from body character `from`, each with * `context` lines before and after, overlapping hits merged. Lines longer than * {@link KNOWLEDGE_READ_MATCH_LINE_CHARS} are never shown whole: a matching one gives the * characters around its first match, a non-matching one is left out. Each part is a body range a * write can take back as it is. */ export declare function knowledgeBodyGrep(lines: KnowledgeBodyLines, terms: string[], context: number, from?: number): Array<{ start: number; end: number; }>; /** * Most estimated tokens of one page chunk the semantic index embeds, page name and description * included. Well under common embedder limits (8,191 for OpenAI's), since the estimate can run low. */ export declare const KNOWLEDGE_EMBED_CHUNK_TOKENS = 2000; /** Estimated tokens each chunk repeats from the end of the one before it. */ export declare const KNOWLEDGE_EMBED_CHUNK_OVERLAP_TOKENS = 150; /** * Splits `body` into pieces of at most `maxTokens` estimated tokens, breaking between paragraphs * and before headings (never inside fenced code unless one block alone is too big), each piece * starting with about `overlapTokens` from the end of the one before. A body that fits is one piece. */ export declare function knowledgeBodyChunks(body: string, maxTokens?: number, overlapTokens?: number): string[]; /** * A long body seen whole at a glance: every heading with its line number, and under each as many * of its first lines as fit in `maxTokens`, shared out evenly; `⋯ lines a–b` marks what is left * out. Undefined when the headings alone don't fit. */ export declare function knowledgeBodySkeleton(lines: KnowledgeBodyLines, headingLines: number[], maxTokens: number): string | undefined; //# sourceMappingURL=page-body.d.ts.map