@elizaos/plugin-sql 2.0.0-alpha.8 → 2.0.11-beta.7
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/LICENSE +1 -1
- package/README.md +88 -301
- package/package.json +90 -73
- package/dist/browser/index.browser.js +0 -24304
- package/dist/browser/index.browser.js.map +0 -69
- package/dist/browser/index.d.ts +0 -2
- package/dist/browser/tsconfig.build.tsbuildinfo +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.node.js +0 -21203
- package/dist/node/index.node.js.map +0 -187
- package/dist/node/tsconfig.build.node.tsbuildinfo +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 Shaw Walters and elizaOS Contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,355 +1,142 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @elizaos/plugin-sql
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SQL database adapter plugin for elizaOS — provides persistent storage via PostgreSQL or embedded PGlite (WASM), with Drizzle ORM, automatic schema migrations, and optional Row Level Security.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
# Using bun
|
|
9
8
|
bun add @elizaos/plugin-sql
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
The adapter supports the following vector dimensions:
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
VECTOR_DIMS = {
|
|
18
|
-
SMALL: 384,
|
|
19
|
-
MEDIUM: 512,
|
|
20
|
-
LARGE: 768,
|
|
21
|
-
XL: 1024,
|
|
22
|
-
XXL: 1536,
|
|
23
|
-
XXXL: 3072,
|
|
24
|
-
};
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Important Note: Once an agent is initialized with a specific embedding dimension, it cannot be changed. Attempting to change the dimension will result in an error: "Cannot change embedding dimension for agent"
|
|
28
|
-
|
|
29
|
-
## Features
|
|
11
|
+
## Overview
|
|
30
12
|
|
|
31
|
-
|
|
32
|
-
- Automatic retries with exponential backoff
|
|
33
|
-
- Connection pooling
|
|
34
|
-
- Vector search capabilities
|
|
35
|
-
- Memory management
|
|
36
|
-
- Caching system
|
|
37
|
-
- Room and participant management
|
|
38
|
-
- Goal tracking system
|
|
13
|
+
This plugin registers a `DatabaseAdapter` with the elizaOS agent runtime so that all core runtime persistence (memories, entities, rooms, tasks, cache, logs, relationships, etc.) works against a real SQL backend. On Node/Bun it selects PostgreSQL when `POSTGRES_URL` is set, otherwise falls back to embedded PGlite. In the browser build it always uses PGlite (WASM).
|
|
39
14
|
|
|
40
15
|
## Database Schema
|
|
41
16
|
|
|
42
|
-
The plugin uses
|
|
17
|
+
The plugin uses the following main tables:
|
|
43
18
|
|
|
44
|
-
|
|
19
|
+
- **Agent**: Agent information and configurations
|
|
20
|
+
- **Room / Channel**: Conversation rooms and messaging channels
|
|
21
|
+
- **Participant / ChannelParticipant**: Participants in rooms and channels
|
|
22
|
+
- **Memory**: Agent memories with vector embeddings for semantic search
|
|
23
|
+
- **Embedding**: Vector embeddings for entities
|
|
24
|
+
- **Entity**: Entities agents interact with
|
|
25
|
+
- **Relationship**: Relationships between entities
|
|
26
|
+
- **Component**: Agent components and configurations
|
|
27
|
+
- **Tasks**: Tasks and goals
|
|
28
|
+
- **Log**: System logs
|
|
29
|
+
- **Cache**: Frequently accessed data cache
|
|
30
|
+
- **World**: World settings and configurations
|
|
45
31
|
|
|
46
|
-
|
|
47
|
-
- **Room**: Manages conversation rooms and their settings
|
|
48
|
-
- **Participant**: Tracks participants in rooms
|
|
49
|
-
- **Memory**: Stores agent memories with vector embeddings for semantic search
|
|
50
|
-
- **Embedding**: Manages vector embeddings for various entities
|
|
51
|
-
- **Entity**: Represents entities that agents can interact with
|
|
52
|
-
- **Relationship**: Tracks relationships between entities
|
|
53
|
-
- **Component**: Stores agent components and their configurations
|
|
54
|
-
- **Tasks**: Manages tasks and goals for agents
|
|
55
|
-
- **Log**: Stores system logs
|
|
56
|
-
- **Cache**: Provides a caching mechanism for frequently accessed data
|
|
57
|
-
- **World**: Manages world settings and configurations
|
|
32
|
+
Table definitions live in `src/schema/`.
|
|
58
33
|
|
|
59
|
-
|
|
34
|
+
## Electric Sync (PGlite ↔ Electric Cloud)
|
|
60
35
|
|
|
61
|
-
|
|
36
|
+
When `ELIZA_ELECTRIC_SYNC_URL` and `AGENT_ID` are set, PGlite connects to an Electric sync service and streams real-time updates for all core tables. Each agent syncs only its own rows (filtered by `agent_id` / `id`), preserving per-agent isolation in shared-Neon deployments.
|
|
62
37
|
|
|
63
|
-
|
|
38
|
+
### Local dev with Electric Cloud
|
|
64
39
|
|
|
65
|
-
|
|
66
|
-
async function findDatabaseAdapter(runtime: IAgentRuntime) {
|
|
67
|
-
let adapter = runtime;
|
|
68
|
-
|
|
69
|
-
if (!adapter) {
|
|
70
|
-
const drizzleAdapterPlugin = await import('@elizaos/plugin-sql');
|
|
71
|
-
const drizzleAdapterPluginDefault = drizzleAdapterPlugin.default;
|
|
72
|
-
adapter = drizzleAdapterPluginDefault.adapter;
|
|
73
|
-
if (!adapter) {
|
|
74
|
-
throw new Error('Internal error: No database adapter found for default plugin-sql');
|
|
75
|
-
}
|
|
76
|
-
} else if (!adapter) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
'Multiple database adapters found. You must have no more than one. Adjust your plugins configuration.'
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const adapterInterface = await adapter?.init(runtime);
|
|
83
|
-
return adapterInterface;
|
|
84
|
-
}
|
|
85
|
-
```
|
|
40
|
+
The e2e write-back test (`__tests__/integration/electric-write-back.test.ts`) uses a [Caddy](https://caddyserver.com) reverse proxy to forward shape requests to Electric Cloud with auth. Caddy is the proxy [recommended by Electric](https://electric.ax/docs/sync/guides/troubleshooting#missing-headers).
|
|
86
41
|
|
|
87
|
-
|
|
42
|
+
```bash
|
|
43
|
+
# 1. Set your Electric Cloud credentials (get these from dashboard.electric-sql.cloud)
|
|
44
|
+
export ELECTRIC_CLOUD_SOURCE_ID=svc-xxxxxxxxxxxx
|
|
45
|
+
export ELECTRIC_CLOUD_SECRET=eyJ...
|
|
88
46
|
|
|
89
|
-
|
|
47
|
+
# 2. Start the Caddy proxy
|
|
48
|
+
caddy run --config plugins/plugin-sql/caddy/electric-proxy.Caddyfile
|
|
90
49
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
resetTimeout: 60000,
|
|
95
|
-
halfOpenMaxAttempts: 3,
|
|
96
|
-
maxRetries: 3,
|
|
97
|
-
baseDelay: 1000, // 1 second
|
|
98
|
-
maxDelay: 10000, // 10 seconds
|
|
99
|
-
jitterMax: 1000, // 1 second
|
|
100
|
-
connectionTimeout: 5000 // 5 seconds
|
|
101
|
-
}
|
|
50
|
+
# 3. Run the e2e test
|
|
51
|
+
bun run --cwd plugins/plugin-sql test -- \
|
|
52
|
+
__tests__/integration/electric-write-back.test.ts
|
|
102
53
|
```
|
|
103
54
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
- PostgreSQL with vector extension installed
|
|
107
|
-
- Node.js or Bun (≥1.2.2)
|
|
55
|
+
The Caddyfile at `plugins/plugin-sql/caddy/electric-proxy.Caddyfile` forwards every incoming request to `api.electric-sql.cloud` with auth query params appended.
|
|
108
56
|
|
|
109
57
|
## Environment Variables
|
|
110
58
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
59
|
+
| Variable | Required | Default | Effect |
|
|
60
|
+
|----------|----------|---------|--------|
|
|
61
|
+
| `POSTGRES_URL` | No | — | PostgreSQL connection string. When absent, PGlite is used. |
|
|
62
|
+
| `PGLITE_DATA_DIR` | No | `.eliza/.elizadb` | Directory (or `idb://` URL) for PGlite data storage. |
|
|
63
|
+
| `ELIZA_ELECTRIC_SYNC_URL` | No | — | Base URL of Electric sync service (e.g. `http://localhost:3001` via Caddy). |
|
|
64
|
+
| `AGENT_ID` | Conditional | — | UUID of the agent. Required when `ELIZA_ELECTRIC_SYNC_URL` is set (per-agent WHERE filter). |
|
|
65
|
+
| `ELIZA_CLOUD_WRITE_BASE_URL` | No | — | Write-back cloud endpoint for forwarding local PGlite writes to Postgres. |
|
|
66
|
+
| `ELIZA_CLOUD_SERVICE_KEY` | No | — | Service key for authenticating write-back requests. |
|
|
67
|
+
| `ELECTRIC_CLOUD_SOURCE_ID` | Test-only | — | Electric Cloud source ID (consumed by Caddy, not the runtime). |
|
|
68
|
+
| `ELECTRIC_CLOUD_SECRET` | Test-only | — | Electric Cloud JWT secret (consumed by Caddy, not the runtime). |
|
|
69
|
+
| `ELIZA_PGLITE_DISABLE_EXTENSIONS` | No | `false` | Set to `1` to disable PGlite extensions (vector, live, fuzzystrmatch, Electric sync). |
|
|
70
|
+
| `ENABLE_DATA_ISOLATION` | No | `false` | When `true`, enables PostgreSQL Row Level Security per-server isolation. |
|
|
71
|
+
| `ELIZA_SERVER_ID` | Conditional | — | Required when `ENABLE_DATA_ISOLATION=true`; becomes the RLS server UUID. |
|
|
72
|
+
| `ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS` | No | `false` | Allow column drops and other destructive schema changes at startup. |
|
|
73
|
+
| `NODE_ENV` | No | `development` | `production` disables verbose migration logging and tightens safety checks. |
|
|
74
|
+
|
|
75
|
+
Settings are read via `runtime.getSetting(key)` inside `plugin.init`.
|
|
118
76
|
|
|
119
|
-
##
|
|
120
|
-
|
|
121
|
-
Default pool configuration:
|
|
77
|
+
## Vector Dimensions
|
|
122
78
|
|
|
123
79
|
```typescript
|
|
124
|
-
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
80
|
+
VECTOR_DIMS = {
|
|
81
|
+
SMALL: 384,
|
|
82
|
+
MEDIUM: 512,
|
|
83
|
+
LARGE: 768,
|
|
84
|
+
XL: 1024,
|
|
85
|
+
XXL: 1536,
|
|
86
|
+
XXXL: 3072,
|
|
87
|
+
};
|
|
129
88
|
```
|
|
130
89
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
ElizaOS v1.0.0 introduces **dynamic runtime migrations** - automatic schema management that runs at startup without manual intervention. Plugins can define their schemas and the system handles all migrations automatically.
|
|
134
|
-
|
|
135
|
-
### TLDR: What Changed?
|
|
136
|
-
|
|
137
|
-
**Before (v0.x):** Manual migrations with `drizzle-kit generate` → `drizzle-kit push` → restart
|
|
138
|
-
**Now (v1.0.0):** Define schema in plugin → Start agent → Migrations run automatically ✨
|
|
90
|
+
Once an agent is initialized with a specific embedding dimension, it cannot be changed without a new agent or manual DB surgery.
|
|
139
91
|
|
|
140
|
-
|
|
92
|
+
## Runtime Migrations
|
|
141
93
|
|
|
142
|
-
-
|
|
143
|
-
- **Plugin Isolation**: Each plugin gets its own schema namespace
|
|
144
|
-
- **Safety First**: Destructive changes blocked by default in production
|
|
145
|
-
- **Concurrent Safety**: Built-in locks prevent race conditions
|
|
146
|
-
- **Rollback Protection**: All migrations run in transactions
|
|
147
|
-
|
|
148
|
-
### How It Works
|
|
149
|
-
|
|
150
|
-
1. **Plugin defines schema** using Drizzle ORM:
|
|
94
|
+
Plugins export a `schema` object; `DatabaseMigrationService` diffs the schema against the live DB at startup and runs migrations automatically. No manual `drizzle-kit generate` / `drizzle-kit push` step is needed in normal development.
|
|
151
95
|
|
|
152
96
|
```typescript
|
|
153
|
-
// In your plugin
|
|
154
|
-
import { pgTable, text, uuid } from 'drizzle-orm/pg-core';
|
|
155
|
-
|
|
156
|
-
export const myTable = pgTable('my_table', {
|
|
157
|
-
id: uuid('id').primaryKey(),
|
|
158
|
-
name: text('name').notNull(),
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Export schema in your plugin
|
|
97
|
+
// In your plugin
|
|
162
98
|
export const plugin = {
|
|
163
|
-
name:
|
|
164
|
-
schema: schema, //
|
|
165
|
-
// ...
|
|
99
|
+
name: "@your-org/plugin-name",
|
|
100
|
+
schema: schema, // Drizzle schema object
|
|
101
|
+
// ...
|
|
166
102
|
};
|
|
167
103
|
```
|
|
168
104
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
[RuntimeMigrator] Starting migration for plugin: @your-org/plugin-name
|
|
173
|
-
[RuntimeMigrator] Executing 2 SQL statements...
|
|
174
|
-
[RuntimeMigrator] Migration completed successfully
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
3. **Automatic safety checks**:
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
# Destructive changes are blocked
|
|
181
|
-
[RuntimeMigrator] Destructive migration blocked
|
|
182
|
-
[RuntimeMigrator] Destructive operations detected:
|
|
183
|
-
[RuntimeMigrator] - Column "email" will be dropped from table "users"
|
|
184
|
-
[RuntimeMigrator] To proceed:
|
|
185
|
-
[RuntimeMigrator] 1. Set ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true
|
|
186
|
-
[RuntimeMigrator] 2. Or use { force: true } option
|
|
187
|
-
```
|
|
105
|
+
Destructive changes (column drops, type changes) are blocked by default. Set `ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true` to allow them.
|
|
188
106
|
|
|
189
|
-
|
|
107
|
+
## Connection Management
|
|
190
108
|
|
|
191
|
-
|
|
109
|
+
Both `PostgresConnectionManager` and `PGliteClientManager` are stored under `Symbol.for("elizaos.plugin-sql.global-singletons")` on `globalThis`. This prevents multiple pools when the module is imported from multiple paths in the same process. Do not construct manager instances directly — always go through `createDatabaseAdapter()`.
|
|
192
110
|
|
|
193
|
-
|
|
194
|
-
# Allow destructive migrations (drops, type changes)
|
|
195
|
-
ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true
|
|
196
|
-
|
|
197
|
-
# Development vs Production
|
|
198
|
-
NODE_ENV=production # Stricter checks, verbose off by default
|
|
199
|
-
NODE_ENV=development # More permissive, verbose on
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
Or programmatically:
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
await databaseAdapter.runPluginMigrations(plugins, {
|
|
206
|
-
verbose: true, // Show SQL statements
|
|
207
|
-
force: true, // Allow destructive changes
|
|
208
|
-
dryRun: true, // Preview without applying
|
|
209
|
-
});
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Transitioning from Manual Migrations
|
|
213
|
-
|
|
214
|
-
If you have existing manual Drizzle migrations:
|
|
215
|
-
|
|
216
|
-
1. **Keep existing migrations** - They remain compatible
|
|
217
|
-
2. **Add schema to plugin** - Export your Drizzle schema
|
|
218
|
-
3. **First run** - Runtime migrator detects current state
|
|
219
|
-
4. **Future changes** - Just update schema and restart
|
|
220
|
-
|
|
221
|
-
Example transition:
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
// Before: Manual migrations
|
|
225
|
-
// 1. Edit schema
|
|
226
|
-
// 2. Run: bunx drizzle-kit generate
|
|
227
|
-
// 3. Run: bunx drizzle-kit push
|
|
228
|
-
// 4. Restart agent
|
|
229
|
-
|
|
230
|
-
// After: Runtime migrations
|
|
231
|
-
// 1. Edit schema in plugin
|
|
232
|
-
// 2. Restart agent (migrations run automatically)
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Schema Namespacing
|
|
236
|
-
|
|
237
|
-
Plugins automatically get namespaced schemas for isolation:
|
|
238
|
-
|
|
239
|
-
- `@elizaos/plugin-sql` → Uses `public` schema (core tables)
|
|
240
|
-
- `@your-org/plugin-name` → Uses `your_org_plugin_name` schema
|
|
241
|
-
- Prevents table name conflicts between plugins
|
|
242
|
-
- Clean separation of concerns
|
|
243
|
-
|
|
244
|
-
To use a custom schema:
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
import { pgSchema } from 'drizzle-orm/pg-core';
|
|
248
|
-
|
|
249
|
-
const mySchema = pgSchema('my_custom_schema');
|
|
250
|
-
export const myTable = mySchema.table('my_table', {
|
|
251
|
-
// ... columns
|
|
252
|
-
});
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Debugging Migrations
|
|
256
|
-
|
|
257
|
-
Check migration status:
|
|
258
|
-
|
|
259
|
-
```typescript
|
|
260
|
-
const migrator = migrationService.getMigrator();
|
|
261
|
-
const status = await migrator.getStatus('@your-org/plugin-name');
|
|
262
|
-
console.log(status);
|
|
263
|
-
// {
|
|
264
|
-
// hasRun: true,
|
|
265
|
-
// lastMigration: { hash: "...", timestamp: ... },
|
|
266
|
-
// journal: [...],
|
|
267
|
-
// snapshots: 3
|
|
268
|
-
// }
|
|
269
|
-
```
|
|
111
|
+
## Database Pool Configuration
|
|
270
112
|
|
|
271
|
-
|
|
113
|
+
Default Postgres pool configuration (`src/pg/manager.ts`):
|
|
272
114
|
|
|
273
115
|
```typescript
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
116
|
+
{
|
|
117
|
+
max: 20,
|
|
118
|
+
min: 2,
|
|
119
|
+
idleTimeoutMillis: 30000,
|
|
120
|
+
connectionTimeoutMillis: 5000,
|
|
121
|
+
keepAlive: true,
|
|
122
|
+
keepAliveInitialDelayMillis: 10000
|
|
277
123
|
}
|
|
278
124
|
```
|
|
279
125
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
The plugin supports two database backends with automatic migration support:
|
|
126
|
+
## Retry Configuration
|
|
283
127
|
|
|
284
|
-
|
|
285
|
-
2. **PGlite**: Embedded database for development/testing
|
|
286
|
-
|
|
287
|
-
Both use identical migration systems - develop locally with PGlite, deploy to PostgreSQL.
|
|
288
|
-
|
|
289
|
-
### Troubleshooting
|
|
290
|
-
|
|
291
|
-
**"Destructive migration blocked"**
|
|
292
|
-
|
|
293
|
-
- Set `ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true` for development
|
|
294
|
-
- For production, review changes carefully before enabling
|
|
295
|
-
|
|
296
|
-
**"Migration already in progress"**
|
|
297
|
-
|
|
298
|
-
- Another instance is running migrations
|
|
299
|
-
- System will wait for lock automatically
|
|
300
|
-
|
|
301
|
-
**"No changes detected"**
|
|
302
|
-
|
|
303
|
-
- Schema matches database state
|
|
304
|
-
- No migration needed
|
|
305
|
-
|
|
306
|
-
**Manual migration needed?**
|
|
307
|
-
|
|
308
|
-
- Use standard Drizzle Kit for complex scenarios:
|
|
309
|
-
```bash
|
|
310
|
-
bunx drizzle-kit generate
|
|
311
|
-
bunx drizzle-kit migrate
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
## Clean Shutdown
|
|
315
|
-
|
|
316
|
-
The adapter implements cleanup handlers for:
|
|
317
|
-
|
|
318
|
-
- SIGINT
|
|
319
|
-
- SIGTERM
|
|
320
|
-
- beforeExit
|
|
321
|
-
|
|
322
|
-
These ensure proper closing of database connections when the application shuts down.
|
|
323
|
-
|
|
324
|
-
## Implementation Details
|
|
325
|
-
|
|
326
|
-
### Connection Management
|
|
327
|
-
|
|
328
|
-
The plugin uses a global singleton pattern to manage database connections. This approach ensures that:
|
|
329
|
-
|
|
330
|
-
1. **Single Connection Per Process**: Only one connection manager instance exists per Node.js process, regardless of how many times the package is imported or initialized.
|
|
331
|
-
|
|
332
|
-
2. **Resource Efficiency**: Prevents multiple connection pools to the same database, which could lead to resource exhaustion.
|
|
333
|
-
|
|
334
|
-
3. **Consistent State**: Ensures all parts of the application share the same database connection state.
|
|
335
|
-
|
|
336
|
-
4. **Proper Cleanup**: Facilitates proper cleanup of database connections during application shutdown, preventing connection leaks.
|
|
337
|
-
|
|
338
|
-
This pattern is particularly important in monorepo setups or when the package is used by multiple modules within the same process. The implementation uses JavaScript Symbols to create a global registry that persists across module boundaries.
|
|
128
|
+
`BaseDrizzleAdapter` retries failed operations with exponential backoff and jitter (`src/base.ts`):
|
|
339
129
|
|
|
340
130
|
```typescript
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
globalSymbols[GLOBAL_SINGLETONS] = {};
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// Reuse existing managers or create new ones when needed
|
|
350
|
-
if (!globalSingletons.postgresConnectionManager) {
|
|
351
|
-
globalSingletons.postgresConnectionManager = new PostgresConnectionManager(config.postgresUrl);
|
|
131
|
+
{
|
|
132
|
+
maxRetries: 3,
|
|
133
|
+
baseDelay: 1000,
|
|
134
|
+
maxDelay: 10000,
|
|
135
|
+
jitterMax: 1000
|
|
352
136
|
}
|
|
353
137
|
```
|
|
354
138
|
|
|
355
|
-
|
|
139
|
+
## Requirements
|
|
140
|
+
|
|
141
|
+
- Node.js or Bun
|
|
142
|
+
- PostgreSQL with vector extension (for Postgres mode)
|
package/package.json
CHANGED
|
@@ -1,97 +1,114 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-sql",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11-beta.7",
|
|
4
|
+
"description": "",
|
|
4
5
|
"type": "module",
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://github.com/elizaos-plugins/plugin-sql"
|
|
11
|
-
},
|
|
12
|
-
"publishConfig": {
|
|
13
|
-
"access": "public"
|
|
14
|
-
},
|
|
15
|
-
"browser": "dist/browser/index.browser.js",
|
|
6
|
+
"main": "src/dist/index.js",
|
|
7
|
+
"types": "src/dist/index.d.ts",
|
|
16
8
|
"exports": {
|
|
17
9
|
"./package.json": "./package.json",
|
|
18
10
|
".": {
|
|
19
|
-
"types": "./
|
|
11
|
+
"types": "./src/dist/index.node.d.ts",
|
|
12
|
+
"eliza-source": {
|
|
13
|
+
"types": "./src/index.node.ts",
|
|
14
|
+
"import": "./src/index.node.ts",
|
|
15
|
+
"default": "./src/index.node.ts"
|
|
16
|
+
},
|
|
17
|
+
"bun": {
|
|
18
|
+
"types": "./src/dist/index.node.d.ts",
|
|
19
|
+
"import": "./src/dist/node/index.node.js",
|
|
20
|
+
"default": "./src/dist/node/index.node.js"
|
|
21
|
+
},
|
|
20
22
|
"browser": {
|
|
21
|
-
"types": "./dist/
|
|
22
|
-
"import": "./dist/browser/index.browser.js",
|
|
23
|
-
"default": "./dist/browser/index.browser.js"
|
|
23
|
+
"types": "./src/dist/index.d.ts",
|
|
24
|
+
"import": "./src/dist/browser/index.browser.js",
|
|
25
|
+
"default": "./src/dist/browser/index.browser.js"
|
|
24
26
|
},
|
|
25
27
|
"node": {
|
|
26
|
-
"types": "./dist/
|
|
27
|
-
"import": "./dist/node/index.node.js",
|
|
28
|
-
"default": "./dist/node/index.node.js"
|
|
28
|
+
"types": "./src/dist/index.d.ts",
|
|
29
|
+
"import": "./src/dist/node/index.node.js",
|
|
30
|
+
"default": "./src/dist/node/index.node.js"
|
|
29
31
|
},
|
|
32
|
+
"import": "./src/dist/index.js",
|
|
33
|
+
"default": "./src/dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./drizzle": {
|
|
36
|
+
"types": "./src/dist/drizzle/index.d.ts",
|
|
30
37
|
"bun": {
|
|
31
|
-
"types": "./dist/
|
|
32
|
-
"
|
|
38
|
+
"types": "./src/dist/drizzle/index.d.ts",
|
|
39
|
+
"import": "./src/dist/drizzle/index.js",
|
|
40
|
+
"default": "./src/dist/drizzle/index.js"
|
|
33
41
|
},
|
|
34
|
-
"
|
|
42
|
+
"import": "./src/dist/drizzle/index.js",
|
|
43
|
+
"default": "./src/dist/drizzle/index.js"
|
|
35
44
|
},
|
|
36
|
-
"./
|
|
37
|
-
"types": "./dist/
|
|
38
|
-
"
|
|
39
|
-
|
|
45
|
+
"./schema": {
|
|
46
|
+
"types": "./src/dist/schema/index.d.ts",
|
|
47
|
+
"bun": {
|
|
48
|
+
"types": "./src/dist/schema/index.d.ts",
|
|
49
|
+
"import": "./src/dist/schema/index.js",
|
|
50
|
+
"default": "./src/dist/schema/index.js"
|
|
51
|
+
},
|
|
52
|
+
"import": "./src/dist/schema/index.js",
|
|
53
|
+
"default": "./src/dist/schema/index.js"
|
|
40
54
|
},
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
55
|
+
"./*.css": "./dist/*.css",
|
|
56
|
+
"./*": {
|
|
57
|
+
"types": "./dist/*.d.ts",
|
|
58
|
+
"import": "./dist/*.js",
|
|
59
|
+
"default": "./dist/*.js"
|
|
45
60
|
}
|
|
46
61
|
},
|
|
47
|
-
"sideEffects": false,
|
|
48
62
|
"files": [
|
|
49
|
-
"dist",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
63
|
+
"src/dist",
|
|
64
|
+
"README.md",
|
|
65
|
+
"dist"
|
|
52
66
|
],
|
|
67
|
+
"keywords": [],
|
|
68
|
+
"author": "elizaOS",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"repository": {
|
|
71
|
+
"type": "git",
|
|
72
|
+
"url": "https://github.com/elizaos-plugins/plugin-sql"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"build": "cd src && bun run build.ts",
|
|
76
|
+
"dev": "cd src && bun --hot build.ts",
|
|
77
|
+
"test": "cd src && vitest run",
|
|
78
|
+
"typecheck": "tsc --noEmit -p src/tsconfig.json",
|
|
79
|
+
"lint": "cd src && bun run lint",
|
|
80
|
+
"lint:check": "cd src && bun run lint:check",
|
|
81
|
+
"clean": "rm -rf src/dist .turbo",
|
|
82
|
+
"format": "cd src && bun run format",
|
|
83
|
+
"format:check": "cd src && bun run format:check",
|
|
84
|
+
"test:e2e": "node ../../packages/app-core/scripts/run-local-plugin-live-smoke.mjs",
|
|
85
|
+
"test:live": "bun run test:e2e"
|
|
86
|
+
},
|
|
53
87
|
"dependencies": {
|
|
54
|
-
"@electric-sql/pglite": "^0.
|
|
55
|
-
"@
|
|
56
|
-
"@neondatabase/serverless": "^1.0
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"uuid": "^13.0.0",
|
|
62
|
-
"ws": "^8.19.0"
|
|
88
|
+
"@electric-sql/pglite": "^0.4.0",
|
|
89
|
+
"@electric-sql/pglite-sync": "0.5.6",
|
|
90
|
+
"@neondatabase/serverless": "^1.1.0",
|
|
91
|
+
"drizzle-orm": "0.45.2",
|
|
92
|
+
"pg": "^8.16.3",
|
|
93
|
+
"uuid": "^14.0.0",
|
|
94
|
+
"ws": "^8.18.3"
|
|
63
95
|
},
|
|
64
96
|
"devDependencies": {
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"@types/node": "^25.0.
|
|
68
|
-
"@types/pg": "^8.15.
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"typescript
|
|
97
|
+
"@biomejs/biome": "^2.4.14",
|
|
98
|
+
"@types/bun": "^1.3.5",
|
|
99
|
+
"@types/node": "^25.0.3",
|
|
100
|
+
"@types/pg": "^8.15.2",
|
|
101
|
+
"@types/ws": "^8.18.1",
|
|
102
|
+
"dotenv": "^17.2.3",
|
|
103
|
+
"drizzle-kit": "^0.31.8",
|
|
104
|
+
"typescript": "^6.0.3",
|
|
105
|
+
"vitest": "^4.0.0"
|
|
73
106
|
},
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"dev": "bun run build.ts --watch",
|
|
77
|
-
"migrate:generate": "drizzle-kit generate",
|
|
78
|
-
"migrate": "drizzle-kit migrate",
|
|
79
|
-
"lint": "eslint . && prettier --write .",
|
|
80
|
-
"lint:check": "eslint .",
|
|
81
|
-
"clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json *.tsbuildinfo",
|
|
82
|
-
"format": "prettier --write .",
|
|
83
|
-
"format:check": "prettier --check ./src",
|
|
84
|
-
"test": "bun run test:unit && bun run test:integration",
|
|
85
|
-
"test:unit": "bun test src/__tests__/unit/",
|
|
86
|
-
"test:integration": "bash scripts/run-integration-tests.sh",
|
|
87
|
-
"test:integration:postgres": "bash scripts/run-integration-tests.sh --postgres",
|
|
88
|
-
"test:migration": "bun test src/__tests__/migration/",
|
|
89
|
-
"test:migration:postgres": "bun test src/__tests__/migration/ --serial",
|
|
90
|
-
"test:e2e:upgrade": "bash src/__tests__/migration/e2e/run-upgrade-test.sh",
|
|
91
|
-
"test:watch": "bun test --watch",
|
|
92
|
-
"test:coverage": "bun test --coverage",
|
|
93
|
-
"build:clean": "rm -rf dist",
|
|
94
|
-
"lint:fix": "eslint . --fix"
|
|
107
|
+
"peerDependencies": {
|
|
108
|
+
"@elizaos/core": "2.0.11-beta.7"
|
|
95
109
|
},
|
|
96
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "cdbc876f793d96073d7eb0d09715a031ce0cd32e",
|
|
111
|
+
"publishConfig": {
|
|
112
|
+
"access": "public"
|
|
113
|
+
}
|
|
97
114
|
}
|