@reinsjs/ui-agui

中文文档
0.3.3发布于 2026/11/02MITTypeScriptES Module

reins — timeline events → AG-UI protocol events (encoder for @reinsjs/server, or standalone mapper)

原始使用文档

@reinsjs/ui-agui

Timeline events → AG-UI protocol events. reins does not invent a front-end protocol; this package makes any AG-UI client (CopilotKit and friends) a working UI for a reins agent. Zero runtime dependencies; every emitted event is validated against @ag-ui/core's official schema in the tests.

pnpm add @reinsjs/ui-agui
import { aguiEncoding } from "@reinsjs/ui-agui"
import { createAgentHandler } from "@reinsjs/server"

// `agentDefinition` is the AgentDefinition (loop config); with `createAgent()` that is `agent.definition`
export const POST = createAgentHandler(agentDefinition, { encode: aguiEncoding() })

The umbrella @reinsjs/agent package already uses aguiEncoding() as the default for createAgent(...).handler.

Mapping

timelineAG-UI
run start / resultRUN_STARTED, RUN_FINISHED (outcome: success or interrupt with one entry per Interruption, the full RunResult — including the signed state — in result), RUN_ERROR
model_text (+ streaming deltas)TEXT_MESSAGE_START / _CONTENT / _END
model_thinkingREASONING_*
tool_call, tool_resultTOOL_CALL_START / _ARGS / _END, TOOL_CALL_RESULT
user_messageMESSAGES_SNAPSHOT-compatible user message
everything else (system_note, compaction, approval_*, budget_usage, run_paused …)CUSTOM with name = event type and the event as value

Interrupts carry what a UI needs to answer them: an approval has toolCallId, the request summary and the policy id; a subagent interrupt (a nested agent waiting for approval) has metadata.childSessionId plus the child's own interruptions — send the decision back with sessionId: childSessionId.

mapEvent / AGUI_MAPPING are exported for hosts that want the pure per-event translation without the streaming encoder. @reinsjs/ui-agui/demo/index.html is a dependency-free page that talks to @reinsjs/server and renders the stream; examples/minimal serves it.

Documentation

docs/系统全景图_模块盘点/ui-agui.md — in Chinese, at the repository root.

MIT © 2026 NewRate Limited.

版本与发布记录

@reinsjs/ui-agui 共发布 8 个版本,首次发布于 2026/09/14;过去 12 个月发布了 8 个版本。

版本发布日期距今
0.3.3latest2026/11/021 天前
0.3.22026/10/313 天前
0.3.12026/10/303 天前
0.3.02026/09/221 个月前
0.2.12026/09/151 个月前
0.2.02026/09/151 个月前

关于 @reinsjs/ui-agui 的常见问题

@reinsjs/ui-agui 是什么?

缰绳-时间轴事件→AG-UI协议事件(@reinsjs/server的编码器,或独立的映射器)

如何安装 @reinsjs/ui-agui?

在项目目录运行 npm install @reinsjs/ui-agui,或使用 pnpm add / yarn add / bun add。

@reinsjs/ui-agui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@reinsjs/ui-agui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@reinsjs/ui-agui 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@reinsjs/ui-agui 可以商用吗?

@reinsjs/ui-agui 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@reinsjs/ui-agui 还在维护吗?

最新版本 0.3.3 发布于 2026/11/02(1 天前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/09/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。