praisonai 1.2.0 → 1.2.2

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 (53) hide show
  1. package/dist/cache/index.d.ts +78 -0
  2. package/dist/cache/index.js +235 -0
  3. package/dist/db/postgres.d.ts +84 -0
  4. package/dist/db/postgres.js +266 -0
  5. package/dist/db/redis.d.ts +109 -0
  6. package/dist/db/redis.js +307 -0
  7. package/dist/db/sqlite.d.ts +66 -0
  8. package/dist/db/sqlite.js +339 -0
  9. package/dist/events/index.d.ts +84 -0
  10. package/dist/events/index.js +153 -0
  11. package/dist/index.d.ts +12 -1
  12. package/dist/index.js +88 -2
  13. package/dist/integrations/index.d.ts +7 -0
  14. package/dist/integrations/index.js +26 -0
  15. package/dist/integrations/observability/base.d.ts +123 -0
  16. package/dist/integrations/observability/base.js +183 -0
  17. package/dist/integrations/observability/index.d.ts +8 -0
  18. package/dist/integrations/observability/index.js +29 -0
  19. package/dist/integrations/observability/langfuse.d.ts +32 -0
  20. package/dist/integrations/observability/langfuse.js +174 -0
  21. package/dist/integrations/vector/base.d.ts +110 -0
  22. package/dist/integrations/vector/base.js +158 -0
  23. package/dist/integrations/vector/chroma.d.ts +25 -0
  24. package/dist/integrations/vector/chroma.js +143 -0
  25. package/dist/integrations/vector/index.d.ts +14 -0
  26. package/dist/integrations/vector/index.js +37 -0
  27. package/dist/integrations/vector/pinecone.d.ts +28 -0
  28. package/dist/integrations/vector/pinecone.js +172 -0
  29. package/dist/integrations/vector/qdrant.d.ts +25 -0
  30. package/dist/integrations/vector/qdrant.js +146 -0
  31. package/dist/integrations/vector/weaviate.d.ts +30 -0
  32. package/dist/integrations/vector/weaviate.js +206 -0
  33. package/dist/integrations/voice/base.d.ts +76 -0
  34. package/dist/integrations/voice/base.js +168 -0
  35. package/dist/integrations/voice/index.d.ts +6 -0
  36. package/dist/integrations/voice/index.js +26 -0
  37. package/dist/knowledge/graph-rag.d.ts +125 -0
  38. package/dist/knowledge/graph-rag.js +289 -0
  39. package/dist/knowledge/index.d.ts +2 -0
  40. package/dist/knowledge/index.js +18 -0
  41. package/dist/knowledge/reranker.d.ts +86 -0
  42. package/dist/knowledge/reranker.js +196 -0
  43. package/dist/tools/arxivTools.d.ts +19 -6
  44. package/dist/tools/arxivTools.js +13 -7
  45. package/dist/tools/base.d.ts +97 -0
  46. package/dist/tools/base.js +147 -0
  47. package/dist/tools/index.d.ts +1 -11
  48. package/dist/tools/index.js +7 -11
  49. package/dist/tools/mcpSse.d.ts +5 -3
  50. package/dist/tools/mcpSse.js +6 -4
  51. package/dist/workflows/yaml-parser.d.ts +48 -0
  52. package/dist/workflows/yaml-parser.js +304 -0
  53. package/package.json +1 -1
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ /**
3
+ * SQLite Database Adapter
4
+ * Persistent storage using SQLite for sessions, messages, and runs
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.SQLiteAdapter = void 0;
41
+ exports.createSQLiteAdapter = createSQLiteAdapter;
42
+ /**
43
+ * SQLite Adapter - Uses better-sqlite3 for synchronous operations
44
+ * Falls back to sql.js for browser compatibility
45
+ */
46
+ class SQLiteAdapter {
47
+ constructor(config) {
48
+ this.initialized = false;
49
+ this.filename = config.filename;
50
+ this.verbose = config.verbose || false;
51
+ }
52
+ async initialize() {
53
+ if (this.initialized)
54
+ return;
55
+ try {
56
+ // Try better-sqlite3 first (Node.js)
57
+ // @ts-ignore - optional dependency
58
+ const Database = (await Promise.resolve().then(() => __importStar(require('better-sqlite3')))).default;
59
+ this.db = new Database(this.filename, { verbose: this.verbose ? console.log : undefined });
60
+ this.db.pragma('journal_mode = WAL');
61
+ }
62
+ catch (e) {
63
+ // Fallback to in-memory Map-based storage
64
+ console.warn('SQLite not available, using in-memory storage');
65
+ this.db = new InMemoryDb();
66
+ }
67
+ await this.createTables();
68
+ this.initialized = true;
69
+ }
70
+ async createTables() {
71
+ if (this.db.exec) {
72
+ // better-sqlite3
73
+ this.db.exec(`
74
+ CREATE TABLE IF NOT EXISTS messages (
75
+ id TEXT PRIMARY KEY,
76
+ session_id TEXT NOT NULL,
77
+ role TEXT NOT NULL,
78
+ content TEXT NOT NULL,
79
+ tool_calls TEXT,
80
+ created_at INTEGER NOT NULL,
81
+ metadata TEXT,
82
+ FOREIGN KEY (session_id) REFERENCES sessions(id)
83
+ );
84
+
85
+ CREATE TABLE IF NOT EXISTS sessions (
86
+ id TEXT PRIMARY KEY,
87
+ created_at INTEGER NOT NULL,
88
+ updated_at INTEGER NOT NULL,
89
+ metadata TEXT
90
+ );
91
+
92
+ CREATE TABLE IF NOT EXISTS runs (
93
+ id TEXT PRIMARY KEY,
94
+ session_id TEXT NOT NULL,
95
+ agent_id TEXT,
96
+ status TEXT NOT NULL,
97
+ input TEXT,
98
+ output TEXT,
99
+ error TEXT,
100
+ started_at INTEGER NOT NULL,
101
+ completed_at INTEGER,
102
+ metadata TEXT
103
+ );
104
+
105
+ CREATE TABLE IF NOT EXISTS traces (
106
+ id TEXT PRIMARY KEY,
107
+ run_id TEXT NOT NULL,
108
+ span_id TEXT NOT NULL,
109
+ parent_span_id TEXT,
110
+ name TEXT NOT NULL,
111
+ type TEXT NOT NULL,
112
+ started_at INTEGER NOT NULL,
113
+ completed_at INTEGER,
114
+ attributes TEXT,
115
+ status TEXT
116
+ );
117
+
118
+ CREATE INDEX IF NOT EXISTS idx_messages_session ON messages(session_id);
119
+ CREATE INDEX IF NOT EXISTS idx_runs_session ON runs(session_id);
120
+ CREATE INDEX IF NOT EXISTS idx_traces_run ON traces(run_id);
121
+ `);
122
+ }
123
+ else {
124
+ // In-memory fallback
125
+ await this.db.createTables();
126
+ }
127
+ }
128
+ // Session operations
129
+ async createSession(id, metadata) {
130
+ await this.initialize();
131
+ const now = Date.now();
132
+ if (this.db.prepare) {
133
+ const stmt = this.db.prepare('INSERT OR REPLACE INTO sessions (id, created_at, updated_at, metadata) VALUES (?, ?, ?, ?)');
134
+ stmt.run(id, now, now, metadata ? JSON.stringify(metadata) : null);
135
+ }
136
+ else {
137
+ this.db.sessions.set(id, { id, createdAt: now, updatedAt: now, metadata });
138
+ }
139
+ }
140
+ async getSession(id) {
141
+ await this.initialize();
142
+ if (this.db.prepare) {
143
+ const stmt = this.db.prepare('SELECT * FROM sessions WHERE id = ?');
144
+ const row = stmt.get(id);
145
+ if (!row)
146
+ return null;
147
+ return {
148
+ id: row.id,
149
+ createdAt: row.created_at,
150
+ updatedAt: row.updated_at,
151
+ metadata: row.metadata ? JSON.parse(row.metadata) : undefined
152
+ };
153
+ }
154
+ else {
155
+ return this.db.sessions.get(id) || null;
156
+ }
157
+ }
158
+ // Message operations
159
+ async addMessage(message) {
160
+ await this.initialize();
161
+ if (this.db.prepare) {
162
+ const stmt = this.db.prepare('INSERT INTO messages (id, session_id, role, content, tool_calls, created_at, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)');
163
+ stmt.run(message.id, message.sessionId, message.role, message.content, message.toolCalls || null, message.createdAt, message.metadata || null);
164
+ }
165
+ else {
166
+ this.db.messages.set(message.id, message);
167
+ }
168
+ }
169
+ async getMessages(sessionId, limit) {
170
+ await this.initialize();
171
+ if (this.db.prepare) {
172
+ const query = limit
173
+ ? 'SELECT * FROM messages WHERE session_id = ? ORDER BY created_at DESC LIMIT ?'
174
+ : 'SELECT * FROM messages WHERE session_id = ? ORDER BY created_at ASC';
175
+ const stmt = this.db.prepare(query);
176
+ const rows = limit ? stmt.all(sessionId, limit) : stmt.all(sessionId);
177
+ return rows.map((row) => ({
178
+ id: row.id,
179
+ sessionId: row.session_id,
180
+ role: row.role,
181
+ content: row.content,
182
+ toolCalls: row.tool_calls,
183
+ createdAt: row.created_at,
184
+ metadata: row.metadata
185
+ }));
186
+ }
187
+ else {
188
+ const messages = Array.from(this.db.messages.values())
189
+ .filter((m) => m.sessionId === sessionId)
190
+ .sort((a, b) => a.createdAt - b.createdAt);
191
+ return limit ? messages.slice(-limit) : messages;
192
+ }
193
+ }
194
+ // Run operations
195
+ async createRun(run) {
196
+ await this.initialize();
197
+ if (this.db.prepare) {
198
+ const stmt = this.db.prepare('INSERT INTO runs (id, session_id, agent_id, status, input, output, error, started_at, completed_at, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
199
+ stmt.run(run.id, run.sessionId, run.agentId || null, run.status, run.input || null, run.output || null, run.error || null, run.startedAt, run.completedAt || null, run.metadata || null);
200
+ }
201
+ else {
202
+ this.db.runs.set(run.id, run);
203
+ }
204
+ }
205
+ async updateRun(id, updates) {
206
+ await this.initialize();
207
+ if (this.db.prepare) {
208
+ const fields = [];
209
+ const values = [];
210
+ if (updates.status !== undefined) {
211
+ fields.push('status = ?');
212
+ values.push(updates.status);
213
+ }
214
+ if (updates.output !== undefined) {
215
+ fields.push('output = ?');
216
+ values.push(updates.output);
217
+ }
218
+ if (updates.error !== undefined) {
219
+ fields.push('error = ?');
220
+ values.push(updates.error);
221
+ }
222
+ if (updates.completedAt !== undefined) {
223
+ fields.push('completed_at = ?');
224
+ values.push(updates.completedAt);
225
+ }
226
+ if (fields.length > 0) {
227
+ values.push(id);
228
+ const stmt = this.db.prepare(`UPDATE runs SET ${fields.join(', ')} WHERE id = ?`);
229
+ stmt.run(...values);
230
+ }
231
+ }
232
+ else {
233
+ const existing = this.db.runs.get(id);
234
+ if (existing) {
235
+ this.db.runs.set(id, { ...existing, ...updates });
236
+ }
237
+ }
238
+ }
239
+ async getRun(id) {
240
+ await this.initialize();
241
+ if (this.db.prepare) {
242
+ const stmt = this.db.prepare('SELECT * FROM runs WHERE id = ?');
243
+ const row = stmt.get(id);
244
+ if (!row)
245
+ return null;
246
+ return {
247
+ id: row.id,
248
+ sessionId: row.session_id,
249
+ agentId: row.agent_id,
250
+ status: row.status,
251
+ input: row.input,
252
+ output: row.output,
253
+ error: row.error,
254
+ startedAt: row.started_at,
255
+ completedAt: row.completed_at,
256
+ metadata: row.metadata
257
+ };
258
+ }
259
+ else {
260
+ return this.db.runs.get(id) || null;
261
+ }
262
+ }
263
+ // Trace operations
264
+ async addTrace(trace) {
265
+ await this.initialize();
266
+ if (this.db.prepare) {
267
+ const stmt = this.db.prepare('INSERT INTO traces (id, run_id, span_id, parent_span_id, name, type, started_at, completed_at, attributes, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
268
+ stmt.run(trace.id, trace.runId, trace.spanId, trace.parentSpanId || null, trace.name, trace.type, trace.startedAt, trace.completedAt || null, trace.attributes || null, trace.status || null);
269
+ }
270
+ else {
271
+ this.db.traces.set(trace.id, trace);
272
+ }
273
+ }
274
+ async getTraces(runId) {
275
+ await this.initialize();
276
+ if (this.db.prepare) {
277
+ const stmt = this.db.prepare('SELECT * FROM traces WHERE run_id = ? ORDER BY started_at ASC');
278
+ const rows = stmt.all(runId);
279
+ return rows.map((row) => ({
280
+ id: row.id,
281
+ runId: row.run_id,
282
+ spanId: row.span_id,
283
+ parentSpanId: row.parent_span_id,
284
+ name: row.name,
285
+ type: row.type,
286
+ startedAt: row.started_at,
287
+ completedAt: row.completed_at,
288
+ attributes: row.attributes,
289
+ status: row.status
290
+ }));
291
+ }
292
+ else {
293
+ return Array.from(this.db.traces.values())
294
+ .filter((t) => t.runId === runId)
295
+ .sort((a, b) => a.startedAt - b.startedAt);
296
+ }
297
+ }
298
+ // Cleanup
299
+ async close() {
300
+ if (this.db?.close) {
301
+ this.db.close();
302
+ }
303
+ this.initialized = false;
304
+ }
305
+ async clear() {
306
+ await this.initialize();
307
+ if (this.db.exec) {
308
+ this.db.exec('DELETE FROM traces; DELETE FROM runs; DELETE FROM messages; DELETE FROM sessions;');
309
+ }
310
+ else {
311
+ this.db.clear();
312
+ }
313
+ }
314
+ }
315
+ exports.SQLiteAdapter = SQLiteAdapter;
316
+ /**
317
+ * In-memory fallback database
318
+ */
319
+ class InMemoryDb {
320
+ constructor() {
321
+ this.sessions = new Map();
322
+ this.messages = new Map();
323
+ this.runs = new Map();
324
+ this.traces = new Map();
325
+ }
326
+ async createTables() {
327
+ // No-op for in-memory
328
+ }
329
+ clear() {
330
+ this.sessions.clear();
331
+ this.messages.clear();
332
+ this.runs.clear();
333
+ this.traces.clear();
334
+ }
335
+ }
336
+ // Factory function
337
+ function createSQLiteAdapter(config) {
338
+ return new SQLiteAdapter(config);
339
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Event System - PubSub and Event Emitter for agent communication
3
+ * Inspired by mastra's events module
4
+ */
5
+ import { EventEmitter } from 'events';
6
+ export interface Event {
7
+ id: string;
8
+ topic: string;
9
+ data: any;
10
+ createdAt: Date;
11
+ metadata?: Record<string, any>;
12
+ }
13
+ export type EventHandler = (event: Event, ack?: () => Promise<void>) => void | Promise<void>;
14
+ /**
15
+ * Abstract PubSub base class
16
+ */
17
+ export declare abstract class PubSub {
18
+ abstract publish(topic: string, data: any, metadata?: Record<string, any>): Promise<void>;
19
+ abstract subscribe(topic: string, handler: EventHandler): Promise<void>;
20
+ abstract unsubscribe(topic: string, handler: EventHandler): Promise<void>;
21
+ abstract close(): Promise<void>;
22
+ }
23
+ /**
24
+ * In-memory EventEmitter-based PubSub implementation
25
+ */
26
+ export declare class EventEmitterPubSub extends PubSub {
27
+ private emitter;
28
+ private handlers;
29
+ constructor(existingEmitter?: EventEmitter);
30
+ publish(topic: string, data: any, metadata?: Record<string, any>): Promise<void>;
31
+ subscribe(topic: string, handler: EventHandler): Promise<void>;
32
+ unsubscribe(topic: string, handler: EventHandler): Promise<void>;
33
+ close(): Promise<void>;
34
+ /**
35
+ * Wait for a specific event with optional timeout
36
+ */
37
+ waitFor(topic: string, timeout?: number): Promise<Event>;
38
+ /**
39
+ * Get the underlying EventEmitter
40
+ */
41
+ getEmitter(): EventEmitter;
42
+ }
43
+ /**
44
+ * Agent Event Bus - Specialized event system for agent communication
45
+ */
46
+ export declare class AgentEventBus {
47
+ private pubsub;
48
+ private agentId;
49
+ constructor(agentId: string, pubsub?: PubSub);
50
+ /**
51
+ * Emit an agent event
52
+ */
53
+ emit(eventType: string, data: any): Promise<void>;
54
+ /**
55
+ * Listen for agent events
56
+ */
57
+ on(eventType: string, handler: (data: any) => void | Promise<void>): Promise<void>;
58
+ /**
59
+ * Broadcast to all agents
60
+ */
61
+ broadcast(eventType: string, data: any): Promise<void>;
62
+ /**
63
+ * Listen for broadcast events
64
+ */
65
+ onBroadcast(eventType: string, handler: (data: any, sourceAgentId: string) => void | Promise<void>): Promise<void>;
66
+ /**
67
+ * Send message to specific agent
68
+ */
69
+ sendTo(targetAgentId: string, eventType: string, data: any): Promise<void>;
70
+ close(): Promise<void>;
71
+ }
72
+ export declare const AgentEvents: {
73
+ readonly STARTED: "started";
74
+ readonly COMPLETED: "completed";
75
+ readonly ERROR: "error";
76
+ readonly TOOL_CALLED: "tool_called";
77
+ readonly TOOL_RESULT: "tool_result";
78
+ readonly MESSAGE_RECEIVED: "message_received";
79
+ readonly MESSAGE_SENT: "message_sent";
80
+ readonly HANDOFF_INITIATED: "handoff_initiated";
81
+ readonly HANDOFF_COMPLETED: "handoff_completed";
82
+ };
83
+ export declare function createEventBus(agentId: string): AgentEventBus;
84
+ export declare function createPubSub(): EventEmitterPubSub;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ /**
3
+ * Event System - PubSub and Event Emitter for agent communication
4
+ * Inspired by mastra's events module
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.AgentEvents = exports.AgentEventBus = exports.EventEmitterPubSub = exports.PubSub = void 0;
8
+ exports.createEventBus = createEventBus;
9
+ exports.createPubSub = createPubSub;
10
+ const events_1 = require("events");
11
+ /**
12
+ * Abstract PubSub base class
13
+ */
14
+ class PubSub {
15
+ }
16
+ exports.PubSub = PubSub;
17
+ /**
18
+ * In-memory EventEmitter-based PubSub implementation
19
+ */
20
+ class EventEmitterPubSub extends PubSub {
21
+ constructor(existingEmitter) {
22
+ super();
23
+ this.handlers = new Map();
24
+ this.emitter = existingEmitter ?? new events_1.EventEmitter();
25
+ this.emitter.setMaxListeners(100); // Allow many listeners
26
+ }
27
+ async publish(topic, data, metadata) {
28
+ const event = {
29
+ id: crypto.randomUUID(),
30
+ topic,
31
+ data,
32
+ createdAt: new Date(),
33
+ metadata
34
+ };
35
+ this.emitter.emit(topic, event);
36
+ }
37
+ async subscribe(topic, handler) {
38
+ if (!this.handlers.has(topic)) {
39
+ this.handlers.set(topic, new Set());
40
+ }
41
+ this.handlers.get(topic).add(handler);
42
+ this.emitter.on(topic, handler);
43
+ }
44
+ async unsubscribe(topic, handler) {
45
+ this.handlers.get(topic)?.delete(handler);
46
+ this.emitter.off(topic, handler);
47
+ }
48
+ async close() {
49
+ this.emitter.removeAllListeners();
50
+ this.handlers.clear();
51
+ }
52
+ /**
53
+ * Wait for a specific event with optional timeout
54
+ */
55
+ async waitFor(topic, timeout) {
56
+ return new Promise((resolve, reject) => {
57
+ const timer = timeout ? setTimeout(() => {
58
+ this.emitter.off(topic, handler);
59
+ reject(new Error(`Timeout waiting for event: ${topic}`));
60
+ }, timeout) : null;
61
+ const handler = (event) => {
62
+ if (timer)
63
+ clearTimeout(timer);
64
+ this.emitter.off(topic, handler);
65
+ resolve(event);
66
+ };
67
+ this.emitter.once(topic, handler);
68
+ });
69
+ }
70
+ /**
71
+ * Get the underlying EventEmitter
72
+ */
73
+ getEmitter() {
74
+ return this.emitter;
75
+ }
76
+ }
77
+ exports.EventEmitterPubSub = EventEmitterPubSub;
78
+ /**
79
+ * Agent Event Bus - Specialized event system for agent communication
80
+ */
81
+ class AgentEventBus {
82
+ constructor(agentId, pubsub) {
83
+ this.agentId = agentId;
84
+ this.pubsub = pubsub ?? new EventEmitterPubSub();
85
+ }
86
+ /**
87
+ * Emit an agent event
88
+ */
89
+ async emit(eventType, data) {
90
+ await this.pubsub.publish(`agent:${this.agentId}:${eventType}`, data, {
91
+ agentId: this.agentId,
92
+ eventType
93
+ });
94
+ }
95
+ /**
96
+ * Listen for agent events
97
+ */
98
+ async on(eventType, handler) {
99
+ await this.pubsub.subscribe(`agent:${this.agentId}:${eventType}`, (event) => {
100
+ handler(event.data);
101
+ });
102
+ }
103
+ /**
104
+ * Broadcast to all agents
105
+ */
106
+ async broadcast(eventType, data) {
107
+ await this.pubsub.publish(`broadcast:${eventType}`, data, {
108
+ sourceAgentId: this.agentId,
109
+ eventType
110
+ });
111
+ }
112
+ /**
113
+ * Listen for broadcast events
114
+ */
115
+ async onBroadcast(eventType, handler) {
116
+ await this.pubsub.subscribe(`broadcast:${eventType}`, (event) => {
117
+ handler(event.data, event.metadata?.sourceAgentId);
118
+ });
119
+ }
120
+ /**
121
+ * Send message to specific agent
122
+ */
123
+ async sendTo(targetAgentId, eventType, data) {
124
+ await this.pubsub.publish(`agent:${targetAgentId}:${eventType}`, data, {
125
+ sourceAgentId: this.agentId,
126
+ targetAgentId,
127
+ eventType
128
+ });
129
+ }
130
+ async close() {
131
+ await this.pubsub.close();
132
+ }
133
+ }
134
+ exports.AgentEventBus = AgentEventBus;
135
+ // Standard event types
136
+ exports.AgentEvents = {
137
+ STARTED: 'started',
138
+ COMPLETED: 'completed',
139
+ ERROR: 'error',
140
+ TOOL_CALLED: 'tool_called',
141
+ TOOL_RESULT: 'tool_result',
142
+ MESSAGE_RECEIVED: 'message_received',
143
+ MESSAGE_SENT: 'message_sent',
144
+ HANDOFF_INITIATED: 'handoff_initiated',
145
+ HANDOFF_COMPLETED: 'handoff_completed'
146
+ };
147
+ // Factory functions
148
+ function createEventBus(agentId) {
149
+ return new AgentEventBus(agentId);
150
+ }
151
+ function createPubSub() {
152
+ return new EventEmitterPubSub();
153
+ }
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from './knowledge';
3
3
  export * from './llm';
4
4
  export * from './memory';
5
5
  export * from './process';
6
- export { Tool, BaseTool, FunctionTool, tool, ToolRegistry, getRegistry, registerTool, getTool, type ToolConfig, type ToolContext, type ToolParameters } from './tools';
6
+ export { BaseTool, ToolResult, ToolValidationError, validateTool, createTool, FunctionTool, tool, ToolRegistry, getRegistry, registerTool, getTool, type ToolConfig, type ToolContext, type ToolParameters } from './tools';
7
7
  export * from './tools/arxivTools';
8
8
  export * from './tools/mcpSse';
9
9
  export * from './session';
@@ -28,4 +28,15 @@ export { PromptExpanderAgent, createPromptExpanderAgent, type PromptExpanderConf
28
28
  export { Chunking, createChunking, type ChunkingConfig, type Chunk, type ChunkStrategy } from './knowledge/chunking';
29
29
  export { LLMGuardrail, createLLMGuardrail, type LLMGuardrailConfig, type LLMGuardrailResult } from './guardrails/llm-guardrail';
30
30
  export { Plan, PlanStep, TodoList, TodoItem, PlanStorage, createPlan, createTodoList, createPlanStorage, type PlanConfig, type PlanStepConfig, type TodoItemConfig, type PlanStatus, type TodoStatus } from './planning';
31
+ export { BaseCache, MemoryCache, FileCache, createMemoryCache, createFileCache, type CacheConfig, type CacheEntry } from './cache';
32
+ export { PubSub, EventEmitterPubSub, AgentEventBus, AgentEvents, createEventBus, createPubSub, type Event, type EventHandler } from './events';
33
+ export { parseYAMLWorkflow, createWorkflowFromYAML, loadWorkflowFromFile, validateWorkflowDefinition, type YAMLWorkflowDefinition, type YAMLStepDefinition, type ParsedWorkflow } from './workflows/yaml-parser';
34
+ export { SQLiteAdapter, createSQLiteAdapter, type SQLiteConfig, type DbMessage, type DbRun, type DbTrace } from './db/sqlite';
35
+ export { UpstashRedisAdapter, MemoryRedisAdapter, createUpstashRedis, createMemoryRedis, type RedisConfig, type RedisAdapter } from './db/redis';
36
+ export { NeonPostgresAdapter, MemoryPostgresAdapter, PostgresSessionStorage, createNeonPostgres, createMemoryPostgres, createPostgresSessionStorage, type PostgresConfig, type PostgresAdapter } from './db/postgres';
37
+ export { BaseVectorStore, MemoryVectorStore, createMemoryVectorStore, PineconeVectorStore, createPineconeStore, WeaviateVectorStore, createWeaviateStore, QdrantVectorStore, createQdrantStore, ChromaVectorStore, createChromaStore, type VectorDocument, type QueryResult as VectorQueryResult, type IndexStats } from './integrations/vector';
38
+ export { BaseObservabilityProvider, ConsoleObservabilityProvider, MemoryObservabilityProvider, LangfuseObservabilityProvider, createConsoleObservability, createMemoryObservability, createLangfuseObservability, type Span, type TraceContext as ObservabilityTraceContext, type LogEntry, type Metric } from './integrations/observability';
39
+ export { BaseVoiceProvider, OpenAIVoiceProvider, ElevenLabsVoiceProvider, createOpenAIVoice, createElevenLabsVoice, type VoiceConfig, type SpeakOptions, type ListenOptions, type Speaker } from './integrations/voice';
40
+ export { BaseReranker, CohereReranker, CrossEncoderReranker, LLMReranker, createCohereReranker, createCrossEncoderReranker, createLLMReranker, type RerankResult, type RerankConfig } from './knowledge/reranker';
41
+ export { GraphStore, GraphRAG, createGraphRAG, type GraphNode, type GraphEdge, type GraphQueryResult, type GraphRAGConfig } from './knowledge/graph-rag';
31
42
  export { createProvider, getDefaultProvider, parseModelString, isProviderAvailable, getAvailableProviders, OpenAIProvider, AnthropicProvider, GoogleProvider, BaseProvider, type LLMProvider, type ProviderConfig, type ProviderFactory, type GenerateTextOptions, type GenerateTextResult, type StreamTextOptions, type StreamChunk, type GenerateObjectOptions, type GenerateObjectResult, type TokenUsage, type Message as ProviderMessage, type ToolCall, type ToolDefinition as ProviderToolDefinition, } from './llm/providers';