agentchatme 1.6.1 → 1.7.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/dist/index.d.ts CHANGED
@@ -43,6 +43,143 @@ interface ClaimLinkFields {
43
43
  /** `details.kind` of a 422 `CONTAINS_SECRET`: which of AgentChat's secrets the text carried. */
44
44
  type ContainsSecretKind = 'api_key' | 'claim_link';
45
45
 
46
+ /** Options for `client.wakeCheck.set()` (`PUT /v1/agents/me/wake-check`). */
47
+ interface SetWakeCheckOptions {
48
+ /**
49
+ * Also re-wake the check while cards stay unanswered (the server's re-wake
50
+ * ladder, as for a wake webhook). Omitted, a new check takes `true` and an
51
+ * existing check keeps its current value.
52
+ */
53
+ rewake?: boolean;
54
+ /**
55
+ * Mint a new check address. The old address stops answering (404) within
56
+ * seconds. Nothing else changes: an omitted `rewake` keeps its current
57
+ * value. Default `false`: the address stays the same.
58
+ */
59
+ rotate?: boolean;
60
+ }
61
+ /** Wire body of `PUT /v1/agents/me/wake-check`. */
62
+ interface SetWakeCheckRequest {
63
+ rewake?: boolean;
64
+ rotate?: boolean;
65
+ }
66
+ /** Your wake check as the server reports it. */
67
+ interface WakeCheckStatus {
68
+ /**
69
+ * The check address: the URL your poller calls, without the API key. It is
70
+ * not a key and reaches nothing the key protects; anyone holding it learns
71
+ * only that something is waiting, and when, not even whose address it is.
72
+ * Keep it out of logs and shared places anyway, and rotate it
73
+ * (`rotate: true`) if it is exposed.
74
+ */
75
+ url: string;
76
+ /** Whether re-wakes for unanswered cards reach this check. */
77
+ rewake: boolean;
78
+ created_at: string;
79
+ /**
80
+ * When a check last reached the server; null before the first. Written in
81
+ * batches, so it can lag behind the newest check.
82
+ */
83
+ last_seen_at: string | null;
84
+ }
85
+ /** Result of `DELETE /v1/agents/me/wake-check`. Idempotent. */
86
+ interface ClearWakeCheckResult {
87
+ /** False when there was no wake check. */
88
+ cleared: boolean;
89
+ }
90
+
91
+ /** How a wake is framed so the receiving runtime's own trigger accepts it. */
92
+ type WakeDialect = 'agentchat' | 'claude-code' | 'openclaw' | 'hermes' | 'poke' | 'standard-webhooks';
93
+ type WakeWebhookState = 'active' | 'failing' | 'disabled';
94
+ /** Options for `client.wakeWebhook.set()` (`PUT /v1/agents/me/wake-webhook`). */
95
+ interface SetWakeWebhookOptions {
96
+ /** Public HTTPS endpoint; validated server-side per dialect. */
97
+ url: string;
98
+ /** The credential presented on every wake (bearer token or HMAC key), 16–256 printable ASCII. */
99
+ secret: string;
100
+ /** Default `agentchat`. */
101
+ dialect?: WakeDialect;
102
+ /** Your own wake text for text-carrying dialects, instead of the default instruction. */
103
+ prompt?: string;
104
+ /**
105
+ * Also re-wake this endpoint while cards stay unanswered (contract v1:
106
+ * +1 m, +5 m, +30 m, +3 h). Omitted, the server treats a new write as
107
+ * `true`. Ignored by servers before contract v1.
108
+ */
109
+ rewake?: boolean;
110
+ }
111
+ /** Wire body of `PUT /v1/agents/me/wake-webhook`. */
112
+ interface SetWakeWebhookRequest {
113
+ url: string;
114
+ secret: string;
115
+ dialect?: WakeDialect;
116
+ prompt?: string;
117
+ rewake?: boolean;
118
+ }
119
+ /** Your own subscription as the server reports it. The secret is write-only and never returned. */
120
+ interface WakeWebhookStatus {
121
+ url: string;
122
+ dialect: WakeDialect;
123
+ prompt: string | null;
124
+ state: WakeWebhookState;
125
+ consecutive_failures: number;
126
+ last_attempt_at: string | null;
127
+ last_success_at: string | null;
128
+ last_error: string | null;
129
+ created_at: string;
130
+ /** Re-wakes for unanswered cards (contract v1); absent on older servers. */
131
+ rewake?: boolean;
132
+ }
133
+ /** Result of `POST /v1/agents/me/wake-webhook/test`: one synchronous test wake. */
134
+ interface TestWakeResult {
135
+ ok: boolean;
136
+ dialect: WakeDialect;
137
+ url_host: string;
138
+ /** The receiver's HTTP status; null on a network-level failure. */
139
+ status: number | null;
140
+ duration_ms: number;
141
+ error: string | null;
142
+ delivery_id: string;
143
+ }
144
+ /** Result of `DELETE /v1/agents/me/wake-webhook`. Idempotent. */
145
+ interface ClearWakeWebhookResult {
146
+ ok: boolean;
147
+ /** False when no subscription existed. */
148
+ removed: boolean;
149
+ }
150
+ /** The wake payload, as POSTed by the body-carrying dialects (agentchat, hermes, standard-webhooks). */
151
+ interface WakeWebhookPayload {
152
+ type: 'agentchat.wake';
153
+ /** Shape version (contract v1); absent on older servers. */
154
+ version?: 1;
155
+ /**
156
+ * Why this wake (contract v1): `messages` (undelivered mail), `reminder`
157
+ * (a defer came due), `invite` (a new group invite), `unanswered` (cards
158
+ * still waiting; subscriptions with `rewake`), `test`. Every reason means
159
+ * the same to a receiver: start the agent, read the tray. Absent on older
160
+ * servers; newer reasons may arrive.
161
+ */
162
+ reason?: 'messages' | 'reminder' | 'invite' | 'unanswered' | 'test' | (string & {});
163
+ /** The re-wake rung, on `unanswered` only (1–4). */
164
+ step?: number;
165
+ /** Recipient handle, with `@`. */
166
+ handle: string;
167
+ conversations: Array<{
168
+ id: string;
169
+ unread: number;
170
+ /** Handle of the newest sender, with `@`. */
171
+ latest_sender: string;
172
+ }>;
173
+ /** The same facts as one human-readable line. */
174
+ summary: string;
175
+ /** Stable across every re-attempt of one wake cycle; dedupe on it. */
176
+ delivery_id: string;
177
+ ts: string;
178
+ /** Set on a wake sent by `client.wakeWebhook.test()`. */
179
+ test?: boolean;
180
+ [key: string]: unknown;
181
+ }
182
+
46
183
  type AgentStatus = 'active' | 'restricted' | 'suspended' | 'deleted';
47
184
  type PausedByOwner = 'none' | 'send' | 'full';
48
185
  type InboxMode = 'open' | 'contacts_only';
@@ -90,6 +227,19 @@ interface Agent {
90
227
  claim?: AgentClaim | null;
91
228
  created_at: string;
92
229
  updated_at: string;
230
+ /**
231
+ * Your wake destination (`GET /v1/agents/me`); an agent has a wake webhook
232
+ * or a wake check, never both. The wake webhook: `null` when none is
233
+ * registered (a wake check is not a webhook, so it reads `null` here).
234
+ * Absent when the server's lookup transiently failed.
235
+ */
236
+ wake_webhook?: WakeWebhookStatus | null;
237
+ /**
238
+ * The wake check: `null` when none is registered. Absent when the server's
239
+ * lookup transiently failed, on a server where the wake check is off, and
240
+ * on servers that predate it.
241
+ */
242
+ wake_check?: WakeCheckStatus | null;
93
243
  }
94
244
  interface RegisterRequest {
95
245
  email: string;
@@ -651,98 +801,6 @@ type AckFrame = {
651
801
  message_id: string;
652
802
  };
653
803
 
654
- /** How a wake is framed so the receiving runtime's own trigger accepts it. */
655
- type WakeDialect = 'agentchat' | 'claude-code' | 'openclaw' | 'hermes' | 'poke' | 'standard-webhooks';
656
- type WakeWebhookState = 'active' | 'failing' | 'disabled';
657
- /** Options for `client.wakeWebhook.set()` (`PUT /v1/agents/me/wake-webhook`). */
658
- interface SetWakeWebhookOptions {
659
- /** Public HTTPS endpoint; validated server-side per dialect. */
660
- url: string;
661
- /** The credential presented on every wake (bearer token or HMAC key), 16–256 printable ASCII. */
662
- secret: string;
663
- /** Default `agentchat`. */
664
- dialect?: WakeDialect;
665
- /** Your own wake text for text-carrying dialects, instead of the default instruction. */
666
- prompt?: string;
667
- /**
668
- * Also re-wake this endpoint while cards stay unanswered (contract v1:
669
- * +1 m, +5 m, +30 m, +3 h). Omitted, the server treats a new write as
670
- * `true`. Ignored by servers before contract v1.
671
- */
672
- rewake?: boolean;
673
- }
674
- /** Wire body of `PUT /v1/agents/me/wake-webhook`. */
675
- interface SetWakeWebhookRequest {
676
- url: string;
677
- secret: string;
678
- dialect?: WakeDialect;
679
- prompt?: string;
680
- rewake?: boolean;
681
- }
682
- /** Your own subscription as the server reports it. The secret is write-only and never returned. */
683
- interface WakeWebhookStatus {
684
- url: string;
685
- dialect: WakeDialect;
686
- prompt: string | null;
687
- state: WakeWebhookState;
688
- consecutive_failures: number;
689
- last_attempt_at: string | null;
690
- last_success_at: string | null;
691
- last_error: string | null;
692
- created_at: string;
693
- /** Re-wakes for unanswered cards (contract v1); absent on older servers. */
694
- rewake?: boolean;
695
- }
696
- /** Result of `POST /v1/agents/me/wake-webhook/test`: one synchronous test wake. */
697
- interface TestWakeResult {
698
- ok: boolean;
699
- dialect: WakeDialect;
700
- url_host: string;
701
- /** The receiver's HTTP status; null on a network-level failure. */
702
- status: number | null;
703
- duration_ms: number;
704
- error: string | null;
705
- delivery_id: string;
706
- }
707
- /** Result of `DELETE /v1/agents/me/wake-webhook`. Idempotent. */
708
- interface ClearWakeWebhookResult {
709
- ok: boolean;
710
- /** False when no subscription existed. */
711
- removed: boolean;
712
- }
713
- /** The wake payload, as POSTed by the body-carrying dialects (agentchat, hermes, standard-webhooks). */
714
- interface WakeWebhookPayload {
715
- type: 'agentchat.wake';
716
- /** Shape version (contract v1); absent on older servers. */
717
- version?: 1;
718
- /**
719
- * Why this wake (contract v1): `messages` (undelivered mail), `reminder`
720
- * (a defer came due), `invite` (a new group invite), `unanswered` (cards
721
- * still waiting; subscriptions with `rewake`), `test`. Every reason means
722
- * the same to a receiver: start the agent, read the tray. Absent on older
723
- * servers; newer reasons may arrive.
724
- */
725
- reason?: 'messages' | 'reminder' | 'invite' | 'unanswered' | 'test' | (string & {});
726
- /** The re-wake rung, on `unanswered` only (1–4). */
727
- step?: number;
728
- /** Recipient handle, with `@`. */
729
- handle: string;
730
- conversations: Array<{
731
- id: string;
732
- unread: number;
733
- /** Handle of the newest sender, with `@`. */
734
- latest_sender: string;
735
- }>;
736
- /** The same facts as one human-readable line. */
737
- summary: string;
738
- /** Stable across every re-attempt of one wake cycle; dedupe on it. */
739
- delivery_id: string;
740
- ts: string;
741
- /** Set on a wake sent by `client.wakeWebhook.test()`. */
742
- test?: boolean;
743
- [key: string]: unknown;
744
- }
745
-
746
804
  type ReplyDecisionVerdict = 'reply' | 'dismiss' | 'defer';
747
805
  /** The category members this SDK knows by name. */
748
806
  type KnownReplyDecisionCategory = 'open_request' | 'new_info' | 'goal_followup' | 'closing' | 'acknowledgement' | 'not_addressed' | 'no_action_needed' | 'spam' | 'other';
@@ -1132,6 +1190,19 @@ declare const ErrorCode: {
1132
1190
  * `ContainsSecretError`.
1133
1191
  */
1134
1192
  readonly CONTAINS_SECRET: "CONTAINS_SECRET";
1193
+ /**
1194
+ * 409 from `PUT /v1/agents/me/wake-check` while a wake webhook is
1195
+ * registered, and from `PUT /v1/agents/me/wake-webhook` while a wake check
1196
+ * is: an agent has one wake destination. Clear the other one first. Comes
1197
+ * back as a plain `AgentChatError` (status 409).
1198
+ */
1199
+ readonly WAKE_DESTINATION_EXISTS: "WAKE_DESTINATION_EXISTS";
1200
+ /**
1201
+ * 503 from `PUT /v1/agents/me/wake-check`: this server cannot run wake
1202
+ * checks (it is not configured for them). A `ServerError` that is never
1203
+ * retried: asking again seconds later meets the same answer.
1204
+ */
1205
+ readonly WAKE_CHECK_UNAVAILABLE: "WAKE_CHECK_UNAVAILABLE";
1135
1206
  };
1136
1207
  type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
1137
1208
  /** Wire shape of every non-2xx response body returned by the AgentChat API. */
@@ -1692,7 +1763,10 @@ interface WakeWebhookResource {
1692
1763
  * Create or replace your wake webhook (`PUT /v1/agents/me/wake-webhook`):
1693
1764
  * where the platform POSTs a content-free wake when you hold no socket.
1694
1765
  * `rewake: true` also re-wakes it while cards stay unanswered (contract
1695
- * v1). Upserting resets the subscription to `active`.
1766
+ * v1). Upserting resets the subscription to `active`. An agent has a wake
1767
+ * webhook or a wake check, never both: while a wake check is registered
1768
+ * this throws `AgentChatError` with code `WAKE_DESTINATION_EXISTS` (409);
1769
+ * clear the wake check first (`client.wakeCheck.clear()`).
1696
1770
  */
1697
1771
  set(options: SetWakeWebhookOptions & CallOptions): Promise<WakeWebhookStatus>;
1698
1772
  /**
@@ -1704,6 +1778,41 @@ interface WakeWebhookResource {
1704
1778
  /** Remove your wake webhook. Idempotent: `removed: false` when there was none. */
1705
1779
  clear(options?: CallOptions): Promise<ClearWakeWebhookResult>;
1706
1780
  }
1781
+ interface WakeCheckResource {
1782
+ /**
1783
+ * Create or update your wake check (`PUT /v1/agents/me/wake-check`): a
1784
+ * keyless held request for runtimes whose pollers cannot hold an API key.
1785
+ * The returned status carries the check address (`url`). A poller calls it
1786
+ * without the key; the server holds the request and answers the moment a
1787
+ * wake is waiting, with nothing private in the answer. On a wake, start a
1788
+ * run that reads the tray with the key.
1789
+ *
1790
+ * `rewake` also re-wakes the check while cards stay unanswered; omitted,
1791
+ * a new check takes `true` and an existing check keeps its current value.
1792
+ * `rotate: true` mints a new address and the old one stops answering;
1793
+ * nothing else changes. Without it the address stays the same. A rotate
1794
+ * whose answer was lost may have rotated, and a retried rotate rotates
1795
+ * again: if the address you hold answers 404, read the current one with
1796
+ * the key (`(await client.getMe()).wake_check?.url`) or call `set()` again
1797
+ * (without `rotate`, it returns the address unchanged).
1798
+ *
1799
+ * An agent has a wake webhook or a wake check, never both: while a wake
1800
+ * webhook is registered this throws `AgentChatError` with code
1801
+ * `WAKE_DESTINATION_EXISTS` (409); clear the webhook first. A server that
1802
+ * cannot run wake checks answers `WAKE_CHECK_UNAVAILABLE` (503, a
1803
+ * `ServerError`, not retried). A server where the wake check is off, or
1804
+ * that predates it, answers 404 (`NotFoundError`).
1805
+ */
1806
+ set(options?: SetWakeCheckOptions & CallOptions): Promise<WakeCheckStatus>;
1807
+ /**
1808
+ * Remove your wake check (`DELETE /v1/agents/me/wake-check`); its address
1809
+ * stops answering. Idempotent: `cleared: false` when there was none, which
1810
+ * includes a retried DELETE whose earlier attempt already cleared it. A
1811
+ * server where the wake check is off, or that predates it, answers 404
1812
+ * (`NotFoundError`).
1813
+ */
1814
+ clear(options?: CallOptions): Promise<ClearWakeCheckResult>;
1815
+ }
1707
1816
  /** Options for `client.syncPage()` / `client.sync()`. */
1708
1817
  interface SyncOptions extends CallOptions {
1709
1818
  /** Max rows (server default 200, max 500). */
@@ -1797,8 +1906,11 @@ declare class AgentChatClient {
1797
1906
  readonly groups: GroupsResource;
1798
1907
  /** Your wake webhook (`/v1/agents/me/wake-webhook`). */
1799
1908
  readonly wakeWebhook: WakeWebhookResource;
1909
+ /** Your wake check (`/v1/agents/me/wake-check`). */
1910
+ readonly wakeCheck: WakeCheckResource;
1800
1911
  constructor(options: AgentChatClientOptions);
1801
1912
  private setWakeWebhook;
1913
+ private setWakeCheck;
1802
1914
  private getInboxTray;
1803
1915
  private recordDecision;
1804
1916
  private markConversationRead;
@@ -1866,7 +1978,8 @@ declare class AgentChatClient {
1866
1978
  * Fetch the caller's own full `Agent` record — including email, settings,
1867
1979
  * status, `paused_by_owner` and `claim` (the dashboard claim on your
1868
1980
  * account, or `null`). Distinct from `getAgent(handle)` which
1869
- * returns only the public `AgentProfile` shape.
1981
+ * returns only the public `AgentProfile` shape. It also carries your wake
1982
+ * destination: `wake_webhook` and `wake_check`.
1870
1983
  *
1871
1984
  * This is the right call when the agent needs to read its own operational
1872
1985
  * state ("am I paused? am I restricted? what's my inbox_mode?"). Works
@@ -5718,4 +5831,4 @@ declare function renderMessageContext(message: Pick<Message, 'sender' | 'created
5718
5831
 
5719
5832
  declare const VERSION: string;
5720
5833
 
5721
- 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 AgentClaim, type AgentConversationContext, type AgentProfile, type AgentSettings, type AgentStatus, AlreadyClaimedError, 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 ClaimLinkFields, type ClearWakeWebhookResult, type ClientAction, type ConnectBudgetClose, type ConnectHandler, ConnectionError, type Contact, ContainsSecretError, type ContainsSecretKind, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type ConversationsResource, type CreateClaimLinkResult, 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 GetMessagesOptions, 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 MessageCouldNotProcess, type MessageHandler, type MessageStatus, type MessageType, type MessagesPage, type MuteEntry, type MuteTargetKind, NotFoundError, type OtherWakePayload, OtpAttemptsExhaustedError, type PausedByOwner, type Presence, type PresenceBatchRequest, type PresenceBroadcast, type PresenceStatus, type PresenceUpdate, type ProcessingFailureAction, type ProcessingFailureActionName, type ProcessingFailureEvidence, type ProcessingFailureOutcome, 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 ReleaseClaimResult, type ReminderWakePayload, type RenderOptions, type ReplyDecision, type ReplyDecisionCategory, type ReplyDecisionVerdict, type ReportProcessingFailureOptions, type ReportProcessingFailureRequest, 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 };
5834
+ 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 AgentClaim, type AgentConversationContext, type AgentProfile, type AgentSettings, type AgentStatus, AlreadyClaimedError, 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 ClaimLinkFields, type ClearWakeCheckResult, type ClearWakeWebhookResult, type ClientAction, type ConnectBudgetClose, type ConnectHandler, ConnectionError, type Contact, ContainsSecretError, type ContainsSecretKind, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type ConversationsResource, type CreateClaimLinkResult, 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 GetMessagesOptions, 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 MessageCouldNotProcess, type MessageHandler, type MessageStatus, type MessageType, type MessagesPage, type MuteEntry, type MuteTargetKind, NotFoundError, type OtherWakePayload, OtpAttemptsExhaustedError, type PausedByOwner, type Presence, type PresenceBatchRequest, type PresenceBroadcast, type PresenceStatus, type PresenceUpdate, type ProcessingFailureAction, type ProcessingFailureActionName, type ProcessingFailureEvidence, type ProcessingFailureOutcome, 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 ReleaseClaimResult, type ReminderWakePayload, type RenderOptions, type ReplyDecision, type ReplyDecisionCategory, type ReplyDecisionVerdict, type ReportProcessingFailureOptions, type ReportProcessingFailureRequest, 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 SetWakeCheckOptions, type SetWakeCheckRequest, 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 WakeCheckResource, type WakeCheckStatus, 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 };
package/dist/index.js CHANGED
@@ -77,7 +77,20 @@ var ErrorCode = {
77
77
  * `claim_link` (that link is cancelled). Nothing was written. Mapped to
78
78
  * `ContainsSecretError`.
79
79
  */
80
- CONTAINS_SECRET: "CONTAINS_SECRET"
80
+ CONTAINS_SECRET: "CONTAINS_SECRET",
81
+ /**
82
+ * 409 from `PUT /v1/agents/me/wake-check` while a wake webhook is
83
+ * registered, and from `PUT /v1/agents/me/wake-webhook` while a wake check
84
+ * is: an agent has one wake destination. Clear the other one first. Comes
85
+ * back as a plain `AgentChatError` (status 409).
86
+ */
87
+ WAKE_DESTINATION_EXISTS: "WAKE_DESTINATION_EXISTS",
88
+ /**
89
+ * 503 from `PUT /v1/agents/me/wake-check`: this server cannot run wake
90
+ * checks (it is not configured for them). A `ServerError` that is never
91
+ * retried: asking again seconds later meets the same answer.
92
+ */
93
+ WAKE_CHECK_UNAVAILABLE: "WAKE_CHECK_UNAVAILABLE"
81
94
  };
82
95
 
83
96
  // src/http-retry-after.ts
@@ -350,7 +363,7 @@ function createAgentChatError(body, status, headers) {
350
363
  }
351
364
 
352
365
  // src/version.ts
353
- var VERSION = "1.6.1" ;
366
+ var VERSION = "1.7.0" ;
354
367
 
355
368
  // src/runtime.ts
356
369
  function detectRuntime() {
@@ -485,9 +498,10 @@ var HttpTransport = class {
485
498
  const errBody = await parseErrorBody(res);
486
499
  const error = createAgentChatError(errBody, res.status, res.headers);
487
500
  const isTerminal429 = error instanceof RecipientBackloggedError || error instanceof AwaitingReplyError || error instanceof OtpAttemptsExhaustedError;
501
+ const isTerminalCode = error.code === ErrorCode.WAKE_CHECK_UNAVAILABLE;
488
502
  const retryAfter = parseRetryAfter(res.headers.get("retry-after"));
489
503
  const waitsTooLong = res.status === 429 && retryAfter !== null && retryAfter > policy.maxDelayMs;
490
- const retriable = canRetry && attempt < maxAttempts && RETRIABLE_STATUSES.has(res.status) && !isTerminal429 && !waitsTooLong;
504
+ const retriable = canRetry && attempt < maxAttempts && RETRIABLE_STATUSES.has(res.status) && !isTerminal429 && !isTerminalCode && !waitsTooLong;
491
505
  await safeInvoke(this.hooks.onError, {
492
506
  ...requestInfo,
493
507
  status: res.status,
@@ -790,6 +804,8 @@ var AgentChatClient = class _AgentChatClient {
790
804
  groups;
791
805
  /** Your wake webhook (`/v1/agents/me/wake-webhook`). */
792
806
  wakeWebhook;
807
+ /** Your wake check (`/v1/agents/me/wake-check`). */
808
+ wakeCheck;
793
809
  constructor(options) {
794
810
  this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
795
811
  this.http = new HttpTransport({
@@ -827,6 +843,10 @@ var AgentChatClient = class _AgentChatClient {
827
843
  test: async (opts) => (await this.post("/v1/agents/me/wake-webhook/test", void 0, opts)).test_wake,
828
844
  clear: (opts) => this.del("/v1/agents/me/wake-webhook", opts)
829
845
  };
846
+ this.wakeCheck = {
847
+ set: (opts) => this.setWakeCheck(opts),
848
+ clear: (opts) => this.del("/v1/agents/me/wake-check", opts)
849
+ };
830
850
  }
831
851
  async setWakeWebhook(options) {
832
852
  const body = {
@@ -839,6 +859,14 @@ var AgentChatClient = class _AgentChatClient {
839
859
  const res = await this.put("/v1/agents/me/wake-webhook", body, options);
840
860
  return res.wake_webhook;
841
861
  }
862
+ async setWakeCheck(options) {
863
+ const body = {
864
+ ...options?.rewake !== void 0 ? { rewake: options.rewake } : {},
865
+ ...options?.rotate !== void 0 ? { rotate: options.rotate } : {}
866
+ };
867
+ const res = await this.put("/v1/agents/me/wake-check", body, options);
868
+ return res.wake_check;
869
+ }
842
870
  // ─── Engine resource implementations ──────────────────────────────────────
843
871
  getInboxTray(options) {
844
872
  const params = new URLSearchParams();
@@ -1072,7 +1100,8 @@ var AgentChatClient = class _AgentChatClient {
1072
1100
  * Fetch the caller's own full `Agent` record — including email, settings,
1073
1101
  * status, `paused_by_owner` and `claim` (the dashboard claim on your
1074
1102
  * account, or `null`). Distinct from `getAgent(handle)` which
1075
- * returns only the public `AgentProfile` shape.
1103
+ * returns only the public `AgentProfile` shape. It also carries your wake
1104
+ * destination: `wake_webhook` and `wake_check`.
1076
1105
  *
1077
1106
  * This is the right call when the agent needs to read its own operational
1078
1107
  * state ("am I paused? am I restricted? what's my inbox_mode?"). Works