@agentchatme/openclaw 0.10.1 → 0.11.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/CHANGELOG.md +55 -0
- package/README.md +7 -6
- package/RUNBOOK.md +4 -3
- package/dist/binding/agents-anchor.cjs.map +1 -1
- package/dist/binding/agents-anchor.d.cts +1 -1
- package/dist/binding/agents-anchor.d.ts +1 -1
- package/dist/binding/agents-anchor.js.map +1 -1
- package/dist/index.cjs +577 -810
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -189
- package/dist/index.d.ts +31 -189
- package/dist/index.js +577 -806
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +560 -781
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.js +561 -782
- package/dist/setup-entry.js.map +1 -1
- package/openclaw.plugin.json +5 -5
- package/package.json +2 -2
- package/skills/agentchat/SKILL.md +77 -40
package/dist/index.d.cts
CHANGED
|
@@ -124,7 +124,7 @@ interface TurnOutcome {
|
|
|
124
124
|
readonly runId?: string;
|
|
125
125
|
readonly status?: RunEndStatus | 'gone';
|
|
126
126
|
readonly error?: string;
|
|
127
|
-
/** AgentChat tool calls the run made, from its transcript; null when
|
|
127
|
+
/** AgentChat tool calls the run made, from its transcript; null when unknown — the transcript could not be read, or may be cut, or a call's outcome cannot be read from it (never zero, never all-ok). */
|
|
128
128
|
readonly agentchatCalls?: AgentChatCalls | null;
|
|
129
129
|
/** From admission to the confirmed end. */
|
|
130
130
|
readonly elapsedMs?: number;
|
|
@@ -656,8 +656,8 @@ declare function turnEndOf(outcome: TurnOutcome): integration.TurnEnd;
|
|
|
656
656
|
*
|
|
657
657
|
* Every text an agent sees is written once on the server and served as data
|
|
658
658
|
* (`GET /v1/texts?runtime=openclaw`): the wake instruction, the invite
|
|
659
|
-
* prompt, the gate-call preamble and answer format, the
|
|
660
|
-
* the manual is. The kit's cache fetches them at channel start and daily,
|
|
659
|
+
* prompt, the gate-call preamble and answer format, the reply-turn template,
|
|
660
|
+
* the identity line, where the manual is. The kit's cache fetches them at channel start and daily,
|
|
661
661
|
* keeps the last good copy in `<state dir>/agentchat/<accountId>/texts.json`
|
|
662
662
|
* (an offline start is not mute), and backs off after a failure. The server
|
|
663
663
|
* spells the hosted tools for `runtime=openclaw` the way OpenClaw exposes
|
|
@@ -775,197 +775,39 @@ declare class AgentChatChannelError extends Error {
|
|
|
775
775
|
}
|
|
776
776
|
|
|
777
777
|
/**
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
* This module holds no HTTP of its own: it turns the SDK's typed results
|
|
792
|
-
* and errors into result unions a setup UI can `switch` on without
|
|
793
|
-
* guessing at status codes. Every call is made once (`retry: never` in the
|
|
794
|
-
* SDK for these routes; one attempt for the key check) — setup is
|
|
795
|
-
* interactive, and a retry would only send a second email.
|
|
796
|
-
*
|
|
797
|
-
* Per-email policy (server-enforced, the numbers live in the server's
|
|
798
|
-
* `agent_email_policy` row and are NOT hard-coded here): an email can back
|
|
799
|
-
* up to `max_active` live agents and `max_lifetime` registrations overall.
|
|
800
|
-
* The server quotes the number that applies in `details.limit`; every
|
|
801
|
-
* user-facing string built from these results must quote that value rather
|
|
802
|
-
* than assume one.
|
|
778
|
+
* AgentChat's account calls, as setup makes them: sign-up and recovery by
|
|
779
|
+
* email code (the wizard runs `integration.account.run`) and the key check
|
|
780
|
+
* (`integration.account.checkKey`, `GET /v1/agents/me`), both from the
|
|
781
|
+
* `agentchatme` SDK.
|
|
782
|
+
*
|
|
783
|
+
* The SDK's helper follows the server's answer (contract v1, "Sign-up
|
|
784
|
+
* flows"): which input to ask again, when to wait, when a new code may be
|
|
785
|
+
* sent, and the sentence the person reads. This module keeps none of that;
|
|
786
|
+
* it only binds this plugin's client identity and the account's API base,
|
|
787
|
+
* so every setup path announces itself the same way and reaches the same
|
|
788
|
+
* host. Every call is made once: a retry of a sign-up call would send a
|
|
789
|
+
* second email.
|
|
803
790
|
*/
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
readonly createdAt: string;
|
|
810
|
-
}
|
|
811
|
-
type ValidateApiKeyResult = {
|
|
812
|
-
readonly ok: true;
|
|
813
|
-
readonly agent: AgentchatAgentIdentity;
|
|
814
|
-
} | {
|
|
815
|
-
readonly ok: false;
|
|
816
|
-
/** High-level reason code the UI can map to a localized message. */
|
|
817
|
-
readonly reason: 'unauthorized' | 'forbidden' | 'deleted' | 'network-error' | 'unreachable' | 'server-error' | 'unexpected-shape';
|
|
818
|
-
readonly message: string;
|
|
819
|
-
readonly status?: number;
|
|
820
|
-
};
|
|
821
|
-
interface ValidateApiKeyOptions {
|
|
791
|
+
|
|
792
|
+
/** The server's verdict on a key: `{ok: true, handle}` or `{ok: false, code, message}`. */
|
|
793
|
+
type KeyCheck = integration.CheckKeyResult;
|
|
794
|
+
interface AccountCallParams {
|
|
795
|
+
/** The account's `apiBase`; default `https://api.agentchat.me`. */
|
|
822
796
|
readonly apiBase?: string;
|
|
797
|
+
/** `fetch` override (tests, a progress indicator around each call). */
|
|
823
798
|
readonly fetch?: typeof fetch;
|
|
824
799
|
readonly timeoutMs?: number;
|
|
825
800
|
}
|
|
801
|
+
/** What every account call carries: this plugin's identity and the account's API base. */
|
|
802
|
+
declare function accountCallOptions(params?: AccountCallParams): integration.AccountCallOptions;
|
|
826
803
|
/**
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
readonly email: string;
|
|
834
|
-
readonly handle: string;
|
|
835
|
-
readonly displayName?: string;
|
|
836
|
-
readonly description?: string;
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* Per-email policy rejections, shared by `/register` and `/register/verify`
|
|
840
|
-
* (the pre-check fires at start; the DB trigger is the race-proof net at
|
|
841
|
-
* verify time, and the server maps both to the same 409 shapes).
|
|
842
|
-
*
|
|
843
|
-
* - `email-limit-reached` — the email already backs the maximum number of
|
|
844
|
-
* live agents. Also what the retired `EMAIL_TAKEN` code from a server
|
|
845
|
-
* that predates the multi-agent policy collapses into: that server
|
|
846
|
-
* allowed exactly one live agent per email, so "taken" means "at its
|
|
847
|
-
* limit" — just without a `limit` to quote.
|
|
848
|
-
* - `email-exhausted` — the email has used up its lifetime registration
|
|
849
|
-
* budget (deleted agents count). Only a different email helps.
|
|
850
|
-
*/
|
|
851
|
-
type EmailPolicyReason = 'email-limit-reached' | 'email-exhausted';
|
|
852
|
-
type RegisterStartResult = {
|
|
853
|
-
readonly ok: true;
|
|
854
|
-
readonly pendingId: string;
|
|
855
|
-
} | {
|
|
856
|
-
readonly ok: false;
|
|
857
|
-
readonly reason: 'invalid-handle' | 'handle-taken' | EmailPolicyReason | 'rate-limited' | 'otp-failed' | 'network-error' | 'server-error' | 'validation';
|
|
858
|
-
readonly message: string;
|
|
859
|
-
readonly status?: number;
|
|
860
|
-
readonly retryAfterSeconds?: number;
|
|
861
|
-
/**
|
|
862
|
-
* The policy number the server quoted in `details.limit` for an
|
|
863
|
-
* `email-limit-reached` / `email-exhausted` rejection. Absent when the
|
|
864
|
-
* server did not send one (legacy `EMAIL_TAKEN`); callers must then
|
|
865
|
-
* fall back to `message` instead of guessing a number.
|
|
866
|
-
*/
|
|
867
|
-
readonly limit?: number;
|
|
868
|
-
};
|
|
869
|
-
interface RegisterAgentVerifyInput {
|
|
870
|
-
readonly pendingId: string;
|
|
871
|
-
readonly code: string;
|
|
872
|
-
}
|
|
873
|
-
type RegisterVerifyResult = {
|
|
874
|
-
readonly ok: true;
|
|
875
|
-
readonly apiKey: string;
|
|
876
|
-
readonly agent: AgentchatAgentIdentity;
|
|
877
|
-
} | {
|
|
878
|
-
readonly ok: false;
|
|
879
|
-
readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-taken' | EmailPolicyReason | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
|
|
880
|
-
readonly message: string;
|
|
881
|
-
readonly status?: number;
|
|
882
|
-
readonly retryAfterSeconds?: number;
|
|
883
|
-
/** See `RegisterStartResult.limit`. */
|
|
884
|
-
readonly limit?: number;
|
|
885
|
-
};
|
|
886
|
-
/**
|
|
887
|
-
* Options for the registration and recovery calls. The SDK makes these
|
|
888
|
-
* calls with its own transport (the runtime's `fetch`, its default timeout);
|
|
889
|
-
* its static `register` / `verify` / `recover` / `recoverVerify` take no
|
|
890
|
-
* `fetch` or timeout of their own, so neither is offered here.
|
|
891
|
-
*/
|
|
892
|
-
interface RegisterOptions {
|
|
893
|
-
readonly apiBase?: string;
|
|
894
|
-
}
|
|
895
|
-
/**
|
|
896
|
-
* Kick off an email-OTP registration. Server caches the intent under a
|
|
897
|
-
* `pending_id` for 10 minutes and emails a 6-digit code to `email`.
|
|
898
|
-
*/
|
|
899
|
-
declare function registerAgentStart(input: RegisterAgentStartInput, opts?: RegisterOptions): Promise<RegisterStartResult>;
|
|
900
|
-
/** Verify the OTP the user received by email and mint the API key. */
|
|
901
|
-
declare function registerAgentVerify(input: RegisterAgentVerifyInput, opts?: RegisterOptions): Promise<RegisterVerifyResult>;
|
|
902
|
-
interface RecoverAgentStartInput {
|
|
903
|
-
/** Email the agent registered with. Normalized server-side (lowercase/trim). */
|
|
904
|
-
readonly email: string;
|
|
905
|
-
/**
|
|
906
|
-
* Handle of the agent whose key is being re-issued. Required — not
|
|
907
|
-
* optional — because one email can back several agents and the server
|
|
908
|
-
* can only pick the right one when told. A client that omits it gets a
|
|
909
|
-
* `HANDLE_REQUIRED` at verify time on a multi-agent email; this type
|
|
910
|
-
* makes that path unreachable from the plugin.
|
|
911
|
-
*/
|
|
912
|
-
readonly handle: string;
|
|
913
|
-
}
|
|
914
|
-
type RecoverStartResult = {
|
|
915
|
-
readonly ok: true;
|
|
916
|
-
readonly pendingId: string;
|
|
917
|
-
/**
|
|
918
|
-
* The server's generic acknowledgement. It is deliberately the same
|
|
919
|
-
* whether or not the email + handle matched a live agent, so surface
|
|
920
|
-
* it verbatim — do not paraphrase it into "code sent".
|
|
921
|
-
*/
|
|
922
|
-
readonly message: string;
|
|
923
|
-
} | {
|
|
924
|
-
readonly ok: false;
|
|
925
|
-
readonly reason: 'validation' | 'rate-limited' | 'network-error' | 'server-error' | 'unexpected-shape';
|
|
926
|
-
readonly message: string;
|
|
927
|
-
readonly status?: number;
|
|
928
|
-
readonly retryAfterSeconds?: number;
|
|
929
|
-
};
|
|
930
|
-
interface RecoverAgentVerifyInput {
|
|
931
|
-
readonly pendingId: string;
|
|
932
|
-
readonly code: string;
|
|
933
|
-
}
|
|
934
|
-
type RecoverVerifyResult = {
|
|
935
|
-
readonly ok: true;
|
|
936
|
-
/** Freshly minted key. The previous key is revoked the moment this is issued. */
|
|
937
|
-
readonly apiKey: string;
|
|
938
|
-
/** Handle the new key authenticates as — the source of truth for `agentHandle`. */
|
|
939
|
-
readonly handle: string;
|
|
940
|
-
} | {
|
|
941
|
-
readonly ok: false;
|
|
942
|
-
readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-required' | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
|
|
943
|
-
readonly message: string;
|
|
944
|
-
readonly status?: number;
|
|
945
|
-
readonly retryAfterSeconds?: number;
|
|
946
|
-
/**
|
|
947
|
-
* `handle-required` only: the live handles on that email, in
|
|
948
|
-
* registration order. The server lists them here and nowhere else —
|
|
949
|
-
* the caller has just proven inbox control. Show them and ask the
|
|
950
|
-
* user to run recovery again naming one.
|
|
951
|
-
*/
|
|
952
|
-
readonly handles?: readonly string[];
|
|
953
|
-
};
|
|
954
|
-
/**
|
|
955
|
-
* Kick off a recovery. The server always answers `200 { pending_id, message }`
|
|
956
|
-
* — for a matching agent it emails a 6-digit code; for a non-matching
|
|
957
|
-
* email + handle it mints a decoy `pending_id` so step 2 behaves identically
|
|
958
|
-
* (the code simply never validates). Nothing in this response reveals
|
|
959
|
-
* whether the agent exists.
|
|
960
|
-
*/
|
|
961
|
-
declare function recoverAgentStart(input: RecoverAgentStartInput, opts?: RegisterOptions): Promise<RecoverStartResult>;
|
|
962
|
-
/** Verify the recovery code and receive the re-issued API key. */
|
|
963
|
-
declare function recoverAgentVerify(input: RecoverAgentVerifyInput, opts?: RegisterOptions): Promise<RecoverVerifyResult>;
|
|
964
|
-
/**
|
|
965
|
-
* Throw-flavored wrapper used by callers that prefer exception control flow
|
|
966
|
-
* (the setup plugin's `afterAccountConfigWritten` hook). Converts a failure
|
|
967
|
-
* result into an `AgentChatChannelError` with an appropriate class.
|
|
804
|
+
* Does AgentChat accept this key? `{ok: true, handle}` with the handle the
|
|
805
|
+
* key belongs to (save that one, not a typed one), or `{ok: false, code,
|
|
806
|
+
* message}` when AgentChat turned the key away (401 / 403: never save it).
|
|
807
|
+
* Rejects when no verdict came — no answer (network, timeout), or an answer
|
|
808
|
+
* that is not about the key (`KeyCheckUnanswered`: a 429, a 5xx) — and
|
|
809
|
+
* then nothing is known about the key.
|
|
968
810
|
*/
|
|
969
|
-
declare function
|
|
811
|
+
declare function checkApiKey(apiKey: string, params?: AccountCallParams): Promise<KeyCheck>;
|
|
970
812
|
|
|
971
|
-
export { AGENTCHAT_CHANNEL_ID, AGENTCHAT_DEFAULT_ACCOUNT_ID,
|
|
813
|
+
export { AGENTCHAT_CHANNEL_ID, AGENTCHAT_DEFAULT_ACCOUNT_ID, type AccountCallParams, AgentChatChannelError, type ErrorClass, type IntegrationLoop, type IntegrationLoopOptions, type KeyCheck, MAX_HUNG_TURNS, MCP_SERVER_NAME, MetricsRecorder, OPENCLAW_TOOL_NAMER, OpenClawTexts, accountCallOptions, accountTurns, checkApiKey, createIntegrationLoop, createLoopTurnStarter, createTextsCache, hostedMcpServerEntry, hostedMcpSnippet, hostedMcpUrl, loadIdentityLine, mcpToolName, probeHostedMcp, spellTextsForOpenClaw, spellToolsForOpenClaw, trackerFor, turnEndOf };
|
package/dist/index.d.ts
CHANGED
|
@@ -124,7 +124,7 @@ interface TurnOutcome {
|
|
|
124
124
|
readonly runId?: string;
|
|
125
125
|
readonly status?: RunEndStatus | 'gone';
|
|
126
126
|
readonly error?: string;
|
|
127
|
-
/** AgentChat tool calls the run made, from its transcript; null when
|
|
127
|
+
/** AgentChat tool calls the run made, from its transcript; null when unknown — the transcript could not be read, or may be cut, or a call's outcome cannot be read from it (never zero, never all-ok). */
|
|
128
128
|
readonly agentchatCalls?: AgentChatCalls | null;
|
|
129
129
|
/** From admission to the confirmed end. */
|
|
130
130
|
readonly elapsedMs?: number;
|
|
@@ -656,8 +656,8 @@ declare function turnEndOf(outcome: TurnOutcome): integration.TurnEnd;
|
|
|
656
656
|
*
|
|
657
657
|
* Every text an agent sees is written once on the server and served as data
|
|
658
658
|
* (`GET /v1/texts?runtime=openclaw`): the wake instruction, the invite
|
|
659
|
-
* prompt, the gate-call preamble and answer format, the
|
|
660
|
-
* the manual is. The kit's cache fetches them at channel start and daily,
|
|
659
|
+
* prompt, the gate-call preamble and answer format, the reply-turn template,
|
|
660
|
+
* the identity line, where the manual is. The kit's cache fetches them at channel start and daily,
|
|
661
661
|
* keeps the last good copy in `<state dir>/agentchat/<accountId>/texts.json`
|
|
662
662
|
* (an offline start is not mute), and backs off after a failure. The server
|
|
663
663
|
* spells the hosted tools for `runtime=openclaw` the way OpenClaw exposes
|
|
@@ -775,197 +775,39 @@ declare class AgentChatChannelError extends Error {
|
|
|
775
775
|
}
|
|
776
776
|
|
|
777
777
|
/**
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
* This module holds no HTTP of its own: it turns the SDK's typed results
|
|
792
|
-
* and errors into result unions a setup UI can `switch` on without
|
|
793
|
-
* guessing at status codes. Every call is made once (`retry: never` in the
|
|
794
|
-
* SDK for these routes; one attempt for the key check) — setup is
|
|
795
|
-
* interactive, and a retry would only send a second email.
|
|
796
|
-
*
|
|
797
|
-
* Per-email policy (server-enforced, the numbers live in the server's
|
|
798
|
-
* `agent_email_policy` row and are NOT hard-coded here): an email can back
|
|
799
|
-
* up to `max_active` live agents and `max_lifetime` registrations overall.
|
|
800
|
-
* The server quotes the number that applies in `details.limit`; every
|
|
801
|
-
* user-facing string built from these results must quote that value rather
|
|
802
|
-
* than assume one.
|
|
778
|
+
* AgentChat's account calls, as setup makes them: sign-up and recovery by
|
|
779
|
+
* email code (the wizard runs `integration.account.run`) and the key check
|
|
780
|
+
* (`integration.account.checkKey`, `GET /v1/agents/me`), both from the
|
|
781
|
+
* `agentchatme` SDK.
|
|
782
|
+
*
|
|
783
|
+
* The SDK's helper follows the server's answer (contract v1, "Sign-up
|
|
784
|
+
* flows"): which input to ask again, when to wait, when a new code may be
|
|
785
|
+
* sent, and the sentence the person reads. This module keeps none of that;
|
|
786
|
+
* it only binds this plugin's client identity and the account's API base,
|
|
787
|
+
* so every setup path announces itself the same way and reaches the same
|
|
788
|
+
* host. Every call is made once: a retry of a sign-up call would send a
|
|
789
|
+
* second email.
|
|
803
790
|
*/
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
readonly createdAt: string;
|
|
810
|
-
}
|
|
811
|
-
type ValidateApiKeyResult = {
|
|
812
|
-
readonly ok: true;
|
|
813
|
-
readonly agent: AgentchatAgentIdentity;
|
|
814
|
-
} | {
|
|
815
|
-
readonly ok: false;
|
|
816
|
-
/** High-level reason code the UI can map to a localized message. */
|
|
817
|
-
readonly reason: 'unauthorized' | 'forbidden' | 'deleted' | 'network-error' | 'unreachable' | 'server-error' | 'unexpected-shape';
|
|
818
|
-
readonly message: string;
|
|
819
|
-
readonly status?: number;
|
|
820
|
-
};
|
|
821
|
-
interface ValidateApiKeyOptions {
|
|
791
|
+
|
|
792
|
+
/** The server's verdict on a key: `{ok: true, handle}` or `{ok: false, code, message}`. */
|
|
793
|
+
type KeyCheck = integration.CheckKeyResult;
|
|
794
|
+
interface AccountCallParams {
|
|
795
|
+
/** The account's `apiBase`; default `https://api.agentchat.me`. */
|
|
822
796
|
readonly apiBase?: string;
|
|
797
|
+
/** `fetch` override (tests, a progress indicator around each call). */
|
|
823
798
|
readonly fetch?: typeof fetch;
|
|
824
799
|
readonly timeoutMs?: number;
|
|
825
800
|
}
|
|
801
|
+
/** What every account call carries: this plugin's identity and the account's API base. */
|
|
802
|
+
declare function accountCallOptions(params?: AccountCallParams): integration.AccountCallOptions;
|
|
826
803
|
/**
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
readonly email: string;
|
|
834
|
-
readonly handle: string;
|
|
835
|
-
readonly displayName?: string;
|
|
836
|
-
readonly description?: string;
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* Per-email policy rejections, shared by `/register` and `/register/verify`
|
|
840
|
-
* (the pre-check fires at start; the DB trigger is the race-proof net at
|
|
841
|
-
* verify time, and the server maps both to the same 409 shapes).
|
|
842
|
-
*
|
|
843
|
-
* - `email-limit-reached` — the email already backs the maximum number of
|
|
844
|
-
* live agents. Also what the retired `EMAIL_TAKEN` code from a server
|
|
845
|
-
* that predates the multi-agent policy collapses into: that server
|
|
846
|
-
* allowed exactly one live agent per email, so "taken" means "at its
|
|
847
|
-
* limit" — just without a `limit` to quote.
|
|
848
|
-
* - `email-exhausted` — the email has used up its lifetime registration
|
|
849
|
-
* budget (deleted agents count). Only a different email helps.
|
|
850
|
-
*/
|
|
851
|
-
type EmailPolicyReason = 'email-limit-reached' | 'email-exhausted';
|
|
852
|
-
type RegisterStartResult = {
|
|
853
|
-
readonly ok: true;
|
|
854
|
-
readonly pendingId: string;
|
|
855
|
-
} | {
|
|
856
|
-
readonly ok: false;
|
|
857
|
-
readonly reason: 'invalid-handle' | 'handle-taken' | EmailPolicyReason | 'rate-limited' | 'otp-failed' | 'network-error' | 'server-error' | 'validation';
|
|
858
|
-
readonly message: string;
|
|
859
|
-
readonly status?: number;
|
|
860
|
-
readonly retryAfterSeconds?: number;
|
|
861
|
-
/**
|
|
862
|
-
* The policy number the server quoted in `details.limit` for an
|
|
863
|
-
* `email-limit-reached` / `email-exhausted` rejection. Absent when the
|
|
864
|
-
* server did not send one (legacy `EMAIL_TAKEN`); callers must then
|
|
865
|
-
* fall back to `message` instead of guessing a number.
|
|
866
|
-
*/
|
|
867
|
-
readonly limit?: number;
|
|
868
|
-
};
|
|
869
|
-
interface RegisterAgentVerifyInput {
|
|
870
|
-
readonly pendingId: string;
|
|
871
|
-
readonly code: string;
|
|
872
|
-
}
|
|
873
|
-
type RegisterVerifyResult = {
|
|
874
|
-
readonly ok: true;
|
|
875
|
-
readonly apiKey: string;
|
|
876
|
-
readonly agent: AgentchatAgentIdentity;
|
|
877
|
-
} | {
|
|
878
|
-
readonly ok: false;
|
|
879
|
-
readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-taken' | EmailPolicyReason | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
|
|
880
|
-
readonly message: string;
|
|
881
|
-
readonly status?: number;
|
|
882
|
-
readonly retryAfterSeconds?: number;
|
|
883
|
-
/** See `RegisterStartResult.limit`. */
|
|
884
|
-
readonly limit?: number;
|
|
885
|
-
};
|
|
886
|
-
/**
|
|
887
|
-
* Options for the registration and recovery calls. The SDK makes these
|
|
888
|
-
* calls with its own transport (the runtime's `fetch`, its default timeout);
|
|
889
|
-
* its static `register` / `verify` / `recover` / `recoverVerify` take no
|
|
890
|
-
* `fetch` or timeout of their own, so neither is offered here.
|
|
891
|
-
*/
|
|
892
|
-
interface RegisterOptions {
|
|
893
|
-
readonly apiBase?: string;
|
|
894
|
-
}
|
|
895
|
-
/**
|
|
896
|
-
* Kick off an email-OTP registration. Server caches the intent under a
|
|
897
|
-
* `pending_id` for 10 minutes and emails a 6-digit code to `email`.
|
|
898
|
-
*/
|
|
899
|
-
declare function registerAgentStart(input: RegisterAgentStartInput, opts?: RegisterOptions): Promise<RegisterStartResult>;
|
|
900
|
-
/** Verify the OTP the user received by email and mint the API key. */
|
|
901
|
-
declare function registerAgentVerify(input: RegisterAgentVerifyInput, opts?: RegisterOptions): Promise<RegisterVerifyResult>;
|
|
902
|
-
interface RecoverAgentStartInput {
|
|
903
|
-
/** Email the agent registered with. Normalized server-side (lowercase/trim). */
|
|
904
|
-
readonly email: string;
|
|
905
|
-
/**
|
|
906
|
-
* Handle of the agent whose key is being re-issued. Required — not
|
|
907
|
-
* optional — because one email can back several agents and the server
|
|
908
|
-
* can only pick the right one when told. A client that omits it gets a
|
|
909
|
-
* `HANDLE_REQUIRED` at verify time on a multi-agent email; this type
|
|
910
|
-
* makes that path unreachable from the plugin.
|
|
911
|
-
*/
|
|
912
|
-
readonly handle: string;
|
|
913
|
-
}
|
|
914
|
-
type RecoverStartResult = {
|
|
915
|
-
readonly ok: true;
|
|
916
|
-
readonly pendingId: string;
|
|
917
|
-
/**
|
|
918
|
-
* The server's generic acknowledgement. It is deliberately the same
|
|
919
|
-
* whether or not the email + handle matched a live agent, so surface
|
|
920
|
-
* it verbatim — do not paraphrase it into "code sent".
|
|
921
|
-
*/
|
|
922
|
-
readonly message: string;
|
|
923
|
-
} | {
|
|
924
|
-
readonly ok: false;
|
|
925
|
-
readonly reason: 'validation' | 'rate-limited' | 'network-error' | 'server-error' | 'unexpected-shape';
|
|
926
|
-
readonly message: string;
|
|
927
|
-
readonly status?: number;
|
|
928
|
-
readonly retryAfterSeconds?: number;
|
|
929
|
-
};
|
|
930
|
-
interface RecoverAgentVerifyInput {
|
|
931
|
-
readonly pendingId: string;
|
|
932
|
-
readonly code: string;
|
|
933
|
-
}
|
|
934
|
-
type RecoverVerifyResult = {
|
|
935
|
-
readonly ok: true;
|
|
936
|
-
/** Freshly minted key. The previous key is revoked the moment this is issued. */
|
|
937
|
-
readonly apiKey: string;
|
|
938
|
-
/** Handle the new key authenticates as — the source of truth for `agentHandle`. */
|
|
939
|
-
readonly handle: string;
|
|
940
|
-
} | {
|
|
941
|
-
readonly ok: false;
|
|
942
|
-
readonly reason: 'expired' | 'invalid-code' | 'rate-limited' | 'handle-required' | 'network-error' | 'server-error' | 'unexpected-shape' | 'validation';
|
|
943
|
-
readonly message: string;
|
|
944
|
-
readonly status?: number;
|
|
945
|
-
readonly retryAfterSeconds?: number;
|
|
946
|
-
/**
|
|
947
|
-
* `handle-required` only: the live handles on that email, in
|
|
948
|
-
* registration order. The server lists them here and nowhere else —
|
|
949
|
-
* the caller has just proven inbox control. Show them and ask the
|
|
950
|
-
* user to run recovery again naming one.
|
|
951
|
-
*/
|
|
952
|
-
readonly handles?: readonly string[];
|
|
953
|
-
};
|
|
954
|
-
/**
|
|
955
|
-
* Kick off a recovery. The server always answers `200 { pending_id, message }`
|
|
956
|
-
* — for a matching agent it emails a 6-digit code; for a non-matching
|
|
957
|
-
* email + handle it mints a decoy `pending_id` so step 2 behaves identically
|
|
958
|
-
* (the code simply never validates). Nothing in this response reveals
|
|
959
|
-
* whether the agent exists.
|
|
960
|
-
*/
|
|
961
|
-
declare function recoverAgentStart(input: RecoverAgentStartInput, opts?: RegisterOptions): Promise<RecoverStartResult>;
|
|
962
|
-
/** Verify the recovery code and receive the re-issued API key. */
|
|
963
|
-
declare function recoverAgentVerify(input: RecoverAgentVerifyInput, opts?: RegisterOptions): Promise<RecoverVerifyResult>;
|
|
964
|
-
/**
|
|
965
|
-
* Throw-flavored wrapper used by callers that prefer exception control flow
|
|
966
|
-
* (the setup plugin's `afterAccountConfigWritten` hook). Converts a failure
|
|
967
|
-
* result into an `AgentChatChannelError` with an appropriate class.
|
|
804
|
+
* Does AgentChat accept this key? `{ok: true, handle}` with the handle the
|
|
805
|
+
* key belongs to (save that one, not a typed one), or `{ok: false, code,
|
|
806
|
+
* message}` when AgentChat turned the key away (401 / 403: never save it).
|
|
807
|
+
* Rejects when no verdict came — no answer (network, timeout), or an answer
|
|
808
|
+
* that is not about the key (`KeyCheckUnanswered`: a 429, a 5xx) — and
|
|
809
|
+
* then nothing is known about the key.
|
|
968
810
|
*/
|
|
969
|
-
declare function
|
|
811
|
+
declare function checkApiKey(apiKey: string, params?: AccountCallParams): Promise<KeyCheck>;
|
|
970
812
|
|
|
971
|
-
export { AGENTCHAT_CHANNEL_ID, AGENTCHAT_DEFAULT_ACCOUNT_ID,
|
|
813
|
+
export { AGENTCHAT_CHANNEL_ID, AGENTCHAT_DEFAULT_ACCOUNT_ID, type AccountCallParams, AgentChatChannelError, type ErrorClass, type IntegrationLoop, type IntegrationLoopOptions, type KeyCheck, MAX_HUNG_TURNS, MCP_SERVER_NAME, MetricsRecorder, OPENCLAW_TOOL_NAMER, OpenClawTexts, accountCallOptions, accountTurns, checkApiKey, createIntegrationLoop, createLoopTurnStarter, createTextsCache, hostedMcpServerEntry, hostedMcpSnippet, hostedMcpUrl, loadIdentityLine, mcpToolName, probeHostedMcp, spellTextsForOpenClaw, spellToolsForOpenClaw, trackerFor, turnEndOf };
|