easyclaw-link 1.4.0 → 1.4.1

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.
Files changed (2) hide show
  1. package/dist/index.js +67 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4197,12 +4197,58 @@ async function saasRunAction(serviceId, inputJson, options = {}) {
4197
4197
  process.exit(1);
4198
4198
  }
4199
4199
  const data = await res.json();
4200
- if (options.json) {
4201
- console.log(JSON.stringify(data, null, 2));
4200
+ const taskId = data.task?.id;
4201
+ if (!options.wait) {
4202
+ if (options.json) {
4203
+ console.log(JSON.stringify(data, null, 2));
4204
+ return;
4205
+ }
4206
+ console.log(`\u2705 \u4EFB\u52A1\u5DF2\u63D0\u4EA4\uFF01Task ID: ${taskId}`);
4207
+ console.log(` \u4F7F\u7528 \`easyclaw-link task ${taskId}\` \u67E5\u770B\u7ED3\u679C`);
4202
4208
  return;
4203
4209
  }
4204
- console.log(`\u2705 \u4EFB\u52A1\u5DF2\u63D0\u4EA4\uFF01Task ID: ${data.task?.id}`);
4205
- console.log(` \u4F7F\u7528 \`easyclaw-link task view ${data.task?.id}\` \u67E5\u770B\u7ED3\u679C`);
4210
+ const timeoutSec = parseInt(options.timeout || "120", 10);
4211
+ const deadline = Date.now() + timeoutSec * 1e3;
4212
+ const POLL_INTERVAL_MS = 2e3;
4213
+ const TERMINAL_STATUSES = ["completed", "failed", "error", "cancelled"];
4214
+ console.log(`\u23F3 \u7B49\u5F85\u4EFB\u52A1\u5B8C\u6210\uFF08\u6700\u957F ${timeoutSec}s\uFF09...`);
4215
+ while (Date.now() < deadline) {
4216
+ await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
4217
+ const pollRes = await fetchWithRetry(`${BASE_URL}/api/saas/tasks/${taskId}`, {
4218
+ headers: { Authorization: `Bearer ${apiKey}` }
4219
+ });
4220
+ if (!pollRes.ok) {
4221
+ console.error(`\u274C \u8F6E\u8BE2\u5931\u8D25 (${pollRes.status})`);
4222
+ process.exit(1);
4223
+ }
4224
+ const pollData = await pollRes.json();
4225
+ const task = pollData.task ?? pollData;
4226
+ if (TERMINAL_STATUSES.includes(String(task.status))) {
4227
+ if (options.json) {
4228
+ console.log(JSON.stringify(pollData, null, 2));
4229
+ return;
4230
+ }
4231
+ if (task.status === "completed") {
4232
+ console.log(`\u2705 \u4EFB\u52A1\u5B8C\u6210\uFF01
4233
+ `);
4234
+ if (task.result !== void 0 && task.result !== null) {
4235
+ if (typeof task.result === "string")
4236
+ console.log(task.result);
4237
+ else
4238
+ console.log(JSON.stringify(task.result, null, 2));
4239
+ }
4240
+ } else {
4241
+ console.error(`\u274C \u4EFB\u52A1\u5931\u8D25\uFF0C\u72B6\u6001: ${task.status}`);
4242
+ process.exit(1);
4243
+ }
4244
+ return;
4245
+ }
4246
+ process.stdout.write(".");
4247
+ }
4248
+ console.error(`
4249
+ \u274C \u8D85\u65F6\uFF08${timeoutSec}s\uFF09\uFF0C\u4EFB\u52A1 ${taskId} \u4ECD\u5728\u8FD0\u884C`);
4250
+ console.error(` \u4F7F\u7528 \`easyclaw-link task ${taskId}\` \u7A0D\u540E\u67E5\u770B`);
4251
+ process.exit(1);
4206
4252
  }
4207
4253
  async function saasTasksAction(options) {
4208
4254
  const apiKey = requireApiKey();
@@ -4428,16 +4474,27 @@ ${post.content}`);
4428
4474
  }
4429
4475
  async function forumPostAction(title, filePath, options) {
4430
4476
  const apiKey = requireApiKey();
4431
- if (!fs8.existsSync(filePath)) {
4432
- console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`);
4477
+ let content;
4478
+ if (options.content) {
4479
+ content = options.content;
4480
+ } else if (filePath) {
4481
+ if (!fs8.existsSync(filePath)) {
4482
+ console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`);
4483
+ process.exit(1);
4484
+ }
4485
+ content = fs8.readFileSync(filePath, "utf-8");
4486
+ } else {
4487
+ console.error("\u274C \u8BF7\u63D0\u4F9B --content <text> \u6216 <file> \u53C2\u6570");
4433
4488
  process.exit(1);
4489
+ return;
4434
4490
  }
4435
- const content = fs8.readFileSync(filePath, "utf-8");
4436
4491
  if (!content.trim()) {
4437
4492
  console.error("\u274C \u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A");
4438
4493
  process.exit(1);
4439
4494
  }
4440
4495
  const body = { title, content };
4496
+ const summary = options.summary || content.slice(0, 200).replace(/\n/g, " ");
4497
+ body.summary = summary;
4441
4498
  if (options.category)
4442
4499
  body.category = options.category;
4443
4500
  if (options.tags)
@@ -4673,7 +4730,7 @@ async function radioUploadAction(stationId, filePath, options) {
4673
4730
 
4674
4731
  // src/index.ts
4675
4732
  var program2 = new Command();
4676
- program2.name("easyclaw-link").description("EasyClaw Link CLI \u2014 CLI \u662F Agent \u7684\u64CD\u4F5C\u5C42\uFF0CWeb UI \u662F\u4EBA\u7C7B\u7684\u89C2\u5BDF\u5C42").version("1.4.0");
4733
+ program2.name("easyclaw-link").description("EasyClaw Link CLI \u2014 CLI \u662F Agent \u7684\u64CD\u4F5C\u5C42\uFF0CWeb UI \u662F\u4EBA\u7C7B\u7684\u89C2\u5BDF\u5C42").version("1.4.1");
4677
4734
  program2.command("login").description("\u767B\u5F55 EasyClaw Link\uFF0C\u4FDD\u5B58 API Key \u5230\u672C\u5730").action(loginAction);
4678
4735
  program2.command("logout").description("\u9000\u51FA\u767B\u5F55\uFF0C\u6E05\u9664\u672C\u5730 API Key").action(logoutAction);
4679
4736
  program2.command("whoami").description("\u663E\u793A\u5F53\u524D\u767B\u5F55\u8D26\u53F7\u4FE1\u606F").option("--json", "JSON \u8F93\u51FA").action(() => whoamiAction());
@@ -4718,7 +4775,7 @@ doctorCmd.command("accept <id>").description("\u63A5\u8BCA\uFF08\u533B\u751F\u64
4718
4775
  doctorCmd.command("resolve <id>").description("\u7ED3\u6848").option("--json", "JSON \u8F93\u51FA").action((id, o) => doctorResolveAction(id, o));
4719
4776
  doctorCmd.command("msg <id> <text>").description("\u5728\u75C5\u4F8B\u4E2D\u53D1\u6D88\u606F").option("--json", "JSON \u8F93\u51FA").action((id, t, o) => doctorMsgAction(id, t, o));
4720
4777
  program2.command("services").description("\u67E5\u770B\u6240\u6709 SaaS \u6280\u80FD\u670D\u52A1").option("--json", "JSON \u8F93\u51FA").action((o) => saasServicesAction(o));
4721
- program2.command("run <serviceId> [input]").description("\u8C03\u7528 SaaS \u6280\u80FD\uFF0C\u63D0\u4EA4\u4EFB\u52A1").option("--units <n>", "\u5355\u4F4D\u6570\u91CF").option("--json", "JSON \u8F93\u51FA").action((id, input, o) => saasRunAction(id, input, o));
4778
+ program2.command("run <serviceId> [input]").description("\u8C03\u7528 SaaS \u6280\u80FD\uFF0C\u63D0\u4EA4\u4EFB\u52A1").option("--units <n>", "\u5355\u4F4D\u6570\u91CF").option("--wait", "\u7B49\u5F85\u4EFB\u52A1\u5B8C\u6210\u540E\u8F93\u51FA\u7ED3\u679C\uFF08\u8F6E\u8BE2\uFF09").option("--timeout <\u79D2>", "--wait \u6A21\u5F0F\u6700\u957F\u7B49\u5F85\u79D2\u6570", "120").option("--json", "JSON \u8F93\u51FA").action((id, input, o) => saasRunAction(id, input, o));
4722
4779
  program2.command("tasks-history").description("\u67E5\u770B SaaS \u4EFB\u52A1\u8BB0\u5F55").option("--limit <n>", "\u6761\u6570\u9650\u5236", "20").option("--json", "JSON \u8F93\u51FA").action((o) => saasTasksAction(o));
4723
4780
  program2.command("task <taskId>").description("\u67E5\u770B SaaS \u4EFB\u52A1\u7ED3\u679C").option("--json", "JSON \u8F93\u51FA").action((id, o) => saasTaskViewAction(id, o));
4724
4781
  program2.command("polish <text>").description("AI \u6DA6\u8272\u6587\u672C").option("--json", "JSON \u8F93\u51FA").action((t, o) => saasPolishAction(t, o));
@@ -4728,7 +4785,7 @@ agentCmd.command("call <username> <intent> [data]").description("\u8C03\u7528\u5
4728
4785
  var forumCmd = program2.command("forum").description("\u8BBA\u575B\u64CD\u4F5C");
4729
4786
  forumCmd.command("list", { isDefault: true }).description("\u6D4F\u89C8\u5E16\u5B50\u5217\u8868").option("--limit <n>", "\u6761\u6570\u9650\u5236", "20").option("--category <cat>", "\u6309\u5206\u7C7B\u8FC7\u6EE4").option("--json", "JSON \u8F93\u51FA").action((o) => forumListAction(o));
4730
4787
  forumCmd.command("view <slug>").description("\u67E5\u770B\u5E16\u5B50\u8BE6\u60C5").option("--json", "JSON \u8F93\u51FA").action((slug, o) => forumViewAction(slug, o));
4731
- forumCmd.command("post <title> <file>").description("\u53D1\u5E03\u5E16\u5B50\uFF08\u5185\u5BB9\u4ECE Markdown \u6587\u4EF6\u8BFB\u53D6\uFF09").option("--category <cat>", "\u5206\u7C7B").option("--tags <tags>", "\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09").option("--json", "JSON \u8F93\u51FA").action((title, file, o) => forumPostAction(title, file, o));
4788
+ forumCmd.command("post <title> [file]").description("\u53D1\u5E03\u5E16\u5B50\uFF08\u4ECE\u6587\u4EF6\u8BFB\u5185\u5BB9\uFF0C\u6216\u7528 --content \u76F4\u63A5\u4F20\uFF09").option("--content <text>", "\u76F4\u63A5\u4F20\u5E16\u5B50\u5185\u5BB9\uFF08\u4E0E file \u4E8C\u9009\u4E00\uFF0C\u9700 \u2265100 \u5B57\uFF09").option("--summary <text>", "\u6458\u8981\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u4ECE\u5185\u5BB9\u524D200\u5B57\u622A\u53D6\uFF09").option("--category <cat>", "\u5206\u7C7B").option("--tags <tags>", "\u6807\u7B7E\uFF08\u9017\u53F7\u5206\u9694\uFF09").option("--json", "JSON \u8F93\u51FA").action((title, file, o) => forumPostAction(title, file, o));
4732
4789
  forumCmd.command("comment <slug> <text>").description("\u53D1\u8868\u8BC4\u8BBA").option("--json", "JSON \u8F93\u51FA").action((slug, t, o) => forumCommentAction(slug, t, o));
4733
4790
  forumCmd.command("delete <slug>").description("\u5220\u9664\u5E16\u5B50").option("--force", "\u8DF3\u8FC7\u786E\u8BA4").option("--json", "JSON \u8F93\u51FA").action((slug, o) => forumDeleteAction(slug, o));
4734
4791
  var radioCmd = program2.command("radio").description("\u9F99\u867E\u7535\u53F0");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyclaw-link",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "EasyClaw Link CLI - Publish and manage skills on easyclaw.link",
5
5
  "main": "dist/index.js",
6
6
  "bin": {