Skip to content

release: prepare tRPC Agent Service v0.1.1 - #165

Merged
XnLemon merged 6 commits into
mainfrom
codex/multitenant-webui-acceptance
Sep 10, 2026
Merged

XnLemon merged 6 commits into
mainfrom
codex/multitenant-webui-acceptance

Conversation

@XnLemon

@XnLemon XnLemon commented Sep 9, 2026 •

Copy link
Copy Markdown
Owner

变更概览

本 PR 将服务从“需要通过 API/Admin API 手工拼装控制面对象”推进到可以直接从 WebUI 完成首轮 Agent 与渠道配置的 0.1.1 发布候选。它把多租户、多 Agent、Telegram 和企业微信 AI Bot 的配置、运行时物化、真实对话验收和部署文档串成一条可执行路径。

0.1.1 发布内容

  • 服务版本统一为 0.1.1。
  • WebUI package 版本统一为 0.1.1。
  • Kubernetes Deployment/Kustomize 默认镜像更新为 ghcr.io/xnlemon/trpc-agent-service:0.1.1。
  • 部署校验脚本和部署文档同步到 0.1.1。
  • 发布 v0.1.1 tag 后,.github/workflows/publish-image.yml 会构建并推送 amd64/arm64 GHCR 镜像。

核心功能

面向真实用户的 WebUI

在 trpcservice/web 新增 React + Tailwind + shadcn 风格 setup flow:

  1. 管理员登录;
  2. 创建或选择租户;
  3. 注册 Agent;
  4. 配置模型、endpoint、指令;
  5. 创建并发布 Model Profile、Backend Profile 和 Agent Revision;
  6. 将 Agent 设为租户默认 Agent;
  7. 选择 Telegram 或 WeCom AI Bot;
  8. 输入渠道凭据并建立实时连接;
  9. 在对应渠道发送第一条真实消息。

WebUI 同时支持:

  • 租户切换;
  • 一个租户下多个 Agent 的展示和默认 Agent 切换;
  • Agent 下线/恢复;
  • Telegram 连接和断开;
  • WeCom AI Bot ID/Secret 连接;
  • 连接状态轮询和首条会话引导;
  • 明确区分 WeCom AI Bot ID/Secret 与 Corp ID、Agent ID、回调 Token。

多租户、多 Agent runtime

  • 新增按租户懒加载的 TenantRuntimeRegistry。
  • 新租户和新 Agent 通过控制面创建后即可在第一次请求时物化,不需要重启服务。
  • Execution Plan cache key 同时包含 tenant、app、revision、model/backend version 和 content digest,避免跨租户或跨 Agent 复用 Runner。
  • 租户 runtime 使用 tenant-scoped Model/Backend/Secret Registry。
  • 正常关闭和失败启动路径都会清理 runtime registry、session 和 provider 资源。

Telegram 和 WeCom AI Bot 连接生命周期

  • Admin API 新增租户级连接接口:
    • POST /admin/v1/tenants/{tenant_id}/connections
    • GET /admin/v1/tenants/{tenant_id}/connections
    • DELETE /admin/v1/tenants/{tenant_id}/connections/{binding_id}
  • 凭据只穿过认证的连接请求进入进程内 Secret Registry,不写入 Binding、Revision、日志、trace、审计或响应。
  • Telegram 连接使用真实 getMe 身份校验、long polling、tenant/binding/app 路由和回复发送。
  • WeCom AI Bot 使用官方 wss://openws.work.weixin.qq.com 和 aibot_subscribe 协议,支持认证回执、重连、心跳、回复确认和 durable outbox。
  • 修复 WeCom WebUI Binding key 使用下划线导致控制面创建失败的问题(web-wecom-aibot-*)。
  • 兼容带 cmd: aibot_subscribe 的认证回执。
  • 增加不泄露 Secret 的拨号、认证拒绝、认证超时和连接阶段诊断日志。

租户审计与运行时隔离修复

  • 审计 writer 改为始终按事件自身的 tenant_id 动态路由。
  • 修复单 API identity 启动时固定租户审计 writer 导致第二租户 Telegram 请求报 audit tenant scope violation 的问题。
  • 保持 PostgreSQL tenant scope、Agent App、Binding、Session 和 Reply Outbox 的隔离。

复用的上游能力

本 PR 继续复用 tRPC-Agent-Go 和仓库既有平台边界,没有另起一套 Agent 执行框架:

  • 上游 Agent/Runner 执行循环、LLM flow、工具调用、事件流和最大 LLM call budget;
  • 上游 Model provider 接口与 OpenAI-compatible endpoint;
  • 上游 Session/Memory 能力,通过本项目的 tenant-scoped Backend Profile 物化;
  • 既有 Gateway Dispatch、Execution Plan、Runner lease、取消和完整事件 drain;
  • 既有 Agent App/Revision publish、Model Profile、Backend Profile 和 Secret Resolver;
  • 既有 PostgreSQL control plane、migration、乐观锁、Outbox、审计和 observability;
  • Telegram adapter 的真实 Bot API 边界;
  • WeCom AI Bot adapter 的 WebSocket、回执、心跳和 durable reply 边界。

工程亮点

  • 可信路由:tenant/app/binding 不接受来自 Telegram 或 WeCom 消息体的自报值,只从 active Binding 和 control plane 解析。
  • 计划级隔离:Runner cache identity 包含完整 tenant/app/revision/profile 版本与摘要,跨租户复用在构造阶段被阻断。
  • Secret 边界清晰:控制面只保存 secret_ref;WebUI 连接 secret 只进入进程内 resolver,错误和日志脱敏。
  • 动态装配:租户和 Agent 可通过 WebUI 创建后在首次执行时懒加载,不要求重启或写死多租户 env identity。
  • 可靠回复:WeCom 最终回复使用现有 Reply Outbox、lease/fencing、receipt acknowledgement 和恢复路径。
  • 可审计:Admin mutation、执行生命周期、渠道入站/出站和租户变更继续进入既有 audit/metrics 边界。
  • 可部署:Dockerfile 同时构建 Go service、静态 healthcheck 和 WebUI;Compose/Kubernetes/CI 使用同一版本和 readiness contract。
  • 面向评测的路径:README、部署文档和专项验收文档给出从空环境到真实首条消息的逐步命令与检查点。

AI 评测推荐路径

离线、无外部凭据

git clone https://github.com/XnLemon/trpc-agent-service.git
cd trpc-agent-service
cp deploy/example.env deploy/service.env
./scripts/quickstart.sh --demo deploy/service.env
curl -fsS http://127.0.0.1:8080/readyz

期望:服务健康,demo 自动创建 Tenant/App/Model/Backend/Revision,并通过 /v1/chat 返回:

Hello from the tRPC Agent Service demo.

真实 WebUI + 双租户 Telegram

docker compose --env-file deploy/service.env \
  -p trpcfresh -f deploy/docker-compose.yml \
  up -d --build service
curl -fsS http://localhost:8080/readyz

随后打开 http://localhost:8080:

  1. 登录 admin;
  2. 选择/创建租户 A,配置并发布 Agent A;
  3. 选择 Telegram,输入 Bot A ID/Token,看到 Your agent is connected;
  4. 在 Telegram 发送 tenant-a-session-001;
  5. 对租户 B 重复,使用 Agent B 和 Bot B;
  6. 检查两条消息的 tenant_id、app_id、session 和回复没有串租户。

真实 WebUI + WeCom AI Bot

在同一个 WebUI setup flow 选择 WeCom:

  1. 输入企业微信 AI Bot 管理页面的 AI Bot ID;
  2. 输入同一个 Bot 的 AI Bot Secret;
  3. 看到 Your agent is connected;
  4. 在企业微信客户端对该 AI Bot 发送唯一 marker;
  5. 检查 WebSocket 认证、tenant/app 路由和回复。

不要把 Corp ID、Agent ID、应用 Secret、回调 Token 或 EncodingAESKey 填入 AI Bot 长连接表单。完整路径、诊断日志和常见错误阶段见 多租户多 Agent Telegram / WeCom 验收链路。

实际验收成果

  • 已在本地 Compose + PostgreSQL + Redis 环境启动 trpcfresh-service-1,/readyz 返回 200 ready。
  • 已用真实 OpenAI-compatible endpoint 验证 /v1/models 和 /v1/responses 可达。
  • 已完成双租户 Agent/Model Profile/Backend Profile/Published Revision 控制面配置。
  • 已完成真实 Telegram Bot 连接、tenant/app 路由核对和第二租户审计隔离问题定位与修复。
  • 已验证租户 2 失败的真实根因为固定租户 audit writer,修复后改为按事件 tenant 动态路由。
  • 已验证 WeCom AI Bot WebSocket 连接协议、认证回执兼容、Binding 创建路径和失败阶段诊断;WebUI 端到端步骤已固化到 README/验收文档。
  • 当前 WebUI/渠道 Secret 为进程内生命周期;服务重启后必须从 WebUI 重新连接,这是明确记录的发布边界。

验证结果

  • go test ./... -count=1
  • npm run build(trpcservice/web)
  • python -m mkdocs build --strict -f docs/mkdocs.yml
  • ./scripts/validate-deployment.sh
  • git diff --check
  • Docker Compose 镜像构建通过
  • /readyz 返回 ready

发布/部署注意事项

  • 合并后创建并推送 v0.1.1 tag,触发 GHCR 多架构镜像发布。
  • 生产部署应使用 ghcr.io/xnlemon/trpc-agent-service:0.1.1 或 digest,不使用 latest。
  • 生产环境需要替换 admin、model、database 和渠道凭据;不要提交 deploy/service.env。
  • 当前 channel credentials 进程内保存,滚动重启前应安排重新连接或后续接入持久化 Secret Manager。

Add tenant-scoped runtime materialization and process-owned Telegram and WeCom AI Bot connections, with the React setup UI and acceptance documentation.
@XnLemon
XnLemon force-pushed the codex/multitenant-webui-acceptance branch from 7a1c56d to c6bcc07 Compare September 9, 2026 18:21
@XnLemon
XnLemon deployed to telegram-e2e September 9, 2026 18:21 — with GitHub Actions Active
@XnLemon XnLemon changed the title feat: add multi-tenant channel setup WebUI release: prepare tRPC Agent Service v0.1.1 Sep 9, 2026
@XnLemon
XnLemon deployed to telegram-e2e September 9, 2026 18:29 — with GitHub Actions Active
@XnLemon XnLemon self-assigned this Sep 10, 2026
@XnLemon
XnLemon deployed to telegram-e2e September 10, 2026 05:07 — with GitHub Actions Active
Comment thread trpcservice/bootstrap/web_connections_test.go Fixed
Comment thread trpcservice/bootstrap/web_connections_test.go Outdated
@XnLemon
XnLemon deployed to telegram-e2e September 10, 2026 05:10 — with GitHub Actions Active
Comment thread trpcservice/bootstrap/web_connections_test.go Fixed
Comment thread trpcservice/bootstrap/web_connections_test.go Fixed
Comment thread trpcservice/bootstrap/web_connections_test.go
@XnLemon
XnLemon deployed to telegram-e2e September 10, 2026 06:19 — with GitHub Actions Active
Comment thread trpcservice/bootstrap/web_connections_test.go Dismissed
Comment thread trpcservice/bootstrap/web_connections_test.go Dismissed
@XnLemon
XnLemon merged commit 204faa4 into main Sep 10, 2026
12 checks passed
XnLemon pushed a commit to XnLemon/trpc-agent-service-platform that referenced this pull request Sep 10, 2026
Sync XnLemon/trpc-agent-service-platform with the merged upstream main.

Source PR: XnLemon/trpc-agent-service#165
Source merge commit: 204faa4

This branch was successfully deployed

1 active deployment
telegram-e2e — f4a7741c Deployed Sep 10, 2026 by XnLemon via Telegram live long-polling E2E #773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants