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

@agenticforge/workflow

v1.0.0

Published

DAG workflow engine for AgenticFORGE

Downloads

30

Readme

@agenticforge/workflow

npm License: CC BY-NC-SA 4.0

AgenticFORGE 的独立 DAG 工作流引擎。为 WorkflowAgent 提供底层驱动,也可以直接用于后端任务编排,无需 Agent 层包装。

安装

npm install @agenticforge/workflow

特性

  • Sequential(顺序)— 通过 depends 形成线性执行链
  • Parallel(并发)— 无相互依赖的节点在同一波次自动并发
  • Branch(条件分支)— condition(ctx) 返回分支名,执行对应子 DAG
  • Loop(循环)— do-while 模式,反复执行 body 子 DAG
  • 拓扑排序 — Kahn 算法,自动检测循环依赖
  • 并发上限maxConcurrency 控制单波次最大并发数

节点类型

| 类型 | 说明 | |------|------| | tool | 调用已注册工具,inputTemplate 支持 {变量} 插值 | | llm | 直接调用 LLM,promptTemplate 支持 {变量} 插值 | | fn | 自定义异步函数 (ctx, llm, registry) => string | | passthrough | 透传某个 context 变量 | | branch | 条件分支,condition(ctx) 返回分支名 | | loop | 循环执行 body 子 DAG(do-while 语义) |

用法

直接使用(不经过 WorkflowAgent)

import "dotenv/config";
import { WorkflowEngine } from "@agenticforge/workflow";
import { LLMClient } from "@agenticforge/core";

const engine = new WorkflowEngine({
  llm: new LLMClient({ provider: "openai", model: "gpt-4o" }),
  verbose: true,
});

const result = await engine.execute(
  {
    name: "summary-pipeline",
    nodes: [
      { id: "draft",  type: "llm", promptTemplate: "写一段摘要:{input}",   depends: [] },
      { id: "refine", type: "llm", promptTemplate: "优化这段摘要:\n{draft}", depends: ["draft"] },
    ],
  },
  "2024年AI行业发展趋势",
);

console.log(result.output);
console.log(result.nodeResults); // 每个节点的状态和耗时

并发 fan-out / fan-in

const result = await engine.execute(
  {
    name: "bilingual-report",
    nodes: [
      { id: "fetch",     type: "tool", toolName: "search", inputTemplate: "{input}",                        depends: [] },
      { id: "analyze",   type: "llm",  promptTemplate: "分析:\n{fetch}",                                   depends: ["fetch"] },
      { id: "translate", type: "llm",  promptTemplate: "翻译成英文:\n{fetch}",                             depends: ["fetch"] },
      { id: "report",    type: "llm",  promptTemplate: "双语报告:\n{analyze}\n\n{translate}",               depends: ["analyze", "translate"] },
    ],
  },
  "2024年AI趋势",
);

条件分支

nodes: [
  { id: "classify", type: "llm", promptTemplate: "只输出 simple 或 complex:{input}", depends: [] },
  {
    id: "router", type: "branch",
    condition: (ctx) => ctx["classify"].includes("complex") ? "complex" : "simple",
    branches: {
      simple:  [{ id: "quick",  type: "llm", promptTemplate: "简洁回答:{input}",  depends: [] }],
      complex: [{ id: "detail", type: "llm", promptTemplate: "详细分析:{input}", depends: [] }],
    },
    depends: ["classify"],
  },
]

循环(迭代优化)

nodes: [
  {
    id: "refine", type: "loop",
    maxIterations: 3,
    condition: (ctx, iter) => !ctx["refine"].includes("满意"),
    body: [
      { id: "critique", type: "llm", promptTemplate: "批评上一版本:{refine}",   depends: [] },
      { id: "improve",  type: "llm", promptTemplate: "根据批评改进:{critique}", depends: ["critique"] },
    ],
  },
]

WorkflowEngineOptions

| 选项 | 类型 | 默认值 | 说明 | |------|------|--------|------| | llm | LLMClient | 必填 | LLM 实例 | | registry | ToolRegistry | — | tool 节点必须提供 | | verbose | boolean | false | 打印每个波次的执行日志 | | maxConcurrency | number | 不限制 | 单波次最大并发节点数 |

与 WorkflowAgent 配合使用

如需会话历史、Hooks 生命周期、run() 统一接口,可使用 @agenticforge/agents 中的 WorkflowAgent

import { WorkflowAgent } from "@agenticforge/agents";
import type { WorkflowDefinition } from "@agenticforge/workflow";

const agent = new WorkflowAgent({
  name: "my-workflow",
  llm,
  verbose: true,
});

agent.setWorkflow(definition);
const output = await agent.run("输入文本");

链接