UNPKG

@adonis-agora/agent

Version:

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

44 lines • 2.76 kB
/** * The `schema` option: put the agent's tables in a database schema other than the connection's (a * Postgres schema, a MySQL database). Every statement the stores issue names the schema itself — * never `SET search_path`, which leaks to other clients' connections behind PgBouncer in * transaction mode. * * Query-builder calls take {@link qualifiedName} (`schema.table`, which knex quotes as two * identifiers); raw SQL takes {@link qualifiedSql} (`"schema"."table"`, turned into backticks on * MySQL by `portableSql` / `forDialect` like every other identifier the statements quote). */ import type { LucidRawRunner } from './lucid.js'; /** * Check a `schema` option: `undefined` passes through (today's behaviour — unqualified names, the * connection's current schema), anything else must be a plain identifier of at most 63 characters. * `where` names the option in the error (`stores.lucid()`, `config/agent.ts`, …). */ export declare function assertSchemaName(schema: unknown, where: string): string | undefined; /** * {@link assertSchemaName}, plus the dialect: a connection without schemas (SQLite) cannot honour * `schema`, so it fails here — at boot — rather than falling back to the main database. A client * whose dialect cannot be told is let through: every statement names the schema anyway. */ export declare function validateSchema(db: unknown, schema: unknown, where: string): string | undefined; /** A table for Lucid's query builder: `schema.table` (knex quotes each part), or the bare table. */ export declare function qualifiedName(table: string, schema: string | undefined): string; /** * A table for raw SQL: `"schema"."table"`, or `"table"` without a schema. Double quotes, like every * identifier in the agent's statements: `portableSql` / `forDialect` swap them for MySQL. */ export declare function qualifiedSql(table: string, schema: string | undefined): string; /** * Does `schema` exist? `pg_namespace` on Postgres (it lists every schema, while * `information_schema.schemata` hides the ones the role has no privilege on), the `SCHEMATA` view on * MySQL. A read: no lock. */ export declare function schemaExists(db: LucidRawRunner, schema: string): Promise<boolean>; /** * Create `schema` when it is missing: `CREATE SCHEMA IF NOT EXISTS` on Postgres, `CREATE DATABASE IF * NOT EXISTS` on MySQL. The catalog is read first, so a role that may use an existing schema but not * create one boots fine. When the role cannot create it, the error names the schema and the grant. * What the stores run before their own DDL when they provision their tables. */ export declare function ensureDatabaseSchema(db: LucidRawRunner, schema: string): Promise<void>; //# sourceMappingURL=db-schema.d.ts.map