@lobehub/cli 0.0.151 → 0.0.152

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
@@ -8887,6 +8887,22 @@ var init_params$1 = __esmMin((() => {
8887
8887
  });
8888
8888
  }));
8889
8889
 
8890
+ //#endregion
8891
+ //#region ../../packages/types/src/tool/builtinWork.ts
8892
+ var PluginApiWorkConfigSchema;
8893
+ var init_builtinWork = __esmMin((() => {
8894
+ init_zod$1();
8895
+ PluginApiWorkConfigSchema = object$1({
8896
+ action: _enum([
8897
+ "create",
8898
+ "update",
8899
+ "delete"
8900
+ ]),
8901
+ agentEditable: boolean().optional(),
8902
+ resourceType: _enum(["document", "task"])
8903
+ });
8904
+ }));
8905
+
8890
8906
  //#endregion
8891
8907
  //#region ../../packages/types/src/tool/intervention.ts
8892
8908
  var HumanInterventionPolicySchema, ArgumentMatcherSchema, HumanInterventionRuleSchema, HumanInterventionConfigSchema, HumanInterventionResponseSchema, UserInterventionConfigSchema, SecurityBlacklistRuleSchema, SecurityBlacklistConfigSchema, ShouldInterveneParamsSchema;
@@ -8952,11 +8968,13 @@ var init_builtinIntervention = __esmMin((() => {}));
8952
8968
 
8953
8969
  //#endregion
8954
8970
  //#region ../../packages/types/src/tool/builtin.ts
8955
- var MetaSchema, RenderDisplayControlSchema, DynamicInterventionConfigSchema, ExtendedHumanInterventionConfigSchema, PluginApiWorkConfigSchema, LobeChatPluginApiSchema, BuiltinToolManifestSchema, LobeBuiltinToolSchema;
8971
+ var MetaSchema, RenderDisplayControlSchema, DynamicInterventionConfigSchema, ExtendedHumanInterventionConfigSchema, LobeChatPluginApiSchema, BuiltinToolManifestSchema, LobeBuiltinToolSchema;
8956
8972
  var init_builtin = __esmMin((() => {
8957
8973
  init_zod$1();
8974
+ init_builtinWork();
8958
8975
  init_intervention();
8959
8976
  init_builtinIntervention();
8977
+ init_builtinWork();
8960
8978
  MetaSchema = object$1({
8961
8979
  avatar: string().optional(),
8962
8980
  description: string().optional(),
@@ -8975,14 +8993,6 @@ var init_builtin = __esmMin((() => {
8975
8993
  type: string()
8976
8994
  });
8977
8995
  ExtendedHumanInterventionConfigSchema = union([HumanInterventionConfigSchema, object$1({ dynamic: DynamicInterventionConfigSchema })]);
8978
- PluginApiWorkConfigSchema = object$1({
8979
- action: _enum([
8980
- "create",
8981
- "update",
8982
- "delete"
8983
- ]),
8984
- resourceType: _enum(["document", "task"])
8985
- });
8986
8996
  LobeChatPluginApiSchema = object$1({
8987
8997
  defaultTimeoutMs: number$1().int().positive().optional(),
8988
8998
  description: string(),
@@ -37830,6 +37840,7 @@ const uploadFileBuffer = async (client, { buffer, fileName, fileType }, options
37830
37840
  name: fileName,
37831
37841
  parentId: options.parentId,
37832
37842
  size: buffer.length,
37843
+ source: options.source,
37833
37844
  url: pathname
37834
37845
  });
37835
37846
  } catch (error) {
@@ -593187,8 +593198,89 @@ function registerWidgetCommand(program) {
593187
593198
 
593188
593199
  //#endregion
593189
593200
  //#region src/commands/work.ts
593201
+ const requireOperationId = (options) => {
593202
+ const operationId = options.operation ?? process.env.LOBEHUB_OPERATION_ID;
593203
+ if (!operationId) throw new Error("lh work registers Works of a running agent: pass --operation or run it inside an agent run (LOBEHUB_OPERATION_ID)");
593204
+ return operationId;
593205
+ };
593206
+ /**
593207
+ * Upload a produced file as the run's own output. The `tool-result` source
593208
+ * keeps it out of the resource library, and is the source an operation token
593209
+ * may write.
593210
+ */
593211
+ const uploadWorkFile = async (client, filePath) => {
593212
+ const absolutePath = path.resolve(filePath);
593213
+ return {
593214
+ absolutePath,
593215
+ fileId: (await uploadLocalFile(client, absolutePath, { source: "tool-result" })).id
593216
+ };
593217
+ };
593218
+ const printWork = (work, options, verb) => {
593219
+ if (options.json) outputJson(work);
593220
+ else console.log(`${verb} Work ${work.id}: ${work.title}`);
593221
+ };
593190
593222
  function registerWorkCommand(program) {
593191
- program.command("work").description("Look up agent work").command("lookup").argument("<github-pr-url>", "GitHub pull request URL").description("Find all conversations linked to a GitHub pull request in the current workspace").option("--json", "Output JSON").action(async (url, options) => {
593223
+ const work = program.command("work").description("Register the files and links this agent produced as Works, or look them up");
593224
+ work.command("create").description([
593225
+ "Register a file or link this agent produced as a Work card under its reply.",
593226
+ "Pass exactly one of --file or --url. Creating the same file path or link again in",
593227
+ "this conversation adds a new version. GitHub and Linear links are registered",
593228
+ "automatically when you create or edit them; do not pass them here."
593229
+ ].join("\n")).option("--file <path>", "Local file to upload and register").option("--url <url>", "http(s) link to register; requires --title").option("--title <title>", "Card title (defaults to the file name for --file)").option("--description <text>", "Card description").option("--operation <id>", "Defaults to LOBEHUB_OPERATION_ID").option("--json", "Output JSON").action(async (options) => {
593230
+ if (Boolean(options.file) === Boolean(options.url)) throw new Error("Pass exactly one of --file or --url");
593231
+ if (options.url && !options.title) throw new Error("--title is required with --url");
593232
+ const operationId = requireOperationId(options);
593233
+ const client = await getTrpcClient();
593234
+ const text = {
593235
+ description: options.description,
593236
+ operationId,
593237
+ title: options.title
593238
+ };
593239
+ let created;
593240
+ if (options.url) created = await client.work.createAgentWork.mutate({
593241
+ ...text,
593242
+ title: options.title,
593243
+ type: "link",
593244
+ url: options.url
593245
+ });
593246
+ else {
593247
+ const { absolutePath, fileId } = await uploadWorkFile(client, options.file);
593248
+ created = await client.work.createAgentWork.mutate({
593249
+ ...text,
593250
+ fileId,
593251
+ filePath: absolutePath,
593252
+ type: "file"
593253
+ });
593254
+ }
593255
+ printWork(created, options, "Created");
593256
+ });
593257
+ work.command("update").argument("<work-id>", "Id of a Work this agent created with lh work create").description([
593258
+ "Add a version to a Work this agent created. Options left out keep their values.",
593259
+ "A link Work keeps its URL; register a new link with lh work create --url.",
593260
+ "Works registered automatically (GitHub, Linear, scanned files) cannot be updated."
593261
+ ].join("\n")).option("--file <path>", "New content for a file Work").option("--title <title>", "New card title").option("--description <text>", "New card description").option("--operation <id>", "Defaults to LOBEHUB_OPERATION_ID").option("--json", "Output JSON").action(async (workId, options) => {
593262
+ if (!options.file && !options.title && options.description === void 0) throw new Error("Pass at least one of --file, --title or --description");
593263
+ const operationId = requireOperationId(options);
593264
+ const client = await getTrpcClient();
593265
+ const fileId = options.file ? (await uploadWorkFile(client, options.file)).fileId : void 0;
593266
+ printWork(await client.work.updateAgentWork.mutate({
593267
+ description: options.description,
593268
+ fileId,
593269
+ operationId,
593270
+ title: options.title,
593271
+ workId
593272
+ }), options, "Updated");
593273
+ });
593274
+ work.command("delete").argument("<work-id>", "Id of a Work this agent created with lh work create").description(["Delete a Work this agent created by mistake: its card and versions are removed,", "uploaded files stay. Works registered automatically cannot be deleted."].join("\n")).option("--operation <id>", "Defaults to LOBEHUB_OPERATION_ID").option("--json", "Output JSON").action(async (workId, options) => {
593275
+ const operationId = requireOperationId(options);
593276
+ const deleted = await (await getTrpcClient()).work.deleteAgentWork.mutate({
593277
+ operationId,
593278
+ workId
593279
+ });
593280
+ if (options.json) outputJson(deleted);
593281
+ else console.log(`Deleted Work ${deleted.id}${deleted.title ? `: ${deleted.title}` : ""}`);
593282
+ });
593283
+ work.command("lookup").argument("<github-pr-url>", "GitHub pull request URL").description("Find all conversations linked to a GitHub pull request in the current workspace").option("--json", "Output JSON").action(async (url, options) => {
593192
593284
  const client = await getTrpcClient();
593193
593285
  const { data } = await client.work.lookupPullRequest.query({ url });
593194
593286
  if (data.length === 0) {
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.151" "User Commands"
3
+ .TH LH 1 "" "@lobehub/cli 0.0.152" "User Commands"
4
4
  .SH NAME
5
5
  lh \- LobeHub CLI \- manage and connect to LobeHub services
6
6
  .SH SYNOPSIS
@@ -129,7 +129,7 @@ Manage message threads
129
129
  Manage conversation topics
130
130
  .TP
131
131
  .B work
132
- Look up agent work
132
+ Register the files and links this agent produced as Works, or look them up
133
133
  .TP
134
134
  .B trace
135
135
  Inspect and replay recorded agent execution traces
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/cli",
3
- "version": "0.0.151",
3
+ "version": "0.0.152",
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": "40060aa9e7423c054b78ee98a5acb994f52cda2b"
86
+ "gitHead": "9463328d58872729c60c4f759995da3ddde8b968"
87
87
  }