npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@marktoflow/core

v2.0.5

Published

AI workflow engine with tool calling, parallel execution, structured output, and agent routing

Readme

@marktoflow/core

AI workflow engine — parse, execute, and orchestrate markdown-based automations with tool calling, parallel execution, and structured output.

npm

Part of marktoflow — open-source AI workflow automation.

Quick Start

npm install @marktoflow/core
import { WorkflowParser, WorkflowEngine } from '@marktoflow/core';

const parser = new WorkflowParser();
const workflow = await parser.parseWorkflow('workflow.md');

const engine = new WorkflowEngine();
const result = await engine.execute(workflow, {
  inputs: { message: 'Hello World' },
});

Features

  • Workflow Parser — Parse markdown + YAML workflow definitions with Zod validation
  • Execution Engine — Step-by-step execution with retry, circuit breakers, and error handling
  • Control Flow — Conditionals (if/else), loops (for-each), try/catch/finally, parallel branches
  • Parallel Executionparallel.spawn (multi-agent) and parallel.map (batch processing)
  • Sub-Workflows — Nested workflow execution with optional AI sub-agent mode
  • Template Engine — Nunjucks-based expressions with 50+ built-in filters
  • State Management — SQLite-based persistent state tracking
  • Plugin System — Extensible architecture with 17 hook types
  • Cost Tracking — Monitor and budget API usage per workflow/step
  • Agent Routing — Capability-based agent selection with cost optimization and load balancing
  • Scheduling — Cron-based workflow scheduling
  • Security — RBAC, approval workflows, secret management (Vault, AWS, Azure, env), audit logging
  • Queue System — Distributed execution via Redis, RabbitMQ, or in-memory

Usage

Control Flow

// The engine handles conditionals, loops, parallel, and try/catch natively
const workflow = await parser.parseWorkflow('complex-workflow.md');
const result = await engine.execute(workflow);

// Access step results
console.log(result.output);
console.log(result.stepResults);

State Management

import { WorkflowEngine, StateManager } from '@marktoflow/core';

const stateManager = new StateManager({ dbPath: '.marktoflow/state.db' });
const engine = new WorkflowEngine({ stateManager });
const result = await engine.execute(workflow);

const history = await stateManager.getWorkflowHistory(workflow.id);

Scheduling

import { Scheduler } from '@marktoflow/core';

const scheduler = new Scheduler();
await scheduler.schedule({
  workflowId: 'daily-report',
  cron: '0 9 * * 1-5',
  workflowPath: './workflows/daily-report.md',
});
await scheduler.start();

Plugin System

import { PluginRegistry } from '@marktoflow/core';

const registry = new PluginRegistry();
await registry.register({
  name: 'my-plugin',
  hooks: {
    beforeWorkflowStart: async (ctx) => console.log('Starting:', ctx.workflow.id),
    afterStepComplete: async (ctx) => console.log('Done:', ctx.step.action),
  },
});

Agent Routing

import { AgentRouter, AgentSelector, BudgetTracker } from '@marktoflow/core';

const selector = new AgentSelector(agentProfiles, 'balanced');
const budget = new BudgetTracker({ totalBudget: 10.0 });
const router = new AgentRouter(selector, budget);

const result = router.route({
  requiredCapabilities: new Set(['tool_calling', 'streaming']),
  maxCost: 0.05,
});

Architecture

@marktoflow/core
├── engine/              # Workflow execution engine
│   ├── control-flow     # if/else, for-each, parallel, try/catch
│   ├── subworkflow      # Sub-workflow and AI sub-agent execution
│   ├── variable-resolution  # Nunjucks template resolution
│   ├── conditions       # Condition evaluation
│   └── retry            # Retry with exponential backoff
├── operations/          # 9 built-in operation modules
├── filters/             # 9 Nunjucks filter modules (50+ filters)
├── parser               # Markdown + YAML parser
├── routing              # Agent selection and routing
├── costs                # Cost tracking and budgeting
├── state-manager        # SQLite-based state persistence
├── sdk-registry         # Dynamic SDK loading and caching
├── plugin-registry      # Plugin system with 17 hook types
└── utils/               # Duration parsing, error handling

API Reference

class WorkflowParser {
  parseWorkflow(filePath: string): Promise<Workflow>;
  parseYAML(content: string): Workflow;
  validate(workflow: Workflow): ValidationResult;
}

class WorkflowEngine {
  constructor(options?: EngineOptions);
  execute(workflow: Workflow, context?: ExecutionContext): Promise<WorkflowResult>;
  stop(): Promise<void>;
}

class StateManager {
  constructor(options: StateOptions);
  getWorkflowHistory(workflowId: string): Promise<WorkflowRun[]>;
  saveWorkflowState(state: WorkflowState): Promise<void>;
}

class AgentSelector {
  select(context: RoutingContext): RoutingResult;
  registerAgent(profile: AgentProfile): void;
}

class SDKRegistry {
  registerTools(tools: Record<string, ToolConfig>): void;
  load(name: string): Promise<unknown>;
}

Contributing

See the contributing guide.

License

AGPL-3.0