@sema-agent/core
Version:
Stateless, task-oriented AI agent core
32 lines (31 loc) • 1.19 kB
TypeScript
/**
* Dependency-free `query` adapters for common DB drivers, to plug into createSqlTool.
*
* These are structurally typed: you pass an already-created (ideally READ-ONLY) client/pool.
* No driver is a dependency of this package — install whichever you use in your app.
*
* Usage:
* import pg from "pg";
* const pool = new pg.Pool({ connectionString: READONLY_URL });
* const tool = createSqlTool({ query: pgQuery(pool), allowTables: ["orders"] });
*/
/** node-postgres (`pg`) Pool/Client. */
export declare function pgQuery(pool: {
query: (text: string) => Promise<{
rows: unknown[];
}>;
}): (sql: string) => Promise<unknown[]>;
/**
* `mysql2/promise` connection or pool.
* Also use this for **TiDB** (MySQL wire-compatible): create a read-only `mysql2` pool
* pointed at your TiDB endpoint and pass it here.
*/
export declare function mysqlQuery(conn: {
query: (sql: string) => Promise<[unknown, unknown]>;
}): (sql: string) => Promise<unknown[]>;
/** `better-sqlite3` database (synchronous). */
export declare function sqliteQuery(db: {
prepare: (sql: string) => {
all: () => unknown[];
};
}): (sql: string) => Promise<unknown[]>;