UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

50 lines • 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.indexFolder = void 0; /** * indexFolder — the one-call version, over the same pieces. * * Pattern: sugar. It composes `indexCorpus` and adds nothing the pieces do not * already do — which is the test a convenience has to pass here: if * it could not be written by a consumer in five lines using the * public API, it is hiding something instead of shortening it. * Role: rag/ layer. * Emits: whatever `indexCorpus` emits. * * The only judgement it adds is the splitter default, and it is the judgement * you would make yourself: a folder of Markdown gets `byHeading` (the document * declares its own sections), anything else gets `byParagraph`. Name a * `splitter` and that guess is not made. * * @example * ```ts * const report = await indexFolder('./docs', { * to: sqliteVectorStore({ file: './corpus.db' }), * embedder: staticEmbedder(), * }); * console.log(`${report.embedded} embedded, ${report.skipped} skipped`); * ``` */ const indexCorpus_js_1 = require("./indexCorpus.js"); const capability_js_1 = require("../memory/store/capability.js"); const byHeading_js_1 = require("./splitters/byHeading.js"); const byParagraph_js_1 = require("./splitters/byParagraph.js"); async function indexFolder(dir, options) { const { to, include, recursive, splitter, ...rest } = options; // `indexCorpus` refuses this too — repeated here only so the message names // the call the reader actually wrote. (0, capability_js_1.assertServesVectors)(to, 'indexFolder'); const looksLikeMarkdown = include === undefined || include.some((e) => e === '.md' || e === '.markdown'); return (0, indexCorpus_js_1.indexCorpus)({ ...rest, source: { dir, ...(include && { include }), ...(recursive !== undefined && { recursive }), }, store: to, splitter: splitter ?? (looksLikeMarkdown ? (0, byHeading_js_1.byHeading)() : (0, byParagraph_js_1.byParagraph)()), }); } exports.indexFolder = indexFolder; //# sourceMappingURL=indexFolder.js.map