UNPKG

@adonis-agora/agent

Version:

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

45 lines • 2.48 kB
import type { LucidRawRunner } from '../../stores/lucid.js'; import { type DocumentTreeHeader, type DocumentTreeStore } from './store.js'; import type { DocumentTree, TreeUnit } from './types.js'; export interface PgDocumentTreeStoreOptions { /** Trees table. Default `agent_rag_trees`. Validated against the identifier regex. */ table?: string; /** Units (page/section text) table. Default `${table}_units`, i.e. `agent_rag_trees_units`. */ unitsTable?: string; /** Unit rows per multi-row `INSERT`. Default 200. */ insertBatchSize?: number; } /** * A Postgres {@link DocumentTreeStore} over Lucid's raw runner (`db` or `db.connection(name)` — the * same structural {@link LucidRawRunner} `PgVectorStore` takes, so `@adonisjs/lucid` stays an * optional peer): one row per tree (header columns, `metadata` as `jsonb` for filtering, the nodes as * `jsonb`) and one row per unit of text. Filters compile through the same builder as `PgVectorStore`'s * — scalar `@>` containment, array match-any, empty array denies — so the filter you pass the vector * store works here unchanged. * * Provision it with the published `create_agent_rag_trees` migration, or {@link ensureSchema} / * {@link schemaStatements}. Needs no extension. Writes run in one transaction when the runner has one. */ export declare class PgDocumentTreeStore implements DocumentTreeStore { protected readonly db: LucidRawRunner; protected readonly table: string; protected readonly unitsTable: string; private readonly insertBatchSize; constructor(db: LucidRawRunner, options?: PgDocumentTreeStoreOptions); /** The idempotent DDL {@link ensureSchema} runs, in order. */ schemaStatements(): string[]; ensureSchema(): Promise<void>; private write; /** Replace the tree and its units (one transaction when the runner has one). */ 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=pg-tree-store.d.ts.map