商业产业 Hacker News AI 2026-09-23T19:42 正文 ok 967 words

Show HN:AgentRun——将 Agent 转化为工作流的 DSL

英文标题:🔶 Show HN: AgentRun: DSL to turn agents into Workflows

AgentRun 是面向既有 Agent 的工作流语言,可将可重复步骤、Jev 决策节点和需要调查时调用的 Agent 组合为可执行工作流。它保留应用原有的工具、模型访问权限、权限控制和预算,并提供 JSON、TypeScript builder 与 Zod contracts 等工作流定义方式。项目当前版本为 0.1.0-beta.3,支持脚本化演示、实时 Jev 与 Pi 集成、并行任务、受限循环及工作流嵌套调用。对开发者而言,AgentRun 提供了对 Agent 流程进行显式定义、测试、审查、重跑和升级处理的机制,但官方也提醒类型化决策与输出校验并不能保证答案事实正确。
打开原文相关 5 · 机会 2
media333.6 KB media36.2 KB

中文

为你的 Agent 添加由 Jev 驱动的工作流。

AgentRun 是一门面向你已经在运行的 Agent 的工作流语言。定义可重复执行的步骤,使用 Jev 做出聚焦决策,并在任务需要调查时调用 Agent。你的应用仍保留自身的工具、模型访问权限、权限控制和预算。

快速开始 · 文档 · 示例 · Pi 扩展 · Agent 指令

支持工作流:搜索答案,使用 Jev 检查答案,然后返回答案或要求 Agent 进行调查。返回调查结果或将其升级审核前,先检查该调查结果。

查看静态图表 · 运行此示例

下面的支持示例使用脚本化工具和模型响应,遵循这一工作流。

需要 Node 22.19+ 和 npm。在你的项目中:

npm install @parcha/agentrun-dsl@beta
npx agentrun demo

这个工单路由演示使用脚本化决策,无需 API key。接下来,在你自己的应用中运行并修改工作流。要运行上方展示的支持工作流,请使用下面的 checkout。要使用你的 Agent 构建工作流,请安装 Pi 扩展。

要运行动画中的工作流,请克隆示例并构建:

git clone --branch main --single-branch https://github.com/Parcha-ai/agentrun.git
cd agentrun
# With nvm: nvm install && nvm use
npm ci --ignore-scripts
npm run build
npm run demo:support

这会使用脚本化工具、Jev 回答和 Agent 响应运行解释器。它无需 API key,也不会发送任何客户回复。

该命令会为每个案例输出一份报告:

请求 Agent 调用 决策调用 结果
重置密码 0 1 返回帮助答案
查找发票 0 1 返回帮助答案
调查支付失败 1 2 返回调查答案
支付问题仍未解决 1 2 升级审核
npm run demo:support -- payment
npm run test:support

尝试运行 npm run demo:support -- unresolved 以查看升级处理。它会以退出码 2 结束。响应均为脚本化内容;修改提示词不会改变这些响应。

连接实时 Jev 和你的 Agent,或将这些指令交给你的编程 Agent。

工作流是什么样的

支持工作流要求提供答案文本和来源引用。Jev 还必须以至少 0.8 的置信度回答 yes。否则,工作流允许 Agent 尝试一次,然后再次检查。如果答案仍未通过这些检查,工作流会将其升级审核。你可以为自己的任务选择相应的标准和阈值。

以下是该工作流中的搜索和决策节点:

{
  node: 'call', label: 'find-answer', via: 'tool',
  tool: 'help.search', args: { request: '{request}' },
  out: 'Candidate', as: 'answer', deadline_s: 10,
},
{
  node: 'judge', label: 'check-existing-answer',
  state: { request: '{request}', answer: '{answer}' },
  out: 'Fit', as: 'fit',
}

Candidate 和 Fit 指向工作流中的 schema。Fit 定义了问题及其 yes、no 和 uncertain 判定标准。代码读取决策及其置信度,以选择下一步。阅读完整定义,其中包括 Agent 和审核路径。

你可以将工作流写成 JSON,或使用 TypeScript builder 和 Zod contracts。builder 会推断输入和输出类型。解释器会在运行时检查中间状态路径。工作流可以调用其他工作流、并行映射任务,并运行受限循环。

在你的应用中使用 npm install @parcha/agentrun-dsl@beta @parcha/agentrun-jev@beta 安装核心包和 Jev adapter。然后:

  1. 提供 adapters。 通过 runEffect 连接工具,通过 runNode 连接你现有的 Agent,并通过 createJevRunner() 将 Jev 决策作为 runJudge 连接。
  2. 定义并测试工作流。 编写其 schemas、步骤、阈值和审核路径。先使用 fixtures,再根据任务中的带标签案例评估真实决策。
  3. 为你的 Agent 提供工作流工具。 将调用 runWorkflow 的函数注册为 Agent 的一个工具。处理工作流的输出、升级处理和错误。

支持集成指南提供了配置模板和实时命令。实时 Jev 调用需要来自 TypeSafe dashboard 的 TYPESAFE_API_KEY,该 key 与你的编程 Agent 登录信息相互独立。不包含 Jev 决策的工作流不需要该 key。有关权限、取消和恢复,请参阅宿主集成。

安装 Pi 0.87.0 后,在项目中运行以下命令:

pi install npm:@parcha/agentrun-pi@0.1.0-beta.3 -l
pi --offline

-l 会安装到当前项目中;--offline 会跳过启动下载。Pi 会在加载其扩展前询问你是否信任该项目。无需 AgentRun checkout。

  • /agentrun demo 会加载脚本化研究示例;/agentrun run 会在不调用模型的情况下重复运行它。
  • /agentrun demo live 使用你已配置的 Pi 模型和 Jev。
  • /agentrun status 检查设置;/agentrun 显示图;/agentrun stop 请求取消。

一旦 Pi 获得模型访问权限,就让它构建一个工作流:

/agentrun Research how this repository handles cancellation. Investigate the runtime and tests separately, then report gaps with file references.

Pi 使用打包的 skill 来构建、检查和运行工作流。如果在已打开的 Pi 会话中进行安装,请运行 /reload。使用 /agentrun save <name> 和 /agentrun load <name> 管理项目本地的定义版本。保存内容既不包含运行输入,也不包含执行权限。Pi 设置和限制。

在构建后的 checkout 中,运行一个脚本化研究工作流:“我们的团队是否应将文档从 wiki 迁移到代码仓库?”

npm run demo
npm run eval:research

它会规划子问题、并行开展研究、筛选证据并撰写报告。评估会使用脚本化响应检查六个带标签案例。连接真实 Jev 和 Pi 模型。

软件包、状态和贡献

此版本为 0.1.0-beta.3。请参阅更新日志以及contracts 和限制。

对于固定的顺序,普通函数可能已经足够。AgentRun 会将步骤存储在你可以检查、重跑或由 Agent 调用的工作流文档中。代码节点会以进程权限执行 JavaScript;不受信任的工作流作者需要由宿主控制的沙箱。类型化决策和经过验证的输出形状,并不能证明答案在事实层面是正确的。

有关开发环境设置和检查,请参阅贡献指南。如有 bug 或提议,请提交 issue。

代码和文档采用 Apache-2.0 许可证。版权所有 © 2026 Parcha Labs, Inc. 依赖项保留各自的许可证。由 Grep.ai 构建。

English / 原文

Add Jev-powered workflows to your agents.

AgentRun is a workflow language for the agents you already run. Define repeatable steps, use Jev for focused decisions, and call an agent when the work needs investigation. Your application keeps its tools, model access, permissions, and budgets.

Quickstart · Documentation · Examples · Pi extension · Agent instructions

Support workflow: search for an answer, check it with Jev, and return it or ask an agent to investigate. Check the investigation before returning it or escalating for review.

View the static diagram · Run this example

The support example below follows this workflow with scripted tools and model responses.

Requires Node 22.19+ and npm. In your project:

npm install @parcha/agentrun-dsl@beta
npx agentrun demo

This ticket-routing demo uses scripted decisions and needs no API key. Next, run and change a workflow in your own app. To run the support workflow shown above, use the checkout below. To build workflows with your agent, install the Pi extension.

To run the workflow in the animation, clone the examples and build:

git clone --branch main --single-branch https://github.com/Parcha-ai/agentrun.git
cd agentrun
# With nvm: nvm install && nvm use
npm ci --ignore-scripts
npm run build
npm run demo:support

This runs the interpreter with scripted tools, Jev answers, and agent responses. It needs no API key and sends no customer replies.

The command prints a report for each case:

Request Agent calls Decision calls Result
Reset a password 0 1 Return the help answer
Find an invoice 0 1 Return the help answer
Investigate a failed payment 1 2 Return the investigation answer
Payment still unresolved 1 2 Escalate for review
npm run demo:support -- payment
npm run test:support

Try npm run demo:support -- unresolved to see an escalation. It exits with code 2. The responses are scripted; changing a prompt does not change them.

Connect live Jev and your agent, or give these instructions to your coding agent.

What a workflow looks like

The support workflow requires answer text and a source reference. Jev must also answer yes with confidence of at least 0.8. Otherwise, the workflow allows one agent attempt and checks again. If the answer still fails those checks, it escalates for review. You choose the criteria and thresholds for your task.

These are the search and decision nodes from that workflow:

{
  node: 'call', label: 'find-answer', via: 'tool',
  tool: 'help.search', args: { request: '{request}' },
  out: 'Candidate', as: 'answer', deadline_s: 10,
},
{
  node: 'judge', label: 'check-existing-answer',
  state: { request: '{request}', answer: '{answer}' },
  out: 'Fit', as: 'fit',
}

Candidate and Fit refer to schemas in the workflow. Fit defines the question and its yes, no, and uncertain criteria. Code reads the decision and its confidence to choose the next step. Read the complete definition, including the agent and review path.

Write workflows as JSON or use the TypeScript builder and Zod contracts. The builder infers input and output types. The interpreter checks intermediate state paths at runtime. Workflows can call other workflows, map work in parallel, and run bounded loops.

Install the core and Jev adapter in your application with npm install @parcha/agentrun-dsl@beta @parcha/agentrun-jev@beta. Then:

  1. Supply adapters. Connect tools through runEffect, your existing agent through runNode, and Jev decisions through createJevRunner() as runJudge.
  2. Define and test the workflow. Write its schemas, steps, thresholds, and review path. Start with fixtures, then evaluate real decisions on labeled cases from your task.
  3. Give your agent a workflow tool. Register a function that calls runWorkflow as one of your agent's tools. Handle the workflow's output, escalation, and errors.

The support integration guide has a config template and live command. Live Jev calls need TYPESAFE_API_KEY from the TypeSafe dashboard, separate from your coding-agent login. Workflows without Jev decisions do not need that key. See host integration for permissions, cancellation, and recovery.

With Pi 0.87.0 installed, run these commands in your project:

pi install npm:@parcha/agentrun-pi@0.1.0-beta.3 -l
pi --offline

-l installs in this project; --offline skips startup downloads. Pi asks whether you trust the project before loading its extension. No AgentRun checkout is needed.

  • /agentrun demo loads the scripted research example; /agentrun run repeats it without model calls.
  • /agentrun demo live uses your configured Pi model and Jev.
  • /agentrun status checks setup; /agentrun shows the graph; /agentrun stop requests cancellation.

Once Pi has model access, ask it to build a workflow:

/agentrun Research how this repository handles cancellation. Investigate the runtime and tests separately, then report gaps with file references.

Pi uses the packaged skill to build, inspect, and run the workflow. Run /reload if you install into an open Pi session. Use /agentrun save <name> and /agentrun load <name> for project-local definition revisions. Saves contain neither run input nor execution permission. Pi setup and limits.

From the built checkout, run a scripted research workflow: "Should our team move its docs from a wiki into the code repository?"

npm run demo
npm run eval:research

It plans subquestions, researches them in parallel, screens evidence, and writes a report. The evaluation checks six labeled cases with scripted responses. Connect real Jev and Pi models.

Packages, status, and contributing

This release is 0.1.0-beta.3. See the changelog and contracts and limits.

Ordinary functions may be enough for a fixed sequence. AgentRun stores the steps in a workflow document that you can inspect, rerun, or call from an agent. Code nodes execute JavaScript with process privileges; untrusted workflow authors require a host-controlled sandbox. Typed decisions and validated output shapes do not prove that an answer is factually correct.

For development setup and checks, see Contributing. Open an issue for bugs or proposals.

Code and documentation use Apache-2.0. Copyright 2026 Parcha Labs, Inc. Dependencies retain their own licenses. Built by Grep.ai.