@agenticmail/enterprise 0.5.508 → 0.5.509
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-heartbeat-SUXHFGH2.js +518 -0
- package/dist/agent-tools-5LDKY7C6.js +14677 -0
- package/dist/agent-tools-R2Q75NQ3.js +9 -0
- package/dist/chunk-6DAMJJG4.js +7790 -0
- package/dist/chunk-BX4RZZQO.js +5563 -0
- package/dist/chunk-MCXOB5TU.js +1728 -0
- package/dist/chunk-TK55CSBH.js +212 -0
- package/dist/chunk-VYVUYSY3.js +26380 -0
- package/dist/chunk-ZW7JLXWZ.js +1386 -0
- package/dist/cli-agent-4WS3WKBR.js +2858 -0
- package/dist/cli-serve-SYUQTWCH.js +322 -0
- package/dist/cli.js +3 -3
- package/dist/connection-manager-XEDVZER6.js +9 -0
- package/dist/index.js +6 -6
- package/dist/routes-HD2C2JEE.js +94 -0
- package/dist/runtime-UMJ4Y7ZI.js +50 -0
- package/dist/server-KLYIHEHS.js +36 -0
- package/dist/setup-BVQ4D3WM.js +20 -0
- package/logs/cloudflared-error.log +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__esm
|
|
3
|
+
} from "./chunk-KFQGP6VL.js";
|
|
4
|
+
|
|
5
|
+
// src/database-access/types.ts
|
|
6
|
+
var DATABASE_LABELS;
|
|
7
|
+
var init_types = __esm({
|
|
8
|
+
"src/database-access/types.ts"() {
|
|
9
|
+
"use strict";
|
|
10
|
+
DATABASE_LABELS = {
|
|
11
|
+
postgresql: "PostgreSQL",
|
|
12
|
+
mysql: "MySQL",
|
|
13
|
+
mariadb: "MariaDB",
|
|
14
|
+
sqlite: "SQLite",
|
|
15
|
+
mongodb: "MongoDB",
|
|
16
|
+
redis: "Redis",
|
|
17
|
+
mssql: "Microsoft SQL Server",
|
|
18
|
+
oracle: "Oracle",
|
|
19
|
+
cockroachdb: "CockroachDB",
|
|
20
|
+
planetscale: "PlanetScale",
|
|
21
|
+
turso: "Turso / LibSQL",
|
|
22
|
+
dynamodb: "AWS DynamoDB",
|
|
23
|
+
supabase: "Supabase",
|
|
24
|
+
neon: "Neon",
|
|
25
|
+
upstash: "Upstash Redis"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// src/database-access/agent-tools.ts
|
|
31
|
+
function jsonResult(data) {
|
|
32
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
33
|
+
}
|
|
34
|
+
function errorResult(msg) {
|
|
35
|
+
return { content: [{ type: "text", text: JSON.stringify({ error: msg }) }] };
|
|
36
|
+
}
|
|
37
|
+
function createDatabaseTools(manager, agentId) {
|
|
38
|
+
const tools = [];
|
|
39
|
+
tools.push({
|
|
40
|
+
name: "db_list_connections",
|
|
41
|
+
description: 'List EXTERNAL database connections (Postgres, MySQL, Supabase, etc.) granted to you by your admin. Use this when asked about any named database like "DateGPT", "production", etc.',
|
|
42
|
+
category: "database",
|
|
43
|
+
risk: "low",
|
|
44
|
+
parameters: { type: "object", properties: {}, required: [] },
|
|
45
|
+
async execute(_toolCallId, _params) {
|
|
46
|
+
const accessList = manager.getAgentAccess(agentId);
|
|
47
|
+
const connections = accessList.filter((a) => a.enabled).map((a) => {
|
|
48
|
+
const conn = manager.getConnection(a.connectionId);
|
|
49
|
+
if (!conn) return null;
|
|
50
|
+
return {
|
|
51
|
+
connectionId: conn.id,
|
|
52
|
+
name: conn.name,
|
|
53
|
+
type: conn.type,
|
|
54
|
+
typeLabel: DATABASE_LABELS[conn.type] || conn.type,
|
|
55
|
+
database: conn.database,
|
|
56
|
+
host: conn.host,
|
|
57
|
+
status: conn.status,
|
|
58
|
+
permissions: a.permissions,
|
|
59
|
+
description: conn.config?.description || conn.description
|
|
60
|
+
};
|
|
61
|
+
}).filter(Boolean);
|
|
62
|
+
if (connections.length === 0) {
|
|
63
|
+
return jsonResult({ connections: [], message: "No external database connections granted. Ask your admin to grant access from the Database Access page." });
|
|
64
|
+
}
|
|
65
|
+
return jsonResult({ connections });
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
tools.push({
|
|
69
|
+
name: "db_query",
|
|
70
|
+
description: "Execute a SQL query on an EXTERNAL database connection granted by your admin. Use db_list_connections first to see available databases and get the connectionId.",
|
|
71
|
+
category: "database",
|
|
72
|
+
risk: "medium",
|
|
73
|
+
sideEffects: ["database_write"],
|
|
74
|
+
parameters: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
connectionId: { type: "string", description: "Database connection ID (from db_list_connections)" },
|
|
78
|
+
sql: { type: "string", description: "SQL query to execute" },
|
|
79
|
+
params: { type: "array", items: { type: "string" }, description: "Query parameters (for parameterized queries)" }
|
|
80
|
+
},
|
|
81
|
+
required: ["connectionId", "sql"]
|
|
82
|
+
},
|
|
83
|
+
async execute(_toolCallId, input) {
|
|
84
|
+
if (!input?.connectionId || !input?.sql) return errorResult("connectionId and sql are required");
|
|
85
|
+
try {
|
|
86
|
+
const result = await manager.executeQuery({
|
|
87
|
+
connectionId: input.connectionId,
|
|
88
|
+
agentId,
|
|
89
|
+
operation: "read",
|
|
90
|
+
sql: input.sql,
|
|
91
|
+
params: input.params
|
|
92
|
+
});
|
|
93
|
+
if (!result.success) {
|
|
94
|
+
return errorResult(result.error || "Query failed");
|
|
95
|
+
}
|
|
96
|
+
return jsonResult({
|
|
97
|
+
rows: result.rows,
|
|
98
|
+
rowCount: result.rowCount,
|
|
99
|
+
affectedRows: result.affectedRows,
|
|
100
|
+
fields: result.fields,
|
|
101
|
+
executionTimeMs: result.executionTimeMs,
|
|
102
|
+
truncated: result.truncated
|
|
103
|
+
});
|
|
104
|
+
} catch (e) {
|
|
105
|
+
return errorResult(e.message || "Query execution failed");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
tools.push({
|
|
110
|
+
name: "db_describe_table",
|
|
111
|
+
description: "Get the schema (columns, types, constraints) of a table in an external database.",
|
|
112
|
+
category: "database",
|
|
113
|
+
risk: "low",
|
|
114
|
+
parameters: {
|
|
115
|
+
type: "object",
|
|
116
|
+
properties: {
|
|
117
|
+
connectionId: { type: "string", description: "Database connection ID" },
|
|
118
|
+
table: { type: "string", description: "Table name" }
|
|
119
|
+
},
|
|
120
|
+
required: ["connectionId", "table"]
|
|
121
|
+
},
|
|
122
|
+
async execute(_toolCallId, input) {
|
|
123
|
+
if (!input?.connectionId || !input?.table) return errorResult("connectionId and table are required");
|
|
124
|
+
const conn = manager.getConnection(input.connectionId);
|
|
125
|
+
if (!conn) return errorResult("Connection not found");
|
|
126
|
+
let sql;
|
|
127
|
+
switch (conn.type) {
|
|
128
|
+
case "postgresql":
|
|
129
|
+
case "cockroachdb":
|
|
130
|
+
case "supabase":
|
|
131
|
+
case "neon":
|
|
132
|
+
sql = `SELECT column_name, data_type, is_nullable, column_default FROM information_schema.columns WHERE table_name = '${input.table.replace(/'/g, "''")}' ORDER BY ordinal_position`;
|
|
133
|
+
break;
|
|
134
|
+
case "mysql":
|
|
135
|
+
case "mariadb":
|
|
136
|
+
case "planetscale":
|
|
137
|
+
sql = `DESCRIBE \`${input.table.replace(/`/g, "``")}\``;
|
|
138
|
+
break;
|
|
139
|
+
case "sqlite":
|
|
140
|
+
case "turso":
|
|
141
|
+
sql = `PRAGMA table_info('${input.table.replace(/'/g, "''")}')`;
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
return errorResult(`Schema inspection not supported for ${conn.type}`);
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const result = await manager.executeQuery({ connectionId: input.connectionId, agentId, operation: "read", sql, _trusted: true });
|
|
148
|
+
if (!result.success) return errorResult(result.error || "Query failed");
|
|
149
|
+
return jsonResult({ columns: result.rows, table: input.table });
|
|
150
|
+
} catch (e) {
|
|
151
|
+
return errorResult(e.message);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
tools.push({
|
|
156
|
+
name: "db_list_tables",
|
|
157
|
+
description: "List all tables in an external database connection.",
|
|
158
|
+
category: "database",
|
|
159
|
+
risk: "low",
|
|
160
|
+
parameters: {
|
|
161
|
+
type: "object",
|
|
162
|
+
properties: {
|
|
163
|
+
connectionId: { type: "string", description: "Database connection ID" }
|
|
164
|
+
},
|
|
165
|
+
required: ["connectionId"]
|
|
166
|
+
},
|
|
167
|
+
async execute(_toolCallId, input) {
|
|
168
|
+
if (!input?.connectionId) return errorResult("connectionId is required");
|
|
169
|
+
const conn = manager.getConnection(input.connectionId);
|
|
170
|
+
if (!conn) return errorResult("Connection not found");
|
|
171
|
+
let sql;
|
|
172
|
+
switch (conn.type) {
|
|
173
|
+
case "postgresql":
|
|
174
|
+
case "cockroachdb":
|
|
175
|
+
case "supabase":
|
|
176
|
+
case "neon":
|
|
177
|
+
sql = `SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_name`;
|
|
178
|
+
break;
|
|
179
|
+
case "mysql":
|
|
180
|
+
case "mariadb":
|
|
181
|
+
case "planetscale":
|
|
182
|
+
sql = "SHOW TABLES";
|
|
183
|
+
break;
|
|
184
|
+
case "sqlite":
|
|
185
|
+
case "turso":
|
|
186
|
+
sql = `SELECT name, type FROM sqlite_master WHERE type IN ('table', 'view') AND name NOT LIKE 'sqlite_%' ORDER BY name`;
|
|
187
|
+
break;
|
|
188
|
+
default:
|
|
189
|
+
return errorResult(`Table listing not supported for ${conn.type}`);
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
const result = await manager.executeQuery({ connectionId: input.connectionId, agentId, operation: "read", sql, _trusted: true });
|
|
193
|
+
if (!result.success) return errorResult(result.error || "Query failed");
|
|
194
|
+
return jsonResult({ tables: result.rows });
|
|
195
|
+
} catch (e) {
|
|
196
|
+
return errorResult(e.message);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return tools;
|
|
201
|
+
}
|
|
202
|
+
var init_agent_tools = __esm({
|
|
203
|
+
"src/database-access/agent-tools.ts"() {
|
|
204
|
+
init_types();
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
export {
|
|
209
|
+
init_types,
|
|
210
|
+
createDatabaseTools,
|
|
211
|
+
init_agent_tools
|
|
212
|
+
};
|