@elizaos/plugin-sql 2.0.0-alpha.7 → 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.
Files changed (91) hide show
  1. package/README.md +359 -0
  2. package/package.json +77 -68
  3. package/src/dist/base.d.ts +1152 -0
  4. package/src/dist/browser/index.browser.d.ts +2 -0
  5. package/src/dist/browser/index.browser.js +26781 -0
  6. package/src/dist/browser/index.browser.js.map +72 -0
  7. package/src/dist/browser/index.d.ts +2 -0
  8. package/src/dist/cjs/index.d.ts +2 -0
  9. package/src/dist/cjs/index.node.cjs +9154 -0
  10. package/src/dist/cjs/index.node.cjs.map +70 -0
  11. package/src/dist/cjs/index.node.d.cts +2 -0
  12. package/src/dist/connector-credential-store.d.ts +48 -0
  13. package/src/dist/drizzle/index.d.ts +1 -0
  14. package/src/dist/drizzle/index.js +1 -0
  15. package/src/dist/index.d.ts +4 -0
  16. package/src/dist/index.js +2 -0
  17. package/src/dist/index.node.d.ts +20 -0
  18. package/src/dist/migration-service.d.ts +17 -0
  19. package/src/dist/migrations.d.ts +15 -0
  20. package/src/dist/node/index.d.ts +2 -0
  21. package/src/dist/node/index.node.d.ts +2 -0
  22. package/{dist/browser/index.browser.js → src/dist/node/index.node.js} +7858 -4638
  23. package/src/dist/node/index.node.js.map +70 -0
  24. package/src/dist/pg/adapter.d.ts +42 -0
  25. package/src/dist/pg/manager.d.ts +17 -0
  26. package/src/dist/pglite/adapter.d.ts +24 -0
  27. package/src/dist/pglite/errors.d.ts +20 -0
  28. package/src/dist/pglite/manager.d.ts +32 -0
  29. package/src/dist/rls.d.ts +13 -0
  30. package/src/dist/runtime-migrator/crypto-utils.d.ts +25 -0
  31. package/src/dist/runtime-migrator/drizzle-adapters/database-introspector.d.ts +58 -0
  32. package/src/dist/runtime-migrator/drizzle-adapters/diff-calculator.d.ts +77 -0
  33. package/src/dist/runtime-migrator/drizzle-adapters/snapshot-generator.d.ts +21 -0
  34. package/src/dist/runtime-migrator/drizzle-adapters/sql-generator.d.ts +38 -0
  35. package/src/dist/runtime-migrator/extension-manager.d.ts +6 -0
  36. package/src/dist/runtime-migrator/index.d.ts +8 -0
  37. package/src/dist/runtime-migrator/runtime-migrator.d.ts +95 -0
  38. package/src/dist/runtime-migrator/schema-transformer.d.ts +18 -0
  39. package/src/dist/runtime-migrator/storage/journal-storage.d.ts +10 -0
  40. package/src/dist/runtime-migrator/storage/migration-tracker.d.ts +13 -0
  41. package/src/dist/runtime-migrator/storage/snapshot-storage.d.ts +9 -0
  42. package/src/dist/runtime-migrator/types.d.ts +157 -0
  43. package/src/dist/schema/agent.d.ts +344 -0
  44. package/src/dist/schema/approvalRequests.d.ts +277 -0
  45. package/src/dist/schema/authAuditEvent.d.ts +153 -0
  46. package/src/dist/schema/authBootstrapJti.d.ts +49 -0
  47. package/src/dist/schema/authIdentity.d.ts +121 -0
  48. package/src/dist/schema/authOwnerBinding.d.ts +168 -0
  49. package/src/dist/schema/authOwnerLoginToken.d.ts +122 -0
  50. package/src/dist/schema/authSession.d.ts +225 -0
  51. package/src/dist/schema/cache.d.ts +97 -0
  52. package/src/dist/schema/channel.d.ts +177 -0
  53. package/src/dist/schema/channelParticipant.d.ts +41 -0
  54. package/src/dist/schema/component.d.ts +163 -0
  55. package/src/dist/schema/connectorAccounts.d.ts +981 -0
  56. package/src/dist/schema/embedding.d.ts +204 -0
  57. package/src/dist/schema/entity.d.ts +125 -0
  58. package/src/dist/schema/entityIdentity.d.ts +577 -0
  59. package/src/dist/schema/index.d.ts +35 -0
  60. package/src/dist/schema/index.js +1 -0
  61. package/src/dist/schema/log.d.ts +114 -0
  62. package/src/dist/schema/longTermMemories.d.ts +254 -0
  63. package/src/dist/schema/memory.d.ts +185 -0
  64. package/src/dist/schema/memoryAccessLogs.d.ts +109 -0
  65. package/src/dist/schema/message.d.ts +194 -0
  66. package/src/dist/schema/messageServer.d.ts +126 -0
  67. package/src/dist/schema/messageServerAgent.d.ts +41 -0
  68. package/src/dist/schema/pairingAllowlist.d.ts +113 -0
  69. package/src/dist/schema/pairingRequest.d.ts +147 -0
  70. package/src/dist/schema/participant.d.ts +114 -0
  71. package/src/dist/schema/relationship.d.ts +156 -0
  72. package/src/dist/schema/room.d.ts +195 -0
  73. package/src/dist/schema/server.d.ts +64 -0
  74. package/src/dist/schema/sessionSummaries.d.ts +273 -0
  75. package/src/dist/schema/tasks.d.ts +225 -0
  76. package/src/dist/schema/types.d.ts +68 -0
  77. package/src/dist/schema/world.d.ts +114 -0
  78. package/src/dist/services/advanced-memory-storage.d.ts +36 -0
  79. package/src/dist/stores/connectorAccount.store.d.ts +64 -0
  80. package/src/dist/stores/types.d.ts +25 -0
  81. package/src/dist/types.d.ts +13 -0
  82. package/src/dist/utils/string-to-uuid.d.ts +2 -0
  83. package/src/dist/utils.d.ts +4 -0
  84. package/src/dist/utils.node.d.ts +4 -0
  85. package/LICENSE +0 -21
  86. package/dist/browser/index.browser.js.map +0 -54
  87. package/dist/browser/index.d.ts +0 -2
  88. package/dist/index.d.ts +0 -2
  89. package/dist/node/index.d.ts +0 -2
  90. package/dist/node/index.node.js +0 -12524
  91. package/dist/node/index.node.js.map +0 -152
@@ -0,0 +1,36 @@
1
+ import { type IAgentRuntime, type MemoryStorageProvider, Service, type UUID } from "@elizaos/core";
2
+ type LongTermMemoryRecord = Awaited<ReturnType<MemoryStorageProvider["storeLongTermMemory"]>>;
3
+ type LongTermMemoryInput = Parameters<MemoryStorageProvider["storeLongTermMemory"]>[0];
4
+ type LongTermMemoryCategory = LongTermMemoryRecord["category"];
5
+ type SessionSummaryRecord = Awaited<ReturnType<MemoryStorageProvider["storeSessionSummary"]>>;
6
+ type SessionSummaryInput = Parameters<MemoryStorageProvider["storeSessionSummary"]>[0];
7
+ export declare class AdvancedMemoryStorageService extends Service implements MemoryStorageProvider {
8
+ static serviceType: "memoryStorage";
9
+ capabilityDescription: string;
10
+ static start(runtime: IAgentRuntime): Promise<Service>;
11
+ initialize(runtime: IAgentRuntime): Promise<void>;
12
+ stop(): Promise<void>;
13
+ private getMemoryWorldId;
14
+ private getLongTermRoomId;
15
+ private ensureMemoryWorld;
16
+ private ensureLongTermRoom;
17
+ private getEntityResolutionService;
18
+ private getIdentityGroup;
19
+ private getAnchorEntityId;
20
+ private parseLongTermMemory;
21
+ private parseSessionSummary;
22
+ private sortLongTermMemories;
23
+ private sortSessionSummaries;
24
+ storeLongTermMemory(memory: LongTermMemoryInput): Promise<LongTermMemoryRecord>;
25
+ getLongTermMemories(agentId: UUID, entityId: UUID, opts?: {
26
+ category?: LongTermMemoryCategory;
27
+ limit?: number;
28
+ }): Promise<LongTermMemoryRecord[]>;
29
+ updateLongTermMemory(id: UUID, agentId: UUID, entityId: UUID, updates: Partial<Omit<LongTermMemoryRecord, "id" | "agentId" | "entityId" | "createdAt">>): Promise<void>;
30
+ deleteLongTermMemory(id: UUID, agentId: UUID, entityId: UUID): Promise<void>;
31
+ storeSessionSummary(summary: SessionSummaryInput): Promise<SessionSummaryRecord>;
32
+ getCurrentSessionSummary(agentId: UUID, roomId: UUID): Promise<SessionSummaryRecord | null>;
33
+ updateSessionSummary(id: UUID, agentId: UUID, roomId: UUID, updates: Partial<Omit<SessionSummaryRecord, "id" | "agentId" | "roomId" | "createdAt" | "updatedAt">>): Promise<void>;
34
+ getSessionSummaries(agentId: UUID, roomId: UUID, limit?: number): Promise<SessionSummaryRecord[]>;
35
+ }
36
+ export {};
@@ -0,0 +1,64 @@
1
+ import type { AppendConnectorAccountAuditEventParams, ConnectorAccountAuditEventRecord, ConnectorAccountCredentialRefRecord, ConnectorAccountJsonObject, ConnectorAccountRecord, ConnectorOwnerBindingLookup, ConnectorOwnerBindingRecord, ConsumeOAuthFlowStateParams, CreateOAuthFlowStateParams, DeleteConnectorAccountParams, GetConnectorAccountCredentialRefParams, GetConnectorAccountParams, ListConnectorAccountCredentialRefsParams, ListConnectorAccountsParams, OAuthFlowRecord, SetConnectorAccountCredentialRefParams, UpsertConnectorAccountParams } from "@elizaos/core";
2
+ import type { Store, StoreContext } from "./types";
3
+ interface GetOAuthFlowStateParams {
4
+ state?: string;
5
+ stateHash?: string;
6
+ flowId?: string;
7
+ agentId?: string;
8
+ provider?: string;
9
+ includeConsumed?: boolean;
10
+ includeExpired?: boolean;
11
+ now?: number | Date;
12
+ }
13
+ interface UpdateOAuthFlowStateParams {
14
+ state?: string;
15
+ stateHash?: string;
16
+ flowId?: string;
17
+ agentId?: string;
18
+ provider?: string;
19
+ accountId?: string | null;
20
+ redirectUri?: string | null;
21
+ codeVerifierRef?: string | null;
22
+ scopes?: string[];
23
+ metadata?: ConnectorAccountJsonObject;
24
+ expiresAt?: number | Date;
25
+ consumedAt?: number | Date | null;
26
+ consumedBy?: string | null;
27
+ }
28
+ interface DeleteOAuthFlowStateParams {
29
+ state?: string;
30
+ stateHash?: string;
31
+ flowId?: string;
32
+ agentId?: string;
33
+ provider?: string;
34
+ }
35
+ export interface ListConnectorAccountAuditEventsParams {
36
+ agentId?: string;
37
+ provider?: string;
38
+ accountId?: string;
39
+ action?: string;
40
+ outcome?: string;
41
+ limit?: number;
42
+ }
43
+ export declare class ConnectorAccountStore implements Store {
44
+ readonly ctx: StoreContext;
45
+ constructor(ctx: StoreContext);
46
+ private get db();
47
+ listAccounts(params?: ListConnectorAccountsParams): Promise<ConnectorAccountRecord[]>;
48
+ getAccount(params: GetConnectorAccountParams): Promise<ConnectorAccountRecord | null>;
49
+ upsertAccount(params: UpsertConnectorAccountParams): Promise<ConnectorAccountRecord>;
50
+ deleteAccount(params: DeleteConnectorAccountParams): Promise<boolean>;
51
+ findOwnerBinding(params: ConnectorOwnerBindingLookup): Promise<ConnectorOwnerBindingRecord | null>;
52
+ setCredentialRef(params: SetConnectorAccountCredentialRefParams): Promise<ConnectorAccountCredentialRefRecord>;
53
+ getCredentialRef(params: GetConnectorAccountCredentialRefParams): Promise<ConnectorAccountCredentialRefRecord | null>;
54
+ listCredentialRefs(params: ListConnectorAccountCredentialRefsParams): Promise<ConnectorAccountCredentialRefRecord[]>;
55
+ appendAuditEvent(params: AppendConnectorAccountAuditEventParams): Promise<ConnectorAccountAuditEventRecord>;
56
+ listAuditEvents(params?: ListConnectorAccountAuditEventsParams): Promise<ConnectorAccountAuditEventRecord[]>;
57
+ createOAuthFlowState(params: CreateOAuthFlowStateParams): Promise<OAuthFlowRecord>;
58
+ consumeOAuthFlowState(params: ConsumeOAuthFlowStateParams): Promise<OAuthFlowRecord | null>;
59
+ private buildOAuthFlowLookupConditions;
60
+ getOAuthFlowState(params: GetOAuthFlowStateParams): Promise<OAuthFlowRecord | null>;
61
+ updateOAuthFlowState(params: UpdateOAuthFlowStateParams): Promise<OAuthFlowRecord | null>;
62
+ deleteOAuthFlowState(params: DeleteOAuthFlowStateParams): Promise<boolean>;
63
+ }
64
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { UUID } from "@elizaos/core";
2
+ import type { EmbeddingDimensionColumn } from "../schema/embedding";
3
+ import type { DrizzleDatabase } from "../types";
4
+ /**
5
+ * Context passed to all stores for database operations.
6
+ * Stores don't manage connections - they receive a context from the adapter.
7
+ */
8
+ export interface StoreContext {
9
+ /** Get the database instance (may be a transaction) */
10
+ getDb: () => DrizzleDatabase;
11
+ /** Execute operation with retry logic (context is for logging, ignored by adapter) */
12
+ withRetry: <T>(operation: () => Promise<T>, context?: string) => Promise<T>;
13
+ /** Execute operation within RLS isolation context */
14
+ withIsolationContext: <T>(entityId: UUID | null, callback: (tx: DrizzleDatabase) => Promise<T>) => Promise<T>;
15
+ /** Current agent ID */
16
+ agentId: UUID;
17
+ /** Get current embedding dimension column (dynamic to reflect runtime changes) */
18
+ getEmbeddingDimension: () => EmbeddingDimensionColumn;
19
+ }
20
+ /**
21
+ * Base interface for all domain stores.
22
+ */
23
+ export interface Store {
24
+ readonly ctx: StoreContext;
25
+ }
@@ -0,0 +1,13 @@
1
+ import type { IDatabaseAdapter } from "@elizaos/core";
2
+ import type { NodePgDatabase } from "drizzle-orm/node-postgres";
3
+ import type { PgliteDatabase } from "drizzle-orm/pglite";
4
+ export type DrizzleDatabase = NodePgDatabase | PgliteDatabase;
5
+ export interface IDatabaseClientManager<T> {
6
+ initialize(): Promise<void>;
7
+ getConnection(): T;
8
+ close(): Promise<void>;
9
+ }
10
+ export declare function getDb(adapter: IDatabaseAdapter): DrizzleDatabase;
11
+ export declare function getRow<T>(result: {
12
+ rows: unknown[];
13
+ }, index?: number): T | undefined;
@@ -0,0 +1,2 @@
1
+ import type { UUID } from "@elizaos/core";
2
+ export declare function stringToUuid(target: string | number): UUID;
@@ -0,0 +1,4 @@
1
+ export declare function expandTildePath(filepath: string): string;
2
+ export declare function resolveEnvFile(startDir?: string): string;
3
+ export declare function resolvePgliteDir(dir?: string, fallbackDir?: string): string;
4
+ export declare function sanitizeJsonObject(value: unknown, seen?: WeakSet<object>): unknown;
@@ -0,0 +1,4 @@
1
+ export declare function expandTildePath(filepath: string): string;
2
+ export declare function resolveEnvFile(startDir?: string): string;
3
+ export declare function resolvePgliteDir(dir?: string, fallbackDir?: string): string;
4
+ export declare function sanitizeJsonObject(value: unknown, seen?: WeakSet<object>): unknown;
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 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.