plaita-nodes
plaita 的通用节点集(infra 级):把 plaita 声明式流程接到真实世界——Agent CLI、本地命令、微信人工确认、通知、文件。
背景:ADR-2026-08-27 编排双轨收敛 ——编排内核收敛到 plaita,Agent 执行层统一走 agentproc;本仓是这层决议的节点承载。
节点一览
| type | 节点 | 说明 |
|---|---|---|
agentrun |
Agent 运行 | Agent 原子:多步工具循环(模型可调工具自主多轮)。经 agentproc 调用 Agent CLI(recursive / claude);配置复用 flowcast 的 agents.json / providers.json |
llm |
LLM 补全 | LLM 原子:单次 chat/completions 生成文本(OpenAI 兼容端点)。与 agentrun 的边界见下 |
capture |
命令执行 | 跑本地命令捕获输出;失败不抛错(exit_code 返回,流程自行分支) |
hitl |
人工确认 | 直连 hitl-server(iLink 微信通道):发消息 → 轮询回复 |
notify |
通知 | terminal 后端(stdout) |
writefile |
写文件 | UTF-8 写文件,支持 JSON 序列化 |
节点经 pyproject 的 [project.entry-points."plaita.nodes"] 自动注册;plaita_nodes.register_all() 可手动注册。
原子节点设计原则
抽象一条硬标准——原子性(一个节点只做一件不可再分的事)、通用性 (不绑定业务语义与特定凭证)、普适性(覆盖一类外部交互):
- Agent ≠ LLM:
agentrun是多步工具循环的 Agent 原子(重);llm是单次 补全的 LLM 原子(轻)。流程里"摘要/改写/抽取/分类"用llm,"多步编码/ 工具任务"用agentrun。 - 纯文本变换(判决提取、frontmatter 解析等)不做节点——注册为表达式
F.*函数(ExpressionRegistry.register),在 assignment 里一行使用。 - 业务领域的状态机(如内容池销账)属于业务仓,不放本仓。
快速上手
# monorepo 内可编辑安装(plaita / agentproc 均为兄弟仓)
pip install -e ../plaita[http] -e ../agentproc/sdk/python -e .
from plaita import Flow
flow = Flow.from_string(open("flow.json").read())
result = flow.run(track="default", platforms=["twitter"], topic="", repo="/path/to/repo")
JSON 用法示例(agentrun + 模板表达式):
{
"type": "agentrun", "id": "brief",
"agent": "glm-52",
"prompt": "{% $F.concat($INPUT.item.brief_prompt) %}",
"next": "write"
}
agents.json / providers.json 兼容性
配置搜索顺序与 flowcast 一致:~/.flowx → ~/.flowcast → <repo>/.flowcast(深合并)。
与 flowcast 的两处行为差异(有意为之):
- agents.json 里的
env字段 flowcast 白名单会静默丢弃,本仓按配置透传 (如 glm-52 的RECURSIVE_MAX_TOKENS)。 - recursive 直路径 flowcast 默认无超时,本仓
timeout_secs默认 1800。
设计边界
- 安全:任何日志不打 apiKey / ANTHROPIC_AUTH_TOKEN。
- dry-run:所有有副作用的节点尊重
globalContext.dry_run——agentrun/capture/hitl 返回 fake 结果,writefile 照常写(草稿便于检查)。 - 断点续跑:hitl 为阻塞版(Normal 模式);崩溃级恢复走 plaita Distributed + EventNode 模式(见 ADR phase 2)。
- 新增执行器:在
agentprocexecutor 层扩展 +config.EXECUTOR_ALIASES加映射,本仓节点无需改动。
开发
pip install -e ".[dev]"
pytest
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file plaita_nodes-0.3.0.tar.gz.
File metadata
- Download URL: plaita_nodes-0.3.0.tar.gz
- Upload date:
- Size: 34.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52194e14e3d306b043f25acb8a0bd8fbcc7b0197bb91f5e70f347d47a8cfb864
|
|
| MD5 |
14dc231827d56b62065d917ab882130e
|
|
| BLAKE2b-256 |
efdfb98089c11c6d26f192bab6e850c52db078c798ef88e12ab1787ed37c1137
|
File details
Details for the file plaita_nodes-0.3.0-py3-none-any.whl.
File metadata
- Download URL: plaita_nodes-0.3.0-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
600b28f3a184c9e85df7305808e5eb585b5c063db5924536cf29c368bc18052d
|
|
| MD5 |
961137391daf57f82d96ee7a49c71a9d
|
|
| BLAKE2b-256 |
530a9998ac7706bc12f10c823706d23819ab0ca9ef2936bf5ffed30fd57b7e32
|