@falai/agent 0.3.12 → 0.3.20
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 +72 -0
- package/dist/adapters/MongoAdapter.d.ts +97 -0
- package/dist/adapters/MongoAdapter.d.ts.map +1 -0
- package/dist/adapters/MongoAdapter.js +163 -0
- package/dist/adapters/MongoAdapter.js.map +1 -0
- package/dist/adapters/PostgreSQLAdapter.d.ts +71 -0
- package/dist/adapters/PostgreSQLAdapter.d.ts.map +1 -0
- package/dist/adapters/PostgreSQLAdapter.js +256 -0
- package/dist/adapters/PostgreSQLAdapter.js.map +1 -0
- package/dist/adapters/RedisAdapter.d.ts +71 -0
- package/dist/adapters/RedisAdapter.d.ts.map +1 -0
- package/dist/adapters/RedisAdapter.js +226 -0
- package/dist/adapters/RedisAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +6 -0
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/cjs/adapters/MongoAdapter.d.ts +97 -0
- package/dist/cjs/adapters/MongoAdapter.d.ts.map +1 -0
- package/dist/cjs/adapters/MongoAdapter.js +167 -0
- package/dist/cjs/adapters/MongoAdapter.js.map +1 -0
- package/dist/cjs/adapters/PostgreSQLAdapter.d.ts +71 -0
- package/dist/cjs/adapters/PostgreSQLAdapter.d.ts.map +1 -0
- package/dist/cjs/adapters/PostgreSQLAdapter.js +260 -0
- package/dist/cjs/adapters/PostgreSQLAdapter.js.map +1 -0
- package/dist/cjs/adapters/RedisAdapter.d.ts +71 -0
- package/dist/cjs/adapters/RedisAdapter.d.ts.map +1 -0
- package/dist/cjs/adapters/RedisAdapter.js +230 -0
- package/dist/cjs/adapters/RedisAdapter.js.map +1 -0
- package/dist/cjs/adapters/index.d.ts +6 -0
- package/dist/cjs/adapters/index.d.ts.map +1 -1
- package/dist/cjs/adapters/index.js +7 -1
- package/dist/cjs/adapters/index.js.map +1 -1
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +7 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/docs/ADAPTERS.md +127 -0
- package/docs/API_REFERENCE.md +337 -0
- package/docs/PERSISTENCE.md +100 -6
- package/examples/redis-persistence.ts +89 -0
- package/package.json +22 -2
- package/src/adapters/MongoAdapter.ts +295 -0
- package/src/adapters/PostgreSQLAdapter.ts +417 -0
- package/src/adapters/RedisAdapter.ts +365 -0
- package/src/adapters/index.ts +18 -0
- package/src/index.ts +15 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL adapter for persistence
|
|
3
|
+
* Raw SQL adapter for PostgreSQL with custom schemas
|
|
4
|
+
*/
|
|
5
|
+
import type { SessionRepository, MessageRepository, PersistenceAdapter } from "../types/persistence";
|
|
6
|
+
/**
|
|
7
|
+
* PostgreSQL query result interface
|
|
8
|
+
*/
|
|
9
|
+
export interface PgQueryResult<T = Record<string, unknown>> {
|
|
10
|
+
rows: T[];
|
|
11
|
+
rowCount: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* PostgreSQL client interface - matches pg (node-postgres)
|
|
15
|
+
*/
|
|
16
|
+
export interface PgClient {
|
|
17
|
+
query<T = Record<string, unknown>>(sql: string, values?: unknown[]): Promise<PgQueryResult<T>>;
|
|
18
|
+
end(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for PostgreSQL adapter
|
|
22
|
+
*/
|
|
23
|
+
export interface PostgreSQLAdapterOptions {
|
|
24
|
+
/**
|
|
25
|
+
* PostgreSQL client instance (from 'pg' package)
|
|
26
|
+
*/
|
|
27
|
+
client: PgClient;
|
|
28
|
+
/**
|
|
29
|
+
* Table names (default: "agent_sessions" and "agent_messages")
|
|
30
|
+
*/
|
|
31
|
+
tables?: {
|
|
32
|
+
sessions?: string;
|
|
33
|
+
messages?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* PostgreSQL Adapter - Provider-style API for PostgreSQL persistence
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { Client } from 'pg';
|
|
42
|
+
* import { Agent, PostgreSQLAdapter } from '@falai/agent';
|
|
43
|
+
*
|
|
44
|
+
* const client = new Client({
|
|
45
|
+
* host: 'localhost',
|
|
46
|
+
* port: 5432,
|
|
47
|
+
* database: 'myapp',
|
|
48
|
+
* user: 'postgres',
|
|
49
|
+
* password: 'password',
|
|
50
|
+
* });
|
|
51
|
+
* await client.connect();
|
|
52
|
+
*
|
|
53
|
+
* const agent = new Agent({
|
|
54
|
+
* name: "My Agent",
|
|
55
|
+
* ai: provider,
|
|
56
|
+
* persistence: {
|
|
57
|
+
* adapter: new PostgreSQLAdapter({ client }),
|
|
58
|
+
* userId: "user_123",
|
|
59
|
+
* },
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare class PostgreSQLAdapter implements PersistenceAdapter {
|
|
64
|
+
readonly sessionRepository: SessionRepository;
|
|
65
|
+
readonly messageRepository: MessageRepository;
|
|
66
|
+
private client;
|
|
67
|
+
constructor(options: PostgreSQLAdapterOptions);
|
|
68
|
+
initialize(): Promise<void>;
|
|
69
|
+
disconnect(): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=PostgreSQLAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgreSQLAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/PostgreSQLAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAIjB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxD,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAC1D,SAAgB,iBAAiB,EAAE,iBAAiB,CAAC;IACrD,SAAgB,iBAAiB,EAAE,iBAAiB,CAAC;IACrD,OAAO,CAAC,MAAM,CAAW;gBAEb,OAAO,EAAE,wBAAwB;IAiBvC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAiD3B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PostgreSQL adapter for persistence
|
|
4
|
+
* Raw SQL adapter for PostgreSQL with custom schemas
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PostgreSQLAdapter = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* PostgreSQL Adapter - Provider-style API for PostgreSQL persistence
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Client } from 'pg';
|
|
14
|
+
* import { Agent, PostgreSQLAdapter } from '@falai/agent';
|
|
15
|
+
*
|
|
16
|
+
* const client = new Client({
|
|
17
|
+
* host: 'localhost',
|
|
18
|
+
* port: 5432,
|
|
19
|
+
* database: 'myapp',
|
|
20
|
+
* user: 'postgres',
|
|
21
|
+
* password: 'password',
|
|
22
|
+
* });
|
|
23
|
+
* await client.connect();
|
|
24
|
+
*
|
|
25
|
+
* const agent = new Agent({
|
|
26
|
+
* name: "My Agent",
|
|
27
|
+
* ai: provider,
|
|
28
|
+
* persistence: {
|
|
29
|
+
* adapter: new PostgreSQLAdapter({ client }),
|
|
30
|
+
* userId: "user_123",
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
class PostgreSQLAdapter {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.client = options.client;
|
|
38
|
+
const sessionTable = options.tables?.sessions || "agent_sessions";
|
|
39
|
+
const messageTable = options.tables?.messages || "agent_messages";
|
|
40
|
+
this.sessionRepository = new PostgreSQLSessionRepository(this.client, sessionTable);
|
|
41
|
+
this.messageRepository = new PostgreSQLMessageRepository(this.client, messageTable);
|
|
42
|
+
}
|
|
43
|
+
async initialize() {
|
|
44
|
+
// Create tables if they don't exist
|
|
45
|
+
const sessionTable = "agent_sessions";
|
|
46
|
+
const messageTable = "agent_messages";
|
|
47
|
+
await this.client.query(`
|
|
48
|
+
CREATE TABLE IF NOT EXISTS ${sessionTable} (
|
|
49
|
+
id VARCHAR(255) PRIMARY KEY,
|
|
50
|
+
user_id VARCHAR(255),
|
|
51
|
+
agent_name VARCHAR(255),
|
|
52
|
+
status VARCHAR(50) DEFAULT 'active',
|
|
53
|
+
current_route VARCHAR(255),
|
|
54
|
+
current_state VARCHAR(255),
|
|
55
|
+
collected_data JSONB,
|
|
56
|
+
message_count INTEGER DEFAULT 0,
|
|
57
|
+
last_message_at TIMESTAMP,
|
|
58
|
+
completed_at TIMESTAMP,
|
|
59
|
+
created_at TIMESTAMP DEFAULT NOW(),
|
|
60
|
+
updated_at TIMESTAMP DEFAULT NOW()
|
|
61
|
+
)
|
|
62
|
+
`);
|
|
63
|
+
await this.client.query(`
|
|
64
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_user_id ON ${sessionTable}(user_id);
|
|
65
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_status ON ${sessionTable}(status);
|
|
66
|
+
`);
|
|
67
|
+
await this.client.query(`
|
|
68
|
+
CREATE TABLE IF NOT EXISTS ${messageTable} (
|
|
69
|
+
id VARCHAR(255) PRIMARY KEY,
|
|
70
|
+
session_id VARCHAR(255) NOT NULL,
|
|
71
|
+
user_id VARCHAR(255),
|
|
72
|
+
role VARCHAR(50) NOT NULL,
|
|
73
|
+
content TEXT NOT NULL,
|
|
74
|
+
route VARCHAR(255),
|
|
75
|
+
state VARCHAR(255),
|
|
76
|
+
tool_calls JSONB,
|
|
77
|
+
event JSONB,
|
|
78
|
+
created_at TIMESTAMP DEFAULT NOW(),
|
|
79
|
+
FOREIGN KEY (session_id) REFERENCES ${sessionTable}(id) ON DELETE CASCADE
|
|
80
|
+
)
|
|
81
|
+
`);
|
|
82
|
+
await this.client.query(`
|
|
83
|
+
CREATE INDEX IF NOT EXISTS idx_messages_session_id ON ${messageTable}(session_id);
|
|
84
|
+
CREATE INDEX IF NOT EXISTS idx_messages_user_id ON ${messageTable}(user_id);
|
|
85
|
+
`);
|
|
86
|
+
}
|
|
87
|
+
async disconnect() {
|
|
88
|
+
await this.client.end();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.PostgreSQLAdapter = PostgreSQLAdapter;
|
|
92
|
+
/**
|
|
93
|
+
* PostgreSQL Session Repository
|
|
94
|
+
*/
|
|
95
|
+
class PostgreSQLSessionRepository {
|
|
96
|
+
constructor(client, tableName) {
|
|
97
|
+
this.client = client;
|
|
98
|
+
this.tableName = tableName;
|
|
99
|
+
}
|
|
100
|
+
async create(data) {
|
|
101
|
+
const id = `session_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
102
|
+
const now = new Date();
|
|
103
|
+
const result = await this.client.query(`INSERT INTO ${this.tableName}
|
|
104
|
+
(id, user_id, agent_name, status, collected_data, message_count, created_at, updated_at)
|
|
105
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
106
|
+
RETURNING *`, [
|
|
107
|
+
id,
|
|
108
|
+
data.userId || null,
|
|
109
|
+
data.agentName || null,
|
|
110
|
+
data.status || "active",
|
|
111
|
+
JSON.stringify(data.collectedData || {}),
|
|
112
|
+
data.messageCount || 0,
|
|
113
|
+
now,
|
|
114
|
+
now,
|
|
115
|
+
]);
|
|
116
|
+
return result.rows[0];
|
|
117
|
+
}
|
|
118
|
+
async findById(id) {
|
|
119
|
+
const result = await this.client.query(`SELECT * FROM ${this.tableName} WHERE id = $1`, [id]);
|
|
120
|
+
return result.rows[0] || null;
|
|
121
|
+
}
|
|
122
|
+
async findActiveByUserId(userId) {
|
|
123
|
+
const result = await this.client.query(`SELECT * FROM ${this.tableName}
|
|
124
|
+
WHERE user_id = $1 AND status = 'active'
|
|
125
|
+
ORDER BY created_at DESC
|
|
126
|
+
LIMIT 1`, [userId]);
|
|
127
|
+
return result.rows[0] || null;
|
|
128
|
+
}
|
|
129
|
+
async findByUserId(userId, limit = 100) {
|
|
130
|
+
const result = await this.client.query(`SELECT * FROM ${this.tableName}
|
|
131
|
+
WHERE user_id = $1
|
|
132
|
+
ORDER BY created_at DESC
|
|
133
|
+
LIMIT $2`, [userId, limit]);
|
|
134
|
+
return result.rows;
|
|
135
|
+
}
|
|
136
|
+
async update(id, data) {
|
|
137
|
+
const fields = [];
|
|
138
|
+
const values = [];
|
|
139
|
+
let paramIndex = 1;
|
|
140
|
+
if (data.status !== undefined) {
|
|
141
|
+
fields.push(`status = $${paramIndex++}`);
|
|
142
|
+
values.push(data.status);
|
|
143
|
+
}
|
|
144
|
+
if (data.collectedData !== undefined) {
|
|
145
|
+
fields.push(`collected_data = $${paramIndex++}`);
|
|
146
|
+
values.push(JSON.stringify(data.collectedData));
|
|
147
|
+
}
|
|
148
|
+
if (data.currentRoute !== undefined) {
|
|
149
|
+
fields.push(`current_route = $${paramIndex++}`);
|
|
150
|
+
values.push(data.currentRoute);
|
|
151
|
+
}
|
|
152
|
+
if (data.currentState !== undefined) {
|
|
153
|
+
fields.push(`current_state = $${paramIndex++}`);
|
|
154
|
+
values.push(data.currentState);
|
|
155
|
+
}
|
|
156
|
+
if (data.messageCount !== undefined) {
|
|
157
|
+
fields.push(`message_count = $${paramIndex++}`);
|
|
158
|
+
values.push(data.messageCount);
|
|
159
|
+
}
|
|
160
|
+
if (data.lastMessageAt !== undefined) {
|
|
161
|
+
fields.push(`last_message_at = $${paramIndex++}`);
|
|
162
|
+
values.push(data.lastMessageAt);
|
|
163
|
+
}
|
|
164
|
+
if (data.completedAt !== undefined) {
|
|
165
|
+
fields.push(`completed_at = $${paramIndex++}`);
|
|
166
|
+
values.push(data.completedAt);
|
|
167
|
+
}
|
|
168
|
+
fields.push(`updated_at = $${paramIndex++}`);
|
|
169
|
+
values.push(new Date());
|
|
170
|
+
values.push(id);
|
|
171
|
+
const result = await this.client.query(`UPDATE ${this.tableName}
|
|
172
|
+
SET ${fields.join(", ")}
|
|
173
|
+
WHERE id = $${paramIndex}
|
|
174
|
+
RETURNING *`, values);
|
|
175
|
+
return result.rows[0] || null;
|
|
176
|
+
}
|
|
177
|
+
async updateStatus(id, status, completedAt) {
|
|
178
|
+
return await this.update(id, { status, completedAt });
|
|
179
|
+
}
|
|
180
|
+
async updateCollectedData(id, collectedData) {
|
|
181
|
+
return await this.update(id, { collectedData });
|
|
182
|
+
}
|
|
183
|
+
async updateRouteState(id, route, state) {
|
|
184
|
+
return await this.update(id, {
|
|
185
|
+
currentRoute: route,
|
|
186
|
+
currentState: state,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
async incrementMessageCount(id) {
|
|
190
|
+
const result = await this.client.query(`UPDATE ${this.tableName}
|
|
191
|
+
SET message_count = message_count + 1,
|
|
192
|
+
last_message_at = NOW(),
|
|
193
|
+
updated_at = NOW()
|
|
194
|
+
WHERE id = $1
|
|
195
|
+
RETURNING *`, [id]);
|
|
196
|
+
return result.rows[0] || null;
|
|
197
|
+
}
|
|
198
|
+
async delete(id) {
|
|
199
|
+
const result = await this.client.query(`DELETE FROM ${this.tableName} WHERE id = $1`, [id]);
|
|
200
|
+
return result.rowCount > 0;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* PostgreSQL Message Repository
|
|
205
|
+
*/
|
|
206
|
+
class PostgreSQLMessageRepository {
|
|
207
|
+
constructor(client, tableName) {
|
|
208
|
+
this.client = client;
|
|
209
|
+
this.tableName = tableName;
|
|
210
|
+
}
|
|
211
|
+
async create(data) {
|
|
212
|
+
const id = `msg_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
213
|
+
const result = await this.client.query(`INSERT INTO ${this.tableName}
|
|
214
|
+
(id, session_id, user_id, role, content, route, state, tool_calls, event, created_at)
|
|
215
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, NOW())
|
|
216
|
+
RETURNING *`, [
|
|
217
|
+
id,
|
|
218
|
+
data.sessionId,
|
|
219
|
+
data.userId || null,
|
|
220
|
+
data.role,
|
|
221
|
+
data.content,
|
|
222
|
+
data.route || null,
|
|
223
|
+
data.state || null,
|
|
224
|
+
JSON.stringify(data.toolCalls || null),
|
|
225
|
+
JSON.stringify(data.event || null),
|
|
226
|
+
]);
|
|
227
|
+
return result.rows[0];
|
|
228
|
+
}
|
|
229
|
+
async findById(id) {
|
|
230
|
+
const result = await this.client.query(`SELECT * FROM ${this.tableName} WHERE id = $1`, [id]);
|
|
231
|
+
return result.rows[0] || null;
|
|
232
|
+
}
|
|
233
|
+
async findBySessionId(sessionId, limit = 1000) {
|
|
234
|
+
const result = await this.client.query(`SELECT * FROM ${this.tableName}
|
|
235
|
+
WHERE session_id = $1
|
|
236
|
+
ORDER BY created_at ASC
|
|
237
|
+
LIMIT $2`, [sessionId, limit]);
|
|
238
|
+
return result.rows;
|
|
239
|
+
}
|
|
240
|
+
async findByUserId(userId, limit = 100) {
|
|
241
|
+
const result = await this.client.query(`SELECT * FROM ${this.tableName}
|
|
242
|
+
WHERE user_id = $1
|
|
243
|
+
ORDER BY created_at DESC
|
|
244
|
+
LIMIT $2`, [userId, limit]);
|
|
245
|
+
return result.rows;
|
|
246
|
+
}
|
|
247
|
+
async delete(id) {
|
|
248
|
+
const result = await this.client.query(`DELETE FROM ${this.tableName} WHERE id = $1`, [id]);
|
|
249
|
+
return result.rowCount > 0;
|
|
250
|
+
}
|
|
251
|
+
async deleteBySessionId(sessionId) {
|
|
252
|
+
const result = await this.client.query(`DELETE FROM ${this.tableName} WHERE session_id = $1`, [sessionId]);
|
|
253
|
+
return result.rowCount;
|
|
254
|
+
}
|
|
255
|
+
async deleteByUserId(userId) {
|
|
256
|
+
const result = await this.client.query(`DELETE FROM ${this.tableName} WHERE user_id = $1`, [userId]);
|
|
257
|
+
return result.rowCount;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=PostgreSQLAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgreSQLAdapter.js","sourceRoot":"","sources":["../../../src/adapters/PostgreSQLAdapter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgDH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,iBAAiB;IAK5B,YAAY,OAAiC;QAC3C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAE7B,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,QAAQ,IAAI,gBAAgB,CAAC;QAClE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C,eAAe,IAAI,CAAC,SAAS,wBAAwB,EACrD,CAAC,SAAS,CAAC,CACZ,CAAC;QAEF,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc;QACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACpC,eAAe,IAAI,CAAC,SAAS,qBAAqB,EAClD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis adapter for persistence
|
|
3
|
+
* Uses Redis for fast session/message storage
|
|
4
|
+
*/
|
|
5
|
+
import type { SessionRepository, MessageRepository, PersistenceAdapter } from "../types/persistence";
|
|
6
|
+
/**
|
|
7
|
+
* Redis client interface - matches ioredis/redis clients
|
|
8
|
+
*/
|
|
9
|
+
export interface RedisClient {
|
|
10
|
+
get(key: string): Promise<string | null>;
|
|
11
|
+
set(key: string, value: string): Promise<string | null>;
|
|
12
|
+
setex(key: string, seconds: number, value: string): Promise<string>;
|
|
13
|
+
del(...keys: string[]): Promise<number>;
|
|
14
|
+
keys(pattern: string): Promise<string[]>;
|
|
15
|
+
hgetall(key: string): Promise<Record<string, string>>;
|
|
16
|
+
hset(key: string, field: string, value: string): Promise<number>;
|
|
17
|
+
expire(key: string, seconds: number): Promise<number>;
|
|
18
|
+
quit(): Promise<string>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for Redis adapter
|
|
22
|
+
*/
|
|
23
|
+
export interface RedisAdapterOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Redis client instance (ioredis or node-redis)
|
|
26
|
+
*/
|
|
27
|
+
redis: RedisClient;
|
|
28
|
+
/**
|
|
29
|
+
* Key prefix for all keys (default: "agent:")
|
|
30
|
+
*/
|
|
31
|
+
keyPrefix?: string;
|
|
32
|
+
/**
|
|
33
|
+
* TTL in seconds for sessions (default: 7 days)
|
|
34
|
+
*/
|
|
35
|
+
sessionTTL?: number;
|
|
36
|
+
/**
|
|
37
|
+
* TTL in seconds for messages (default: 30 days)
|
|
38
|
+
*/
|
|
39
|
+
messageTTL?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Redis Adapter - Provider-style API for Redis persistence
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import Redis from 'ioredis';
|
|
47
|
+
* import { Agent, RedisAdapter } from '@falai/agent';
|
|
48
|
+
*
|
|
49
|
+
* const redis = new Redis();
|
|
50
|
+
*
|
|
51
|
+
* const agent = new Agent({
|
|
52
|
+
* name: "My Agent",
|
|
53
|
+
* ai: provider,
|
|
54
|
+
* persistence: {
|
|
55
|
+
* adapter: new RedisAdapter({ redis }),
|
|
56
|
+
* userId: "user_123",
|
|
57
|
+
* },
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class RedisAdapter implements PersistenceAdapter {
|
|
62
|
+
readonly sessionRepository: SessionRepository;
|
|
63
|
+
readonly messageRepository: MessageRepository;
|
|
64
|
+
private redis;
|
|
65
|
+
private keyPrefix;
|
|
66
|
+
private sessionTTL;
|
|
67
|
+
private messageTTL;
|
|
68
|
+
constructor(options: RedisAdapterOptions);
|
|
69
|
+
disconnect(): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=RedisAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedisAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/RedisAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAIjB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,GAAG,EAAE,MA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C3B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,mBAAmB;IAmBlC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Redis adapter for persistence
|
|
4
|
+
* Uses Redis for fast session/message storage
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RedisAdapter = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Redis Adapter - Provider-style API for Redis persistence
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import Redis from 'ioredis';
|
|
14
|
+
* import { Agent, RedisAdapter } from '@falai/agent';
|
|
15
|
+
*
|
|
16
|
+
* const redis = new Redis();
|
|
17
|
+
*
|
|
18
|
+
* const agent = new Agent({
|
|
19
|
+
* name: "My Agent",
|
|
20
|
+
* ai: provider,
|
|
21
|
+
* persistence: {
|
|
22
|
+
* adapter: new RedisAdapter({ redis }),
|
|
23
|
+
* userId: "user_123",
|
|
24
|
+
* },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
class RedisAdapter {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
this.redis = options.redis;
|
|
31
|
+
this.keyPrefix = options.keyPrefix || "agent:";
|
|
32
|
+
this.sessionTTL = options.sessionTTL || 7 * 24 * 60 * 60; // 7 days
|
|
33
|
+
this.messageTTL = options.messageTTL || 30 * 24 * 60 * 60; // 30 days
|
|
34
|
+
this.sessionRepository = new RedisSessionRepository(this.redis, this.keyPrefix, this.sessionTTL);
|
|
35
|
+
this.messageRepository = new RedisMessageRepository(this.redis, this.keyPrefix, this.messageTTL);
|
|
36
|
+
}
|
|
37
|
+
async disconnect() {
|
|
38
|
+
await this.redis.quit();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.RedisAdapter = RedisAdapter;
|
|
42
|
+
/**
|
|
43
|
+
* Redis Session Repository
|
|
44
|
+
*/
|
|
45
|
+
class RedisSessionRepository {
|
|
46
|
+
constructor(redis, keyPrefix, ttl) {
|
|
47
|
+
this.redis = redis;
|
|
48
|
+
this.keyPrefix = keyPrefix;
|
|
49
|
+
this.ttl = ttl;
|
|
50
|
+
}
|
|
51
|
+
getKey(id) {
|
|
52
|
+
return `${this.keyPrefix}session:${id}`;
|
|
53
|
+
}
|
|
54
|
+
getUserKey(userId) {
|
|
55
|
+
return `${this.keyPrefix}user:${userId}:sessions`;
|
|
56
|
+
}
|
|
57
|
+
async create(data) {
|
|
58
|
+
const id = `session_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
59
|
+
const now = new Date();
|
|
60
|
+
const session = {
|
|
61
|
+
...data,
|
|
62
|
+
id,
|
|
63
|
+
createdAt: now,
|
|
64
|
+
updatedAt: now,
|
|
65
|
+
status: data.status || "active",
|
|
66
|
+
messageCount: data.messageCount || 0,
|
|
67
|
+
};
|
|
68
|
+
await this.redis.setex(this.getKey(id), this.ttl, JSON.stringify(session));
|
|
69
|
+
// Add to user's session list
|
|
70
|
+
if (data.userId) {
|
|
71
|
+
await this.redis.hset(this.getUserKey(data.userId), id, now.toISOString());
|
|
72
|
+
}
|
|
73
|
+
return session;
|
|
74
|
+
}
|
|
75
|
+
async findById(id) {
|
|
76
|
+
const data = await this.redis.get(this.getKey(id));
|
|
77
|
+
if (!data)
|
|
78
|
+
return null;
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(data);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(`Error parsing session data for id ${id}:`, error);
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async findActiveByUserId(userId) {
|
|
88
|
+
const sessionIds = await this.redis.hgetall(this.getUserKey(userId));
|
|
89
|
+
for (const sessionId of Object.keys(sessionIds)) {
|
|
90
|
+
const session = await this.findById(sessionId);
|
|
91
|
+
if (session && session.status === "active") {
|
|
92
|
+
return session;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
async findByUserId(userId, limit = 100) {
|
|
98
|
+
const sessionIds = await this.redis.hgetall(this.getUserKey(userId));
|
|
99
|
+
const sessions = [];
|
|
100
|
+
for (const sessionId of Object.keys(sessionIds).slice(0, limit)) {
|
|
101
|
+
const session = await this.findById(sessionId);
|
|
102
|
+
if (session) {
|
|
103
|
+
sessions.push(session);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return sessions.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
107
|
+
}
|
|
108
|
+
async update(id, data) {
|
|
109
|
+
const existing = await this.findById(id);
|
|
110
|
+
if (!existing)
|
|
111
|
+
return null;
|
|
112
|
+
const updated = {
|
|
113
|
+
...existing,
|
|
114
|
+
...data,
|
|
115
|
+
updatedAt: new Date(),
|
|
116
|
+
};
|
|
117
|
+
await this.redis.setex(this.getKey(id), this.ttl, JSON.stringify(updated));
|
|
118
|
+
return updated;
|
|
119
|
+
}
|
|
120
|
+
async updateStatus(id, status, completedAt) {
|
|
121
|
+
return this.update(id, { status, completedAt });
|
|
122
|
+
}
|
|
123
|
+
async updateCollectedData(id, collectedData) {
|
|
124
|
+
return this.update(id, { collectedData });
|
|
125
|
+
}
|
|
126
|
+
async updateRouteState(id, route, state) {
|
|
127
|
+
return this.update(id, { currentRoute: route, currentState: state });
|
|
128
|
+
}
|
|
129
|
+
async incrementMessageCount(id) {
|
|
130
|
+
const session = await this.findById(id);
|
|
131
|
+
if (!session)
|
|
132
|
+
return null;
|
|
133
|
+
return this.update(id, {
|
|
134
|
+
messageCount: (session.messageCount || 0) + 1,
|
|
135
|
+
lastMessageAt: new Date(),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
async delete(id) {
|
|
139
|
+
const result = await this.redis.del(this.getKey(id));
|
|
140
|
+
return result > 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Redis Message Repository
|
|
145
|
+
*/
|
|
146
|
+
class RedisMessageRepository {
|
|
147
|
+
constructor(redis, keyPrefix, ttl) {
|
|
148
|
+
this.redis = redis;
|
|
149
|
+
this.keyPrefix = keyPrefix;
|
|
150
|
+
this.ttl = ttl;
|
|
151
|
+
}
|
|
152
|
+
getKey(id) {
|
|
153
|
+
return `${this.keyPrefix}message:${id}`;
|
|
154
|
+
}
|
|
155
|
+
getSessionKey(sessionId) {
|
|
156
|
+
return `${this.keyPrefix}session:${sessionId}:messages`;
|
|
157
|
+
}
|
|
158
|
+
async create(data) {
|
|
159
|
+
const id = `msg_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
160
|
+
const message = {
|
|
161
|
+
...data,
|
|
162
|
+
id,
|
|
163
|
+
createdAt: new Date(),
|
|
164
|
+
};
|
|
165
|
+
await this.redis.setex(this.getKey(id), this.ttl, JSON.stringify(message));
|
|
166
|
+
await this.redis.hset(this.getSessionKey(data.sessionId), id, message.createdAt.toISOString());
|
|
167
|
+
return message;
|
|
168
|
+
}
|
|
169
|
+
async findById(id) {
|
|
170
|
+
const data = await this.redis.get(this.getKey(id));
|
|
171
|
+
if (!data)
|
|
172
|
+
return null;
|
|
173
|
+
try {
|
|
174
|
+
return JSON.parse(data);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
console.error(`Error parsing message data for id ${id}:`, error);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async findBySessionId(sessionId, limit = 1000) {
|
|
182
|
+
const messageIds = await this.redis.hgetall(this.getSessionKey(sessionId));
|
|
183
|
+
const messages = [];
|
|
184
|
+
for (const messageId of Object.keys(messageIds).slice(0, limit)) {
|
|
185
|
+
const message = await this.findById(messageId);
|
|
186
|
+
if (message) {
|
|
187
|
+
messages.push(message);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return messages.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
191
|
+
}
|
|
192
|
+
async findByUserId(userId, limit = 100) {
|
|
193
|
+
// Redis doesn't have efficient user-level querying
|
|
194
|
+
// This would require additional indexing
|
|
195
|
+
const pattern = `${this.keyPrefix}message:*`;
|
|
196
|
+
const keys = await this.redis.keys(pattern);
|
|
197
|
+
const messages = [];
|
|
198
|
+
for (const key of keys.slice(0, limit)) {
|
|
199
|
+
const data = await this.redis.get(key);
|
|
200
|
+
if (data) {
|
|
201
|
+
const message = JSON.parse(data);
|
|
202
|
+
if (message.userId === userId) {
|
|
203
|
+
messages.push(message);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return messages.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
|
208
|
+
}
|
|
209
|
+
async delete(id) {
|
|
210
|
+
const result = await this.redis.del(this.getKey(id));
|
|
211
|
+
return result > 0;
|
|
212
|
+
}
|
|
213
|
+
async deleteBySessionId(sessionId) {
|
|
214
|
+
const messageIds = await this.redis.hgetall(this.getSessionKey(sessionId));
|
|
215
|
+
const keys = Object.keys(messageIds).map((id) => this.getKey(id));
|
|
216
|
+
if (keys.length === 0)
|
|
217
|
+
return 0;
|
|
218
|
+
const result = await this.redis.del(...keys);
|
|
219
|
+
await this.redis.del(this.getSessionKey(sessionId));
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
async deleteByUserId(userId) {
|
|
223
|
+
const messages = await this.findByUserId(userId);
|
|
224
|
+
const keys = messages.map((m) => this.getKey(m.id));
|
|
225
|
+
if (keys.length === 0)
|
|
226
|
+
return 0;
|
|
227
|
+
return await this.redis.del(...keys);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=RedisAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AC;QAC3E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAElE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAEhC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7C,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;QAEpD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAAc;QACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEpD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAEhC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -3,4 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { PrismaAdapter } from "./PrismaAdapter";
|
|
5
5
|
export type { PrismaClient, FieldMappings, PrismaAdapterOptions, } from "./PrismaAdapter";
|
|
6
|
+
export { RedisAdapter } from "./RedisAdapter";
|
|
7
|
+
export type { RedisClient, RedisAdapterOptions } from "./RedisAdapter";
|
|
8
|
+
export { MongoAdapter } from "./MongoAdapter";
|
|
9
|
+
export type { MongoClient, MongoDatabase, MongoCollection, MongoAdapterOptions, } from "./MongoAdapter";
|
|
10
|
+
export { PostgreSQLAdapter } from "./PostgreSQLAdapter";
|
|
11
|
+
export type { PgClient, PgQueryResult, PostgreSQLAdapterOptions, } from "./PostgreSQLAdapter";
|
|
6
12
|
//# sourceMappingURL=index.d.ts.map
|