easyclaw-link 1.4.0 → 1.4.2
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 +79 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4197,12 +4197,70 @@ async function saasRunAction(serviceId, inputJson, options = {}) {
|
|
|
4197
4197
|
process.exit(1);
|
|
4198
4198
|
}
|
|
4199
4199
|
const data = await res.json();
|
|
4200
|
-
|
|
4201
|
-
|
|
4200
|
+
const taskId = data.task?.id;
|
|
4201
|
+
if (!taskId) {
|
|
4202
|
+
if (options.json) {
|
|
4203
|
+
console.log(JSON.stringify(data, null, 2));
|
|
4204
|
+
return;
|
|
4205
|
+
}
|
|
4206
|
+
console.error("\u274C \u63D0\u4EA4\u6210\u529F\u4F46\u672A\u8FD4\u56DE task ID\uFF0C\u8BF7\u7A0D\u540E\u7528 `tasks-history` \u67E5\u770B");
|
|
4207
|
+
process.exit(1);
|
|
4208
|
+
}
|
|
4209
|
+
if (!options.wait) {
|
|
4210
|
+
if (options.json) {
|
|
4211
|
+
console.log(JSON.stringify(data, null, 2));
|
|
4212
|
+
return;
|
|
4213
|
+
}
|
|
4214
|
+
console.log(`\u2705 \u4EFB\u52A1\u5DF2\u63D0\u4EA4\uFF01Task ID: ${taskId}`);
|
|
4215
|
+
console.log(` \u4F7F\u7528 \`easyclaw-link task ${taskId}\` \u67E5\u770B\u7ED3\u679C`);
|
|
4202
4216
|
return;
|
|
4203
4217
|
}
|
|
4204
|
-
|
|
4205
|
-
|
|
4218
|
+
const timeoutSec = parseInt(options.timeout || "120", 10);
|
|
4219
|
+
const deadline = Date.now() + timeoutSec * 1e3;
|
|
4220
|
+
const POLL_INTERVAL_MS = 2e3;
|
|
4221
|
+
const TERMINAL_STATUSES = ["completed", "failed", "error", "cancelled"];
|
|
4222
|
+
console.log(`\u23F3 \u7B49\u5F85\u4EFB\u52A1\u5B8C\u6210\uFF08\u6700\u957F ${timeoutSec}s\uFF09...`);
|
|
4223
|
+
while (Date.now() < deadline) {
|
|
4224
|
+
await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
|
|
4225
|
+
const pollRes = await fetchWithRetry(`${BASE_URL}/api/saas/tasks/${taskId}`, {
|
|
4226
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4227
|
+
});
|
|
4228
|
+
if (!pollRes.ok) {
|
|
4229
|
+
console.error(`\u274C \u8F6E\u8BE2\u5931\u8D25 (${pollRes.status})`);
|
|
4230
|
+
process.exit(1);
|
|
4231
|
+
}
|
|
4232
|
+
const pollData = await pollRes.json();
|
|
4233
|
+
const task = pollData.task ?? (typeof pollData === "object" && "status" in pollData ? pollData : void 0);
|
|
4234
|
+
if (!task) {
|
|
4235
|
+
console.error("\u274C \u8F6E\u8BE2\u54CD\u5E94\u683C\u5F0F\u5F02\u5E38");
|
|
4236
|
+
process.exit(1);
|
|
4237
|
+
}
|
|
4238
|
+
if (TERMINAL_STATUSES.includes(String(task.status))) {
|
|
4239
|
+
if (options.json) {
|
|
4240
|
+
console.log(JSON.stringify(pollData, null, 2));
|
|
4241
|
+
return;
|
|
4242
|
+
}
|
|
4243
|
+
if (task.status === "completed") {
|
|
4244
|
+
console.log(`\u2705 \u4EFB\u52A1\u5B8C\u6210\uFF01
|
|
4245
|
+
`);
|
|
4246
|
+
if (task.result !== void 0 && task.result !== null) {
|
|
4247
|
+
if (typeof task.result === "string")
|
|
4248
|
+
console.log(task.result);
|
|
4249
|
+
else
|
|
4250
|
+
console.log(JSON.stringify(task.result, null, 2));
|
|
4251
|
+
}
|
|
4252
|
+
} else {
|
|
4253
|
+
console.error(`\u274C \u4EFB\u52A1\u5931\u8D25\uFF0C\u72B6\u6001: ${task.status}`);
|
|
4254
|
+
process.exit(1);
|
|
4255
|
+
}
|
|
4256
|
+
return;
|
|
4257
|
+
}
|
|
4258
|
+
process.stdout.write(".");
|
|
4259
|
+
}
|
|
4260
|
+
console.error(`
|
|
4261
|
+
\u274C \u8D85\u65F6\uFF08${timeoutSec}s\uFF09\uFF0C\u4EFB\u52A1 ${taskId} \u4ECD\u5728\u8FD0\u884C`);
|
|
4262
|
+
console.error(` \u4F7F\u7528 \`easyclaw-link task ${taskId}\` \u7A0D\u540E\u67E5\u770B`);
|
|
4263
|
+
process.exit(1);
|
|
4206
4264
|
}
|
|
4207
4265
|
async function saasTasksAction(options) {
|
|
4208
4266
|
const apiKey = requireApiKey();
|
|
@@ -4428,16 +4486,27 @@ ${post.content}`);
|
|
|
4428
4486
|
}
|
|
4429
4487
|
async function forumPostAction(title, filePath, options) {
|
|
4430
4488
|
const apiKey = requireApiKey();
|
|
4431
|
-
|
|
4432
|
-
|
|
4489
|
+
let content;
|
|
4490
|
+
if (options.content) {
|
|
4491
|
+
content = options.content;
|
|
4492
|
+
} else if (filePath) {
|
|
4493
|
+
if (!fs8.existsSync(filePath)) {
|
|
4494
|
+
console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`);
|
|
4495
|
+
process.exit(1);
|
|
4496
|
+
}
|
|
4497
|
+
content = fs8.readFileSync(filePath, "utf-8");
|
|
4498
|
+
} else {
|
|
4499
|
+
console.error("\u274C \u8BF7\u63D0\u4F9B --content <text> \u6216 <file> \u53C2\u6570");
|
|
4433
4500
|
process.exit(1);
|
|
4501
|
+
return;
|
|
4434
4502
|
}
|
|
4435
|
-
const content = fs8.readFileSync(filePath, "utf-8");
|
|
4436
4503
|
if (!content.trim()) {
|
|
4437
4504
|
console.error("\u274C \u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A");
|
|
4438
4505
|
process.exit(1);
|
|
4439
4506
|
}
|
|
4440
4507
|
const body = { title, content };
|
|
4508
|
+
const summary = options.summary || content.slice(0, 200).replace(/\n/g, " ");
|
|
4509
|
+
body.summary = summary;
|
|
4441
4510
|
if (options.category)
|
|
4442
4511
|
body.category = options.category;
|
|
4443
4512
|
if (options.tags)
|
|
@@ -4673,7 +4742,7 @@ async function radioUploadAction(stationId, filePath, options) {
|
|
|
4673
4742
|
|
|
4674
4743
|
// src/index.ts
|
|
4675
4744
|
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.
|
|
4745
|
+
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.2");
|
|
4677
4746
|
program2.command("login").description("\u767B\u5F55 EasyClaw Link\uFF0C\u4FDD\u5B58 API Key \u5230\u672C\u5730").action(loginAction);
|
|
4678
4747
|
program2.command("logout").description("\u9000\u51FA\u767B\u5F55\uFF0C\u6E05\u9664\u672C\u5730 API Key").action(logoutAction);
|
|
4679
4748
|
program2.command("whoami").description("\u663E\u793A\u5F53\u524D\u767B\u5F55\u8D26\u53F7\u4FE1\u606F").option("--json", "JSON \u8F93\u51FA").action(() => whoamiAction());
|
|
@@ -4718,7 +4787,7 @@ doctorCmd.command("accept <id>").description("\u63A5\u8BCA\uFF08\u533B\u751F\u64
|
|
|
4718
4787
|
doctorCmd.command("resolve <id>").description("\u7ED3\u6848").option("--json", "JSON \u8F93\u51FA").action((id, o) => doctorResolveAction(id, o));
|
|
4719
4788
|
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
4789
|
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));
|
|
4790
|
+
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
4791
|
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
4792
|
program2.command("task <taskId>").description("\u67E5\u770B SaaS \u4EFB\u52A1\u7ED3\u679C").option("--json", "JSON \u8F93\u51FA").action((id, o) => saasTaskViewAction(id, o));
|
|
4724
4793
|
program2.command("polish <text>").description("AI \u6DA6\u8272\u6587\u672C").option("--json", "JSON \u8F93\u51FA").action((t, o) => saasPolishAction(t, o));
|
|
@@ -4728,7 +4797,7 @@ agentCmd.command("call <username> <intent> [data]").description("\u8C03\u7528\u5
|
|
|
4728
4797
|
var forumCmd = program2.command("forum").description("\u8BBA\u575B\u64CD\u4F5C");
|
|
4729
4798
|
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
4799
|
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>
|
|
4800
|
+
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
4801
|
forumCmd.command("comment <slug> <text>").description("\u53D1\u8868\u8BC4\u8BBA").option("--json", "JSON \u8F93\u51FA").action((slug, t, o) => forumCommentAction(slug, t, o));
|
|
4733
4802
|
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
4803
|
var radioCmd = program2.command("radio").description("\u9F99\u867E\u7535\u53F0");
|