AIFeed

Show HN:AG-UI,一个用于将 AI 智能体连接到前端的开放协议

Translation(model translation, not the source's own text)

AG-UI Inspector

题图
题图

一个 Manifest V3 Chrome DevTools 扩展,用于实时捕获、解码和调试 AG-UI 1.0 协议流。

无需再眯着眼看 Chrome 网络面板里原始的 text/event-stream 数据块,AG-UI Inspector 会把 agent 运行重建成可折叠的执行树,让你逐步回放状态补丁,并把真实的 agent 流量导出为确定性的 Playwright 和 MSW 测试 mock。

功能特性

  • 零配置流捕获:通过 Chrome DevTools Protocol(chrome.debugger)被动拦截 HTTP + Server-Sent Events(SSE)以及 EventSource 流量,包括嵌套 iframe——无需改动 SDK。
  • 扁平视图与执行树视图:可在按时间顺序的线缆日志和嵌套执行树(RUN_STARTED → STEP_STARTED → TOOL_CALL_ → TEXT_MESSAGE_)之间切换,支持跨度时长汇总和自动折叠 token 数据块。
  • 状态时间旅行:从 STATE_SNAPSHOT 出发,不可变地重放 RFC 6902 STATE_DELTA JSON Patch,从而重建时间线上任意事件处的 agent 状态。
  • 一键生成测试代码:将任意捕获的运行直接导出为可复制粘贴的 Playwright page.route() mock 或 MSW(http.post)流式处理器。
  • 协议诊断:校验 AG-UI 1.0 生命周期规则,标记被截断的流或格式错误的帧,并检查脱敏后的 RunAgentInput 载荷。
  • 内置脱敏:在存储或导出追踪记录之前,自动清除敏感请求头、查询参数以及 secret/token/password 键。
  • 一键示例运行:内置示例 agent 运行,无需实时后端即可测试时间线、状态时间旅行和 mock 生成器。

快速安装(未打包——无需构建)

你可以在约 30 秒内将预构建的扩展直接加载到 Chrome 或 Edge 中:

  • 从 Releases 页面下载最新的 ag-ui-inspector-v*.zip。
  • 将压缩包解压到本地文件夹(确认 manifest.json 直接位于解压后的文件夹内)。
  • 在浏览器中打开 chrome://extensions。
  • 打开右上角的开发者模式。
  • 点击加载已解压的扩展程序,并选择解压后的文件夹。

使用方法

  • 打开任意运行 AG-UI 的应用(或直接在 AG-UI Dojo 上测试)。
  • 打开 Chrome DevTools(F12 或 Cmd+Option+I / Ctrl+Shift+I),选择 AG-UI 面板标签页。
  • 点击 Attach 开始捕获实时流(或在空状态下点击 Load Sample Run 离线探索)。
  • 使用 Flat | Tree 切换和 Collapse chunks 复选框来检查工具调用,在 State 标签页中回放 STATE_DELTA 补丁,或点击 Copy as Playwright Mock / Copy as MSW Handler。

本地开发

前置条件

安装与构建


        # Install dependencies
npm install

# Run unit tests (Vitest)
npm test

# Run TypeScript typecheck
npm run typecheck

# Build production extension into dist/
npm run build
      

运行 npm run build 后,通过 chrome://extensions → 加载已解压的扩展程序加载生成的 dist/ 目录。

项目架构


        Inspected Tab
  └─▶ chrome.debugger (CDP Network events)
        └─▶ CdpCapture (src/background/cdp-capture.ts)
              └─▶ SseStreamDecoder (src/lib/sse.ts)
                    └─▶ InspectorStore (src/background/store.ts)
                          └─▶ chrome.runtime.Port (throttled deltas)
                                └─▶ React DevTools Panel (src/panel/)
      
路径职责
src/assets/manifest.jsonManifest V3 配置与权限( debugger 、 storage )
src/devtools/在 Chrome DevTools 中注册 AG-UI 标签页
src/background/sw.tsMV3 service worker,管理面板端口与节流的状态更新
src/background/cdp-capture.tsCDP 网络附加、iframe 自动附加与流式分块解码
src/background/store.ts运行分组( runId )、截断检测与 chrome.storage.session 持久化
src/lib/sse.ts增量式 SSE 帧解析器
src/lib/agui.tsAG-UI 1.0 事件族映射与结构诊断
src/lib/eventTree.ts分层事件树投影与汇总时长计算器
src/lib/codegen.tsPlaywright 与 MSW mock 生成器
src/shared/redaction.ts请求头、查询字符串与密钥脱敏
src/panel/React UI、虚拟化事件列表与 RFC 6902 状态检查器

Roadmap

  • WebSocket 与自定义传输解码
  • Protobuf 线格式支持
  • 完整的 AG-UI JSON Schema 校验
  • 用于跨会话追踪历史的 IndexedDB 保留

Privacy & Security

所有捕获的流量严格保留在浏览器内存与 chrome.storage.session 本地。敏感的 authorization 请求头、token 以及匹配密钥的键在存储或导出前均会被脱敏。

License

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗