@elizaos/plugin-sql 2.0.0-beta.1 → 2.0.3-beta.3

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.
Files changed (35) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +87 -304
  3. package/package.json +24 -12
  4. package/src/dist/base.d.ts +22 -5
  5. package/src/dist/browser/index.browser.js +4719 -333
  6. package/src/dist/browser/index.browser.js.map +24 -20
  7. package/src/dist/cjs/index.node.cjs +4689 -278
  8. package/src/dist/cjs/index.node.cjs.map +27 -22
  9. package/src/dist/index.d.ts +2 -2
  10. package/src/dist/index.node.d.ts +40 -7
  11. package/src/dist/migration-service.d.ts +2 -2
  12. package/src/dist/node/index.node.js +4638 -225
  13. package/src/dist/node/index.node.js.map +27 -22
  14. package/src/dist/pg/adapter.d.ts +4 -4
  15. package/src/dist/pg/sslmode.d.ts +6 -0
  16. package/src/dist/pglite/adapter.d.ts +44 -5
  17. package/src/dist/pglite/manager.d.ts +185 -4
  18. package/src/dist/runtime-migrator/drizzle-adapters/database-introspector.d.ts +1 -1
  19. package/src/dist/runtime-migrator/drizzle-adapters/diff-calculator.d.ts +1 -1
  20. package/src/dist/runtime-migrator/drizzle-adapters/snapshot-generator.d.ts +1 -1
  21. package/src/dist/runtime-migrator/drizzle-adapters/sql-generator.d.ts +2 -2
  22. package/src/dist/runtime-migrator/extension-manager.d.ts +1 -1
  23. package/src/dist/runtime-migrator/index.d.ts +8 -8
  24. package/src/dist/runtime-migrator/runtime-migrator.d.ts +2 -2
  25. package/src/dist/runtime-migrator/storage/journal-storage.d.ts +1 -1
  26. package/src/dist/runtime-migrator/storage/migration-tracker.d.ts +1 -1
  27. package/src/dist/runtime-migrator/storage/snapshot-storage.d.ts +1 -1
  28. package/src/dist/schema/agent.d.ts +2 -2
  29. package/src/dist/schema/approvalRequests.d.ts +1 -1
  30. package/src/dist/schema/embedding.d.ts +22 -1
  31. package/src/dist/schema/index.d.ts +35 -35
  32. package/src/dist/schema/types.d.ts +2 -2
  33. package/src/dist/stores/connectorAccount.store.d.ts +1 -1
  34. package/src/dist/stores/types.d.ts +2 -2
  35. package/src/dist/write-back/index.d.ts +56 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shaw Walters and elizaOS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,359 +1,142 @@
1
- # DrizzleDatabaseAdapter
1
+ # @elizaos/plugin-sql
2
2
 
3
- A PostgreSQL database adapter built with Drizzle ORM for the elizaOS ecosystem.
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
- ## Vector Dimensions
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
- - Circuit breaker pattern for database failures
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 a structured schema with the following main tables:
17
+ The plugin uses the following main tables:
43
18
 
44
- ### Core Tables
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
- - **Agent**: Stores agent information and configurations
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
- Each table is defined using Drizzle ORM schema definitions in the `src/schema` directory. The schema is designed to support the elizaOS ecosystem's requirements for agent-based systems.
34
+ ## Electric Sync (PGlite Electric Cloud)
60
35
 
61
- ## Usage
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
- The adapter is typically used as part of the elizaOS runtime:
38
+ ### Local dev with Electric Cloud
64
39
 
65
- ```typescript
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(
75
- "Internal error: No database adapter found for default plugin-sql",
76
- );
77
- }
78
- } else if (!adapter) {
79
- throw new Error(
80
- "Multiple database adapters found. You must have no more than one. Adjust your plugins configuration.",
81
- );
82
- }
83
-
84
- const adapterInterface = await adapter?.init(runtime);
85
- return adapterInterface;
86
- }
87
- ```
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).
88
41
 
89
- ## Error Handling Configuration
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...
90
46
 
91
- The adapter implements the following error handling configurations:
47
+ # 2. Start the Caddy proxy
48
+ caddy run --config plugins/plugin-sql/caddy/electric-proxy.Caddyfile
92
49
 
93
- ```typescript
94
- {
95
- failureThreshold: 5,
96
- resetTimeout: 60000,
97
- halfOpenMaxAttempts: 3,
98
- maxRetries: 3,
99
- baseDelay: 1000, // 1 second
100
- maxDelay: 10000, // 10 seconds
101
- jitterMax: 1000, // 1 second
102
- connectionTimeout: 5000 // 5 seconds
103
- }
50
+ # 3. Run the e2e test
51
+ bun run --cwd plugins/plugin-sql test -- \
52
+ __tests__/integration/electric-write-back.test.ts
104
53
  ```
105
54
 
106
- ## Requirements
107
-
108
- - PostgreSQL with vector extension installed
109
- - 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.
110
56
 
111
57
  ## Environment Variables
112
58
 
113
- The plugin uses the following environment variables:
114
-
115
- - `POSTGRES_URL`: Connection string for PostgreSQL database (e.g., `postgresql://user:password@localhost:5432/dbname`)
116
- - If not provided, the plugin will use PGlite as a fallback
117
- - `PGLITE_DATA_DIR`: (Optional) Directory for PGlite data storage (default: `./pglite`)
118
-
119
- These variables should be defined in a `.env` file at the root of your project.
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`.
120
76
 
121
- ## Database Pool Configuration
122
-
123
- Default pool configuration:
77
+ ## Vector Dimensions
124
78
 
125
79
  ```typescript
126
- {
127
- max: 20,
128
- idleTimeoutMillis: 30000,
129
- connectionTimeoutMillis: 5000
130
- }
80
+ VECTOR_DIMS = {
81
+ SMALL: 384,
82
+ MEDIUM: 512,
83
+ LARGE: 768,
84
+ XL: 1024,
85
+ XXL: 1536,
86
+ XXXL: 3072,
87
+ };
131
88
  ```
132
89
 
133
- ## Migration Support
134
-
135
- 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.
136
-
137
- ### TLDR: What Changed?
138
-
139
- **Before (v0.x):** Manual migrations with `drizzle-kit generate` → `drizzle-kit push` → restart
140
- **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.
141
91
 
142
- ### Key Features
92
+ ## Runtime Migrations
143
93
 
144
- - **Zero-Config Migrations**: No more manual migration commands
145
- - **Plugin Isolation**: Each plugin gets its own schema namespace
146
- - **Safety First**: Destructive changes blocked by default in production
147
- - **Concurrent Safety**: Built-in locks prevent race conditions
148
- - **Rollback Protection**: All migrations run in transactions
149
-
150
- ### How It Works
151
-
152
- 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.
153
95
 
154
96
  ```typescript
155
- // In your plugin's schema.ts
156
- import { pgTable, text, uuid } from "drizzle-orm/pg-core";
157
-
158
- export const myTable = pgTable("my_table", {
159
- id: uuid("id").primaryKey(),
160
- name: text("name").notNull(),
161
- });
162
-
163
- // Export schema in your plugin
97
+ // In your plugin
164
98
  export const plugin = {
165
99
  name: "@your-org/plugin-name",
166
- schema: schema, // Your Drizzle schema object
167
- // ... rest of plugin
100
+ schema: schema, // Drizzle schema object
101
+ // ...
168
102
  };
169
103
  ```
170
104
 
171
- 2. **Runtime detects changes** at startup:
172
-
173
- ```bash
174
- [RuntimeMigrator] Starting migration for plugin: @your-org/plugin-name
175
- [RuntimeMigrator] Executing 2 SQL statements...
176
- [RuntimeMigrator] Migration completed successfully
177
- ```
178
-
179
- 3. **Automatic safety checks**:
180
-
181
- ```bash
182
- # Destructive changes are blocked
183
- [RuntimeMigrator] Destructive migration blocked
184
- [RuntimeMigrator] Destructive operations detected:
185
- [RuntimeMigrator] - Column "email" will be dropped from table "users"
186
- [RuntimeMigrator] To proceed:
187
- [RuntimeMigrator] 1. Set ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true
188
- [RuntimeMigrator] 2. Or use { force: true } option
189
- ```
105
+ Destructive changes (column drops, type changes) are blocked by default. Set `ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true` to allow them.
190
106
 
191
- ### Migration Controls
107
+ ## Connection Management
192
108
 
193
- Control migration behavior via environment variables:
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()`.
194
110
 
195
- ```bash
196
- # Allow destructive migrations (drops, type changes)
197
- ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true
198
-
199
- # Development vs Production
200
- NODE_ENV=production # Stricter checks, verbose off by default
201
- NODE_ENV=development # More permissive, verbose on
202
- ```
203
-
204
- Or programmatically:
205
-
206
- ```typescript
207
- await databaseAdapter.runPluginMigrations(plugins, {
208
- verbose: true, // Show SQL statements
209
- force: true, // Allow destructive changes
210
- dryRun: true, // Preview without applying
211
- });
212
- ```
213
-
214
- ### Transitioning from Manual Migrations
215
-
216
- If you have existing manual Drizzle migrations:
217
-
218
- 1. **Keep existing migrations** - They remain compatible
219
- 2. **Add schema to plugin** - Export your Drizzle schema
220
- 3. **First run** - Runtime migrator detects current state
221
- 4. **Future changes** - Just update schema and restart
222
-
223
- Example transition:
224
-
225
- ```typescript
226
- // Before: Manual migrations
227
- // 1. Edit schema
228
- // 2. Run: bunx drizzle-kit generate
229
- // 3. Run: bunx drizzle-kit push
230
- // 4. Restart agent
231
-
232
- // After: Runtime migrations
233
- // 1. Edit schema in plugin
234
- // 2. Restart agent (migrations run automatically)
235
- ```
236
-
237
- ### Schema Namespacing
238
-
239
- Plugins automatically get namespaced schemas for isolation:
240
-
241
- - `@elizaos/plugin-sql` → Uses `public` schema (core tables)
242
- - `@your-org/plugin-name` → Uses `your_org_plugin_name` schema
243
- - Prevents table name conflicts between plugins
244
- - Clean separation of concerns
245
-
246
- To use a custom schema:
247
-
248
- ```typescript
249
- import { pgSchema } from "drizzle-orm/pg-core";
250
-
251
- const mySchema = pgSchema("my_custom_schema");
252
- export const myTable = mySchema.table("my_table", {
253
- // ... columns
254
- });
255
- ```
256
-
257
- ### Debugging Migrations
258
-
259
- Check migration status:
260
-
261
- ```typescript
262
- const migrator = migrationService.getMigrator();
263
- const status = await migrator.getStatus("@your-org/plugin-name");
264
- console.log(status);
265
- // {
266
- // hasRun: true,
267
- // lastMigration: { hash: "...", timestamp: ... },
268
- // journal: [...],
269
- // snapshots: 3
270
- // }
271
- ```
111
+ ## Database Pool Configuration
272
112
 
273
- Preview changes without applying:
113
+ Default Postgres pool configuration (`src/pg/manager.ts`):
274
114
 
275
115
  ```typescript
276
- const check = await migrator.checkMigration("@your-org/plugin-name", schema);
277
- if (check?.hasDataLoss) {
278
- console.log("Warning: Destructive changes:", check.warnings);
116
+ {
117
+ max: 20,
118
+ min: 2,
119
+ idleTimeoutMillis: 30000,
120
+ connectionTimeoutMillis: 5000,
121
+ keepAlive: true,
122
+ keepAliveInitialDelayMillis: 10000
279
123
  }
280
124
  ```
281
125
 
282
- ### Database Support
283
-
284
- The plugin supports two database backends with automatic migration support:
126
+ ## Retry Configuration
285
127
 
286
- 1. **PostgreSQL**: Production-ready with full feature support
287
- 2. **PGlite**: Embedded database for development/testing
288
-
289
- Both use identical migration systems - develop locally with PGlite, deploy to PostgreSQL.
290
-
291
- ### Troubleshooting
292
-
293
- **"Destructive migration blocked"**
294
-
295
- - Set `ELIZA_ALLOW_DESTRUCTIVE_MIGRATIONS=true` for development
296
- - For production, review changes carefully before enabling
297
-
298
- **"Migration already in progress"**
299
-
300
- - Another instance is running migrations
301
- - System will wait for lock automatically
302
-
303
- **"No changes detected"**
304
-
305
- - Schema matches database state
306
- - No migration needed
307
-
308
- **Manual migration needed?**
309
-
310
- - Use standard Drizzle Kit for complex scenarios:
311
- ```bash
312
- bunx drizzle-kit generate
313
- bunx drizzle-kit migrate
314
- ```
315
-
316
- ## Clean Shutdown
317
-
318
- The adapter implements cleanup handlers for:
319
-
320
- - SIGINT
321
- - SIGTERM
322
- - beforeExit
323
-
324
- These ensure proper closing of database connections when the application shuts down.
325
-
326
- ## Implementation Details
327
-
328
- ### Connection Management
329
-
330
- The plugin uses a global singleton pattern to manage database connections. This approach ensures that:
331
-
332
- 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.
333
-
334
- 2. **Resource Efficiency**: Prevents multiple connection pools to the same database, which could lead to resource exhaustion.
335
-
336
- 3. **Consistent State**: Ensures all parts of the application share the same database connection state.
337
-
338
- 4. **Proper Cleanup**: Facilitates proper cleanup of database connections during application shutdown, preventing connection leaks.
339
-
340
- 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`):
341
129
 
342
130
  ```typescript
343
- // Example of the singleton pattern implementation
344
- const GLOBAL_SINGLETONS = Symbol.for("@elizaos/plugin-sql/global-singletons");
345
-
346
- // Store managers in a global symbol registry
347
- if (!globalSymbols[GLOBAL_SINGLETONS]) {
348
- globalSymbols[GLOBAL_SINGLETONS] = {};
349
- }
350
-
351
- // Reuse existing managers or create new ones when needed
352
- if (!globalSingletons.postgresConnectionManager) {
353
- globalSingletons.postgresConnectionManager = new PostgresConnectionManager(
354
- config.postgresUrl,
355
- );
131
+ {
132
+ maxRetries: 3,
133
+ baseDelay: 1000,
134
+ maxDelay: 10000,
135
+ jitterMax: 1000
356
136
  }
357
137
  ```
358
138
 
359
- This approach is especially critical for PGlite connections, which require careful management to ensure proper shutdown and prevent resource leaks.
139
+ ## Requirements
140
+
141
+ - Node.js or Bun
142
+ - PostgreSQL with vector extension (for Postgres mode)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-sql",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.3-beta.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/dist/index.js",
@@ -9,10 +9,15 @@
9
9
  "./package.json": "./package.json",
10
10
  ".": {
11
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
+ },
12
17
  "bun": {
13
- "types": "./src/index.ts",
14
- "import": "./src/index.ts",
15
- "default": "./src/index.ts"
18
+ "types": "./src/dist/index.node.d.ts",
19
+ "import": "./src/dist/node/index.node.js",
20
+ "default": "./src/dist/node/index.node.js"
16
21
  },
17
22
  "browser": {
18
23
  "types": "./src/dist/index.d.ts",
@@ -30,9 +35,9 @@
30
35
  "./drizzle": {
31
36
  "types": "./src/dist/drizzle/index.d.ts",
32
37
  "bun": {
33
- "types": "./src/drizzle/index.ts",
34
- "import": "./src/drizzle/index.ts",
35
- "default": "./src/drizzle/index.ts"
38
+ "types": "./src/dist/drizzle/index.d.ts",
39
+ "import": "./src/dist/drizzle/index.js",
40
+ "default": "./src/dist/drizzle/index.js"
36
41
  },
37
42
  "import": "./src/dist/drizzle/index.js",
38
43
  "default": "./src/dist/drizzle/index.js"
@@ -40,12 +45,18 @@
40
45
  "./schema": {
41
46
  "types": "./src/dist/schema/index.d.ts",
42
47
  "bun": {
43
- "types": "./src/schema/index.ts",
44
- "import": "./src/schema/index.ts",
45
- "default": "./src/schema/index.ts"
48
+ "types": "./src/dist/schema/index.d.ts",
49
+ "import": "./src/dist/schema/index.js",
50
+ "default": "./src/dist/schema/index.js"
46
51
  },
47
52
  "import": "./src/dist/schema/index.js",
48
53
  "default": "./src/dist/schema/index.js"
54
+ },
55
+ "./*.css": "./dist/*.css",
56
+ "./*": {
57
+ "types": "./dist/*.d.ts",
58
+ "import": "./dist/*.js",
59
+ "default": "./dist/*.js"
49
60
  }
50
61
  },
51
62
  "files": [
@@ -75,6 +86,7 @@
75
86
  },
76
87
  "dependencies": {
77
88
  "@electric-sql/pglite": "^0.4.0",
89
+ "@electric-sql/pglite-sync": "0.5.6",
78
90
  "@neondatabase/serverless": "^1.1.0",
79
91
  "drizzle-orm": "0.45.2",
80
92
  "pg": "^8.16.3",
@@ -93,9 +105,9 @@
93
105
  "vitest": "^4.0.0"
94
106
  },
95
107
  "peerDependencies": {
96
- "@elizaos/core": "2.0.0-beta.1"
108
+ "@elizaos/core": "2.0.3-beta.3"
97
109
  },
98
- "gitHead": "05d4ca11d769db8c7f54a722ee24b2ce2b951543",
110
+ "gitHead": "f54b0f4eaed317d59fa7dbcdce20f4cdb0734420",
99
111
  "publishConfig": {
100
112
  "access": "public"
101
113
  }
@@ -1,4 +1,4 @@
1
- import { type Agent, type AgentRunSummaryResult, type AppendConnectorAccountAuditEventParams, type Component, type ConnectorAccountAuditEventRecord, type ConnectorAccountCredentialRefRecord, type ConnectorAccountRecord, type ConnectorOwnerBindingLookup, type ConnectorOwnerBindingRecord, type ConsumeOAuthFlowStateParams, type CreateOAuthFlowStateParams, DatabaseAdapter, type DeleteConnectorAccountParams, type EntitiesForRoomsResult, type Entity, type GetConnectorAccountCredentialRefParams, type GetConnectorAccountParams, type IDatabaseAdapter, type JsonValue, type ListConnectorAccountCredentialRefsParams, type ListConnectorAccountsParams, type Log, type LogBody, type Memory, type MemoryMetadata, type Metadata, type OAuthFlowRecord, type PairingAllowlistEntry, type PairingAllowlistsResult, type PairingChannel, type PairingRequest, type PairingRequestsResult, type Participant, type ParticipantsForRoomsResult, type ParticipantUpdateFields, type ParticipantUserState, type PatchOp, type Relationship, type Room, type RunStatus, type SetConnectorAccountCredentialRefParams, type Task, type UpsertConnectorAccountParams, type UUID, type World } from "@elizaos/core";
1
+ import { type AccessContext, type Agent, type AgentRunSummaryResult, type AppendConnectorAccountAuditEventParams, type Component, type ConnectorAccountAuditEventRecord, type ConnectorAccountCredentialRefRecord, type ConnectorAccountRecord, type ConnectorOwnerBindingLookup, type ConnectorOwnerBindingRecord, type ConsumeOAuthFlowStateParams, type CreateOAuthFlowStateParams, DatabaseAdapter, type DeleteConnectorAccountParams, type EntitiesForRoomsResult, type Entity, type GetConnectorAccountCredentialRefParams, type GetConnectorAccountParams, type IDatabaseAdapter, type JsonValue, type ListConnectorAccountCredentialRefsParams, type ListConnectorAccountsParams, type Log, type LogBody, type Memory, type MemoryMetadata, type Metadata, type OAuthFlowRecord, type PairingAllowlistEntry, type PairingAllowlistsResult, type PairingChannel, type PairingRequest, type PairingRequestsResult, type Participant, type ParticipantsForRoomsResult, type ParticipantUpdateFields, type ParticipantUserState, type PatchOp, type Relationship, type Room, type RunStatus, type SetConnectorAccountCredentialRefParams, type Task, type UpsertConnectorAccountParams, type UUID, type World } from "@elizaos/core";
2
2
  interface GetOAuthFlowStateParams {
3
3
  state?: string;
4
4
  stateHash?: string;
@@ -39,10 +39,10 @@ type CountMemoriesParams = {
39
39
  agentId?: UUID;
40
40
  metadata?: Record<string, unknown>;
41
41
  };
42
- import type { DatabaseMigrationService } from "./migration-service";
43
- import { type EmbeddingDimensionColumn } from "./schema/embedding";
42
+ import type { DatabaseMigrationService } from "./migration-service.js";
43
+ import { type EmbeddingDimensionColumn } from "./schema/embedding.js";
44
44
  import { ConnectorAccountStore, type ListConnectorAccountAuditEventsParams } from "./stores/connectorAccount.store";
45
- import type { DrizzleDatabase } from "./types";
45
+ import type { DrizzleDatabase } from "./types.js";
46
46
  export declare abstract class BaseDrizzleAdapter extends DatabaseAdapter<DrizzleDatabase> {
47
47
  protected readonly maxRetries: number;
48
48
  protected readonly baseDelay: number;
@@ -50,6 +50,7 @@ export declare abstract class BaseDrizzleAdapter extends DatabaseAdapter<Drizzle
50
50
  protected readonly jitterMax: number;
51
51
  protected embeddingDimension: EmbeddingDimensionColumn;
52
52
  protected migrationService?: DatabaseMigrationService;
53
+ private migrationRunPromise;
53
54
  private _connectorAccountStore?;
54
55
  protected getConnectorAccountStore(): ConnectorAccountStore;
55
56
  protected abstract withDatabase<T>(operation: () => Promise<T>): Promise<T>;
@@ -255,6 +256,7 @@ export declare abstract class BaseDrizzleAdapter extends DatabaseAdapter<Drizzle
255
256
  getMemories(params: {
256
257
  entityId?: UUID;
257
258
  agentId?: UUID;
259
+ limit?: number;
258
260
  count?: number;
259
261
  offset?: number;
260
262
  unique?: boolean;
@@ -263,6 +265,14 @@ export declare abstract class BaseDrizzleAdapter extends DatabaseAdapter<Drizzle
263
265
  end?: number;
264
266
  roomId?: UUID;
265
267
  worldId?: UUID;
268
+ /**
269
+ * When `false`, skip fetching/materializing the embedding vector. List and
270
+ * browse callers discard embeddings, so fetching the 384-float column for
271
+ * every row (via the embeddingTable join) is pure waste. Defaults to `true`
272
+ * (embeddings included) to preserve existing behavior.
273
+ */
274
+ includeEmbedding?: boolean;
275
+ accessContext?: AccessContext;
266
276
  }): Promise<Memory[]>;
267
277
  /**
268
278
  * Asynchronously retrieves memories from the database based on the provided parameters.
@@ -276,6 +286,7 @@ export declare abstract class BaseDrizzleAdapter extends DatabaseAdapter<Drizzle
276
286
  roomIds: UUID[];
277
287
  tableName: string;
278
288
  limit?: number;
289
+ accessContext?: AccessContext;
279
290
  }): Promise<Memory[]>;
280
291
  /**
281
292
  * Asynchronously retrieves a memory by its unique identifier.
@@ -391,6 +402,7 @@ export declare abstract class BaseDrizzleAdapter extends DatabaseAdapter<Drizzle
391
402
  roomId?: UUID;
392
403
  worldId?: UUID;
393
404
  entityId?: UUID;
405
+ accessContext?: AccessContext;
394
406
  }): Promise<Memory[]>;
395
407
  /**
396
408
  * Asynchronously searches for memories in the database based on the provided parameters.
@@ -709,6 +721,11 @@ export declare abstract class BaseDrizzleAdapter extends DatabaseAdapter<Drizzle
709
721
  count?: number;
710
722
  tableName?: string;
711
723
  }): Promise<Memory[]>;
724
+ getMemoriesByServerId(params: {
725
+ serverId: UUID;
726
+ count?: number;
727
+ tableName?: string;
728
+ }): Promise<Memory[]>;
712
729
  deleteRoomsByWorldId(worldId: UUID): Promise<void>;
713
730
  /**
714
731
  * Creates a new message server in the central database
@@ -1013,7 +1030,7 @@ export declare abstract class BaseDrizzleAdapter extends DatabaseAdapter<Drizzle
1013
1030
  upsertComponents(components: Component[], _options?: {
1014
1031
  entityContext?: UUID;
1015
1032
  }): Promise<void>;
1016
- patchComponents(_updates: Array<{
1033
+ patchComponents(updates: Array<{
1017
1034
  componentId: UUID;
1018
1035
  ops: PatchOp[];
1019
1036
  }>, _options?: {