agentic-flow 1.8.11 → 1.8.13

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 (31) hide show
  1. package/dist/cli/federation-cli.d.ts +53 -0
  2. package/dist/cli/federation-cli.js +431 -0
  3. package/dist/cli-proxy.js +28 -1
  4. package/dist/federation/EphemeralAgent.js +258 -0
  5. package/dist/federation/FederationHub.js +283 -0
  6. package/dist/federation/FederationHubClient.js +212 -0
  7. package/dist/federation/FederationHubServer.js +436 -0
  8. package/dist/federation/SecurityManager.js +191 -0
  9. package/dist/federation/debug/agent-debug-stream.js +474 -0
  10. package/dist/federation/debug/debug-stream.js +419 -0
  11. package/dist/federation/index.js +12 -0
  12. package/dist/federation/integrations/realtime-federation.js +404 -0
  13. package/dist/federation/integrations/supabase-adapter-debug.js +400 -0
  14. package/dist/federation/integrations/supabase-adapter.js +258 -0
  15. package/dist/utils/cli.js +5 -0
  16. package/docs/architecture/FEDERATION-DATA-LIFECYCLE.md +520 -0
  17. package/docs/federation/AGENT-DEBUG-STREAMING.md +403 -0
  18. package/docs/federation/DEBUG-STREAMING-COMPLETE.md +432 -0
  19. package/docs/federation/DEBUG-STREAMING.md +537 -0
  20. package/docs/federation/DEPLOYMENT-VALIDATION-SUCCESS.md +394 -0
  21. package/docs/federation/DOCKER-FEDERATION-DEEP-REVIEW.md +478 -0
  22. package/docs/issues/ISSUE-SUPABASE-INTEGRATION.md +536 -0
  23. package/docs/supabase/IMPLEMENTATION-SUMMARY.md +498 -0
  24. package/docs/supabase/INDEX.md +358 -0
  25. package/docs/supabase/QUICKSTART.md +365 -0
  26. package/docs/supabase/README.md +318 -0
  27. package/docs/supabase/SUPABASE-REALTIME-FEDERATION.md +575 -0
  28. package/docs/supabase/TEST-REPORT.md +446 -0
  29. package/docs/supabase/migrations/001_create_federation_tables.sql +339 -0
  30. package/docs/validation/reports/REGRESSION-TEST-V1.8.11.md +456 -0
  31. package/package.json +4 -1
@@ -0,0 +1,403 @@
1
+ # Single Agent Debug Streaming
2
+
3
+ **Version**: 1.0.0
4
+ **Date**: 2025-11-01
5
+ **Status**: ✅ Production Ready
6
+
7
+ ---
8
+
9
+ ## 🔍 Overview
10
+
11
+ Track a **single agent's complete lifecycle** with detailed visibility into every operation, decision, and state change.
12
+
13
+ **Perfect for**: Understanding agent behavior, debugging issues, performance tuning, learning how agents work.
14
+
15
+ ---
16
+
17
+ ## ✨ What You Get
18
+
19
+ ### Agent Lifecycle Tracking
20
+ - **Spawning** → **Initializing** → **Ready** → **Working** → **Idle** → **Shutting Down** → **Dead**
21
+ - Automatic phase transitions
22
+ - Timestamp every change
23
+ - Context for each phase
24
+
25
+ ### Task Execution Tracing
26
+ - Task start/complete/fail
27
+ - Individual step tracking
28
+ - Duration measurement
29
+ - Result capture
30
+ - Error logging
31
+
32
+ ### Decision Logging
33
+ - What decisions the agent makes
34
+ - Available options
35
+ - Selected choice
36
+ - Reasoning
37
+ - Confidence scores
38
+
39
+ ### Communication Tracking
40
+ - Messages sent
41
+ - Messages received
42
+ - Target agents
43
+ - Message types and sizes
44
+
45
+ ### Performance Metrics
46
+ - Operation timing
47
+ - Step duration
48
+ - Task completion time
49
+ - Average/min/max calculations
50
+ - Automatic aggregation
51
+
52
+ ### Timeline Visualization
53
+ - Chronological event log
54
+ - Elapsed time markers
55
+ - Complete agent history
56
+
57
+ ---
58
+
59
+ ## 🚀 Quick Start
60
+
61
+ ### Basic Usage
62
+
63
+ ```typescript
64
+ import { createAgentDebugStream, DebugLevel } from 'agentic-flow/federation/debug/agent-debug-stream';
65
+
66
+ // Create debug stream for your agent
67
+ const agentDebug = createAgentDebugStream({
68
+ agentId: 'my-agent-001',
69
+ tenantId: 'my-team',
70
+ level: DebugLevel.VERBOSE,
71
+ timeline: true,
72
+ });
73
+
74
+ // Track lifecycle
75
+ agentDebug.logInitialization({ type: 'researcher' });
76
+ agentDebug.logReady();
77
+
78
+ // Track task
79
+ agentDebug.startTask('task-001', 'Research AI safety');
80
+ agentDebug.logTaskStep('task-001', 0, 'web_search', { query: '...' });
81
+ agentDebug.completeTaskStep('task-001', 0, 200);
82
+ agentDebug.completeTask('task-001', { findings: [...] });
83
+
84
+ // Track decision
85
+ agentDebug.logDecision(
86
+ 'select_source',
87
+ [{ name: 'arxiv', score: 0.95 }, { name: 'scholar', score: 0.87 }],
88
+ { name: 'arxiv', score: 0.95 },
89
+ 'Highest relevance',
90
+ 0.95
91
+ );
92
+
93
+ // Track communication
94
+ agentDebug.logCommunication('send', 'other-agent', { type: 'data', payload: {...} });
95
+
96
+ // Print summary
97
+ agentDebug.printSummary();
98
+ agentDebug.printTimeline();
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 📊 Sample Output
104
+
105
+ ### Phase Transitions
106
+
107
+ ```
108
+ [2025-11-01T14:00:00.000Z] BASIC AGENT_LIFECYCLE phase_initializing
109
+ Data: {
110
+ "old_phase": "spawning",
111
+ "new_phase": "initializing",
112
+ "config": { "type": "researcher" }
113
+ }
114
+
115
+ 📍 Phase Change: spawning → initializing
116
+ ```
117
+
118
+ ### Task Execution
119
+
120
+ ```
121
+ [2025-11-01T14:00:01.000Z] VERBOS TASK task_start
122
+ Data: {
123
+ "taskId": "research-001",
124
+ "description": "Research AI safety frameworks"
125
+ }
126
+
127
+ [2025-11-01T14:00:01.050Z] VERBOS TASK_STEP web_search
128
+ Data: {
129
+ "taskId": "research-001",
130
+ "step": 0,
131
+ "query": "AI safety frameworks 2024"
132
+ }
133
+
134
+ [2025-11-01T14:00:01.250Z] VERBOS TASK_STEP step_complete
135
+ Data: {
136
+ "taskId": "research-001",
137
+ "step": 0,
138
+ "duration": 200,
139
+ "results_found": 15
140
+ }
141
+ ```
142
+
143
+ ### Decision Logging
144
+
145
+ ```
146
+ [2025-11-01T14:00:02.000Z] VERBOS DECISION decision_made
147
+ Data: {
148
+ "context": "select_papers_to_analyze",
149
+ "options_count": 3,
150
+ "selected": { "title": "Paper A", "relevance": 0.95 },
151
+ "reasoning": "Highest relevance score",
152
+ "confidence": 0.95
153
+ }
154
+
155
+ 🤔 Decision Made: select_papers_to_analyze → {"title":"Paper A","relevance":0.95}
156
+ ```
157
+
158
+ ### Agent Summary
159
+
160
+ ```
161
+ ============================================================
162
+ 📊 Agent Summary: research-agent-001
163
+ ============================================================
164
+
165
+ Uptime: 1.68s
166
+ Tasks Completed: 2
167
+ Tasks Failed: 0
168
+ Decisions Made: 1
169
+ Messages Sent: 1
170
+ Messages Recv: 1
171
+
172
+ Performance Metrics:
173
+ ------------------------------------------------------------
174
+ step_web_search 1x avg: 200.0ms min: 200.0ms max: 200.0ms
175
+ step_analyze_document 1x avg: 300.0ms min: 300.0ms max: 300.0ms
176
+ memory_store 1x avg: 15.0ms min: 15.0ms max: 15.0ms
177
+ task_completion 2x avg: 538.0ms min: 151.0ms max: 925.0ms
178
+
179
+ ============================================================
180
+ ```
181
+
182
+ ### Timeline View
183
+
184
+ ```
185
+ ============================================================
186
+ 📅 Agent Timeline
187
+ ============================================================
188
+
189
+ +0.000s | phase_change | {"from":"spawning","to":"initializing"}
190
+ +0.100s | phase_change | {"from":"initializing","to":"ready"}
191
+ +0.200s | phase_change | {"from":"ready","to":"working"}
192
+ +0.250s | task_start | {"taskId":"research-001"}
193
+ +1.100s | task_complete | {"taskId":"research-001","duration":925}
194
+ +1.150s | phase_change | {"from":"working","to":"idle"}
195
+
196
+ ============================================================
197
+ ```
198
+
199
+ ---
200
+
201
+ ## 🎯 Use Cases
202
+
203
+ ### 1. Debug a Failing Agent
204
+
205
+ ```typescript
206
+ const debug = createAgentDebugStream({
207
+ agentId: 'buggy-agent',
208
+ level: DebugLevel.TRACE, // Maximum detail
209
+ trackDecisions: true,
210
+ });
211
+
212
+ // When task fails, you'll see:
213
+ // - Exact phase when failure occurred
214
+ // - All decisions leading to failure
215
+ // - Complete stack of operations
216
+ // - Performance metrics showing slow operations
217
+ ```
218
+
219
+ ### 2. Understand Agent Behavior
220
+
221
+ ```typescript
222
+ const debug = createAgentDebugStream({
223
+ agentId: 'learning-agent',
224
+ timeline: true,
225
+ });
226
+
227
+ // After agent runs:
228
+ debug.printTimeline(); // See complete sequence of events
229
+ ```
230
+
231
+ ### 3. Performance Profiling
232
+
233
+ ```typescript
234
+ const debug = createAgentDebugStream({
235
+ agentId: 'slow-agent',
236
+ level: DebugLevel.DETAILED,
237
+ });
238
+
239
+ // Track every operation with timing
240
+ // Metrics show which operations are slow
241
+ debug.printSummary(); // See performance breakdown
242
+ ```
243
+
244
+ ### 4. Multi-Agent Coordination
245
+
246
+ ```typescript
247
+ // Track each agent individually
248
+ const agent1Debug = createAgentDebugStream({ agentId: 'agent-1' });
249
+ const agent2Debug = createAgentDebugStream({ agentId: 'agent-2' });
250
+ const agent3Debug = createAgentDebugStream({ agentId: 'agent-3' });
251
+
252
+ // See exactly how they interact
253
+ agent1Debug.logCommunication('send', 'agent-2', {...});
254
+ agent2Debug.logCommunication('receive', 'agent-1', {...});
255
+ ```
256
+
257
+ ---
258
+
259
+ ## 🔧 Configuration
260
+
261
+ ### AgentDebugConfig Options
262
+
263
+ ```typescript
264
+ interface AgentDebugConfig {
265
+ agentId: string; // Required: Agent identifier
266
+ tenantId?: string; // Optional: Tenant ID
267
+ level?: DebugLevel; // Verbosity level (default: VERBOSE)
268
+ format?: 'human' | 'json' | 'compact' | 'timeline';
269
+ output?: 'console' | 'file' | 'both';
270
+ outputFile?: string; // File path for output
271
+ colorize?: boolean; // Color-coded output (default: true)
272
+ trackState?: boolean; // Track state changes (default: true)
273
+ trackDecisions?: boolean; // Log decisions (default: false)
274
+ trackCommunication?: boolean; // Log messages (default: false)
275
+ timeline?: boolean; // Build timeline (default: false)
276
+ }
277
+ ```
278
+
279
+ ### Environment Variables
280
+
281
+ ```bash
282
+ DEBUG_LEVEL=VERBOSE # Verbosity level
283
+ DEBUG_FORMAT=human # Output format
284
+ DEBUG_OUTPUT=console # Output destination
285
+ DEBUG_TRACK_DECISIONS=true # Enable decision tracking
286
+ DEBUG_TRACK_COMMUNICATION=true # Enable communication tracking
287
+ DEBUG_TIMELINE=true # Enable timeline
288
+ ```
289
+
290
+ ---
291
+
292
+ ## 📚 API Reference
293
+
294
+ ### AgentDebugStream Methods
295
+
296
+ #### Lifecycle
297
+
298
+ - **`logAgentPhase(phase, data?)`** - Log phase change
299
+ - **`logInitialization(config)`** - Log agent initialization
300
+ - **`logReady(capabilities?)`** - Log agent ready
301
+ - **`logShutdown(reason?)`** - Log shutdown
302
+
303
+ #### Tasks
304
+
305
+ - **`startTask(taskId, description, data?)`** - Start tracking task
306
+ - **`logTaskStep(taskId, step, operation, data?)`** - Log task step
307
+ - **`completeTaskStep(taskId, step, duration, data?)`** - Complete step
308
+ - **`completeTask(taskId, result?)`** - Complete task
309
+ - **`failTask(taskId, error)`** - Mark task as failed
310
+
311
+ #### Decisions & Communication
312
+
313
+ - **`logDecision(context, options, selected, reasoning?, confidence?)`** - Log decision
314
+ - **`logCommunication(type, target, message)`** - Log send/receive
315
+ - **`logMemoryOperation(operation, data, duration?)`** - Log memory ops
316
+ - **`logThought(thought, context?)`** - Log reasoning
317
+
318
+ #### Reporting
319
+
320
+ - **`printSummary()`** - Print agent summary
321
+ - **`printTimeline()`** - Print chronological timeline
322
+ - **`getState()`** - Get current state
323
+ - **`getTasks()`** - Get task history
324
+ - **`getDecisions()`** - Get decision history
325
+ - **`getCommunications()`** - Get communication history
326
+
327
+ ---
328
+
329
+ ## 🎓 Best Practices
330
+
331
+ ### Development
332
+
333
+ ```bash
334
+ # Maximum visibility
335
+ DEBUG_LEVEL=TRACE \\
336
+ DEBUG_TIMELINE=true \\
337
+ DEBUG_TRACK_DECISIONS=true \\
338
+ DEBUG_TRACK_COMMUNICATION=true \\
339
+ npm start
340
+ ```
341
+
342
+ ### Debugging
343
+
344
+ ```typescript
345
+ // Enable all tracking
346
+ const debug = createAgentDebugStream({
347
+ agentId: agent.id,
348
+ level: DebugLevel.TRACE,
349
+ trackDecisions: true,
350
+ trackCommunication: true,
351
+ timeline: true,
352
+ });
353
+
354
+ // Subscribe to events
355
+ debug.on('phase_change', (data) => {
356
+ if (data.to === 'failed') {
357
+ console.error('AGENT FAILED!', data);
358
+ }
359
+ });
360
+ ```
361
+
362
+ ### Production
363
+
364
+ ```bash
365
+ # Minimal overhead
366
+ DEBUG_LEVEL=BASIC \\
367
+ DEBUG_FORMAT=json \\
368
+ DEBUG_OUTPUT=file \\
369
+ DEBUG_OUTPUT_FILE=/var/log/agent.log \\
370
+ npm start
371
+ ```
372
+
373
+ ---
374
+
375
+ ## ✅ Summary
376
+
377
+ **Single Agent Debug Streaming provides**:
378
+
379
+ ✅ **Complete lifecycle tracking** (spawn → shutdown)
380
+ ✅ **Task execution tracing** with steps
381
+ ✅ **Decision logging** with reasoning
382
+ ✅ **Communication tracking** (send/receive)
383
+ ✅ **Memory operation logging**
384
+ ✅ **Performance metrics** (automatic)
385
+ ✅ **Timeline visualization**
386
+ ✅ **Automatic summaries**
387
+ ✅ **Event subscriptions**
388
+ ✅ **Production-ready**
389
+
390
+ **Perfect for**:
391
+ - Debugging agent behavior
392
+ - Understanding decision-making
393
+ - Performance profiling
394
+ - Learning how agents work
395
+ - Multi-agent coordination debugging
396
+
397
+ ---
398
+
399
+ **Version**: 1.0.0
400
+ **Last Updated**: 2025-11-01
401
+ **Status**: ✅ Production Ready
402
+
403
+ 🔍 **Track your agents with complete visibility!**