agentchatme 1.3.2 → 1.4.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 +34 -0
- package/README.md +24 -2
- package/dist/index.cjs +646 -127
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +459 -27
- package/dist/index.d.ts +459 -27
- package/dist/index.js +646 -128
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -929,6 +929,12 @@ declare const ErrorCode: {
|
|
|
929
929
|
* lists the candidates; re-run `recover()` with one of them.
|
|
930
930
|
*/
|
|
931
931
|
readonly HANDLE_REQUIRED: "HANDLE_REQUIRED";
|
|
932
|
+
/**
|
|
933
|
+
* 429 from a sign-up verify call: the code's attempts are used up and the
|
|
934
|
+
* pending id is gone. Repeating never succeeds; request a new code.
|
|
935
|
+
* Mapped to `OtpAttemptsExhaustedError` (not `RateLimitedError`).
|
|
936
|
+
*/
|
|
937
|
+
readonly OTP_ATTEMPTS_EXHAUSTED: "OTP_ATTEMPTS_EXHAUSTED";
|
|
932
938
|
readonly SUSPENDED: "SUSPENDED";
|
|
933
939
|
readonly RESTRICTED: "RESTRICTED";
|
|
934
940
|
readonly CONVERSATION_NOT_FOUND: "CONVERSATION_NOT_FOUND";
|
|
@@ -955,6 +961,87 @@ interface ApiError {
|
|
|
955
961
|
details?: Record<string, unknown>;
|
|
956
962
|
}
|
|
957
963
|
|
|
964
|
+
/**
|
|
965
|
+
* The sign-up flow object (contract v1, "Sign-up flows"; additive).
|
|
966
|
+
*
|
|
967
|
+
* Every answer of the six sign-up endpoints (`POST /v1/register` and
|
|
968
|
+
* `/verify`, `POST /v1/agents/recover` and `/verify`,
|
|
969
|
+
* `POST /v1/agents/{handle}/rotate-key` and `/verify`) carries it: a 2xx
|
|
970
|
+
* body at its top level, beside the existing fields; an error body inside
|
|
971
|
+
* `details`, beside the existing `details.*`. A client reads it with
|
|
972
|
+
* `flow = body.code ? body.details : body` (`integration.account.flowOf`),
|
|
973
|
+
* ignores fields it does not know, branches only on `code` / `next_step`,
|
|
974
|
+
* and shows the answer's `message` verbatim.
|
|
975
|
+
*/
|
|
976
|
+
/** Which family of calls the answer belongs to. */
|
|
977
|
+
type SignupFlowKind = 'register' | 'recover' | 'rotate_key';
|
|
978
|
+
/**
|
|
979
|
+
* The call to make next, named after the endpoint (and SDK method):
|
|
980
|
+
* `register` / `recover` / `rotate_key` start a flow (and send a code),
|
|
981
|
+
* `verify` / `recover_verify` / `rotate_key_verify` submit the code, `done`
|
|
982
|
+
* means the API key is in the body. A 429 keeps the step it applies to and
|
|
983
|
+
* adds `retry_after_s`.
|
|
984
|
+
*/
|
|
985
|
+
type SignupNextStep = 'register' | 'verify' | 'recover' | 'recover_verify' | 'rotate_key' | 'rotate_key_verify' | 'done';
|
|
986
|
+
/** The steps that start a flow and send a code. */
|
|
987
|
+
type SignupStartStep = 'register' | 'recover' | 'rotate_key';
|
|
988
|
+
/** The steps that submit a code. */
|
|
989
|
+
type SignupVerifyStep = 'verify' | 'recover_verify' | 'rotate_key_verify';
|
|
990
|
+
/** The state of the pending code the answer concerns (Twilio Verify statuses). */
|
|
991
|
+
type SignupCodeStatus = 'pending' | 'approved' | 'expired' | 'max_attempts_reached';
|
|
992
|
+
/** The one input that must change before the next call. */
|
|
993
|
+
type SignupParam = 'email' | 'handle' | 'code';
|
|
994
|
+
/**
|
|
995
|
+
* The flow object. Only `version`, `flow` and `next_step` are always
|
|
996
|
+
* present; the rest appear as the contract table says. String fields are
|
|
997
|
+
* open (`string & {}`) so a value a later server adds still parses — an
|
|
998
|
+
* unknown `next_step` means "stop and show the message".
|
|
999
|
+
*/
|
|
1000
|
+
interface SignupFlow {
|
|
1001
|
+
version: 1 | (number & {});
|
|
1002
|
+
flow: SignupFlowKind | (string & {});
|
|
1003
|
+
next_step: SignupNextStep | (string & {});
|
|
1004
|
+
/** Present whenever the answer concerns a pending code. */
|
|
1005
|
+
status?: SignupCodeStatus | (string & {});
|
|
1006
|
+
/** While the code is alive (`status: "pending"`). */
|
|
1007
|
+
pending_id?: string;
|
|
1008
|
+
/** When one input must change. */
|
|
1009
|
+
param?: SignupParam | (string & {});
|
|
1010
|
+
/** ISO-8601 UTC, while pending. */
|
|
1011
|
+
expires_at?: string;
|
|
1012
|
+
/** Seconds, while pending. */
|
|
1013
|
+
expires_in_s?: number;
|
|
1014
|
+
/** Digits in the code (6), while pending. */
|
|
1015
|
+
code_length?: number;
|
|
1016
|
+
/** Wrong codes so far for this pending id: while pending, and on the answer that ends it. */
|
|
1017
|
+
attempts?: number;
|
|
1018
|
+
/** With `attempts`. */
|
|
1019
|
+
max_attempts?: number;
|
|
1020
|
+
/** Seconds until a new code may be requested for this email (0 = now), while pending. */
|
|
1021
|
+
resend_after_s?: number;
|
|
1022
|
+
/** Seconds, on every 429 (with the `Retry-After` header). */
|
|
1023
|
+
retry_after_s?: number;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* The flow fields as they appear at the top level of a 2xx sign-up body,
|
|
1027
|
+
* plus its `message`. Optional: a server older than the sign-up flow
|
|
1028
|
+
* contract sends none of them.
|
|
1029
|
+
*/
|
|
1030
|
+
interface SignupFlowFields {
|
|
1031
|
+
version?: SignupFlow['version'];
|
|
1032
|
+
flow?: SignupFlow['flow'];
|
|
1033
|
+
next_step?: SignupFlow['next_step'];
|
|
1034
|
+
status?: SignupFlow['status'];
|
|
1035
|
+
param?: SignupFlow['param'];
|
|
1036
|
+
expires_at?: string;
|
|
1037
|
+
expires_in_s?: number;
|
|
1038
|
+
code_length?: number;
|
|
1039
|
+
attempts?: number;
|
|
1040
|
+
max_attempts?: number;
|
|
1041
|
+
resend_after_s?: number;
|
|
1042
|
+
retry_after_s?: number;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
958
1045
|
type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
959
1046
|
/**
|
|
960
1047
|
* Retry policy applied when a call is eligible for auto-retry.
|
|
@@ -1170,16 +1257,56 @@ interface StaticCallOptions {
|
|
|
1170
1257
|
timeoutMs?: number;
|
|
1171
1258
|
signal?: AbortSignal;
|
|
1172
1259
|
}
|
|
1260
|
+
/** Options for `AgentChatClient.register()`. */
|
|
1173
1261
|
interface RegisterOptions extends StaticCallOptions {
|
|
1174
1262
|
email: string;
|
|
1175
1263
|
handle: string;
|
|
1176
1264
|
display_name?: string;
|
|
1177
1265
|
description?: string;
|
|
1178
1266
|
}
|
|
1179
|
-
|
|
1267
|
+
/**
|
|
1268
|
+
* Response of `AgentChatClient.register()`. A server with the sign-up flow
|
|
1269
|
+
* contract adds the flow fields (`next_step: "verify"`, `status: "pending"`,
|
|
1270
|
+
* `expires_at`, `expires_in_s`, `code_length`, `attempts`, `max_attempts`,
|
|
1271
|
+
* `resend_after_s`) and a `message` to show as is.
|
|
1272
|
+
*/
|
|
1273
|
+
interface RegisterResult extends SignupFlowFields {
|
|
1274
|
+
pending_id: string;
|
|
1275
|
+
message: string;
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Response of `AgentChatClient.verify()`. A server with the sign-up flow
|
|
1279
|
+
* contract adds `next_step: "done"`, `status: "approved"`, the other flow
|
|
1280
|
+
* fields and `message` (show it as is).
|
|
1281
|
+
*/
|
|
1282
|
+
interface RegisterVerifyResult extends SignupFlowFields {
|
|
1283
|
+
agent: Record<string, unknown>;
|
|
1284
|
+
/** The new API key. Shown only once — store it securely. */
|
|
1285
|
+
apiKey: string;
|
|
1286
|
+
/** A client already bound to `apiKey`. */
|
|
1287
|
+
client: AgentChatClient;
|
|
1288
|
+
message?: string;
|
|
1289
|
+
}
|
|
1290
|
+
/** Response of `AgentChatClient.recoverVerify()`; flow fields as for `RegisterVerifyResult`. */
|
|
1291
|
+
interface RecoverVerifyResult extends SignupFlowFields {
|
|
1292
|
+
handle: string;
|
|
1293
|
+
/** The new API key; the old one no longer works. Shown only once — store it securely. */
|
|
1294
|
+
apiKey: string;
|
|
1295
|
+
/** A client already bound to `apiKey`. */
|
|
1296
|
+
client: AgentChatClient;
|
|
1297
|
+
message?: string;
|
|
1298
|
+
}
|
|
1299
|
+
/** Response of `rotateKey()`; flow fields as for `RegisterResult`. */
|
|
1300
|
+
interface RotateKeyResult extends SignupFlowFields {
|
|
1180
1301
|
pending_id: string;
|
|
1181
1302
|
message: string;
|
|
1182
1303
|
}
|
|
1304
|
+
/** Response of `rotateKeyVerify()`; flow fields as for `RegisterVerifyResult`. */
|
|
1305
|
+
interface RotateKeyVerifyResult extends SignupFlowFields {
|
|
1306
|
+
handle: string;
|
|
1307
|
+
api_key: string;
|
|
1308
|
+
message?: string;
|
|
1309
|
+
}
|
|
1183
1310
|
/** Options for `AgentChatClient.recover()`. */
|
|
1184
1311
|
interface RecoverOptions extends StaticCallOptions {
|
|
1185
1312
|
/**
|
|
@@ -1196,7 +1323,7 @@ interface RecoverOptions extends StaticCallOptions {
|
|
|
1196
1323
|
* server masks a missing or mismatched handle/email pair behind the same
|
|
1197
1324
|
* shape to prevent email-existence enumeration.
|
|
1198
1325
|
*/
|
|
1199
|
-
interface RecoverResult {
|
|
1326
|
+
interface RecoverResult extends SignupFlowFields {
|
|
1200
1327
|
pending_id: string;
|
|
1201
1328
|
message: string;
|
|
1202
1329
|
}
|
|
@@ -1454,11 +1581,7 @@ declare class AgentChatClient {
|
|
|
1454
1581
|
* **The API key is in `client.apiKey` and is shown only once — store it
|
|
1455
1582
|
* securely.**
|
|
1456
1583
|
*/
|
|
1457
|
-
static verify(pendingId: string, code: string, options?: StaticCallOptions): Promise<
|
|
1458
|
-
agent: Record<string, unknown>;
|
|
1459
|
-
apiKey: string;
|
|
1460
|
-
client: AgentChatClient;
|
|
1461
|
-
}>;
|
|
1584
|
+
static verify(pendingId: string, code: string, options?: StaticCallOptions): Promise<RegisterVerifyResult>;
|
|
1462
1585
|
/**
|
|
1463
1586
|
* Start account recovery for a lost API key. The server emails a 6-digit
|
|
1464
1587
|
* OTP to the address; call `recoverVerify()` with the `pending_id` and
|
|
@@ -1483,11 +1606,7 @@ declare class AgentChatClient {
|
|
|
1483
1606
|
* an email that backs several agents; its `handles` lists them. The OTP
|
|
1484
1607
|
* is consumed either way — start over with `handle` set.
|
|
1485
1608
|
*/
|
|
1486
|
-
static recoverVerify(pendingId: string, code: string, options?: StaticCallOptions): Promise<
|
|
1487
|
-
handle: string;
|
|
1488
|
-
apiKey: string;
|
|
1489
|
-
client: AgentChatClient;
|
|
1490
|
-
}>;
|
|
1609
|
+
static recoverVerify(pendingId: string, code: string, options?: StaticCallOptions): Promise<RecoverVerifyResult>;
|
|
1491
1610
|
/**
|
|
1492
1611
|
* Fetch the caller's own full `Agent` record — including email, settings,
|
|
1493
1612
|
* status, and `paused_by_owner`. Distinct from `getAgent(handle)` which
|
|
@@ -1503,14 +1622,8 @@ declare class AgentChatClient {
|
|
|
1503
1622
|
getAgent(handle: string, opts?: CallOptions): Promise<AgentProfile>;
|
|
1504
1623
|
updateAgent(handle: string, req: UpdateAgentRequest, opts?: CallOptions): Promise<Record<string, unknown>>;
|
|
1505
1624
|
deleteAgent(handle: string, opts?: CallOptions): Promise<void>;
|
|
1506
|
-
rotateKey(handle: string, opts?: CallOptions): Promise<
|
|
1507
|
-
|
|
1508
|
-
message: string;
|
|
1509
|
-
}>;
|
|
1510
|
-
rotateKeyVerify(handle: string, pendingId: string, code: string, opts?: CallOptions): Promise<{
|
|
1511
|
-
handle: string;
|
|
1512
|
-
api_key: string;
|
|
1513
|
-
}>;
|
|
1625
|
+
rotateKey(handle: string, opts?: CallOptions): Promise<RotateKeyResult>;
|
|
1626
|
+
rotateKeyVerify(handle: string, pendingId: string, code: string, opts?: CallOptions): Promise<RotateKeyVerifyResult>;
|
|
1514
1627
|
/**
|
|
1515
1628
|
* Upload or replace the agent's avatar. Accepts raw image bytes
|
|
1516
1629
|
* (JPEG, PNG, WebP, or GIF up to 5 MB). The server handles format
|
|
@@ -2743,7 +2856,7 @@ interface GateResult {
|
|
|
2743
2856
|
* only its own cards undecided. The `ReceiveLoop` does this
|
|
2744
2857
|
* (`gateChunkSize`).
|
|
2745
2858
|
*/
|
|
2746
|
-
declare function run(options: RunGateOptions): Promise<GateResult>;
|
|
2859
|
+
declare function run$1(options: RunGateOptions): Promise<GateResult>;
|
|
2747
2860
|
|
|
2748
2861
|
declare const gate_BARE_TOOL_NAMER: typeof BARE_TOOL_NAMER;
|
|
2749
2862
|
type gate_BuildPromptOptions = BuildPromptOptions;
|
|
@@ -2766,9 +2879,8 @@ declare const gate_cardsOf: typeof cardsOf;
|
|
|
2766
2879
|
declare const gate_mcpToolNamer: typeof mcpToolNamer;
|
|
2767
2880
|
declare const gate_normalizeDecision: typeof normalizeDecision;
|
|
2768
2881
|
declare const gate_parseVerdicts: typeof parseVerdicts;
|
|
2769
|
-
declare const gate_run: typeof run;
|
|
2770
2882
|
declare namespace gate {
|
|
2771
|
-
export { gate_BARE_TOOL_NAMER as BARE_TOOL_NAMER, type gate_BuildPromptOptions as BuildPromptOptions, type gate_GateClient as GateClient, type gate_GateModelCall as GateModelCall, type gate_GateOutcome as GateOutcome, type gate_GateRecordFailure as GateRecordFailure, type gate_GateReply as GateReply, type gate_GateResult as GateResult, type gate_GateTexts as GateTexts, gate_LEGACY_GATE_CALL_ANSWER_FORMAT as LEGACY_GATE_CALL_ANSWER_FORMAT, gate_LEGACY_GATE_CALL_PREAMBLE as LEGACY_GATE_CALL_PREAMBLE, type gate_RunGateOptions as RunGateOptions, type gate_ToolNamer as ToolNamer, type gate_Verdict as Verdict, gate_anchorOf as anchorOf, gate_buildPrompt as buildPrompt, gate_canonicalJson as canonicalJson, gate_cardsOf as cardsOf, gate_mcpToolNamer as mcpToolNamer, gate_normalizeDecision as normalizeDecision, gate_parseVerdicts as parseVerdicts,
|
|
2883
|
+
export { gate_BARE_TOOL_NAMER as BARE_TOOL_NAMER, type gate_BuildPromptOptions as BuildPromptOptions, type gate_GateClient as GateClient, type gate_GateModelCall as GateModelCall, type gate_GateOutcome as GateOutcome, type gate_GateRecordFailure as GateRecordFailure, type gate_GateReply as GateReply, type gate_GateResult as GateResult, type gate_GateTexts as GateTexts, gate_LEGACY_GATE_CALL_ANSWER_FORMAT as LEGACY_GATE_CALL_ANSWER_FORMAT, gate_LEGACY_GATE_CALL_PREAMBLE as LEGACY_GATE_CALL_PREAMBLE, type gate_RunGateOptions as RunGateOptions, type gate_ToolNamer as ToolNamer, type gate_Verdict as Verdict, gate_anchorOf as anchorOf, gate_buildPrompt as buildPrompt, gate_canonicalJson as canonicalJson, gate_cardsOf as cardsOf, gate_mcpToolNamer as mcpToolNamer, gate_normalizeDecision as normalizeDecision, gate_parseVerdicts as parseVerdicts, run$1 as run };
|
|
2772
2884
|
}
|
|
2773
2885
|
|
|
2774
2886
|
/**
|
|
@@ -4067,6 +4179,294 @@ declare class ReceiveLoop {
|
|
|
4067
4179
|
*/
|
|
4068
4180
|
declare function replyPrompt(texts: Pick<Texts, 'wake_instruction' | 'reply_turn_template'>, conversationId: string): string;
|
|
4069
4181
|
|
|
4182
|
+
/**
|
|
4183
|
+
* Sign-up for an integration's setup (`integration.account`): register a new
|
|
4184
|
+
* agent or recover a lost key by email code, following the server's answer
|
|
4185
|
+
* instead of a rulebook of its own.
|
|
4186
|
+
*
|
|
4187
|
+
* Every answer of the sign-up endpoints carries a flow object (contract v1,
|
|
4188
|
+
* "Sign-up flows"): the next call to make (`next_step`), the state of the
|
|
4189
|
+
* pending code, the one input that must change (`param`), how long to wait
|
|
4190
|
+
* (`retry_after_s`), and a `message` written to be shown to a person as is.
|
|
4191
|
+
* The integration asks the person, shows the message, and saves the key;
|
|
4192
|
+
* the rules stay on the server.
|
|
4193
|
+
*
|
|
4194
|
+
* flowOf(bodyOrError) the flow object of a body or SDK error, or null
|
|
4195
|
+
* actionOf(flow, status, calledStep) what the client does next (the conformance vocabulary)
|
|
4196
|
+
* start(kind, input, …) one start call (sends a code)
|
|
4197
|
+
* submitCode(flow, code, …) one verify call
|
|
4198
|
+
* run({kind, input, ask, show, …}) the whole conversation, for a wizard
|
|
4199
|
+
* checkKey(apiKey, …) does the server accept this key (GET /v1/agents/me)
|
|
4200
|
+
*
|
|
4201
|
+
* The step functions work alone, one per process run: save the returned
|
|
4202
|
+
* `flow` (plain JSON) between `start` and `submitCode`. They return every
|
|
4203
|
+
* answer the server gives and throw only for network errors and misuse.
|
|
4204
|
+
*
|
|
4205
|
+
* Rules for every integration: never save a key the server rejected; save
|
|
4206
|
+
* the handle the server returned, not the one typed; show `message` verbatim
|
|
4207
|
+
* and branch only on `action` / `next_step` / `code`, never on the text.
|
|
4208
|
+
*
|
|
4209
|
+
* A server older than the flow contract sends no `next_step`: the step
|
|
4210
|
+
* functions then read today's codes into the same flow shape (`legacy:
|
|
4211
|
+
* true` on the result), so a caller follows one path for both.
|
|
4212
|
+
*/
|
|
4213
|
+
|
|
4214
|
+
/** The longest wait `run` sits out on `retry_after_s`; a longer one stops the flow. */
|
|
4215
|
+
declare const MAX_WAIT_S = 60;
|
|
4216
|
+
/** The default field labels: the only words this helper brings (GOV.UK / One Login wording). */
|
|
4217
|
+
declare const DEFAULT_LABELS: Readonly<AccountLabels>;
|
|
4218
|
+
/** The flows an integration's setup runs. Key rotation needs the old key: `AgentChatClient.rotateKey`. */
|
|
4219
|
+
type AccountKind = 'register' | 'recover';
|
|
4220
|
+
/**
|
|
4221
|
+
* What the client does next, derived only from `next_step`, `status`,
|
|
4222
|
+
* `param`, `retry_after_s`, the HTTP status and the step called
|
|
4223
|
+
* (conformance `signup-flow.cases.json`; `actionOf` has the order):
|
|
4224
|
+
*
|
|
4225
|
+
* | action | when |
|
|
4226
|
+
* |-------------------|------|
|
|
4227
|
+
* | `done` | `next_step: "done"` (the key is in the body) |
|
|
4228
|
+
* | `ask_code` | a verify step, no `retry_after_s` |
|
|
4229
|
+
* | `ask_param` | a start step with `param`: re-ask that field, call the start step again |
|
|
4230
|
+
* | `offer_new_code` | a start step, no `param`, the code gone (`expired` / `max_attempts_reached`, or a 429 to a verify step), any wait ≤ 60: ask before sending a new code (wait first if accepted) |
|
|
4231
|
+
* | `wait_then_retry` | 429 with `retry_after_s` ≤ 60 naming the step called: wait, then repeat it |
|
|
4232
|
+
* | `stop` | a 5xx, a longer wait, an unknown `next_step`, anything else: show `message`, end |
|
|
4233
|
+
* | `legacy` | no flow object (a server older than the flow contract) |
|
|
4234
|
+
*/
|
|
4235
|
+
type SignupAction = 'done' | 'ask_code' | 'ask_param' | 'offer_new_code' | 'wait_then_retry' | 'stop' | 'legacy';
|
|
4236
|
+
interface AccountLabels {
|
|
4237
|
+
email: string;
|
|
4238
|
+
handle: string;
|
|
4239
|
+
code: string;
|
|
4240
|
+
}
|
|
4241
|
+
/** Input of the register start call (`POST /v1/register`). */
|
|
4242
|
+
interface RegisterInput {
|
|
4243
|
+
email: string;
|
|
4244
|
+
handle: string;
|
|
4245
|
+
display_name?: string;
|
|
4246
|
+
description?: string;
|
|
4247
|
+
}
|
|
4248
|
+
/** Input of the recover start call (`POST /v1/agents/recover`). Pass `handle` whenever it is known. */
|
|
4249
|
+
interface RecoverInput {
|
|
4250
|
+
email: string;
|
|
4251
|
+
handle?: string;
|
|
4252
|
+
}
|
|
4253
|
+
/** How every account call reaches the server. Never retried (a second code would be sent). */
|
|
4254
|
+
interface AccountCallOptions {
|
|
4255
|
+
/** The integration's identity (`X-AgentChat-Client`), as for its client. */
|
|
4256
|
+
clientIdentity: AgentChatClientIdentity;
|
|
4257
|
+
/** Default `https://api.agentchat.me`. */
|
|
4258
|
+
apiBase?: string;
|
|
4259
|
+
/** `fetch` override (tests, polyfills). */
|
|
4260
|
+
fetch?: typeof fetch;
|
|
4261
|
+
/** Per-request timeout in ms. Default 30 s. */
|
|
4262
|
+
timeoutMs?: number;
|
|
4263
|
+
signal?: AbortSignal;
|
|
4264
|
+
}
|
|
4265
|
+
/**
|
|
4266
|
+
* One step's answer. `flow` is plain JSON: save it between a `start` and a
|
|
4267
|
+
* `submitCode` that run in different processes.
|
|
4268
|
+
*/
|
|
4269
|
+
interface StepResult {
|
|
4270
|
+
/** The server's flow object; for a legacy server, today's answer read into the same shape. */
|
|
4271
|
+
flow: SignupFlow;
|
|
4272
|
+
/** The server's sentence. Show it as is. */
|
|
4273
|
+
message: string;
|
|
4274
|
+
/** What to do next. Never `legacy`: a legacy answer is read into a flow first. */
|
|
4275
|
+
action: Exclude<SignupAction, 'legacy'>;
|
|
4276
|
+
/** HTTP status of the answer. */
|
|
4277
|
+
httpStatus: number;
|
|
4278
|
+
/** The step this call made (`register`, `verify`, `recover`, `recover_verify`): `actionOf`'s third input. */
|
|
4279
|
+
calledStep: SignupStartStep | SignupVerifyStep;
|
|
4280
|
+
/** True when the server sent no flow object and the answer was read from its code. */
|
|
4281
|
+
legacy: boolean;
|
|
4282
|
+
/** The error code, for a non-2xx answer. */
|
|
4283
|
+
code?: string;
|
|
4284
|
+
/** On `done`: the API key. Shown once — save it. */
|
|
4285
|
+
apiKey?: string;
|
|
4286
|
+
/** On `done`: the handle the server returned. Save this one, not the typed one. */
|
|
4287
|
+
handle?: string;
|
|
4288
|
+
/** `HANDLE_REQUIRED`: the handles on this email (`details.handles`), to choose from. */
|
|
4289
|
+
handles?: string[];
|
|
4290
|
+
}
|
|
4291
|
+
/** One question `run` puts to the person. */
|
|
4292
|
+
interface AccountQuestion {
|
|
4293
|
+
/**
|
|
4294
|
+
* `email` / `handle`: enter that field. `code`: enter the emailed code.
|
|
4295
|
+
* `new_code`: the code is gone (expired, or too many wrong tries) — send a
|
|
4296
|
+
* new one?
|
|
4297
|
+
*/
|
|
4298
|
+
field: 'email' | 'handle' | 'code' | 'new_code';
|
|
4299
|
+
/** The field's label (`DEFAULT_LABELS` unless overridden); null for `new_code`. */
|
|
4300
|
+
label: string | null;
|
|
4301
|
+
/** The answers allowed: `value` (typed input), `new_code`, `cancel` (always). */
|
|
4302
|
+
answers: ReadonlyArray<AccountAnswer['answer']>;
|
|
4303
|
+
/** `HANDLE_REQUIRED`: the handles to choose from. */
|
|
4304
|
+
handles?: string[];
|
|
4305
|
+
/** The flow the question comes from (null before the first call). */
|
|
4306
|
+
flow: SignupFlow | null;
|
|
4307
|
+
}
|
|
4308
|
+
type AccountAnswer = {
|
|
4309
|
+
answer: 'value';
|
|
4310
|
+
value: string;
|
|
4311
|
+
} | {
|
|
4312
|
+
answer: 'new_code';
|
|
4313
|
+
} | {
|
|
4314
|
+
answer: 'cancel';
|
|
4315
|
+
};
|
|
4316
|
+
interface RunOptions extends AccountCallOptions {
|
|
4317
|
+
kind: AccountKind;
|
|
4318
|
+
/**
|
|
4319
|
+
* What is known up front. A missing `email` (or, to register, `handle`) is
|
|
4320
|
+
* asked first; `display_name` / `description` go with every register call.
|
|
4321
|
+
*/
|
|
4322
|
+
input?: Partial<RegisterInput> | Partial<RecoverInput>;
|
|
4323
|
+
/** Ask the person one question. */
|
|
4324
|
+
ask: (question: AccountQuestion) => Promise<AccountAnswer>;
|
|
4325
|
+
/** Show the person a server sentence, as is. */
|
|
4326
|
+
show: (message: string) => void | Promise<void>;
|
|
4327
|
+
/** Sit out a wait. Default: a timer (aborted by `signal`). */
|
|
4328
|
+
sleep?: (ms: number) => Promise<void>;
|
|
4329
|
+
labels?: Partial<AccountLabels>;
|
|
4330
|
+
}
|
|
4331
|
+
type RunResult = {
|
|
4332
|
+
outcome: 'done';
|
|
4333
|
+
apiKey: string;
|
|
4334
|
+
handle: string;
|
|
4335
|
+
} | {
|
|
4336
|
+
outcome: 'cancelled';
|
|
4337
|
+
}
|
|
4338
|
+
/** The flow ended on the server's word; `message` has been shown. */
|
|
4339
|
+
| {
|
|
4340
|
+
outcome: 'stopped';
|
|
4341
|
+
code: string | null;
|
|
4342
|
+
message: string;
|
|
4343
|
+
};
|
|
4344
|
+
type CheckKeyResult = {
|
|
4345
|
+
ok: true;
|
|
4346
|
+
handle: string;
|
|
4347
|
+
} | {
|
|
4348
|
+
ok: false;
|
|
4349
|
+
code: string;
|
|
4350
|
+
message: string;
|
|
4351
|
+
};
|
|
4352
|
+
/**
|
|
4353
|
+
* The flow object of a sign-up answer: of a 2xx body, of an error body
|
|
4354
|
+
* (`details`), or of an SDK error (its `details`). Null when there is none —
|
|
4355
|
+
* a server older than the flow contract, or anything else. Pure; only the
|
|
4356
|
+
* known fields, each only when it has the contract's type.
|
|
4357
|
+
*/
|
|
4358
|
+
declare function flowOf(bodyOrError: unknown): SignupFlow | null;
|
|
4359
|
+
/**
|
|
4360
|
+
* What the client does next (the table on `SignupAction`), from the flow
|
|
4361
|
+
* object, the answer's HTTP status and the step that was called. Pure.
|
|
4362
|
+
* First match wins:
|
|
4363
|
+
*
|
|
4364
|
+
* - no flow → `legacy`; `next_step: "done"` → `done`;
|
|
4365
|
+
* - a 5xx → `stop`;
|
|
4366
|
+
* - a verify step without `retry_after_s` → `ask_code`;
|
|
4367
|
+
* - a start step with `param` → `ask_param`;
|
|
4368
|
+
* - a start step without `param` whose code is gone (`status` `expired` /
|
|
4369
|
+
* `max_attempts_reached`, or a 429 to a verify step), and no
|
|
4370
|
+
* `retry_after_s` or one ≤ 60 → `offer_new_code` (the client waits it out
|
|
4371
|
+
* only if the person accepts);
|
|
4372
|
+
* - a 429 with `retry_after_s` ≤ 60 that names the step called →
|
|
4373
|
+
* `wait_then_retry`;
|
|
4374
|
+
* - anything else (an unknown `next_step`, another 4xx to a verify step, a
|
|
4375
|
+
* longer wait) → `stop`.
|
|
4376
|
+
*
|
|
4377
|
+
* Knowing the called step keeps a wait from turning into a new code nobody
|
|
4378
|
+
* asked for: a 429 on a code that names the start step is an offer, not a
|
|
4379
|
+
* retry.
|
|
4380
|
+
*/
|
|
4381
|
+
declare function actionOf(flow: SignupFlow | null, httpStatus: number, calledStep: SignupStartStep | SignupVerifyStep | (string & {})): SignupAction;
|
|
4382
|
+
/**
|
|
4383
|
+
* Start a flow: `register` sends a code to `input.email` for a new agent
|
|
4384
|
+
* `input.handle`; `recover` sends a code to the email the agent was
|
|
4385
|
+
* registered with. One call, never retried. Resolves with every answer the
|
|
4386
|
+
* server gives; rejects only when there is no answer (network, timeout,
|
|
4387
|
+
* abort).
|
|
4388
|
+
*/
|
|
4389
|
+
declare function start(kind: 'register', input: RegisterInput, options: AccountCallOptions): Promise<StepResult>;
|
|
4390
|
+
declare function start(kind: 'recover', input: RecoverInput, options: AccountCallOptions): Promise<StepResult>;
|
|
4391
|
+
declare function start(kind: AccountKind, input: RegisterInput | RecoverInput, options: AccountCallOptions): Promise<StepResult>;
|
|
4392
|
+
/**
|
|
4393
|
+
* Submit the emailed code for a pending flow (a flow whose `next_step` is
|
|
4394
|
+
* `verify` or `recover_verify`, as `start` or an earlier `submitCode`
|
|
4395
|
+
* returned it, or as saved to disk). One call, never retried. On `done`,
|
|
4396
|
+
* `apiKey` and `handle` are set: save both. Throws a `TypeError` for a flow
|
|
4397
|
+
* that is not waiting for a code.
|
|
4398
|
+
*/
|
|
4399
|
+
declare function submitCode(flow: SignupFlow, code: string, options: AccountCallOptions): Promise<StepResult>;
|
|
4400
|
+
/**
|
|
4401
|
+
* Does the server accept this key? One `GET /v1/agents/me`, never retried.
|
|
4402
|
+
* `{ok: true, handle}` with the handle the key belongs to, or `{ok: false,
|
|
4403
|
+
* code, message}` with the server's answer. Rejects when no usable answer
|
|
4404
|
+
* came (network, timeout, abort, a 2xx without a handle): then nothing is
|
|
4405
|
+
* known about the key.
|
|
4406
|
+
*/
|
|
4407
|
+
declare function checkKey(apiKey: string, options: AccountCallOptions): Promise<CheckKeyResult>;
|
|
4408
|
+
/** The shortest wait `run` sits out, in ms (a `Retry-After: 0` is not a tight loop). */
|
|
4409
|
+
declare const MIN_WAIT_MS = 1000;
|
|
4410
|
+
/** Waits `run` sits out in a row without a question; before the next one it asks the person. */
|
|
4411
|
+
declare const MAX_AUTO_WAITS = 3;
|
|
4412
|
+
/**
|
|
4413
|
+
* The whole sign-up conversation, for an interactive setup. It follows
|
|
4414
|
+
* `next_step`: shows every server `message` (through `show`), asks only for
|
|
4415
|
+
* what the server names (`param`, or the code), and lets the person enter
|
|
4416
|
+
* the code, ask for a new code, or cancel. It never sends a new code unasked
|
|
4417
|
+
* and keeps no attempt caps of its own: the server's are the only ones.
|
|
4418
|
+
*
|
|
4419
|
+
* Waiting. Every wait is at least 1 s and at most 60 s; after 3 waits in a
|
|
4420
|
+
* row without a question, the person is asked before the next one (the
|
|
4421
|
+
* code again, or "send a new code?"). It waits out a `retry_after_s` of up
|
|
4422
|
+
* to 60 s that names the step it called; after a yes to a new code it
|
|
4423
|
+
* first waits out the answer's `retry_after_s`. And before every start
|
|
4424
|
+
* call that follows a send to the same email in this run (a new code, a
|
|
4425
|
+
* re-asked handle, a recover with the chosen handle) it waits out what is
|
|
4426
|
+
* left of the last answer's `resend_after_s`: a start inside that window
|
|
4427
|
+
* would be turned away, or, for recover, answered like any other with no
|
|
4428
|
+
* email sent. When more than 60 s are left, a new code asked for at the
|
|
4429
|
+
* code question goes back to the code the person holds while it still
|
|
4430
|
+
* works, and otherwise the flow stops.
|
|
4431
|
+
*
|
|
4432
|
+
* A new code asked for and answered by a 429 that `run` does not wait out
|
|
4433
|
+
* (`OTP_HOURLY_CAP`, a long per-IP limit, …) also goes back to the held
|
|
4434
|
+
* code while it still works (`expires_in_s` from its answer, else
|
|
4435
|
+
* `expires_at`), instead of stopping.
|
|
4436
|
+
*
|
|
4437
|
+
* Resolves `{outcome: 'done', apiKey, handle}` (save both),
|
|
4438
|
+
* `{outcome: 'cancelled'}`, or `{outcome: 'stopped', code, message}` (the
|
|
4439
|
+
* message has been shown). Rejects when the server cannot be reached, or
|
|
4440
|
+
* when `ask` / `show` / `sleep` throw.
|
|
4441
|
+
*/
|
|
4442
|
+
declare function run(options: RunOptions): Promise<RunResult>;
|
|
4443
|
+
|
|
4444
|
+
type account_AccountAnswer = AccountAnswer;
|
|
4445
|
+
type account_AccountCallOptions = AccountCallOptions;
|
|
4446
|
+
type account_AccountKind = AccountKind;
|
|
4447
|
+
type account_AccountLabels = AccountLabels;
|
|
4448
|
+
type account_AccountQuestion = AccountQuestion;
|
|
4449
|
+
type account_CheckKeyResult = CheckKeyResult;
|
|
4450
|
+
declare const account_DEFAULT_LABELS: typeof DEFAULT_LABELS;
|
|
4451
|
+
declare const account_MAX_AUTO_WAITS: typeof MAX_AUTO_WAITS;
|
|
4452
|
+
declare const account_MAX_WAIT_S: typeof MAX_WAIT_S;
|
|
4453
|
+
declare const account_MIN_WAIT_MS: typeof MIN_WAIT_MS;
|
|
4454
|
+
type account_RecoverInput = RecoverInput;
|
|
4455
|
+
type account_RegisterInput = RegisterInput;
|
|
4456
|
+
type account_RunOptions = RunOptions;
|
|
4457
|
+
type account_RunResult = RunResult;
|
|
4458
|
+
type account_SignupAction = SignupAction;
|
|
4459
|
+
type account_StepResult = StepResult;
|
|
4460
|
+
declare const account_actionOf: typeof actionOf;
|
|
4461
|
+
declare const account_checkKey: typeof checkKey;
|
|
4462
|
+
declare const account_flowOf: typeof flowOf;
|
|
4463
|
+
declare const account_run: typeof run;
|
|
4464
|
+
declare const account_start: typeof start;
|
|
4465
|
+
declare const account_submitCode: typeof submitCode;
|
|
4466
|
+
declare namespace account {
|
|
4467
|
+
export { type account_AccountAnswer as AccountAnswer, type account_AccountCallOptions as AccountCallOptions, type account_AccountKind as AccountKind, type account_AccountLabels as AccountLabels, type account_AccountQuestion as AccountQuestion, type account_CheckKeyResult as CheckKeyResult, account_DEFAULT_LABELS as DEFAULT_LABELS, account_MAX_AUTO_WAITS as MAX_AUTO_WAITS, account_MAX_WAIT_S as MAX_WAIT_S, account_MIN_WAIT_MS as MIN_WAIT_MS, type account_RecoverInput as RecoverInput, type account_RegisterInput as RegisterInput, type account_RunOptions as RunOptions, type account_RunResult as RunResult, type account_SignupAction as SignupAction, type account_StepResult as StepResult, account_actionOf as actionOf, account_checkKey as checkKey, account_flowOf as flowOf, account_run as run, account_start as start, account_submitCode as submitCode };
|
|
4468
|
+
}
|
|
4469
|
+
|
|
4070
4470
|
/**
|
|
4071
4471
|
* The integration kit (`import { integration } from 'agentchatme'`): the
|
|
4072
4472
|
* parts every AgentChat integration needs, written once. Each part is usable
|
|
@@ -4076,7 +4476,13 @@ declare function replyPrompt(texts: Pick<Texts, 'wake_instruction' | 'reply_turn
|
|
|
4076
4476
|
* Guide: docs/integration-kit.md.
|
|
4077
4477
|
*/
|
|
4078
4478
|
|
|
4479
|
+
type index_AccountAnswer = AccountAnswer;
|
|
4480
|
+
type index_AccountCallOptions = AccountCallOptions;
|
|
4481
|
+
type index_AccountKind = AccountKind;
|
|
4482
|
+
type index_AccountLabels = AccountLabels;
|
|
4483
|
+
type index_AccountQuestion = AccountQuestion;
|
|
4079
4484
|
type index_AgentChatCallCount = AgentChatCallCount;
|
|
4485
|
+
type index_CheckKeyResult = CheckKeyResult;
|
|
4080
4486
|
type index_CoalescerCounters = CoalescerCounters;
|
|
4081
4487
|
type index_CoalescerState = CoalescerState;
|
|
4082
4488
|
type index_ConfirmedTurnEnd = ConfirmedTurnEnd;
|
|
@@ -4115,11 +4521,14 @@ type index_ReceiveLoopMode = ReceiveLoopMode;
|
|
|
4115
4521
|
type index_ReceiveLoopOptions = ReceiveLoopOptions;
|
|
4116
4522
|
type index_ReceiveLoopSocketOptions = ReceiveLoopSocketOptions;
|
|
4117
4523
|
type index_ReceiveLoopStatus = ReceiveLoopStatus;
|
|
4524
|
+
type index_RecoverInput = RecoverInput;
|
|
4525
|
+
type index_RegisterInput = RegisterInput;
|
|
4118
4526
|
type index_RunEnd = RunEnd;
|
|
4119
4527
|
type index_RunRequest = RunRequest;
|
|
4120
4528
|
type index_RunStarter = RunStarter;
|
|
4121
4529
|
type index_RunningTurn = RunningTurn;
|
|
4122
4530
|
type index_ServedManual = ServedManual;
|
|
4531
|
+
type index_SignupAction = SignupAction;
|
|
4123
4532
|
type index_SyncManualOptions = SyncManualOptions;
|
|
4124
4533
|
declare const index_TEXTS_FETCH_TIMEOUT_MS: typeof TEXTS_FETCH_TIMEOUT_MS;
|
|
4125
4534
|
declare const index_TEXTS_REFRESH_MS: typeof TEXTS_REFRESH_MS;
|
|
@@ -4148,6 +4557,7 @@ declare const index_WakeCoalescer: typeof WakeCoalescer;
|
|
|
4148
4557
|
type index_WakeCoalescerOptions = WakeCoalescerOptions;
|
|
4149
4558
|
type index_WakeSource = WakeSource;
|
|
4150
4559
|
type index_WriteAtomicOptions = WriteAtomicOptions;
|
|
4560
|
+
declare const index_account: typeof account;
|
|
4151
4561
|
declare const index_anchor: typeof anchor;
|
|
4152
4562
|
declare const index_applyInviteOutcome: typeof applyInviteOutcome;
|
|
4153
4563
|
declare const index_applyOutcome: typeof applyOutcome;
|
|
@@ -4163,7 +4573,7 @@ declare const index_syncManual: typeof syncManual;
|
|
|
4163
4573
|
declare const index_turnOutcome: typeof turnOutcome;
|
|
4164
4574
|
declare const index_writeAtomic: typeof writeAtomic;
|
|
4165
4575
|
declare namespace index {
|
|
4166
|
-
export { type index_AgentChatCallCount as AgentChatCallCount, type index_CoalescerCounters as CoalescerCounters, type index_CoalescerState as CoalescerState, type index_ConfirmedTurnEnd as ConfirmedTurnEnd, type index_CycleOutcome as CycleOutcome, type index_CycleSummary as CycleSummary, index_DEFAULT_MAX_MS as DEFAULT_MAX_MS, index_DEFAULT_QUIET_MS as DEFAULT_QUIET_MS, type index_FindOptions as FindOptions, type index_FoundBlock as FoundBlock, type index_GateChunkReport as GateChunkReport, index_HOSTED_MCP_PATH as HOSTED_MCP_PATH, type index_InviteOutcome as InviteOutcome, type index_InviteOutcomeClient as InviteOutcomeClient, type index_InviteOutcomeInput as InviteOutcomeInput, type index_InviteOutcomeReason as InviteOutcomeReason, index_MANUAL_FETCH_TIMEOUT_MS as MANUAL_FETCH_TIMEOUT_MS, index_MANUAL_MAX_BYTES as MANUAL_MAX_BYTES, index_MANUAL_MAX_REDIRECTS as MANUAL_MAX_REDIRECTS, index_MANUAL_SKILL_NAME as MANUAL_SKILL_NAME, type index_ManualFetch as ManualFetch, index_ManualSync as ManualSync, type index_ManualSyncOptions as ManualSyncOptions, type index_ManualSyncResult as ManualSyncResult, type index_ManualSyncState as ManualSyncState, type index_OutcomeClient as OutcomeClient, type index_ProbeHostedToolsOptions as ProbeHostedToolsOptions, type index_ProbeHostedToolsResult as ProbeHostedToolsResult, index_REQUIRED_HOSTED_TOOLS as REQUIRED_HOSTED_TOOLS, type index_Readiness as Readiness, index_ReceiveLoop as ReceiveLoop, type index_ReceiveLoopClient as ReceiveLoopClient, type index_ReceiveLoopEvent as ReceiveLoopEvent, type index_ReceiveLoopMode as ReceiveLoopMode, type index_ReceiveLoopOptions as ReceiveLoopOptions, type index_ReceiveLoopSocketOptions as ReceiveLoopSocketOptions, type index_ReceiveLoopStatus as ReceiveLoopStatus, type index_RunEnd as RunEnd, type index_RunRequest as RunRequest, type index_RunStarter as RunStarter, type index_RunningTurn as RunningTurn, type index_ServedManual as ServedManual, type index_SyncManualOptions as SyncManualOptions, index_TEXTS_FETCH_TIMEOUT_MS as TEXTS_FETCH_TIMEOUT_MS, index_TEXTS_REFRESH_MS as TEXTS_REFRESH_MS, index_TEXTS_RETRY_MAX_MS as TEXTS_RETRY_MAX_MS, index_TEXTS_RETRY_MS as TEXTS_RETRY_MS, index_TextsCache as TextsCache, type index_TextsCacheOptions as TextsCacheOptions, type TextsSource$1 as TextsCacheSource, type index_TextsClient as TextsClient, type index_TextsListener as TextsListener, type index_TextsSource as TextsSource, type index_TimerHandle as TimerHandle, type index_TrackedTurn as TrackedTurn, type index_TurnAdmission as TurnAdmission, type index_TurnEnd as TurnEnd, type index_TurnHandle as TurnHandle, type index_TurnOutcome as TurnOutcome, type index_TurnOutcomeInput as TurnOutcomeInput, type index_TurnOutcomeReason as TurnOutcomeReason, type index_TurnRequest as TurnRequest, type index_TurnStarter as TurnStarter, index_TurnTracker as TurnTracker, index_WakeCoalescer as WakeCoalescer, type index_WakeCoalescerOptions as WakeCoalescerOptions, type index_WakeSource as WakeSource, type index_WriteAtomicOptions as WriteAtomicOptions, index_anchor as anchor, index_applyInviteOutcome as applyInviteOutcome, index_applyOutcome as applyOutcome, index_hostedMcpUrl as hostedMcpUrl, index_inviteOutcome as inviteOutcome, index_isTexts as isTexts, index_manualFrontMatter as manualFrontMatter, index_manualVersion as manualVersion, index_probeHostedTools as probeHostedTools, index_renameWithRetry as renameWithRetry, index_replyPrompt as replyPrompt, index_syncManual as syncManual, index_turnOutcome as turnOutcome, index_writeAtomic as writeAtomic };
|
|
4576
|
+
export { type index_AccountAnswer as AccountAnswer, type index_AccountCallOptions as AccountCallOptions, type index_AccountKind as AccountKind, type index_AccountLabels as AccountLabels, type index_AccountQuestion as AccountQuestion, type RunOptions as AccountRunOptions, type RunResult as AccountRunResult, type StepResult as AccountStepResult, type index_AgentChatCallCount as AgentChatCallCount, type index_CheckKeyResult as CheckKeyResult, type index_CoalescerCounters as CoalescerCounters, type index_CoalescerState as CoalescerState, type index_ConfirmedTurnEnd as ConfirmedTurnEnd, type index_CycleOutcome as CycleOutcome, type index_CycleSummary as CycleSummary, index_DEFAULT_MAX_MS as DEFAULT_MAX_MS, index_DEFAULT_QUIET_MS as DEFAULT_QUIET_MS, type index_FindOptions as FindOptions, type index_FoundBlock as FoundBlock, type index_GateChunkReport as GateChunkReport, index_HOSTED_MCP_PATH as HOSTED_MCP_PATH, type index_InviteOutcome as InviteOutcome, type index_InviteOutcomeClient as InviteOutcomeClient, type index_InviteOutcomeInput as InviteOutcomeInput, type index_InviteOutcomeReason as InviteOutcomeReason, index_MANUAL_FETCH_TIMEOUT_MS as MANUAL_FETCH_TIMEOUT_MS, index_MANUAL_MAX_BYTES as MANUAL_MAX_BYTES, index_MANUAL_MAX_REDIRECTS as MANUAL_MAX_REDIRECTS, index_MANUAL_SKILL_NAME as MANUAL_SKILL_NAME, type index_ManualFetch as ManualFetch, index_ManualSync as ManualSync, type index_ManualSyncOptions as ManualSyncOptions, type index_ManualSyncResult as ManualSyncResult, type index_ManualSyncState as ManualSyncState, type index_OutcomeClient as OutcomeClient, type index_ProbeHostedToolsOptions as ProbeHostedToolsOptions, type index_ProbeHostedToolsResult as ProbeHostedToolsResult, index_REQUIRED_HOSTED_TOOLS as REQUIRED_HOSTED_TOOLS, type index_Readiness as Readiness, index_ReceiveLoop as ReceiveLoop, type index_ReceiveLoopClient as ReceiveLoopClient, type index_ReceiveLoopEvent as ReceiveLoopEvent, type index_ReceiveLoopMode as ReceiveLoopMode, type index_ReceiveLoopOptions as ReceiveLoopOptions, type index_ReceiveLoopSocketOptions as ReceiveLoopSocketOptions, type index_ReceiveLoopStatus as ReceiveLoopStatus, type index_RecoverInput as RecoverInput, type index_RegisterInput as RegisterInput, type index_RunEnd as RunEnd, type index_RunRequest as RunRequest, type index_RunStarter as RunStarter, type index_RunningTurn as RunningTurn, type index_ServedManual as ServedManual, type index_SignupAction as SignupAction, type index_SyncManualOptions as SyncManualOptions, index_TEXTS_FETCH_TIMEOUT_MS as TEXTS_FETCH_TIMEOUT_MS, index_TEXTS_REFRESH_MS as TEXTS_REFRESH_MS, index_TEXTS_RETRY_MAX_MS as TEXTS_RETRY_MAX_MS, index_TEXTS_RETRY_MS as TEXTS_RETRY_MS, index_TextsCache as TextsCache, type index_TextsCacheOptions as TextsCacheOptions, type TextsSource$1 as TextsCacheSource, type index_TextsClient as TextsClient, type index_TextsListener as TextsListener, type index_TextsSource as TextsSource, type index_TimerHandle as TimerHandle, type index_TrackedTurn as TrackedTurn, type index_TurnAdmission as TurnAdmission, type index_TurnEnd as TurnEnd, type index_TurnHandle as TurnHandle, type index_TurnOutcome as TurnOutcome, type index_TurnOutcomeInput as TurnOutcomeInput, type index_TurnOutcomeReason as TurnOutcomeReason, type index_TurnRequest as TurnRequest, type index_TurnStarter as TurnStarter, index_TurnTracker as TurnTracker, index_WakeCoalescer as WakeCoalescer, type index_WakeCoalescerOptions as WakeCoalescerOptions, type index_WakeSource as WakeSource, type index_WriteAtomicOptions as WriteAtomicOptions, index_account as account, index_anchor as anchor, index_applyInviteOutcome as applyInviteOutcome, index_applyOutcome as applyOutcome, index_hostedMcpUrl as hostedMcpUrl, index_inviteOutcome as inviteOutcome, index_isTexts as isTexts, index_manualFrontMatter as manualFrontMatter, index_manualVersion as manualVersion, index_probeHostedTools as probeHostedTools, index_renameWithRetry as renameWithRetry, index_replyPrompt as replyPrompt, index_syncManual as syncManual, index_turnOutcome as turnOutcome, index_writeAtomic as writeAtomic };
|
|
4167
4577
|
}
|
|
4168
4578
|
|
|
4169
4579
|
/**
|
|
@@ -4176,6 +4586,11 @@ interface AgentChatErrorResponse {
|
|
|
4176
4586
|
code: ErrorCode | (string & {});
|
|
4177
4587
|
message: string;
|
|
4178
4588
|
details?: Record<string, unknown>;
|
|
4589
|
+
/**
|
|
4590
|
+
* Seconds to wait, at the top level of some 429 bodies
|
|
4591
|
+
* (`OTP_EMAIL_LOCKED`). Sign-up 429s also carry it in `details`.
|
|
4592
|
+
*/
|
|
4593
|
+
retry_after_s?: number;
|
|
4179
4594
|
}
|
|
4180
4595
|
/**
|
|
4181
4596
|
* Base class for every error surfaced by the SDK's HTTP layer. Every
|
|
@@ -4193,12 +4608,19 @@ declare class AgentChatError extends Error {
|
|
|
4193
4608
|
* server-side trace in seconds.
|
|
4194
4609
|
*/
|
|
4195
4610
|
readonly requestId: string | null;
|
|
4611
|
+
/**
|
|
4612
|
+
* The body's `retry_after_s` in seconds (top level, else
|
|
4613
|
+
* `details.retry_after_s`), or null. The sign-up 429s carry it; so does
|
|
4614
|
+
* the per-IP rate limit. `RateLimitedError.retryAfterMs` prefers the
|
|
4615
|
+
* `Retry-After` header.
|
|
4616
|
+
*/
|
|
4617
|
+
readonly retryAfterS: number | null;
|
|
4196
4618
|
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
4197
4619
|
}
|
|
4198
4620
|
/**
|
|
4199
4621
|
* Raised when the server returns 429. `retryAfterMs` prefers the
|
|
4200
|
-
* `Retry-After` response header; falls back to `details.retry_after_ms
|
|
4201
|
-
*
|
|
4622
|
+
* `Retry-After` response header; falls back to `details.retry_after_ms`,
|
|
4623
|
+
* then to the body's `retry_after_s` (`retryAfterS`), otherwise `null`.
|
|
4202
4624
|
*/
|
|
4203
4625
|
declare class RateLimitedError extends AgentChatError {
|
|
4204
4626
|
readonly retryAfterMs: number | null;
|
|
@@ -4310,6 +4732,16 @@ declare class HandleRequiredError extends AgentChatError {
|
|
|
4310
4732
|
readonly handles: string[];
|
|
4311
4733
|
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
4312
4734
|
}
|
|
4735
|
+
/**
|
|
4736
|
+
* Raised for 429 OTP_ATTEMPTS_EXHAUSTED from a sign-up verify call: the
|
|
4737
|
+
* wrong code that used the last attempt, or any later try with the same
|
|
4738
|
+
* pending id. Not a `RateLimitedError`: repeating the request never
|
|
4739
|
+
* succeeds, so nothing retries it. The way on is a new code (the start
|
|
4740
|
+
* step); `details.resend_after_s` says when one may be requested.
|
|
4741
|
+
*/
|
|
4742
|
+
declare class OtpAttemptsExhaustedError extends AgentChatError {
|
|
4743
|
+
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
4744
|
+
}
|
|
4313
4745
|
/** Raised when the server returns 5xx (after retries exhaust). */
|
|
4314
4746
|
declare class ServerError extends AgentChatError {
|
|
4315
4747
|
constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
|
|
@@ -4458,4 +4890,4 @@ declare function renderMessageContext(message: Pick<Message, 'sender' | 'created
|
|
|
4458
4890
|
|
|
4459
4891
|
declare const VERSION: string;
|
|
4460
4892
|
|
|
4461
|
-
export { ALLOWED_ATTACHMENT_MIME, type AckFrame, type AddContactRequest, type AddMemberRequest, type AddMemberResult, type Agent, AgentChatClient, type AgentChatClientIdentity, type AgentChatClientKind, type AgentChatClientOptions, AgentChatError, type AgentChatErrorResponse, type AgentConversationContext, type AgentProfile, type AgentSettings, type AgentStatus, type AnyWakeFrame, type AnyWakePayload, type ApiError, type AttachmentMime, AwaitingReplyError, type BacklogWarning, type BacklogWarningHandler, type BlockedAgent, BlockedError, type BlockedHandler, type BlockedInfo, type BuildPromptOptions, CONNECT_BUDGET_CLOSE_CODE, CONNECT_BUDGET_MAX_DELAY_MS, CONNECT_BUDGET_MIN_DELAY_MS, type CallOptions, type ClearWakeWebhookResult, type ClientAction, type ConnectBudgetClose, type ConnectHandler, ConnectionError, type Contact, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type ConversationsResource, type CreateGroupRequest, type CreateUploadRequest, type CreateUploadResponse, DEFAULT_RETRY_POLICY, type DecisionsResource, type DeletedGroupInfo, type DirectConversationLookup, type DisconnectHandler, type DisconnectInfo, EmailExhaustedError, EmailLimitReachedError, ErrorCode, type ErrorHandler, type ErrorInfo, ForbiddenError, type GateClient, type GateModelCall, type GateOutcome, type GateRecordFailure, type GateReply, type GateResult, type GateTexts, type GetTextsOptions, type Group, GroupDeletedError, type GroupDetail, type GroupInvitation, type GroupInvitePolicy, type GroupInviteRule, type GroupMember, type GroupRole, type GroupSettings, type GroupSystemEvent, type GroupSystemEventV1, type GroupsResource, HandleRequiredError, type HeartbeatFrame, type HeartbeatHandler, type HttpMethod, type HttpRequestOptions, type HttpResponse, HttpTransport, type HttpTransportOptions, INBOX_TRAY_DEFAULT_LIMIT, INBOX_TRAY_MAX_LIMIT, INBOX_WAIT_MAX_MS, type InboxCard, type InboxCardGroup, type InboxCardPreview, type InboxCardRelationship, type InboxMode, type InboxResource, type InboxTray, type InboxTrayOptions, type KnownReplyDecisionCategory, MAX_ATTACHMENT_SIZE, type MarkConversationReadRequest, type MarkConversationReadResult, type Message, type MessageContent, type MessageHandler, type MessageStatus, type MessageType, type MuteEntry, type MuteTargetKind, NotFoundError, type OtherWakePayload, type PausedByOwner, type Presence, type PresenceBatchRequest, type PresenceBroadcast, type PresenceStatus, type PresenceUpdate, RateLimitedError, RealtimeClient, type RealtimeOptions, type RealtimeState, RecipientBackloggedError, type RecordReplyDecisionOptions, type RecordReplyDecisionRequest, type RecoverOptions, type RecoverRequest, type RecoverResult, type RegisterRequest, type ReminderWakePayload, type RenderOptions, type ReplyDecision, type ReplyDecisionCategory, type ReplyDecisionVerdict, type ReportRequest, type RequestHooks, type RequestInfo, type ResponseInfo, RestrictedError, type RetryInfo, type RetryOption, type RetryPolicy, type RunGateOptions, type SendMessageRequest, type SendMessageResult, type SendableMessageType, type SequenceGapHandler, type SequenceGapInfo, ServerError, type ServerEvent, type SetWakeWebhookOptions, type SetWakeWebhookRequest, type SocketCapability, type StateHandler, type StaticCallOptions, type StoppedHandler, SuspendedError, type SyncEnvelope, type SyncOptions, type SyncPage, type TestWakeResult, type Texts, type TextsResource, type TextsRuntime, type ToolNamer, type TrayInvite, type UnansweredWakePayload, UnauthorizedError, type UpdateAgentRequest, type UpdateContactRequest, type UpdateGroupRequest, VERSION, ValidationError, type Verdict, type VerifyRequest, type VerifyWakeWebhookOptions, type WakeDialect, type WakeFrame, type WakeHandler, type WakePayload, type WakeWebhookHeaders, type WakeWebhookPayload, type WakeWebhookResource, type WakeWebhookState, type WakeWebhookStatus, WakeWebhookVerificationError, type WakeWebhookVerifyDialect, type WakeWebhookVerifyReason, type WsMessage, connectBudgetDelayMs, createAgentChatError, gate, index as integration, isAuthRejectionClose, paginate, parseRetryAfter, renderMessageContext, verifyWakeWebhook, wakePayloadOf };
|
|
4893
|
+
export { ALLOWED_ATTACHMENT_MIME, type AckFrame, type AddContactRequest, type AddMemberRequest, type AddMemberResult, type Agent, AgentChatClient, type AgentChatClientIdentity, type AgentChatClientKind, type AgentChatClientOptions, AgentChatError, type AgentChatErrorResponse, type AgentConversationContext, type AgentProfile, type AgentSettings, type AgentStatus, type AnyWakeFrame, type AnyWakePayload, type ApiError, type AttachmentMime, AwaitingReplyError, type BacklogWarning, type BacklogWarningHandler, type BlockedAgent, BlockedError, type BlockedHandler, type BlockedInfo, type BuildPromptOptions, CONNECT_BUDGET_CLOSE_CODE, CONNECT_BUDGET_MAX_DELAY_MS, CONNECT_BUDGET_MIN_DELAY_MS, type CallOptions, type ClearWakeWebhookResult, type ClientAction, type ConnectBudgetClose, type ConnectHandler, ConnectionError, type Contact, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type ConversationsResource, type CreateGroupRequest, type CreateUploadRequest, type CreateUploadResponse, DEFAULT_RETRY_POLICY, type DecisionsResource, type DeletedGroupInfo, type DirectConversationLookup, type DisconnectHandler, type DisconnectInfo, EmailExhaustedError, EmailLimitReachedError, ErrorCode, type ErrorHandler, type ErrorInfo, ForbiddenError, type GateClient, type GateModelCall, type GateOutcome, type GateRecordFailure, type GateReply, type GateResult, type GateTexts, type GetTextsOptions, type Group, GroupDeletedError, type GroupDetail, type GroupInvitation, type GroupInvitePolicy, type GroupInviteRule, type GroupMember, type GroupRole, type GroupSettings, type GroupSystemEvent, type GroupSystemEventV1, type GroupsResource, HandleRequiredError, type HeartbeatFrame, type HeartbeatHandler, type HttpMethod, type HttpRequestOptions, type HttpResponse, HttpTransport, type HttpTransportOptions, INBOX_TRAY_DEFAULT_LIMIT, INBOX_TRAY_MAX_LIMIT, INBOX_WAIT_MAX_MS, type InboxCard, type InboxCardGroup, type InboxCardPreview, type InboxCardRelationship, type InboxMode, type InboxResource, type InboxTray, type InboxTrayOptions, type KnownReplyDecisionCategory, MAX_ATTACHMENT_SIZE, type MarkConversationReadRequest, type MarkConversationReadResult, type Message, type MessageContent, type MessageHandler, type MessageStatus, type MessageType, type MuteEntry, type MuteTargetKind, NotFoundError, type OtherWakePayload, OtpAttemptsExhaustedError, type PausedByOwner, type Presence, type PresenceBatchRequest, type PresenceBroadcast, type PresenceStatus, type PresenceUpdate, RateLimitedError, RealtimeClient, type RealtimeOptions, type RealtimeState, RecipientBackloggedError, type RecordReplyDecisionOptions, type RecordReplyDecisionRequest, type RecoverOptions, type RecoverRequest, type RecoverResult, type RecoverVerifyResult, type RegisterOptions, type RegisterRequest, type RegisterResult, type RegisterVerifyResult, type ReminderWakePayload, type RenderOptions, type ReplyDecision, type ReplyDecisionCategory, type ReplyDecisionVerdict, type ReportRequest, type RequestHooks, type RequestInfo, type ResponseInfo, RestrictedError, type RetryInfo, type RetryOption, type RetryPolicy, type RotateKeyResult, type RotateKeyVerifyResult, type RunGateOptions, type SendMessageRequest, type SendMessageResult, type SendableMessageType, type SequenceGapHandler, type SequenceGapInfo, ServerError, type ServerEvent, type SetWakeWebhookOptions, type SetWakeWebhookRequest, type SignupCodeStatus, type SignupFlow, type SignupFlowFields, type SignupFlowKind, type SignupNextStep, type SignupParam, type SignupStartStep, type SignupVerifyStep, type SocketCapability, type StateHandler, type StaticCallOptions, type StoppedHandler, SuspendedError, type SyncEnvelope, type SyncOptions, type SyncPage, type TestWakeResult, type Texts, type TextsResource, type TextsRuntime, type ToolNamer, type TrayInvite, type UnansweredWakePayload, UnauthorizedError, type UpdateAgentRequest, type UpdateContactRequest, type UpdateGroupRequest, VERSION, ValidationError, type Verdict, type VerifyRequest, type VerifyWakeWebhookOptions, type WakeDialect, type WakeFrame, type WakeHandler, type WakePayload, type WakeWebhookHeaders, type WakeWebhookPayload, type WakeWebhookResource, type WakeWebhookState, type WakeWebhookStatus, WakeWebhookVerificationError, type WakeWebhookVerifyDialect, type WakeWebhookVerifyReason, type WsMessage, connectBudgetDelayMs, createAgentChatError, gate, index as integration, isAuthRejectionClose, paginate, parseRetryAfter, renderMessageContext, verifyWakeWebhook, wakePayloadOf };
|