/** * Role Type Definitions * * Types for the Role system that powers agent personas with default prompts and assigned skills. * * @module types/role.types */ /** * Role category for grouping and filtering roles */ export type RoleCategory = 'development' | 'management' | 'quality' | 'design' | 'sales' | 'support' | 'automation'; /** * Array of all valid role categories */ export declare const ROLE_CATEGORIES: readonly RoleCategory[]; /** * Role definition for AI agent personas * Roles define the default behavior, prompts, and available skills for agents */ export interface Role { /** Unique identifier for the role */ id: string; /** Internal name used for file references (e.g., "developer", "product-manager") */ name: string; /** Human-readable display name (e.g., "Developer", "Product Manager") */ displayName: string; /** Description of the role's purpose and capabilities */ description: string; /** Category for grouping similar roles */ category: RoleCategory; /** Path to the .md file containing the system prompt */ systemPromptFile: string; /** Array of Skill IDs that this role can use */ assignedSkills: string[]; /** Whether this is the default role for new agents */ isDefault: boolean; /** Whether this role is hidden from the UI (e.g., orchestrator) */ isHidden: boolean; /** Whether this role is built-in (system) or user-created */ isBuiltin: boolean; /** Whether this builtin role has a user override in ~/.crewly/roles/ */ hasOverride?: boolean; /** ISO timestamp of role creation */ createdAt: string; /** ISO timestamp of last update */ updatedAt: string; } /** * Input for creating a new role */ export interface CreateRoleInput { /** Internal name used for file references */ name: string; /** Human-readable display name */ displayName: string; /** Description of the role's purpose */ description: string; /** Category for grouping */ category: RoleCategory; /** The actual prompt content (will be saved to file) */ systemPromptContent: string; /** Array of Skill IDs to assign (optional) */ assignedSkills?: string[]; /** Whether this should be the default role (optional) */ isDefault?: boolean; } /** * Input for updating an existing role */ export interface UpdateRoleInput { /** Human-readable display name */ displayName?: string; /** Description of the role's purpose */ description?: string; /** Category for grouping */ category?: RoleCategory; /** The actual prompt content (will be saved to file) */ systemPromptContent?: string; /** Array of Skill IDs to assign */ assignedSkills?: string[]; /** Whether this should be the default role */ isDefault?: boolean; } /** * Role with resolved prompt content (for API responses) */ export interface RoleWithPrompt extends Role { /** The actual content of the system prompt file */ systemPromptContent: string; } /** * Role summary for list views (without full prompt content) */ export interface RoleSummary { /** Unique identifier */ id: string; /** Internal name */ name: string; /** Human-readable display name */ displayName: string; /** Description of the role */ description: string; /** Category for grouping */ category: RoleCategory; /** Number of assigned skills */ skillCount: number; /** Whether this is the default role */ isDefault: boolean; /** Whether this role is hidden from UI */ isHidden: boolean; /** Whether this builtin role has a user override */ hasOverride?: boolean; /** Whether this is a built-in role */ isBuiltin: boolean; } /** * Role filter options for querying roles */ export interface RoleFilter { /** Filter by category */ category?: RoleCategory; /** Filter by built-in status */ isBuiltin?: boolean; /** Filter by having a specific skill */ hasSkill?: string; /** Search term for name/displayName/description */ search?: string; } /** * Role storage format (JSON file structure) */ export interface RoleStorageFormat { /** Unique identifier */ id: string; /** Internal name */ name: string; /** Human-readable display name */ displayName: string; /** Description of the role */ description: string; /** Category for grouping */ category: RoleCategory; /** Path to the prompt file */ systemPromptFile: string; /** Array of assigned skill IDs */ assignedSkills: string[]; /** Whether this is the default role */ isDefault: boolean; /** Whether this role is hidden from UI */ isHidden?: boolean; /** ISO timestamp of creation */ createdAt: string; /** ISO timestamp of last update */ updatedAt: string; } /** * Type guard to check if a string is a valid RoleCategory * * @param value - The string to check * @returns True if the value is a valid RoleCategory * * @example * ```typescript * if (isValidRoleCategory(input)) { * // input is typed as RoleCategory * } * ``` */ export declare function isValidRoleCategory(value: string): value is RoleCategory; /** * Create a new Role with default values * * @param input - Required name and displayName, with optional overrides for other fields * @returns A complete Role object with generated ID and timestamps * * @example * ```typescript * const role = createDefaultRole({ * name: 'my-role', * displayName: 'My Role', * category: 'development', * }); * ``` */ export declare function createDefaultRole(input: Pick & Partial): Role; /** * Convert a Role to a RoleSummary (for list views) * * Strips out detailed information like timestamps and prompt file path, * and replaces assignedSkills array with a count. * * @param role - The full Role object * @returns A RoleSummary with essential fields only * * @example * ```typescript * const roles = await roleService.getAll(); * const summaries = roles.map(roleToSummary); * ``` */ export declare function roleToSummary(role: Role): RoleSummary; /** * Validate CreateRoleInput and return an array of error messages * * @param input - The CreateRoleInput to validate * @returns Array of error messages (empty if valid) * * @example * ```typescript * const errors = validateCreateRoleInput(input); * if (errors.length > 0) { * throw new ValidationError(errors.join(', ')); * } * ``` */ export declare function validateCreateRoleInput(input: CreateRoleInput): string[]; /** * Validate UpdateRoleInput and return an array of error messages * * @param input - The UpdateRoleInput to validate * @returns Array of error messages (empty if valid) * * @example * ```typescript * const errors = validateUpdateRoleInput(input); * if (errors.length > 0) { * throw new ValidationError(errors.join(', ')); * } * ``` */ export declare function validateUpdateRoleInput(input: UpdateRoleInput): string[]; /** * Check if a Role matches the given filter criteria * * @param role - The role to check * @param filter - The filter criteria * @returns True if the role matches all filter criteria * * @example * ```typescript * const filteredRoles = roles.filter(role => matchesRoleFilter(role, filter)); * ``` */ export declare function matchesRoleFilter(role: Role, filter: RoleFilter): boolean; /** * Convert a Role to RoleStorageFormat for persistence * * @param role - The role to convert * @returns A RoleStorageFormat object ready for JSON serialization */ export declare function roleToStorageFormat(role: Role): RoleStorageFormat; /** * Convert a RoleStorageFormat back to a Role * * @param stored - The stored role data * @param isBuiltin - Whether this role is built-in * @returns A complete Role object */ export declare function storageFormatToRole(stored: RoleStorageFormat, isBuiltin: boolean): Role; //# sourceMappingURL=role.types.d.ts.map