@agentchatme/openclaw 0.7.82111 → 0.7.8211111

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.
@@ -119,7 +119,7 @@ function classifyNetworkError(err3) {
119
119
  }
120
120
 
121
121
  // src/version.ts
122
- var PACKAGE_VERSION = "0.7.82111";
122
+ var PACKAGE_VERSION = "0.7.8211111";
123
123
 
124
124
  // src/client-identity.ts
125
125
  var AGENTCHAT_CLIENT_NAME = "openclaw";
@@ -240,8 +240,10 @@ async function registerAgentStart(input, opts = {}) {
240
240
  if (res.status === 400 && code === "INVALID_HANDLE") return { ok: false, reason: "invalid-handle", message, status: 400 };
241
241
  if (res.status === 400 && code === "VALIDATION_ERROR") return { ok: false, reason: "validation", message, status: 400 };
242
242
  if (res.status === 409 && code === "HANDLE_TAKEN") return { ok: false, reason: "handle-taken", message, status: 409 };
243
- if (res.status === 409 && code === "EMAIL_TAKEN") return { ok: false, reason: "email-taken", message, status: 409 };
244
- if (res.status === 409 && code === "EMAIL_EXHAUSTED") return { ok: false, reason: "email-exhausted", message, status: 409 };
243
+ const emailPolicy = res.status === 409 ? classifyEmailPolicyRejection(code) : void 0;
244
+ if (emailPolicy) {
245
+ return { ok: false, reason: emailPolicy, message, status: 409, limit: readPolicyLimit(body.details) };
246
+ }
245
247
  if (res.status === 429) {
246
248
  return {
247
249
  ok: false,
@@ -286,12 +288,84 @@ async function registerAgentVerify(input, opts = {}) {
286
288
  if (res.status === 400 && code === "INVALID_CODE") return { ok: false, reason: "invalid-code", message, status: 400 };
287
289
  if (res.status === 400 && code === "VALIDATION_ERROR") return { ok: false, reason: "validation", message, status: 400 };
288
290
  if (res.status === 409 && code === "HANDLE_TAKEN") return { ok: false, reason: "handle-taken", message, status: 409 };
289
- if (res.status === 409 && code === "EMAIL_TAKEN") return { ok: false, reason: "email-taken", message, status: 409 };
291
+ const emailPolicy = res.status === 409 ? classifyEmailPolicyRejection(code) : void 0;
292
+ if (emailPolicy) {
293
+ return { ok: false, reason: emailPolicy, message, status: 409, limit: readPolicyLimit(body.details) };
294
+ }
295
+ if (res.status === 429) {
296
+ return { ok: false, reason: "rate-limited", message, status: 429, retryAfterSeconds: res.retryAfterSeconds };
297
+ }
298
+ return { ok: false, reason: "server-error", status: res.status, message };
299
+ }
300
+ async function recoverAgentStart(input, opts = {}) {
301
+ const res = await post("/v1/agents/recover", { email: input.email, handle: input.handle }, opts);
302
+ if (res.kind === "network") return { ok: false, reason: "network-error", message: res.message };
303
+ if (res.kind === "timeout") return { ok: false, reason: "network-error", message: "request timed out" };
304
+ const body = res.body ?? {};
305
+ const message = typeof body.message === "string" ? body.message : `status ${res.status}`;
306
+ if (res.status === 200) {
307
+ if (typeof body.pending_id !== "string") {
308
+ return {
309
+ ok: false,
310
+ reason: "unexpected-shape",
311
+ status: 200,
312
+ message: "AgentChat did not start a recovery (no pending_id in the response). Check that the email is the one this agent registered with."
313
+ };
314
+ }
315
+ return { ok: true, pendingId: body.pending_id, message };
316
+ }
317
+ const code = typeof body.code === "string" ? body.code : "";
318
+ if (res.status === 400 && code === "VALIDATION_ERROR") return { ok: false, reason: "validation", message, status: 400 };
319
+ if (res.status === 429) {
320
+ return { ok: false, reason: "rate-limited", message, status: 429, retryAfterSeconds: res.retryAfterSeconds };
321
+ }
322
+ return { ok: false, reason: "server-error", status: res.status, message };
323
+ }
324
+ async function recoverAgentVerify(input, opts = {}) {
325
+ const res = await post("/v1/agents/recover/verify", { pending_id: input.pendingId, code: input.code }, opts);
326
+ if (res.kind === "network") return { ok: false, reason: "network-error", message: res.message };
327
+ if (res.kind === "timeout") return { ok: false, reason: "network-error", message: "request timed out" };
328
+ const body = res.body ?? {};
329
+ if (res.status === 200) {
330
+ if (typeof body.api_key !== "string" || typeof body.handle !== "string") {
331
+ return {
332
+ ok: false,
333
+ reason: "unexpected-shape",
334
+ status: 200,
335
+ message: "AgentChat /agents/recover/verify returned an unrecognized shape"
336
+ };
337
+ }
338
+ return { ok: true, apiKey: body.api_key, handle: body.handle };
339
+ }
340
+ const code = typeof body.code === "string" ? body.code : "";
341
+ const message = typeof body.message === "string" ? body.message : `status ${res.status}`;
342
+ if (res.status === 400 && code === "EXPIRED") return { ok: false, reason: "expired", message, status: 400 };
343
+ if (res.status === 400 && code === "INVALID_CODE") return { ok: false, reason: "invalid-code", message, status: 400 };
344
+ if (res.status === 400 && code === "VALIDATION_ERROR") return { ok: false, reason: "validation", message, status: 400 };
345
+ if (res.status === 409 && code === "HANDLE_REQUIRED") {
346
+ return { ok: false, reason: "handle-required", message, status: 409, handles: readHandleList(body.details) };
347
+ }
290
348
  if (res.status === 429) {
291
349
  return { ok: false, reason: "rate-limited", message, status: 429, retryAfterSeconds: res.retryAfterSeconds };
292
350
  }
293
351
  return { ok: false, reason: "server-error", status: res.status, message };
294
352
  }
353
+ function classifyEmailPolicyRejection(code) {
354
+ if (code === "EMAIL_LIMIT_REACHED" || code === "EMAIL_TAKEN") return "email-limit-reached";
355
+ if (code === "EMAIL_EXHAUSTED") return "email-exhausted";
356
+ return void 0;
357
+ }
358
+ function readPolicyLimit(details) {
359
+ if (!details || typeof details !== "object") return void 0;
360
+ const limit = details.limit;
361
+ return typeof limit === "number" && Number.isInteger(limit) && limit > 0 ? limit : void 0;
362
+ }
363
+ function readHandleList(details) {
364
+ if (!details || typeof details !== "object") return [];
365
+ const handles = details.handles;
366
+ if (!Array.isArray(handles)) return [];
367
+ return handles.filter((h) => typeof h === "string" && h.length > 0);
368
+ }
295
369
  async function post(path3, body, opts) {
296
370
  const base = (opts.apiBase ?? DEFAULT_API_BASE).replace(/\/+$/, "");
297
371
  const url = `${base}${path3}`;
@@ -339,9 +413,9 @@ function hasConfiguredKey(cfg, accountId) {
339
413
  return isApiKeyPresent(readAgentchatConfigField(cfg, accountId, "apiKey"));
340
414
  }
341
415
  var MAX_START_RETRIES = 5;
342
- async function promptEmail(prompter) {
416
+ async function promptEmail(prompter, opts = {}) {
343
417
  return (await prompter.text({
344
- message: "Email \u2014 receives a 6-digit verification code",
418
+ message: opts.message ?? "Email \u2014 receives a 6-digit verification code",
345
419
  placeholder: "you@example.com",
346
420
  validate: (value) => {
347
421
  const trimmed = value.trim();
@@ -351,10 +425,11 @@ async function promptEmail(prompter) {
351
425
  }
352
426
  })).trim();
353
427
  }
354
- async function promptHandle(prompter) {
428
+ async function promptHandle(prompter, opts = {}) {
355
429
  return (await prompter.text({
356
- message: "Choose a handle (your @name on AgentChat)",
430
+ message: opts.message ?? "Choose a handle (your @name on AgentChat)",
357
431
  placeholder: "3\u201330 chars, lowercase a-z, 0-9, hyphens, starts with a letter",
432
+ ...opts.initialValue ? { initialValue: opts.initialValue } : {},
358
433
  validate: (value) => {
359
434
  const trimmed = value.trim();
360
435
  if (!trimmed) return "Handle is required";
@@ -414,11 +489,37 @@ async function runChangeApiBaseFlow(params) {
414
489
  await prompter.note(`API base set to ${input}`, "Updated");
415
490
  return { cfg: patched };
416
491
  }
492
+ function describeEmailPolicyRejection(email, result) {
493
+ if (result.limit === void 0) return result.message;
494
+ return result.reason === "email-limit-reached" ? `${email} already backs ${result.limit} active agents \u2014 the per-email limit.` : `${email} has used all ${result.limit} of its lifetime account registrations.`;
495
+ }
496
+ async function promptEmailPolicyChoice(prompter, email, result) {
497
+ return prompter.select({
498
+ message: `${describeEmailPolicyRejection(email, result)} What next?`,
499
+ options: [
500
+ {
501
+ value: "retry",
502
+ label: "Use a different email address",
503
+ hint: "a +alias like you+agent2@example.com counts as a separate email"
504
+ },
505
+ {
506
+ value: "recover",
507
+ label: "Recover the API key of an agent this email already backs",
508
+ hint: "needs that agent\u2019s handle \u2014 a code goes to this email"
509
+ },
510
+ { value: "paste", label: "Paste a key from an existing agent" },
511
+ { value: "cancel", label: "Cancel registration" }
512
+ ],
513
+ initialValue: "retry"
514
+ });
515
+ }
417
516
  async function runRegisterFlow(params) {
418
517
  const { cfg, accountId, prompter, apiBase } = params;
419
518
  await prompter.note(
420
519
  [
421
520
  "Registration mints a new AgentChat agent identity tied to your email.",
521
+ "One email can back several agents (the server enforces the limit);",
522
+ "each one registers and verifies separately.",
422
523
  "You will receive a 6-digit code to verify \u2014 check your inbox (and spam)."
423
524
  ].join("\n"),
424
525
  "AgentChat: register a new agent"
@@ -463,36 +564,15 @@ async function runRegisterFlow(params) {
463
564
  handle = await promptHandle(prompter);
464
565
  continue;
465
566
  }
466
- case "email-taken": {
467
- const choice = await prompter.select({
468
- message: `${email} is already registered as an AgentChat agent. What would you like to do?`,
469
- options: [
470
- {
471
- value: "paste",
472
- label: "Paste the existing API key for this agent",
473
- hint: "recommended if you own the account"
474
- },
475
- { value: "retry", label: "Use a different email address" },
476
- { value: "cancel", label: "Cancel registration" }
477
- ],
478
- initialValue: "paste"
479
- });
480
- if (choice === "paste") return "user-chose-paste";
481
- if (choice === "cancel") return "abort";
482
- email = await promptEmail(prompter);
483
- continue;
484
- }
567
+ case "email-limit-reached":
485
568
  case "email-exhausted": {
486
- const choice = await prompter.select({
487
- message: `${email} has reached the per-email agent quota. What next?`,
488
- options: [
489
- { value: "retry", label: "Use a different email address" },
490
- { value: "paste", label: "Paste a key from an existing agent" },
491
- { value: "cancel", label: "Cancel registration" }
492
- ],
493
- initialValue: "retry"
569
+ const choice = await promptEmailPolicyChoice(prompter, email, {
570
+ reason: startResult.reason,
571
+ limit: startResult.limit,
572
+ message: startResult.message
494
573
  });
495
574
  if (choice === "paste") return "user-chose-paste";
575
+ if (choice === "recover") return "user-chose-recover";
496
576
  if (choice === "cancel") return "abort";
497
577
  email = await promptEmail(prompter);
498
578
  continue;
@@ -598,10 +678,10 @@ function describeRegisterStartError(result) {
598
678
  return "That handle is not acceptable. Try a different one (3\u201330 chars \u2014 lowercase letters/digits/hyphens; must start with a letter).";
599
679
  case "handle-taken":
600
680
  return "That handle is already taken. Try a different one.";
601
- case "email-taken":
602
- return "That email is already registered as an agent. Paste the existing key instead, or use a different email.";
681
+ case "email-limit-reached":
682
+ return `${result.limit === void 0 ? result.message : `This email already backs ${result.limit} active agents \u2014 the per-email limit.`} Use a different email (a +alias works), recover a key for one of its agents, or paste an existing key.`;
603
683
  case "email-exhausted":
604
- return "This email has reached the agent quota. Use a different email, or paste a key from an existing agent.";
684
+ return `${result.limit === void 0 ? result.message : `This email has used all ${result.limit} of its lifetime account registrations.`} Use a different email (a +alias works), or paste a key from an existing agent.`;
605
685
  case "rate-limited": {
606
686
  const wait = result.retryAfterSeconds ? ` Try again in ${result.retryAfterSeconds}s.` : "";
607
687
  return `Rate limited.${wait}`;
@@ -623,8 +703,158 @@ function describeRegisterVerifyError(result) {
623
703
  return "Too many incorrect codes. Restart the wizard to receive a new one.";
624
704
  case "handle-taken":
625
705
  return "Your chosen handle was claimed by another registration in the meantime. Restart with a different handle.";
626
- case "email-taken":
627
- return "This email is already registered. Paste the existing key instead.";
706
+ case "email-limit-reached":
707
+ return `${result.limit === void 0 ? result.message : `This email reached its limit of ${result.limit} active agents while you were verifying.`} Restart with a different email (a +alias works), or paste an existing key.`;
708
+ case "email-exhausted":
709
+ return `${result.limit === void 0 ? result.message : `This email used all ${result.limit} of its lifetime account registrations while you were verifying.`} Restart with a different email (a +alias works), or paste an existing key.`;
710
+ case "rate-limited": {
711
+ const wait = result.retryAfterSeconds ? ` Try again in ${result.retryAfterSeconds}s.` : "";
712
+ return `Rate limited.${wait}`;
713
+ }
714
+ case "network-error":
715
+ case "server-error":
716
+ case "unexpected-shape":
717
+ case "validation":
718
+ default:
719
+ return result.message;
720
+ }
721
+ }
722
+ async function runRecoverFlow(params) {
723
+ const { cfg, accountId, prompter, apiBase } = params;
724
+ const storedHandle = readAgentchatConfigField(cfg, accountId, "agentHandle");
725
+ const defaultHandle = storedHandle && isValidHandleShape(storedHandle) ? storedHandle : void 0;
726
+ await prompter.note(
727
+ [
728
+ "Recovery re-issues the API key for ONE agent \u2014 the handle you name below.",
729
+ "You need that handle and the email it registered with; a 6-digit code",
730
+ "goes to that email. The old key stops working the moment the new one",
731
+ "is minted.",
732
+ ...defaultHandle ? ["", `@${defaultHandle} is configured here \u2014 press Enter at the handle prompt to recover it.`] : []
733
+ ].join("\n"),
734
+ "AgentChat: recover a lost API key"
735
+ );
736
+ const handle = await promptHandle(prompter, {
737
+ message: "Handle of the agent to recover (its @name on AgentChat)",
738
+ ...defaultHandle ? { initialValue: defaultHandle } : {}
739
+ });
740
+ const email = await promptEmail(prompter, {
741
+ message: `Email @${handle} registered with \u2014 receives a 6-digit recovery code`
742
+ });
743
+ const startSpinner = prompter.progress("Requesting recovery code\u2026");
744
+ let startResult;
745
+ try {
746
+ startResult = await recoverAgentStart({ email, handle }, { apiBase });
747
+ } catch (err3) {
748
+ startSpinner.stop("Could not reach AgentChat");
749
+ await prompter.note(
750
+ `${err3 instanceof Error ? err3.message : String(err3)}. Try again when the network is available, or paste an existing key instead.`,
751
+ "Recovery failed"
752
+ );
753
+ return "abort";
754
+ }
755
+ if (!startResult.ok) {
756
+ startSpinner.stop("Recovery rejected");
757
+ await prompter.note(describeRecoverStartError(startResult), "Could not start recovery");
758
+ return "abort";
759
+ }
760
+ startSpinner.stop(startResult.message);
761
+ const maxCodeAttempts = 3;
762
+ let verifyResult = null;
763
+ for (let attempt = 1; attempt <= maxCodeAttempts; attempt += 1) {
764
+ const code = (await prompter.text({
765
+ message: attempt === 1 ? `Enter the 6-digit recovery code (check ${email}, including spam)` : `Recovery code (attempt ${attempt}/${maxCodeAttempts})`,
766
+ placeholder: "123456",
767
+ validate: (value) => {
768
+ const trimmed = value.trim();
769
+ if (!trimmed) return "Code is required";
770
+ if (!OTP_PATTERN.test(trimmed)) return "Code is 6 digits";
771
+ return void 0;
772
+ }
773
+ })).trim();
774
+ const verifySpinner = prompter.progress("Verifying code\u2026");
775
+ try {
776
+ verifyResult = await recoverAgentVerify({ pendingId: startResult.pendingId, code }, { apiBase });
777
+ } catch (err3) {
778
+ verifySpinner.stop("Could not reach AgentChat");
779
+ await prompter.note(
780
+ `${err3 instanceof Error ? err3.message : String(err3)}. Try again, or paste an existing key instead.`,
781
+ "Recovery failed"
782
+ );
783
+ return "abort";
784
+ }
785
+ if (verifyResult.ok) {
786
+ verifySpinner.stop(`Recovered @${verifyResult.handle}`);
787
+ break;
788
+ }
789
+ verifySpinner.stop("Verification failed");
790
+ if (verifyResult.reason === "invalid-code" && attempt < maxCodeAttempts) {
791
+ await prompter.note(
792
+ "That code did not match. Check your email and try again \u2014 if no code arrived, the handle and email may not belong to the same agent.",
793
+ "Invalid recovery code"
794
+ );
795
+ continue;
796
+ }
797
+ await prompter.note(describeRecoverVerifyError(verifyResult), "Recovery failed");
798
+ return "abort";
799
+ }
800
+ if (!verifyResult || !verifyResult.ok) {
801
+ await prompter.note(
802
+ "Too many incorrect codes. Restart the wizard to request a new one \u2014 and double-check the handle and email belong to the same agent.",
803
+ "Recovery failed"
804
+ );
805
+ return "abort";
806
+ }
807
+ const patch = { apiKey: verifyResult.apiKey };
808
+ if (isValidHandleShape(verifyResult.handle)) {
809
+ patch.agentHandle = verifyResult.handle;
810
+ }
811
+ const nextCfg = applyAgentchatAccountPatch(cfg, accountId, patch);
812
+ await prompter.note(
813
+ [
814
+ `Handle: @${verifyResult.handle}`,
815
+ `API key: ${redactKey(verifyResult.apiKey)} (saved to your OpenClaw config)`,
816
+ "",
817
+ "The previous key for this agent has been revoked."
818
+ ].join("\n"),
819
+ "AgentChat API key recovered"
820
+ );
821
+ return {
822
+ cfg: nextCfg,
823
+ credentialValues: {
824
+ token: verifyResult.apiKey,
825
+ [JUST_REGISTERED_SENTINEL]: "1"
826
+ }
827
+ };
828
+ }
829
+ function describeRecoverStartError(result) {
830
+ switch (result.reason) {
831
+ case "rate-limited": {
832
+ const wait = result.retryAfterSeconds ? ` Try again in ${result.retryAfterSeconds}s.` : "";
833
+ return `Too many recovery attempts from this network.${wait}`;
834
+ }
835
+ case "validation":
836
+ return `AgentChat rejected the request: ${result.message}`;
837
+ case "network-error":
838
+ case "server-error":
839
+ case "unexpected-shape":
840
+ default:
841
+ return result.message;
842
+ }
843
+ }
844
+ function describeRecoverVerifyError(result) {
845
+ switch (result.reason) {
846
+ case "expired":
847
+ return "This recovery code expired. Restart the wizard to request a new one.";
848
+ case "invalid-code":
849
+ return "Too many incorrect codes. Restart the wizard to request a new one.";
850
+ case "handle-required": {
851
+ const handles = result.handles ?? [];
852
+ const list = handles.length > 0 ? `
853
+
854
+ Agents on this email:
855
+ ${handles.map((h) => ` @${h}`).join("\n")}` : "";
856
+ return `This email backs more than one agent. Run recovery again and enter the handle you want to recover.${list}`;
857
+ }
628
858
  case "rate-limited": {
629
859
  const wait = result.retryAfterSeconds ? ` Try again in ${result.retryAfterSeconds}s.` : "";
630
860
  return `Rate limited.${wait}`;
@@ -672,7 +902,7 @@ var agentchatSetupWizard = {
672
902
  resolveStatusLines: ({ cfg, accountId, configured }) => {
673
903
  const id = accountId ?? "default";
674
904
  if (!configured) {
675
- return ["AgentChat: not configured \u2014 the wizard will register you or accept an existing key."];
905
+ return ["AgentChat: not configured \u2014 the wizard will register you, accept an existing key, or recover a lost one."];
676
906
  }
677
907
  const handle = readAgentchatConfigField(cfg, id, "agentHandle");
678
908
  return [`AgentChat: configured${handle ? ` (@${handle})` : ""}`];
@@ -684,8 +914,9 @@ var agentchatSetupWizard = {
684
914
  "AgentChat is a messaging platform for AI agents \u2014 direct messages,",
685
915
  "groups, presence, attachments. Registration is free.",
686
916
  "",
687
- "This wizard will either mint a new account via email OTP, or accept",
688
- "an existing API key \u2014 your choice in the next prompt."
917
+ "This wizard will mint a new account via email OTP, accept an existing",
918
+ "API key, or recover a lost key (handle + email OTP) \u2014 your choice in",
919
+ "the next prompt."
689
920
  ]
690
921
  },
691
922
  prepare: async ({ cfg, accountId, credentialValues, prompter }) => {
@@ -706,7 +937,7 @@ var agentchatSetupWizard = {
706
937
  {
707
938
  value: "replace-key",
708
939
  label: "Replace the API key",
709
- hint: "paste a new key, or register a new agent"
940
+ hint: "paste a new key, register a new agent, or recover a lost key"
710
941
  }
711
942
  ],
712
943
  initialValue: "keep"
@@ -728,6 +959,11 @@ var agentchatSetupWizard = {
728
959
  value: "paste",
729
960
  label: "I already have an API key",
730
961
  hint: "paste ac_live_\u2026 on the next prompt"
962
+ },
963
+ {
964
+ value: "recover",
965
+ label: "Recover a lost API key (handle + email OTP)",
966
+ hint: "an agent exists but its key is gone \u2014 re-issue it"
731
967
  }
732
968
  ],
733
969
  initialValue: "register"
@@ -736,19 +972,32 @@ var agentchatSetupWizard = {
736
972
  return;
737
973
  }
738
974
  const apiBase = readAgentchatConfigField(cfg, accountId, "apiBase");
739
- try {
740
- const result = await runRegisterFlow({ cfg, accountId, prompter, apiBase });
741
- if (result === "abort") {
975
+ const recover = async () => {
976
+ try {
977
+ const result = await runRecoverFlow({ cfg, accountId, prompter, apiBase });
978
+ if (result === "abort") {
979
+ await prompter.note(
980
+ "Recovery was not completed. You can still paste an existing API key at the next prompt, or cancel the wizard.",
981
+ "Falling back to credential entry"
982
+ );
983
+ return;
984
+ }
985
+ return result;
986
+ } catch (err3) {
987
+ if (err3 instanceof WizardCancelledError) throw err3;
742
988
  await prompter.note(
743
- "Registration was not completed. You can still paste an existing API key at the next prompt, or cancel the wizard.",
744
- "Falling back to credential entry"
989
+ `${err3 instanceof Error ? err3.message : String(err3)}`,
990
+ "Recovery flow failed"
745
991
  );
746
992
  return;
747
993
  }
748
- if (result === "user-chose-paste") {
749
- return;
750
- }
751
- return result;
994
+ };
995
+ if (choice === "recover") {
996
+ return await recover();
997
+ }
998
+ let registerOutcome;
999
+ try {
1000
+ registerOutcome = await runRegisterFlow({ cfg, accountId, prompter, apiBase });
752
1001
  } catch (err3) {
753
1002
  if (err3 instanceof WizardCancelledError) throw err3;
754
1003
  await prompter.note(
@@ -757,6 +1006,20 @@ var agentchatSetupWizard = {
757
1006
  );
758
1007
  return;
759
1008
  }
1009
+ if (registerOutcome === "abort") {
1010
+ await prompter.note(
1011
+ "Registration was not completed. You can still paste an existing API key at the next prompt, or cancel the wizard.",
1012
+ "Falling back to credential entry"
1013
+ );
1014
+ return;
1015
+ }
1016
+ if (registerOutcome === "user-chose-paste") {
1017
+ return;
1018
+ }
1019
+ if (registerOutcome === "user-chose-recover") {
1020
+ return await recover();
1021
+ }
1022
+ return registerOutcome;
760
1023
  },
761
1024
  credentials: [
762
1025
  {
@@ -5094,7 +5357,7 @@ var uiHints = {
5094
5357
  label: "AgentChat API key",
5095
5358
  placeholder: "ac_live_...",
5096
5359
  sensitive: true,
5097
- help: "The setup wizard registers you via email OTP and mints a key \u2014 or paste an existing ac_live_\u2026 key."
5360
+ help: "The setup wizard registers you via email OTP and mints a key, recovers a lost key (handle + email OTP), or accepts an existing ac_live_\u2026 key."
5098
5361
  },
5099
5362
  apiBase: {
5100
5363
  label: "API base URL",
@@ -5205,7 +5468,7 @@ var agentchatPlugin = {
5205
5468
  */
5206
5469
  validateInput({ input }) {
5207
5470
  if (typeof input.token !== "string" || input.token.trim().length === 0) {
5208
- return "apiKey is required \u2014 pass via --token or run the register flow";
5471
+ return "apiKey is required \u2014 pass via --token, or run `openclaw channels add agentchat` to register a new agent or recover a lost key (handle + email OTP)";
5209
5472
  }
5210
5473
  if (input.token.length < MIN_API_KEY_LENGTH) {
5211
5474
  return `apiKey looks too short (got ${input.token.length} chars, expect \u2265${MIN_API_KEY_LENGTH})`;