Skip to content

✨ feat: support local device binding in lh agent run#13277

Merged
arvinxx merged 2 commits intolobehub:canaryfrom
cy948:feat/agent-run-local-device
Apr 3, 2026
Merged

✨ feat: support local device binding in lh agent run#13277
arvinxx merged 2 commits intolobehub:canaryfrom
cy948:feat/agent-run-local-device

Conversation

@cy948
Copy link
Copy Markdown
Contributor

@cy948 cy948 commented Mar 26, 2026

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔗 Related Issue

🔀 Description of Change

  • apps/cli/src/commands/connect.ts: lh connect 现在会在前台和 daemon 模式下统一写入本地连接状态,并额外记
    录当前 deviceId,供后续命令解析 --device local。
    • apps/cli/src/daemon/manager.ts: 扩展本地 daemon 状态结构,新增 deviceId 持久化字段,让 CLI 不同进程之间
      可以共享当前连接设备信息。
    • apps/cli/src/utils/device.ts: 新增 resolveLocalDeviceId(),从本地状态文件读取当前连接设备 ID,作为 local
      别名解析入口。
    • apps/cli/src/commands/agent.ts: 为 agent run 增加 --device 参数,支持 --device local,并在请求前校验目标
      设备存在且在线,再把 deviceId 透传给执行接口。
    • packages/types/src/agentGroup/index.ts: 为 ExecAgentParams 增加可选 deviceId,把显式设备执行正式纳入共享
      类型定义。
    • src/services/aiAgent.ts: 为客户端执行参数增加 deviceId 字段,继续向 tRPC execAgent 调用透传。
    • src/server/routers/lambda/aiAgent.ts: 在 execAgent schema 中接收可选 deviceId,并将其传递给服务端执行
      service。
    • src/server/services/aiAgent/index.ts: 在执行时把显式设备绑定到 topic metadata,并按“本次请求设备 > topic
      绑定设备 > agent 绑定设备 > bot/IM 唯一在线设备”的顺序决定最终激活设备。
    • packages/types/src/topic/topic.ts: 为 ChatTopicMetadata 增加 boundDeviceId,将 topic 级设备绑定纳入共享
      模型。
    • src/services/topic/index.ts: 扩展 topic metadata 更新参数,允许客户端更新 boundDeviceId。
    • src/server/routers/lambda/topic.ts: 扩展 topic metadata 更新 schema,允许服务端接口接收 boundDeviceId。
    • packages/openapi/src/types/topic.type.ts: 同步更新 OpenAPI topic metadata schema,补齐 boundDeviceId 协
      议定义。

🧪 How to Test

  • Tested locally
  • Added/updated tests
  • No tests needed

📸 Screenshots / Videos

Before After
... ...

📝 Additional Information

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

@cy948 is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @cy948, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@lobehubbot
Copy link
Copy Markdown
Member

@ONLY-yours @nekomeowww - This PR adds local device binding support for the agent run command, touching AI agent services (backend + client), topic services, and CLI commands. Please coordinate on review.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.53%. Comparing base (9264a9c) to head (bdbb577).
⚠️ Report is 2 commits behind head on canary.

Additional details and impacted files
@@             Coverage Diff             @@
##           canary   #13277       +/-   ##
===========================================
- Coverage   86.13%   66.53%   -19.60%     
===========================================
  Files         608     1994     +1386     
  Lines       48759   165041   +116282     
  Branches     7540    15937     +8397     
===========================================
+ Hits        42000   109815    +67815     
- Misses       6637    55104    +48467     
  Partials      122      122               
Flag Coverage Δ
app 58.32% <97.14%> (?)
database 92.57% <ø> (ø)
packages/agent-runtime 88.98% <ø> (ø)
packages/context-engine 86.51% <ø> (ø)
packages/conversation-flow 92.36% <ø> (ø)
packages/file-loaders 87.02% <ø> (ø)
packages/memory-user-memory 66.68% <ø> (ø)
packages/model-bank 99.85% <ø> (ø)
packages/model-runtime 84.73% <ø> (ø)
packages/prompts 65.80% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 90.02% <ø> (ø)
packages/web-crawler 88.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 66.87% <ø> (∅)
Services 49.50% <0.00%> (∅)
Server 66.09% <100.00%> (∅)
Libs 51.03% <ø> (∅)
Utils 91.01% <ø> (-2.46%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cy948 cy948 marked this pull request as ready for review March 26, 2026 15:45
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5fa59331c3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@cy948 cy948 force-pushed the feat/agent-run-local-device branch from 38ef150 to 0eff22a Compare April 3, 2026 03:14
@cy948 cy948 force-pushed the feat/agent-run-local-device branch from bf131ba to bdbb577 Compare April 3, 2026 04:45
@arvinxx arvinxx merged commit eb086b8 into lobehub:canary Apr 3, 2026
20 of 21 checks passed
@lobehubbot
Copy link
Copy Markdown
Member

❤️ Great PR @cy948 ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

arvinxx added a commit that referenced this pull request Apr 7, 2026
# 🚀 release: 20260407

This release includes **148 commits**. Key updates are below.

- **Response API tool execution is more capable and reliable** — Added
hosted builtin tools + client-side function tools and improved tool-call
streaming/completion behavior.
[#13406](#13406)
[#13414](#13414)
[#13506](#13506)
[#13555](#13555)
- **Input and composition UX upgraded** — Added AI input auto-completion
and multiple chat-input stability fixes.
[#13458](#13458)
[#13551](#13551)
[#13481](#13481)
- **Model/provider compatibility improved** — Better Gemini/Google tool
schema handling and additional model updates.
[#13429](#13429)
[#13465](#13465)
[#13613](#13613)
- **Desktop and CLI reliability improved** — Gateway WebSocket support
and desktop runtime upgrades.
[#13608](#13608)
[#13550](#13550)
[#13557](#13557)
- **Security hardening continued** — Fixed auth and sanitization risks
and upgraded vulnerable dependencies.
[#13535](#13535)
[#13529](#13529)
[#13479](#13479)

### Models & Providers

- Added/updated support for `glm-5v-turbo`, GLM-5.1 updates, and
qwen3.5-omni series.
[#13487](#13487)
[#13405](#13405)
[#13422](#13422)
- Added additional ImageGen providers/models (Wanxiang 2.7 and Keling
from Qwen). [#13478](#13478)
- Improved Gemini/Google tool schema and compatibility handling across
runtime paths. [#13429](#13429)
[#13465](#13465)
[#13613](#13613)

### Response API & Runtime

- Added hosted builtin tools in Response API and client-side function
tool execution support.
[#13406](#13406)
[#13414](#13414)
- Improved stream tool-call argument handling and `response.completed`
output correctness.
[#13506](#13506)
[#13555](#13555)
- Improved runtime error/context handling for intervention and provider
edge cases. [#13420](#13420)
[#13607](#13607)

### Desktop App

- Bumped desktop dependencies and runtime integrations (`agent-browser`,
`electron`). [#13550](#13550)
[#13557](#13557)
- Simplified desktop release channel setup by removing nightly release
flow. [#13480](#13480)

### CLI

- Added OpenClaw migration command.
[#13566](#13566)
- Added local device binding support for `lh agent run`.
[#13277](#13277)
- Added WebSocket gateway support and reconnect reliability
improvements. [#13608](#13608)
[#13418](#13418)

### Security

- Removed risky `apiKey` fallback behavior in webapi auth path to
prevent bypass risk.
[#13535](#13535)
- Sanitized HTML artifact rendering and iframe sandboxing to reduce
XSS-to-RCE risk. [#13529](#13529)
- Upgraded nodemailer to v8 to address SMTP command injection advisory.
[#13479](#13479)

### Bug Fixes

- Fixed image generation model default switch issues.
[#13587](#13587)
- Fixed subtopic re-fork message scope behavior and agent panel reset
edge cases. [#13606](#13606)
[#13556](#13556)
- Fixed chat-input freeze on paste and mention plugin behavior.
[#13551](#13551)
[#13415](#13415)
- Fixed auth/social sign-in and settings UX edge cases.
[#13368](#13368)
[#13392](#13392)
[#13338](#13338)

### Credits

Huge thanks to these contributors:

@chriszf @hardy-one @Innei @lijian @neko @OctopusNote @rdmclin2
@rivertwilight @RylanCai @suyua9 @sxjeru @Tsuki @wangyk @WindSpiritSR
@yizhuo @YuTengjing @hezhijie0327 @arvinxx
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