/** * Goal DSL — Schema-driven goal definitions for swarm orchestration * * Provides a declarative way to define multi-agent goals with constraints, * dependencies, and validation rules. Goals can be defined in TypeScript * objects or parsed from YAML/JSON strings. * * Features: * - Typed GoalDefinition with tasks, constraints, and outputs * - Dependency graph validation (cycle detection, missing refs) * - Constraint checking (budget, timeout, required agents) * - YAML/JSON parsing (YAML via simple built-in parser, no deps) * - Goal compilation to executable task DAGs * * Usage: * const goal = parseGoal(` * name: research-and-summarize * tasks: * - id: research * agent: researcher * action: search * - id: summarize * agent: writer * action: summarize * depends: [research] * `); * const plan = compileGoal(goal); * * @module GoalDSL * @version 1.0.0 */ /** A single task within a goal */ export interface GoalTask { /** Unique task ID within this goal */ id: string; /** Agent or adapter:agent to execute this task */ agent: string; /** Action/instruction for the agent */ action: string; /** Task IDs this depends on (must complete before this starts) */ depends?: string[]; /** Parameters to pass to the agent */ params?: Record; /** Per-task timeout in ms */ timeoutMs?: number; /** Whether failure of this task fails the entire goal (default: true) */ critical?: boolean; /** Retry count (default: 0) */ retries?: number; /** Output key — result stored under this key for downstream tasks */ outputKey?: string; } /** Constraints on goal execution */ export interface GoalConstraints { /** Maximum total budget */ maxBudget?: number; /** Maximum total time in ms */ maxTimeMs?: number; /** Required agent capabilities */ requiredCapabilities?: string[]; /** Maximum parallel tasks */ maxParallelism?: number; /** Minimum confidence threshold for results */ minConfidence?: number; } /** Expected output definition */ export interface GoalOutput { /** Output key name */ key: string; /** Expected type ('string' | 'number' | 'object' | 'array' | 'boolean') */ type?: string; /** Whether this output is required (default: true) */ required?: boolean; /** Description of the output */ description?: string; } /** Complete goal definition */ export interface GoalDefinition { /** Goal name */ name: string; /** Goal description */ description?: string; /** Version */ version?: string; /** Tasks to execute */ tasks: GoalTask[]; /** Execution constraints */ constraints?: GoalConstraints; /** Expected outputs */ outputs?: GoalOutput[]; /** Metadata */ metadata?: Record; } /** Validation error */ export interface GoalValidationError { /** Error type */ type: 'missing_dependency' | 'cycle' | 'duplicate_id' | 'empty_tasks' | 'invalid_field' | 'missing_agent'; /** Human-readable message */ message: string; /** Related task ID */ taskId?: string; } /** Validation result */ export interface GoalValidationResult { /** Whether the goal is valid */ valid: boolean; /** Validation errors */ errors: GoalValidationError[]; } /** Compiled execution layer (tasks that can run in parallel) */ export interface ExecutionLayer { /** Layer index (0 = first) */ index: number; /** Task IDs in this layer */ taskIds: string[]; } /** Compiled goal — ready for execution */ export interface CompiledGoal { /** Original goal definition */ definition: GoalDefinition; /** Execution layers (topologically sorted) */ layers: ExecutionLayer[]; /** Total parallel depth */ depth: number; /** Maximum width (max tasks in a single layer) */ maxWidth: number; /** All task IDs in execution order */ taskOrder: string[]; /** Dependency adjacency map */ adjacency: Map; } /** * Parse a goal from a YAML-like or JSON string. * * Supports a simple YAML subset (no anchors, tags, or multi-doc): * - Key: value pairs * - Lists with `- item` syntax * - Inline arrays `[a, b, c]` * - Nested indentation * - JSON input (auto-detected) */ export declare function parseGoal(input: string): GoalDefinition; /** Parse from a plain object (e.g. loaded from file) */ export declare function goalFromObject(obj: Record): GoalDefinition; /** * Validate a goal definition for correctness. * Checks for cycles, missing dependencies, duplicate IDs, and required fields. */ export declare function validateGoal(goal: GoalDefinition): GoalValidationResult; /** * Compile a validated goal into an executable plan with layered parallelism. * Performs topological sort to determine execution layers. * * @throws If the goal is invalid. */ export declare function compileGoal(goal: GoalDefinition): CompiledGoal; //# sourceMappingURL=goal-dsl.d.ts.map