@agentchatme/openclaw 0.7.8211 → 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.
package/dist/index.d.cts CHANGED
@@ -671,6 +671,8 @@ declare const AGENTCHAT_DEFAULT_ACCOUNT_ID = "default";
671
671
  * - verify an API key is live before finalizing setup (`validateApiKey`)
672
672
  * - drive the email-OTP self-registration flow for agents without a key yet
673
673
  * (`registerAgentStart` → `registerAgentVerify`)
674
+ * - drive the email-OTP recovery flow that re-issues a lost API key
675
+ * (`recoverAgentStart` → `recoverAgentVerify`)
674
676
  *
675
677
  * Why this lives separately from `outbound.ts`:
676
678
  * - `outbound.ts` is the hot-path message sender. It wants retries, a circuit
@@ -681,9 +683,26 @@ declare const AGENTCHAT_DEFAULT_ACCOUNT_ID = "default";
681
683
  * partial-config path during registration.
682
684
  *
683
685
  * The server endpoints this module targets are stable AgentChat REST calls:
684
- * - `GET /v1/agents/me` → 200 OK when the key authenticates
685
- * - `POST /v1/register` → 200 with `{ pending_id }`
686
- * - `POST /v1/register/verify` → 201 with `{ agent, api_key }` on success
686
+ * - `GET /v1/agents/me` → 200 OK when the key authenticates
687
+ * - `POST /v1/register` → 200 with `{ pending_id }`
688
+ * - `POST /v1/register/verify` → 201 with `{ agent, api_key }` on success
689
+ * - `POST /v1/agents/recover` → 200 with `{ pending_id, message }` — always,
690
+ * whether or not the email + handle match
691
+ * a live agent (no existence leak)
692
+ * - `POST /v1/agents/recover/verify` → 200 with `{ handle, api_key }` on success
693
+ *
694
+ * Registration and recovery deliberately bypass the `agentchatme` SDK: the
695
+ * SDK's `recover(email)` predates the handle + email recovery contract and
696
+ * has no way to send `handle`, and the pinned SDK floor cannot move until a
697
+ * compatible SDK is published. Owning these four calls here keeps the plugin
698
+ * on the current server contract regardless of which SDK version resolves.
699
+ *
700
+ * Per-email policy (server-enforced, the numbers live in the server's
701
+ * `agent_email_policy` row and are NOT hard-coded here): an email can back
702
+ * up to `max_active` live agents and `max_lifetime` registrations overall.
703
+ * The server quotes the number that applies in `details.limit`; every
704
+ * user-facing string built from these results must quote that value rather
705
+ * than assume one.
687
706
  *
688
707
  * All methods return strongly-typed result unions — setup UIs can `switch` on
689
708
  * the discriminant without guessing at HTTP status codes.
@@ -722,15 +741,36 @@ interface RegisterAgentStartInput {
722
741
  readonly displayName?: string;
723
742
  readonly description?: string;
724
743
  }
744
+ /**
745
+ * Per-email policy rejections, shared by `/register` and `/register/verify`
746
+ * (the pre-check fires at start; the DB trigger is the race-proof net at
747
+ * verify time, and the server maps both to the same 409 shapes).
748
+ *
749
+ * - `email-limit-reached` — the email already backs the maximum number of
750
+ * live agents. Also what the retired `EMAIL_TAKEN` code from a server
751
+ * that predates the multi-agent policy collapses into: that server
752
+ * allowed exactly one live agent per email, so "taken" means "at its
753
+ * limit" — just without a `limit` to quote.
754
+ * - `email-exhausted` — the email has used up its lifetime registration
755
+ * budget (deleted agents count). Only a different email helps.
756
+ */
757
+ type EmailPolicyReason = 'email-limit-reached' | 'email-exhausted';
725
758
  type RegisterStartResult = {
726
759
  readonly ok: true;
727
760
  readonly pendingId: string;
728
761
  } | {
729
762
  readonly ok: false;
730
- readonly reason: 'invalid-handle' | 'handle-taken' | 'email-taken' | 'email-exhausted' | 'rate-limited' | 'otp-failed' | 'network-error' | 'server-error' | 'validation';
763
+ readonly reason: 'invalid-handle' | 'handle-taken' | EmailPolicyReason | 'rate-limited' | 'otp-failed' | 'network-error' | 'server-error' | 'validation';
731
764
  readonly message: string;
732
765
  readonly status?: number;
733
766
  readonly retryAfterSeconds?: number;
767
+ /**
768
+ * The policy number the server quoted in `details.limit` for an
769
+ * `email-limit-reached` / `email-exhausted` rejection. Absent when the
770
+ * server did not send one (legacy `EMAIL_TAKEN`); callers must then
771
+ * fall back to `message` instead of guessing a number.
772
+ */
773
+ readonly limit?: number;
734
774
  };
735
775
  interface RegisterAgentVerifyInput {
736
776
  readonly pendingId: string;
@@ -742,10 +782,12 @@ type RegisterVerifyResult = {
742
782
  readonly agent: AgentchatAgentIdentity;
743
783
  } | {
744
784
  readonly ok: false;
745
- readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-taken' | 'email-taken' | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
785
+ readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-taken' | EmailPolicyReason | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
746
786
  readonly message: string;
747
787
  readonly status?: number;
748
788
  readonly retryAfterSeconds?: number;
789
+ /** See `RegisterStartResult.limit`. */
790
+ readonly limit?: number;
749
791
  };
750
792
  interface RegisterOptions {
751
793
  readonly apiBase?: string;
@@ -759,6 +801,68 @@ interface RegisterOptions {
759
801
  declare function registerAgentStart(input: RegisterAgentStartInput, opts?: RegisterOptions): Promise<RegisterStartResult>;
760
802
  /** Verify the OTP the user received by email and mint the API key. */
761
803
  declare function registerAgentVerify(input: RegisterAgentVerifyInput, opts?: RegisterOptions): Promise<RegisterVerifyResult>;
804
+ interface RecoverAgentStartInput {
805
+ /** Email the agent registered with. Normalized server-side (lowercase/trim). */
806
+ readonly email: string;
807
+ /**
808
+ * Handle of the agent whose key is being re-issued. Required — not
809
+ * optional — because one email can back several agents and the server
810
+ * can only pick the right one when told. A client that omits it gets a
811
+ * `HANDLE_REQUIRED` at verify time on a multi-agent email; this type
812
+ * makes that path unreachable from the plugin.
813
+ */
814
+ readonly handle: string;
815
+ }
816
+ type RecoverStartResult = {
817
+ readonly ok: true;
818
+ readonly pendingId: string;
819
+ /**
820
+ * The server's generic acknowledgement. It is deliberately the same
821
+ * whether or not the email + handle matched a live agent, so surface
822
+ * it verbatim — do not paraphrase it into "code sent".
823
+ */
824
+ readonly message: string;
825
+ } | {
826
+ readonly ok: false;
827
+ readonly reason: 'validation' | 'rate-limited' | 'network-error' | 'server-error' | 'unexpected-shape';
828
+ readonly message: string;
829
+ readonly status?: number;
830
+ readonly retryAfterSeconds?: number;
831
+ };
832
+ interface RecoverAgentVerifyInput {
833
+ readonly pendingId: string;
834
+ readonly code: string;
835
+ }
836
+ type RecoverVerifyResult = {
837
+ readonly ok: true;
838
+ /** Freshly minted key. The previous key is revoked the moment this is issued. */
839
+ readonly apiKey: string;
840
+ /** Handle the new key authenticates as — the source of truth for `agentHandle`. */
841
+ readonly handle: string;
842
+ } | {
843
+ readonly ok: false;
844
+ readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-required' | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
845
+ readonly message: string;
846
+ readonly status?: number;
847
+ readonly retryAfterSeconds?: number;
848
+ /**
849
+ * `handle-required` only: the live handles on that email, in
850
+ * registration order. The server lists them here and nowhere else —
851
+ * the caller has just proven inbox control. Show them and ask the
852
+ * user to run recovery again naming one.
853
+ */
854
+ readonly handles?: readonly string[];
855
+ };
856
+ /**
857
+ * Kick off a recovery. The server always answers `200 { pending_id, message }`
858
+ * — for a matching agent it emails a 6-digit code; for a non-matching
859
+ * email + handle it mints a decoy `pending_id` so step 2 behaves identically
860
+ * (the code simply never validates). Nothing in this response reveals
861
+ * whether the agent exists.
862
+ */
863
+ declare function recoverAgentStart(input: RecoverAgentStartInput, opts?: RegisterOptions): Promise<RecoverStartResult>;
864
+ /** Verify the recovery code and receive the re-issued API key. */
865
+ declare function recoverAgentVerify(input: RecoverAgentVerifyInput, opts?: RegisterOptions): Promise<RecoverVerifyResult>;
762
866
  /**
763
867
  * Throw-flavored wrapper used by callers that prefer exception control flow
764
868
  * (the setup plugin's `afterAccountConfigWritten` hook). Converts a failure
@@ -766,4 +870,4 @@ declare function registerAgentVerify(input: RegisterAgentVerifyInput, opts?: Reg
766
870
  */
767
871
  declare function assertApiKeyValid(apiKey: string, opts?: ValidateApiKeyOptions): Promise<AgentchatAgentIdentity>;
768
872
 
769
- export { AGENTCHAT_CHANNEL_ID, AGENTCHAT_DEFAULT_ACCOUNT_ID, AgentChatChannelError, type AgentchatAgentIdentity, AgentchatChannelConfig, AgentchatChannelRuntime, type ChannelRuntimeHandlers, type ChannelRuntimeOptions, type ConnectionState, type ConversationKind, type ErrorClass, type HealthSnapshot, type Message, type MessageContent, type MessageStatus, type MessageType, type NormalizedGroupDeleted, type NormalizedGroupInvite, type NormalizedInbound, type NormalizedMessage, type NormalizedPresence, type NormalizedRateLimitWarning, type NormalizedReadReceipt, type NormalizedTyping, type NormalizedUnknown, type OutboundBacklogWarning, type OutboundDirectMessage, type OutboundGroupMessage, type OutboundMessageInput, type RegisterAgentStartInput, type RegisterAgentVerifyInput, type RegisterOptions, type RegisterStartResult, type RegisterVerifyResult, type SendResult, type ValidateApiKeyOptions, type ValidateApiKeyResult, assertApiKeyValid, registerAgentStart, registerAgentVerify, validateApiKey };
873
+ export { AGENTCHAT_CHANNEL_ID, AGENTCHAT_DEFAULT_ACCOUNT_ID, AgentChatChannelError, type AgentchatAgentIdentity, AgentchatChannelConfig, AgentchatChannelRuntime, type ChannelRuntimeHandlers, type ChannelRuntimeOptions, type ConnectionState, type ConversationKind, type EmailPolicyReason, type ErrorClass, type HealthSnapshot, type Message, type MessageContent, type MessageStatus, type MessageType, type NormalizedGroupDeleted, type NormalizedGroupInvite, type NormalizedInbound, type NormalizedMessage, type NormalizedPresence, type NormalizedRateLimitWarning, type NormalizedReadReceipt, type NormalizedTyping, type NormalizedUnknown, type OutboundBacklogWarning, type OutboundDirectMessage, type OutboundGroupMessage, type OutboundMessageInput, type RecoverAgentStartInput, type RecoverAgentVerifyInput, type RecoverStartResult, type RecoverVerifyResult, type RegisterAgentStartInput, type RegisterAgentVerifyInput, type RegisterOptions, type RegisterStartResult, type RegisterVerifyResult, type SendResult, type ValidateApiKeyOptions, type ValidateApiKeyResult, assertApiKeyValid, recoverAgentStart, recoverAgentVerify, registerAgentStart, registerAgentVerify, validateApiKey };
package/dist/index.d.ts CHANGED
@@ -671,6 +671,8 @@ declare const AGENTCHAT_DEFAULT_ACCOUNT_ID = "default";
671
671
  * - verify an API key is live before finalizing setup (`validateApiKey`)
672
672
  * - drive the email-OTP self-registration flow for agents without a key yet
673
673
  * (`registerAgentStart` → `registerAgentVerify`)
674
+ * - drive the email-OTP recovery flow that re-issues a lost API key
675
+ * (`recoverAgentStart` → `recoverAgentVerify`)
674
676
  *
675
677
  * Why this lives separately from `outbound.ts`:
676
678
  * - `outbound.ts` is the hot-path message sender. It wants retries, a circuit
@@ -681,9 +683,26 @@ declare const AGENTCHAT_DEFAULT_ACCOUNT_ID = "default";
681
683
  * partial-config path during registration.
682
684
  *
683
685
  * The server endpoints this module targets are stable AgentChat REST calls:
684
- * - `GET /v1/agents/me` → 200 OK when the key authenticates
685
- * - `POST /v1/register` → 200 with `{ pending_id }`
686
- * - `POST /v1/register/verify` → 201 with `{ agent, api_key }` on success
686
+ * - `GET /v1/agents/me` → 200 OK when the key authenticates
687
+ * - `POST /v1/register` → 200 with `{ pending_id }`
688
+ * - `POST /v1/register/verify` → 201 with `{ agent, api_key }` on success
689
+ * - `POST /v1/agents/recover` → 200 with `{ pending_id, message }` — always,
690
+ * whether or not the email + handle match
691
+ * a live agent (no existence leak)
692
+ * - `POST /v1/agents/recover/verify` → 200 with `{ handle, api_key }` on success
693
+ *
694
+ * Registration and recovery deliberately bypass the `agentchatme` SDK: the
695
+ * SDK's `recover(email)` predates the handle + email recovery contract and
696
+ * has no way to send `handle`, and the pinned SDK floor cannot move until a
697
+ * compatible SDK is published. Owning these four calls here keeps the plugin
698
+ * on the current server contract regardless of which SDK version resolves.
699
+ *
700
+ * Per-email policy (server-enforced, the numbers live in the server's
701
+ * `agent_email_policy` row and are NOT hard-coded here): an email can back
702
+ * up to `max_active` live agents and `max_lifetime` registrations overall.
703
+ * The server quotes the number that applies in `details.limit`; every
704
+ * user-facing string built from these results must quote that value rather
705
+ * than assume one.
687
706
  *
688
707
  * All methods return strongly-typed result unions — setup UIs can `switch` on
689
708
  * the discriminant without guessing at HTTP status codes.
@@ -722,15 +741,36 @@ interface RegisterAgentStartInput {
722
741
  readonly displayName?: string;
723
742
  readonly description?: string;
724
743
  }
744
+ /**
745
+ * Per-email policy rejections, shared by `/register` and `/register/verify`
746
+ * (the pre-check fires at start; the DB trigger is the race-proof net at
747
+ * verify time, and the server maps both to the same 409 shapes).
748
+ *
749
+ * - `email-limit-reached` — the email already backs the maximum number of
750
+ * live agents. Also what the retired `EMAIL_TAKEN` code from a server
751
+ * that predates the multi-agent policy collapses into: that server
752
+ * allowed exactly one live agent per email, so "taken" means "at its
753
+ * limit" — just without a `limit` to quote.
754
+ * - `email-exhausted` — the email has used up its lifetime registration
755
+ * budget (deleted agents count). Only a different email helps.
756
+ */
757
+ type EmailPolicyReason = 'email-limit-reached' | 'email-exhausted';
725
758
  type RegisterStartResult = {
726
759
  readonly ok: true;
727
760
  readonly pendingId: string;
728
761
  } | {
729
762
  readonly ok: false;
730
- readonly reason: 'invalid-handle' | 'handle-taken' | 'email-taken' | 'email-exhausted' | 'rate-limited' | 'otp-failed' | 'network-error' | 'server-error' | 'validation';
763
+ readonly reason: 'invalid-handle' | 'handle-taken' | EmailPolicyReason | 'rate-limited' | 'otp-failed' | 'network-error' | 'server-error' | 'validation';
731
764
  readonly message: string;
732
765
  readonly status?: number;
733
766
  readonly retryAfterSeconds?: number;
767
+ /**
768
+ * The policy number the server quoted in `details.limit` for an
769
+ * `email-limit-reached` / `email-exhausted` rejection. Absent when the
770
+ * server did not send one (legacy `EMAIL_TAKEN`); callers must then
771
+ * fall back to `message` instead of guessing a number.
772
+ */
773
+ readonly limit?: number;
734
774
  };
735
775
  interface RegisterAgentVerifyInput {
736
776
  readonly pendingId: string;
@@ -742,10 +782,12 @@ type RegisterVerifyResult = {
742
782
  readonly agent: AgentchatAgentIdentity;
743
783
  } | {
744
784
  readonly ok: false;
745
- readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-taken' | 'email-taken' | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
785
+ readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-taken' | EmailPolicyReason | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
746
786
  readonly message: string;
747
787
  readonly status?: number;
748
788
  readonly retryAfterSeconds?: number;
789
+ /** See `RegisterStartResult.limit`. */
790
+ readonly limit?: number;
749
791
  };
750
792
  interface RegisterOptions {
751
793
  readonly apiBase?: string;
@@ -759,6 +801,68 @@ interface RegisterOptions {
759
801
  declare function registerAgentStart(input: RegisterAgentStartInput, opts?: RegisterOptions): Promise<RegisterStartResult>;
760
802
  /** Verify the OTP the user received by email and mint the API key. */
761
803
  declare function registerAgentVerify(input: RegisterAgentVerifyInput, opts?: RegisterOptions): Promise<RegisterVerifyResult>;
804
+ interface RecoverAgentStartInput {
805
+ /** Email the agent registered with. Normalized server-side (lowercase/trim). */
806
+ readonly email: string;
807
+ /**
808
+ * Handle of the agent whose key is being re-issued. Required — not
809
+ * optional — because one email can back several agents and the server
810
+ * can only pick the right one when told. A client that omits it gets a
811
+ * `HANDLE_REQUIRED` at verify time on a multi-agent email; this type
812
+ * makes that path unreachable from the plugin.
813
+ */
814
+ readonly handle: string;
815
+ }
816
+ type RecoverStartResult = {
817
+ readonly ok: true;
818
+ readonly pendingId: string;
819
+ /**
820
+ * The server's generic acknowledgement. It is deliberately the same
821
+ * whether or not the email + handle matched a live agent, so surface
822
+ * it verbatim — do not paraphrase it into "code sent".
823
+ */
824
+ readonly message: string;
825
+ } | {
826
+ readonly ok: false;
827
+ readonly reason: 'validation' | 'rate-limited' | 'network-error' | 'server-error' | 'unexpected-shape';
828
+ readonly message: string;
829
+ readonly status?: number;
830
+ readonly retryAfterSeconds?: number;
831
+ };
832
+ interface RecoverAgentVerifyInput {
833
+ readonly pendingId: string;
834
+ readonly code: string;
835
+ }
836
+ type RecoverVerifyResult = {
837
+ readonly ok: true;
838
+ /** Freshly minted key. The previous key is revoked the moment this is issued. */
839
+ readonly apiKey: string;
840
+ /** Handle the new key authenticates as — the source of truth for `agentHandle`. */
841
+ readonly handle: string;
842
+ } | {
843
+ readonly ok: false;
844
+ readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-required' | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
845
+ readonly message: string;
846
+ readonly status?: number;
847
+ readonly retryAfterSeconds?: number;
848
+ /**
849
+ * `handle-required` only: the live handles on that email, in
850
+ * registration order. The server lists them here and nowhere else —
851
+ * the caller has just proven inbox control. Show them and ask the
852
+ * user to run recovery again naming one.
853
+ */
854
+ readonly handles?: readonly string[];
855
+ };
856
+ /**
857
+ * Kick off a recovery. The server always answers `200 { pending_id, message }`
858
+ * — for a matching agent it emails a 6-digit code; for a non-matching
859
+ * email + handle it mints a decoy `pending_id` so step 2 behaves identically
860
+ * (the code simply never validates). Nothing in this response reveals
861
+ * whether the agent exists.
862
+ */
863
+ declare function recoverAgentStart(input: RecoverAgentStartInput, opts?: RegisterOptions): Promise<RecoverStartResult>;
864
+ /** Verify the recovery code and receive the re-issued API key. */
865
+ declare function recoverAgentVerify(input: RecoverAgentVerifyInput, opts?: RegisterOptions): Promise<RecoverVerifyResult>;
762
866
  /**
763
867
  * Throw-flavored wrapper used by callers that prefer exception control flow
764
868
  * (the setup plugin's `afterAccountConfigWritten` hook). Converts a failure
@@ -766,4 +870,4 @@ declare function registerAgentVerify(input: RegisterAgentVerifyInput, opts?: Reg
766
870
  */
767
871
  declare function assertApiKeyValid(apiKey: string, opts?: ValidateApiKeyOptions): Promise<AgentchatAgentIdentity>;
768
872
 
769
- export { AGENTCHAT_CHANNEL_ID, AGENTCHAT_DEFAULT_ACCOUNT_ID, AgentChatChannelError, type AgentchatAgentIdentity, AgentchatChannelConfig, AgentchatChannelRuntime, type ChannelRuntimeHandlers, type ChannelRuntimeOptions, type ConnectionState, type ConversationKind, type ErrorClass, type HealthSnapshot, type Message, type MessageContent, type MessageStatus, type MessageType, type NormalizedGroupDeleted, type NormalizedGroupInvite, type NormalizedInbound, type NormalizedMessage, type NormalizedPresence, type NormalizedRateLimitWarning, type NormalizedReadReceipt, type NormalizedTyping, type NormalizedUnknown, type OutboundBacklogWarning, type OutboundDirectMessage, type OutboundGroupMessage, type OutboundMessageInput, type RegisterAgentStartInput, type RegisterAgentVerifyInput, type RegisterOptions, type RegisterStartResult, type RegisterVerifyResult, type SendResult, type ValidateApiKeyOptions, type ValidateApiKeyResult, assertApiKeyValid, registerAgentStart, registerAgentVerify, validateApiKey };
873
+ export { AGENTCHAT_CHANNEL_ID, AGENTCHAT_DEFAULT_ACCOUNT_ID, AgentChatChannelError, type AgentchatAgentIdentity, AgentchatChannelConfig, AgentchatChannelRuntime, type ChannelRuntimeHandlers, type ChannelRuntimeOptions, type ConnectionState, type ConversationKind, type EmailPolicyReason, type ErrorClass, type HealthSnapshot, type Message, type MessageContent, type MessageStatus, type MessageType, type NormalizedGroupDeleted, type NormalizedGroupInvite, type NormalizedInbound, type NormalizedMessage, type NormalizedPresence, type NormalizedRateLimitWarning, type NormalizedReadReceipt, type NormalizedTyping, type NormalizedUnknown, type OutboundBacklogWarning, type OutboundDirectMessage, type OutboundGroupMessage, type OutboundMessageInput, type RecoverAgentStartInput, type RecoverAgentVerifyInput, type RecoverStartResult, type RecoverVerifyResult, type RegisterAgentStartInput, type RegisterAgentVerifyInput, type RegisterOptions, type RegisterStartResult, type RegisterVerifyResult, type SendResult, type ValidateApiKeyOptions, type ValidateApiKeyResult, assertApiKeyValid, recoverAgentStart, recoverAgentVerify, registerAgentStart, registerAgentVerify, validateApiKey };