@hashgraphonline/conversational-agent
Version:
Hashgraph Online conversational AI agent implementing HCS-10 communication, HCS-2 registries, and content inscription on Hedera. https://hol.org
142 lines (140 loc) • 3.8 kB
TypeScript
import { FormFieldType, FieldOption } from './types';
/**
* Field guidance configuration for providing contextual help and suggestions
*/
export interface FieldGuidance {
/**
* Suggestions to show as placeholder or examples
*/
suggestions?: string[];
/**
* Predefined options for select fields
*/
predefinedOptions?: FieldOption[];
/**
* Warning messages for specific patterns to avoid
*/
warnings?: {
pattern: RegExp;
message: string;
}[];
/**
* Validation rules specific to the field context
*/
validationRules?: {
/**
* Patterns that should be rejected
*/
rejectPatterns?: {
pattern: RegExp;
reason: string;
}[];
/**
* Minimum quality requirements
*/
qualityChecks?: {
minNonTechnicalWords?: number;
requireSpecificTerms?: string[];
forbidTechnicalTerms?: string[];
};
};
/**
* Field type override for specific contexts
*/
fieldTypeOverride?: FormFieldType;
/**
* Help text specific to the tool context
*/
contextualHelpText?: string;
}
/**
* Tool-specific field configurations
*/
export interface ToolFieldConfiguration {
/**
* Tool name or pattern to match
*/
toolPattern: string | RegExp;
/**
* Field-specific guidance
*/
fields: Record<string, FieldGuidance>;
/**
* Global guidance for all fields in this tool
*/
globalGuidance?: {
/**
* General warnings to show
*/
warnings?: string[];
/**
* Quality standards for this tool
*/
qualityStandards?: string[];
};
}
/**
* Registry for field guidance configurations
*/
declare class FieldGuidanceRegistry {
private configurations;
private providers;
private registerOrderCounter;
private logger;
constructor();
/**
* Register field guidance for a specific tool
*/
registerToolConfiguration(config: ToolFieldConfiguration): void;
/**
* Register a provider for dynamic field/global guidance
*/
registerToolProvider(toolPattern: string | RegExp, provider: FieldGuidanceProvider, options?: {
id?: string;
priority?: number;
}): string;
/** Unregister a provider by id */
unregisterProvider(id: string): void;
/** List registered providers */
listProviders(): Array<{
id: string;
priority: number;
pattern: string | RegExp;
}>;
/**
* Get field guidance for a specific tool and field
*/
getFieldGuidance(toolName: string, fieldName: string): FieldGuidance | null;
/**
* Get global guidance for a tool
*/
getGlobalGuidance(toolName: string): ToolFieldConfiguration['globalGuidance'] | null;
/**
* Validate field value against guidance rules
*/
validateFieldValue(toolName: string, fieldName: string, value: unknown): {
isValid: boolean;
warnings: string[];
errors: string[];
};
/**
* Clear all configurations (useful for testing)
*/
clear(): void;
/** Choose matching provider by priority then last-in wins */
private pickMatchingProviders;
private safeGetFieldGuidance;
private safeGetGlobalGuidance;
private mergeGuidance;
}
export declare const fieldGuidanceRegistry: FieldGuidanceRegistry;
/**
* Provider interface (optional, for dynamic guidance)
*/
export interface FieldGuidanceProvider {
getFieldGuidance(fieldName: string, ctx: {
toolName: string;
}): FieldGuidance | null;
getGlobalGuidance?(toolName: string): ToolFieldConfiguration['globalGuidance'] | null;
}
export {};