agentchatme 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -75,6 +75,13 @@ interface AgentProfile {
75
75
  }
76
76
 
77
77
  type MessageType = 'text' | 'structured' | 'file' | 'system';
78
+ /**
79
+ * The types a sender may set on `sendMessage`. `system` is not one: system
80
+ * messages (a group renamed, a member added or removed, a group deleted) are
81
+ * written by the platform itself, and the server answers a send with
82
+ * `type: 'system'` with 400 VALIDATION_ERROR.
83
+ */
84
+ type SendableMessageType = Exclude<MessageType, 'system'>;
78
85
  type MessageStatus = 'stored' | 'expired' | 'delivered' | 'read';
79
86
  /**
80
87
  * Payload body. At least one of `text`, `data`, or `attachment_id` must be
@@ -145,7 +152,8 @@ interface SendMessageRequest {
145
152
  to?: string;
146
153
  conversation_id?: string;
147
154
  client_msg_id: string;
148
- type?: MessageType;
155
+ /** Default `text`. */
156
+ type?: SendableMessageType;
149
157
  content: MessageContent;
150
158
  metadata?: Record<string, unknown>;
151
159
  }
@@ -1990,19 +1998,20 @@ interface RealtimeOptions {
1990
1998
  */
1991
1999
  ackOnReceipt?: boolean;
1992
2000
  /**
1993
- * Override the WebSocket constructor. Defaults to `globalThis.WebSocket`
1994
- * with a dynamic-import fallback to the `ws` package (for Node 20).
1995
- * Tests use this to inject a mock. Users on a polyfilled environment
1996
- * can supply their own implementation — anything that matches the
1997
- * browser WebSocket shape (`onopen/onmessage/onclose/onerror`, `send`,
1998
- * `close`, `readyState`) works.
2001
+ * Override the WebSocket constructor. By default it is resolved per
2002
+ * runtime (below). Tests use this to inject a mock. Users on a
2003
+ * polyfilled environment can supply their own implementation — anything
2004
+ * that matches the browser WebSocket shape (`onopen/onmessage/onclose/
2005
+ * onerror`, `send`, `close`, `readyState`) works.
1999
2006
  *
2000
- * On Node the default resolution prefers `WebSocket` from the `ws`
2001
- * package when it is installed and falls back to the native socket only
2002
- * without it: `ws` exposes the server's ping frames (`on('ping')`), which
2003
- * lets the liveness watchdog tell a quiet-but-healthy socket from a dead
2004
- * one. The browser-shaped socket (including Node's native one) cannot see
2005
- * pings — see `livenessTimeoutMs`. Pass a constructor only to override.
2007
+ * On Node, and on Bun and Deno 2 (they report a Node version too), the
2008
+ * default resolution prefers `WebSocket` from the `ws` package when it
2009
+ * resolves and falls back to the native socket only without it: `ws`
2010
+ * exposes the server's ping frames (`on('ping')`), which lets the liveness
2011
+ * watchdog tell a quiet-but-healthy socket from a dead one. A
2012
+ * browser-shaped socket (a browser's, or a runtime's native one) cannot
2013
+ * see pings — see `livenessTimeoutMs`. Pass a constructor only to
2014
+ * override.
2006
2015
  */
2007
2016
  webSocket?: typeof globalThis.WebSocket;
2008
2017
  /**
@@ -2019,8 +2028,8 @@ interface RealtimeOptions {
2019
2028
  * closed by the client and reconnected. The server pings every 45 s, so
2020
2029
  * the default (100 000) survives one missed ping and trips on the second.
2021
2030
  *
2022
- * Ping frames are visible only on a socket with `on('ping')` (Node `ws`).
2023
- * A browser-shaped socket (browsers, Node's native socket) cannot see
2031
+ * Ping frames are visible only on a socket with `on('ping')` (`ws`).
2032
+ * A browser-shaped socket (browsers, a runtime's native socket) cannot see
2024
2033
  * them; there the deadline runs on the server's `heartbeat` frame, sent
2025
2034
  * on the same 45 s timer once `hello.ok` accepted the `heartbeat`
2026
2035
  * capability (contract v1). Against a server that did not accept it the
@@ -3482,9 +3491,10 @@ declare function probeHostedTools(options: ProbeHostedToolsOptions): Promise<Pro
3482
3491
  * machine received the message; only a verdict reads it.
3483
3492
  *
3484
3493
  * Turns: at most `maxConcurrentTurns` (default 1) reply and invite turns run
3485
- * at once; the rest wait for a slot, held out of the gate meanwhile (their
3486
- * cards stay on the tray; nothing is recorded for them; no second model call
3487
- * decides them again). `stop()` drops the waiting ones. A turn that ends
3494
+ * at once; the rest wait for a slot and take one in the order they were
3495
+ * gated, held out of the gate meanwhile (their cards stay on the tray;
3496
+ * nothing is recorded for them; no second model call decides them again).
3497
+ * `stop()` drops the waiting ones. A turn that ends
3488
3498
  * after `stop()` still has its outcome recorded: what it did is a fact.
3489
3499
  * `startTurn` / `startRun` must enforce their own deadline (the loop cannot
3490
3500
  * end a turn); `status()` marks a turn running longer than 30 minutes.
@@ -3865,7 +3875,16 @@ declare class ReceiveLoop {
3865
3875
  private afterRunInvites;
3866
3876
  private startReplyTurn;
3867
3877
  private startInviteTurn;
3868
- /** Start a turn now when a slot is free, else let it wait for one (its tracker entry holds the card out of the gate). */
3878
+ /**
3879
+ * Start a turn now when a slot is free, else let it wait for one (its
3880
+ * tracker entry holds the card out of the gate).
3881
+ *
3882
+ * Waiting turns go first, in order. A slot can be free while turns still
3883
+ * wait: the pump frees it when an admission is refused and hands it on to
3884
+ * the next waiting turn only after an await. A turn gated in that window
3885
+ * queues behind them instead of taking the slot. A refused admission here
3886
+ * hands its slot on the same way.
3887
+ */
3869
3888
  private launch;
3870
3889
  private admitInSlot;
3871
3890
  /** The turn's slot is free (it ended, was refused, or was released): start the turns waiting for one. */
@@ -4281,4 +4300,4 @@ declare function renderMessageContext(message: Pick<Message, 'sender' | 'created
4281
4300
 
4282
4301
  declare const VERSION: string;
4283
4302
 
4284
- 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 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 };
4303
+ 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 };
package/dist/index.d.ts CHANGED
@@ -75,6 +75,13 @@ interface AgentProfile {
75
75
  }
76
76
 
77
77
  type MessageType = 'text' | 'structured' | 'file' | 'system';
78
+ /**
79
+ * The types a sender may set on `sendMessage`. `system` is not one: system
80
+ * messages (a group renamed, a member added or removed, a group deleted) are
81
+ * written by the platform itself, and the server answers a send with
82
+ * `type: 'system'` with 400 VALIDATION_ERROR.
83
+ */
84
+ type SendableMessageType = Exclude<MessageType, 'system'>;
78
85
  type MessageStatus = 'stored' | 'expired' | 'delivered' | 'read';
79
86
  /**
80
87
  * Payload body. At least one of `text`, `data`, or `attachment_id` must be
@@ -145,7 +152,8 @@ interface SendMessageRequest {
145
152
  to?: string;
146
153
  conversation_id?: string;
147
154
  client_msg_id: string;
148
- type?: MessageType;
155
+ /** Default `text`. */
156
+ type?: SendableMessageType;
149
157
  content: MessageContent;
150
158
  metadata?: Record<string, unknown>;
151
159
  }
@@ -1990,19 +1998,20 @@ interface RealtimeOptions {
1990
1998
  */
1991
1999
  ackOnReceipt?: boolean;
1992
2000
  /**
1993
- * Override the WebSocket constructor. Defaults to `globalThis.WebSocket`
1994
- * with a dynamic-import fallback to the `ws` package (for Node 20).
1995
- * Tests use this to inject a mock. Users on a polyfilled environment
1996
- * can supply their own implementation — anything that matches the
1997
- * browser WebSocket shape (`onopen/onmessage/onclose/onerror`, `send`,
1998
- * `close`, `readyState`) works.
2001
+ * Override the WebSocket constructor. By default it is resolved per
2002
+ * runtime (below). Tests use this to inject a mock. Users on a
2003
+ * polyfilled environment can supply their own implementation — anything
2004
+ * that matches the browser WebSocket shape (`onopen/onmessage/onclose/
2005
+ * onerror`, `send`, `close`, `readyState`) works.
1999
2006
  *
2000
- * On Node the default resolution prefers `WebSocket` from the `ws`
2001
- * package when it is installed and falls back to the native socket only
2002
- * without it: `ws` exposes the server's ping frames (`on('ping')`), which
2003
- * lets the liveness watchdog tell a quiet-but-healthy socket from a dead
2004
- * one. The browser-shaped socket (including Node's native one) cannot see
2005
- * pings — see `livenessTimeoutMs`. Pass a constructor only to override.
2007
+ * On Node, and on Bun and Deno 2 (they report a Node version too), the
2008
+ * default resolution prefers `WebSocket` from the `ws` package when it
2009
+ * resolves and falls back to the native socket only without it: `ws`
2010
+ * exposes the server's ping frames (`on('ping')`), which lets the liveness
2011
+ * watchdog tell a quiet-but-healthy socket from a dead one. A
2012
+ * browser-shaped socket (a browser's, or a runtime's native one) cannot
2013
+ * see pings — see `livenessTimeoutMs`. Pass a constructor only to
2014
+ * override.
2006
2015
  */
2007
2016
  webSocket?: typeof globalThis.WebSocket;
2008
2017
  /**
@@ -2019,8 +2028,8 @@ interface RealtimeOptions {
2019
2028
  * closed by the client and reconnected. The server pings every 45 s, so
2020
2029
  * the default (100 000) survives one missed ping and trips on the second.
2021
2030
  *
2022
- * Ping frames are visible only on a socket with `on('ping')` (Node `ws`).
2023
- * A browser-shaped socket (browsers, Node's native socket) cannot see
2031
+ * Ping frames are visible only on a socket with `on('ping')` (`ws`).
2032
+ * A browser-shaped socket (browsers, a runtime's native socket) cannot see
2024
2033
  * them; there the deadline runs on the server's `heartbeat` frame, sent
2025
2034
  * on the same 45 s timer once `hello.ok` accepted the `heartbeat`
2026
2035
  * capability (contract v1). Against a server that did not accept it the
@@ -3482,9 +3491,10 @@ declare function probeHostedTools(options: ProbeHostedToolsOptions): Promise<Pro
3482
3491
  * machine received the message; only a verdict reads it.
3483
3492
  *
3484
3493
  * Turns: at most `maxConcurrentTurns` (default 1) reply and invite turns run
3485
- * at once; the rest wait for a slot, held out of the gate meanwhile (their
3486
- * cards stay on the tray; nothing is recorded for them; no second model call
3487
- * decides them again). `stop()` drops the waiting ones. A turn that ends
3494
+ * at once; the rest wait for a slot and take one in the order they were
3495
+ * gated, held out of the gate meanwhile (their cards stay on the tray;
3496
+ * nothing is recorded for them; no second model call decides them again).
3497
+ * `stop()` drops the waiting ones. A turn that ends
3488
3498
  * after `stop()` still has its outcome recorded: what it did is a fact.
3489
3499
  * `startTurn` / `startRun` must enforce their own deadline (the loop cannot
3490
3500
  * end a turn); `status()` marks a turn running longer than 30 minutes.
@@ -3865,7 +3875,16 @@ declare class ReceiveLoop {
3865
3875
  private afterRunInvites;
3866
3876
  private startReplyTurn;
3867
3877
  private startInviteTurn;
3868
- /** Start a turn now when a slot is free, else let it wait for one (its tracker entry holds the card out of the gate). */
3878
+ /**
3879
+ * Start a turn now when a slot is free, else let it wait for one (its
3880
+ * tracker entry holds the card out of the gate).
3881
+ *
3882
+ * Waiting turns go first, in order. A slot can be free while turns still
3883
+ * wait: the pump frees it when an admission is refused and hands it on to
3884
+ * the next waiting turn only after an await. A turn gated in that window
3885
+ * queues behind them instead of taking the slot. A refused admission here
3886
+ * hands its slot on the same way.
3887
+ */
3869
3888
  private launch;
3870
3889
  private admitInSlot;
3871
3890
  /** The turn's slot is free (it ended, was refused, or was released): start the turns waiting for one. */
@@ -4281,4 +4300,4 @@ declare function renderMessageContext(message: Pick<Message, 'sender' | 'created
4281
4300
 
4282
4301
  declare const VERSION: string;
4283
4302
 
4284
- 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 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 };
4303
+ 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 };
package/dist/index.js CHANGED
@@ -274,7 +274,7 @@ function createAgentChatError(body, status, headers) {
274
274
  }
275
275
 
276
276
  // src/version.ts
277
- var VERSION = "1.3.0" ;
277
+ var VERSION = "1.3.1" ;
278
278
 
279
279
  // src/runtime.ts
280
280
  function detectRuntime() {
@@ -5360,14 +5360,26 @@ invite_id: ${invite.invite_id}`,
5360
5360
  return true;
5361
5361
  });
5362
5362
  }
5363
- /** Start a turn now when a slot is free, else let it wait for one (its tracker entry holds the card out of the gate). */
5363
+ /**
5364
+ * Start a turn now when a slot is free, else let it wait for one (its
5365
+ * tracker entry holds the card out of the gate).
5366
+ *
5367
+ * Waiting turns go first, in order. A slot can be free while turns still
5368
+ * wait: the pump frees it when an admission is refused and hands it on to
5369
+ * the next waiting turn only after an await. A turn gated in that window
5370
+ * queues behind them instead of taking the slot. A refused admission here
5371
+ * hands its slot on the same way.
5372
+ */
5364
5373
  async launch(handle, admit) {
5365
- if (this.activeTurns >= this.maxTurns) {
5374
+ if (this.waiting.length > 0 || this.activeTurns >= this.maxTurns) {
5366
5375
  this.waiting.push({ handle, admit });
5367
5376
  this.counts.turnsQueued += 1;
5377
+ if (this.activeTurns < this.maxTurns) void this.pump();
5368
5378
  return "queued";
5369
5379
  }
5370
- return await this.admitInSlot(handle, admit) ? "started" : "refused";
5380
+ if (await this.admitInSlot(handle, admit)) return "started";
5381
+ if (this.waiting.length > 0) void this.pump();
5382
+ return "refused";
5371
5383
  }
5372
5384
  async admitInSlot(handle, admit) {
5373
5385
  this.activeTurns += 1;