@lobehub/cli 0.0.165 → 0.0.167

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
@@ -65168,7 +65168,7 @@ var AcpStdioClient = class {
65168
65168
  async start() {
65169
65169
  if (this.child) return;
65170
65170
  if (this.closed) throw new Error("ACP stdio client is closed");
65171
- const spawnPlan = await resolveCliSpawnPlan(this.options.commandPath, this.options.args);
65171
+ const spawnPlan = await resolveCliSpawnPlan(this.options.commandPath, this.options.args, this.options.env);
65172
65172
  if (this.closed) throw new Error("ACP stdio client is closed");
65173
65173
  const detached = process.platform !== "win32" && (this.options.detached ?? true);
65174
65174
  const child = spawnManaged(spawnPlan.command, spawnPlan.args, {
@@ -74762,6 +74762,22 @@ const detectDshCommand = async (command = "dsh", env) => {
74762
74762
  error: `DeepSeek Harness CLI ${status.version} is too old; LobeHub needs ${DSH_MIN_VERSION} or newer. Update it with: npm i -g @deepseek-ai/dsh`
74763
74763
  };
74764
74764
  };
74765
+ /**
74766
+ * The `dsh` binary a session should spawn, with the PATH that validated it.
74767
+ * A custom command is used verbatim; the default one is re-detected so a CLI
74768
+ * installed after the host started (a fresh registry PATH on Windows, a new
74769
+ * login-shell PATH elsewhere) still launches instead of failing with ENOENT.
74770
+ */
74771
+ const resolveDshSpawnCommand = async (command, env) => {
74772
+ const requested = command?.trim();
74773
+ if (requested && requested !== "dsh") return { command: requested };
74774
+ const detected = await detectDshCommand("dsh", env).catch(() => void 0);
74775
+ return detected?.available && detected.path ? {
74776
+ command: detected.path,
74777
+ pathEnv: detected.resolvedPathEnv,
74778
+ version: detected.version
74779
+ } : { command: "dsh" };
74780
+ };
74765
74781
  /** Select the CLI's shipped ACP profile, served on stdio until disconnect. */
74766
74782
  const DSH_ACP_PROFILE_ARGS = ["--profile", "acp"];
74767
74783
  /** The profile boots its plugin tree before answering `initialize`. */
@@ -76155,7 +76171,7 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
76155
76171
  home: childEnv.HOME,
76156
76172
  sessionId: options.resumeSessionId
76157
76173
  }) : void 0;
76158
- const cliSpawnPlan = await resolveCliSpawnPlan(command, args);
76174
+ const cliSpawnPlan = await resolveCliSpawnPlan(command, args, childEnv);
76159
76175
  const detached = platform() !== "win32" && (options.detached ?? true);
76160
76176
  const startedAt = Date.now();
76161
76177
  const proc = spawnManaged(cliSpawnPlan.command, cliSpawnPlan.args, {
@@ -306298,7 +306314,7 @@ const listHeterogeneousAgentModels = async (params) => {
306298
306314
  "list",
306299
306315
  "--json"
306300
306316
  ] : params.type === "pi" ? buildPiCatalogArgs(params.args) : ["--list-models"];
306301
- const spawnPlan = await resolveCliSpawnPlan(resolved.command, args);
306317
+ const spawnPlan = await resolveCliSpawnPlan(resolved.command, args, env);
306302
306318
  const { stderr, stdout } = await execFilePromise(spawnPlan.command, spawnPlan.args, {
306303
306319
  cwd,
306304
306320
  encoding: "utf8",
@@ -583278,7 +583294,7 @@ var RpcStdioClient = class {
583278
583294
  */
583279
583295
  async start() {
583280
583296
  if (this.child || this.closed) return;
583281
- const spawnPlan = await resolveCliSpawnPlan(this.options.commandPath, this.options.args);
583297
+ const spawnPlan = await resolveCliSpawnPlan(this.options.commandPath, this.options.args, this.options.env);
583282
583298
  if (this.closed) return;
583283
583299
  const child = spawnManaged(spawnPlan.command, spawnPlan.args, {
583284
583300
  cwd: this.options.cwd,
@@ -585346,13 +585362,15 @@ const exec = async (options) => {
585346
585362
  session?.dispose().catch(() => {});
585347
585363
  };
585348
585364
  try {
585365
+ const dshCommand = await resolveDshSpawnCommand(options.command);
585349
585366
  session = spawnDshAcpSession({
585350
585367
  args: options.agentArg,
585351
585368
  clientVersion: "lobehub-cli",
585352
- command: options.command,
585369
+ command: dshCommand.command,
585353
585370
  cwd: options.cwd || process.cwd(),
585354
585371
  env: buildAgentProcessEnv({
585355
585372
  operationId: serverIngest ? operationId : void 0,
585373
+ pathEnv: dshCommand.pathEnv,
585356
585374
  topicId: options.topic
585357
585375
  }),
585358
585376
  model: options.model,
@@ -591274,6 +591292,38 @@ function registerTopicCommands(task) {
591274
591292
  });
591275
591293
  }
591276
591294
 
591295
+ //#endregion
591296
+ //#region src/commands/task/visibility.ts
591297
+ const TASK_VISIBILITIES = ["private", "public"];
591298
+ const VISIBILITY_OPTION_DESCRIPTION = "Task visibility: private (only you) or public (the whole workspace)";
591299
+ /** Validate `--visibility`; throws a message listing the accepted values. */
591300
+ const parseVisibility = (value) => {
591301
+ if (value === void 0) return void 0;
591302
+ const normalized = value.trim().toLowerCase();
591303
+ if (TASK_VISIBILITIES.includes(normalized)) return normalized;
591304
+ throw new Error(`Invalid visibility "${value}". Must be one of: ${TASK_VISIBILITIES.join(", ")}`);
591305
+ };
591306
+ const PRIVATE_AGENT_ON_PUBLIC_TASK = /public task cannot be assigned to a private agent/i;
591307
+ /**
591308
+ * Append how to fix a failed create / edit when the server's message has a
591309
+ * CLI-side remedy. The server message itself is kept verbatim; other errors
591310
+ * pass through unchanged so the global handler still recognizes them.
591311
+ */
591312
+ const withVisibilityHint = (error, context) => {
591313
+ const message = formatError(error);
591314
+ if (!PRIVATE_AGENT_ON_PUBLIC_TASK.test(message)) return error;
591315
+ const hint = context.command === "create" ? "Create it with `--visibility private` instead." : `Add \`--visibility private\` to this command, or run \`lh task edit ${context.id} --visibility private\` first (only the task creator can make it private).`;
591316
+ return /* @__PURE__ */ new Error(`${message}\nHint: ${hint}`);
591317
+ };
591318
+ /**
591319
+ * Prefix a failed `updateVisibility` call with what was being attempted; the
591320
+ * server's reason (e.g. only the creator can make a task private) stays
591321
+ * verbatim. `appliedOtherEdits` notes that the rest of the edit already landed.
591322
+ */
591323
+ const describeVisibilityError = (error, id, visibility, appliedOtherEdits = false) => {
591324
+ return /* @__PURE__ */ new Error(`Could not make ${id} ${visibility}${appliedOtherEdits ? " (the other changes in this command were applied)" : ""}: ${formatError(error)}`);
591325
+ };
591326
+
591277
591327
  //#endregion
591278
591328
  //#region src/commands/task/index.ts
591279
591329
  init_src$2();
@@ -591601,10 +591651,12 @@ function registerTaskCommand(program) {
591601
591651
  }
591602
591652
  console.log();
591603
591653
  });
591604
- task.command("create").description("Create a new task").requiredOption("-i, --instruction <text>", "Task instruction").option("-n, --name <name>", "Task name").option("--agent <id>", "Assign to agent").option("--user <idOrEmail>", "Assign to a workspace member (user id, email or username)").option("--parent <id>", "Parent task ID").option("--priority <n>", "Priority (0=none, 1=urgent, 2=high, 3=normal, 4=low)", "0").option("--label <name>", "Attach an existing label (repeatable or comma-separated; \"Group/Label\" also works)", collectLabels).option("--model <model>", "Model to run with (default: the assignee agent's model)").option("--provider <provider>", "Provider for --model (default: resolved from the agent)").option("--origin-agent <id>", "Agent to notify when the task finishes (requires --origin-topic)").option("--origin-topic <id>", "Your conversation (topic) that receives the result card (requires --origin-agent)").option("--origin-message <id>", "Message in the origin topic the task was created from").option("--origin-operation <id>", "Operation that created the task").option("--origin-tool-call <id>", "Tool call that created the task").option("--json [fields]", "Output JSON").action(async (options) => {
591654
+ task.command("create").description("Create a new task").requiredOption("-i, --instruction <text>", "Task instruction").option("-n, --name <name>", "Task name").option("--agent <id>", "Assign to agent").option("--user <idOrEmail>", "Assign to a workspace member (user id, email or username)").option("--parent <id>", "Parent task ID").option("--priority <n>", "Priority (0=none, 1=urgent, 2=high, 3=normal, 4=low)", "0").option("--visibility <visibility>", `${VISIBILITY_OPTION_DESCRIPTION}. Default: inherited from --parent, private for a private --agent, otherwise public`).option("--label <name>", "Attach an existing label (repeatable or comma-separated; \"Group/Label\" also works)", collectLabels).option("--model <model>", "Model to run with (default: the assignee agent's model)").option("--provider <provider>", "Provider for --model (default: resolved from the agent)").option("--origin-agent <id>", "Agent to notify when the task finishes (requires --origin-topic)").option("--origin-topic <id>", "Your conversation (topic) that receives the result card (requires --origin-agent)").option("--origin-message <id>", "Message in the origin topic the task was created from").option("--origin-operation <id>", "Operation that created the task").option("--origin-tool-call <id>", "Tool call that created the task").option("--json [fields]", "Output JSON").action(async (options) => {
591605
591655
  let origin;
591656
+ let visibility;
591606
591657
  try {
591607
591658
  origin = toCreateOrigin(options);
591659
+ visibility = parseVisibility(options.visibility);
591608
591660
  } catch (error) {
591609
591661
  log$15.error(error.message);
591610
591662
  process.exitCode = 1;
@@ -591626,7 +591678,10 @@ function registerTaskCommand(program) {
591626
591678
  const modelConfig = toCreateModelConfig(options);
591627
591679
  if (modelConfig) input.config = modelConfig;
591628
591680
  if (origin) input.context = { origin };
591629
- const result = await client.task.create.mutate(input);
591681
+ if (visibility) input.visibility = visibility;
591682
+ const result = await client.task.create.mutate(input).catch((error) => {
591683
+ throw withVisibilityHint(error, { command: "create" });
591684
+ });
591630
591685
  const url = buildUrl(taskPath(result.data.identifier, result.data.name));
591631
591686
  if (options.json !== void 0) {
591632
591687
  outputJson({
@@ -591639,7 +591694,15 @@ function registerTaskCommand(program) {
591639
591694
  console.log(`ID: ${result.data.id}`);
591640
591695
  console.log(`${import_picocolors.default.bold("task")}: ${url}`);
591641
591696
  });
591642
- task.command("edit <id>").description("Update a task").option("-n, --name <name>", "Task name").option("-i, --instruction <text>", "Task instruction").option("--agent <id>", "Assign to agent").option("--user <idOrEmail>", "Assign to a workspace member (user id, email or username)").option("--priority <n>", "Priority (0-4)").option("--project <id>", "Move to a project (\"null\" to remove it from its project)").option("--label <name>", "Add a label (repeatable or comma-separated; replaces the task's other label of the same group)", collectLabels).option("--remove-label <name>", "Remove a label (repeatable or comma-separated)", collectLabels).option("--heartbeat-interval <n>", "Heartbeat interval in seconds").option("--heartbeat-timeout <n>", "Heartbeat timeout in seconds (0 to disable)").option("--description <text>", "Task description").option("--model <model>", "Model to run with (\"null\" to follow the assignee agent again)").option("--provider <provider>", "Provider for the model (default: resolved from the agent)").option("--status <status>", "Set status (backlog, running, paused, completed, failed, canceled)").option("--json [fields]", "Output JSON").action(async (id, options) => {
591697
+ task.command("edit <id>").description("Update a task").option("-n, --name <name>", "Task name").option("-i, --instruction <text>", "Task instruction").option("--agent <id>", "Assign to agent").option("--user <idOrEmail>", "Assign to a workspace member (user id, email or username)").option("--priority <n>", "Priority (0-4)").option("--visibility <visibility>", `${VISIBILITY_OPTION_DESCRIPTION}. Only the task creator can make a task private`).option("--project <id>", "Move to a project (\"null\" to remove it from its project)").option("--label <name>", "Add a label (repeatable or comma-separated; replaces the task's other label of the same group)", collectLabels).option("--remove-label <name>", "Remove a label (repeatable or comma-separated)", collectLabels).option("--heartbeat-interval <n>", "Heartbeat interval in seconds").option("--heartbeat-timeout <n>", "Heartbeat timeout in seconds (0 to disable)").option("--description <text>", "Task description").option("--model <model>", "Model to run with (\"null\" to follow the assignee agent again)").option("--provider <provider>", "Provider for the model (default: resolved from the agent)").option("--status <status>", "Set status (backlog, running, paused, completed, failed, canceled)").option("--json [fields]", "Output JSON").action(async (id, options) => {
591698
+ let visibility;
591699
+ try {
591700
+ visibility = parseVisibility(options.visibility);
591701
+ } catch (error) {
591702
+ log$15.error(error.message);
591703
+ process.exitCode = 1;
591704
+ return;
591705
+ }
591643
591706
  const client = await getTrpcClient();
591644
591707
  const assigneeUserId = await resolveUserOption(client, options.user);
591645
591708
  if (assigneeUserId === false) return;
@@ -591677,6 +591740,27 @@ function registerTaskCommand(program) {
591677
591740
  process.exitCode = 1;
591678
591741
  return;
591679
591742
  }
591743
+ const changeVisibility = (target, appliedOtherEdits) => client.task.updateVisibility.mutate({
591744
+ id,
591745
+ visibility: target
591746
+ }).catch((error) => {
591747
+ throw describeVisibilityError(error, id, target, appliedOtherEdits);
591748
+ });
591749
+ const applyPublic = async () => visibility === "public" ? (await changeVisibility("public", true)).data : {};
591750
+ const afterPrivate = (error) => {
591751
+ if (visibility !== "private") throw error;
591752
+ throw new Error(`${formatError(error)} (${id} was already made private)`);
591753
+ };
591754
+ if (visibility && !(hasLabelEdits || hasFieldEdits || options.status)) {
591755
+ const result = await changeVisibility(visibility, false);
591756
+ if (options.json !== void 0) outputJson(withUrl(result.data, await resolveUrlBuilder(client), resourcePath.task(result.data)), typeof options.json === "string" ? options.json : void 0);
591757
+ else {
591758
+ log$15.info(`${import_picocolors.default.bold(result.data.identifier)} is now ${visibility}`);
591759
+ console.log(`ID: ${result.data.id}`);
591760
+ }
591761
+ return;
591762
+ }
591763
+ if (visibility === "private") await changeVisibility("private", false);
591680
591764
  const hasOtherEdits = hasFieldEdits || !!options.status;
591681
591765
  const readLabels = async () => (await client.task.detail.query({ id })).data?.labels ?? [];
591682
591766
  const previousLabels = hasLabelEdits && hasOtherEdits ? await readLabels() : void 0;
@@ -591700,8 +591784,9 @@ function registerTaskCommand(program) {
591700
591784
  add: addLabelIds,
591701
591785
  remove: removeLabelIds,
591702
591786
  taskId: id
591703
- });
591787
+ }).catch(afterPrivate);
591704
591788
  if (hasLabelEdits && !hasOtherEdits) {
591789
+ await applyPublic();
591705
591790
  if (options.json !== void 0) {
591706
591791
  const { data } = await client.task.find.query({ id });
591707
591792
  outputJson(withUrl({
@@ -591716,8 +591801,12 @@ function registerTaskCommand(program) {
591716
591801
  const result = await client.task.updateStatus.mutate({
591717
591802
  id,
591718
591803
  status: options.status
591719
- }).catch(restoreLabelsOnFailure);
591720
- if (options.json !== void 0) outputJson(withUrl(result.data, await resolveUrlBuilder(client), resourcePath.task(result.data)), typeof options.json === "string" ? options.json : void 0);
591804
+ }).catch(restoreLabelsOnFailure).catch(afterPrivate);
591805
+ const promoted = await applyPublic();
591806
+ if (options.json !== void 0) outputJson(withUrl({
591807
+ ...result.data,
591808
+ ...promoted
591809
+ }, await resolveUrlBuilder(client), resourcePath.task(result.data)), typeof options.json === "string" ? options.json : void 0);
591721
591810
  else {
591722
591811
  log$15.info(`${import_picocolors.default.bold(result.data.identifier)} → ${options.status}`);
591723
591812
  console.log(`ID: ${result.data.id}`);
@@ -591726,12 +591815,19 @@ function registerTaskCommand(program) {
591726
591815
  }
591727
591816
  input.status = options.status;
591728
591817
  }
591729
- const result = await client.task.update.mutate(input).catch(restoreLabelsOnFailure);
591818
+ const result = await client.task.update.mutate(input).catch(restoreLabelsOnFailure).catch((error) => {
591819
+ throw withVisibilityHint(error, {
591820
+ command: "edit",
591821
+ id
591822
+ });
591823
+ }).catch(afterPrivate);
591824
+ const promoted = await applyPublic();
591730
591825
  if (options.json !== void 0) {
591731
- outputJson(withUrl(labels ? {
591826
+ outputJson(withUrl({
591732
591827
  ...result.data,
591733
- labels
591734
- } : result.data, await resolveUrlBuilder(client), resourcePath.task(result.data)), typeof options.json === "string" ? options.json : void 0);
591828
+ ...promoted,
591829
+ ...labels ? { labels } : {}
591830
+ }, await resolveUrlBuilder(client), resourcePath.task(result.data)), typeof options.json === "string" ? options.json : void 0);
591735
591831
  return;
591736
591832
  }
591737
591833
  const statusSuffix = options.status ? ` → ${options.status}` : "";
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.165" "User Commands"
3
+ .TH LH 1 "" "@lobehub/cli 0.0.167" "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.165",
3
+ "version": "0.0.167",
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": "30986136de82c0aaf366679084054b3cb66008fe"
86
+ "gitHead": "0ec5b27c1f61aded53f3f67903c1f9fcb5e9b915"
87
87
  }