@agentionai/agents 0.3.0-beta

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 +517 -0
  2. package/dist/agents/Agent.d.ts +29 -0
  3. package/dist/agents/Agent.js +28 -0
  4. package/dist/agents/AgentConfig.d.ts +118 -0
  5. package/dist/agents/AgentConfig.js +3 -0
  6. package/dist/agents/AgentEvent.d.ts +18 -0
  7. package/dist/agents/AgentEvent.js +26 -0
  8. package/dist/agents/BaseAgent.d.ts +82 -0
  9. package/dist/agents/BaseAgent.js +121 -0
  10. package/dist/agents/anthropic/ClaudeAgent.d.ts +46 -0
  11. package/dist/agents/anthropic/ClaudeAgent.js +262 -0
  12. package/dist/agents/errors/AgentError.d.ts +47 -0
  13. package/dist/agents/errors/AgentError.js +74 -0
  14. package/dist/agents/google/GeminiAgent.d.ts +63 -0
  15. package/dist/agents/google/GeminiAgent.js +395 -0
  16. package/dist/agents/mistral/MistralAgent.d.ts +47 -0
  17. package/dist/agents/mistral/MistralAgent.js +313 -0
  18. package/dist/agents/model-types.d.ts +30 -0
  19. package/dist/agents/model-types.js +8 -0
  20. package/dist/agents/openai/OpenAiAgent.d.ts +48 -0
  21. package/dist/agents/openai/OpenAiAgent.js +338 -0
  22. package/dist/chunkers/Chunker.d.ts +53 -0
  23. package/dist/chunkers/Chunker.js +174 -0
  24. package/dist/chunkers/RecursiveChunker.d.ts +52 -0
  25. package/dist/chunkers/RecursiveChunker.js +166 -0
  26. package/dist/chunkers/TextChunker.d.ts +27 -0
  27. package/dist/chunkers/TextChunker.js +50 -0
  28. package/dist/chunkers/TokenChunker.d.ts +60 -0
  29. package/dist/chunkers/TokenChunker.js +176 -0
  30. package/dist/chunkers/index.d.ts +6 -0
  31. package/dist/chunkers/index.js +14 -0
  32. package/dist/chunkers/types.d.ts +95 -0
  33. package/dist/chunkers/types.js +3 -0
  34. package/dist/graph/AgentGraph.d.ts +99 -0
  35. package/dist/graph/AgentGraph.js +115 -0
  36. package/dist/graph/BaseExecutor.d.ts +86 -0
  37. package/dist/graph/BaseExecutor.js +61 -0
  38. package/dist/graph/GraphMetrics.d.ts +143 -0
  39. package/dist/graph/GraphMetrics.js +264 -0
  40. package/dist/graph/MapExecutor.d.ts +39 -0
  41. package/dist/graph/MapExecutor.js +123 -0
  42. package/dist/graph/ParallelExecutor.d.ts +51 -0
  43. package/dist/graph/ParallelExecutor.js +103 -0
  44. package/dist/graph/Pipeline.d.ts +44 -0
  45. package/dist/graph/Pipeline.js +109 -0
  46. package/dist/graph/RouterExecutor.d.ts +89 -0
  47. package/dist/graph/RouterExecutor.js +209 -0
  48. package/dist/graph/SequentialExecutor.d.ts +44 -0
  49. package/dist/graph/SequentialExecutor.js +115 -0
  50. package/dist/graph/VotingSystem.d.ts +54 -0
  51. package/dist/graph/VotingSystem.js +106 -0
  52. package/dist/history/History.d.ts +107 -0
  53. package/dist/history/History.js +166 -0
  54. package/dist/history/RedisHistory.d.ts +27 -0
  55. package/dist/history/RedisHistory.js +55 -0
  56. package/dist/history/transformers.d.ts +102 -0
  57. package/dist/history/transformers.js +415 -0
  58. package/dist/history/types.d.ts +130 -0
  59. package/dist/history/types.js +55 -0
  60. package/dist/index.d.ts +16 -0
  61. package/dist/index.js +48 -0
  62. package/dist/ingestion/IngestionPipeline.d.ts +86 -0
  63. package/dist/ingestion/IngestionPipeline.js +266 -0
  64. package/dist/ingestion/index.d.ts +3 -0
  65. package/dist/ingestion/index.js +7 -0
  66. package/dist/ingestion/types.d.ts +74 -0
  67. package/dist/ingestion/types.js +3 -0
  68. package/dist/team/Team.d.ts +46 -0
  69. package/dist/team/Team.js +104 -0
  70. package/dist/tools/Tool.d.ts +75 -0
  71. package/dist/tools/Tool.js +137 -0
  72. package/dist/vectorstore/Embeddings.d.ts +67 -0
  73. package/dist/vectorstore/Embeddings.js +54 -0
  74. package/dist/vectorstore/LanceDBVectorStore.d.ts +149 -0
  75. package/dist/vectorstore/LanceDBVectorStore.js +338 -0
  76. package/dist/vectorstore/OpenAIEmbeddings.d.ts +45 -0
  77. package/dist/vectorstore/OpenAIEmbeddings.js +109 -0
  78. package/dist/vectorstore/VectorStore.d.ts +255 -0
  79. package/dist/vectorstore/VectorStore.js +216 -0
  80. package/dist/vectorstore/index.d.ts +28 -0
  81. package/dist/vectorstore/index.js +35 -0
  82. package/dist/viz/VizConfig.d.ts +54 -0
  83. package/dist/viz/VizConfig.js +100 -0
  84. package/dist/viz/VizReporter.d.ts +127 -0
  85. package/dist/viz/VizReporter.js +595 -0
  86. package/dist/viz/index.d.ts +31 -0
  87. package/dist/viz/index.js +51 -0
  88. package/dist/viz/types.d.ts +105 -0
  89. package/dist/viz/types.js +7 -0
  90. package/package.json +109 -0
  91. package/readme.md +1 -0
@@ -0,0 +1,595 @@
1
+ "use strict";
2
+ /**
3
+ * VizReporter - Singleton for sending visualization events to @agention/viz.
4
+ *
5
+ * This class manages WebSocket connections and event reporting for agent monitoring.
6
+ * Events are queued when disconnected and flushed on reconnection.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.vizReporter = exports.VizReporter = void 0;
43
+ const events_1 = require("events");
44
+ const VizConfig_1 = require("./VizConfig");
45
+ // WebSocket implementation - supports both browser and Node.js
46
+ // In Node.js, requires 'ws' package to be installed
47
+ let WebSocketImpl = null;
48
+ let wsModuleLoaded = false;
49
+ async function loadWebSocket() {
50
+ if (wsModuleLoaded)
51
+ return WebSocketImpl;
52
+ wsModuleLoaded = true;
53
+ // Check for browser WebSocket
54
+ if (typeof WebSocket !== "undefined") {
55
+ WebSocketImpl = WebSocket;
56
+ return WebSocketImpl;
57
+ }
58
+ // Try to load Node.js ws module
59
+ try {
60
+ // Use dynamic import with a variable to avoid TypeScript resolution
61
+ const moduleName = "ws";
62
+ const wsModule = await Promise.resolve(`${moduleName}`).then(s => __importStar(require(s)));
63
+ WebSocketImpl = wsModule.default || wsModule;
64
+ return WebSocketImpl;
65
+ }
66
+ catch {
67
+ // ws module not installed - visualization will be disabled
68
+ return null;
69
+ }
70
+ }
71
+ /**
72
+ * Generate a unique ID for events
73
+ */
74
+ function generateId() {
75
+ return `${Date.now().toString(36)}-${Math.random()
76
+ .toString(36)
77
+ .slice(2, 11)}`;
78
+ }
79
+ /**
80
+ * Truncate a string to a maximum length
81
+ */
82
+ function truncate(str, maxLength = 200) {
83
+ if (str.length <= maxLength)
84
+ return str;
85
+ return str.slice(0, maxLength) + "...";
86
+ }
87
+ /**
88
+ * Safely stringify an object for summaries
89
+ */
90
+ function summarize(obj, maxLength = 200) {
91
+ try {
92
+ const str = typeof obj === "string" ? obj : JSON.stringify(obj);
93
+ return truncate(str, maxLength);
94
+ }
95
+ catch {
96
+ return "[Unable to serialize]";
97
+ }
98
+ }
99
+ class VizReporter extends events_1.EventEmitter {
100
+ constructor() {
101
+ super();
102
+ this.ws = null;
103
+ this.queue = [];
104
+ this.currentSessionId = null;
105
+ this.currentPipelineId = null;
106
+ this.eventStack = [];
107
+ this.eventTimings = new Map();
108
+ this.connecting = false;
109
+ this.reconnectTimer = null;
110
+ this.initWebSocket();
111
+ }
112
+ /**
113
+ * Get the singleton instance
114
+ */
115
+ static getInstance() {
116
+ if (!VizReporter.instance) {
117
+ VizReporter.instance = new VizReporter();
118
+ }
119
+ return VizReporter.instance;
120
+ }
121
+ /**
122
+ * Reset the singleton (for testing)
123
+ */
124
+ static resetInstance() {
125
+ if (VizReporter.instance) {
126
+ VizReporter.instance.disconnect();
127
+ VizReporter.instance = null;
128
+ }
129
+ }
130
+ /**
131
+ * Initialize WebSocket connection
132
+ */
133
+ async initWebSocket() {
134
+ if (!VizConfig_1.vizConfig.isEnabled())
135
+ return;
136
+ // Load WebSocket implementation
137
+ const ws = await loadWebSocket();
138
+ if (!ws) {
139
+ // WebSocket not available - this is fine, visualization just won't work
140
+ return;
141
+ }
142
+ this.tryConnect();
143
+ }
144
+ /**
145
+ * Attempt to connect to the visualization server
146
+ */
147
+ async tryConnect() {
148
+ if (!VizConfig_1.vizConfig.isEnabled() || this.connecting || this.ws)
149
+ return;
150
+ // Ensure WebSocket is loaded
151
+ const WS = await loadWebSocket();
152
+ if (!WS)
153
+ return;
154
+ this.connecting = true;
155
+ try {
156
+ const ws = new WS(VizConfig_1.vizConfig.getUrl());
157
+ ws.onopen = () => {
158
+ this.ws = ws;
159
+ this.connecting = false;
160
+ this.emit("connected");
161
+ this.flushQueue();
162
+ };
163
+ ws.onclose = () => {
164
+ this.ws = null;
165
+ this.connecting = false;
166
+ this.emit("disconnected");
167
+ this.scheduleReconnect();
168
+ };
169
+ ws.onerror = () => {
170
+ ws.close();
171
+ };
172
+ }
173
+ catch {
174
+ this.connecting = false;
175
+ this.scheduleReconnect();
176
+ }
177
+ }
178
+ /**
179
+ * Schedule a reconnection attempt
180
+ */
181
+ scheduleReconnect() {
182
+ if (!VizConfig_1.vizConfig.get().reconnect)
183
+ return;
184
+ if (this.reconnectTimer)
185
+ return;
186
+ this.reconnectTimer = setTimeout(() => {
187
+ this.reconnectTimer = null;
188
+ this.tryConnect();
189
+ }, VizConfig_1.vizConfig.get().reconnectInterval);
190
+ }
191
+ /**
192
+ * Flush queued events
193
+ */
194
+ flushQueue() {
195
+ if (!this.ws || this.ws.readyState !== 1)
196
+ return; // 1 = OPEN
197
+ while (this.queue.length > 0) {
198
+ const event = this.queue.shift();
199
+ if (event) {
200
+ this.ws.send(JSON.stringify(event));
201
+ }
202
+ }
203
+ }
204
+ /**
205
+ * Disconnect from the visualization server
206
+ */
207
+ disconnect() {
208
+ if (this.reconnectTimer) {
209
+ clearTimeout(this.reconnectTimer);
210
+ this.reconnectTimer = null;
211
+ }
212
+ if (this.ws) {
213
+ this.ws.close();
214
+ this.ws = null;
215
+ }
216
+ this.connecting = false;
217
+ }
218
+ /**
219
+ * Check if connected to the visualization server
220
+ */
221
+ isConnected() {
222
+ return this.ws !== null && this.ws.readyState === 1; // 1 = OPEN
223
+ }
224
+ /**
225
+ * Send an event to the visualization server
226
+ */
227
+ send(event) {
228
+ if (!VizConfig_1.vizConfig.isEnabled())
229
+ return;
230
+ const fullEvent = {
231
+ eventId: event.eventId || generateId(),
232
+ sessionId: event.sessionId || this.currentSessionId || "default",
233
+ pipelineId: event.pipelineId || this.currentPipelineId || undefined,
234
+ parentEventId: event.parentEventId ||
235
+ (this.eventStack.length > 0
236
+ ? this.eventStack[this.eventStack.length - 1]
237
+ : undefined),
238
+ timestamp: event.timestamp || Date.now(),
239
+ durationMs: event.durationMs,
240
+ eventType: event.eventType,
241
+ source: event.source,
242
+ payload: event.payload,
243
+ };
244
+ if (this.ws && this.ws.readyState === 1) {
245
+ // 1 = OPEN
246
+ this.ws.send(JSON.stringify(fullEvent));
247
+ }
248
+ else {
249
+ // Queue the event
250
+ if (this.queue.length < VizConfig_1.vizConfig.get().maxQueueSize) {
251
+ this.queue.push(fullEvent);
252
+ }
253
+ // Try to connect if not already
254
+ this.tryConnect();
255
+ }
256
+ }
257
+ // ============================================
258
+ // Session Management
259
+ // ============================================
260
+ /**
261
+ * Start a new session
262
+ */
263
+ startSession(name) {
264
+ const sessionId = generateId();
265
+ this.currentSessionId = sessionId;
266
+ const sessionName = name || VizConfig_1.vizConfig.getSessionName() || undefined;
267
+ this.send({
268
+ eventId: sessionId,
269
+ sessionId,
270
+ eventType: "session.start",
271
+ source: {
272
+ agentId: "system",
273
+ agentName: "System",
274
+ model: "n/a",
275
+ vendor: "anthropic",
276
+ },
277
+ payload: { name: sessionName },
278
+ });
279
+ return sessionId;
280
+ }
281
+ /**
282
+ * End the current session
283
+ */
284
+ endSession(reason = "completed") {
285
+ if (!this.currentSessionId)
286
+ return;
287
+ this.send({
288
+ sessionId: this.currentSessionId,
289
+ eventType: "session.end",
290
+ source: {
291
+ agentId: "system",
292
+ agentName: "System",
293
+ model: "n/a",
294
+ vendor: "anthropic",
295
+ },
296
+ payload: { reason },
297
+ });
298
+ this.currentSessionId = null;
299
+ }
300
+ /**
301
+ * Get or create a session ID
302
+ */
303
+ getSessionId() {
304
+ if (!this.currentSessionId) {
305
+ return this.startSession();
306
+ }
307
+ return this.currentSessionId;
308
+ }
309
+ /**
310
+ * Set the current session ID (for external session management)
311
+ */
312
+ setSessionId(sessionId) {
313
+ this.currentSessionId = sessionId;
314
+ }
315
+ // ============================================
316
+ // Pipeline Management
317
+ // ============================================
318
+ /**
319
+ * Start a pipeline execution
320
+ */
321
+ pipelineStart(name, structure, input, source) {
322
+ const eventId = generateId();
323
+ this.currentPipelineId = eventId;
324
+ this.eventStack.push(eventId);
325
+ this.eventTimings.set(eventId, { startTime: Date.now(), source });
326
+ this.send({
327
+ eventId,
328
+ pipelineId: eventId,
329
+ eventType: "pipeline.start",
330
+ source,
331
+ payload: {
332
+ pipelineName: name,
333
+ nodeType: "pipeline",
334
+ structure,
335
+ inputPreview: truncate(input),
336
+ },
337
+ });
338
+ return eventId;
339
+ }
340
+ /**
341
+ * End a pipeline execution
342
+ */
343
+ pipelineEnd(eventId, success, totalTokens, nodeCount, output, error) {
344
+ const timing = this.eventTimings.get(eventId);
345
+ const durationMs = timing ? Date.now() - timing.startTime : undefined;
346
+ this.send({
347
+ eventId,
348
+ pipelineId: eventId,
349
+ eventType: "pipeline.end",
350
+ durationMs,
351
+ source: timing?.source || {
352
+ agentId: "system",
353
+ agentName: "System",
354
+ model: "n/a",
355
+ vendor: "anthropic",
356
+ },
357
+ payload: {
358
+ success,
359
+ totalTokens,
360
+ nodeCount,
361
+ outputPreview: output ? truncate(output) : undefined,
362
+ error,
363
+ },
364
+ });
365
+ this.eventTimings.delete(eventId);
366
+ this.popEventStack(eventId);
367
+ if (this.currentPipelineId === eventId) {
368
+ this.currentPipelineId = null;
369
+ }
370
+ }
371
+ // ============================================
372
+ // Executor Management
373
+ // ============================================
374
+ /**
375
+ * Start an executor (sequential, parallel, map, voting, router)
376
+ */
377
+ executorStart(name, type, childCount, input, source) {
378
+ const eventId = generateId();
379
+ this.eventStack.push(eventId);
380
+ this.eventTimings.set(eventId, { startTime: Date.now(), source });
381
+ this.send({
382
+ eventId,
383
+ eventType: "executor.start",
384
+ source,
385
+ payload: {
386
+ executorName: name,
387
+ executorType: type,
388
+ childCount,
389
+ inputPreview: truncate(input),
390
+ },
391
+ });
392
+ return eventId;
393
+ }
394
+ /**
395
+ * End an executor
396
+ */
397
+ executorEnd(eventId, success, totalTokens, output, error) {
398
+ const timing = this.eventTimings.get(eventId);
399
+ const durationMs = timing ? Date.now() - timing.startTime : undefined;
400
+ this.send({
401
+ eventId,
402
+ eventType: "executor.end",
403
+ durationMs,
404
+ source: timing?.source || {
405
+ agentId: "system",
406
+ agentName: "System",
407
+ model: "n/a",
408
+ vendor: "anthropic",
409
+ },
410
+ payload: {
411
+ success,
412
+ totalTokens,
413
+ outputPreview: output ? truncate(output) : undefined,
414
+ error,
415
+ },
416
+ });
417
+ this.eventTimings.delete(eventId);
418
+ this.popEventStack(eventId);
419
+ }
420
+ // ============================================
421
+ // Agent Events
422
+ // ============================================
423
+ /**
424
+ * Report agent execution start
425
+ */
426
+ agentStart(agentId, agentName, model, vendor, input) {
427
+ const eventId = generateId();
428
+ const source = { agentId, agentName, model, vendor };
429
+ this.eventStack.push(eventId);
430
+ this.eventTimings.set(eventId, { startTime: Date.now(), source });
431
+ this.send({
432
+ eventId,
433
+ eventType: "agent.start",
434
+ source,
435
+ payload: {
436
+ inputPreview: truncate(input),
437
+ },
438
+ });
439
+ return eventId;
440
+ }
441
+ /**
442
+ * Report agent execution complete
443
+ */
444
+ agentComplete(eventId, tokens, stopReason, hasToolCalls, toolCallCount, output) {
445
+ const timing = this.eventTimings.get(eventId);
446
+ const durationMs = timing ? Date.now() - timing.startTime : undefined;
447
+ this.send({
448
+ eventId,
449
+ eventType: "agent.complete",
450
+ durationMs,
451
+ source: timing?.source || {
452
+ agentId: "unknown",
453
+ agentName: "Unknown",
454
+ model: "unknown",
455
+ vendor: "anthropic",
456
+ },
457
+ payload: {
458
+ tokens,
459
+ stopReason,
460
+ hasToolCalls,
461
+ toolCallCount,
462
+ outputPreview: truncate(output),
463
+ },
464
+ });
465
+ this.eventTimings.delete(eventId);
466
+ this.popEventStack(eventId);
467
+ }
468
+ /**
469
+ * Report agent execution error
470
+ */
471
+ agentError(eventId, errorType, errorMessage, retryable = false) {
472
+ const timing = this.eventTimings.get(eventId);
473
+ const durationMs = timing ? Date.now() - timing.startTime : undefined;
474
+ this.send({
475
+ eventId,
476
+ eventType: "agent.error",
477
+ durationMs,
478
+ source: timing?.source || {
479
+ agentId: "unknown",
480
+ agentName: "Unknown",
481
+ model: "unknown",
482
+ vendor: "anthropic",
483
+ },
484
+ payload: {
485
+ errorType,
486
+ errorMessage: truncate(errorMessage, 500),
487
+ retryable,
488
+ },
489
+ });
490
+ this.eventTimings.delete(eventId);
491
+ this.popEventStack(eventId);
492
+ }
493
+ // ============================================
494
+ // Tool Events
495
+ // ============================================
496
+ /**
497
+ * Report tool execution start
498
+ */
499
+ toolStart(toolName, toolId, input, agentSource) {
500
+ const eventId = generateId();
501
+ this.eventTimings.set(eventId, {
502
+ startTime: Date.now(),
503
+ source: agentSource,
504
+ });
505
+ this.send({
506
+ eventId,
507
+ eventType: "tool.start",
508
+ source: agentSource,
509
+ payload: {
510
+ toolName,
511
+ toolId,
512
+ inputSummary: summarize(input),
513
+ },
514
+ });
515
+ return eventId;
516
+ }
517
+ /**
518
+ * Report tool execution complete
519
+ */
520
+ toolComplete(eventId, toolName, toolId, success, result) {
521
+ const timing = this.eventTimings.get(eventId);
522
+ const durationMs = timing ? Date.now() - timing.startTime : undefined;
523
+ this.send({
524
+ eventId,
525
+ eventType: "tool.complete",
526
+ durationMs,
527
+ source: timing?.source || {
528
+ agentId: "unknown",
529
+ agentName: "Unknown",
530
+ model: "unknown",
531
+ vendor: "anthropic",
532
+ },
533
+ payload: {
534
+ toolName,
535
+ toolId,
536
+ success,
537
+ resultSummary: summarize(result),
538
+ },
539
+ });
540
+ this.eventTimings.delete(eventId);
541
+ }
542
+ /**
543
+ * Report tool execution error
544
+ */
545
+ toolError(eventId, toolName, toolId, errorMessage) {
546
+ const timing = this.eventTimings.get(eventId);
547
+ const durationMs = timing ? Date.now() - timing.startTime : undefined;
548
+ this.send({
549
+ eventId,
550
+ eventType: "tool.error",
551
+ durationMs,
552
+ source: timing?.source || {
553
+ agentId: "unknown",
554
+ agentName: "Unknown",
555
+ model: "unknown",
556
+ vendor: "anthropic",
557
+ },
558
+ payload: {
559
+ toolName,
560
+ toolId,
561
+ errorMessage: truncate(errorMessage, 500),
562
+ },
563
+ });
564
+ this.eventTimings.delete(eventId);
565
+ }
566
+ // ============================================
567
+ // Helper Methods
568
+ // ============================================
569
+ /**
570
+ * Pop an event from the stack
571
+ */
572
+ popEventStack(eventId) {
573
+ const index = this.eventStack.lastIndexOf(eventId);
574
+ if (index !== -1) {
575
+ this.eventStack.splice(index, 1);
576
+ }
577
+ }
578
+ /**
579
+ * Get current event stack depth
580
+ */
581
+ getStackDepth() {
582
+ return this.eventStack.length;
583
+ }
584
+ /**
585
+ * Get queued event count
586
+ */
587
+ getQueueSize() {
588
+ return this.queue.length;
589
+ }
590
+ }
591
+ exports.VizReporter = VizReporter;
592
+ VizReporter.instance = null;
593
+ /** Global VizReporter instance */
594
+ exports.vizReporter = VizReporter.getInstance();
595
+ //# sourceMappingURL=VizReporter.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Visualization module for agent monitoring.
3
+ *
4
+ * This module provides tools for sending agent execution events
5
+ * to a visualization server (@agention/viz).
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { vizConfig, vizReporter } from 'agention-lib';
10
+ *
11
+ * // Enable visualization programmatically
12
+ * vizConfig.set({ enabled: true, url: 'ws://localhost:4242/ws/agent' });
13
+ *
14
+ * // Or use environment variables:
15
+ * // AGENTION_VIZ_ENABLED=true
16
+ * // AGENTION_VIZ_URL=ws://localhost:4242/ws/agent
17
+ *
18
+ * // Start a session
19
+ * vizReporter.startSession('My Test Session');
20
+ *
21
+ * // Agent events are automatically reported when visualization is enabled
22
+ * const response = await agent.execute('Hello!');
23
+ *
24
+ * // End the session
25
+ * vizReporter.endSession('completed');
26
+ * ```
27
+ */
28
+ export { vizConfig, type VizConfigOptions } from "./VizConfig";
29
+ export { vizReporter, VizReporter } from "./VizReporter";
30
+ export * from "./types";
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * Visualization module for agent monitoring.
4
+ *
5
+ * This module provides tools for sending agent execution events
6
+ * to a visualization server (@agention/viz).
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { vizConfig, vizReporter } from 'agention-lib';
11
+ *
12
+ * // Enable visualization programmatically
13
+ * vizConfig.set({ enabled: true, url: 'ws://localhost:4242/ws/agent' });
14
+ *
15
+ * // Or use environment variables:
16
+ * // AGENTION_VIZ_ENABLED=true
17
+ * // AGENTION_VIZ_URL=ws://localhost:4242/ws/agent
18
+ *
19
+ * // Start a session
20
+ * vizReporter.startSession('My Test Session');
21
+ *
22
+ * // Agent events are automatically reported when visualization is enabled
23
+ * const response = await agent.execute('Hello!');
24
+ *
25
+ * // End the session
26
+ * vizReporter.endSession('completed');
27
+ * ```
28
+ */
29
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ var desc = Object.getOwnPropertyDescriptor(m, k);
32
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
33
+ desc = { enumerable: true, get: function() { return m[k]; } };
34
+ }
35
+ Object.defineProperty(o, k2, desc);
36
+ }) : (function(o, m, k, k2) {
37
+ if (k2 === undefined) k2 = k;
38
+ o[k2] = m[k];
39
+ }));
40
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
41
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.VizReporter = exports.vizReporter = exports.vizConfig = void 0;
45
+ var VizConfig_1 = require("./VizConfig");
46
+ Object.defineProperty(exports, "vizConfig", { enumerable: true, get: function () { return VizConfig_1.vizConfig; } });
47
+ var VizReporter_1 = require("./VizReporter");
48
+ Object.defineProperty(exports, "vizReporter", { enumerable: true, get: function () { return VizReporter_1.vizReporter; } });
49
+ Object.defineProperty(exports, "VizReporter", { enumerable: true, get: function () { return VizReporter_1.VizReporter; } });
50
+ __exportStar(require("./types"), exports);
51
+ //# sourceMappingURL=index.js.map