@memberjunction/ng-ai-test-harness
Version:
MemberJunction AI Test Harness - A reusable component for testing AI agents and prompts with beautiful UX
109 lines • 5.01 kB
TypeScript
import { EventEmitter, OnInit, ChangeDetectorRef, AfterViewInit } from '@angular/core';
import { AIAgentEntityExtended, AIPromptEntityExtended } from '@memberjunction/core-entities';
import { AITestHarnessComponent } from './ai-test-harness.component';
import * as i0 from "@angular/core";
/**
* Configuration data interface for the AI Test Harness Dialog.
* Provides all necessary options for initializing the dialog with appropriate
* agent/prompt data, dimensions, and initial variable configurations.
*/
export interface AITestHarnessDialogData {
/** ID of the AI agent to load (alternative to providing agent entity) */
agentId?: string;
/** Pre-loaded AI agent entity (alternative to providing agentId) */
agent?: AIAgentEntityExtended;
/** ID of the AI prompt to load (alternative to providing prompt entity) */
promptId?: string;
/** Pre-loaded AI prompt entity (alternative to providing promptId) */
prompt?: AIPromptEntityExtended;
/** Custom dialog title (defaults to agent/prompt name) */
title?: string;
/** Dialog width in CSS units or viewport percentage */
width?: string | number;
/** Dialog height in CSS units or viewport percentage */
height?: string | number;
/** Initial data context variables for agent execution */
initialDataContext?: Record<string, any>;
/** Initial template data variables for prompt rendering */
initialTemplateData?: Record<string, any>;
/** Initial template variables for prompt execution */
initialTemplateVariables?: Record<string, any>;
/** Pre-selected AI model ID for prompt execution */
selectedModelId?: string;
/** Pre-selected AI vendor ID for prompt execution */
selectedVendorId?: string;
/** Pre-selected AI configuration ID for prompt execution */
selectedConfigurationId?: string;
/** Mode of operation - 'agent' or 'prompt' */
mode?: 'agent' | 'prompt';
/** ID of an existing prompt run to preload data from */
promptRunId?: string;
}
/**
* Dialog wrapper component for the AI Agent Test Harness.
* Provides a modal dialog interface with proper sizing, header, and close functionality.
* Automatically loads agent data and initializes the test harness with provided configuration.
*
* ## Features:
* - **Automatic Agent Loading**: Loads agent by ID or uses provided entity
* - **Configurable Dimensions**: Supports custom dialog sizing
* - **Initial Data Setup**: Pre-populates data context and template variables
* - **Clean Dialog Interface**: Professional header with close button
* - **Responsive Layout**: Adapts to content and screen size
*
* ## Usage:
* This component is typically opened through the `TestHarnessDialogService` rather than directly:
* ```typescript
* const dialogRef = this.testHarnessService.openAgentTestHarness({
* agentId: 'agent-123',
* initialDataContext: { userId: 'user-456' }
* });
* ```
*/
export declare class AITestHarnessDialogComponent implements OnInit, AfterViewInit {
private cdr;
/** Reference to the embedded test harness component */
testHarness: AITestHarnessComponent;
/** The loaded AI agent entity for testing */
agent: AIAgentEntityExtended | null;
/** The loaded AI prompt entity for testing */
prompt: AIPromptEntityExtended | null;
/** The mode of operation - either 'agent' or 'prompt' */
mode: 'agent' | 'prompt';
/** Display title for the dialog header */
title: string;
/** Configuration data passed from the dialog service */
data: AITestHarnessDialogData;
/** Event emitted when the dialog should be closed */
closeDialog: EventEmitter<void>;
constructor(cdr: ChangeDetectorRef);
/**
* Initializes the dialog component by loading agent/prompt data and configuring
* the embedded test harness with initial variables and settings.
*/
ngOnInit(): Promise<void>;
/**
* AfterViewInit lifecycle hook to set initial data after view is initialized
*/
ngAfterViewInit(): Promise<void>;
/**
* Determines the appropriate variable type for initial data configuration.
* @param value - The value to analyze for type detection
* @returns The detected variable type
* @private
*/
private detectVariableType;
/**
* Loads data from an existing prompt run to pre-populate the test harness
* @param promptRunId - The ID of the prompt run to load
*/
private loadFromPromptRun;
/**
* Closes the dialog by emitting the close event.
* This method is called by the close button in the header.
*/
close(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<AITestHarnessDialogComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<AITestHarnessDialogComponent, "mj-ai-test-harness-dialog", never, { "data": { "alias": "data"; "required": false; }; }, { "closeDialog": "closeDialog"; }, never, never, false, never>;
}
//# sourceMappingURL=ai-test-harness-dialog.component.d.ts.map