/** * @fileoverview CAR Domain Codes and Bitmask Operations * * Defines the capability domain codes used in CAR strings, with bitmask * encoding for efficient queries and domain matching. * * Domain codes represent high-level capability areas that agents can operate in. * Each domain has a single-character code, a human-readable name, a bitmask value, * and a description of its scope. * * @module @vorionsys/contracts/car/domains */ import { z } from 'zod'; /** * Single-character domain codes representing capability areas. * * Each code maps to a specific area of agent capability: * - A: Administration - System administration, user management, organizational operations * - B: Business - Business logic, workflows, approvals, process automation * - C: Communications - Email, messaging, notifications, real-time communication * - D: Data - Data processing, analytics, reporting, ETL pipelines * - E: External - Third-party integrations, external APIs, partner systems * - F: Finance - Financial operations, payments, accounting, treasury * - G: Governance - Policy enforcement, compliance, oversight, audit * - H: Healthcare - Clinical systems, patient data, medical devices, health records * - I: Infrastructure - Compute, storage, networking, cloud resource management * - J: Judicial - Legal operations, contract analysis, regulatory compliance * - K: Knowledge - Knowledge management, documentation, search, retrieval * - L: Logistics - Supply chain, inventory, shipping, warehouse management * - M: Manufacturing - Production systems, quality control, industrial automation * - N: NLP - Natural language processing, translation, content generation * - O: Operations - DevOps, SRE, incident response, operational management * - P: People - HR, recruitment, employee management, talent operations * - Q: Quality - Testing, QA, certification, standards compliance * - R: Research - R&D, experimentation, scientific computing, analysis * - S: Security - Authentication, authorization, threat detection, audit * - T: Training - Education, learning systems, skill development, onboarding * - U: Utilities - Shared services, scheduling, notifications, common tools * - V: Verification - Identity verification, attestation, proof validation * - W: Web - Web applications, digital experiences, content management * - X: Cross-domain - Multi-domain orchestration, cross-cutting concerns * - Y: Yield - Analytics, optimization, performance measurement, ROI * - Z: Reserved - Reserved for future domain expansion */ export type DomainCode = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z'; /** * Array of all valid domain codes. */ export declare const DOMAIN_CODES: readonly DomainCode[]; /** * Zod schema for DomainCode validation. */ export declare const domainCodeSchema: z.ZodEnum<["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]>; /** * Complete definition for a capability domain. */ export interface DomainDefinition { /** Single-character domain code */ readonly code: DomainCode; /** Human-readable domain name */ readonly name: string; /** Bitmask value for efficient queries (power of 2) */ readonly bit: number; /** Description of the domain's scope */ readonly description: string; } /** * Capability domains with their definitions. * * Each domain has a unique bitmask value (power of 2) for efficient * storage and querying of domain combinations. */ export declare const CAPABILITY_DOMAINS: Readonly>; /** * Human-readable domain names indexed by code. */ export declare const DOMAIN_NAMES: Readonly>; /** * Bitmask value representing all domains combined. */ export declare const ALL_DOMAINS_BITMASK: number; /** * Encodes an array of domain codes into a bitmask. * * @param domains - Array of domain codes to encode * @returns Bitmask integer representing the domains * * @example * ```typescript * encodeDomains(['A', 'B']); // 0x003 (3) * encodeDomains(['A', 'S']); // 0x201 (513) * encodeDomains([]); // 0 * ``` */ export declare function encodeDomains(domains: readonly DomainCode[]): number; /** * Decodes a bitmask into an array of domain codes. * * @param bitmask - Bitmask integer to decode * @returns Array of domain codes present in the bitmask * * @example * ```typescript * decodeDomains(0x003); // ['A', 'B'] * decodeDomains(0x201); // ['A', 'S'] * decodeDomains(0); // [] * ``` */ export declare function decodeDomains(bitmask: number): DomainCode[]; /** * Converts a domain string (e.g., "ABS") to an array of domain codes. * * @param domainString - String containing domain codes (e.g., "ABS") * @returns Array of domain codes * @throws Error if any character is not a valid domain code * * @example * ```typescript * parseDomainString('ABS'); // ['A', 'B', 'S'] * parseDomainString('D'); // ['D'] * ``` */ export declare function parseDomainString(domainString: string): DomainCode[]; /** * Converts an array of domain codes to a domain string. * * @param domains - Array of domain codes * @param sort - Whether to sort the codes alphabetically (default: true) * @returns String containing the domain codes * * @example * ```typescript * formatDomainString(['S', 'A', 'B']); // 'ABS' * formatDomainString(['S', 'A'], false); // 'SA' * ``` */ export declare function formatDomainString(domains: readonly DomainCode[], sort?: boolean): string; /** * Checks if a set of domains includes all required domains. * * @param agentDomains - Domains the agent has (array or bitmask) * @param requiredDomains - Domains required (array or bitmask) * @returns True if agent has all required domains * * @example * ```typescript * hasDomains(['A', 'B', 'C'], ['A', 'B']); // true * hasDomains(['A', 'B'], ['A', 'B', 'C']); // false * hasDomains(0x007, 0x003); // true (ABC has AB) * ``` */ export declare function hasDomains(agentDomains: readonly DomainCode[] | number, requiredDomains: readonly DomainCode[] | number): boolean; /** * Checks if a set of domains satisfies domain requirements. * * This is an alias for hasDomains with more semantic naming for * authorization contexts. * * @param agentDomains - Domains the agent has * @param requirements - Domain requirements to satisfy * @returns True if all requirements are satisfied */ export declare function satisfiesDomainRequirements(agentDomains: readonly DomainCode[] | number, requirements: readonly DomainCode[] | number): boolean; /** * Gets the intersection of two domain sets. * * @param domainsA - First domain set * @param domainsB - Second domain set * @returns Array of domains present in both sets * * @example * ```typescript * intersectDomains(['A', 'B', 'C'], ['B', 'C', 'D']); // ['B', 'C'] * ``` */ export declare function intersectDomains(domainsA: readonly DomainCode[] | number, domainsB: readonly DomainCode[] | number): DomainCode[]; /** * Gets the union of two domain sets. * * @param domainsA - First domain set * @param domainsB - Second domain set * @returns Array of domains present in either set * * @example * ```typescript * unionDomains(['A', 'B'], ['B', 'C']); // ['A', 'B', 'C'] * ``` */ export declare function unionDomains(domainsA: readonly DomainCode[] | number, domainsB: readonly DomainCode[] | number): DomainCode[]; /** * Gets domains in the first set that are not in the second. * * @param domainsA - First domain set * @param domainsB - Second domain set * @returns Array of domains in A but not in B * * @example * ```typescript * differenceDomains(['A', 'B', 'C'], ['B', 'C']); // ['A'] * ``` */ export declare function differenceDomains(domainsA: readonly DomainCode[] | number, domainsB: readonly DomainCode[] | number): DomainCode[]; /** * Gets the full definition for a domain code. * * @param code - Domain code * @returns Domain definition */ export declare function getDomainDefinition(code: DomainCode): DomainDefinition; /** * Gets the human-readable name for a domain code. * * @param code - Domain code * @returns Domain name */ export declare function getDomainName(code: DomainCode): string; /** * Gets the bitmask value for a domain code. * * @param code - Domain code * @returns Bitmask value */ export declare function getDomainBit(code: DomainCode): number; /** * Counts the number of domains in a bitmask. * * @param bitmask - Domain bitmask * @returns Number of domains */ export declare function countDomains(bitmask: number): number; /** * Type guard to check if a value is a valid DomainCode. * * @param value - Value to check * @returns True if value is a valid DomainCode */ export declare function isDomainCode(value: unknown): value is DomainCode; /** * Type guard to check if all values in an array are valid DomainCodes. * * @param values - Array to check * @returns True if all values are valid DomainCodes */ export declare function isDomainCodeArray(values: unknown): values is DomainCode[]; /** * Zod schema for domain definition. */ export declare const domainDefinitionSchema: z.ZodObject<{ code: z.ZodEnum<["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]>; name: z.ZodString; bit: z.ZodNumber; description: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; code: "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"; description: string; bit: number; }, { name: string; code: "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"; description: string; bit: number; }>; /** * Zod schema for an array of domain codes. */ export declare const domainCodeArraySchema: z.ZodArray, "many">; /** * Zod schema for a domain bitmask (positive integer). */ export declare const domainBitmaskSchema: z.ZodNumber; /** * Zod schema for domain string (e.g., "ABS"). */ export declare const domainStringSchema: z.ZodEffects;