@lobehub/cli 0.0.166 → 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 +88 -10
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -591292,6 +591292,38 @@ function registerTopicCommands(task) {
|
|
|
591292
591292
|
});
|
|
591293
591293
|
}
|
|
591294
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
|
+
|
|
591295
591327
|
//#endregion
|
|
591296
591328
|
//#region src/commands/task/index.ts
|
|
591297
591329
|
init_src$2();
|
|
@@ -591619,10 +591651,12 @@ function registerTaskCommand(program) {
|
|
|
591619
591651
|
}
|
|
591620
591652
|
console.log();
|
|
591621
591653
|
});
|
|
591622
|
-
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) => {
|
|
591623
591655
|
let origin;
|
|
591656
|
+
let visibility;
|
|
591624
591657
|
try {
|
|
591625
591658
|
origin = toCreateOrigin(options);
|
|
591659
|
+
visibility = parseVisibility(options.visibility);
|
|
591626
591660
|
} catch (error) {
|
|
591627
591661
|
log$15.error(error.message);
|
|
591628
591662
|
process.exitCode = 1;
|
|
@@ -591644,7 +591678,10 @@ function registerTaskCommand(program) {
|
|
|
591644
591678
|
const modelConfig = toCreateModelConfig(options);
|
|
591645
591679
|
if (modelConfig) input.config = modelConfig;
|
|
591646
591680
|
if (origin) input.context = { origin };
|
|
591647
|
-
|
|
591681
|
+
if (visibility) input.visibility = visibility;
|
|
591682
|
+
const result = await client.task.create.mutate(input).catch((error) => {
|
|
591683
|
+
throw withVisibilityHint(error, { command: "create" });
|
|
591684
|
+
});
|
|
591648
591685
|
const url = buildUrl(taskPath(result.data.identifier, result.data.name));
|
|
591649
591686
|
if (options.json !== void 0) {
|
|
591650
591687
|
outputJson({
|
|
@@ -591657,7 +591694,15 @@ function registerTaskCommand(program) {
|
|
|
591657
591694
|
console.log(`ID: ${result.data.id}`);
|
|
591658
591695
|
console.log(`${import_picocolors.default.bold("task")}: ${url}`);
|
|
591659
591696
|
});
|
|
591660
|
-
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
|
+
}
|
|
591661
591706
|
const client = await getTrpcClient();
|
|
591662
591707
|
const assigneeUserId = await resolveUserOption(client, options.user);
|
|
591663
591708
|
if (assigneeUserId === false) return;
|
|
@@ -591695,6 +591740,27 @@ function registerTaskCommand(program) {
|
|
|
591695
591740
|
process.exitCode = 1;
|
|
591696
591741
|
return;
|
|
591697
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);
|
|
591698
591764
|
const hasOtherEdits = hasFieldEdits || !!options.status;
|
|
591699
591765
|
const readLabels = async () => (await client.task.detail.query({ id })).data?.labels ?? [];
|
|
591700
591766
|
const previousLabels = hasLabelEdits && hasOtherEdits ? await readLabels() : void 0;
|
|
@@ -591718,8 +591784,9 @@ function registerTaskCommand(program) {
|
|
|
591718
591784
|
add: addLabelIds,
|
|
591719
591785
|
remove: removeLabelIds,
|
|
591720
591786
|
taskId: id
|
|
591721
|
-
});
|
|
591787
|
+
}).catch(afterPrivate);
|
|
591722
591788
|
if (hasLabelEdits && !hasOtherEdits) {
|
|
591789
|
+
await applyPublic();
|
|
591723
591790
|
if (options.json !== void 0) {
|
|
591724
591791
|
const { data } = await client.task.find.query({ id });
|
|
591725
591792
|
outputJson(withUrl({
|
|
@@ -591734,8 +591801,12 @@ function registerTaskCommand(program) {
|
|
|
591734
591801
|
const result = await client.task.updateStatus.mutate({
|
|
591735
591802
|
id,
|
|
591736
591803
|
status: options.status
|
|
591737
|
-
}).catch(restoreLabelsOnFailure);
|
|
591738
|
-
|
|
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);
|
|
591739
591810
|
else {
|
|
591740
591811
|
log$15.info(`${import_picocolors.default.bold(result.data.identifier)} → ${options.status}`);
|
|
591741
591812
|
console.log(`ID: ${result.data.id}`);
|
|
@@ -591744,12 +591815,19 @@ function registerTaskCommand(program) {
|
|
|
591744
591815
|
}
|
|
591745
591816
|
input.status = options.status;
|
|
591746
591817
|
}
|
|
591747
|
-
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();
|
|
591748
591825
|
if (options.json !== void 0) {
|
|
591749
|
-
outputJson(withUrl(
|
|
591826
|
+
outputJson(withUrl({
|
|
591750
591827
|
...result.data,
|
|
591751
|
-
|
|
591752
|
-
|
|
591828
|
+
...promoted,
|
|
591829
|
+
...labels ? { labels } : {}
|
|
591830
|
+
}, await resolveUrlBuilder(client), resourcePath.task(result.data)), typeof options.json === "string" ? options.json : void 0);
|
|
591753
591831
|
return;
|
|
591754
591832
|
}
|
|
591755
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.
|
|
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.
|
|
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": "
|
|
86
|
+
"gitHead": "0ec5b27c1f61aded53f3f67903c1f9fcb5e9b915"
|
|
87
87
|
}
|