React Native (@agentimhq/client-react-native) API
Generated from the source and its doc comments (sdk/client-react-native/src/client.ts).
npm install @agentimhq/client-react-nativeClientOptions
Section titled “ClientOptions”interface ClientOptionsHow the client starts: the server address, this device’s id, the token provider, the cache and how it names itself.
ClientOptions.url
Section titled “ClientOptions.url”url: stringhttps://chat.example.com.
ClientOptions.deviceId
Section titled “ClientOptions.deviceId”deviceId: stringThis device’s id, the same every run (1..64 of A-Z a-z 0-9 _ -).
ClientOptions.tokenProvider
Section titled “ClientOptions.tokenProvider”tokenProvider: () => Promise<string>A client token from your backend; throw TokenRefused to stop.
ClientOptions.storeDir
Section titled “ClientOptions.storeDir”storeDir?: stringWhere the cache lives (the app’s documents directory); none keeps it in memory.
ClientOptions.deviceName
Section titled “ClientOptions.deviceName”deviceName?: stringA name for this device in the user’s device list, like “Maya’s laptop”.
ClientOptions.platform
Section titled “ClientOptions.platform”platform?: stringThe platform reported to the server (web, ios, android…), for the device list and push.
ClientOptions.clientName
Section titled “ClientOptions.clientName”clientName?: stringThis app’s name, sent with each connection (for diagnostics and the server’s minimum-version rules).
ClientOptions.clientVersion
Section titled “ClientOptions.clientVersion”clientVersion?: stringThis app’s version, sent with clientName.
ClientOptions.commandTimeoutMs
Section titled “ClientOptions.commandTimeoutMs”commandTimeoutMs?: numberHow long a command waits for its answer before failing with timeout, in ms (default 60000).
AgentIMClient
Section titled “AgentIMClient”class AgentIMClientThe AgentIM client for one account on one device: keeps the connection, syncs, sends the offline queue in order, keeps the local cache, and turns everything into observable state.
AgentIMClient.connection
Section titled “AgentIMClient.connection”readonly connection = new Observable<Connection>({ state: 'closed' })The connection state (closed, connecting, connected, disconnected, suspended, failed) and why; subscribe to follow it.
AgentIMClient.conversations
Section titled “AgentIMClient.conversations”readonly conversations = new Observable<any[]>([])The conversation list, newest first, kept up to date.
AgentIMClient.version
Section titled “AgentIMClient.version”static version(): stringThe version of the native core.
AgentIMClient.create
Section titled “AgentIMClient.create”static create(o: ClientOptions): AgentIMClientStarts a client with its options: the server address, this device’s id, the token provider and the cache. Nothing connects until connect. The native core runs on its own thread.
AgentIMClient.command
Section titled “AgentIMClient.command”command(cmd: Record<string, unknown>, applyInOrder?: (r: any) => void): Promise<any>Any core command ({cmd: …}); resolves with its result.
AgentIMClient.on
Section titled “AgentIMClient.on”on(type: string, fn: Listener): () => voidEvents: operation, side, signal, reset, storage, event, read, mute.
AgentIMClient.setNetwork
Section titled “AgentIMClient.setNetwork”setNetwork(online: boolean)NetInfo: call on every change.
AgentIMClient.setForeground
Section titled “AgentIMClient.setForeground”setForeground(foreground: boolean)AppState: active is the foreground.
AgentIMClient.messages
Section titled “AgentIMClient.messages”messages(convId: string): MessagesThe messages of a conversation, oldest first, kept up to date while subscribed; pages back with loadOlder.
AgentIMClient.connect
Section titled “AgentIMClient.connect”connect()Connects and keeps connecting: reconnects with backoff when the network or the server goes, syncs what it missed, sends the offline queue.
AgentIMClient.close
Section titled “AgentIMClient.close”close()Disconnects; the queue and the cache stay. connect again picks up where it stopped.
AgentIMClient.logout
Section titled “AgentIMClient.logout”logout()Logs out here: closes and wipes the cache and the queue (GDPR).
AgentIMClient.send
Section titled “AgentIMClient.send”send(convId: string, text: string, opts: { kind?: string; payload?: unknown; replyTo?: string; clientMsgId?: string; threadId?: string; alsoInConv?: boolean } = {})Sends a text (or a custom kind with its payload): shown at once as sending, sent when the connection allows, in order. Returns the client_msg_id and the local key; a retry with the same client_msg_id is the same message.
AgentIMClient.sendFile
Section titled “AgentIMClient.sendFile”sendFile(convId: string, path: string, opts: { name?: string; mime?: string; caption?: string; replyTo?: string; clientMsgId?: string; keepMetadata?: boolean } = {})Sends a file or a photo from a path (file:// URIs work): shown at once as uploading, sent when it is up. A photo loses its EXIF and GPS (unless keepMetadata) and gets a 320-pixel thumbnail (docs/en/design/messaging.md).
AgentIMClient.localPreview
Section titled “AgentIMClient.localPreview”localPreview(key?: string | null): string | undefinedA local address for a file this device is sending (payload.local_thumb or local_source: paths).
AgentIMClient.fileUrl
Section titled “AgentIMClient.fileUrl”fileUrl(convId: string, fileId: string, variant: 'original' | 'thumb' = 'original'): Promise<{ url: string; variant: string; expires_at: number }>A link (valid a few minutes) to read a file: original or thumb.
AgentIMClient.edit
Section titled “AgentIMClient.edit”edit(convId: string, target: { msgId?: string; clientMsgId?: string }, text: string)Edits one of my messages (by msgId, or by clientMsgId while it is still queued); the change shows at once.
AgentIMClient.recall
Section titled “AgentIMClient.recall”recall(convId: string, target: { msgId?: string; clientMsgId?: string })Recalls one of my messages for everyone; a message still in the queue is simply not sent.
AgentIMClient.read
Section titled “AgentIMClient.read”read(convId: string, seq?: number)Marks the conversation read up to seq (default: the newest) on all my devices.
AgentIMClient.feedback
Section titled “AgentIMClient.feedback”feedback(convId: string, msgId: string, rating: 'up' | 'down', reason?: string)Rates an agent’s message up or down, with an optional reason.
AgentIMClient.react
Section titled “AgentIMClient.react”react(convId: string, msgId: string, key: string): Promise<{ changed: boolean; seq?: number }>Adds a reaction (one emoji, or one of the app’s :names:); adding it twice changes nothing.
AgentIMClient.unreact
Section titled “AgentIMClient.unreact”unreact(convId: string, msgId: string, key: string): Promise<{ changed: boolean; seq?: number }>Removes my reaction; removing one that is not there changes nothing.
AgentIMClient.listReactions
Section titled “AgentIMClient.listReactions”listReactions(convId: string, msgId: string, key: string, opts: { afterSeq?: number; limit?: number } = {})Who reacted to a message with a key, oldest first.
AgentIMClient.pin
Section titled “AgentIMClient.pin”pin(convId: string, msgId: string): Promise<{ changed: boolean; seq?: number }>Pins a message to the conversation; pinning it again changes nothing.
AgentIMClient.unpin
Section titled “AgentIMClient.unpin”unpin(convId: string, msgId: string): Promise<{ changed: boolean; seq?: number }>Unpins a message.
AgentIMClient.listPins
Section titled “AgentIMClient.listPins”listPins(convId: string, opts: { beforeSeq?: number; limit?: number } = {})The conversation’s pinned messages, latest pin first.
AgentIMClient.pullThread
Section titled “AgentIMClient.pullThread”pullThread(convId: string, threadId: string, opts: { afterSeq?: number; limit?: number } = {})A thread’s root and its replies after afterSeq.
AgentIMClient.listThreads
Section titled “AgentIMClient.listThreads”listThreads(opts: { convId?: string; before?: number; limit?: number } = {})The threads I follow (in one conversation, or all), latest reply first, with unread counts.
AgentIMClient.readThread
Section titled “AgentIMClient.readThread”readThread(convId: string, threadId: string, seq: number)Marks a thread read up to seq on all my devices.
AgentIMClient.followThread
Section titled “AgentIMClient.followThread”followThread(convId: string, threadId: string, follow = true)Follows a thread (its replies notify me) or stops following it.
AgentIMClient.msgSummary
Section titled “AgentIMClient.msgSummary”msgSummary(convId: string, msgIds: string[])The thread summary, reactions and pin of up to 100 messages (for messages loaded from history).
AgentIMClient.respond
Section titled “AgentIMClient.respond”respond(convId: string, msgId: string, blockId: string, r: { action?: string; values?: Record<string, unknown> })Answers a card: a button (action) or a filled form (values).
AgentIMClient.retry
Section titled “AgentIMClient.retry”retry(convId: string, clientMsgId: string)Sends a failed message again (the same client_msg_id, so it is never doubled).
AgentIMClient.discard
Section titled “AgentIMClient.discard”discard(convId: string, clientMsgId: string)Drops a failed or waiting message from the queue.
AgentIMClient.pendingOps
Section titled “AgentIMClient.pendingOps”pendingOps()What waits in the offline queue.
AgentIMClient.call
Section titled “AgentIMClient.call”call(op: string, args: Record<string, unknown> = {})A request that needs the server now (approvals, decisions, queries); fails at once when offline.
AgentIMClient.debugState
Section titled “AgentIMClient.debugState”debugState()Everything that helps report a problem: the connection, positions, the queue and recent failures.
AgentIMClient.dispose
Section titled “AgentIMClient.dispose”dispose()Stops the client; no event arrives after it. Waiting calls fail with closed.