@elizaos/plugin-sql 2.0.0-alpha.8 → 2.0.0-beta.1
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/README.md +24 -20
- package/package.json +79 -74
- package/src/dist/base.d.ts +1152 -0
- package/src/dist/browser/index.browser.d.ts +2 -0
- package/{dist → src/dist}/browser/index.browser.js +7492 -5015
- package/src/dist/browser/index.browser.js.map +72 -0
- package/src/dist/browser/index.d.ts +2 -0
- package/src/dist/cjs/index.d.ts +2 -0
- package/src/dist/cjs/index.node.cjs +9154 -0
- package/src/dist/cjs/index.node.cjs.map +70 -0
- package/src/dist/cjs/index.node.d.cts +2 -0
- package/src/dist/connector-credential-store.d.ts +48 -0
- package/src/dist/drizzle/index.d.ts +1 -0
- package/src/dist/drizzle/index.js +1 -0
- package/src/dist/index.d.ts +4 -0
- package/src/dist/index.js +2 -0
- package/src/dist/index.node.d.ts +20 -0
- package/src/dist/migration-service.d.ts +17 -0
- package/src/dist/migrations.d.ts +15 -0
- package/src/dist/node/index.d.ts +2 -0
- package/src/dist/node/index.node.d.ts +2 -0
- package/src/dist/node/index.node.js +9175 -0
- package/src/dist/node/index.node.js.map +70 -0
- package/src/dist/pg/adapter.d.ts +42 -0
- package/src/dist/pg/manager.d.ts +17 -0
- package/src/dist/pglite/adapter.d.ts +24 -0
- package/src/dist/pglite/errors.d.ts +20 -0
- package/src/dist/pglite/manager.d.ts +32 -0
- package/src/dist/rls.d.ts +13 -0
- package/src/dist/runtime-migrator/crypto-utils.d.ts +25 -0
- package/src/dist/runtime-migrator/drizzle-adapters/database-introspector.d.ts +58 -0
- package/src/dist/runtime-migrator/drizzle-adapters/diff-calculator.d.ts +77 -0
- package/src/dist/runtime-migrator/drizzle-adapters/snapshot-generator.d.ts +21 -0
- package/src/dist/runtime-migrator/drizzle-adapters/sql-generator.d.ts +38 -0
- package/src/dist/runtime-migrator/extension-manager.d.ts +6 -0
- package/src/dist/runtime-migrator/index.d.ts +8 -0
- package/src/dist/runtime-migrator/runtime-migrator.d.ts +95 -0
- package/src/dist/runtime-migrator/schema-transformer.d.ts +18 -0
- package/src/dist/runtime-migrator/storage/journal-storage.d.ts +10 -0
- package/src/dist/runtime-migrator/storage/migration-tracker.d.ts +13 -0
- package/src/dist/runtime-migrator/storage/snapshot-storage.d.ts +9 -0
- package/src/dist/runtime-migrator/types.d.ts +157 -0
- package/src/dist/schema/agent.d.ts +344 -0
- package/src/dist/schema/approvalRequests.d.ts +277 -0
- package/src/dist/schema/authAuditEvent.d.ts +153 -0
- package/src/dist/schema/authBootstrapJti.d.ts +49 -0
- package/src/dist/schema/authIdentity.d.ts +121 -0
- package/src/dist/schema/authOwnerBinding.d.ts +168 -0
- package/src/dist/schema/authOwnerLoginToken.d.ts +122 -0
- package/src/dist/schema/authSession.d.ts +225 -0
- package/src/dist/schema/cache.d.ts +97 -0
- package/src/dist/schema/channel.d.ts +177 -0
- package/src/dist/schema/channelParticipant.d.ts +41 -0
- package/src/dist/schema/component.d.ts +163 -0
- package/src/dist/schema/connectorAccounts.d.ts +981 -0
- package/src/dist/schema/embedding.d.ts +204 -0
- package/src/dist/schema/entity.d.ts +125 -0
- package/src/dist/schema/entityIdentity.d.ts +577 -0
- package/src/dist/schema/index.d.ts +35 -0
- package/src/dist/schema/index.js +1 -0
- package/src/dist/schema/log.d.ts +114 -0
- package/src/dist/schema/longTermMemories.d.ts +254 -0
- package/src/dist/schema/memory.d.ts +185 -0
- package/src/dist/schema/memoryAccessLogs.d.ts +109 -0
- package/src/dist/schema/message.d.ts +194 -0
- package/src/dist/schema/messageServer.d.ts +126 -0
- package/src/dist/schema/messageServerAgent.d.ts +41 -0
- package/src/dist/schema/pairingAllowlist.d.ts +113 -0
- package/src/dist/schema/pairingRequest.d.ts +147 -0
- package/src/dist/schema/participant.d.ts +114 -0
- package/src/dist/schema/relationship.d.ts +156 -0
- package/src/dist/schema/room.d.ts +195 -0
- package/src/dist/schema/server.d.ts +64 -0
- package/src/dist/schema/sessionSummaries.d.ts +273 -0
- package/src/dist/schema/tasks.d.ts +225 -0
- package/src/dist/schema/types.d.ts +68 -0
- package/src/dist/schema/world.d.ts +114 -0
- package/src/dist/services/advanced-memory-storage.d.ts +36 -0
- package/src/dist/stores/connectorAccount.store.d.ts +64 -0
- package/src/dist/stores/types.d.ts +25 -0
- package/src/dist/types.d.ts +13 -0
- package/src/dist/utils/string-to-uuid.d.ts +2 -0
- package/src/dist/utils.d.ts +4 -0
- package/src/dist/utils.node.d.ts +4 -0
- package/LICENSE +0 -21
- 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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DrizzleDatabaseAdapter
|
|
2
2
|
|
|
3
|
-
A PostgreSQL database adapter built with Drizzle ORM for the
|
|
3
|
+
A PostgreSQL database adapter built with Drizzle ORM for the elizaOS ecosystem.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -56,26 +56,28 @@ The plugin uses a structured schema with the following main tables:
|
|
|
56
56
|
- **Cache**: Provides a caching mechanism for frequently accessed data
|
|
57
57
|
- **World**: Manages world settings and configurations
|
|
58
58
|
|
|
59
|
-
Each table is defined using Drizzle ORM schema definitions in the `src/schema` directory. The schema is designed to support the
|
|
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.
|
|
60
60
|
|
|
61
61
|
## Usage
|
|
62
62
|
|
|
63
|
-
The adapter is typically used as part of the
|
|
63
|
+
The adapter is typically used as part of the elizaOS runtime:
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
async function findDatabaseAdapter(runtime: IAgentRuntime) {
|
|
67
67
|
let adapter = runtime;
|
|
68
68
|
|
|
69
69
|
if (!adapter) {
|
|
70
|
-
const drizzleAdapterPlugin = await import(
|
|
70
|
+
const drizzleAdapterPlugin = await import("@elizaos/plugin-sql");
|
|
71
71
|
const drizzleAdapterPluginDefault = drizzleAdapterPlugin.default;
|
|
72
72
|
adapter = drizzleAdapterPluginDefault.adapter;
|
|
73
73
|
if (!adapter) {
|
|
74
|
-
throw new Error(
|
|
74
|
+
throw new Error(
|
|
75
|
+
"Internal error: No database adapter found for default plugin-sql",
|
|
76
|
+
);
|
|
75
77
|
}
|
|
76
78
|
} else if (!adapter) {
|
|
77
79
|
throw new Error(
|
|
78
|
-
|
|
80
|
+
"Multiple database adapters found. You must have no more than one. Adjust your plugins configuration.",
|
|
79
81
|
);
|
|
80
82
|
}
|
|
81
83
|
|
|
@@ -130,7 +132,7 @@ Default pool configuration:
|
|
|
130
132
|
|
|
131
133
|
## Migration Support
|
|
132
134
|
|
|
133
|
-
|
|
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.
|
|
134
136
|
|
|
135
137
|
### TLDR: What Changed?
|
|
136
138
|
|
|
@@ -151,16 +153,16 @@ ElizaOS v1.0.0 introduces **dynamic runtime migrations** - automatic schema mana
|
|
|
151
153
|
|
|
152
154
|
```typescript
|
|
153
155
|
// In your plugin's schema.ts
|
|
154
|
-
import { pgTable, text, uuid } from
|
|
156
|
+
import { pgTable, text, uuid } from "drizzle-orm/pg-core";
|
|
155
157
|
|
|
156
|
-
export const myTable = pgTable(
|
|
157
|
-
id: uuid(
|
|
158
|
-
name: text(
|
|
158
|
+
export const myTable = pgTable("my_table", {
|
|
159
|
+
id: uuid("id").primaryKey(),
|
|
160
|
+
name: text("name").notNull(),
|
|
159
161
|
});
|
|
160
162
|
|
|
161
163
|
// Export schema in your plugin
|
|
162
164
|
export const plugin = {
|
|
163
|
-
name:
|
|
165
|
+
name: "@your-org/plugin-name",
|
|
164
166
|
schema: schema, // Your Drizzle schema object
|
|
165
167
|
// ... rest of plugin
|
|
166
168
|
};
|
|
@@ -244,10 +246,10 @@ Plugins automatically get namespaced schemas for isolation:
|
|
|
244
246
|
To use a custom schema:
|
|
245
247
|
|
|
246
248
|
```typescript
|
|
247
|
-
import { pgSchema } from
|
|
249
|
+
import { pgSchema } from "drizzle-orm/pg-core";
|
|
248
250
|
|
|
249
|
-
const mySchema = pgSchema(
|
|
250
|
-
export const myTable = mySchema.table(
|
|
251
|
+
const mySchema = pgSchema("my_custom_schema");
|
|
252
|
+
export const myTable = mySchema.table("my_table", {
|
|
251
253
|
// ... columns
|
|
252
254
|
});
|
|
253
255
|
```
|
|
@@ -258,7 +260,7 @@ Check migration status:
|
|
|
258
260
|
|
|
259
261
|
```typescript
|
|
260
262
|
const migrator = migrationService.getMigrator();
|
|
261
|
-
const status = await migrator.getStatus(
|
|
263
|
+
const status = await migrator.getStatus("@your-org/plugin-name");
|
|
262
264
|
console.log(status);
|
|
263
265
|
// {
|
|
264
266
|
// hasRun: true,
|
|
@@ -271,9 +273,9 @@ console.log(status);
|
|
|
271
273
|
Preview changes without applying:
|
|
272
274
|
|
|
273
275
|
```typescript
|
|
274
|
-
const check = await migrator.checkMigration(
|
|
276
|
+
const check = await migrator.checkMigration("@your-org/plugin-name", schema);
|
|
275
277
|
if (check?.hasDataLoss) {
|
|
276
|
-
console.log(
|
|
278
|
+
console.log("Warning: Destructive changes:", check.warnings);
|
|
277
279
|
}
|
|
278
280
|
```
|
|
279
281
|
|
|
@@ -339,7 +341,7 @@ This pattern is particularly important in monorepo setups or when the package is
|
|
|
339
341
|
|
|
340
342
|
```typescript
|
|
341
343
|
// Example of the singleton pattern implementation
|
|
342
|
-
const GLOBAL_SINGLETONS = Symbol.for(
|
|
344
|
+
const GLOBAL_SINGLETONS = Symbol.for("@elizaos/plugin-sql/global-singletons");
|
|
343
345
|
|
|
344
346
|
// Store managers in a global symbol registry
|
|
345
347
|
if (!globalSymbols[GLOBAL_SINGLETONS]) {
|
|
@@ -348,7 +350,9 @@ if (!globalSymbols[GLOBAL_SINGLETONS]) {
|
|
|
348
350
|
|
|
349
351
|
// Reuse existing managers or create new ones when needed
|
|
350
352
|
if (!globalSingletons.postgresConnectionManager) {
|
|
351
|
-
globalSingletons.postgresConnectionManager = new PostgresConnectionManager(
|
|
353
|
+
globalSingletons.postgresConnectionManager = new PostgresConnectionManager(
|
|
354
|
+
config.postgresUrl,
|
|
355
|
+
);
|
|
352
356
|
}
|
|
353
357
|
```
|
|
354
358
|
|
package/package.json
CHANGED
|
@@ -1,97 +1,102 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-sql",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
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
|
+
"bun": {
|
|
13
|
+
"types": "./src/index.ts",
|
|
14
|
+
"import": "./src/index.ts",
|
|
15
|
+
"default": "./src/index.ts"
|
|
16
|
+
},
|
|
20
17
|
"browser": {
|
|
21
|
-
"types": "./dist/
|
|
22
|
-
"import": "./dist/browser/index.browser.js",
|
|
23
|
-
"default": "./dist/browser/index.browser.js"
|
|
18
|
+
"types": "./src/dist/index.d.ts",
|
|
19
|
+
"import": "./src/dist/browser/index.browser.js",
|
|
20
|
+
"default": "./src/dist/browser/index.browser.js"
|
|
24
21
|
},
|
|
25
22
|
"node": {
|
|
26
|
-
"types": "./dist/
|
|
27
|
-
"import": "./dist/node/index.node.js",
|
|
28
|
-
"default": "./dist/node/index.node.js"
|
|
23
|
+
"types": "./src/dist/index.d.ts",
|
|
24
|
+
"import": "./src/dist/node/index.node.js",
|
|
25
|
+
"default": "./src/dist/node/index.node.js"
|
|
29
26
|
},
|
|
27
|
+
"import": "./src/dist/index.js",
|
|
28
|
+
"default": "./src/dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./drizzle": {
|
|
31
|
+
"types": "./src/dist/drizzle/index.d.ts",
|
|
30
32
|
"bun": {
|
|
31
|
-
"types": "./
|
|
32
|
-
"
|
|
33
|
+
"types": "./src/drizzle/index.ts",
|
|
34
|
+
"import": "./src/drizzle/index.ts",
|
|
35
|
+
"default": "./src/drizzle/index.ts"
|
|
33
36
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
"./node": {
|
|
37
|
-
"types": "./dist/node/index.d.ts",
|
|
38
|
-
"import": "./dist/node/index.node.js",
|
|
39
|
-
"default": "./dist/node/index.node.js"
|
|
37
|
+
"import": "./src/dist/drizzle/index.js",
|
|
38
|
+
"default": "./src/dist/drizzle/index.js"
|
|
40
39
|
},
|
|
41
|
-
"./
|
|
42
|
-
"types": "./dist/
|
|
43
|
-
"
|
|
44
|
-
|
|
40
|
+
"./schema": {
|
|
41
|
+
"types": "./src/dist/schema/index.d.ts",
|
|
42
|
+
"bun": {
|
|
43
|
+
"types": "./src/schema/index.ts",
|
|
44
|
+
"import": "./src/schema/index.ts",
|
|
45
|
+
"default": "./src/schema/index.ts"
|
|
46
|
+
},
|
|
47
|
+
"import": "./src/dist/schema/index.js",
|
|
48
|
+
"default": "./src/dist/schema/index.js"
|
|
45
49
|
}
|
|
46
50
|
},
|
|
47
|
-
"sideEffects": false,
|
|
48
51
|
"files": [
|
|
49
|
-
"dist",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
+
"src/dist",
|
|
53
|
+
"README.md",
|
|
54
|
+
"dist"
|
|
52
55
|
],
|
|
56
|
+
"keywords": [],
|
|
57
|
+
"author": "elizaOS",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "https://github.com/elizaos-plugins/plugin-sql"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "cd src && bun run build.ts",
|
|
65
|
+
"dev": "cd src && bun --hot build.ts",
|
|
66
|
+
"test": "cd src && vitest run",
|
|
67
|
+
"typecheck": "tsc --noEmit -p src/tsconfig.json",
|
|
68
|
+
"lint": "cd src && bun run lint",
|
|
69
|
+
"lint:check": "cd src && bun run lint:check",
|
|
70
|
+
"clean": "rm -rf src/dist .turbo",
|
|
71
|
+
"format": "cd src && bun run format",
|
|
72
|
+
"format:check": "cd src && bun run format:check",
|
|
73
|
+
"test:e2e": "node ../../packages/app-core/scripts/run-local-plugin-live-smoke.mjs",
|
|
74
|
+
"test:live": "bun run test:e2e"
|
|
75
|
+
},
|
|
53
76
|
"dependencies": {
|
|
54
|
-
"@electric-sql/pglite": "^0.
|
|
55
|
-
"@
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"pg": "^8.13.3",
|
|
61
|
-
"uuid": "^13.0.0",
|
|
62
|
-
"ws": "^8.19.0"
|
|
77
|
+
"@electric-sql/pglite": "^0.4.0",
|
|
78
|
+
"@neondatabase/serverless": "^1.1.0",
|
|
79
|
+
"drizzle-orm": "0.45.2",
|
|
80
|
+
"pg": "^8.16.3",
|
|
81
|
+
"uuid": "^14.0.0",
|
|
82
|
+
"ws": "^8.18.3"
|
|
63
83
|
},
|
|
64
84
|
"devDependencies": {
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"@types/node": "^25.0.
|
|
68
|
-
"@types/pg": "^8.15.
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"typescript
|
|
85
|
+
"@biomejs/biome": "^2.4.14",
|
|
86
|
+
"@types/bun": "^1.3.5",
|
|
87
|
+
"@types/node": "^25.0.3",
|
|
88
|
+
"@types/pg": "^8.15.2",
|
|
89
|
+
"@types/ws": "^8.18.1",
|
|
90
|
+
"dotenv": "^17.2.3",
|
|
91
|
+
"drizzle-kit": "^0.31.8",
|
|
92
|
+
"typescript": "^6.0.3",
|
|
93
|
+
"vitest": "^4.0.0"
|
|
73
94
|
},
|
|
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"
|
|
95
|
+
"peerDependencies": {
|
|
96
|
+
"@elizaos/core": "2.0.0-beta.1"
|
|
95
97
|
},
|
|
96
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "05d4ca11d769db8c7f54a722ee24b2ce2b951543",
|
|
99
|
+
"publishConfig": {
|
|
100
|
+
"access": "public"
|
|
101
|
+
}
|
|
97
102
|
}
|