Skip to content

feat(openclaw-plugin): support tenant account and user headers#1378

Open
chethanuk wants to merge 2 commits intovolcengine:mainfrom
chethanuk:feature/1216-openclaw-tenant-headers
Open

feat(openclaw-plugin): support tenant account and user headers#1378
chethanuk wants to merge 2 commits intovolcengine:mainfrom
chethanuk:feature/1216-openclaw-tenant-headers

Conversation

@chethanuk
Copy link
Copy Markdown
Contributor

Summary

  • add accountId and userId to the OpenClaw OpenViking plugin config and schema
  • propagate tenant headers through all plugin client construction paths
  • add config and integration coverage for tenant header parsing and request routing

Testing

  • npm test -- tests/ut/config.test.ts tests/ut/plugin-normal-flow-real-server.test.ts
  • npm test

Fixes #1216

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

1216 - Fully compliant

Compliant requirements:

  • Extend plugin config with accountId and userId
  • Pass accountId/userId as X-OpenViking-Account/X-OpenViking-User headers
  • Update plugin config schema to accept these fields
  • Allow env var fallback for accountId/userId
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 92
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Potential Missing Client Construction Path

The PR updates the OpenVikingClient constructor call in the respawn path, but other client construction paths (e.g., remote mode) are not visible in the diff. Verify all paths are updated to pass tenantAccount and tenantUser.

const client = new OpenVikingClient(
  baseUrl,
  cfg.apiKey,
  cfg.agentId,
  cfg.timeoutMs,
  tenantAccount,
  tenantUser,
  routingDebugLog,
);

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@Mijamind719 Mijamind719 self-assigned this Apr 13, 2026
@jcp0578
Copy link
Copy Markdown
Contributor

jcp0578 commented Apr 13, 2026

  1. 原本已有 resolved_user_id,其作用是参与本地 identity/space 推导,并用于 routing debug 日志;它的数值来源不是插件配置,而是调用 /api/v1/system/status 的返回值。相关代码包括 getRuntimeIdentity()emitRoutingDebug()resolveScopeSpace()

  2. 现在 config.userId 已经被明确作为客户端期望的 tenant user,并通过 X-OpenViking-User 发给服务端;但代码里参与本地 identity/space 推导的仍是 /api/v1/system/status 返回值,建议本地推导 identity/space 时优先使用 config.userId

  3. 建议保留 /api/v1/system/status 返回值作为 server_reported_user_id 用于诊断,在两者不一致时输出 warning/ERROR。

Use config.userId for local identity/space derivation while retaining /system/status user as server_reported_user_id diagnostics. Emit mismatch warnings even when verbose routing logs are disabled, and add coverage for target URI rewriting and mismatch logging.
@chethanuk
Copy link
Copy Markdown
Contributor Author

@jcp0578 已根据这条 review comment 完成修复并推送:c0956866

更新点:

  1. 本地 identity/space 推导优先使用 config.userId(避免 header 与本地路由空间不一致)。
  2. 仍保留 /api/v1/system/status 返回 user 作为 server_reported_user_id 用于诊断。
  3. config.userId 与 server reported user 不一致时输出 WARNING user identity mismatch(即使 logFindRequests=false 也会告警,不再静默)。

补充:

  • 路由 debug 中新增 server_reported_user_id 字段。
  • 增加 UT 覆盖:验证 target_uri 改写到 viking://user/<config.userId>/memories,并验证 mismatch warning 输出。

已验证:npm test -- tests/ut/plugin-normal-flow-real-server.test.ts tests/ut/config.test.ts 通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Feature]: Openclaw plugin supports X-OpenViking-Account and X-OpenViking-User

3 participants