@memberjunction/ng-ai-test-harness
Version:
MemberJunction AI Test Harness - A reusable component for testing AI agents and prompts with beautiful UX
237 lines • 6.85 kB
TypeScript
import { OnChanges, SimpleChanges, OnDestroy, ElementRef, AfterViewInit, ChangeDetectorRef, ViewContainerRef, EventEmitter } from '@angular/core';
import { MJAIAgentRunEntityExtended, MJAIAgentRunStepEntityExtended } from '@memberjunction/ai-core-plus';
import * as i0 from "@angular/core";
/**
* Progress message with display mode
*/
export interface ProgressMessage {
id: string;
message: string;
timestamp: Date;
displayMode: 'live' | 'historical' | 'both';
metadata?: Record<string, unknown>;
}
/**
* Mode for the execution monitor component
*/
export type ExecutionMonitorMode = 'live' | 'historical';
/**
* Execution statistics for display
*/
export interface ExecutionStats {
totalSteps: number;
completedSteps: number;
failedSteps: number;
totalTokens: number;
totalCost: number;
stepsByType: Record<string, number>;
totalDuration?: number;
totalPrompts: number;
}
/**
* AgentExecutionMonitor Component
*
* A reusable component for visualizing AI agent execution flow in real-time or historically.
* Displays a hierarchical tree of execution steps with status, timing, and preview information.
*
* Features:
* - Real-time updates for live executions
* - Historical playback for completed executions
* - Collapsible tree structure
* - Step status indicators with animations
* - Execution statistics
* - Token usage and cost tracking
* - Error display
* - Input/output preview
*/
export declare class AgentExecutionMonitorComponent implements OnChanges, OnDestroy, AfterViewInit {
private cdr;
mode: ExecutionMonitorMode;
agentRun: MJAIAgentRunEntityExtended | null;
liveSteps: MJAIAgentRunStepEntityExtended[];
autoExpand: boolean;
runId: string | null;
runType: 'agent' | 'prompt';
viewRunClick: EventEmitter<{
runId: string;
runType: "agent" | "prompt";
}>;
executionTreeContainer: ElementRef<HTMLDivElement>;
executionNodesContainer: ViewContainerRef;
currentStep: MJAIAgentRunStepEntityExtended | null;
private nodeComponentMap;
private expandedStates;
private detailsExpandedStates;
stats: ExecutionStats;
private userHasInteracted;
private userHasScrolled;
private isAutoScrolling;
private lastScrollPosition;
private scrollThreshold;
private viewInitialized;
private processedStepIds;
private newlyAddedNodeIds;
private lastParsedAgentData;
private lastParsedActionData;
private destroy$;
private updateSubscription?;
constructor(cdr: ChangeDetectorRef);
ngOnChanges(changes: SimpleChanges): void;
ngAfterViewInit(): void;
ngOnDestroy(): void;
/**
* Clear all dynamically created components
*/
private clearNodeComponents;
/**
* Process agent run for historical mode
*/
private processAgentRun;
/**
* Process live steps for live mode
*/
private processLiveSteps;
/**
* Render steps recursively with proper hierarchy
*/
private renderSteps;
/**
* Create a component for a step
*/
private createStepComponent;
/**
* Toggle step expansion
*/
private toggleStepExpansion;
/**
* Toggle step details expansion
*/
private toggleStepDetails;
/**
* Get step type CSS class for styling
*/
private getStepTypeClass;
/**
* Get status CSS class for styling
*/
private getStatusClass;
/**
* Helper function to safely convert a value to a preview string
*/
private valueToPreviewString;
/**
* Create a preview string from data
*/
private createPreview;
/**
* Extract token count from output data
*/
private extractTokens;
/**
* Extract cost from output data
*/
private extractCost;
/**
* Calculate duration from timestamps
*/
private calculateDuration;
/**
* Set up live updates for real-time execution
*/
private setupLiveUpdates;
/**
* Update current step indicator
*/
private updateCurrentStep;
/**
* Mark previously new nodes as completed
*/
private markPreviouslyNewNodesAsComplete;
/**
* Ensure only the last step in the execution order shows as running
*/
private ensureOnlyLastStepIsRunning;
/**
* Calculate execution statistics
*/
private calculateStats;
/**
* Count steps recursively
*/
private countSteps;
/**
* Handle scroll events
*/
onScroll(event: Event): void;
/**
* Handle user clicks (interaction detection)
*/
onUserInteraction(): void;
/**
* Check if scroll is at bottom
*/
private isScrolledToBottom;
/**
* Check if user is at bottom (for initial setup)
*/
private checkIfUserAtBottom;
/**
* Auto-scroll to bottom if user hasn't interacted
*/
private autoScrollToBottom;
/**
* Format agent path for display
*/
formatAgentPath(path: string[]): string;
/**
* Format duration for display
*/
formatDuration(ms: number): string;
/**
* Get step types for display
*/
getStepTypes(): string[];
/**
* Pluralize step type based on count
*/
pluralizeStepType(type: string, count: number): string;
/**
* Format markdown content for display
*/
formatMarkdown(markdown: string): string;
/**
* Append new live steps without re-rendering entire tree
*/
private appendNewLiveSteps;
/**
* Calculate step depth based on parent hierarchy
*/
private calculateStepDepth;
/**
* Build agent path for a step
*/
private buildAgentPath;
/**
* Check if execution is complete
*/
isExecutionComplete(): boolean;
/**
* Handle view run button click
*/
onViewRunClick(): void;
/**
* Expands all nodes that have sub-agent children
*/
private expandAllNodes;
/**
* Scroll the execution tree to the top
*/
private scrollToTop;
/**
* Check if there is content to display
*/
hasContent(): boolean;
static ɵfac: i0.ɵɵFactoryDeclaration<AgentExecutionMonitorComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<AgentExecutionMonitorComponent, "mj-agent-execution-monitor", never, { "mode": { "alias": "mode"; "required": false; }; "agentRun": { "alias": "agentRun"; "required": false; }; "liveSteps": { "alias": "liveSteps"; "required": false; }; "autoExpand": { "alias": "autoExpand"; "required": false; }; "runId": { "alias": "runId"; "required": false; }; "runType": { "alias": "runType"; "required": false; }; }, { "viewRunClick": "viewRunClick"; }, never, never, false, never>;
}
//# sourceMappingURL=agent-execution-monitor.component.d.ts.map