/**
 * Agent Types - Role definitions for AI agents in the orchestration system
 *
 * This module defines the core types for agents in the Stoneforge Smithy:
 * - AgentRole: The primary role classification (director, steward, worker)
 * - WorkerMode: Whether a worker is ephemeral (short-lived) or persistent
 * - StewardFocus: The specialty area for steward agents (merge, docs, custom)
 * - StewardTrigger: How stewards are activated (cron or event)
 *
 * Agents are stored as Entity elements with additional metadata in their
 * `metadata` field to track orchestrator-specific properties.
 */
/**
 * All valid agent role values
 */
export const AgentRoleValues = ['director', 'steward', 'worker'];
/**
 * Type guard to check if a value is a valid AgentRole
 */
export function isAgentRole(value) {
    return typeof value === 'string' && AgentRoleValues.includes(value);
}
/**
 * All valid worker mode values
 */
export const WorkerModeValues = ['ephemeral', 'persistent'];
/**
 * Type guard to check if a value is a valid WorkerMode
 */
export function isWorkerMode(value) {
    return typeof value === 'string' && WorkerModeValues.includes(value);
}
/**
 * All valid steward focus values
 */
export const StewardFocusValues = ['merge', 'docs', 'recovery', 'custom'];
/**
 * Type guard to check if a value is a valid StewardFocus
 */
export function isStewardFocus(value) {
    return typeof value === 'string' && StewardFocusValues.includes(value);
}
/**
 * Type guard to check if a trigger is a CronTrigger
 */
export function isCronTrigger(trigger) {
    return trigger.type === 'cron';
}
/**
 * Type guard to check if a trigger is an EventTrigger
 */
export function isEventTrigger(trigger) {
    return trigger.type === 'event';
}
/**
 * Type guard to check if a value is a valid StewardTrigger
 */
export function isStewardTrigger(value) {
    if (typeof value !== 'object' || value === null) {
        return false;
    }
    const obj = value;
    if (obj.type === 'cron') {
        return typeof obj.schedule === 'string';
    }
    if (obj.type === 'event') {
        return typeof obj.event === 'string' && (obj.condition === undefined || typeof obj.condition === 'string');
    }
    return false;
}
/**
 * Type guard to check if metadata is DirectorMetadata
 */
export function isDirectorMetadata(metadata) {
    return metadata.agentRole === 'director';
}
/**
 * Type guard to check if metadata is WorkerMetadata
 */
export function isWorkerMetadata(metadata) {
    return metadata.agentRole === 'worker';
}
/**
 * Type guard to check if metadata is StewardMetadata
 */
export function isStewardMetadata(metadata) {
    return metadata.agentRole === 'steward';
}
// ============================================================================
// Validation Utilities
// ============================================================================
/**
 * Validates agent metadata structure
 */
export function validateAgentMetadata(metadata) {
    if (typeof metadata !== 'object' || metadata === null) {
        return false;
    }
    const obj = metadata;
    if (!isAgentRole(obj.agentRole)) {
        return false;
    }
    // Validate maxConcurrentTasks if present
    if (obj.maxConcurrentTasks !== undefined && typeof obj.maxConcurrentTasks !== 'number') {
        return false;
    }
    switch (obj.agentRole) {
        case 'director':
            return true;
        case 'worker':
            return isWorkerMode(obj.workerMode);
        case 'steward':
            if (!isStewardFocus(obj.stewardFocus)) {
                return false;
            }
            if (obj.triggers !== undefined) {
                if (!Array.isArray(obj.triggers)) {
                    return false;
                }
                return obj.triggers.every(isStewardTrigger);
            }
            return true;
        default:
            return false;
    }
}
//# sourceMappingURL=agent.js.map