@lobehub/cli 0.0.130 → 0.0.132

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
@@ -60741,7 +60741,7 @@ const lobeHubCliGuideBody = [
60741
60741
  "- **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.",
60742
60742
  "- **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.",
60743
60743
  "- **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.",
60744
- "- **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.",
60744
+ "- **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.",
60745
60745
  "- **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.",
60746
60746
  "- **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.",
60747
60747
  "- **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.",
@@ -266781,12 +266781,12 @@ const summarizeListeners = (entries, options) => {
266781
266781
  };
266782
266782
  }).sort((a, b) => Number(b.inProject) - Number(a.inProject) || a.port - b.port).slice(0, MAX_PORTS);
266783
266783
  };
266784
- const run$1 = async (file, args) => (await execFileAsync$3(file, args, {
266784
+ const run$2 = async (file, args) => (await execFileAsync$3(file, args, {
266785
266785
  maxBuffer: 4 * 1024 * 1024,
266786
266786
  timeout: COMMAND_TIMEOUT_MS
266787
266787
  })).stdout;
266788
266788
  const collectDarwin = async () => {
266789
- const entries = parseLsofListen(await run$1("lsof", [
266789
+ const entries = parseLsofListen(await run$2("lsof", [
266790
266790
  "-nP",
266791
266791
  "-iTCP",
266792
266792
  "-sTCP:LISTEN",
@@ -266798,7 +266798,7 @@ const collectDarwin = async () => {
266798
266798
  }));
266799
266799
  const pids = [...new Set(entries.map((e) => e.pid).filter((p) => !!p))];
266800
266800
  return {
266801
- cwds: pids.length ? parseLsofCwd(await run$1("lsof", [
266801
+ cwds: pids.length ? parseLsofCwd(await run$2("lsof", [
266802
266802
  "-a",
266803
266803
  "-p",
266804
266804
  pids.join(","),
@@ -266847,17 +266847,17 @@ const collectLinux = async () => {
266847
266847
  };
266848
266848
  const collectWindows = async () => {
266849
266849
  const [v4, v6, tasks] = await Promise.all([
266850
- run$1("netstat", [
266850
+ run$2("netstat", [
266851
266851
  "-ano",
266852
266852
  "-p",
266853
266853
  "TCP"
266854
266854
  ]),
266855
- run$1("netstat", [
266855
+ run$2("netstat", [
266856
266856
  "-ano",
266857
266857
  "-p",
266858
266858
  "TCPv6"
266859
266859
  ]),
266860
- run$1("tasklist", [
266860
+ run$2("tasklist", [
266861
266861
  "/FO",
266862
266862
  "CSV",
266863
266863
  "/NH"
@@ -307089,7 +307089,7 @@ async function writeMaintenanceState(file, operation) {
307089
307089
  await writeFile(temporary, JSON.stringify(operation), { mode: 384 });
307090
307090
  await rename(temporary, file);
307091
307091
  }
307092
- async function run(command, args, timeout) {
307092
+ async function run$1(command, args, timeout) {
307093
307093
  await new Promise((resolve, reject) => {
307094
307094
  const child = spawn(command, args, {
307095
307095
  stdio: "inherit",
@@ -307110,7 +307110,7 @@ async function runMaintenanceWorker(config, ready) {
307110
307110
  await writeMaintenanceState(statePath, operation);
307111
307111
  };
307112
307112
  try {
307113
- if (config.install) await run(config.install.command, config.install.args, 18e4);
307113
+ if (config.install) await run$1(config.install.command, config.install.args, 18e4);
307114
307114
  const { stdout } = await promisify(execFile)(executable, [entry, "--version"], { timeout: 3e4 });
307115
307115
  if (stdout.trim() !== operation.targetVersion) throw new Error("Installed CLI version did not match the requested version. The existing connection was kept.");
307116
307116
  operation.stage = "restarting";
@@ -307128,7 +307128,7 @@ async function runMaintenanceWorker(config, ready) {
307128
307128
  await setTimeout$1(100);
307129
307129
  }
307130
307130
  if (!config.restartArgs) return;
307131
- await run(executable, [
307131
+ await run$1(executable, [
307132
307132
  entry,
307133
307133
  ...config.restartArgs,
307134
307134
  "--daemon"
@@ -584876,6 +584876,8 @@ const resolveTargetDevice = async (client, device) => {
584876
584876
  */
584877
584877
  const sendToNewConversation = async (client, params) => {
584878
584878
  const agentId = params.agentId ?? process.env.LOBEHUB_AGENT_ID;
584879
+ if (params.detach && params.parentTopicId) throw new Error("Pass either --parent-topic-id or --detach, not both.");
584880
+ const parentTopicId = params.detach ? void 0 : params.parentTopicId || process.env.LOBEHUB_TOPIC_ID || void 0;
584879
584881
  if (!agentId) throw new Error("No agent to start the new conversation with: pass --agent-id (LOBEHUB_AGENT_ID is not set).");
584880
584882
  const request = {
584881
584883
  agentId,
@@ -584888,6 +584890,7 @@ const sendToNewConversation = async (client, params) => {
584888
584890
  request.requireDevice = true;
584889
584891
  }
584890
584892
  if (params.title) request.title = params.title;
584893
+ if (parentTopicId) request.openedByTopicId = parentTopicId;
584891
584894
  const sourceOperationId = process.env.LOBEHUB_OPERATION_ID;
584892
584895
  if (sourceOperationId) request.sourceOperationId = sourceOperationId;
584893
584896
  const started = await client.aiAgent.execAgent.mutate(request);
@@ -584922,10 +584925,15 @@ const reportConversationSend = async (send, options) => {
584922
584925
  console.log(import_picocolors.default.dim("The answer arrives in that conversation. If it replies to you, the reply wakes this one."));
584923
584926
  };
584924
584927
  function registerTopicSendCommand(topic) {
584925
- 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", `
584928
+ 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", `
584926
584929
  Examples:
584927
584930
  lh topic send tpc_xxx -c "Iterate the verifier with these notes"
584928
584931
  lh topic send --new -c "Draft the release notes" --device local --title "Release notes"
584932
+ lh topic send --new -c "Check the flaky test" --parent-topic-id tpc_xxx
584933
+
584934
+ Run from inside a conversation, --new opens a topic linked to it as its parent
584935
+ ('lh topic list --parent-topic-id <id>' lists them); --detach opens one that
584936
+ stands on its own.
584929
584937
 
584930
584938
  Run by an agent, the message is shown as written by that agent, and the
584931
584939
  receiving agent can answer it with 'lh message reply <messageId>', which wakes
@@ -584938,7 +584946,7 @@ after a few rounds, so a person can step in.`).action(async (topicId, options) =
584938
584946
  return sendToNewConversation(client, { ...options });
584939
584947
  }
584940
584948
  if (!topicId) throw new Error("Pass the <topicId> to send to, or --new to open a new conversation.");
584941
- 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.");
584949
+ 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.");
584942
584950
  return sendToConversation(client, {
584943
584951
  content: options.content,
584944
584952
  topicId
@@ -590128,6 +590136,52 @@ function registerTopicExportCommand(topic) {
590128
590136
  });
590129
590137
  }
590130
590138
 
590139
+ //#endregion
590140
+ //#region src/commands/topic/lifecycle.ts
590141
+ /** Print a refusal and exit 1 instead of a stack trace. */
590142
+ const run = async (fn) => {
590143
+ try {
590144
+ await fn();
590145
+ } catch (error) {
590146
+ log$15.error(error.message);
590147
+ process.exit(1);
590148
+ }
590149
+ };
590150
+ const WORKSPACE_OPTION_HELP = "Workspace (overrides LOBEHUB_WORKSPACE_ID and 'workspace use')";
590151
+ /**
590152
+ * A topic's lifecycle from the CLI: stop its running turn, archive it, or bring
590153
+ * it back — through the same entries the app's own buttons use
590154
+ * (`aiAgent.interruptTask`, `topic.updateTopic`).
590155
+ */
590156
+ function registerTopicLifecycleCommands(topic) {
590157
+ 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 () => {
590158
+ const result = await (await getTrpcClient(await resolveWorkspaceRef(options.workspace))).aiAgent.interruptTask.mutate({ topicId });
590159
+ if (options.json) return outputJson(result);
590160
+ 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.`);
590161
+ console.log(result.stopped ? `${import_picocolors.default.green("✓")} Stopped ${topicId}.` : `${topicId} was not running.`);
590162
+ }));
590163
+ 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 () => {
590164
+ await (await getTrpcClient(await resolveWorkspaceRef(options.workspace))).topic.updateTopic.mutate({
590165
+ id: topicId,
590166
+ value: {
590167
+ completedAt: /* @__PURE__ */ new Date(),
590168
+ status: "completed"
590169
+ }
590170
+ });
590171
+ console.log(`${import_picocolors.default.green("✓")} Archived ${topicId}.`);
590172
+ }));
590173
+ 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 () => {
590174
+ await (await getTrpcClient(await resolveWorkspaceRef(options.workspace))).topic.updateTopic.mutate({
590175
+ id: topicId,
590176
+ value: {
590177
+ completedAt: null,
590178
+ status: "active"
590179
+ }
590180
+ });
590181
+ console.log(`${import_picocolors.default.green("✓")} Unarchived ${topicId}.`);
590182
+ }));
590183
+ }
590184
+
590131
590185
  //#endregion
590132
590186
  //#region src/commands/topic/readTranscript.ts
590133
590187
  /** A server that predates the operation route answers this for the unknown path. */
@@ -590337,10 +590391,17 @@ function registerTopicViewCommand(topic) {
590337
590391
  //#region src/commands/topic.ts
590338
590392
  function registerTopicCommand(program) {
590339
590393
  const topic = program.command("topic").description("Manage conversation topics");
590340
- 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) => {
590394
+ 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) => {
590395
+ const parentTopicId = options.parentTopicId ?? (options.openedByMe ? process.env.LOBEHUB_TOPIC_ID : void 0);
590396
+ if (options.openedByMe && !parentTopicId) {
590397
+ log$15.error("--opened-by-me needs LOBEHUB_TOPIC_ID; pass --parent-topic-id instead.");
590398
+ process.exit(1);
590399
+ return;
590400
+ }
590341
590401
  const client = await getTrpcClient();
590342
590402
  const input = {};
590343
590403
  if (options.agentId) input.agentId = options.agentId;
590404
+ if (parentTopicId) input.openedByTopicId = parentTopicId;
590344
590405
  if (options.limit) input.pageSize = Number.parseInt(options.limit, 10);
590345
590406
  const page = options.page ? Number.parseInt(options.page, 10) : void 0;
590346
590407
  if (page !== void 0 && page > 1) input.current = page - 1;
@@ -590358,6 +590419,20 @@ function registerTopicCommand(program) {
590358
590419
  console.log("No topics found.");
590359
590420
  return;
590360
590421
  }
590422
+ if (parentTopicId) {
590423
+ printTable(items.map((t) => [
590424
+ t.id || "",
590425
+ truncate$2(t.title || "Untitled", 50),
590426
+ t.agentId || "",
590427
+ t.updatedAt ? timeAgo(t.updatedAt) : ""
590428
+ ]), [
590429
+ "ID",
590430
+ "TITLE",
590431
+ "AGENT",
590432
+ "UPDATED"
590433
+ ]);
590434
+ return;
590435
+ }
590361
590436
  printTable(items.map((t) => [
590362
590437
  t.id || "",
590363
590438
  truncate$2(t.title || "Untitled", 50),
@@ -590525,6 +590600,7 @@ function registerTopicCommand(program) {
590525
590600
  registerTopicExportCommand(topic);
590526
590601
  registerTopicViewCommand(topic);
590527
590602
  registerTopicSendCommand(topic);
590603
+ registerTopicLifecycleCommands(topic);
590528
590604
  }
590529
590605
 
590530
590606
  //#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 "" "@lobehub/cli 0.0.130" "User Commands"
3
+ .TH LH 1 "" "@lobehub/cli 0.0.132" "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": "@lobehub/cli",
3
- "version": "0.0.130",
3
+ "version": "0.0.132",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/lobehub/lobehub",
@@ -83,5 +83,5 @@
83
83
  "access": "public",
84
84
  "registry": "https://registry.npmjs.org"
85
85
  },
86
- "gitHead": "e8ac56b1b30a1776c8454ee233d1158df5d0760d"
86
+ "gitHead": "08004870b02e7391882c57d57a0a3f7b55c015b3"
87
87
  }