DAFT - v1.0.0
    Preparing search index...

    Class DAGExecutor

    Executes DAFT specs with DAG-based parallelism and budget enforcement.

    The executor handles:

    • Topological sorting of steps with dependencies
    • Parallel execution of independent steps
    • Iterative execution with predicates
    • Concurrency control
    • Budget enforcement (time, tokens, cost)
    • Automatic error handling and logging
    const executor = new DAGExecutor(predicates, tools, 4, logger);
    const result = await executor.execute(spec);
    console.log(result.message);
    Index

    Constructors

    Methods

    Constructors

    • Create a new DAGExecutor instance.

      Parameters

      • predicates: Record<string, Predicate>

        Map of predicate names to predicate functions

      • tools: Record<string, Tool>

        Map of tool names to tool implementations

      • concurrency: number = 4

        Maximum number of steps to run in parallel (default: 4)

      • Optionallogger: WideEventLogger

        Optional logger for structured event logging

      Returns DAGExecutor

    Methods

    • Execute a DAFT spec.

      Steps are executed in topological order, respecting dependencies. Steps without common dependencies run in parallel up to the concurrency limit. Each step runs iteratively until its predicate is satisfied or maxIter is reached.

      Parameters

      • spec: Spec

        The spec to execute

      Returns Promise<Result>

      Result object with success status, final data, and per-step results

      const result = await executor.execute(spec);
      if (result.success) {
      console.log('Final data:', result.data);
      console.log('Usage:', result.usage);
      }