Cogitator
API Reference

Workflows API

Complete API reference for @cogitator-ai/workflows — DAG-based orchestration.

Classes

WorkflowBuilder

Fluent API for constructing workflow DAGs:

import { WorkflowBuilder } from '@cogitator-ai/workflows';

const workflow = new WorkflowBuilder()
  .addNode('step1', agentNode(agent))
  .addNode('step2', toolNode(myTool))
  .addEdge('step1', 'step2')
  .build();

Methods:

MethodSignatureDescription
addNodeaddNode(id: string, node: WorkflowNode)Add a node to the DAG
addEdgeaddEdge(from: string, to: string, condition?)Connect two nodes
buildbuild(): WorkflowCompile the workflow

WorkflowExecutor

Execute compiled workflows:

import { WorkflowExecutor } from '@cogitator-ai/workflows';

const executor = new WorkflowExecutor(workflow, options?);
const result = await executor.execute(input);

ExecutorOptions:

PropertyTypeDescription
cogitatorCogitatorRuntime for agent nodes
checkpointingbooleanEnable checkpoints
maxConcurrencynumberMax parallel nodes
timeoutnumberExecution timeout (ms)

Node Factories

import { agentNode, toolNode, functionNode, humanNode, customNode } from '@cogitator-ai/workflows';
FactoryDescription
agentNode(agent)Run an Agent, returns its output
toolNode(tool)Execute a tool directly
functionNode(fn)Run arbitrary async function
humanNode(options)Pause for human input
customNode(handler)Fully custom node logic

Saga Support

import { SagaExecutor, CompensationRegistry } from '@cogitator-ai/workflows';
ClassDescription
SagaExecutorExecute workflows with compensation
CompensationRegistryRegister rollback actions per node

Scheduling

import { WorkflowScheduler, CronTrigger, WebhookTrigger } from '@cogitator-ai/workflows';
ClassDescription
WorkflowSchedulerSchedule workflow executions
CronTriggerCron-based scheduling
WebhookTriggerHTTP webhook triggers
TimerTriggerOne-shot delayed execution

On this page