🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(hetero): let external agents run the latest lh once via dlx when the device lh is too old (#21258)
Neko16c1d1db8e0a
diff --git a/packages/heterogeneous-agents/src/protocol/lobeHubCliGuide.test.ts b/packages/heterogeneous-agents/src/protocol/lobeHubCliGuide.test.tsnew file mode 100644index 00000000000..af381f84303--- /dev/null+++ b/packages/heterogeneous-agents/src/protocol/lobeHubCliGuide.test.ts@@ -0,0 +1,19 @@+import { describe, expect, it } from 'vitest';++import { lobeHubCliGuide } from './lobeHubCliGuide';++describe('lobeHubCliGuide', () => {+ it('forbids replacing the installed lh and logging in', () => {+ expect(lobeHubCliGuide).toContain('Never install, upgrade or replace `lh` globally');+ expect(lobeHubCliGuide).toContain('never run `lh login`');+ });++ it('does not forbid running a newer CLI outright', () => {+ expect(lobeHubCliGuide).not.toMatch(/never install it/);+ });++ it('names a one-off latest-CLI run when the installed lh is too old', () => {+ expect(lobeHubCliGuide).toContain('`pnpm --package @lobehub/cli@latest dlx lh …`');+ expect(lobeHubCliGuide).toContain('`npx -y -p @lobehub/cli@latest lh …`');+ });+});diff --git a/packages/heterogeneous-agents/src/protocol/lobeHubCliGuide.ts b/packages/heterogeneous-agents/src/protocol/lobeHubCliGuide.tsindex 9f572889cbd..fe6255ff86a 100644--- a/packages/heterogeneous-agents/src/protocol/lobeHubCliGuide.ts+++ b/packages/heterogeneous-agents/src/protocol/lobeHubCliGuide.ts@@ -33,6 +33,13 @@ import type { AgentTextBlock } from './types';* hand-copied flag list here would. The homogeneous runtime gets the same* material as `@lobechat/builtin-skills`'s `lobehub` skill.*+ * It forbids installing `lh` but not running a newer one. A global reinstall+ * can swap out the binary a `lh connect` device is running from, yet devices+ * keep whatever `lh` they were set up with and new commands land in every+ * release. A blanket "never install it" made agents refuse a one-off+ * `pnpm dlx` of the latest CLI even when the user asked for it, leaving them+ * stuck on an old device; the stale-`lh` bullet names that path explicitly.+ ** Two things it deliberately does NOT promise, because they are not true on* every transport:*@@ -73,13 +80,13 @@ export const lobeHubCliSkillDescription ="Reach the user's LobeHub — the app this conversation runs in — through the preinstalled `lh` CLI. Use when the request concerns LobeHub itself: its documents, knowledge bases, files, memory, earlier conversations (topic ids start with `tpc_`, or a `<refer_topic>` tag), agents and your own agent configuration, tasks, projects, widgets, bots, models, providers, plugins or skills, or generating images, video or speech there. Not needed for ordinary work on local files or other tools.";const lobeHubCliGuideBody = [- "You are running inside a LobeHub conversation, on a machine where the `lh` CLI is already installed and the run normally carries the user's credentials in its environment — never install it, and never run `lh login`.",+ "You are running inside a LobeHub conversation, on a machine where the `lh` CLI is already installed and the run normally carries the user's credentials in its environment. Never install, upgrade or replace `lh` globally — that binary may be the one running `lh connect`, which is executing you — and never run `lh login`.",'','- **When to use it:** only when the user asks for something that lives in LobeHub rather than in this working directory — saving a document, recalling an earlier conversation, generating an image, or changing your own agent configuration. A request about local files, code or another tool does not need `lh`. Say what you did and where it landed.',"- **You already know where you are.** `LOBEHUB_TOPIC_ID` (this conversation) and `LOBEHUB_OPERATION_ID` (this run) are in your environment, and `LOBEHUB_AGENT_ID` (you) and `LOBEHUB_WORKSPACE_ID` (the workspace this conversation belongs to, which scopes every `lh` call) are too whenever the run carries them. They are ordinary environment variables, so every sub-shell, script or tool you spawn inherits them. Pass them straight to commands rather than listing agents or topics to find yourself; if the one you need is empty, say so instead of guessing an id. LobeHub topic ids start with `tpc_` — an id in the user's message without that prefix belongs to something else.",'- **Earlier conversations:** read one with `lh topic view <id>`. This run can always read its own conversation and the ones the user names in it (a `tpc_…` id or a `<refer_topic>` tag); for any other, ask the user to name it here.','- **Talking to another conversation:** `lh topic send <tpc_id> -c "…"` delivers a message to that conversation and has its agent act on it (queued behind its current turn if it is busy). To hand work to a fresh conversation instead, `lh topic send --new -c "…"` opens one for you (or `--agent-id` another agent), optionally on a given machine with `--device <id|local>` and named with `--title`; `lh message send -c "…"` is the same thing spelled message-first: without `--topic-id` it opens a new conversation, with `--topic-id <tpc_id>` it sends to that one. Prefer these over `lh agent run` for handing off work. `lh message create` only writes a row — nobody sees or answers it. A message another agent sent you starts with an `<agent_sender>` header; answer it with `lh message reply <message_id> -c "…"`, which wakes the sender\'s conversation. Your ordinary response is not delivered to that agent.',- '- **If `lh` is older than this app**, the shell may have found a stale global install first: `lh man` lacks a command you expect, or `lh` reports an unknown command. When `LOBEHUB_CLI` is set it is the path of the CLI this app ships — run that path instead of `lh` for the rest of the session.',+ '- **If `lh` is too old** — `lh man` lacks a command you expect, or `lh` reports an unknown command or option — the shell may have found a stale global install first. When `LOBEHUB_CLI` is set it is the path of the CLI this app ships — run that path instead of `lh` for the rest of the session. Otherwise, or if that one is too old as well, run the latest CLI once without installing it: `pnpm --package @lobehub/cli@latest dlx lh …` (or `npx -y -p @lobehub/cli@latest lh …`). It reads the same environment and saved login as `lh`. If the user asks you to run `lh` this way, do so.','- **Look commands up, do not guess them.** `lh man` lists every command, and `lh man <command>` (e.g. `lh man doc create`) prints the manual for the CLI actually installed here, including exactly which flags that command takes. Many commands offer `--json` for structured output, but not all of them — the manual is what says so, and an invented flag just fails the call.','- **What it reaches:** `lh kb` knowledge bases · `lh doc` documents · `lh file` files · `lh artifact` artifacts · `lh topic` / `lh message` past conversations · `lh agent` agents · `lh task` / `lh project` work · `lh widget` / `lh dashboard` monitoring widgets and dashboards · `lh search` local resources and the web · `lh recall` past messages, topics, goals and pages in a time window · `lh gen` text/image/video/TTS/ASR generation · `lh memory` user memory · `lh notify` notifications to the user · `lh model` / `lh provider` / `lh plugin` / `lh skill` platform configuration · `lh bot` chat-platform bots.',"- **Widgets run code with the user's credentials.** Before `lh widget dry-run` of a draft that declares connector credentials (`manifest.env`) or network hosts (`manifest.network.allow`), show the user that version id, what the script does and which credentials and hosts it uses, and wait for their explicit approval of that exact version before passing `--version <id> --yes`. Never publish (`lh widget publish`) without the user's confirmation.",