easyclaw-link 1.4.2 → 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 +75 -14
- 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"));
|
|
@@ -4349,6 +4387,7 @@ async function saasPolishAction(text, options) {
|
|
|
4349
4387
|
}
|
|
4350
4388
|
|
|
4351
4389
|
// src/commands/agent.ts
|
|
4390
|
+
var fs8 = __toESM(require("fs"));
|
|
4352
4391
|
async function agentListAction(options) {
|
|
4353
4392
|
const apiKey = requireApiKey();
|
|
4354
4393
|
const parsed = parseInt(options.limit || "20", 10);
|
|
@@ -4382,8 +4421,29 @@ async function agentListAction(options) {
|
|
|
4382
4421
|
}
|
|
4383
4422
|
async function agentCallAction(username, intent, dataJson, options = {}) {
|
|
4384
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
|
+
}
|
|
4385
4428
|
const body = { intent };
|
|
4386
|
-
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) {
|
|
4387
4447
|
try {
|
|
4388
4448
|
body.data = JSON.parse(dataJson);
|
|
4389
4449
|
} catch {
|
|
@@ -4415,7 +4475,7 @@ async function agentCallAction(username, intent, dataJson, options = {}) {
|
|
|
4415
4475
|
}
|
|
4416
4476
|
|
|
4417
4477
|
// src/commands/forum.ts
|
|
4418
|
-
var
|
|
4478
|
+
var fs9 = __toESM(require("fs"));
|
|
4419
4479
|
var readline6 = __toESM(require("readline"));
|
|
4420
4480
|
function promptYN2(question) {
|
|
4421
4481
|
const rl = readline6.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -4490,11 +4550,11 @@ async function forumPostAction(title, filePath, options) {
|
|
|
4490
4550
|
if (options.content) {
|
|
4491
4551
|
content = options.content;
|
|
4492
4552
|
} else if (filePath) {
|
|
4493
|
-
if (!
|
|
4553
|
+
if (!fs9.existsSync(filePath)) {
|
|
4494
4554
|
console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`);
|
|
4495
4555
|
process.exit(1);
|
|
4496
4556
|
}
|
|
4497
|
-
content =
|
|
4557
|
+
content = fs9.readFileSync(filePath, "utf-8");
|
|
4498
4558
|
} else {
|
|
4499
4559
|
console.error("\u274C \u8BF7\u63D0\u4F9B --content <text> \u6216 <file> \u53C2\u6570");
|
|
4500
4560
|
process.exit(1);
|
|
@@ -4580,7 +4640,7 @@ async function forumDeleteAction(slug, options) {
|
|
|
4580
4640
|
}
|
|
4581
4641
|
|
|
4582
4642
|
// src/commands/radio.ts
|
|
4583
|
-
var
|
|
4643
|
+
var fs10 = __toESM(require("fs"));
|
|
4584
4644
|
var path7 = __toESM(require("path"));
|
|
4585
4645
|
async function radioListAction(options) {
|
|
4586
4646
|
const apiKey = requireApiKey();
|
|
@@ -4690,19 +4750,19 @@ async function radioCreateAction(name, options) {
|
|
|
4690
4750
|
}
|
|
4691
4751
|
async function radioUploadAction(stationId, filePath, options) {
|
|
4692
4752
|
const apiKey = requireApiKey();
|
|
4693
|
-
if (!
|
|
4753
|
+
if (!fs10.existsSync(filePath)) {
|
|
4694
4754
|
console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${filePath}`);
|
|
4695
4755
|
process.exit(1);
|
|
4696
4756
|
}
|
|
4697
4757
|
const MAX_SIZE = 5 * 1024 * 1024;
|
|
4698
|
-
const stat =
|
|
4758
|
+
const stat = fs10.statSync(filePath);
|
|
4699
4759
|
if (stat.size > MAX_SIZE) {
|
|
4700
4760
|
console.error(`\u274C \u6587\u4EF6\u8FC7\u5927\uFF08${Math.round(stat.size / 1024 / 1024 * 10) / 10}MB\uFF09\uFF0C\u4E0A\u9650 5MB`);
|
|
4701
4761
|
process.exit(1);
|
|
4702
4762
|
}
|
|
4703
4763
|
const title = options.title || path7.basename(filePath, path7.extname(filePath));
|
|
4704
4764
|
const formData = new FormData();
|
|
4705
|
-
const blob = new Blob([
|
|
4765
|
+
const blob = new Blob([fs10.readFileSync(filePath)]);
|
|
4706
4766
|
formData.append("file", blob, path7.basename(filePath));
|
|
4707
4767
|
formData.append("title", title);
|
|
4708
4768
|
if (options.artist)
|
|
@@ -4742,7 +4802,7 @@ async function radioUploadAction(stationId, filePath, options) {
|
|
|
4742
4802
|
|
|
4743
4803
|
// src/index.ts
|
|
4744
4804
|
var program2 = new Command();
|
|
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.
|
|
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");
|
|
4746
4806
|
program2.command("login").description("\u767B\u5F55 EasyClaw Link\uFF0C\u4FDD\u5B58 API Key \u5230\u672C\u5730").action(loginAction);
|
|
4747
4807
|
program2.command("logout").description("\u9000\u51FA\u767B\u5F55\uFF0C\u6E05\u9664\u672C\u5730 API Key").action(logoutAction);
|
|
4748
4808
|
program2.command("whoami").description("\u663E\u793A\u5F53\u524D\u767B\u5F55\u8D26\u53F7\u4FE1\u606F").option("--json", "JSON \u8F93\u51FA").action(() => whoamiAction());
|
|
@@ -4759,6 +4819,7 @@ program2.command("publish [dir]").description("\u53D1\u5E03\u6216\u66F4\u65B0\u6
|
|
|
4759
4819
|
program2.command("list").description("\u5217\u51FA\u4F60\u53D1\u5E03\u7684\u6240\u6709\u6280\u80FD").option("--json", "JSON \u8F93\u51FA").action(() => listAction());
|
|
4760
4820
|
program2.command("validate [dir]").description("\u672C\u5730\u6821\u9A8C\u6280\u80FD\u76EE\u5F55\u683C\u5F0F").action((dir) => validateAction(dir));
|
|
4761
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));
|
|
4762
4823
|
skillCmd.command("view <id>").description("\u67E5\u770B\u6280\u80FD\u8BE6\u60C5").option("--json", "JSON \u8F93\u51FA").action((id, o) => skillViewAction(id, o));
|
|
4763
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));
|
|
4764
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));
|
|
@@ -4793,7 +4854,7 @@ program2.command("task <taskId>").description("\u67E5\u770B SaaS \u4EFB\u52A1\u7
|
|
|
4793
4854
|
program2.command("polish <text>").description("AI \u6DA6\u8272\u6587\u672C").option("--json", "JSON \u8F93\u51FA").action((t, o) => saasPolishAction(t, o));
|
|
4794
4855
|
var agentCmd = program2.command("agent").description("Agent \u4E92\u8054\uFF08A2A\uFF09");
|
|
4795
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));
|
|
4796
|
-
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));
|
|
4797
4858
|
var forumCmd = program2.command("forum").description("\u8BBA\u575B\u64CD\u4F5C");
|
|
4798
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));
|
|
4799
4860
|
forumCmd.command("view <slug>").description("\u67E5\u770B\u5E16\u5B50\u8BE6\u60C5").option("--json", "JSON \u8F93\u51FA").action((slug, o) => forumViewAction(slug, o));
|