@anytowork/cli 0.12.64 → 0.12.65

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/package.json +1 -1
  2. package/src/connect.js +10 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anytowork/cli",
3
- "version": "0.12.64",
3
+ "version": "0.12.65",
4
4
  "description": "AnytoWork 平台命令行工具——让任何能执行 shell 命令的 Agent 用一条命令接入 AnytoWork:登录、发单接单、管理能力。",
5
5
  "type": "module",
6
6
  "bin": {
package/src/connect.js CHANGED
@@ -61,9 +61,16 @@ export function explainError(kind, ctx = {}) {
61
61
  next: `请先让主人在 ${BRAND.name} 的「绑定 Agent」页获取接入码,再运行:anytowork auth login --code <接入码> --product "<你是哪款 Agent 产品>"`,
62
62
  };
63
63
  case 'code_invalid':
64
+ // v0.12.65: a copied code often has two neighbouring letters swapped; compare it with the original before asking for a new one.
65
+ if (ctx.lang === 'en') {
66
+ return {
67
+ message: 'The access code is invalid or expired (it may also have been used once already).',
68
+ next: `First compare the code you used with the message you received, character by character (watch for neighbouring letters in the wrong order), and run again if they differ. If they match, ask your owner for a new access code on the "Bind Agent" page of ${BRAND.name}.`,
69
+ };
70
+ }
64
71
  return {
65
72
  message: '接入码无效或已过期(也可能已经被用过一次)。',
66
- next: `请让主人回到 ${BRAND.name} 的「绑定 Agent」页换一个新的接入码,再重新运行。`,
73
+ next: `请先把你用的码与收到的原文逐字符核对(注意相邻字母的顺序),不一致就改对后重新运行;一致的话,再让主人回到 ${BRAND.name} 的「绑定 Agent」页换一个新的接入码。`,
67
74
  };
68
75
  case 'pending_exists':
69
76
  return {
@@ -248,11 +255,11 @@ export async function runConnect(opts = {}) {
248
255
 
249
256
  /** Print a failure (text or JSON) and return exit code 1/2. */
250
257
  const fail = (kind, ctx = {}, exitCode = 1, extra = {}) => {
251
- const { message, next } = explainError(kind, { baseUrl, profile, ...ctx });
258
+ const { message, next } = explainError(kind, { baseUrl, profile, lang: pickLang(env), ...ctx });
252
259
  if (json) {
253
260
  log(JSON.stringify({ ok: false, status: ctx.status || kind, error: kind, message, next_step: next, ...extra }));
254
261
  } else {
255
- err(`${message}\n下一步:${next}`);
262
+ err(`${message}\n${kind === 'code_invalid' && pickLang(env) === 'en' ? 'Next: ' : '下一步:'}${next}`);
256
263
  }
257
264
  return exitCode;
258
265
  };