agentflow-core 0.7.0 → 0.8.1

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/dist/index.d.ts CHANGED
@@ -50,6 +50,25 @@ interface TraceEvent {
50
50
  readonly nodeId: string;
51
51
  readonly data: Readonly<Record<string, unknown>>;
52
52
  }
53
+ /**
54
+ * Optional typed data for `decision` trace events.
55
+ * Frameworks can emit these to provide richer decision data than graph inference.
56
+ * SOMA will use these fields if present, falling back to graph-structure inference.
57
+ */
58
+ interface DecisionTraceData {
59
+ /** What was selected */
60
+ readonly choice: string;
61
+ /** Other options available */
62
+ readonly alternatives?: readonly string[];
63
+ /** Why this choice was made */
64
+ readonly rationale?: string;
65
+ /** Confidence in the decision (0.0-1.0) */
66
+ readonly confidence?: number;
67
+ /** Arbitrary context */
68
+ readonly context?: Readonly<Record<string, unknown>>;
69
+ /** Decision outcome */
70
+ readonly outcome?: string;
71
+ }
53
72
  /** The complete execution graph for one agent run. */
54
73
  interface ExecutionGraph {
55
74
  readonly id: string;
@@ -71,6 +90,8 @@ interface ExecutionGraph {
71
90
  readonly spanId?: string;
72
91
  /** Parent span ID, or null if this is the root span. */
73
92
  readonly parentSpanId?: string | null;
93
+ /** Arbitrary metadata preserved from the trace file. */
94
+ readonly metadata?: Record<string, unknown>;
74
95
  }
75
96
  /**
76
97
  * Configuration for AgentFlow.
@@ -229,6 +250,423 @@ interface DistributedTrace {
229
250
  readonly endTime: number | null;
230
251
  readonly status: GraphStatus;
231
252
  }
253
+ /** A transition between two steps in a discovered process model. */
254
+ interface ProcessTransition {
255
+ /** Source step identifier (`type:name`). */
256
+ readonly from: string;
257
+ /** Target step identifier (`type:name`). */
258
+ readonly to: string;
259
+ /** Absolute frequency: how many times this transition was observed. */
260
+ readonly count: number;
261
+ /** Relative frequency from the source step (0.0–1.0). */
262
+ readonly probability: number;
263
+ }
264
+ /** A process model discovered from multiple execution graphs. */
265
+ interface ProcessModel {
266
+ /** All observed step identifiers (`type:name`). */
267
+ readonly steps: readonly string[];
268
+ /** All observed transitions with frequencies. */
269
+ readonly transitions: readonly ProcessTransition[];
270
+ /** Number of graphs used to build this model. */
271
+ readonly totalGraphs: number;
272
+ /** Agent ID from the input graphs. */
273
+ readonly agentId: string;
274
+ }
275
+ /** A group of execution graphs that share the same structural path. */
276
+ interface Variant {
277
+ /** Canonical path signature for this variant. */
278
+ readonly pathSignature: string;
279
+ /** Number of graphs in this variant. */
280
+ readonly count: number;
281
+ /** Percentage of total graphs (0–100). */
282
+ readonly percentage: number;
283
+ /** IDs of graphs belonging to this variant. */
284
+ readonly graphIds: readonly string[];
285
+ /** First graph in the group (representative example). */
286
+ readonly exampleGraph: ExecutionGraph;
287
+ }
288
+ /** Duration statistics for a node across multiple execution graphs. */
289
+ interface Bottleneck {
290
+ /** Node name (e.g. `"fetch-data"`). */
291
+ readonly nodeName: string;
292
+ /** Node type (e.g. `"tool"`). */
293
+ readonly nodeType: NodeType;
294
+ /** How many graphs contain this node. */
295
+ readonly occurrences: number;
296
+ /** Duration statistics in milliseconds. */
297
+ readonly durations: {
298
+ readonly median: number;
299
+ readonly p95: number;
300
+ readonly p99: number;
301
+ readonly min: number;
302
+ readonly max: number;
303
+ };
304
+ /** Fraction of input graphs that include this node (0–100). */
305
+ readonly percentOfGraphs: number;
306
+ }
307
+ /** Category of deviation detected during conformance checking. */
308
+ type DeviationType = 'unexpected-transition' | 'missing-transition' | 'low-frequency-path';
309
+ /** A specific deviation between a graph and a process model. */
310
+ interface Deviation {
311
+ /** Category of deviation. */
312
+ readonly type: DeviationType;
313
+ /** Source step identifier. */
314
+ readonly from: string;
315
+ /** Target step identifier. */
316
+ readonly to: string;
317
+ /** Human-readable description of the deviation. */
318
+ readonly message: string;
319
+ /** Model probability of this transition (if applicable). */
320
+ readonly modelProbability?: number;
321
+ }
322
+ /** Result of comparing a single graph against a process model. */
323
+ interface ConformanceReport {
324
+ /** Ratio of conforming transitions to total transitions (0.0–1.0). */
325
+ readonly conformanceScore: number;
326
+ /** True when conformanceScore is 1.0 (no deviations). */
327
+ readonly isConforming: boolean;
328
+ /** List of specific deviations found. */
329
+ readonly deviations: readonly Deviation[];
330
+ }
331
+ /** Explanation attached to every guard violation for transparency. */
332
+ interface GuardExplanation {
333
+ /** The guard rule name (e.g., 'max-depth', 'timeout'). */
334
+ readonly rule: string;
335
+ /** The configured threshold that was exceeded. */
336
+ readonly threshold: number | string;
337
+ /** The actual observed value. */
338
+ readonly actual: number | string;
339
+ /** Where the threshold came from. */
340
+ readonly source: 'static' | 'soma-policy' | 'adaptive' | 'assertion';
341
+ /** Optional historical evidence supporting the threshold. */
342
+ readonly evidence?: string;
343
+ }
344
+ /** Outcome assertion for post-action verification. */
345
+ interface OutcomeAssertion {
346
+ /** Human-readable label for this assertion. */
347
+ readonly name: string;
348
+ /** Verification function — returns true if the expected outcome occurred. */
349
+ readonly verify: () => Promise<boolean> | boolean;
350
+ /** Timeout in milliseconds (default: 5000). */
351
+ readonly timeout?: number;
352
+ }
353
+ /**
354
+ * A detected guard violation.
355
+ */
356
+ interface GuardViolation {
357
+ readonly type: 'timeout' | 'reasoning-loop' | 'spawn-explosion' | 'high-failure-rate' | 'conformance-drift' | 'known-bottleneck' | 'outcome_mismatch';
358
+ readonly nodeId: string;
359
+ readonly message: string;
360
+ readonly timestamp: number;
361
+ readonly explanation: GuardExplanation;
362
+ }
363
+ /** Per-node cost attribution. */
364
+ interface NodeCost {
365
+ readonly nodeId: string;
366
+ readonly name: string;
367
+ readonly type: NodeType;
368
+ readonly tokenCost: number | null;
369
+ readonly durationMs: number | null;
370
+ }
371
+ /** Wasteful pattern detection flag. */
372
+ interface EfficiencyFlag {
373
+ readonly pattern: 'wasteful_retry' | 'context_bloat';
374
+ readonly nodeName: string;
375
+ readonly retryCount?: number;
376
+ readonly tokenCost: number;
377
+ readonly message: string;
378
+ }
379
+ /** Per-run efficiency summary. */
380
+ interface RunEfficiency {
381
+ readonly graphId: string;
382
+ readonly agentId: string;
383
+ readonly totalTokenCost: number;
384
+ readonly completedNodes: number;
385
+ readonly costPerNode: number;
386
+ }
387
+ /** Aggregate efficiency report across runs. */
388
+ interface EfficiencyReport {
389
+ readonly runs: readonly RunEfficiency[];
390
+ readonly aggregate: {
391
+ mean: number;
392
+ median: number;
393
+ p95: number;
394
+ };
395
+ readonly flags: readonly EfficiencyFlag[];
396
+ readonly nodeCosts: readonly NodeCost[];
397
+ readonly dataCoverage: number;
398
+ }
399
+ /** Per-step summary in a run receipt. */
400
+ interface StepSummary {
401
+ readonly nodeId: string;
402
+ readonly name: string;
403
+ readonly type: NodeType;
404
+ readonly status: NodeStatus;
405
+ readonly durationMs: number | null;
406
+ readonly tokenCost: number | null;
407
+ readonly error: string | null;
408
+ }
409
+ /** Structured run summary. */
410
+ interface RunReceipt {
411
+ readonly runId: string;
412
+ readonly agentId: string;
413
+ readonly status: GraphStatus;
414
+ readonly startTime: number;
415
+ readonly endTime: number | null;
416
+ readonly totalDurationMs: number | null;
417
+ readonly totalTokenCost: number | null;
418
+ readonly steps: readonly StepSummary[];
419
+ readonly summary: {
420
+ readonly attempted: number;
421
+ readonly succeeded: number;
422
+ readonly failed: number;
423
+ readonly skipped: number;
424
+ };
425
+ }
426
+ /** A single conformance history entry. */
427
+ interface ConformanceHistoryEntry {
428
+ readonly agentId: string;
429
+ readonly timestamp: number;
430
+ readonly score: number;
431
+ readonly runId: string;
432
+ }
433
+ /** Conformance score history for an agent. */
434
+ type ConformanceHistory = ConformanceHistoryEntry[];
435
+ /** Options for drift detection. */
436
+ interface DriftOptions {
437
+ /** Sliding window size (number of runs). Default: 50. */
438
+ readonly windowSize?: number;
439
+ }
440
+ /** Drift detection report. */
441
+ interface DriftReport {
442
+ readonly status: 'stable' | 'degrading' | 'improving' | 'insufficient_data';
443
+ readonly slope: number;
444
+ readonly r2: number;
445
+ readonly windowSize: number;
446
+ readonly dataPoints: number;
447
+ readonly alert?: {
448
+ readonly type: 'conformance_trend_degradation';
449
+ readonly agentId: string;
450
+ readonly currentScore: number;
451
+ readonly trendSlope: number;
452
+ readonly windowSize: number;
453
+ readonly message: string;
454
+ };
455
+ }
456
+ /** Options for variant analysis. */
457
+ interface VariantOptions {
458
+ /** Dimensions to include in variant signature. Default: ['path']. */
459
+ readonly dimensions?: readonly ('path' | 'modelId' | 'status')[];
460
+ }
461
+ /** Event type discriminator for AgentFlow events. */
462
+ type AgentFlowEventType = 'execution.completed' | 'execution.failed' | 'pattern.discovered' | 'pattern.updated';
463
+ /** Optional semantic context attached to an execution event by adapters. */
464
+ interface SemanticContext {
465
+ readonly intent?: string;
466
+ readonly trigger?: string;
467
+ readonly inputSummary?: string;
468
+ readonly outputSummary?: string;
469
+ readonly tokenCost?: number;
470
+ readonly modelId?: string;
471
+ }
472
+ /** Process mining context for an execution event. */
473
+ interface ProcessContext {
474
+ readonly variant: string;
475
+ readonly conformanceScore: number;
476
+ readonly isAnomaly: boolean;
477
+ }
478
+ /** The point at which an execution failed. */
479
+ interface FailurePoint {
480
+ readonly nodeId: string;
481
+ readonly nodeName: string;
482
+ readonly nodeType: NodeType;
483
+ readonly error?: string;
484
+ }
485
+ /** A structured event emitted after an agent execution completes or fails. */
486
+ interface ExecutionEvent {
487
+ readonly eventType: 'execution.completed' | 'execution.failed';
488
+ readonly graphId: string;
489
+ readonly agentId: string;
490
+ readonly timestamp: number;
491
+ readonly schemaVersion: number;
492
+ readonly status: GraphStatus;
493
+ readonly duration: number;
494
+ readonly nodeCount: number;
495
+ readonly pathSignature: string;
496
+ readonly failurePoint?: FailurePoint;
497
+ readonly processContext?: ProcessContext;
498
+ readonly semantic?: SemanticContext;
499
+ readonly violations: readonly GuardViolation[];
500
+ }
501
+ /** A structured event emitted when process mining discovers a pattern. */
502
+ interface PatternEvent {
503
+ readonly eventType: 'pattern.discovered' | 'pattern.updated';
504
+ readonly agentId: string;
505
+ readonly timestamp: number;
506
+ readonly schemaVersion: number;
507
+ readonly pattern: {
508
+ readonly totalGraphs: number;
509
+ readonly variantCount: number;
510
+ readonly topVariants: readonly {
511
+ readonly pathSignature: string;
512
+ readonly count: number;
513
+ readonly percentage: number;
514
+ }[];
515
+ readonly topBottlenecks: readonly {
516
+ readonly nodeName: string;
517
+ readonly nodeType: NodeType;
518
+ readonly p95: number;
519
+ }[];
520
+ readonly processModel: ProcessModel;
521
+ };
522
+ }
523
+ /** Options for creating an ExecutionEvent from a graph. */
524
+ interface ExecutionEventOptions {
525
+ readonly processContext?: ProcessContext;
526
+ readonly semantic?: SemanticContext;
527
+ readonly violations?: readonly GuardViolation[];
528
+ }
529
+ /** Configuration for the event emitter. */
530
+ interface EventEmitterConfig {
531
+ readonly writers?: readonly EventWriter[];
532
+ readonly onError?: (error: unknown) => void;
533
+ /** Optional knowledge store for automatic event persistence. */
534
+ readonly knowledgeStore?: KnowledgeStore;
535
+ }
536
+ /**
537
+ * Extended Writer interface that can handle structured events.
538
+ * Backward-compatible — existing Writers are unaffected.
539
+ */
540
+ interface EventWriter extends Writer {
541
+ /** Write a structured event to the output target. */
542
+ writeEvent(event: ExecutionEvent | PatternEvent): Promise<void>;
543
+ }
544
+ /** Event emitter for routing AgentFlow events to writers and subscribers. */
545
+ interface EventEmitter {
546
+ /** Emit an event to all writers and subscribers. */
547
+ emit(event: ExecutionEvent | PatternEvent): Promise<void>;
548
+ /** Subscribe to events. Returns an unsubscribe function. */
549
+ subscribe(listener: (event: ExecutionEvent | PatternEvent) => void): () => void;
550
+ }
551
+ /** Derived per-agent profile accumulated from execution and pattern events. */
552
+ interface AgentProfile {
553
+ readonly agentId: string;
554
+ readonly totalRuns: number;
555
+ readonly successCount: number;
556
+ readonly failureCount: number;
557
+ readonly failureRate: number;
558
+ readonly recentDurations: readonly number[];
559
+ readonly lastConformanceScore: number | null;
560
+ readonly knownBottlenecks: readonly string[];
561
+ readonly lastPatternTimestamp: number | null;
562
+ readonly updatedAt: string;
563
+ }
564
+ /** Configuration for the knowledge store. */
565
+ interface KnowledgeStoreConfig {
566
+ /** Base directory for knowledge storage. Defaults to `.agentflow/knowledge`. */
567
+ readonly baseDir?: string;
568
+ }
569
+ /**
570
+ * Filesystem-based knowledge store that accumulates execution and pattern events.
571
+ * Implements EventWriter so it can be used directly with createEventEmitter.
572
+ */
573
+ interface KnowledgeStore extends EventWriter {
574
+ /** Base directory of the knowledge store. */
575
+ readonly baseDir: string;
576
+ /** Persist an event and update the agent profile. */
577
+ append(event: ExecutionEvent | PatternEvent): void;
578
+ /** Query recent execution events for an agent. */
579
+ getRecentEvents(agentId: string, options?: {
580
+ limit?: number;
581
+ since?: number;
582
+ }): ExecutionEvent[];
583
+ /** Get the derived profile for an agent, or null if no history. */
584
+ getAgentProfile(agentId: string): AgentProfile | null;
585
+ /** Query pattern event history for an agent. */
586
+ getPatternHistory(agentId: string, options?: {
587
+ limit?: number;
588
+ }): PatternEvent[];
589
+ /** Remove event files older than the given timestamp. Profiles are preserved. */
590
+ compact(options: {
591
+ olderThan: number;
592
+ }): {
593
+ removed: number;
594
+ };
595
+ /** Persist an insight event generated by the insight engine. */
596
+ appendInsight(event: InsightEvent): void;
597
+ /** Query recent insight events for an agent. */
598
+ getRecentInsights(agentId: string, options?: {
599
+ type?: string;
600
+ limit?: number;
601
+ }): InsightEvent[];
602
+ }
603
+ /**
604
+ * Read-only interface for querying accumulated knowledge.
605
+ * Used by guards to make adaptive decisions based on execution history.
606
+ */
607
+ interface PolicySource {
608
+ /** Recent failure rate for an agent (0.0–1.0). Returns 0 if no history. */
609
+ recentFailureRate(agentId: string): number;
610
+ /** Whether a node name appears as a known bottleneck across any agent. */
611
+ isKnownBottleneck(nodeName: string): boolean;
612
+ /** Most recent conformance score for an agent, or null if none recorded. */
613
+ lastConformanceScore(agentId: string): number | null;
614
+ /** Full derived profile for an agent, or null if no history. */
615
+ getAgentProfile(agentId: string): AgentProfile | null;
616
+ }
617
+ /**
618
+ * User-provided LLM function. AgentFlow constructs prompts and delegates
619
+ * the actual LLM call to this function. Any provider can be wrapped as an AnalysisFn.
620
+ */
621
+ type AnalysisFn = (prompt: string) => Promise<string>;
622
+ /** A structured event emitted when the insight engine generates an LLM-powered analysis. */
623
+ interface InsightEvent {
624
+ readonly eventType: 'insight.generated';
625
+ readonly agentId: string;
626
+ readonly timestamp: number;
627
+ readonly schemaVersion: number;
628
+ readonly insightType: 'failure-analysis' | 'anomaly-explanation' | 'agent-summary' | 'fix-suggestion';
629
+ /** The prompt that was sent to the AnalysisFn (for auditing). */
630
+ readonly prompt: string;
631
+ /** The LLM response. */
632
+ readonly response: string;
633
+ /** Hash of input data — used for cache identity. */
634
+ readonly dataHash: string;
635
+ }
636
+ /** Result returned by InsightEngine methods. */
637
+ interface InsightResult {
638
+ readonly agentId: string;
639
+ readonly insightType: InsightEvent['insightType'];
640
+ /** The LLM response or pre-computed message. */
641
+ readonly content: string;
642
+ /** Whether this result came from cache. */
643
+ readonly cached: boolean;
644
+ /** When the insight was generated (epoch ms). */
645
+ readonly timestamp: number;
646
+ }
647
+ /** Configuration for the insight engine. */
648
+ interface InsightEngineConfig {
649
+ /** How long cached insights remain valid (ms). Default: 3600000 (1 hour). */
650
+ readonly cacheTtlMs?: number;
651
+ }
652
+ /** LLM-powered semantic analysis engine for agent execution data. */
653
+ interface InsightEngine {
654
+ /** Explain recent failures for an agent in natural language. */
655
+ explainFailures(agentId: string): Promise<InsightResult>;
656
+ /** Explain why a specific execution was anomalous. */
657
+ explainAnomaly(agentId: string, event: ExecutionEvent): Promise<InsightResult>;
658
+ /** Generate a natural language health summary for an agent. */
659
+ summarizeAgent(agentId: string): Promise<InsightResult>;
660
+ /** Suggest actionable fixes based on failure patterns and bottlenecks. */
661
+ suggestFixes(agentId: string): Promise<InsightResult>;
662
+ }
663
+ /** Thresholds for policy-derived guard violations. */
664
+ interface PolicyThresholds {
665
+ /** Maximum acceptable failure rate before triggering a violation (default 0.5). */
666
+ readonly maxFailureRate?: number;
667
+ /** Minimum acceptable conformance score before triggering a violation (default 0.7). */
668
+ readonly minConformance?: number;
669
+ }
232
670
  /** @internal Mutable version of ExecutionNode used during graph construction. */
233
671
  interface MutableExecutionNode {
234
672
  id: string;
@@ -243,6 +681,80 @@ interface MutableExecutionNode {
243
681
  state: Record<string, unknown>;
244
682
  }
245
683
 
684
+ /**
685
+ * Event emission layer for AgentFlow execution intelligence.
686
+ *
687
+ * Transforms completed execution graphs and process mining results into
688
+ * structured, self-describing events consumable by external systems
689
+ * (Soma, dashboards, sentinel agents, custom knowledge engines).
690
+ *
691
+ * @module
692
+ */
693
+
694
+ /**
695
+ * Create a structured ExecutionEvent from a completed execution graph.
696
+ *
697
+ * Pure function — no side effects. The returned event is self-describing:
698
+ * it contains all context needed to understand the execution without
699
+ * reading the original graph.
700
+ *
701
+ * @param graph - The completed execution graph.
702
+ * @param options - Optional process mining context, semantic context, and violations.
703
+ * @returns A structured ExecutionEvent.
704
+ *
705
+ * @example
706
+ * ```ts
707
+ * const event = createExecutionEvent(graph, {
708
+ * processContext: { variant: 'A→B→C', conformanceScore: 0.9, isAnomaly: false },
709
+ * semantic: { intent: 'daily-rebalance', trigger: 'cron' },
710
+ * });
711
+ * ```
712
+ */
713
+ declare function createExecutionEvent(graph: ExecutionGraph, options?: ExecutionEventOptions): ExecutionEvent;
714
+ /**
715
+ * Create a structured PatternEvent from process mining results.
716
+ *
717
+ * Pure function — no side effects. Summarizes the mining results into
718
+ * a compact event with top variants (up to 5) and top bottlenecks (up to 5).
719
+ *
720
+ * @param agentId - The agent these patterns belong to.
721
+ * @param model - The discovered process model.
722
+ * @param variants - Variant analysis results.
723
+ * @param bottlenecks - Bottleneck detection results.
724
+ * @returns A structured PatternEvent.
725
+ *
726
+ * @example
727
+ * ```ts
728
+ * const model = discoverProcess(graphs);
729
+ * const variants = findVariants(graphs);
730
+ * const bottlenecks = getBottlenecks(graphs);
731
+ * const event = createPatternEvent('my-agent', model, variants, bottlenecks);
732
+ * ```
733
+ */
734
+ declare function createPatternEvent(agentId: string, model: ProcessModel, variants: Variant[], bottlenecks: Bottleneck[]): PatternEvent;
735
+ /**
736
+ * Create an event emitter for routing AgentFlow events to writers and subscribers.
737
+ *
738
+ * The emitter is a simple pub/sub — no queuing, no retry, no backpressure.
739
+ * Writer errors are reported via the `onError` callback and do not block emission.
740
+ *
741
+ * @param config - Optional configuration with writers and error handler.
742
+ * @returns An EventEmitter with emit and subscribe methods.
743
+ *
744
+ * @example
745
+ * ```ts
746
+ * const emitter = createEventEmitter({
747
+ * writers: [jsonWriter],
748
+ * onError: (err) => console.error('Event write failed:', err),
749
+ * });
750
+ *
751
+ * emitter.subscribe((event) => console.log('Event:', event.eventType));
752
+ *
753
+ * await emitter.emit(createExecutionEvent(graph));
754
+ * ```
755
+ */
756
+ declare function createEventEmitter(config?: EventEmitterConfig): EventEmitter;
757
+
246
758
  /**
247
759
  * Closure-based factory for constructing execution graphs.
248
760
  *
@@ -423,16 +935,12 @@ interface GuardConfig {
423
935
  readonly onViolation?: 'warn' | 'error' | 'abort';
424
936
  /** Custom logger for warnings (defaults to console.warn). */
425
937
  readonly logger?: (message: string) => void;
938
+ /** Optional policy source for adaptive guard behavior based on accumulated knowledge. */
939
+ readonly policySource?: PolicySource;
940
+ /** Thresholds for policy-derived violations (only used when policySource is set). */
941
+ readonly policyThresholds?: PolicyThresholds;
426
942
  }
427
- /**
428
- * A detected guard violation.
429
- */
430
- interface GuardViolation {
431
- readonly type: 'timeout' | 'reasoning-loop' | 'spawn-explosion';
432
- readonly nodeId: string;
433
- readonly message: string;
434
- readonly timestamp: number;
435
- }
943
+
436
944
  /**
437
945
  * Check an execution graph for guard violations.
438
946
  *
@@ -475,6 +983,106 @@ declare function checkGuards(graph: ExecutionGraph, config?: GuardConfig): reado
475
983
  */
476
984
  declare function withGuards(builder: GraphBuilder, config?: GuardConfig): GraphBuilder;
477
985
 
986
+ /**
987
+ * LLM-powered semantic analysis engine for agent execution data.
988
+ *
989
+ * The insight engine reads from the knowledge store, constructs prompts via
990
+ * pure prompt builder functions, delegates to a user-provided AnalysisFn,
991
+ * and caches results as InsightEvents in the store.
992
+ *
993
+ * @module
994
+ */
995
+
996
+ /**
997
+ * Create an LLM-powered semantic analysis engine.
998
+ *
999
+ * @param store - The knowledge store to read data from and cache insights to.
1000
+ * @param analysisFn - User-provided LLM function (prompt → response).
1001
+ * @param config - Optional configuration (cache TTL).
1002
+ * @returns An InsightEngine for semantic analysis of agent execution data.
1003
+ *
1004
+ * @example
1005
+ * ```ts
1006
+ * const engine = createInsightEngine(store, async (prompt) => {
1007
+ * return await myLlm.complete(prompt);
1008
+ * });
1009
+ * const result = await engine.explainFailures('my-agent');
1010
+ * console.log(result.content);
1011
+ * ```
1012
+ */
1013
+ declare function createInsightEngine(store: KnowledgeStore, analysisFn: AnalysisFn, config?: InsightEngineConfig): InsightEngine;
1014
+
1015
+ /**
1016
+ * JSON file-based event writer for AgentFlow.
1017
+ *
1018
+ * Writes each event as an individual JSON file to a configurable directory.
1019
+ * Designed for filesystem-as-IPC: Soma's Curator (or any file-watching consumer)
1020
+ * picks up events from the output directory.
1021
+ *
1022
+ * @module
1023
+ */
1024
+
1025
+ /**
1026
+ * Configuration for the JSON event writer.
1027
+ */
1028
+ interface JsonEventWriterConfig {
1029
+ /** Directory to write event files to. Created if it does not exist. */
1030
+ readonly outputDir: string;
1031
+ }
1032
+ /**
1033
+ * Create a JSON event writer that persists events as individual files.
1034
+ *
1035
+ * Each event is written to `{eventType}-{agentId}-{timestamp}.json` where
1036
+ * dots in the eventType are replaced with dashes. Files are formatted with
1037
+ * 2-space indentation for human readability.
1038
+ *
1039
+ * The `write(graph)` method is a no-op — this writer only handles structured events.
1040
+ *
1041
+ * @param config - Writer configuration with output directory.
1042
+ * @returns An EventWriter that writes JSON files.
1043
+ *
1044
+ * @example
1045
+ * ```ts
1046
+ * const writer = createJsonEventWriter({ outputDir: './events' });
1047
+ * await writer.writeEvent(executionEvent);
1048
+ * // Creates: events/execution-completed-my-agent-1710800000000.json
1049
+ * ```
1050
+ */
1051
+ declare function createJsonEventWriter(config: JsonEventWriterConfig): EventWriter;
1052
+
1053
+ /**
1054
+ * Filesystem-based knowledge store for accumulating execution intelligence.
1055
+ *
1056
+ * Stores execution and pattern events as individual JSON files, organized by
1057
+ * agentId and date. Maintains derived agent profiles that summarize execution
1058
+ * history for fast querying by guards and dashboards.
1059
+ *
1060
+ * Storage layout:
1061
+ * ```
1062
+ * {baseDir}/
1063
+ * ├── events/{agentId}/{YYYY-MM-DD}/{eventType}-{timestamp}.json
1064
+ * ├── patterns/{agentId}/{timestamp}.json
1065
+ * └── profiles/{agentId}.json
1066
+ * ```
1067
+ *
1068
+ * @module
1069
+ */
1070
+
1071
+ /**
1072
+ * Create a filesystem-based knowledge store for accumulating execution intelligence.
1073
+ *
1074
+ * @param config - Optional configuration with base directory path.
1075
+ * @returns A KnowledgeStore that persists events and maintains agent profiles.
1076
+ *
1077
+ * @example
1078
+ * ```ts
1079
+ * const store = createKnowledgeStore({ baseDir: '.agentflow/knowledge' });
1080
+ * store.append(createExecutionEvent(graph));
1081
+ * const profile = store.getAgentProfile('my-agent');
1082
+ * ```
1083
+ */
1084
+ declare function createKnowledgeStore(config?: KnowledgeStoreConfig): KnowledgeStore;
1085
+
478
1086
  /**
479
1087
  * AgentFlow Live Monitor — real-time terminal dashboard for any agent system.
480
1088
  *
@@ -494,6 +1102,85 @@ declare function withGuards(builder: GraphBuilder, config?: GuardConfig): GraphB
494
1102
 
495
1103
  declare function startLive(argv: string[]): void;
496
1104
 
1105
+ /**
1106
+ * Load and deserialize execution graphs from JSON.
1107
+ *
1108
+ * Handles all serialization formats produced by the runner, graph-builder,
1109
+ * and third-party tools:
1110
+ * - `nodes` as a plain object `{ "node_001": { ... } }` (runner.ts output)
1111
+ * - `nodes` as an array of `[id, node]` pairs (Map JSON serialization)
1112
+ * - `nodes` already a Map (in-memory passthrough)
1113
+ *
1114
+ * @module
1115
+ */
1116
+
1117
+ /**
1118
+ * Deserialize a JSON object (or JSON string) into a valid `ExecutionGraph`.
1119
+ *
1120
+ * Use this whenever you read a trace file from disk or receive one over the
1121
+ * network. It normalizes `nodes` into a proper `Map` regardless of the
1122
+ * serialization format.
1123
+ *
1124
+ * @param input - A parsed JSON object, or a JSON string to be parsed.
1125
+ * @returns A valid `ExecutionGraph` ready for use with query functions.
1126
+ * @throws {Error} If the input cannot be parsed or is missing required fields.
1127
+ *
1128
+ * @example
1129
+ * ```ts
1130
+ * import { readFileSync } from 'fs';
1131
+ * import { loadGraph, getStats } from 'agentflow-core';
1132
+ *
1133
+ * const graph = loadGraph(readFileSync('trace.json', 'utf8'));
1134
+ * console.log(getStats(graph));
1135
+ * ```
1136
+ */
1137
+ declare function loadGraph(input: string | Record<string, unknown>): ExecutionGraph;
1138
+ /**
1139
+ * Serialize an `ExecutionGraph` to a plain JSON-safe object.
1140
+ *
1141
+ * The inverse of `loadGraph`. `nodes` is written as a plain object keyed by
1142
+ * node ID, which is the most readable format for trace files on disk.
1143
+ *
1144
+ * @param graph - The execution graph to serialize.
1145
+ * @returns A plain object safe to pass to `JSON.stringify`.
1146
+ *
1147
+ * @example
1148
+ * ```ts
1149
+ * import { writeFileSync } from 'fs';
1150
+ * import { graphToJson } from 'agentflow-core';
1151
+ *
1152
+ * writeFileSync('trace.json', JSON.stringify(graphToJson(graph), null, 2));
1153
+ * ```
1154
+ */
1155
+ declare function graphToJson(graph: ExecutionGraph): Record<string, unknown>;
1156
+
1157
+ /**
1158
+ * PolicySource: read-only interface over the knowledge store for adaptive guards.
1159
+ *
1160
+ * Bridges accumulated execution knowledge to guard decisions without
1161
+ * coupling guards to storage internals.
1162
+ *
1163
+ * @module
1164
+ */
1165
+
1166
+ /**
1167
+ * Create a PolicySource backed by a knowledge store.
1168
+ *
1169
+ * All methods delegate to the store's profile data. The PolicySource is a
1170
+ * pure read interface — it never writes to the store.
1171
+ *
1172
+ * @param store - The knowledge store to query.
1173
+ * @returns A PolicySource for use with adaptive guards.
1174
+ *
1175
+ * @example
1176
+ * ```ts
1177
+ * const store = createKnowledgeStore({ baseDir: '.agentflow/knowledge' });
1178
+ * const policy = createPolicySource(store);
1179
+ * const rate = policy.recentFailureRate('my-agent'); // 0.0–1.0
1180
+ * ```
1181
+ */
1182
+ declare function createPolicySource(store: KnowledgeStore): PolicySource;
1183
+
497
1184
  /**
498
1185
  * AgentFlow Process Audit — OS-level process health checks for agent systems.
499
1186
  *
@@ -581,6 +1268,22 @@ interface ProcessAuditConfig {
581
1268
  * ```
582
1269
  */
583
1270
  declare function discoverProcessConfig(dirs: string[]): ProcessAuditConfig | null;
1271
+ /**
1272
+ * Discover all process configurations from the given directories and systemd.
1273
+ *
1274
+ * Unlike `discoverProcessConfig` which returns only the first match, this
1275
+ * scans all PID files and also discovers systemd user services to return
1276
+ * a complete list of auditable processes.
1277
+ *
1278
+ * @example
1279
+ * ```ts
1280
+ * const configs = discoverAllProcessConfigs(['./data', '/var/run']);
1281
+ * for (const config of configs) {
1282
+ * console.log(formatAuditReport(auditProcesses(config)));
1283
+ * }
1284
+ * ```
1285
+ */
1286
+ declare function discoverAllProcessConfigs(dirs: string[]): ProcessAuditConfig[];
584
1287
  /**
585
1288
  * Run a full process health audit.
586
1289
  *
@@ -609,56 +1312,198 @@ declare function auditProcesses(config: ProcessAuditConfig): ProcessAuditResult;
609
1312
  declare function formatAuditReport(result: ProcessAuditResult): string;
610
1313
 
611
1314
  /**
612
- * Load and deserialize execution graphs from JSON.
1315
+ * Process mining primitives for cross-run analysis of execution graphs.
613
1316
  *
614
- * Handles all serialization formats produced by the runner, graph-builder,
615
- * and third-party tools:
616
- * - `nodes` as a plain object `{ "node_001": { ... } }` (runner.ts output)
617
- * - `nodes` as an array of `[id, node]` pairs (Map JSON serialization)
618
- * - `nodes` already a Map (in-memory passthrough)
1317
+ * All functions are pure: they take frozen graphs and return derived data
1318
+ * without mutation or side effects. Designed to operate on `ExecutionGraph[]`
1319
+ * collections to discover patterns across multiple agent runs.
619
1320
  *
620
1321
  * @module
621
1322
  */
622
1323
 
623
1324
  /**
624
- * Deserialize a JSON object (or JSON string) into a valid `ExecutionGraph`.
1325
+ * Produce a canonical string representation of a graph's execution path.
625
1326
  *
626
- * Use this whenever you read a trace file from disk or receive one over the
627
- * network. It normalizes `nodes` into a proper `Map` regardless of the
628
- * serialization format.
1327
+ * Performs a depth-first traversal, emitting `type:name` for each node.
1328
+ * Children are sorted alphabetically by `type:name` to ensure deterministic output.
629
1329
  *
630
- * @param input - A parsed JSON object, or a JSON string to be parsed.
631
- * @returns A valid `ExecutionGraph` ready for use with query functions.
632
- * @throws {Error} If the input cannot be parsed or is missing required fields.
1330
+ * @param graph - The execution graph.
1331
+ * @returns A `→`-separated path signature, or `""` if the root is unresolvable.
633
1332
  *
634
1333
  * @example
635
1334
  * ```ts
636
- * import { readFileSync } from 'fs';
637
- * import { loadGraph, getStats } from 'agentflow-core';
1335
+ * const sig = getPathSignature(graph);
1336
+ * // "agent:main→tool:fetch→tool:analyze"
1337
+ * ```
1338
+ */
1339
+ declare function getPathSignature(graph: ExecutionGraph): string;
1340
+ /**
1341
+ * Discover a process model from multiple execution graphs.
638
1342
  *
639
- * const graph = loadGraph(readFileSync('trace.json', 'utf8'));
640
- * console.log(getStats(graph));
1343
+ * Walks every graph's node tree and counts parent→child transitions.
1344
+ * The returned model is a directly-follows graph (DFG) annotated with
1345
+ * absolute and relative frequencies.
1346
+ *
1347
+ * @param graphs - Array of execution graphs (must not be empty).
1348
+ * @returns A process model with steps, transitions, and frequencies.
1349
+ * @throws If `graphs` is empty.
1350
+ *
1351
+ * @example
1352
+ * ```ts
1353
+ * const model = discoverProcess(graphs);
1354
+ * for (const t of model.transitions) {
1355
+ * console.log(`${t.from} → ${t.to} (${(t.probability * 100).toFixed(0)}%)`);
1356
+ * }
641
1357
  * ```
642
1358
  */
643
- declare function loadGraph(input: string | Record<string, unknown>): ExecutionGraph;
1359
+ declare function discoverProcess(graphs: ExecutionGraph[]): ProcessModel;
644
1360
  /**
645
- * Serialize an `ExecutionGraph` to a plain JSON-safe object.
1361
+ * Group execution graphs by their structural path and return variant clusters.
646
1362
  *
647
- * The inverse of `loadGraph`. `nodes` is written as a plain object keyed by
648
- * node ID, which is the most readable format for trace files on disk.
1363
+ * Variants are sorted by frequency (most common first). Ties are broken
1364
+ * alphabetically by path signature.
649
1365
  *
650
- * @param graph - The execution graph to serialize.
651
- * @returns A plain object safe to pass to `JSON.stringify`.
1366
+ * @param graphs - Array of execution graphs.
1367
+ * @returns Variant clusters sorted by frequency descending.
652
1368
  *
653
1369
  * @example
654
1370
  * ```ts
655
- * import { writeFileSync } from 'fs';
656
- * import { graphToJson } from 'agentflow-core';
1371
+ * const variants = findVariants(graphs);
1372
+ * console.log(`${variants[0].percentage}% of runs follow the happy path`);
1373
+ * ```
1374
+ */
1375
+ declare function findVariants(graphs: ExecutionGraph[]): Variant[];
1376
+ /**
1377
+ * Identify performance bottlenecks by aggregating node durations across graphs.
657
1378
  *
658
- * writeFileSync('trace.json', JSON.stringify(graphToJson(graph), null, 2));
1379
+ * Collects duration samples per node `name` (grouped by `type:name`),
1380
+ * computes percentile statistics, and returns results sorted by p95 descending.
1381
+ *
1382
+ * @param graphs - Array of execution graphs.
1383
+ * @returns Bottleneck entries sorted by p95 duration descending.
1384
+ *
1385
+ * @example
1386
+ * ```ts
1387
+ * const bottlenecks = getBottlenecks(graphs);
1388
+ * console.log(`Slowest: ${bottlenecks[0].nodeName} (p95: ${bottlenecks[0].durations.p95}ms)`);
659
1389
  * ```
660
1390
  */
661
- declare function graphToJson(graph: ExecutionGraph): Record<string, unknown>;
1391
+ declare function getBottlenecks(graphs: ExecutionGraph[]): Bottleneck[];
1392
+ /**
1393
+ * Compare a single execution graph against a discovered process model.
1394
+ *
1395
+ * Classifies deviations into three categories:
1396
+ * - `unexpected-transition`: exists in the graph but not in the model
1397
+ * - `missing-transition`: exists in the model with probability > 0.5 but not in the graph
1398
+ * - `low-frequency-path`: exists in both but model probability < 0.1
1399
+ *
1400
+ * @param graph - The execution graph to check.
1401
+ * @param model - The process model to check against.
1402
+ * @returns A conformance report with score, deviations, and conformance flag.
1403
+ *
1404
+ * @example
1405
+ * ```ts
1406
+ * const report = checkConformance(newRun, model);
1407
+ * if (!report.isConforming) {
1408
+ * console.log(`Conformance: ${(report.conformanceScore * 100).toFixed(0)}%`);
1409
+ * for (const d of report.deviations) console.log(d.message);
1410
+ * }
1411
+ * ```
1412
+ */
1413
+ declare function checkConformance(graph: ExecutionGraph, model: ProcessModel): ConformanceReport;
1414
+
1415
+ /**
1416
+ * Pure prompt construction functions for LLM-powered semantic analysis.
1417
+ *
1418
+ * Each function takes knowledge store data and returns a structured prompt string.
1419
+ * No side effects, no filesystem access, no external calls.
1420
+ *
1421
+ * @module
1422
+ */
1423
+
1424
+ /**
1425
+ * Build a structured prompt for LLM analysis of agent failures.
1426
+ *
1427
+ * @param events - Recent failed execution events for the agent.
1428
+ * @param profile - The agent's derived profile.
1429
+ * @returns A structured prompt string.
1430
+ */
1431
+ declare function buildFailureAnalysisPrompt(events: ExecutionEvent[], profile: AgentProfile): string;
1432
+ /**
1433
+ * Build a structured prompt for explaining why an execution was anomalous.
1434
+ *
1435
+ * @param event - The specific execution event flagged as anomalous.
1436
+ * @param profile - The agent's derived profile for baseline context.
1437
+ * @returns A structured prompt string.
1438
+ */
1439
+ declare function buildAnomalyExplanationPrompt(event: ExecutionEvent, profile: AgentProfile): string;
1440
+ /**
1441
+ * Build a structured prompt for generating an agent health summary.
1442
+ *
1443
+ * @param profile - The agent's derived profile.
1444
+ * @param recentEvents - Recent execution events.
1445
+ * @param patterns - Recent pattern discovery events.
1446
+ * @returns A structured prompt string.
1447
+ */
1448
+ declare function buildAgentSummaryPrompt(profile: AgentProfile, recentEvents: ExecutionEvent[], patterns: PatternEvent[]): string;
1449
+ /**
1450
+ * Build a structured prompt for generating actionable fix recommendations.
1451
+ *
1452
+ * @param events - Recent failed execution events.
1453
+ * @param profile - The agent's derived profile.
1454
+ * @param patterns - Recent pattern discovery events.
1455
+ * @returns A structured prompt string.
1456
+ */
1457
+ declare function buildFixSuggestionPrompt(events: ExecutionEvent[], profile: AgentProfile, patterns: PatternEvent[]): string;
1458
+
1459
+ /**
1460
+ * Pure functions for building and formatting run receipts from execution graphs.
1461
+ *
1462
+ * A receipt is a structured summary of a completed (or running) agent execution,
1463
+ * including per-step details, cost attribution, and aggregate counts.
1464
+ * @module
1465
+ */
1466
+
1467
+ /**
1468
+ * Walk an execution graph and produce a structured {@link RunReceipt}.
1469
+ *
1470
+ * Steps are sorted by `startTime`. Summary counts classify each node as
1471
+ * succeeded (`completed`), failed (`failed | hung | timeout`), or skipped
1472
+ * (none currently — reserved for future use). `attempted` equals the total
1473
+ * node count.
1474
+ *
1475
+ * @param graph - A built (or snapshot) execution graph.
1476
+ * @returns A frozen run receipt.
1477
+ */
1478
+ declare function toReceipt(graph: ExecutionGraph): RunReceipt;
1479
+ /**
1480
+ * Format a {@link RunReceipt} into a human-readable text block.
1481
+ *
1482
+ * Layout:
1483
+ * ```
1484
+ * === Run Receipt ===
1485
+ * Run: <runId>
1486
+ * Agent: <agentId>
1487
+ * Status: <status>
1488
+ * Duration: <totalDurationMs>ms
1489
+ *
1490
+ * Summary: <attempted> attempted, <succeeded> succeeded, <failed> failed, <skipped> skipped
1491
+ *
1492
+ * # | Step | Type | Status | Duration | Tokens
1493
+ * ---|------------------|---------|-----------|----------|-------
1494
+ * 1 | fetch-data | tool | completed | 120ms | 450
1495
+ * ...
1496
+ *
1497
+ * Total token cost: 1 250
1498
+ * ```
1499
+ *
1500
+ * Shows `'---'` for missing duration and `'---'` for missing cost data per step.
1501
+ * Shows `'no cost data'` for the totals line when no cost information is available.
1502
+ *
1503
+ * @param receipt - A run receipt produced by {@link toReceipt}.
1504
+ * @returns Multi-line formatted string.
1505
+ */
1506
+ declare function formatReceipt(receipt: RunReceipt): string;
662
1507
 
663
1508
  /**
664
1509
  * CLI runner that wraps any command with automatic AgentFlow tracing.
@@ -709,6 +1554,41 @@ interface RunResult {
709
1554
  */
710
1555
  declare function runTraced(config: RunConfig): Promise<RunResult>;
711
1556
 
1557
+ /**
1558
+ * Soma-compatible event writer for AgentFlow.
1559
+ *
1560
+ * Converts AgentFlow events (ExecutionEvent, PatternEvent) into Markdown files
1561
+ * with YAML frontmatter that Soma's Curator can ingest from its inbox directory.
1562
+ *
1563
+ * @module
1564
+ */
1565
+
1566
+ /**
1567
+ * Configuration for the Soma event writer.
1568
+ */
1569
+ interface SomaEventWriterConfig {
1570
+ /** Directory to write event files to (Soma's inbox). Created if it does not exist. */
1571
+ readonly inboxDir: string;
1572
+ }
1573
+ /**
1574
+ * Create a Soma event writer that persists events as Curator-compatible Markdown files.
1575
+ *
1576
+ * Each event is written to `{type}-{agentId}-{compact-ISO-timestamp}.md` in the
1577
+ * configured inbox directory. The Curator picks up these files on its 60-second cycle.
1578
+ *
1579
+ * @param config - Writer configuration with inbox directory path.
1580
+ * @returns An EventWriter that writes Markdown files to the Soma inbox.
1581
+ *
1582
+ * @example
1583
+ * ```ts
1584
+ * const writer = createSomaEventWriter({ inboxDir: '~/.openclaw/workspace/inbox' });
1585
+ * const emitter = createEventEmitter({ writers: [writer] });
1586
+ * await emitter.emit(createExecutionEvent(graph));
1587
+ * // Creates: ~/.openclaw/workspace/inbox/execution-alfred-20260314T083502.md
1588
+ * ```
1589
+ */
1590
+ declare function createSomaEventWriter(config: SomaEventWriterConfig): EventWriter;
1591
+
712
1592
  /**
713
1593
  * JSON file-based trace storage for ExecutionGraphs.
714
1594
  *
@@ -857,4 +1737,4 @@ interface AlertPayload {
857
1737
  readonly dirs: readonly string[];
858
1738
  }
859
1739
 
860
- export { type Adapter, type AgentFlowConfig, type AlertCondition, type AlertPayload, type DistributedTrace, type EdgeType, type ExecutionEdge, type ExecutionGraph, type ExecutionNode, type GraphBuilder, type GraphStats, type GraphStatus, type GuardConfig, type GuardViolation, type MutableExecutionNode, type NodeStatus, type NodeType, type NotifyChannel, type OsProcess, type PidFileResult, type ProcessAuditConfig, type ProcessAuditResult, type RunConfig, type RunResult, type StartNodeOptions, type SystemdUnitResult, type TraceEvent, type TraceEventType, type TraceStore, type WatchConfig, type WorkerEntry, type WorkersResult, type Writer, auditProcesses, checkGuards, createGraphBuilder, createTraceStore, discoverProcessConfig, findWaitingOn, formatAuditReport, getChildren, getCriticalPath, getDepth, getDuration, getFailures, getHungNodes, getNode, getParent, getStats, getSubtree, getTraceTree, graphToJson, groupByTraceId, loadGraph, runTraced, startLive, startWatch, stitchTrace, toAsciiTree, toTimeline, withGuards };
1740
+ export { type Adapter, type AgentFlowConfig, type AgentFlowEventType, type AgentProfile, type AlertCondition, type AlertPayload, type AnalysisFn, type Bottleneck, type ConformanceHistory, type ConformanceHistoryEntry, type ConformanceReport, type DecisionTraceData, type Deviation, type DeviationType, type DistributedTrace, type DriftOptions, type DriftReport, type EdgeType, type EfficiencyFlag, type EfficiencyReport, type EventEmitter, type EventEmitterConfig, type EventWriter, type ExecutionEdge, type ExecutionEvent, type ExecutionEventOptions, type ExecutionGraph, type ExecutionNode, type FailurePoint, type GraphBuilder, type GraphStats, type GraphStatus, type GuardConfig, type GuardExplanation, type GuardViolation, type InsightEngine, type InsightEngineConfig, type InsightEvent, type InsightResult, type JsonEventWriterConfig, type KnowledgeStore, type KnowledgeStoreConfig, type MutableExecutionNode, type NodeCost, type NodeStatus, type NodeType, type NotifyChannel, type OsProcess, type OutcomeAssertion, type PatternEvent, type PidFileResult, type PolicySource, type PolicyThresholds, type ProcessAuditConfig, type ProcessAuditResult, type ProcessContext, type ProcessModel, type ProcessTransition, type RunConfig, type RunEfficiency, type RunReceipt, type RunResult, type SemanticContext, type SomaEventWriterConfig, type StartNodeOptions, type StepSummary, type SystemdUnitResult, type TraceEvent, type TraceEventType, type TraceStore, type Variant, type VariantOptions, type WatchConfig, type WorkerEntry, type WorkersResult, type Writer, auditProcesses, buildAgentSummaryPrompt, buildAnomalyExplanationPrompt, buildFailureAnalysisPrompt, buildFixSuggestionPrompt, checkConformance, checkGuards, createEventEmitter, createExecutionEvent, createGraphBuilder, createInsightEngine, createJsonEventWriter, createKnowledgeStore, createPatternEvent, createPolicySource, createSomaEventWriter, createTraceStore, discoverAllProcessConfigs, discoverProcess, discoverProcessConfig, findVariants, findWaitingOn, formatAuditReport, formatReceipt, getBottlenecks, getChildren, getCriticalPath, getDepth, getDuration, getFailures, getHungNodes, getNode, getParent, getPathSignature, getStats, getSubtree, getTraceTree, graphToJson, groupByTraceId, loadGraph, runTraced, startLive, startWatch, stitchTrace, toAsciiTree, toReceipt, toTimeline, withGuards };