easyclaw-link 1.7.0 → 1.8.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 +22 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2833,7 +2833,7 @@ var os = __toESM(require("os"));
|
|
|
2833
2833
|
var CONFIG_DIR = path.join(os.homedir(), ".easyclaw-link");
|
|
2834
2834
|
var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
2835
2835
|
var BASE_URL = process.env.EASYCLAW_LINK_API || "https://easyclaw.link";
|
|
2836
|
-
var
|
|
2836
|
+
var EXIT2 = {
|
|
2837
2837
|
OK: 0,
|
|
2838
2838
|
ERROR: 1,
|
|
2839
2839
|
AUTH: 2,
|
|
@@ -2848,26 +2848,26 @@ function httpError(status, serverMessage) {
|
|
|
2848
2848
|
case 401:
|
|
2849
2849
|
console.error(`\u274C \u8BA4\u8BC1\u5931\u8D25${msg}
|
|
2850
2850
|
\u2192 \u8BF7\u5148\u8FD0\u884C: ecl login`);
|
|
2851
|
-
process.exit(
|
|
2851
|
+
process.exit(EXIT2.AUTH);
|
|
2852
2852
|
case 403:
|
|
2853
2853
|
console.error(`\u274C \u6743\u9650\u4E0D\u8DB3${msg}
|
|
2854
2854
|
\u2192 \u5F53\u524D\u8D26\u53F7\u65E0\u6B64\u64CD\u4F5C\u6743\u9650\uFF0C\u68C0\u67E5\u8D26\u53F7\u89D2\u8272`);
|
|
2855
|
-
process.exit(
|
|
2855
|
+
process.exit(EXIT2.PERMISSION);
|
|
2856
2856
|
case 404:
|
|
2857
2857
|
console.error(`\u274C \u8D44\u6E90\u4E0D\u5B58\u5728${msg}
|
|
2858
2858
|
\u2192 \u68C0\u67E5 ID/slug \u662F\u5426\u6B63\u786E`);
|
|
2859
|
-
process.exit(
|
|
2859
|
+
process.exit(EXIT2.NOT_FOUND);
|
|
2860
2860
|
case 422:
|
|
2861
2861
|
console.error(`\u274C \u8BF7\u6C42\u6821\u9A8C\u5931\u8D25${msg}
|
|
2862
2862
|
\u2192 \u68C0\u67E5\u53C2\u6570\u683C\u5F0F`);
|
|
2863
|
-
process.exit(
|
|
2863
|
+
process.exit(EXIT2.VALIDATION);
|
|
2864
2864
|
case 429:
|
|
2865
2865
|
console.error(`\u274C \u89E6\u53D1\u9891\u7387\u9650\u5236${msg}
|
|
2866
2866
|
\u2192 \u8BF7\u7A0D\u540E\u91CD\u8BD5`);
|
|
2867
|
-
process.exit(
|
|
2867
|
+
process.exit(EXIT2.RATE_LIMIT);
|
|
2868
2868
|
default:
|
|
2869
2869
|
console.error(`\u274C \u8BF7\u6C42\u5931\u8D25 (HTTP ${status})${msg}`);
|
|
2870
|
-
process.exit(
|
|
2870
|
+
process.exit(EXIT2.ERROR);
|
|
2871
2871
|
}
|
|
2872
2872
|
}
|
|
2873
2873
|
async function assertOk(res) {
|
|
@@ -2901,7 +2901,7 @@ function requireApiKey() {
|
|
|
2901
2901
|
const cfg = readConfig();
|
|
2902
2902
|
if (!cfg.apiKey) {
|
|
2903
2903
|
console.error("\u274C \u672A\u767B\u5F55\uFF0C\u8BF7\u5148\u8FD0\u884C: ecl login");
|
|
2904
|
-
process.exit(
|
|
2904
|
+
process.exit(EXIT2.AUTH);
|
|
2905
2905
|
}
|
|
2906
2906
|
return cfg.apiKey;
|
|
2907
2907
|
}
|
|
@@ -3417,13 +3417,15 @@ async function leaderboardAction(options) {
|
|
|
3417
3417
|
async function profileUpdateAction(options) {
|
|
3418
3418
|
const apiKey = requireApiKey();
|
|
3419
3419
|
const body = {};
|
|
3420
|
+
if (options.displayName !== void 0)
|
|
3421
|
+
body.display_name = options.displayName || null;
|
|
3420
3422
|
if (options.webhookUrl !== void 0)
|
|
3421
3423
|
body.webhook_url = options.webhookUrl || null;
|
|
3422
3424
|
if (options.ownerEmail !== void 0)
|
|
3423
3425
|
body.owner_email = options.ownerEmail || null;
|
|
3424
3426
|
if (!Object.keys(body).length) {
|
|
3425
|
-
console.error("\u274C \u8BF7\u63D0\u4F9B\u81F3\u5C11\u4E00\u4E2A\u5B57\u6BB5\uFF1A--webhook-url \u6216 --owner-email");
|
|
3426
|
-
process.exit(
|
|
3427
|
+
console.error("\u274C \u8BF7\u63D0\u4F9B\u81F3\u5C11\u4E00\u4E2A\u5B57\u6BB5\uFF1A--display-name\u3001--webhook-url \u6216 --owner-email");
|
|
3428
|
+
process.exit(EXIT.VALIDATION);
|
|
3427
3429
|
}
|
|
3428
3430
|
const res = await fetchWithRetry(`${BASE_URL}/api/auth/me`, {
|
|
3429
3431
|
method: "PATCH",
|
|
@@ -3437,6 +3439,8 @@ async function profileUpdateAction(options) {
|
|
|
3437
3439
|
return;
|
|
3438
3440
|
}
|
|
3439
3441
|
console.log("\u2705 \u4E2A\u4EBA\u8D44\u6599\u5DF2\u66F4\u65B0");
|
|
3442
|
+
if (body.display_name !== void 0)
|
|
3443
|
+
console.log(` \u663E\u793A\u540D\u79F0: ${body.display_name || "(\u5DF2\u6E05\u9664)"}`);
|
|
3440
3444
|
if (body.webhook_url !== void 0)
|
|
3441
3445
|
console.log(` Webhook URL: ${body.webhook_url || "(\u5DF2\u6E05\u9664)"}`);
|
|
3442
3446
|
if (body.owner_email !== void 0)
|
|
@@ -3507,14 +3511,14 @@ async function validateAction(dir, options) {
|
|
|
3507
3511
|
const target = path5.resolve(dir || ".");
|
|
3508
3512
|
if (!fs5.existsSync(target) || !fs5.statSync(target).isDirectory()) {
|
|
3509
3513
|
console.error(`\u274C \u76EE\u5F55\u4E0D\u5B58\u5728: ${target}`);
|
|
3510
|
-
process.exit(
|
|
3514
|
+
process.exit(EXIT2.NOT_FOUND);
|
|
3511
3515
|
}
|
|
3512
3516
|
const { errors, warnings } = validateSkillDir2(target);
|
|
3513
3517
|
const passed = errors.length === 0;
|
|
3514
3518
|
if (options.json) {
|
|
3515
3519
|
console.log(JSON.stringify({ path: target, passed, errors, warnings }, null, 2));
|
|
3516
3520
|
if (!passed)
|
|
3517
|
-
process.exit(
|
|
3521
|
+
process.exit(EXIT2.VALIDATION);
|
|
3518
3522
|
return;
|
|
3519
3523
|
}
|
|
3520
3524
|
console.log(`\u{1F50D} \u6821\u9A8C\u76EE\u5F55: ${target}
|
|
@@ -3538,7 +3542,7 @@ async function validateAction(dir, options) {
|
|
|
3538
3542
|
} else {
|
|
3539
3543
|
console.log(`
|
|
3540
3544
|
\u274C \u6821\u9A8C\u5931\u8D25\uFF08${errors.length} \u4E2A\u9519\u8BEF\uFF09`);
|
|
3541
|
-
process.exit(
|
|
3545
|
+
process.exit(EXIT2.VALIDATION);
|
|
3542
3546
|
}
|
|
3543
3547
|
}
|
|
3544
3548
|
|
|
@@ -3585,14 +3589,14 @@ var PKG_TEMPLATE = (name) => JSON.stringify({
|
|
|
3585
3589
|
async function skillInitAction(name, options) {
|
|
3586
3590
|
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
3587
3591
|
console.error("\u274C \u6280\u80FD\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\uFF0C\u4F8B\u5982: my-skill");
|
|
3588
|
-
process.exit(
|
|
3592
|
+
process.exit(EXIT2.VALIDATION);
|
|
3589
3593
|
}
|
|
3590
3594
|
const dir = path6.resolve(name);
|
|
3591
3595
|
if (fs6.existsSync(dir)) {
|
|
3592
3596
|
if (!options.force) {
|
|
3593
3597
|
console.error(`\u274C \u76EE\u5F55\u5DF2\u5B58\u5728: ${dir}
|
|
3594
3598
|
\u4F7F\u7528 --force \u8986\u76D6`);
|
|
3595
|
-
process.exit(
|
|
3599
|
+
process.exit(EXIT2.VALIDATION);
|
|
3596
3600
|
}
|
|
3597
3601
|
} else {
|
|
3598
3602
|
fs6.mkdirSync(dir, { recursive: true });
|
|
@@ -3731,7 +3735,7 @@ async function skillUseAction(id, options) {
|
|
|
3731
3735
|
async function skillSearchAction(keyword, options) {
|
|
3732
3736
|
if (!keyword?.trim()) {
|
|
3733
3737
|
console.error("\u274C \u8BF7\u63D0\u4F9B\u641C\u7D22\u5173\u952E\u8BCD");
|
|
3734
|
-
process.exit(
|
|
3738
|
+
process.exit(EXIT2.VALIDATION);
|
|
3735
3739
|
}
|
|
3736
3740
|
const apiKey = requireApiKey();
|
|
3737
3741
|
const parsed = parseInt(options.limit || "20", 10);
|
|
@@ -4756,7 +4760,7 @@ async function radioUploadAction(stationId, filePath, options) {
|
|
|
4756
4760
|
|
|
4757
4761
|
// src/index.ts
|
|
4758
4762
|
var program2 = new Command();
|
|
4759
|
-
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.
|
|
4763
|
+
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.8.0");
|
|
4760
4764
|
program2.command("login").description("\u767B\u5F55 EasyClaw Link\uFF0C\u4FDD\u5B58 API Key \u5230\u672C\u5730").action(loginAction);
|
|
4761
4765
|
program2.command("logout").description("\u9000\u51FA\u767B\u5F55\uFF0C\u6E05\u9664\u672C\u5730 API Key").action(logoutAction);
|
|
4762
4766
|
program2.command("whoami").description("\u663E\u793A\u5F53\u524D\u767B\u5F55\u8D26\u53F7\u4FE1\u606F").option("--json", "JSON \u8F93\u51FA").action(() => whoamiAction());
|
|
@@ -4765,7 +4769,7 @@ program2.command("unread").description("\u67E5\u770B\u672A\u8BFB\u6D88\u606F/\u9
|
|
|
4765
4769
|
program2.command("stats").description("\u67E5\u770B\u5E73\u53F0\u7EDF\u8BA1\u6570\u636E").option("--json", "JSON \u8F93\u51FA").action((o) => statsAction(o));
|
|
4766
4770
|
program2.command("leaderboard").description("\u58F0\u671B\u6392\u884C\u699C").option("--json", "JSON \u8F93\u51FA").option("--limit <n>", "\u6761\u6570\u9650\u5236", "20").action((o) => leaderboardAction(o));
|
|
4767
4771
|
var profileCmd = program2.command("profile").description("\u4E2A\u4EBA\u8D44\u6599\u64CD\u4F5C");
|
|
4768
|
-
profileCmd.command("update").description("\u66F4\u65B0\u4E2A\u4EBA\u8D44\u6599").option("--webhook-url <url>", "Webhook \u5730\u5740\uFF08https://...\uFF0C\u7A7A\u5B57\u7B26\u4E32\u53EF\u6E05\u9664\uFF09").option("--owner-email <email>", "\u90AE\u7BB1\u5730\u5740\uFF08\u7A7A\u5B57\u7B26\u4E32\u53EF\u6E05\u9664\uFF09").option("--json", "JSON \u8F93\u51FA").action((o) => profileUpdateAction(o));
|
|
4772
|
+
profileCmd.command("update").description("\u66F4\u65B0\u4E2A\u4EBA\u8D44\u6599").option("--display-name <name>", "\u663E\u793A\u540D\u79F0\uFF08\u6700\u591A50\u5B57\uFF0C\u7A7A\u5B57\u7B26\u4E32\u53EF\u6E05\u9664\uFF09").option("--webhook-url <url>", "Webhook \u5730\u5740\uFF08https://...\uFF0C\u7A7A\u5B57\u7B26\u4E32\u53EF\u6E05\u9664\uFF09").option("--owner-email <email>", "\u90AE\u7BB1\u5730\u5740\uFF08\u7A7A\u5B57\u7B26\u4E32\u53EF\u6E05\u9664\uFF09").option("--json", "JSON \u8F93\u51FA").action((o) => profileUpdateAction(o));
|
|
4769
4773
|
var notifCmd = program2.command("notifications").description("\u67E5\u770B\u548C\u7BA1\u7406\u901A\u77E5");
|
|
4770
4774
|
notifCmd.command("list", { isDefault: true }).description("\u5217\u51FA\u901A\u77E5").option("--json", "JSON \u8F93\u51FA").option("--limit <n>", "\u6761\u6570\u9650\u5236", "20").action((o) => notificationsAction(o));
|
|
4771
4775
|
notifCmd.command("read").description("\u6807\u8BB0\u6240\u6709\u901A\u77E5\u4E3A\u5DF2\u8BFB").option("--json", "JSON \u8F93\u51FA").action((o) => notificationsReadAction(o));
|