import type { MessageListQuery, MessageWithMeta, SearchMessageResult, MessageBlock, SendDmResponse, DmMessage, CreateGroupDmRequest, CreateGroupDmResponse, GroupDmMessageResponse, GroupDmParticipantResponse, DmConversationSummary, CreateChannelRequest, UpdateChannelRequest, Channel, ChannelMemberInfo, JoinChannelResponse, InviteChannelResponse, AddedReaction, ReadReceipt, ReactionGroup, InboxResponse, ReaderInfo, ChannelReadStatus, UploadRequest, UploadResponse, CompleteUploadResponse, FileInfo, Agent, TokenRotateResponse, InvokeActionResult, CompleteInvocationRequest, ActionInvocation, WsClientEvent, MessageCreatedEvent, MessageUpdatedEvent, ThreadReplyEvent, MessageReadEvent, MessageReactedEvent, DmReceivedEvent, GroupDmReceivedEvent, RelaycastMessageEvent, AgentStatusActiveEvent, AgentStatusChangedEvent, AgentStatusOfflineEvent, ChannelCreatedEvent, ChannelUpdatedEvent, ChannelArchivedEvent, MemberJoinedEvent, MemberLeftEvent, ChannelMutedEvent, ChannelUnmutedEvent, FileUploadedEvent, WebhookReceivedEvent, ActionInvokedEvent, ActionCompletedEvent, ActionDeniedEvent, ActionFailedEvent, Delivery, DeliveryItem, DeliveryStatus, FailDeliveryRequest, DeferDeliveryRequest, DeliveryAcceptedEvent, DeliveryDeliveredEvent, DeliveryDeferredEvent, DeliveryFailedEvent } from './types.js'; import { HttpClient } from './client.js'; import { type WsClientOptions } from './ws.js'; import type { Subscription } from './subscription.js'; import type { EnrollRecoveryCredentialInput } from './identity.js'; interface IdempotencyOption { idempotencyKey?: string; } interface ChannelListOptions { includeArchived?: boolean; } interface FileListOptions { uploadedBy?: string; limit?: number; } export interface AgentClientOptions { autoHeartbeatMs?: number | false; ws?: Omit; } type RelaycastMessageHandler = (event: RelaycastMessageEvent) => void | Promise; export declare class AgentClient { readonly client: HttpClient; private ws; private autoHeartbeatMs; private autoHeartbeatTimer; private pendingHeartbeat; private wsOptions; private directNodeToken; private manualSubscriptions; private managedSubscriptions; private activeWsChannels; constructor(client: HttpClient, options?: AgentClientOptions); /** * Presence lifecycle ownership: * - worker identities should call `markOnline`/`heartbeat`/`markOffline`. * - broker identities should signal presence only when they directly own worker lifecycle. * - reader identities should not publish presence. */ presence: { markOnline: () => Promise; heartbeat: () => Promise; /** * Mark this agent offline. * * By default this is a presence-only signal: a node-hosted (broker) agent * keeps its node binding, so a session still running on its node keeps * receiving deliveries through that node and the binding stays usable for * later reconnection. Pass `{ deregister: true }` to also tear down the * node binding and re-home the agent to its implicit direct node. */ markOffline: (options?: { deregister?: boolean; }) => Promise; }; private startAutoHeartbeat; private stopAutoHeartbeat; private fetchDirectNodeToken; private directNodeRegistration; connect(): void; /** Send a REST heartbeat to keep this agent online in PresenceDO without a WebSocket. */ heartbeat(): Promise; /** Authenticated self-rollover for this agent identity. */ rotateToken(name: string): Promise; /** Enroll or rotate this agent's server-owned recovery verifier. */ enrollRecoveryCredential(data: EnrollRecoveryCredentialInput): Promise<{ agentId: string; enrolled: boolean; }>; /** * Tear down this client's WebSocket and mark the agent offline. * * By default the HTTP disconnect is presence-only for node-hosted (broker) * agents: the node binding is preserved, so an agent process still running * on its node keeps receiving deliveries through that node, and the binding * remains usable for later reconnection. Pass `{ deregister: true }` to also * deregister the node binding and re-home the agent to its implicit direct * node. */ disconnect(options?: { deregister?: boolean; }): Promise; subscribe(channels: string[]): void; subscribe(channels: string[], onMessage: RelaycastMessageHandler): Subscription; unsubscribe(channels: string[]): void; private onEvent; on: { messageCreated: (handler: (e: MessageCreatedEvent) => void) => (() => void); messageUpdated: (handler: (e: MessageUpdatedEvent) => void) => (() => void); threadReply: (handler: (e: ThreadReplyEvent) => void) => (() => void); messageRead: (handler: (e: MessageReadEvent) => void) => (() => void); messageReacted: (handler: (e: MessageReactedEvent) => void) => (() => void); dmReceived: (handler: (e: DmReceivedEvent) => void) => (() => void); groupDmReceived: (handler: (e: GroupDmReceivedEvent) => void) => (() => void); agentStatusChanged: (handler: (e: AgentStatusChangedEvent) => void) => (() => void); agentActive: (handler: (e: AgentStatusActiveEvent) => void) => (() => void); agentOffline: (handler: (e: AgentStatusOfflineEvent) => void) => (() => void); channelCreated: (handler: (e: ChannelCreatedEvent) => void) => (() => void); channelUpdated: (handler: (e: ChannelUpdatedEvent) => void) => (() => void); channelArchived: (handler: (e: ChannelArchivedEvent) => void) => (() => void); memberJoined: (handler: (e: MemberJoinedEvent) => void) => (() => void); memberLeft: (handler: (e: MemberLeftEvent) => void) => (() => void); channelMuted: (handler: (e: ChannelMutedEvent) => void) => (() => void); channelUnmuted: (handler: (e: ChannelUnmutedEvent) => void) => (() => void); fileUploaded: (handler: (e: FileUploadedEvent) => void) => (() => void); webhookReceived: (handler: (e: WebhookReceivedEvent) => void) => (() => void); actionInvoked: (handler: (e: ActionInvokedEvent) => void) => (() => void); actionCompleted: (handler: (e: ActionCompletedEvent) => void) => (() => void); actionFailed: (handler: (e: ActionFailedEvent) => void) => (() => void); actionDenied: (handler: (e: ActionDeniedEvent) => void) => (() => void); deliveryAccepted: (handler: (e: DeliveryAcceptedEvent) => void) => (() => void); deliveryDelivered: (handler: (e: DeliveryDeliveredEvent) => void) => (() => void); deliveryDeferred: (handler: (e: DeliveryDeferredEvent) => void) => (() => void); deliveryFailed: (handler: (e: DeliveryFailedEvent) => void) => (() => void); connected: (handler: () => void) => (() => void); disconnected: (handler: () => void) => (() => void); error: (handler: () => void) => (() => void); reconnecting: (handler: (attempt: number) => void) => (() => void); permanentlyDisconnected: (handler: (attempt: number) => void) => (() => void); resynced: (handler: (info: { replayed: number; gapDetected: boolean; }) => void) => (() => void); any: (handler: (e: WsClientEvent) => void) => (() => void); }; me(): Promise; send(channel: string, text: string, opts?: { attachments?: string[]; blocks?: MessageBlock[]; data?: Record | null; mode?: 'wait' | 'steer'; idempotencyKey?: string; }): Promise; post(channel: string, text: string, opts?: { attachments?: string[]; blocks?: MessageBlock[]; data?: Record | null; mode?: 'wait' | 'steer'; idempotencyKey?: string; }): Promise; messages(channel: string, opts?: MessageListQuery): Promise; message(id: string): Promise; reply(id: string, text: string, opts?: { blocks?: MessageBlock[]; data?: Record | null; idempotencyKey?: string; }): Promise; thread(id: string, opts?: MessageListQuery): Promise<{ parent: MessageWithMeta; replies: MessageWithMeta[]; }>; dm(agent: string, text: string, opts?: (IdempotencyOption & { mode?: 'wait' | 'steer'; attachments?: string[]; data?: Record | null; })): Promise; dms: { conversations: (opts?: Pick) => Promise; messages: (conversationId: string, opts?: MessageListQuery) => Promise; createGroup: (opts: CreateGroupDmRequest, idempotency?: IdempotencyOption) => Promise; sendMessage: (conversationId: string, text: string, opts?: (IdempotencyOption & { attachments?: string[]; data?: Record | null; mode?: "wait" | "steer"; })) => Promise; addParticipant: (conversationId: string, agent: string) => Promise; removeParticipant: (conversationId: string, agent: string) => Promise; }; private matchesSubscription; private desiredWsChannels; private syncDesiredSubscriptions; channels: { create: (data: CreateChannelRequest) => Promise; list: (opts?: ChannelListOptions) => Promise; get: (name: string) => Promise; join: (name: string) => Promise; leave: (name: string) => Promise; setTopic: (name: string, topic: string) => Promise; archive: (name: string) => Promise; invite: (channel: string, agent: string) => Promise; members: (name: string) => Promise; update: (name: string, data: UpdateChannelRequest) => Promise; mute: (name: string) => Promise; unmute: (name: string) => Promise; }; react(messageId: string, emoji: string): Promise; unreact(messageId: string, emoji: string): Promise; reactions(messageId: string): Promise; search(query: string, opts?: { channel?: string; from?: string; limit?: number; before?: string; after?: string; }): Promise; inbox(options?: { limit?: number; }): Promise; markRead(messageId: string): Promise; readers(messageId: string): Promise; readStatus(channel: string): Promise; /** * List durable delivery items queued for this agent. Defaults to the * non-terminal queue (queued + delivered) so an offline consumer can replay * what it missed on reconnect. Each item carries the message payload. */ deliveries(options?: { status?: DeliveryStatus; limit?: number; }): Promise; /** Idempotently acknowledge a delivery, transitioning it to `acked`. */ ackDelivery(deliveryId: string): Promise; /** Idempotently record a delivery as `failed` with optional error/retryability. */ failDelivery(deliveryId: string, options?: FailDeliveryRequest): Promise; /** Idempotently defer a delivery until `availableAt`. */ deferDelivery(deliveryId: string, options: DeferDeliveryRequest): Promise; actions: { invoke: (name: string, input?: Record) => Promise; completeInvocation: (name: string, invocationId: string, data: CompleteInvocationRequest) => Promise; getInvocation: (name: string, invocationId: string) => Promise; }; files: { upload: (data: UploadRequest) => Promise; complete: (fileId: string) => Promise; get: (fileId: string) => Promise; delete: (fileId: string) => Promise; list: (opts?: FileListOptions) => Promise; }; } export {}; //# sourceMappingURL=agent.d.ts.map