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

@runflow-ai/flow-compiler

v0.0.3

Published

Bidirectional compiler between visual FlowGraph and Runflow SDK TypeScript code

Readme

@runflow-ai/flow-compiler

Bidirectional compiler between visual FlowGraph JSON and Runflow SDK TypeScript code.

The visual flow editor (Flows / Agent Builder) is a projection of the canonical agent code. This package is the bridge: it compiles a graph into runnable SDK code and (in the beta roadmap) parses code back into a graph.

Install

npm install @runflow-ai/flow-compiler

Inside the Runflow monorepo it is consumed via npm workspaces by apps/api-portal and apps/portal (the latter only imports types).

Usage

import { compile, validate, FlowGraph } from '@runflow-ai/flow-compiler';

const graph: FlowGraph = {
  id: 'support_agent',
  name: 'Support Agent',
  nodes: [
    { id: 'start_1', kind: 'start', config: {} },
    { id: 'classify', kind: 'agent', config: {
      agentName: 'classifier',
      model: { provider: 'openai', modelId: 'gpt-4o-mini' },
      instructions: 'Classify support tickets…',
    } },
    { id: 'end_1', kind: 'end', config: {} },
  ],
  edges: [
    { id: 'e1', source: 'start_1', target: 'classify' },
    { id: 'e2', source: 'classify', target: 'end_1' },
  ],
};

const issues = validate(graph);              // cycle/orphan/required-field checks
const { source, sourceHash, warnings } = compile(graph);

The emitted source is plain Runflow SDK TypeScript using flow().agent().branch().build() — deployable via rf deploy like any other agent.

Supported nodes

| Kind | SDK primitive | Runflow-exclusive | |---|---|---| | start | flow() entry | — | | trigger | bound to trigger-engine (webhook / cron / manual) | ✓ | | agent | Agent + .agent(id, instance, { prompt }) | — | | branch | .branch(id, { condition, onTrue, onFalse }) | — | | transform | .step(id, async (input, ctx) => …) | — | | knowledge | Knowledge.search(query, { k, threshold }) | ✓ | | mcp | .connector(id, slug, tool, 'invoke', params) against mcp-gateway | ✓ | | guardrails | PIISanitizer({ locale, strategy }) | ✓ | | credentials | Credentials.get(id) injected into context | ✓ | | end | terminal step | — |

Each emitted step is annotated with // @flow-node:<uuid> so future round-trip (decompile) preserves IDs without losing canvas-authored structure.

Validation

validate(graph) returns ValidationIssue[] with errors (block save) and warnings (allowed). Built-in checks: single start node, no orphan edges, branch must have an onTrue edge, Knowledge requires vectorStore, MCP requires instanceSlug + toolSlug, Credentials require credentialId.

Tests

npm test --workspace=packages/flow-compiler

8 tests covering: validation, deterministic hashing, the 6 base nodes, and each of the 4 Runflow-exclusive nodes.

Round-trip (decompile)

compile() embeds the full FlowGraph as a base64 JSON comment (// @flow-graph-json:<…>) at the top of the emitted source. decompile(source) reads that line back and returns the graph — survives hand-editing of function bodies as long as the marker line is preserved.

import { compile, decompile } from '@runflow-ai/flow-compiler';
const { source } = compile(graph);
const { graph: recovered } = decompile(source); // === graph

This is "best-effort" Phase-2 round-trip. For agents whose TS was authored entirely outside the canvas (no marker), decompile returns null. Full AST-level round-trip via ts-morph is the Phase-3 roadmap.

Roadmap

  • AST-level decompile (ts-morph) for code authored outside the canvas
  • Additional nodes: While, User approval, Sandbox, Deploy
  • Trace replay attribute (flow.nodeId) on startSpan for live debugging