@lichao0223/lobehub-cli 0.0.88 → 0.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -60746,7 +60746,7 @@ const lobeHubCliGuideBody = [
60746
60746
  "- **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.",
60747
60747
  "- **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.",
60748
60748
  "- **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.",
60749
- "- **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.",
60749
+ "- **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`; it is linked to this conversation as its parent (`--parent-topic-id <tpc_id>` names another, `--detach` links none), and `lh topic list --opened-by-me` lists the ones you opened; `lh topic stop <tpc_id>` stops a topic's running turn and `lh topic archive <tpc_id>` archives it; `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.",
60750
60750
  "- **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 @lichao0223/lobehub-cli@latest dlx lh …` (or `npx -y -p @lichao0223/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.",
60751
60751
  "- **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.",
60752
60752
  "- **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 legacy-plugin` / `lh skill` platform configuration · `lh bot` chat-platform bots.",
@@ -266786,12 +266786,12 @@ const summarizeListeners = (entries, options) => {
266786
266786
  };
266787
266787
  }).sort((a, b) => Number(b.inProject) - Number(a.inProject) || a.port - b.port).slice(0, MAX_PORTS);
266788
266788
  };
266789
- const run$1 = async (file, args) => (await execFileAsync$3(file, args, {
266789
+ const run$2 = async (file, args) => (await execFileAsync$3(file, args, {
266790
266790
  maxBuffer: 4 * 1024 * 1024,
266791
266791
  timeout: COMMAND_TIMEOUT_MS
266792
266792
  })).stdout;
266793
266793
  const collectDarwin = async () => {
266794
- const entries = parseLsofListen(await run$1("lsof", [
266794
+ const entries = parseLsofListen(await run$2("lsof", [
266795
266795
  "-nP",
266796
266796
  "-iTCP",
266797
266797
  "-sTCP:LISTEN",
@@ -266803,7 +266803,7 @@ const collectDarwin = async () => {
266803
266803
  }));
266804
266804
  const pids = [...new Set(entries.map((e) => e.pid).filter((p) => !!p))];
266805
266805
  return {
266806
- cwds: pids.length ? parseLsofCwd(await run$1("lsof", [
266806
+ cwds: pids.length ? parseLsofCwd(await run$2("lsof", [
266807
266807
  "-a",
266808
266808
  "-p",
266809
266809
  pids.join(","),
@@ -266852,17 +266852,17 @@ const collectLinux = async () => {
266852
266852
  };
266853
266853
  const collectWindows = async () => {
266854
266854
  const [v4, v6, tasks] = await Promise.all([
266855
- run$1("netstat", [
266855
+ run$2("netstat", [
266856
266856
  "-ano",
266857
266857
  "-p",
266858
266858
  "TCP"
266859
266859
  ]),
266860
- run$1("netstat", [
266860
+ run$2("netstat", [
266861
266861
  "-ano",
266862
266862
  "-p",
266863
266863
  "TCPv6"
266864
266864
  ]),
266865
- run$1("tasklist", [
266865
+ run$2("tasklist", [
266866
266866
  "/FO",
266867
266867
  "CSV",
266868
266868
  "/NH"
@@ -307094,7 +307094,7 @@ async function writeMaintenanceState(file, operation) {
307094
307094
  await writeFile(temporary, JSON.stringify(operation), { mode: 384 });
307095
307095
  await rename(temporary, file);
307096
307096
  }
307097
- async function run(command, args, timeout) {
307097
+ async function run$1(command, args, timeout) {
307098
307098
  await new Promise((resolve, reject) => {
307099
307099
  const child = spawn(command, args, {
307100
307100
  stdio: "inherit",
@@ -307115,7 +307115,7 @@ async function runMaintenanceWorker(config, ready) {
307115
307115
  await writeMaintenanceState(statePath, operation);
307116
307116
  };
307117
307117
  try {
307118
- if (config.install) await run(config.install.command, config.install.args, 18e4);
307118
+ if (config.install) await run$1(config.install.command, config.install.args, 18e4);
307119
307119
  const { stdout } = await promisify(execFile)(executable, [entry, "--version"], { timeout: 3e4 });
307120
307120
  if (stdout.trim() !== operation.targetVersion) throw new Error("Installed CLI version did not match the requested version. The existing connection was kept.");
307121
307121
  operation.stage = "restarting";
@@ -307133,7 +307133,7 @@ async function runMaintenanceWorker(config, ready) {
307133
307133
  await setTimeout$1(100);
307134
307134
  }
307135
307135
  if (!config.restartArgs) return;
307136
- await run(executable, [
307136
+ await run$1(executable, [
307137
307137
  entry,
307138
307138
  ...config.restartArgs,
307139
307139
  "--daemon"
@@ -584889,6 +584889,8 @@ const resolveTargetDevice = async (client, device) => {
584889
584889
  */
584890
584890
  const sendToNewConversation = async (client, params) => {
584891
584891
  const agentId = params.agentId ?? process.env.LOBEHUB_AGENT_ID;
584892
+ if (params.detach && params.parentTopicId) throw new Error("Pass either --parent-topic-id or --detach, not both.");
584893
+ const parentTopicId = params.detach ? void 0 : params.parentTopicId || process.env.LOBEHUB_TOPIC_ID || void 0;
584892
584894
  if (!agentId) throw new Error("No agent to start the new conversation with: pass --agent-id (LOBEHUB_AGENT_ID is not set).");
584893
584895
  const request = {
584894
584896
  agentId,
@@ -584901,6 +584903,7 @@ const sendToNewConversation = async (client, params) => {
584901
584903
  request.requireDevice = true;
584902
584904
  }
584903
584905
  if (params.title) request.title = params.title;
584906
+ if (parentTopicId) request.openedByTopicId = parentTopicId;
584904
584907
  const sourceOperationId = process.env.LOBEHUB_OPERATION_ID;
584905
584908
  if (sourceOperationId) request.sourceOperationId = sourceOperationId;
584906
584909
  const started = await client.aiAgent.execAgent.mutate(request);
@@ -584935,10 +584938,15 @@ const reportConversationSend = async (send, options) => {
584935
584938
  console.log(import_picocolors.default.dim("The answer arrives in that conversation. If it replies to you, the reply wakes this one."));
584936
584939
  };
584937
584940
  function registerTopicSendCommand(topic) {
584938
- topic.command("send [topicId]").description("Send a message to another conversation and have its agent act on it (queued if it is busy), or with --new hand it to a new conversation. Unlike 'lh message create', this wakes the agent").requiredOption("-c, --content <content>", "Message content").option("--new", "Open a new conversation for the message instead of sending to <topicId>").option("--agent-id <id>", `With --new: ${NEW_CONVERSATION_OPTIONS_HELP.agentId}`).option("--device <target>", `With --new: ${NEW_CONVERSATION_OPTIONS_HELP.device}`).option("--title <title>", `With --new: ${NEW_CONVERSATION_OPTIONS_HELP.title}`).option("--workspace <id|slug>", "The workspace the topic lives in (overrides LOBEHUB_WORKSPACE_ID and 'workspace use')").option("--json", "Output JSON").addHelpText("after", `
584941
+ topic.command("send [topicId]").description("Send a message to another conversation and have its agent act on it (queued if it is busy), or with --new hand it to a new conversation. Unlike 'lh message create', this wakes the agent").requiredOption("-c, --content <content>", "Message content").option("--new", "Open a new conversation for the message instead of sending to <topicId>").option("--agent-id <id>", `With --new: ${NEW_CONVERSATION_OPTIONS_HELP.agentId}`).option("--device <target>", `With --new: ${NEW_CONVERSATION_OPTIONS_HELP.device}`).option("--title <title>", `With --new: ${NEW_CONVERSATION_OPTIONS_HELP.title}`).option("--parent-topic-id <tpc_id>", "With --new: the parent topic the new one lists under (default: the conversation running this command, LOBEHUB_TOPIC_ID)").option("--detach", "With --new: link the new topic to no parent, even from inside a conversation").option("--workspace <id|slug>", "The workspace the topic lives in (overrides LOBEHUB_WORKSPACE_ID and 'workspace use')").option("--json", "Output JSON").addHelpText("after", `
584939
584942
  Examples:
584940
584943
  lh topic send tpc_xxx -c "Iterate the verifier with these notes"
584941
584944
  lh topic send --new -c "Draft the release notes" --device local --title "Release notes"
584945
+ lh topic send --new -c "Check the flaky test" --parent-topic-id tpc_xxx
584946
+
584947
+ Run from inside a conversation, --new opens a topic linked to it as its parent
584948
+ ('lh topic list --parent-topic-id <id>' lists them); --detach opens one that
584949
+ stands on its own.
584942
584950
 
584943
584951
  Run by an agent, the message is shown as written by that agent, and the
584944
584952
  receiving agent can answer it with 'lh message reply <messageId>', which wakes
@@ -584951,7 +584959,7 @@ after a few rounds, so a person can step in.`).action(async (topicId, options) =
584951
584959
  return sendToNewConversation(client, { ...options });
584952
584960
  }
584953
584961
  if (!topicId) throw new Error("Pass the <topicId> to send to, or --new to open a new conversation.");
584954
- if (options.agentId || options.device || options.title) throw new Error("--agent-id, --device and --title only apply with --new; an existing conversation keeps its own.");
584962
+ if (options.agentId || options.device || options.title || options.parentTopicId || options.detach) throw new Error("--agent-id, --device, --title, --parent-topic-id and --detach only apply with --new; an existing conversation keeps its own.");
584955
584963
  return sendToConversation(client, {
584956
584964
  content: options.content,
584957
584965
  topicId
@@ -590171,6 +590179,52 @@ function registerTopicExportCommand(topic) {
590171
590179
  });
590172
590180
  }
590173
590181
 
590182
+ //#endregion
590183
+ //#region src/commands/topic/lifecycle.ts
590184
+ /** Print a refusal and exit 1 instead of a stack trace. */
590185
+ const run = async (fn) => {
590186
+ try {
590187
+ await fn();
590188
+ } catch (error) {
590189
+ log$15.error(error.message);
590190
+ process.exit(1);
590191
+ }
590192
+ };
590193
+ const WORKSPACE_OPTION_HELP = "Workspace (overrides LOBEHUB_WORKSPACE_ID and 'workspace use')";
590194
+ /**
590195
+ * A topic's lifecycle from the CLI: stop its running turn, archive it, or bring
590196
+ * it back — through the same entries the app's own buttons use
590197
+ * (`aiAgent.interruptTask`, `topic.updateTopic`).
590198
+ */
590199
+ function registerTopicLifecycleCommands(topic) {
590200
+ topic.command("stop <topicId>").description("Stop the topic's running turn (the ones you started)").option("--workspace <id|slug>", WORKSPACE_OPTION_HELP).option("--json", "Output JSON").action((topicId, options) => run(async () => {
590201
+ const result = await (await getTrpcClient(await resolveWorkspaceRef(options.workspace))).aiAgent.interruptTask.mutate({ topicId });
590202
+ if (options.json) return outputJson(result);
590203
+ if (!result.success) throw new Error(`${topicId}: ${(result.running ?? 0) - (result.stopped ?? 0)} run(s) could not be confirmed stopped (a device may still be running them). Try again once the device is reachable.`);
590204
+ console.log(result.stopped ? `${import_picocolors.default.green("✓")} Stopped ${topicId}.` : `${topicId} was not running.`);
590205
+ }));
590206
+ topic.command("archive <topicId>").description("Archive a topic: it leaves the agent list, and its auto-created worktree is cleaned up").option("--workspace <id|slug>", WORKSPACE_OPTION_HELP).action((topicId, options) => run(async () => {
590207
+ await (await getTrpcClient(await resolveWorkspaceRef(options.workspace))).topic.updateTopic.mutate({
590208
+ id: topicId,
590209
+ value: {
590210
+ completedAt: /* @__PURE__ */ new Date(),
590211
+ status: "completed"
590212
+ }
590213
+ });
590214
+ console.log(`${import_picocolors.default.green("✓")} Archived ${topicId}.`);
590215
+ }));
590216
+ topic.command("unarchive <topicId>").description("Bring an archived topic back to the agent list").option("--workspace <id|slug>", WORKSPACE_OPTION_HELP).action((topicId, options) => run(async () => {
590217
+ await (await getTrpcClient(await resolveWorkspaceRef(options.workspace))).topic.updateTopic.mutate({
590218
+ id: topicId,
590219
+ value: {
590220
+ completedAt: null,
590221
+ status: "active"
590222
+ }
590223
+ });
590224
+ console.log(`${import_picocolors.default.green("✓")} Unarchived ${topicId}.`);
590225
+ }));
590226
+ }
590227
+
590174
590228
  //#endregion
590175
590229
  //#region src/commands/topic/readTranscript.ts
590176
590230
  /** A server that predates the operation route answers this for the unknown path. */
@@ -590380,10 +590434,17 @@ function registerTopicViewCommand(topic) {
590380
590434
  //#region src/commands/topic.ts
590381
590435
  function registerTopicCommand(program) {
590382
590436
  const topic = program.command("topic").description("Manage conversation topics");
590383
- topic.command("list").description("List topics").option("--agent-id <id>", "Filter by agent ID").option("-L, --limit <n>", "Page size", "30").option("-P, --page <n>", "Page number", "1").option("--json [fields]", "Output JSON, optionally specify fields (comma-separated)").action(async (options) => {
590437
+ topic.command("list").description("List topics").option("--agent-id <id>", "Filter by agent ID").option("--parent-topic-id <tpc_id>", "Only the topics opened from this one (its child topics), whatever their agent").option("--opened-by-me", "Only the topics this conversation opened (--parent-topic-id from LOBEHUB_TOPIC_ID)").option("-L, --limit <n>", "Page size", "30").option("-P, --page <n>", "Page number", "1").option("--json [fields]", "Output JSON, optionally specify fields (comma-separated)").action(async (options) => {
590438
+ const parentTopicId = options.parentTopicId ?? (options.openedByMe ? process.env.LOBEHUB_TOPIC_ID : void 0);
590439
+ if (options.openedByMe && !parentTopicId) {
590440
+ log$15.error("--opened-by-me needs LOBEHUB_TOPIC_ID; pass --parent-topic-id instead.");
590441
+ process.exit(1);
590442
+ return;
590443
+ }
590384
590444
  const client = await getTrpcClient();
590385
590445
  const input = {};
590386
590446
  if (options.agentId) input.agentId = options.agentId;
590447
+ if (parentTopicId) input.openedByTopicId = parentTopicId;
590387
590448
  if (options.limit) input.pageSize = Number.parseInt(options.limit, 10);
590388
590449
  const page = options.page ? Number.parseInt(options.page, 10) : void 0;
590389
590450
  if (page !== void 0 && page > 1) input.current = page - 1;
@@ -590401,6 +590462,20 @@ function registerTopicCommand(program) {
590401
590462
  console.log("No topics found.");
590402
590463
  return;
590403
590464
  }
590465
+ if (parentTopicId) {
590466
+ printTable(items.map((t) => [
590467
+ t.id || "",
590468
+ truncate$2(t.title || "Untitled", 50),
590469
+ t.agentId || "",
590470
+ t.updatedAt ? timeAgo(t.updatedAt) : ""
590471
+ ]), [
590472
+ "ID",
590473
+ "TITLE",
590474
+ "AGENT",
590475
+ "UPDATED"
590476
+ ]);
590477
+ return;
590478
+ }
590404
590479
  printTable(items.map((t) => [
590405
590480
  t.id || "",
590406
590481
  truncate$2(t.title || "Untitled", 50),
@@ -590568,6 +590643,7 @@ function registerTopicCommand(program) {
590568
590643
  registerTopicExportCommand(topic);
590569
590644
  registerTopicViewCommand(topic);
590570
590645
  registerTopicSendCommand(topic);
590646
+ registerTopicLifecycleCommands(topic);
590571
590647
  }
590572
590648
 
590573
590649
  //#endregion
package/man/man1/lh.1 CHANGED
@@ -1,6 +1,6 @@
1
1
  .\" Code generated by `npm run man:generate`; DO NOT EDIT.
2
2
  .\" Manual command details come from the Commander command tree.
3
- .TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.88" "User Commands"
3
+ .TH LH 1 "" "@lichao0223/lobehub\-cli 0.0.89" "User Commands"
4
4
  .SH NAME
5
5
  lh \- LobeHub CLI \- manage and connect to LobeHub services
6
6
  .SH SYNOPSIS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lichao0223/lobehub-cli",
3
- "version": "0.0.88",
3
+ "version": "0.0.89",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/lichao0223/lobehub",
@@ -83,5 +83,5 @@
83
83
  "access": "public",
84
84
  "registry": "https://registry.npmjs.org"
85
85
  },
86
- "gitHead": "9fb4a1aa24af6d0830300646ed381b7b1cbf814f"
86
+ "gitHead": "bf1ec8368ec4b47d1908117ba723fc7f28cbc662"
87
87
  }