easyclaw-link 1.4.1 → 1.5.0
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 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -932,7 +932,7 @@ var require_command = __commonJS({
|
|
|
932
932
|
var EventEmitter = require("events").EventEmitter;
|
|
933
933
|
var childProcess = require("child_process");
|
|
934
934
|
var path8 = require("path");
|
|
935
|
-
var
|
|
935
|
+
var fs11 = require("fs");
|
|
936
936
|
var process2 = require("process");
|
|
937
937
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
938
938
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -1765,11 +1765,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1765
1765
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1766
1766
|
function findFile(baseDir, baseName) {
|
|
1767
1767
|
const localBin = path8.resolve(baseDir, baseName);
|
|
1768
|
-
if (
|
|
1768
|
+
if (fs11.existsSync(localBin))
|
|
1769
1769
|
return localBin;
|
|
1770
1770
|
if (sourceExt.includes(path8.extname(baseName)))
|
|
1771
1771
|
return void 0;
|
|
1772
|
-
const foundExt = sourceExt.find((ext) =>
|
|
1772
|
+
const foundExt = sourceExt.find((ext) => fs11.existsSync(`${localBin}${ext}`));
|
|
1773
1773
|
if (foundExt)
|
|
1774
1774
|
return `${localBin}${foundExt}`;
|
|
1775
1775
|
return void 0;
|
|
@@ -1781,7 +1781,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1781
1781
|
if (this._scriptPath) {
|
|
1782
1782
|
let resolvedScriptPath;
|
|
1783
1783
|
try {
|
|
1784
|
-
resolvedScriptPath =
|
|
1784
|
+
resolvedScriptPath = fs11.realpathSync(this._scriptPath);
|
|
1785
1785
|
} catch (err) {
|
|
1786
1786
|
resolvedScriptPath = this._scriptPath;
|
|
1787
1787
|
}
|
|
@@ -3641,6 +3641,44 @@ async function skillUseAction(id, options) {
|
|
|
3641
3641
|
}
|
|
3642
3642
|
console.log(`\u2705 \u6280\u80FD #${id} \u8C03\u7528\u5DF2\u8BB0\u5F55`);
|
|
3643
3643
|
}
|
|
3644
|
+
async function skillSearchAction(keyword, options) {
|
|
3645
|
+
if (!keyword?.trim()) {
|
|
3646
|
+
console.error("\u274C \u8BF7\u63D0\u4F9B\u641C\u7D22\u5173\u952E\u8BCD");
|
|
3647
|
+
process.exit(1);
|
|
3648
|
+
}
|
|
3649
|
+
const apiKey = requireApiKey();
|
|
3650
|
+
const parsed = parseInt(options.limit || "20", 10);
|
|
3651
|
+
const limit = isNaN(parsed) || parsed <= 0 ? 20 : Math.min(parsed, 50);
|
|
3652
|
+
const qs = new URLSearchParams({ q: keyword, limit: String(limit) });
|
|
3653
|
+
const res = await fetchWithRetry(`${BASE_URL}/api/assets?${qs}`, {
|
|
3654
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
3655
|
+
});
|
|
3656
|
+
if (!res.ok) {
|
|
3657
|
+
console.error(`\u274C \u641C\u7D22\u5931\u8D25 (${res.status})`);
|
|
3658
|
+
process.exit(1);
|
|
3659
|
+
}
|
|
3660
|
+
const data = await res.json();
|
|
3661
|
+
if (options.json) {
|
|
3662
|
+
console.log(JSON.stringify(data, null, 2));
|
|
3663
|
+
return;
|
|
3664
|
+
}
|
|
3665
|
+
const assets = data.assets ?? [];
|
|
3666
|
+
console.log(`\u{1F50D} \u641C\u7D22\u7ED3\u679C\uFF1A"${keyword}" (${data.total ?? assets.length} \u4E2A)
|
|
3667
|
+
`);
|
|
3668
|
+
if (!assets.length) {
|
|
3669
|
+
console.log("\u65E0\u5339\u914D\u6280\u80FD");
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3672
|
+
const sep = "-".repeat(72);
|
|
3673
|
+
console.log(`${"#ID".padEnd(6)} ${"\u7B49\u7EA7".padEnd(4)} ${"\u6807\u9898".padEnd(28)} ${"\u4F5C\u8005".padEnd(18)} \u2B50 \u{1F4DE}`);
|
|
3674
|
+
console.log(sep);
|
|
3675
|
+
for (const a of assets) {
|
|
3676
|
+
const title = (a.title || "").slice(0, 28).padEnd(28);
|
|
3677
|
+
const author = (a.author_username || "-").slice(0, 18).padEnd(18);
|
|
3678
|
+
const grade = (a.grade || "-").padEnd(4);
|
|
3679
|
+
console.log(`#${String(a.id).padEnd(5)} ${grade} ${title} ${author} ${a.stars ?? 0} ${a.calls ?? 0}`);
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3644
3682
|
|
|
3645
3683
|
// src/commands/bounty.ts
|
|
3646
3684
|
var fs7 = __toESM(require("fs"));
|
|
@@ -4198,6 +4236,14 @@ async function saasRunAction(serviceId, inputJson, options = {}) {
|
|
|
4198
4236
|
}
|
|
4199
4237
|
const data = await res.json();
|
|
4200
4238
|
const taskId = data.task?.id;
|
|
4239
|
+
if (!taskId) {
|
|
4240
|
+
if (options.json) {
|
|
4241
|
+
console.log(JSON.stringify(data, null, 2));
|
|
4242
|
+
return;
|
|
4243
|
+
}
|
|
4244
|
+
console.error("\u274C \u63D0\u4EA4\u6210\u529F\u4F46\u672A\u8FD4\u56DE task ID\uFF0C\u8BF7\u7A0D\u540E\u7528 `tasks-history` \u67E5\u770B");
|
|
4245
|
+
process.exit(1);
|
|
4246
|
+
}
|
|
4201
4247
|
if (!options.wait) {
|
|
4202
4248
|
if (options.json) {
|
|
4203
4249
|
console.log(JSON.stringify(data, null, 2));
|
|
@@ -4222,7 +4268,11 @@ async function saasRunAction(serviceId, inputJson, options = {}) {
|
|
|
4222
4268
|
process.exit(1);
|
|
4223
4269
|
}
|
|
4224
4270
|
const pollData = await pollRes.json();
|
|
4225
|
-
const task = pollData.task ?? pollData;
|
|
4271
|
+
const task = pollData.task ?? (typeof pollData === "object" && "status" in pollData ? pollData : void 0);
|
|
4272
|
+
if (!task) {
|
|
4273
|
+
console.error("\u274C \u8F6E\u8BE2\u54CD\u5E94\u683C\u5F0F\u5F02\u5E38");
|
|
4274
|
+
process.exit(1);
|
|
4275
|
+
}
|
|
4226
4276
|
if (TERMINAL_STATUSES.includes(String(task.status))) {
|
|
4227
4277
|
if (options.json) {
|
|
4228
4278
|
console.log(JSON.stringify(pollData, null, 2));
|
|
@@ -4337,6 +4387,7 @@ async function saasPolishAction(text, options) {
|
|
|
4337
4387
|
}
|
|
4338
4388
|
|
|
4339
4389
|
// src/commands/agent.ts
|
|
4390
|
+
var fs8 = __toESM(require("fs"));
|
|
4340
4391
|
async function agentListAction(options) {
|
|
4341
4392
|
const apiKey = requireApiKey();
|
|
4342
4393
|
const parsed = parseInt(options.limit || "20", 10);
|
|
@@ -4370,8 +4421,29 @@ async function agentListAction(options) {
|
|
|
4370
4421
|
}
|
|
4371
4422
|
async function agentCallAction(username, intent, dataJson, options = {}) {
|
|
4372
4423
|
const apiKey = requireApiKey();
|
|
4424
|
+
if (dataJson && options.dataFile) {
|
|
4425
|
+
console.error("\u274C `dataJson` \u548C `--data-file` \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\uFF0C\u8BF7\u9009\u5176\u4E00");
|
|
4426
|
+
process.exit(1);
|
|
4427
|
+
}
|
|
4373
4428
|
const body = { intent };
|
|
4374
|
-
if (
|
|
4429
|
+
if (options.dataFile) {
|
|
4430
|
+
if (!fs8.existsSync(options.dataFile)) {
|
|
4431
|
+
console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${options.dataFile}`);
|
|
4432
|
+
process.exit(1);
|
|
4433
|
+
}
|
|
4434
|
+
const MAX_SIZE = 512 * 1024;
|
|
4435
|
+
const stat = fs8.statSync(options.dataFile);
|
|
4436
|
+
if (stat.size > MAX_SIZE) {
|
|
4437
|
+
console.error(`\u274C \u6587\u4EF6\u8FC7\u5927\uFF08${Math.round(stat.size / 1024)}KB\uFF09\uFF0C\u4E0A\u9650 512KB`);
|
|
4438
|
+
process.exit(1);
|
|
4439
|
+
}
|
|
4440
|
+
const raw = fs8.readFileSync(options.dataFile, "utf-8");
|
|
4441
|
+
try {
|
|
4442
|
+
body.data = JSON.parse(raw);
|
|
4443
|
+
} catch {
|
|
4444
|
+
body.data = { text: raw };
|
|
4445
|
+
}
|
|
4446
|
+
} else if (dataJson) {
|
|
4375
4447
|
try {
|
|
4376
4448
|
body.data = JSON.parse(dataJson);
|
|
4377
4449
|
} catch {
|
|
@@ -4403,7 +4475,7 @@ async function agentCallAction(username, intent, dataJson, options = {}) {
|
|
|
4403
4475
|
}
|
|
4404
4476
|
|
|
4405
4477
|
// src/commands/forum.ts
|
|
4406
|
-
var
|
|
4478
|
+
var fs9 = __toESM(require("fs"));
|
|
4407
4479
|
var readline6 = __toESM(require("readline"));
|
|
4408
4480
|
function promptYN2(question) {
|
|
4409
4481
|
const rl = readline6.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -4478,11 +4550,11 @@ async function forumPostAction(title, filePath, options) {
|
|
|
4478
4550
|
if (options.content) {
|
|
4479
4551
|
content = options.content;
|
|
4480
4552
|
} else if (filePath) {
|
|
4481
|
-
if (!
|
|
4553
|
+
if (!fs9.existsSync(filePath)) {
|
|
4482
4554
|
console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`);
|
|
4483
4555
|
process.exit(1);
|
|
4484
4556
|
}
|
|
4485
|
-
content =
|
|
4557
|
+
content = fs9.readFileSync(filePath, "utf-8");
|
|
4486
4558
|
} else {
|
|
4487
4559
|
console.error("\u274C \u8BF7\u63D0\u4F9B --content <text> \u6216 <file> \u53C2\u6570");
|
|
4488
4560
|
process.exit(1);
|
|
@@ -4568,7 +4640,7 @@ async function forumDeleteAction(slug, options) {
|
|
|
4568
4640
|
}
|
|
4569
4641
|
|
|
4570
4642
|
// src/commands/radio.ts
|
|
4571
|
-
var
|
|
4643
|
+
var fs10 = __toESM(require("fs"));
|
|
4572
4644
|
var path7 = __toESM(require("path"));
|
|
4573
4645
|
async function radioListAction(options) {
|
|
4574
4646
|
const apiKey = requireApiKey();
|
|
@@ -4678,19 +4750,19 @@ async function radioCreateAction(name, options) {
|
|
|
4678
4750
|
}
|
|
4679
4751
|
async function radioUploadAction(stationId, filePath, options) {
|
|
4680
4752
|
const apiKey = requireApiKey();
|
|
4681
|
-
if (!
|
|
4753
|
+
if (!fs10.existsSync(filePath)) {
|
|
4682
4754
|
console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`);
|
|
4683
4755
|
process.exit(1);
|
|
4684
4756
|
}
|
|
4685
4757
|
const MAX_SIZE = 5 * 1024 * 1024;
|
|
4686
|
-
const stat =
|
|
4758
|
+
const stat = fs10.statSync(filePath);
|
|
4687
4759
|
if (stat.size > MAX_SIZE) {
|
|
4688
4760
|
console.error(`\u274C \u6587\u4EF6\u8FC7\u5927\uFF08${Math.round(stat.size / 1024 / 1024 * 10) / 10}MB\uFF09\uFF0C\u4E0A\u9650 5MB`);
|
|
4689
4761
|
process.exit(1);
|
|
4690
4762
|
}
|
|
4691
4763
|
const title = options.title || path7.basename(filePath, path7.extname(filePath));
|
|
4692
4764
|
const formData = new FormData();
|
|
4693
|
-
const blob = new Blob([
|
|
4765
|
+
const blob = new Blob([fs10.readFileSync(filePath)]);
|
|
4694
4766
|
formData.append("file", blob, path7.basename(filePath));
|
|
4695
4767
|
formData.append("title", title);
|
|
4696
4768
|
if (options.artist)
|
|
@@ -4730,7 +4802,7 @@ async function radioUploadAction(stationId, filePath, options) {
|
|
|
4730
4802
|
|
|
4731
4803
|
// src/index.ts
|
|
4732
4804
|
var program2 = new Command();
|
|
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.
|
|
4805
|
+
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.5.0");
|
|
4734
4806
|
program2.command("login").description("\u767B\u5F55 EasyClaw Link\uFF0C\u4FDD\u5B58 API Key \u5230\u672C\u5730").action(loginAction);
|
|
4735
4807
|
program2.command("logout").description("\u9000\u51FA\u767B\u5F55\uFF0C\u6E05\u9664\u672C\u5730 API Key").action(logoutAction);
|
|
4736
4808
|
program2.command("whoami").description("\u663E\u793A\u5F53\u524D\u767B\u5F55\u8D26\u53F7\u4FE1\u606F").option("--json", "JSON \u8F93\u51FA").action(() => whoamiAction());
|
|
@@ -4747,6 +4819,7 @@ program2.command("publish [dir]").description("\u53D1\u5E03\u6216\u66F4\u65B0\u6
|
|
|
4747
4819
|
program2.command("list").description("\u5217\u51FA\u4F60\u53D1\u5E03\u7684\u6240\u6709\u6280\u80FD").option("--json", "JSON \u8F93\u51FA").action(() => listAction());
|
|
4748
4820
|
program2.command("validate [dir]").description("\u672C\u5730\u6821\u9A8C\u6280\u80FD\u76EE\u5F55\u683C\u5F0F").action((dir) => validateAction(dir));
|
|
4749
4821
|
var skillCmd = program2.command("skill").description("\u6280\u80FD\u8BE6\u7EC6\u64CD\u4F5C");
|
|
4822
|
+
skillCmd.command("search <keyword>").description("\u641C\u7D22\u5E73\u53F0\u6280\u80FD").option("--limit <n>", "\u6761\u6570\u9650\u5236", "20").option("--json", "JSON \u8F93\u51FA").action((kw, o) => skillSearchAction(kw, o));
|
|
4750
4823
|
skillCmd.command("view <id>").description("\u67E5\u770B\u6280\u80FD\u8BE6\u60C5").option("--json", "JSON \u8F93\u51FA").action((id, o) => skillViewAction(id, o));
|
|
4751
4824
|
skillCmd.command("delete <id>").description("\u5220\u9664\u6280\u80FD").option("--force", "\u8DF3\u8FC7\u786E\u8BA4").option("--json", "JSON \u8F93\u51FA").action((id, o) => skillDeleteAction(id, o));
|
|
4752
4825
|
skillCmd.command("download <id>").description("\u4E0B\u8F7D\u6280\u80FD\u5230\u672C\u5730 zip").option("--out <path>", "\u8F93\u51FA\u8DEF\u5F84").option("--json", "JSON \u8F93\u51FA").action((id, o) => skillDownloadAction(id, o));
|
|
@@ -4781,7 +4854,7 @@ program2.command("task <taskId>").description("\u67E5\u770B SaaS \u4EFB\u52A1\u7
|
|
|
4781
4854
|
program2.command("polish <text>").description("AI \u6DA6\u8272\u6587\u672C").option("--json", "JSON \u8F93\u51FA").action((t, o) => saasPolishAction(t, o));
|
|
4782
4855
|
var agentCmd = program2.command("agent").description("Agent \u4E92\u8054\uFF08A2A\uFF09");
|
|
4783
4856
|
agentCmd.command("list", { isDefault: true }).description("\u67E5\u770B\u5E73\u53F0 Agent \u5217\u8868").option("--limit <n>", "\u6761\u6570\u9650\u5236", "20").option("--json", "JSON \u8F93\u51FA").action((o) => agentListAction(o));
|
|
4784
|
-
agentCmd.command("call <username> <intent> [data]").description("\u8C03\u7528\u53E6\u4E00\u4E2A Agent\uFF08A2A\uFF09").option("--json", "JSON \u8F93\u51FA").action((u, intent, data, o) => agentCallAction(u, intent, data, o));
|
|
4857
|
+
agentCmd.command("call <username> <intent> [data]").description("\u8C03\u7528\u53E6\u4E00\u4E2A Agent\uFF08A2A\uFF09").option("--data-file <path>", "\u4ECE\u6587\u4EF6\u8BFB\u53D6 payload\uFF08\u4E0E data \u53C2\u6570\u4E92\u65A5\uFF0C\u4E0A\u9650 512KB\uFF09").option("--json", "JSON \u8F93\u51FA").action((u, intent, data, o) => agentCallAction(u, intent, data, o));
|
|
4785
4858
|
var forumCmd = program2.command("forum").description("\u8BBA\u575B\u64CD\u4F5C");
|
|
4786
4859
|
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));
|
|
4787
4860
|
forumCmd.command("view <slug>").description("\u67E5\u770B\u5E16\u5B50\u8BE6\u60C5").option("--json", "JSON \u8F93\u51FA").action((slug, o) => forumViewAction(slug, o));
|