Files
anything-llm/server/utils/agents/aibitat/plugins/sql-agent/list-database.js
Marcello Fitton 4a4378ed99 chore: add ESLint to /server (#5126)
* add eslint config to server

* add break statements to switch case

* add support for browser globals and turn off empty catch blocks

* disable lines with useless try/catch wrappers

* format

* fix no-undef errors

* disbale lines violating no-unsafe-finally

* ignore syncStaticLists.mjs

* use proper null check for creatorId instead of unreachable nullish coalescing

* remove unneeded typescript eslint comment

* make no-unused-private-class-members a warning

* disable line for no-empty-objects

* add new lint script

* fix no-unused-vars violations

* make no-unsued-vars an error

---------

Co-authored-by: shatfield4 <seanhatfield5@gmail.com>
Co-authored-by: Timothy Carambat <rambat1010@gmail.com>
2026-03-05 16:32:45 -08:00

50 lines
1.6 KiB
JavaScript

module.exports.SqlAgentListDatabase = {
name: "sql-list-databases",
plugin: function () {
const { listSQLConnections } = require("./SQLConnectors");
return {
name: "sql-list-databases",
setup(aibitat) {
aibitat.function({
super: aibitat,
name: this.name,
description:
"List all available databases via `list_databases` you currently have access to. Returns a unique string identifier `database_id` that can be used for future calls.",
examples: [
{
prompt: "What databases can you access?",
call: JSON.stringify({}),
},
{
prompt: "What databases can you tell me about?",
call: JSON.stringify({}),
},
{
prompt: "Is there a database named erp-logs you can access?",
call: JSON.stringify({}),
},
],
parameters: {
$schema: "http://json-schema.org/draft-07/schema#",
type: "object",
properties: {},
additionalProperties: false,
},
handler: async function () {
this.super.handlerProps.log(`Using the sql-list-databases tool.`);
this.super.introspect(
`${this.caller}: Checking what are the available databases.`
);
const connections = (await listSQLConnections()).map((conn) => {
const { connectionString: _connectionString, ...rest } = conn;
return rest;
});
return JSON.stringify(connections);
},
});
},
};
},
};