workflows

Classes

AgentStepExecutor

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:95

Executor for individual workflow steps.

Constructors

Constructor
new AgentStepExecutor(deps): AgentStepExecutor;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:98

Parameters
deps

StepExecutorDeps

Returns

AgentStepExecutor

Methods

execute()
execute(
   step, 
   context, 
   options?
): Promise<Result<StepResult, WorkflowError>>;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:102

Parameters
step

WorkflowStep

context

WorkflowExecutionContext

options?

StepExecutionOptions

Returns

Promise<Result<StepResult, WorkflowError>>


DependencyGraph

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:26

Dependency graph for workflow steps.

Constructors

Constructor
new DependencyGraph(): DependencyGraph;
Returns

DependencyGraph

Methods

addStep()
addStep(step): void;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:33

Adds a step to the graph.

Parameters
step

WorkflowStep

The workflow step to add

Returns

void

buildReverseLinks(): void;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:45

Builds the reverse dependency links (dependents).

Returns

void

detectCycles()
detectCycles(): Result<string[], ParseError>;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:157

Detects circular dependencies using Kahn’s algorithm.

Returns

Result<string[], ParseError>

Result with topologically sorted step IDs or ParseError for cycles

getExecutionOrder()
getExecutionOrder(): Result<string[], ParseError>;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:242

Gets the execution order (topologically sorted step IDs).

Returns

Result<string[], ParseError>

Result with sorted step IDs or ParseError

getNode()
getNode(id): GraphNode | undefined;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:66

Gets a node by step ID.

Parameters
id

string

Returns

GraphNode | undefined

getStepIds()
getStepIds(): string[];

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:59

Gets all step IDs in the graph.

Returns

string[]

validateReferences()
validateReferences(): Result<void, ParseError>;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:74

Validates that all dependency references exist.

Returns

Result<void, ParseError>

Result with void or ParseError containing missing references

validateUniqueIds()
static validateUniqueIds(steps): Result<void, ParseError>;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:100

Validates that all step IDs are unique.

Parameters
steps

WorkflowStep[]

Array of workflow steps

Returns

Result<void, ParseError>

Result with void or ParseError for duplicates


ExpertFactoryAdapter

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:45

Wrapper to adapt ExpertFactory to IExpertFactory interface.

Implements

Constructors

Constructor
new ExpertFactoryAdapter(factory): ExpertFactoryAdapter;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:48

Parameters
factory
create

(config, options?) => Result<Expert, FactoryError> = createExpert

createAllBuiltIn

(options?) => Result<Expert[], FactoryError> = createAllBuiltInExperts

createBuiltIn

(type, options?) => Result<Expert, FactoryError> = createBuiltInExpert

createFromICTM

(ictm, subtaskId, options?) => Result<Expert, FactoryError>

createMany

(configs, options?) => Result<Expert[], FactoryError> = createManyExperts

getBuiltInConfig

(type) => Result<ExpertConfig, FactoryError> = getBuiltInExpertConfig

validate

(config) => Result<ExpertConfig, FactoryError> = validateExpertConfigStrict

Returns

ExpertFactoryAdapter

Methods

createForRole()
createForRole(role): Result<Expert, Error>;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:52

Parameters
role

AgentRole

Returns

Result<Expert, Error>

Implementation of

WorkflowExpertFactory.createForRole


TaskQueue

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:27

A task queue that limits concurrent execution.

Type Parameters

T

T

The return type of tasks in this queue

Constructors

Constructor
new TaskQueue<T>(concurrency?): TaskQueue<T>;

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:39

Creates a new TaskQueue.

Parameters
concurrency?

number = 5

Maximum number of concurrent tasks (default: 5)

Returns

TaskQueue<T>

Methods

add()
add(task): Promise<T>;

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:54

Adds a task to the queue for execution.

Parameters
task

Task<T>

The async task to execute

Returns

Promise<T>

Promise that resolves with the task result

Throws

Error if the queue has been cancelled

cancel()
cancel(): void;

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:69

Cancels all pending and running tasks. Running tasks receive an abort signal.

Returns

void

getAbortSignal()
getAbortSignal(): AbortSignal;

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:105

Returns the abort signal for external use.

Returns

AbortSignal

getQueuedCount()
getQueuedCount(): number;

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:98

Returns the number of tasks waiting in the queue.

Returns

number

getRunningCount()
getRunningCount(): number;

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:91

Returns the number of currently running tasks.

Returns

number

isCancelled()
isCancelled(): boolean;

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:84

Returns whether the queue has been cancelled.

Returns

boolean


TemplateRegistry

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:33

Template registry implementation. Manages both built-in and custom workflow templates.

Implements

Constructors

Constructor
new TemplateRegistry(): TemplateRegistry;
Returns

TemplateRegistry

Accessors

isEmpty
Get Signature
get isEmpty(): boolean;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:312

Check if the registry is empty. IRegistry interface method.

Returns

boolean

size
Get Signature
get size(): number;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:304

Get the number of registered templates. IRegistry interface method.

Returns

number

Methods

clear()
clear(): void;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:322

Clear all templates (built-in and custom). IRegistry interface method.

WARNING: This removes built-in templates. Use clearCustom() to only clear custom templates.

Returns

void

clearCustom()
clearCustom(): void;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:227

Clear all custom templates (keeps built-in).

Returns

void

get()
get(id): Result<TemplateMetadata, TemplateRegistryError>;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:253

Get template metadata by ID. IRegistry interface method.

Parameters
id

string

Template ID to retrieve

Returns

Result<TemplateMetadata, TemplateRegistryError>

Result with TemplateMetadata or TemplateRegistryError

getAll()
getAll(): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:82

Get all registered templates.

Returns

TemplateMetadata[]

Implementation of

ITemplateRegistry.getAll

getAllIds()
getAllIds(): string[];

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:285

Get all registered template IDs. IRegistry interface method.

Returns

string[]

Array of all registered template IDs

getBuiltIn()
getBuiltIn(): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:75

Get all built-in templates.

Returns

TemplateMetadata[]

Implementation of

ITemplateRegistry.getBuiltIn

getByCategory()
getByCategory(category): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:220

Get templates by category.

Parameters
category

TemplateCategory

Returns

TemplateMetadata[]

Implementation of

ITemplateRegistry.getByCategory

getById()
getById(id): WorkflowDefinition | undefined;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:89

Get a workflow definition by ID.

Parameters
id

string

Returns

WorkflowDefinition | undefined

Implementation of

ITemplateRegistry.getById

getStats()
getStats(): IRegistryStats & {
  builtIn: number;
  custom: number;
};

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:332

Get registry statistics. IRegistry interface method with domain-specific extensions.

Returns

IRegistryStats & { builtIn: number; custom: number; }

has()
has(id): boolean;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:275

Check if a template is registered. IRegistry interface method.

Parameters
id

string

Template ID to check

Returns

boolean

True if template is registered

initialize()
initialize(): Promise<void>;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:44

Initialize the registry with built-in templates. Called automatically on first access if not already initialized. Uses promise coalescing to prevent duplicate init from concurrent calls.

Returns

Promise<void>

loadFromDirectory()
loadFromDirectory(directoryPath): Promise<number>;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:164

Load templates from a directory.

Parameters
directoryPath

string

Returns

Promise<number>

Implementation of

ITemplateRegistry.loadFromDirectory

query()
query(predicate): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:296

Query templates with predicate function. IRegistry interface method.

Parameters
predicate

(item) => boolean

Function to test each template

Returns

TemplateMetadata[]

Array of matching templates

register()
register(workflow, partialMetadata?): void;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:96

Register a custom workflow template.

Parameters
workflow

WorkflowDefinition

partialMetadata?

Partial<TemplateMetadata>

Returns

void

Implementation of

ITemplateRegistry.register

search(query): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:202

Search templates by keyword.

Parameters
query

string

Returns

TemplateMetadata[]

Implementation of

ITemplateRegistry.search

unregister()
unregister(id): boolean;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:145

Unregister a custom template.

Parameters
id

string

Returns

boolean

Implementation of

ITemplateRegistry.unregister

Interfaces

CreateExecutionContextOptions

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:42

Options for creating an execution context.

Properties

executionId?
optional executionId?: string;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:48

Optional custom execution ID (auto-generated if not provided)

inputs
inputs: Record<string, unknown>;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:46

Workflow inputs

workflowId
workflowId: string;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:44

Workflow definition ID


ExecutionContext

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:31

Context passed to step executor.

Properties

executionId
executionId: string;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:33

Workflow execution ID

inputs
inputs: Record<string, unknown>;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:37

Workflow inputs

signal?
optional signal?: AbortSignal;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:39

Abort signal for cancellation

stepResults
stepResults: Map<string, StepResult>;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:35

Results from previous steps


ExecutionPhase

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:15

A phase of steps that can be executed concurrently.

Properties

phaseIndex
phaseIndex: number;

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:19

Phase index (0-based)

steps
steps: WorkflowStep[];

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:17

Steps that can run in parallel within this phase


ITemplateRegistry

Defined in: packages/nexus-agents/src/workflows/template-types.ts:37

Template registry interface.

Methods

getAll()
getAll(): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-types.ts:48

Get all registered templates (built-in + custom).

Returns

TemplateMetadata[]

Array of all template metadata

getBuiltIn()
getBuiltIn(): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-types.ts:42

Get all built-in templates.

Returns

TemplateMetadata[]

Array of built-in template metadata

getByCategory()
getByCategory(category): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-types.ts:90

Get templates by category.

Parameters
category

TemplateCategory

Category to filter by

Returns

TemplateMetadata[]

Templates in the category

getById()
getById(id): WorkflowDefinition | undefined;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:55

Get a workflow definition by template ID.

Parameters
id

string

Template name/ID

Returns

WorkflowDefinition | undefined

WorkflowDefinition or undefined if not found

loadFromDirectory()
loadFromDirectory(directoryPath): Promise<number>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:76

Load templates from a directory.

Parameters
directoryPath

string

Path to directory containing YAML templates

Returns

Promise<number>

Number of templates loaded

register()
register(workflow, metadata?): void;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:62

Register a custom workflow template.

Parameters
workflow

WorkflowDefinition

Workflow definition to register

metadata?

Partial<TemplateMetadata>

Optional additional metadata

Returns

void

search()
search(query): TemplateMetadata[];

Defined in: packages/nexus-agents/src/workflows/template-types.ts:83

Search templates by keyword.

Parameters
query

string

Search query

Returns

TemplateMetadata[]

Matching template metadata

unregister()
unregister(id): boolean;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:69

Unregister a custom template by ID.

Parameters
id

string

Template ID to unregister

Returns

boolean

True if template was removed


ParallelOptions

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:19

Options for parallel execution.

Properties

failFast?
optional failFast?: boolean;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:23

Stop on first error (default: true)

maxConcurrency?
optional maxConcurrency?: number;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:21

Maximum concurrent steps (default: 5)

timeoutMs?
optional timeoutMs?: number;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:25

Overall timeout in milliseconds


ParsedExpression

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:16

Parsed expression structure.

Properties

original
original: string;

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:18

Original expression string

path
path: string[];

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:22

Path segments after the type

type
type: ExpressionType;

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:20

Expression type (inputs, steps, variables)


ParsedTemplate

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:29

Result of parsing a template file.

Properties

definition
definition: WorkflowDefinition;

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:30

metadata
metadata: TemplateMetadata;

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:31


ResolveResult

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:28

Result of expression resolution.

Properties

error?
optional error?: string;

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:34

Error message if failed

success
success: boolean;

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:30

Whether resolution succeeded

value?
optional value?: unknown;

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:32

Resolved value if successful


StepExecutionOptions

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:86

Options for step execution.

Properties

retries?
optional retries?: number;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:88

retryDelayMs?
optional retryDelayMs?: number;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:89

timeoutMs?
optional timeoutMs?: number;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:87


StepExecutorDeps

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:75

Dependencies for the step executor.

Properties

expertFactory
expertFactory: WorkflowExpertFactory;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:76

logger?
optional logger?: {
  debug: (message, data?) => void;
  error: (message, data?) => void;
  info: (message, data?) => void;
  warn: (message, data?) => void;
};

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:77

debug
debug: (message, data?) => void;
Parameters
message

string

data?

Record<string, unknown>

Returns

void

error
error: (message, data?) => void;
Parameters
message

string

data?

Record<string, unknown>

Returns

void

info
info: (message, data?) => void;
Parameters
message

string

data?

Record<string, unknown>

Returns

void

warn
warn: (message, data?) => void;
Parameters
message

string

data?

Record<string, unknown>

Returns

void


TemplateMetadata

Defined in: packages/nexus-agents/src/workflows/template-types.ts:19

Extended template metadata for registry. Implements IRegistryItem for unified registry API (ADR-0012).

Extends

Properties

author?
optional author?: string;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:29

Template author

builtIn
builtIn: boolean;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:27

Whether this is a built-in template

category
category: TemplateCategory;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:23

Template category

Overrides

WorkflowTemplate.category

description?
optional description?: string;

Defined in: packages/nexus-agents/src/core/types/workflow.ts:184

Description

Inherited from

WorkflowTemplate.description

id
readonly id: string;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:21

Unique identifier (alias for name, required by IRegistryItem)

keywords
keywords: string[];

Defined in: packages/nexus-agents/src/workflows/template-types.ts:25

Keywords for search

name
name: string;

Defined in: packages/nexus-agents/src/core/types/workflow.ts:180

Template name

Inherited from

WorkflowTemplate.name

path
path: string;

Defined in: packages/nexus-agents/src/core/types/workflow.ts:186

File path

Inherited from

WorkflowTemplate.path

updatedAt?
optional updatedAt?: string;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:31

Last updated timestamp

version
version: string;

Defined in: packages/nexus-agents/src/core/types/workflow.ts:182

Version

Inherited from

WorkflowTemplate.version


ValidationIssue

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:177

Validation result with detailed error information.

Properties

code
code: string;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:183

Error code from Zod

message
message: string;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:181

Error message

path
path: PropertyKey[];

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:179

Path to the problematic field


WorkflowEngineFactoryConfig

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:64

Configuration for the workflow engine factory.

Extends

  • WorkflowEngineConfig

Extended by

Properties

builtInTemplates?
optional builtInTemplates?: Map<string, WorkflowDefinition>;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:66

Pre-loaded built-in templates (if not provided, loads at creation time)

contextManagerConfig?
optional contextManagerConfig?: Omit<ContextManagerConfig, "budget">;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-helpers.ts:36

Inherited from
WorkflowEngineConfig.contextManagerConfig
defaultBudget?
optional defaultBudget?: ContextBudget;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-helpers.ts:37

Inherited from
WorkflowEngineConfig.defaultBudget
defaultTimeoutMs?
optional defaultTimeoutMs?: number;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-helpers.ts:33

Inherited from
WorkflowEngineConfig.defaultTimeoutMs
expertFactory?
optional expertFactory?: WorkflowExpertFactory;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:70

Optional expert factory for dependency injection (useful for testing)

logger?
optional logger?: ILogger;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-helpers.ts:38

Inherited from
WorkflowEngineConfig.logger
maxConcurrency?
optional maxConcurrency?: number;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-helpers.ts:34

Inherited from
WorkflowEngineConfig.maxConcurrency
modelAdapter?
optional modelAdapter?: IModelAdapter;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:68

Optional pre-configured model adapter for expert agents

templatePaths?
optional templatePaths?: string[];

Defined in: packages/nexus-agents/src/workflows/workflow-engine-helpers.ts:35

Inherited from
WorkflowEngineConfig.templatePaths
useMockExecutor?
optional useMockExecutor?: boolean;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:72

Use mock executor instead of real StepExecutor (default: false when expertFactory provided)


WorkflowExecutionContext

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:17

Full execution context for a running workflow. Tracks step results, variables, and provides input resolution. This is the comprehensive context used by the step executor.

Properties

cancelled
cancelled: boolean;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:31

Whether execution has been cancelled

executionId
readonly executionId: string;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:21

Unique execution instance ID

inputs
readonly inputs: Record<string, unknown>;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:23

Initial workflow inputs

startedAt
readonly startedAt: Date;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:29

Execution start time

stepResults
readonly stepResults: Map<string, StepResult>;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:25

Results from completed steps (stepId -> result)

variables
readonly variables: Map<string, unknown>;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:27

Runtime variables set during execution

workflowId
readonly workflowId: string;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:19

Workflow definition ID


WorkflowExecutionPlan

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:25

Execution plan with ordered phases.

Properties

maxParallelism
maxParallelism: number;

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:31

Maximum parallelism (max steps in any phase)

phases
phases: ExecutionPhase[];

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:27

Ordered phases of execution

totalSteps
totalSteps: number;

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:29

Total number of steps


WorkflowExpertFactory

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:38

Interface for expert factory dependency.

Methods

createForRole()
createForRole(role): Result<Expert, Error>;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:39

Parameters
role

AgentRole

Returns

Result<Expert, Error>

Type Aliases

AgentRoleType

type AgentRoleType = z.infer<typeof StrictAgentRoleSchema>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:63

Workflows exports - Workflow engine with parallel execution Split from index.ts for file size compliance (Issue #285)


ExpressionType

type ExpressionType = "inputs" | "steps" | "variables";

Defined in: packages/nexus-agents/src/workflows/expression-resolver-types.ts:11

Types of expression references.


InputDefinitionInput

type InputDefinitionInput = z.input<typeof StrictInputDefinitionSchema>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:46

Workflows exports - Workflow engine with parallel execution Split from index.ts for file size compliance (Issue #285)


InputDefinitionOutput

type InputDefinitionOutput = z.output<typeof StrictInputDefinitionSchema>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:47

Workflows exports - Workflow engine with parallel execution Split from index.ts for file size compliance (Issue #285)


InputType

type InputType = z.infer<typeof InputTypeSchema>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:19

Workflows exports - Workflow engine with parallel execution Split from index.ts for file size compliance (Issue #285)


StepExecutor

type StepExecutor = (step, context) => Promise<StepResult>;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:45

Function signature for step execution.

Parameters

step

WorkflowStep

context

ExecutionContext

Returns

Promise<StepResult>


TemplateCategory

type TemplateCategory = "development" | "review" | "documentation" | "testing" | "custom";

Defined in: packages/nexus-agents/src/workflows/template-types.ts:13

Template category for organization.


WorkflowDefinitionInput

type WorkflowDefinitionInput = z.input<typeof StrictWorkflowDefinitionSchema>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:171

Workflows exports - Workflow engine with parallel execution Split from index.ts for file size compliance (Issue #285)


WorkflowDefinitionOutput

type WorkflowDefinitionOutput = z.output<typeof StrictWorkflowDefinitionSchema>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:172

Workflows exports - Workflow engine with parallel execution Split from index.ts for file size compliance (Issue #285)


WorkflowStepInput

type WorkflowStepInput = z.input<typeof StrictWorkflowStepSchema>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:129

Workflows exports - Workflow engine with parallel execution Split from index.ts for file size compliance (Issue #285)


WorkflowStepOutput

type WorkflowStepOutput = z.output<typeof StrictWorkflowStepSchema>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:130

Workflows exports - Workflow engine with parallel execution Split from index.ts for file size compliance (Issue #285)

Variables

AgentRoleSchema

const AgentRoleSchema: ZodEnum<{
  architecture_expert: "architecture_expert";
  code_expert: "code_expert";
  custom: "custom";
  devops_expert: "devops_expert";
  documentation_expert: "documentation_expert";
  infrastructure_expert: "infrastructure_expert";
  orchestrator: "orchestrator";
  research_expert: "research_expert";
  security_expert: "security_expert";
  testing_expert: "testing_expert";
  thinker: "thinker";
  verifier: "verifier";
  worker: "worker";
}>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:112

Agent role schema. Must match AgentRole type in core/types/agent.ts.


BUILT_IN_TEMPLATES

const BUILT_IN_TEMPLATES: readonly ["code-review", "docs-audit", "feature-implementation", "bug-fix", "documentation-update", "infrastructure-audit", "refactoring", "research-review", "security-audit", "standards-review", "test-generation"];

Defined in: packages/nexus-agents/src/workflows/template-types.ts:211

Built-in template names.


InputDefinitionSchema

const InputDefinitionSchema: ZodObject<{
  default: ZodOptional<ZodUnknown>;
  description: ZodOptional<ZodString>;
  name: ZodString;
  required: ZodDefault<ZodOptional<ZodBoolean>>;
  type: ZodEnum<{
     array: "array";
     boolean: "boolean";
     number: "number";
     object: "object";
     string: "string";
  }>;
}, $strip>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:100

Input definition schema.


InputTypeSchema

const InputTypeSchema: ZodEnum<{
  array: "array";
  boolean: "boolean";
  number: "number";
  object: "object";
  string: "string";
}>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:17

Input types supported in workflow definitions.


StrictAgentRoleSchema

const StrictAgentRoleSchema: ZodEnum<{
  architecture_expert: "architecture_expert";
  code_expert: "code_expert";
  custom: "custom";
  documentation_expert: "documentation_expert";
  infrastructure_expert: "infrastructure_expert";
  orchestrator: "orchestrator";
  security_expert: "security_expert";
  testing_expert: "testing_expert";
}>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:52

Agent roles that can execute workflow steps.


StrictInputDefinitionSchema

const StrictInputDefinitionSchema: ZodObject<{
  default: ZodOptional<ZodUnknown>;
  description: ZodOptional<ZodString>;
  name: ZodString;
  required: ZodDefault<ZodBoolean>;
  type: ZodEnum<{
     array: "array";
     boolean: "boolean";
     number: "number";
     object: "object";
     string: "string";
  }>;
}, $strict>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:25

Schema for workflow input definitions. Inputs are parameters that must be provided when executing a workflow.


StrictWorkflowDefinitionSchema

const StrictWorkflowDefinitionSchema: ZodObject<{
  defaultBudget: ZodOptional<ZodObject<{
     active: ZodNumber;
     reserved: ZodNumber;
     system: ZodNumber;
     task: ZodNumber;
  }, $strip>>;
  description: ZodOptional<ZodString>;
  inputs: ZodDefault<ZodArray<ZodObject<{
     default: ZodOptional<ZodUnknown>;
     description: ZodOptional<ZodString>;
     name: ZodString;
     required: ZodDefault<ZodBoolean>;
     type: ZodEnum<{
        array: "array";
        boolean: "boolean";
        number: "number";
        object: "object";
        string: "string";
     }>;
  }, $strict>>>;
  name: ZodString;
  steps: ZodArray<ZodObject<{
     action: ZodString;
     agent: ZodEnum<{
        architecture_expert: "architecture_expert";
        code_expert: "code_expert";
        custom: "custom";
        documentation_expert: "documentation_expert";
        infrastructure_expert: "infrastructure_expert";
        orchestrator: "orchestrator";
        security_expert: "security_expert";
        testing_expert: "testing_expert";
     }>;
     condition: ZodOptional<ZodString>;
     contextBudget: ZodOptional<ZodObject<{
        active: ZodOptional<ZodNumber>;
        reserved: ZodOptional<ZodNumber>;
        system: ZodOptional<ZodNumber>;
        task: ZodOptional<ZodNumber>;
     }, $strip>>;
     dependsOn: ZodOptional<ZodArray<ZodString>>;
     id: ZodString;
     inputs: ZodDefault<ZodRecord<ZodString, ZodUnknown>>;
     parallel: ZodOptional<ZodBoolean>;
     retries: ZodOptional<ZodNumber>;
     timeout: ZodOptional<ZodNumber>;
  }, $strict>>;
  timeout: ZodOptional<ZodNumber>;
  version: ZodString;
}, $strict>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:147

Schema for a complete workflow definition. This is the top-level structure of a workflow template file.


StrictWorkflowStepSchema

const StrictWorkflowStepSchema: ZodObject<{
  action: ZodString;
  agent: ZodEnum<{
     architecture_expert: "architecture_expert";
     code_expert: "code_expert";
     custom: "custom";
     documentation_expert: "documentation_expert";
     infrastructure_expert: "infrastructure_expert";
     orchestrator: "orchestrator";
     security_expert: "security_expert";
     testing_expert: "testing_expert";
  }>;
  condition: ZodOptional<ZodString>;
  contextBudget: ZodOptional<ZodObject<{
     active: ZodOptional<ZodNumber>;
     reserved: ZodOptional<ZodNumber>;
     system: ZodOptional<ZodNumber>;
     task: ZodOptional<ZodNumber>;
  }, $strip>>;
  dependsOn: ZodOptional<ZodArray<ZodString>>;
  id: ZodString;
  inputs: ZodDefault<ZodRecord<ZodString, ZodUnknown>>;
  parallel: ZodOptional<ZodBoolean>;
  retries: ZodOptional<ZodNumber>;
  timeout: ZodOptional<ZodNumber>;
}, $strict>;

Defined in: packages/nexus-agents/src/workflows/workflow-types.ts:98

Schema for a single workflow step. Steps are the atomic units of work in a workflow.


TEMPLATE_CATEGORIES

const TEMPLATE_CATEGORIES: Record<BuiltInTemplateName, TemplateCategory>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:230

Category mapping for built-in templates.


TEMPLATE_KEYWORDS

const TEMPLATE_KEYWORDS: Record<BuiltInTemplateName, string[]>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:247

Keywords for built-in templates.


TemplateCategorySchema

const TemplateCategorySchema: ZodEnum<{
  custom: "custom";
  development: "development";
  documentation: "documentation";
  review: "review";
  testing: "testing";
}>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:185

Template category schema.


TemplateMetadataSchema

const TemplateMetadataSchema: ZodObject<{
  author: ZodOptional<ZodString>;
  builtIn: ZodDefault<ZodBoolean>;
  category: ZodEnum<{
     custom: "custom";
     development: "development";
     documentation: "documentation";
     review: "review";
     testing: "testing";
  }>;
  description: ZodOptional<ZodString>;
  keywords: ZodDefault<ZodArray<ZodString>>;
  name: ZodString;
  path: ZodString;
  updatedAt: ZodOptional<ZodString>;
  version: ZodString;
}, $strip>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:196

Template metadata schema.


WorkflowDefinitionSchema

const WorkflowDefinitionSchema: ZodPipe<ZodObject<{
  description: ZodOptional<ZodString>;
  inputs: ZodDefault<ZodArray<ZodObject<{
     default: ZodOptional<ZodUnknown>;
     description: ZodOptional<ZodString>;
     name: ZodString;
     required: ZodDefault<ZodOptional<ZodBoolean>>;
     type: ZodEnum<{
        array: "array";
        boolean: "boolean";
        number: "number";
        object: "object";
        string: "string";
     }>;
  }, $strip>>>;
  name: ZodString;
  steps: ZodArray<ZodObject<{
     action: ZodString;
     agent: ZodEnum<{
        architecture_expert: "architecture_expert";
        code_expert: "code_expert";
        custom: "custom";
        devops_expert: "devops_expert";
        documentation_expert: "documentation_expert";
        infrastructure_expert: "infrastructure_expert";
        orchestrator: "orchestrator";
        research_expert: "research_expert";
        security_expert: "security_expert";
        testing_expert: "testing_expert";
        thinker: "thinker";
        verifier: "verifier";
        worker: "worker";
     }>;
     condition: ZodOptional<ZodString>;
     dependsOn: ZodOptional<ZodArray<ZodString>>;
     description: ZodOptional<ZodString>;
     id: ZodString;
     inputs: ZodDefault<ZodRecord<ZodString, ZodUnknown>>;
     parallel: ZodDefault<ZodOptional<ZodBoolean>>;
     retries: ZodOptional<ZodNumber>;
     timeout: ZodOptional<ZodNumber>;
  }, $strip>>;
  timeout: ZodOptional<ZodNumber>;
  version: ZodString;
}, $strip>, ZodTransform<{
  description: string | undefined;
  inputs: {
     default: unknown;
     description: string | undefined;
     name: string;
     required: boolean;
     type: "string" | "number" | "boolean" | "object" | "array";
  }[];
  name: string;
  steps: {
     action: string;
     agent:   | "custom"
        | "worker"
        | "orchestrator"
        | "code_expert"
        | "architecture_expert"
        | "security_expert"
        | "documentation_expert"
        | "testing_expert"
        | "devops_expert"
        | "research_expert"
        | "infrastructure_expert"
        | "thinker"
        | "verifier";
     condition: string | undefined;
     dependsOn: string[] | undefined;
     id: string;
     inputs: Record<string, unknown>;
     parallel: boolean;
     retries: number | undefined;
     timeout: number | undefined;
  }[];
  timeout: number | undefined;
  version: string;
}, {
  description?: string;
  inputs: {
     default?: unknown;
     description?: string;
     name: string;
     required: boolean;
     type: "string" | "number" | "boolean" | "object" | "array";
  }[];
  name: string;
  steps: {
     action: string;
     agent:   | "custom"
        | "worker"
        | "orchestrator"
        | "code_expert"
        | "architecture_expert"
        | "security_expert"
        | "documentation_expert"
        | "testing_expert"
        | "devops_expert"
        | "research_expert"
        | "infrastructure_expert"
        | "thinker"
        | "verifier";
     condition?: string;
     dependsOn?: string[];
     description?: string;
     id: string;
     inputs: Record<string, unknown>;
     parallel: boolean;
     retries?: number;
     timeout?: number;
  }[];
  timeout?: number;
  version: string;
}>>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:148

Workflow definition schema for YAML parsing. Validates and transforms YAML content into WorkflowDefinition.


WorkflowInputsSchema

const WorkflowInputsSchema: ZodRecord<ZodString, ZodUnknown>;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:37

Schema for validating workflow inputs.


WorkflowStepSchema

const WorkflowStepSchema: ZodObject<{
  action: ZodString;
  agent: ZodEnum<{
     architecture_expert: "architecture_expert";
     code_expert: "code_expert";
     custom: "custom";
     devops_expert: "devops_expert";
     documentation_expert: "documentation_expert";
     infrastructure_expert: "infrastructure_expert";
     orchestrator: "orchestrator";
     research_expert: "research_expert";
     security_expert: "security_expert";
     testing_expert: "testing_expert";
     thinker: "thinker";
     verifier: "verifier";
     worker: "worker";
  }>;
  condition: ZodOptional<ZodString>;
  dependsOn: ZodOptional<ZodArray<ZodString>>;
  description: ZodOptional<ZodString>;
  id: ZodString;
  inputs: ZodDefault<ZodRecord<ZodString, ZodUnknown>>;
  parallel: ZodDefault<ZodOptional<ZodBoolean>>;
  retries: ZodOptional<ZodNumber>;
  timeout: ZodOptional<ZodNumber>;
}, $strip>;

Defined in: packages/nexus-agents/src/workflows/template-types.ts:131

Workflow step schema.

Functions

areStepsCompleted()

function areStepsCompleted(context, stepIds): boolean;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:165

Checks if all specified steps are completed.

Parameters

context

WorkflowExecutionContext

The execution context

stepIds

string[]

Array of step identifiers to check

Returns

boolean

True if all specified steps are completed (or if stepIds is empty)

Remarks

Vacuously returns true when stepIds is empty (representing no blocking dependencies). Callers requiring proof of completed work must explicitly check that stepIds.length > 0.


buildDependencyGraph()

function buildDependencyGraph(workflow): DependencyGraph;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:252

Builds a dependency graph from a workflow definition.

Parameters

workflow

WorkflowDefinition

The workflow definition

Returns

DependencyGraph

The constructed dependency graph


cancelExecution()

function cancelExecution(context): void;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:184

Marks the execution as cancelled.

Parameters

context

WorkflowExecutionContext

The execution context

Returns

void


clearTemplateCache()

function clearTemplateCache(): void;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:566

Clears the cached built-in templates. Primarily for testing purposes.

Returns

void


containsExpressions()

function containsExpressions(value): boolean;

Defined in: packages/nexus-agents/src/workflows/expression-resolver.ts:93

Checks if a value contains expression patterns.

Parameters

value

unknown

Value to check

Returns

boolean

True if value contains expressions


createAgentStepExecutor()

function createAgentStepExecutor(deps): AgentStepExecutor;

Defined in: packages/nexus-agents/src/workflows/step-executor.ts:369

Creates a new StepExecutor instance.

Parameters

deps

StepExecutorDeps

Returns

AgentStepExecutor


createExecutionContext()

function createExecutionContext(options): WorkflowExecutionContext;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:66

Creates a new execution context for a workflow run.

Parameters

options

CreateExecutionContextOptions

Context creation options

Returns

WorkflowExecutionContext

A new WorkflowExecutionContext instance


createExecutionPlan()

function createExecutionPlan(workflow): Result<WorkflowExecutionPlan, WorkflowError>;

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:225

Creates an execution plan from a workflow definition. Groups steps into phases based on dependencies for parallel execution.

Parameters

workflow

WorkflowDefinition

Workflow definition to analyze

Returns

Result<WorkflowExecutionPlan, WorkflowError>

Result with ExecutionPlan or WorkflowError


createInitializedWorkflowEngine()

function createInitializedWorkflowEngine(config?): Promise<IWorkflowEngine>;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:593

Creates and initializes a WorkflowEngine with built-in templates loaded. This is the recommended way to create a production workflow engine.

Note: Requires modelAdapter, expertFactory, or useMockExecutor: true to be specified. Without these, WorkflowExecutionUnavailableError will be thrown. (Source: Issue #507 - Fail-safe workflow execution)

Parameters

config?

WorkflowEngineFactoryConfig

Engine configuration

Returns

Promise<IWorkflowEngine>

Promise resolving to WorkflowEngine instance


createIsolatedRegistry()

function createIsolatedRegistry(): TemplateRegistry;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:381

Create a new isolated template registry instance. Useful for testing or isolated contexts.

Returns

TemplateRegistry

New template registry instance


createProductionWorkflowEngine()

function createProductionWorkflowEngine(config?): Promise<IWorkflowEngine>;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:703

Creates and initializes a WorkflowEngine with auto-detected model adapter.

This is the most complete factory function - it:

  1. Loads built-in templates
  2. Auto-detects the best available model adapter (CLI or API)
  3. Creates the workflow engine with real step execution

Falls back gracefully to mock execution if no adapter is available.

Parameters

config?

WorkflowEngineFactoryConfig

Engine configuration

Returns

Promise<IWorkflowEngine>

Promise resolving to WorkflowEngine instance

Example

// Create production-ready workflow engine
const engine = await createProductionWorkflowEngine();

// Execute a workflow with real agent experts
const result = await engine.execute(workflow, inputs);

createRealWorkflowEngine()

function createRealWorkflowEngine(config?): IWorkflowEngine;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:577

Creates a WorkflowEngine with real dependencies.

Parameters

config?

WorkflowEngineFactoryConfig

Engine configuration

Returns

IWorkflowEngine

WorkflowEngine instance


createTaskQueue()

function createTaskQueue<T>(concurrency?): TaskQueue<T>;

Defined in: packages/nexus-agents/src/workflows/task-queue.ts:147

Creates a task queue with the specified concurrency.

Type Parameters

T

T

Parameters

concurrency?

number = 5

Maximum number of concurrent tasks

Returns

TaskQueue<T>

A new TaskQueue instance


createTemplateRegistry()

function createTemplateRegistry(): ITemplateRegistry;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:371

Create or get the template registry instance.

Returns

ITemplateRegistry

Template registry instance


createWorkflowEngineDeps()

function createWorkflowEngineDeps(config?): WorkflowEngineDeps;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:528

Creates WorkflowEngineDeps with real implementations.

When expertFactory is provided in config, the workflow engine will use the real StepExecutor to execute steps with agent experts. Otherwise, uses a mock executor.

Parameters

config?

WorkflowEngineFactoryConfig

Factory configuration

Returns

WorkflowEngineDeps

WorkflowEngineDeps instance


createWorkflowEngineDepsAsync()

function createWorkflowEngineDepsAsync(config?): Promise<WorkflowEngineDeps>;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:652

Creates WorkflowEngineDeps asynchronously with auto-detected model adapter.

This function attempts to auto-detect an available model adapter (CLI or API) and configures the workflow engine to use the real StepExecutor with ExpertFactory. Use this when you want production-ready workflow execution with real agent experts.

Parameters

config?

WorkflowEngineFactoryConfig

Factory configuration (modelAdapter will be auto-detected if not provided)

Returns

Promise<WorkflowEngineDeps>

Promise resolving to WorkflowEngineDeps

Example

// Auto-detect adapter and create deps with real execution
const deps = await createWorkflowEngineDepsAsync();
const engine = new WorkflowEngine(deps);

// Or with custom config
const deps = await createWorkflowEngineDepsAsync({
  logger: customLogger,
  useMockExecutor: false,
});

executeParallel()

function executeParallel(
   steps, 
   context, 
   stepExecutor, 
   options?
): Promise<Result<StepResult[], WorkflowError>>;

Defined in: packages/nexus-agents/src/workflows/parallel-executor.ts:207

Executes steps in parallel with concurrency limiting.

Parameters

steps

WorkflowStep[]

context

ExecutionContext

stepExecutor

StepExecutor

options?

ParallelOptions

Returns

Promise<Result<StepResult[], WorkflowError>>


extractExpressions()

function extractExpressions(input): ParsedExpression[];

Defined in: packages/nexus-agents/src/workflows/expression-resolver.ts:221

Extracts all expression references from a value. Useful for determining step dependencies.

Parameters

input

unknown

Value containing potential expressions

Returns

ParsedExpression[]

Array of parsed expressions


getBuiltInTemplates()

function getBuiltInTemplates(): Promise<Map<string, WorkflowDefinition>>;

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:279

Load all built-in templates.

Returns

Promise<Map<string, WorkflowDefinition>>

Map of template name to WorkflowDefinition


getBuiltInTemplatesPath()

function getBuiltInTemplatesPath(): string;

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:63

Get the directory containing built-in templates.

Handles both development (unbundled) and production (bundled) scenarios:

  • Development: import.meta.url points to src/workflows/template-loader.ts
  • Production: import.meta.url points to dist/index.js or dist/cli.js

Returns

string

Path to templates directory


getBuiltInTemplatesWithMetadata()

function getBuiltInTemplatesWithMetadata(): Promise<ParsedTemplate[]>;

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:296

Load built-in templates with full metadata.

Returns

Promise<ParsedTemplate[]>

Array of parsed templates with metadata


getCompletedSteps()

function getCompletedSteps(context): string[];

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:139

Gets all completed step IDs.

Parameters

context

WorkflowExecutionContext

The execution context

Returns

string[]

Array of completed step IDs


getExecutionDuration()

function getExecutionDuration(context): number;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:175

Gets the execution duration in milliseconds.

Parameters

context

WorkflowExecutionContext

The execution context

Returns

number

Duration in milliseconds


getExecutionOrder()

function getExecutionOrder(plan): string[];

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:296

Gets the execution order of steps as a flat array. Steps in the same phase are grouped together.

Parameters

plan

WorkflowExecutionPlan

Execution plan

Returns

string[]

Ordered array of step IDs


getReferencedSteps()

function getReferencedSteps(input): string[];

Defined in: packages/nexus-agents/src/workflows/expression-resolver.ts:259

Gets all step IDs referenced in expressions within a value.

Parameters

input

unknown

Value containing potential expressions

Returns

string[]

Array of referenced step IDs


getStepResult()

function getStepResult(context, stepId): StepResult | undefined;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:104

Retrieves a step result from the execution context.

Parameters

context

WorkflowExecutionContext

The execution context

stepId

string

The step identifier

Returns

StepResult | undefined

The step result or undefined if not found


getTopologicalOrder()

function getTopologicalOrder(workflow): Result<string[], ParseError>;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:306

Gets the topologically sorted execution order for a workflow. Used for parsing validation (returns ParseError). For execution planning, use createExecutionPlan from execution-planner.

Parameters

workflow

WorkflowDefinition

The workflow definition

Returns

Result<string[], ParseError>

Result with sorted step IDs or ParseError


getVariable()

function getVariable(context, name): unknown;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:129

Gets a variable from the execution context.

Parameters

context

WorkflowExecutionContext

The execution context

name

string

Variable name

Returns

unknown

The variable value or undefined


initializeBuiltInTemplates()

function initializeBuiltInTemplates(): Promise<Map<string, WorkflowDefinition>>;

Defined in: packages/nexus-agents/src/workflows/workflow-engine-factory.ts:553

Initializes and caches built-in templates. Call this at startup before creating workflow engines.

Returns

Promise<Map<string, WorkflowDefinition>>

Promise that resolves when templates are loaded


isCancelled()

function isCancelled(context): boolean;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:194

Checks if the execution has been cancelled.

Parameters

context

WorkflowExecutionContext

The execution context

Returns

boolean

True if cancelled


isStepCompleted()

function isStepCompleted(context, stepId): boolean;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:150

Checks if a step has been completed.

Parameters

context

WorkflowExecutionContext

The execution context

stepId

string

The step identifier

Returns

boolean

True if step is completed


loadTemplateFile()

function loadTemplateFile(filePath, allowedRoot?): Promise<Result<ParsedTemplate, 
  | SecurityError
| ParseError>>;

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:163

Load a template from a file path.

Parameters

filePath

string

Path to the YAML template file

allowedRoot?

string

Optional root directory for path validation (skipped if undefined)

Returns

Promise<Result<ParsedTemplate, | SecurityError | ParseError>>

Result with ParsedTemplate or ParseError/SecurityError


loadTemplatesFromDirectory()

function loadTemplatesFromDirectory(directoryPath): Promise<{
  errors: (
     | SecurityError
    | ParseError)[];
  templates: ParsedTemplate[];
}>;

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:225

Load all templates from a directory. Validates each file path to prevent path traversal attacks.

Parameters

directoryPath

string

Path to directory containing YAML templates

Returns

Promise<{ errors: ( | SecurityError | ParseError)[]; templates: ParsedTemplate[]; }>

Array of successfully loaded templates and any errors


loadWorkflowFile()

function loadWorkflowFile(filePath, allowedRoot?): Promise<Result<WorkflowDefinition, 
  | SecurityError
| ParseError>>;

Defined in: packages/nexus-agents/src/workflows/workflow-parser.ts:238

Loads and parses a workflow definition from a file.

Parameters

filePath

string

Path to the workflow file

allowedRoot?

string = ...

Root directory for path validation (defaults to process.cwd())

Returns

Promise<Result<WorkflowDefinition, | SecurityError | ParseError>>

Result with WorkflowDefinition or ParseError/SecurityError


parseExpression()

function parseExpression(expression): ParsedExpression | null;

Defined in: packages/nexus-agents/src/workflows/expression-resolver.ts:46

Parses an expression string into its components.

Parameters

expression

string

The expression content (without ${{ }})

Returns

ParsedExpression | null

Parsed expression or null if invalid


parseTemplateContent()

function parseTemplateContent(content, filePath): Result<WorkflowDefinition, ParseError>;

Defined in: packages/nexus-agents/src/workflows/template-loader.ts:138

Parse a YAML template string into a WorkflowDefinition.

Parameters

content

string

YAML content to parse

filePath

string

Path to the file (for error messages)

Returns

Result<WorkflowDefinition, ParseError>

Result with WorkflowDefinition or ParseError


parseWorkflowJson()

function parseWorkflowJson(content): Result<WorkflowDefinition, ParseError>;

Defined in: packages/nexus-agents/src/workflows/workflow-parser.ts:124

Parses a JSON string into a WorkflowDefinition.

Parameters

content

string

JSON string content

Returns

Result<WorkflowDefinition, ParseError>

Result with WorkflowDefinition or ParseError


parseWorkflowYaml()

function parseWorkflowYaml(content): Result<WorkflowDefinition, ParseError>;

Defined in: packages/nexus-agents/src/workflows/workflow-parser.ts:90

Parses a YAML string into a WorkflowDefinition.

Parameters

content

string

YAML string content

Returns

Result<WorkflowDefinition, ParseError>

Result with WorkflowDefinition or ParseError


resetRegistry()

function resetRegistry(): void;

Defined in: packages/nexus-agents/src/workflows/template-registry.ts:389

Reset the global registry instance. Primarily for testing purposes.

Returns

void


resolveExpression()

function resolveExpression(parsed, context): ResolveResult;

Defined in: packages/nexus-agents/src/workflows/expression-resolver.ts:73

Resolves a single parsed expression against the context.

Parameters

parsed

ParsedExpression

Parsed expression

context

WorkflowExecutionContext

Execution context

Returns

ResolveResult

Resolve result


resolveInput()

function resolveInput(input, context): unknown;

Defined in: packages/nexus-agents/src/workflows/expression-resolver.ts:153

Recursively resolves expressions in a value.

Handles strings, arrays, and objects. Primitives other than strings are returned unchanged.

Parameters

input

unknown

Value containing potential expressions

context

WorkflowExecutionContext

Execution context

Returns

unknown

Resolved value

Throws

ValidationError if resolution fails


resolveStringExpressions()

function resolveStringExpressions(value, context): unknown;

Defined in: packages/nexus-agents/src/workflows/expression-resolver.ts:109

Resolves all expressions in a string value.

If the entire string is a single expression, returns the resolved value. If the string contains multiple expressions or mixed content, returns a string with all expressions replaced by their resolved values.

Parameters

value

string

context

WorkflowExecutionContext

Returns

unknown


setVariable()

function setVariable(
   context, 
   name, 
   value
): void;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:118

Sets a variable in the execution context.

Parameters

context

WorkflowExecutionContext

The execution context

name

string

Variable name

value

unknown

Variable value

Returns

void


snapshotContext()

function snapshotContext(context): Record<string, unknown>;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:205

Creates a snapshot of the current context state. Useful for debugging and logging.

Parameters

context

WorkflowExecutionContext

The execution context

Returns

Record<string, unknown>

A plain object snapshot


storeStepResult()

function storeStepResult(
   context, 
   stepId, 
   result
): void;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:89

Stores a step result in the execution context.

Parameters

context

WorkflowExecutionContext

The execution context

stepId

string

The step identifier

result

StepResult

The step result to store

Returns

void


validateDependencyGraph()

function validateDependencyGraph(workflow): Result<void, ParseError>;

Defined in: packages/nexus-agents/src/workflows/dependency-graph.ts:273

Validates the dependency graph of a workflow. Checks for:

  • Duplicate step IDs
  • Missing step references
  • Circular dependencies

Parameters

workflow

WorkflowDefinition

The workflow definition to validate

Returns

Result<void, ParseError>

Result with void or ParseError


validateExpressions()

function validateExpressions(input, context): string[];

Defined in: packages/nexus-agents/src/workflows/expression-resolver.ts:188

Validates that all expressions in a value can be resolved. Does not actually resolve them, just checks validity.

Parameters

input

unknown

Value containing potential expressions

context

WorkflowExecutionContext

Execution context

Returns

string[]

Array of validation errors (empty if all valid)


validateRequiredInputs()

function validateRequiredInputs(inputs, required): ValidationError | null;

Defined in: packages/nexus-agents/src/workflows/execution-context.ts:235

Validates that required inputs are present.

Parameters

inputs

Record<string, unknown>

The inputs to validate

required

string[]

Array of required input names

Returns

ValidationError | null

Validation error or null if valid


validateWorkflow()

function validateWorkflow(workflow): Result<void, ParseError>;

Defined in: packages/nexus-agents/src/workflows/workflow-parser.ts:288

Validates a WorkflowDefinition object. Useful for validating programmatically created workflows.

Parameters

workflow

WorkflowDefinition

WorkflowDefinition to validate

Returns

Result<void, ParseError>

Result with void or ParseError


validateWorkflowDependencies()

function validateWorkflowDependencies(workflow): Result<void, WorkflowError>;

Defined in: packages/nexus-agents/src/workflows/execution-planner.ts:279

Validates a workflow definition without creating a full plan.

Parameters

workflow

WorkflowDefinition

Workflow definition to validate

Returns

Result<void, WorkflowError>

Result with void or WorkflowError