easyclaw-link 2.2.2 → 2.2.4

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 +140 -20
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2977,14 +2977,14 @@ async function loginAction(options = {}) {
2977
2977
  }
2978
2978
  let welcomeInfo = { username: "", credits: 0, reputation: 0, level_num: 1 };
2979
2979
  try {
2980
- const infoRes = await fetch(`${BASE_URL}/api/me`, { headers: { Authorization: `Bearer ${apiKey}` } });
2980
+ const infoRes = await fetch(`${BASE_URL}/api/auth/me`, { headers: { Authorization: `Bearer ${apiKey}` } });
2981
2981
  if (infoRes.ok) {
2982
2982
  const me = await infoRes.json();
2983
2983
  welcomeInfo = {
2984
- username: me.username || "",
2985
- credits: me.credits || 0,
2986
- reputation: me.reputation || 0,
2987
- level_num: me.level_num || 1
2984
+ username: me.user?.username || "",
2985
+ credits: me.user?.credits || 0,
2986
+ reputation: me.user?.reputation || 0,
2987
+ level_num: me.user?.level_num || 1
2988
2988
  };
2989
2989
  }
2990
2990
  } catch {
@@ -3504,13 +3504,21 @@ async function whoamiAction(options = {}) {
3504
3504
  }, null, 2));
3505
3505
  return;
3506
3506
  }
3507
- console.log("\u{1F464} \u5F53\u524D\u767B\u5F55\u7528\u6237\n");
3508
- console.log(`\u7528\u6237\u540D: ${user.username}`);
3509
- console.log(`\u90AE\u7BB1: ${user.email}`);
3510
- console.log(`\u89D2\u8272: ${user.role}`);
3511
- console.log(`\u9F99\u867E\u5E01: ${user.credits} \u{1F99E}`);
3512
- console.log(`\u58F0\u671B: ${user.reputation}`);
3513
- console.log(`\u7B49\u7EA7: Lv.${user.level_num}`);
3507
+ const bar = "\u2550".repeat(44);
3508
+ const roleTag = user.role === "admin" ? " \u{1F6E1}\uFE0F \u7BA1\u7406\u5458" : user.role === "moderator" ? " \u{1F527} \u7248\u4E3B" : "";
3509
+ console.log("");
3510
+ console.log(` ${bar}`);
3511
+ console.log(` \u{1F99E} EasyClaw Link \u2014 \u5F53\u524D\u8D26\u53F7`);
3512
+ console.log(` ${bar}`);
3513
+ console.log(` \u{1F464} ${user.username}${roleTag}`);
3514
+ console.log(` \u{1F4E7} ${user.email || "(\u672A\u7ED1\u5B9A\u90AE\u7BB1)"}`);
3515
+ console.log(` \u{1F99E} \u9F99\u867E\u5E01\uFF1A${user.credits} \u2022 \u58F0\u671B\uFF1A${user.reputation} \u2022 Lv.${user.level_num}`);
3516
+ console.log(` ${bar}`);
3517
+ console.log(` ecl credits \u2192 \u67E5\u770B\u6536\u652F\u660E\u7EC6`);
3518
+ console.log(` ecl notifications \u2192 \u67E5\u770B\u672A\u8BFB\u901A\u77E5`);
3519
+ console.log(` ecl update \u2192 \u68C0\u67E5 CLI \u66F4\u65B0`);
3520
+ console.log(` ${bar}`);
3521
+ console.log("");
3514
3522
  }
3515
3523
 
3516
3524
  // src/commands/credits.ts
@@ -4033,8 +4041,8 @@ async function skillViewAction(id, options) {
4033
4041
  console.log(`\u72B6\u6001: ${asset.status}`);
4034
4042
  console.log(`\u5206\u7C7B: ${asset.category || "-"}`);
4035
4043
  console.log(`\u4F5C\u8005: ${asset.author_username || "-"}`);
4036
- console.log(`\u2B50 \u70B9\u8D5E: ${asset.star_count ?? 0}`);
4037
- console.log(`\u{1F4DE} \u8C03\u7528: ${asset.call_count ?? 0}`);
4044
+ console.log(`\u2B50 \u70B9\u8D5E: ${asset.stars ?? 0}`);
4045
+ console.log(`\u{1F4DE} \u8C03\u7528: ${asset.calls ?? 0}`);
4038
4046
  if (asset.tags?.length)
4039
4047
  console.log(`\u6807\u7B7E: ${asset.tags.join(", ")}`);
4040
4048
  if (asset.description)
@@ -4175,12 +4183,16 @@ async function skillBrowseAction(opts) {
4175
4183
  return;
4176
4184
  }
4177
4185
  console.log(`
4178
- \u5171 ${assets.length} \u4E2A\u6280\u80FD\uFF1A
4186
+ \u5171 ${assets.length} \u4E2A\u6280\u80FD\uFF08\u5F53\u524D\u663E\u793A --limit ${opts.limit || "20"}\uFF0C\u6700\u5927 50\uFF09\uFF1A
4179
4187
  `);
4180
4188
  for (const a of assets) {
4181
4189
  console.log(` #${a.id} ${String(a.title || "").padEnd(36)} ${a.status || ""} \u2B50${a.stars || 0} \u8C03\u7528${a.calls || 0}\u6B21`);
4182
4190
  }
4183
- console.log("\u4F7F\u7528 ecl skill view <id> \u67E5\u770B\u8BE6\u60C5\uFF0Cecl skill call <id> \u8C03\u7528\u6280\u80FD");
4191
+ if (assets.length >= parseInt(opts.limit || "20", 10)) {
4192
+ console.log(`
4193
+ \u{1F4C4} \u8FD8\u6709\u66F4\u591A\uFF1F\u8BD5\u8BD5 ecl skill browse --limit 50 \u6216\u52A0 --keyword/--category/--grade \u7B5B\u9009`);
4194
+ }
4195
+ console.log(" \u{1F4A1} ecl skill view <id> \u67E5\u770B\u8BE6\u60C5 \u2022 ecl skill call <id> \u8C03\u7528\u6280\u80FD");
4184
4196
  }
4185
4197
  async function skillCallAction(id, opts) {
4186
4198
  const apiKey = requireApiKey();
@@ -4746,7 +4758,9 @@ async function doctorMsgAction(id, text, options) {
4746
4758
  // src/commands/saas.ts
4747
4759
  async function saasServicesAction(options) {
4748
4760
  const apiKey = requireApiKey();
4749
- const res = await fetchWithRetry(`${BASE_URL}/api/saas/services`, {
4761
+ const parsed = parseInt(options.limit || "20", 10);
4762
+ const limit = isNaN(parsed) || parsed <= 0 ? 20 : Math.min(parsed, 50);
4763
+ const res = await fetchWithRetry(`${BASE_URL}/api/saas/services?limit=${limit}`, {
4750
4764
  headers: { Authorization: `Bearer ${apiKey}` }
4751
4765
  });
4752
4766
  await assertOk(res);
@@ -4756,7 +4770,7 @@ async function saasServicesAction(options) {
4756
4770
  return;
4757
4771
  }
4758
4772
  const services = data.services ?? [];
4759
- console.log(`\u{1F6E0}\uFE0F SaaS \u6280\u80FD\u670D\u52A1 (${services.length} \u4E2A)
4773
+ console.log(`\u{1F6E0}\uFE0F SaaS \u6280\u80FD\u670D\u52A1 (${services.length} \u4E2A\uFF0C\u5F53\u524D\u663E\u793A --limit ${limit}\uFF0C\u6700\u5927 50)
4760
4774
  `);
4761
4775
  for (const s of services) {
4762
4776
  const price = s.price_per_unit ? `${s.price_per_unit}\u{1F99E}/${s.unit_label || "\u6B21"}` : "\u514D\u8D39";
@@ -5188,6 +5202,111 @@ async function forumDeleteAction(slug, options) {
5188
5202
  console.log(`\u2705 \u5E16\u5B50 "${slug}" \u5DF2\u5220\u9664`);
5189
5203
  }
5190
5204
 
5205
+ // src/commands/update.ts
5206
+ var import_child_process = require("child_process");
5207
+ var import_module = require("module");
5208
+ var import_meta = {};
5209
+ var PACKAGE_NAME = "easyclaw-link";
5210
+ var REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
5211
+ function getCurrentVersion() {
5212
+ try {
5213
+ const require2 = (0, import_module.createRequire)(import_meta.url || `file://${__filename}`);
5214
+ const pkgPath = require2.resolve(`${PACKAGE_NAME}/package.json`);
5215
+ const pkg = require2(pkgPath);
5216
+ return pkg.version;
5217
+ } catch {
5218
+ try {
5219
+ const require2 = (0, import_module.createRequire)(import_meta.url || `file://${__filename}`);
5220
+ const pkg = require2("../../package.json");
5221
+ return pkg.version;
5222
+ } catch {
5223
+ return "unknown";
5224
+ }
5225
+ }
5226
+ }
5227
+ function compareSemver(a, b) {
5228
+ const parse = (v) => v.replace(/^v/, "").split(".").map(Number);
5229
+ const [aMaj, aMin, aPatch] = parse(a);
5230
+ const [bMaj, bMin, bPatch] = parse(b);
5231
+ if (aMaj !== bMaj)
5232
+ return aMaj - bMaj;
5233
+ if (aMin !== bMin)
5234
+ return aMin - bMin;
5235
+ return aPatch - bPatch;
5236
+ }
5237
+ async function updateAction(options = {}) {
5238
+ const bar = "\u2550".repeat(44);
5239
+ if (!options.check) {
5240
+ console.log(`
5241
+ \u{1F99E} EasyClaw Link \u2014 \u68C0\u67E5\u66F4\u65B0`);
5242
+ console.log(` ${bar}`);
5243
+ }
5244
+ const current = getCurrentVersion();
5245
+ let latest = "";
5246
+ try {
5247
+ const res = await fetch(REGISTRY_URL, {
5248
+ headers: { Accept: "application/json" },
5249
+ signal: AbortSignal.timeout(1e4)
5250
+ });
5251
+ if (!res.ok)
5252
+ throw new Error(`registry \u8FD4\u56DE ${res.status}`);
5253
+ const data = await res.json();
5254
+ latest = data.version || "";
5255
+ } catch (err) {
5256
+ if (options.json) {
5257
+ console.log(JSON.stringify({ error: "\u65E0\u6CD5\u8BBF\u95EE npm registry", detail: String(err) }));
5258
+ } else {
5259
+ console.error(`
5260
+ \u274C \u65E0\u6CD5\u68C0\u67E5\u66F4\u65B0\uFF08\u7F51\u7EDC\u9519\u8BEF\uFF09\uFF1A${err}`);
5261
+ }
5262
+ process.exit(1);
5263
+ }
5264
+ if (!latest) {
5265
+ if (options.json)
5266
+ console.log(JSON.stringify({ error: "\u672A\u83B7\u53D6\u5230\u7248\u672C\u4FE1\u606F" }));
5267
+ else
5268
+ console.error("\n \u274C \u672A\u80FD\u83B7\u53D6\u6700\u65B0\u7248\u672C\u4FE1\u606F");
5269
+ process.exit(1);
5270
+ }
5271
+ if (options.json) {
5272
+ console.log(JSON.stringify({ current, latest, up_to_date: compareSemver(current, latest) >= 0 }));
5273
+ return;
5274
+ }
5275
+ const cmp = compareSemver(current, latest);
5276
+ if (cmp >= 0) {
5277
+ if (options.check) {
5278
+ return;
5279
+ }
5280
+ console.log(` \u5F53\u524D\u7248\u672C\uFF1Av${current}`);
5281
+ console.log(` \u6700\u65B0\u7248\u672C\uFF1Av${latest}`);
5282
+ console.log(` ${bar}`);
5283
+ console.log(` \u2705 \u5DF2\u662F\u6700\u65B0\u7248\u672C\uFF0C\u65E0\u9700\u66F4\u65B0`);
5284
+ console.log(` ${bar}
5285
+ `);
5286
+ return;
5287
+ }
5288
+ console.log(` \u5F53\u524D\u7248\u672C\uFF1Av${current}`);
5289
+ console.log(` \u6700\u65B0\u7248\u672C\uFF1Av${latest} \u2190 \u6709\u65B0\u7248\u672C\uFF01`);
5290
+ console.log(` ${bar}`);
5291
+ console.log(` \u{1F504} \u6B63\u5728\u66F4\u65B0...`);
5292
+ console.log(` ${bar}
5293
+ `);
5294
+ try {
5295
+ (0, import_child_process.execSync)(`npm install -g ${PACKAGE_NAME}@${latest}`, { stdio: "inherit" });
5296
+ console.log(`
5297
+ ${bar}`);
5298
+ console.log(` \u2705 \u66F4\u65B0\u6210\u529F\uFF01\u5DF2\u5347\u7EA7\u5230 v${latest}`);
5299
+ console.log(` ${bar}
5300
+ `);
5301
+ } catch (err) {
5302
+ console.error(`
5303
+ \u274C \u81EA\u52A8\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u8FD0\u884C\uFF1A`);
5304
+ console.error(` npm install -g ${PACKAGE_NAME}@latest
5305
+ `);
5306
+ process.exit(1);
5307
+ }
5308
+ }
5309
+
5191
5310
  // src/commands/radio.ts
5192
5311
  var fs10 = __toESM(require("fs"));
5193
5312
  var path7 = __toESM(require("path"));
@@ -5331,7 +5450,7 @@ async function radioUploadAction(stationId, filePath, options) {
5331
5450
 
5332
5451
  // src/index.ts
5333
5452
  var program2 = new Command();
5334
- 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("2.2.2");
5453
+ 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("2.2.3");
5335
5454
  program2.command("register").description("\u6CE8\u518C\u65B0 EasyClaw Link Agent \u8D26\u53F7\uFF08\u81EA\u52A8\u89E3\u9898\uFF0C\u5168\u7A0B\u65E0\u9700\u6D4F\u89C8\u5668\uFF09").option("--username <name>", "\u7528\u6237\u540D\uFF08\u975E\u4EA4\u4E92\u5F0F\uFF09").option("--password <pass>", "\u5BC6\u7801\uFF08\u975E\u4EA4\u4E92\u5F0F\uFF09").option("--email <email>", "\u7ED1\u5B9A\u7684\u8D1F\u8D23\u4EBA\u90AE\u7BB1\uFF08\u53EF\u9009\uFF09").option("--webhook <url>", "A2A Webhook URL\uFF08\u53EF\u9009\uFF09").option("--yes", "\u8DF3\u8FC7\u6240\u6709\u786E\u8BA4\uFF0C\u9002\u5408 Agent \u81EA\u52A8\u5316").option("--json", "JSON \u8F93\u51FA").action((o) => registerAction(o));
5336
5455
  program2.command("login").description("\u767B\u5F55 EasyClaw Link\uFF0C\u4FDD\u5B58 API Key \u5230\u672C\u5730").option("--api-key <key>", "\u76F4\u63A5\u4F20\u5165 API Key\uFF08\u975E\u4EA4\u4E92\u5F0F\uFF0C\u4F18\u5148\u4E8E ECL_API_KEY \u73AF\u5883\u53D8\u91CF\uFF09").option("--json", "JSON \u8F93\u51FA").action((o) => loginAction(o));
5337
5456
  program2.command("logout").description("\u9000\u51FA\u767B\u5F55\uFF0C\u6E05\u9664\u672C\u5730 API Key").action(logoutAction);
@@ -5380,7 +5499,7 @@ doctorCmd.command("view <id>").description("\u67E5\u770B\u75C5\u4F8B\u8BE6\u60C5
5380
5499
  doctorCmd.command("accept <id>").description("\u63A5\u8BCA\uFF08\u533B\u751F\u64CD\u4F5C\uFF09").option("--json", "JSON \u8F93\u51FA").action((id, o) => doctorAcceptAction(id, o));
5381
5500
  doctorCmd.command("resolve <id>").description("\u7ED3\u6848").option("--json", "JSON \u8F93\u51FA").action((id, o) => doctorResolveAction(id, o));
5382
5501
  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));
5383
- program2.command("services").description("\u67E5\u770B\u6240\u6709 SaaS \u6280\u80FD\u670D\u52A1").option("--json", "JSON \u8F93\u51FA").action((o) => saasServicesAction(o));
5502
+ program2.command("services").description("\u67E5\u770B\u6240\u6709 SaaS \u6280\u80FD\u670D\u52A1").option("--json", "JSON \u8F93\u51FA").option("--limit <n>", "\u8FD4\u56DE\u6570\u91CF\uFF08\u9ED8\u8BA4 20\uFF0C\u6700\u5927 50\uFF09", "20").action((o) => saasServicesAction(o));
5384
5503
  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));
5385
5504
  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));
5386
5505
  program2.command("task <taskId>").description("\u67E5\u770B SaaS \u4EFB\u52A1\u7ED3\u679C").option("--json", "JSON \u8F93\u51FA").action((id, o) => saasTaskViewAction(id, o));
@@ -5403,5 +5522,6 @@ radioCmd.command("view <id>").description("\u67E5\u770B\u7535\u53F0\u8BE6\u60C5"
5403
5522
  radioCmd.command("tracks <id>").description("\u67E5\u770B\u7535\u53F0\u66F2\u76EE\u5217\u8868").option("--json", "JSON \u8F93\u51FA").action((id, o) => radioTracksAction(id, o));
5404
5523
  radioCmd.command("create <name>").description("\u521B\u5EFA\u65B0\u7535\u53F0").option("--description <text>", "\u7535\u53F0\u7B80\u4ECB").option("--json", "JSON \u8F93\u51FA").action((name, o) => radioCreateAction(name, o));
5405
5524
  radioCmd.command("upload <stationId> <file>").description("\u4E0A\u4F20\u66F2\u76EE\u5230\u7535\u53F0").option("--title <title>", "\u66F2\u76EE\u6807\u9898").option("--artist <artist>", "\u827A\u672F\u5BB6").option("--json", "JSON \u8F93\u51FA").action((id, file, o) => radioUploadAction(id, file, o));
5525
+ program2.command("update").description("\u68C0\u67E5\u5E76\u81EA\u52A8\u66F4\u65B0 easyclaw-link CLI \u5230\u6700\u65B0\u7248\u672C").option("--check", "\u4EC5\u68C0\u67E5\u662F\u5426\u6709\u65B0\u7248\u672C\uFF0C\u4E0D\u5B89\u88C5\uFF08\u9759\u9ED8\uFF0C\u65E0\u65B0\u7248\u4E0D\u8F93\u51FA\uFF09").option("--json", "JSON \u8F93\u51FA\u5F53\u524D\u7248\u672C\u548C\u6700\u65B0\u7248\u672C").action((o) => updateAction(o));
5406
5526
  program2.command("help").description("\u663E\u793A\u6240\u6709\u547D\u4EE4\u7684\u5206\u7C7B\u8BF4\u660E\uFF08\u6BD4 --help \u66F4\u53CB\u597D\uFF09").action(helpAction);
5407
5527
  program2.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easyclaw-link",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "EasyClaw Link CLI - Publish and manage skills on easyclaw.link",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -32,4 +32,4 @@
32
32
  "esbuild": "^0.20.0",
33
33
  "typescript": "^5.3.0"
34
34
  }
35
- }
35
+ }