UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

57 lines • 3.01 kB
import type { DocumentTree, TreeUnit } from './types.js'; /** A stored tree without its nodes — what listing and document selection need. */ export interface DocumentTreeHeader { documentId: string; title?: string; description?: string; structure: DocumentTree['structure']; fingerprint: string; unitCount: number; metadata?: Record<string, unknown>; source?: string; builtAt: string; } /** * Where navigation trees live: one tree per document plus the units (pages/sections) its node * ranges point at, so navigation can read a node's text without going back to the source file. * * `filter` has **exactly** the vector stores' semantics (see `VectorStore`): every key must match * the tree's `metadata`, an array value is match-any, and an empty array denies. It is an access * boundary — a navigator given a tenant filter must not read another tenant's tree — so every read * that takes one applies it. `readUnits` takes none: call it only for a tree a filtered `get` just * returned (which is what the navigator does). */ export interface DocumentTreeStore { /** Store (replace) a document's tree and units. */ put(tree: DocumentTree, units: TreeUnit[]): Promise<void>; /** A document's tree, when it exists **and** passes `filter`. */ get(documentId: string, filter?: Record<string, unknown>): Promise<DocumentTree | undefined>; /** The trees of those of `documentIds` that exist and pass `filter` (any order). */ getMany(documentIds: readonly string[], filter?: Record<string, unknown>): Promise<DocumentTree[]>; /** Headers (no nodes) of every tree passing `filter`, or of the listed `documentIds` only. */ list(options?: { filter?: Record<string, unknown>; documentIds?: readonly string[]; limit?: number; }): Promise<DocumentTreeHeader[]>; /** Units `start..end` (inclusive) of a document, in order. */ readUnits(documentId: string, start: number, end: number): Promise<TreeUnit[]>; /** Drop a document's tree and units. Unknown ids are a no-op. */ remove(documentId: string): Promise<void>; } export declare function headerOf(tree: DocumentTree): DocumentTreeHeader; /** An in-process {@link DocumentTreeStore} — tests, and single-process apps with small corpora. */ export declare class MemoryDocumentTreeStore implements DocumentTreeStore { private readonly trees; put(tree: DocumentTree, units: TreeUnit[]): Promise<void>; get(documentId: string, filter?: Record<string, unknown>): Promise<DocumentTree | undefined>; getMany(documentIds: readonly string[], filter?: Record<string, unknown>): Promise<DocumentTree[]>; list(options?: { filter?: Record<string, unknown>; documentIds?: readonly string[]; limit?: number; }): Promise<DocumentTreeHeader[]>; readUnits(documentId: string, start: number, end: number): Promise<TreeUnit[]>; remove(documentId: string): Promise<void>; } //# sourceMappingURL=store.d.ts.map