@elizaos/plugin-sql 2.0.3-beta.2 → 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 (85) hide show
  1. package/package.json +3 -3
  2. package/src/dist/base.d.ts +1169 -0
  3. package/src/dist/browser/index.browser.d.ts +2 -0
  4. package/src/dist/browser/index.browser.js +31167 -0
  5. package/src/dist/browser/index.browser.js.map +76 -0
  6. package/src/dist/browser/index.d.ts +2 -0
  7. package/src/dist/cjs/index.d.ts +2 -0
  8. package/src/dist/cjs/index.node.cjs +13565 -0
  9. package/src/dist/cjs/index.node.cjs.map +75 -0
  10. package/src/dist/cjs/index.node.d.cts +2 -0
  11. package/src/dist/connector-credential-store.d.ts +48 -0
  12. package/src/dist/drizzle/index.d.ts +1 -0
  13. package/src/dist/drizzle/index.js +1 -0
  14. package/src/dist/index.d.ts +4 -0
  15. package/src/dist/index.js +2 -0
  16. package/src/dist/index.node.d.ts +53 -0
  17. package/src/dist/migration-service.d.ts +17 -0
  18. package/src/dist/migrations.d.ts +15 -0
  19. package/src/dist/node/index.d.ts +2 -0
  20. package/src/dist/node/index.node.d.ts +2 -0
  21. package/src/dist/node/index.node.js +13588 -0
  22. package/src/dist/node/index.node.js.map +75 -0
  23. package/src/dist/pg/adapter.d.ts +42 -0
  24. package/src/dist/pg/manager.d.ts +17 -0
  25. package/src/dist/pg/sslmode.d.ts +6 -0
  26. package/src/dist/pglite/adapter.d.ts +63 -0
  27. package/src/dist/pglite/errors.d.ts +20 -0
  28. package/src/dist/pglite/manager.d.ts +213 -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 +225 -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/src/dist/write-back/index.d.ts +56 -0
@@ -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.js";
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.js";
3
+ import type { DrizzleDatabase } from "../types.js";
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;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * WriteBackService — implements Electric's Pattern 1 (Online Writes).
3
+ *
4
+ * When an agent writes to its local PGlite, this service asynchronously
5
+ * forwards the write to the cloud API, which inserts it into the central
6
+ * Postgres. Electric then syncs the confirmed row back to PGlite via the
7
+ * existing syncShapesToTables read path, completing the round-trip.
8
+ *
9
+ * Writes are fire-and-forget — the agent never blocks on the HTTP POST.
10
+ * A small in-memory queue batches writes that arrive while a flush is
11
+ * in-flight, avoiding duplicate concurrent POSTs. Writes that fail are
12
+ * retried up to MAX_RETRIES times, then dropped with a warning log.
13
+ *
14
+ * Configured via:
15
+ * ELIZA_CLOUD_WRITE_BASE_URL — base URL of the cloud API, e.g.
16
+ * https://api.elizacloud.ai. The agentId is appended at runtime:
17
+ * {base}/api/v1/eliza/agents/{agentId}/write
18
+ * ELIZA_CLOUD_SERVICE_KEY — X-Service-Key value (WAIFU_SERVICE_KEY)
19
+ *
20
+ * If neither env var is set, the service is a no-op.
21
+ */
22
+ export interface WriteBackOptions {
23
+ /** Base URL of the cloud API. AgentId is appended at runtime. */
24
+ writeBaseUrl?: string | null;
25
+ /** Agent UUID for constructing the write endpoint URL. */
26
+ agentId?: string | null;
27
+ /** X-Service-Key value for authentication. */
28
+ serviceKey?: string | null;
29
+ }
30
+ export declare class WriteBackService {
31
+ private writeUrl;
32
+ private serviceKey;
33
+ private queue;
34
+ private flushing;
35
+ private flushTimer;
36
+ /** Incrementing counter ensures unique writeIds even without crypto. */
37
+ private writeCounter;
38
+ constructor(opts?: WriteBackOptions);
39
+ /** Whether the service is configured and active. */
40
+ get enabled(): boolean;
41
+ /**
42
+ * Enqueue a write to be forwarded to the cloud API.
43
+ * Returns immediately; the write is flushed asynchronously.
44
+ */
45
+ enqueue(table: string, operation: "insert" | "upsert" | "delete", row: Record<string, unknown>): void;
46
+ /**
47
+ * Flush all pending writes synchronously. Waits for any in-progress
48
+ * drain to complete, then picks up any remaining items.
49
+ * Used during shutdown to drain the queue before the agent exits.
50
+ */
51
+ flush(): Promise<void>;
52
+ private scheduleFlush;
53
+ private drainQueue;
54
+ private sendBatch;
55
+ private requeueOrDrop;
56
+ }