All files / shared/src/utils agent-validation.ts

25% Statements 4/16
100% Branches 1/1
50% Functions 1/2
25% Lines 4/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                              1x                                           1x 45x 45x  
import type { Agent } from '@shared/types/data';
 
export interface AgentValidationResult {
  isReady: boolean;
  missingRequirements: string[];
}
 
/**
 * Validates whether an agent is ready for use.
 * An agent is considered ready if it has at least one skill configured.
 *
 * @param _agent - The agent to validate (reserved for future validation rules)
 * @param skillsCount - The number of skills configured for this agent
 * @returns Validation result with readiness status and missing requirements
 */
export function validateAgent(
  _agent: Agent,
  skillsCount: number,
): AgentValidationResult {
  const missingRequirements: string[] = [];
 
  if (skillsCount === 0) {
    missingRequirements.push('At least one skill must be configured');
  }
 
  return {
    isReady: missingRequirements.length === 0,
    missingRequirements,
  };
}
 
/**
 * Checks if an agent is ready based on skills count.
 *
 * @param skillsCount - The number of skills configured for the agent
 * @returns True if the agent has at least one skill
 */
export function isAgentReady(skillsCount: number): boolean {
  return skillsCount > 0;
}