Skip to Content
Anuma SDKExpoInternalInterfacesUseChatStorageOptions

UseChatStorageOptions

Defined in: src/expo/useChatStorage.ts:282 

Options for useChatStorage hook (Expo version)

Uses the base options without React-specific features (no local chat, no tools).

Extends

  • BaseUseChatStorageOptions

Properties

activeToolSets?

optional activeToolSets: string[]

Defined in: src/expo/useChatStorage.ts:346 

Tool set names that should expand unconditionally for this request, bypassing the anchor-similarity check. Use when conversation state implies a set should be present regardless of how the prompt is phrased — e.g., pass ["documents"] when the conversation already contains a generated document, so short follow-up prompts (“make the background red”) still get the full document toolkit.

Read via a ref so updates are visible to in-flight sendMessage calls without rebuilding the callback.

Names must match a set’s name from BUILT_IN_TOOL_SETS or extraToolSets. Unknown names are ignored.


apiType?

optional apiType: ApiType

Defined in: src/expo/useChatStorage.ts:288 

Which API endpoint to use. Default: “responses”

  • “responses”: OpenAI Responses API (supports thinking, reasoning, conversations)
  • “completions”: OpenAI Chat Completions API (wider model compatibility)

autoCreateConversation?

optional autoCreateConversation: boolean

Defined in: src/lib/db/chat/types.ts:544 

Automatically create a new conversation if none is set (default: true)

Inherited from

BaseUseChatStorageOptions.autoCreateConversation


autoEmbedMessages?

optional autoEmbedMessages: boolean

Defined in: src/lib/db/chat/types.ts:609 

Automatically generate embeddings for messages after saving. Enables semantic search over past conversations via searchMessages().

Default

true

Inherited from

BaseUseChatStorageOptions.autoEmbedMessages


autoFlushOnKeyAvailable?

optional autoFlushOnKeyAvailable: boolean

Defined in: src/expo/useChatStorage.ts:319 

Auto-flush queued operations when key becomes available.

Default

true

baseUrl?

optional baseUrl: string

Defined in: src/lib/db/chat/types.ts:550 

Base URL for the chat API endpoint

Inherited from

BaseUseChatStorageOptions.baseUrl


chatBackend?

optional chatBackend: ChatBackendFactory

Defined in: src/lib/db/chat/types.ts:540 

Builds the chat storage backend (default: this database); keep it stable across renders, since a new factory rebuilds the backend and every callback.

Inherited from

BaseUseChatStorageOptions.chatBackend


conversationId?

optional conversationId: string

Defined in: src/lib/db/chat/types.ts:542 

ID of an existing conversation to load and continue

Inherited from

BaseUseChatStorageOptions.conversationId


database

database: Database

Defined in: src/lib/db/chat/types.ts:536 

WatermelonDB database instance for storing conversations and messages

Inherited from

BaseUseChatStorageOptions.database


defaultConversationTitle?

optional defaultConversationTitle: string

Defined in: src/lib/db/chat/types.ts:546 

Title for auto-created conversations (default: “New conversation”)

Inherited from

BaseUseChatStorageOptions.defaultConversationTitle


detachedTools?

optional detachedTools: ToolConfig[]

Defined in: src/expo/useChatStorage.ts:392 

Device tools that can finish a turn the portal completed while the device was away: their executors run when that answer is stored. Pass the display tools and the memory save tool.


embeddedWalletSigner?

optional embeddedWalletSigner: EmbeddedWalletSignerFn

Defined in: src/expo/useChatStorage.ts:304 

Function for silent signing with Privy embedded wallets.


embeddingModel?

optional embeddingModel: string

Defined in: src/lib/db/chat/types.ts:614 

Embedding model to use when autoEmbedMessages is enabled.

Default

DEFAULT_API_EMBEDDING_MODEL

Inherited from

BaseUseChatStorageOptions.embeddingModel


enableQueue?

optional enableQueue: boolean

Defined in: src/expo/useChatStorage.ts:314 

Enable the in-memory write queue.

Default

true

extraToolSets?

optional extraToolSets: ToolSet[]

Defined in: src/expo/useChatStorage.ts:330 

Additional tool sets to apply on top of the built-in ones (app-generation, slides, github). When any anchor tool in a custom set is selected by semantic matching, all members of that set are included automatically.

Treated as static config — set once at hook setup. Changing it across renders does not affect in-flight sendMessage calls; use activeToolSets for dynamic, conversation-state-driven overrides.


fileProcessingOptions?

optional fileProcessingOptions: object

Defined in: src/lib/db/chat/types.ts:579 

Options for file preprocessing behavior

keepOriginalFiles?

optional keepOriginalFiles: boolean

Whether to keep original file attachments (default: true)

maxFileSizeBytes?

optional maxFileSizeBytes: number

Max file size to process in bytes (default: 10MB)

onError()?

optional onError: (fileName: string, error: Error) => void

Callback for errors (non-fatal)

Parameters

ParameterType

fileName

string

error

Error

Returns

void

onProgress()?

optional onProgress: (current: number, total: number, fileName: string) => void

Callback for progress updates

Parameters

ParameterType

current

number

total

number

fileName

string

Returns

void

Inherited from

BaseUseChatStorageOptions.fileProcessingOptions


fileProcessors?

optional fileProcessors: FileProcessor[] | null

Defined in: src/lib/db/chat/types.ts:575 

File preprocessors to use for automatic text extraction.

  • undefined (default): Use all built-in processors (PDF, Excel, Word)
  • null or []: Disable preprocessing
  • FileProcessor[]: Use specific processors

Inherited from

BaseUseChatStorageOptions.fileProcessors


foldToolResultsInHistory?

optional foldToolResultsInHistory: boolean

Defined in: src/lib/db/chat/types.ts:660 

Fold persisted [Tool Execution Results] rows onto the assistant turn that produced them when replaying stored history, instead of dropping them.

Defaults to false, and that default is deliberate. Folding is the better behaviour — it is what lets a follow-up about a tool’s output work after a reload — but it moves the payload from a role: "user" row onto an assistant row. Any consumer that scrubs these rows by checking role === "user" plus the content prefix (which is how both apps did it before this option existed) stops catching them the moment folding turns on, and starts replaying whatever the row held. Opting in is therefore a statement that the caller has checked its own filters and set toolResultsHistoryExclude for any payload that must not reach the model.

With it off, rows are dropped from the replayed history rather than sent verbatim. Verbatim would put two consecutive user turns on the wire, and the model answers the previous turn instead of the new prompt.

Inherited from

BaseUseChatStorageOptions.foldToolResultsInHistory


getToken()?

optional getToken: () => Promise<string | null>

Defined in: src/lib/db/chat/types.ts:548 

Function to retrieve the auth token for API requests

Returns

Promise<string | null>

Inherited from

BaseUseChatStorageOptions.getToken


getWalletAddress()?

optional getWalletAddress: () => Promise<string | null>

Defined in: src/expo/useChatStorage.ts:309 

Async function to poll for wallet address during Privy initialization.

Returns

Promise<string | null>


hooks?

optional hooks: RunHooks | RunHooks[]

Defined in: src/lib/db/chat/types.ts:534 

Run lifecycle hooks for telemetry and tracing, for example from createMetricsHooks

Inherited from

BaseUseChatStorageOptions.hooks


inbox?

optional inbox: VaultInbox

Defined in: src/expo/useChatStorage.ts:387 

The vault inbox that receives answers finished while no client was attached.


mcpR2Domain?

optional mcpR2Domain: string

Defined in: src/lib/db/chat/types.ts:626 

R2 domain for identifying MCP-generated image URLs. When set, enables OPFS caching of generated images. Defaults to the hardcoded MCP_R2_DOMAIN from clientConfig.

Inherited from

BaseUseChatStorageOptions.mcpR2Domain


memoryStore?

optional memoryStore: MemoryStore | null

Defined in: src/lib/db/chat/types.ts:538 

Route memory operations through this store; null disables memory access while undefined uses the local vault. Folders are unsupported. With piiRedaction on, build the store with embeddingOptions.maskInput or its memory calls throw.

Inherited from

BaseUseChatStorageOptions.memoryStore


minContentLength?

optional minContentLength: number

Defined in: src/lib/db/chat/types.ts:620 

Minimum content length required to generate embeddings. Messages shorter than this are skipped as they provide limited semantic value.

Default

10

Inherited from

BaseUseChatStorageOptions.minContentLength


nerDetector?

optional nerDetector: NerDetector

Defined in: src/lib/db/chat/types.ts:698 

Optional on-device NER detector for unstructured PII (names, locations, organizations) that regex can’t catch. When supplied AND piiRedaction is active, the conversation redactor merges its spans into the outbound message redaction (chat-send path only). Supply e.g. createTransformersNerDetector() from @anuma/sdk/pii/transformers on web. Ignored when piiRedaction is off. See NerDetector.

Inherited from

BaseUseChatStorageOptions.nerDetector


onCancelResult()?

optional onCancelResult: (result: object) => void

Defined in: src/expo/useChatStorage.ts:364 

Observability for the fire-and-forget cancel POST that stop() issues for a resumable stream. Forwarded to the underlying useChat. The stop-without-cancel billing risk must be visible: once the capability header ships, the portal no longer treats a dropped socket as cancellation, so a stop() whose cancel POST silently fails bills the full generation.

Parameters

ParameterType

result

object

result.error?

Error

result.inferenceId

string

result.ok

boolean

result.status?

number

Returns

void


onData()?

optional onData: (chunk: string) => void

Defined in: src/lib/db/chat/types.ts:552 

Callback invoked with each streamed response chunk

Parameters

ParameterType

chunk

string

Returns

void

Inherited from

BaseUseChatStorageOptions.onData


onError()?

optional onError: (error: Error) => void

Defined in: src/lib/db/chat/types.ts:558 

Callback invoked when an error occurs during the request

Parameters

ParameterType

error

Error

Returns

void

Inherited from

BaseUseChatStorageOptions.onError


onFinish()?

optional onFinish: (response: LlmapiResponseResponse) => void

Defined in: src/lib/db/chat/types.ts:556 

Callback invoked when the response completes successfully

Parameters

ParameterType

response

LlmapiResponseResponse

Returns

void

Inherited from

BaseUseChatStorageOptions.onFinish


onPiiRedacted()?

optional onPiiRedacted: (matches: PiiMatch[]) => void

Defined in: src/lib/db/chat/types.ts:689 

Called with the PII matches found whenever outbound messages are redacted. Only fired when piiRedaction is active and at least one match was found.

Parameters

ParameterType

matches

PiiMatch[]

Returns

void

Inherited from

BaseUseChatStorageOptions.onPiiRedacted


onServerToolCall()?

optional onServerToolCall: (toolCall: ServerToolCallEvent) => void

Defined in: src/lib/db/chat/types.ts:563 

Callback invoked when a server-side tool (MCP) is called during streaming. Use this to show activity indicators like “Searching…” in the UI.

Parameters

ParameterType

toolCall

ServerToolCallEvent

Returns

void

Inherited from

BaseUseChatStorageOptions.onServerToolCall


onStreamMeta()?

optional onStreamMeta: (meta: object) => void

Defined in: src/expo/useChatStorage.ts:379 

Observe the stream metadata the portal issues at HEADERS_RECEIVED, once per round. Forwarded to the underlying useChat. The enriched payload carries the RESOLVED apiType and model alongside inferenceId, so a consumer can persist a rebuildable StreamResumeHandle for a cold-launch resume registry (mobile PR5). Additive — never alters the internal resume-handle capture.

Parameters

ParameterType

meta

object

meta.apiType

"responses" | "completions"

meta.assistantMessageId?

string

meta.inferenceId

string

meta.model?

string

meta.round?

number

Returns

void


onThinking()?

optional onThinking: (chunk: string) => void

Defined in: src/lib/db/chat/types.ts:554 

Callback invoked when thinking/reasoning content is received (from <think> tags or API reasoning)

Parameters

ParameterType

chunk

string

Returns

void

Inherited from

BaseUseChatStorageOptions.onThinking


onToolCallArgumentsDelta()?

optional onToolCallArgumentsDelta: (event: ToolCallArgumentsDeltaEvent) => void

Defined in: src/lib/db/chat/types.ts:568 

Called with partial tool call arguments as they stream in. Use for live preview of artifacts (HTML, slides) being generated.

Parameters

ParameterType

event

ToolCallArgumentsDeltaEvent

Returns

void

Inherited from

BaseUseChatStorageOptions.onToolCallArgumentsDelta


onToolSelection()?

optional onToolSelection: (info: object) => void

Defined in: src/expo/useChatStorage.ts:398 

Observability hook fired once per send with the tools actually selected for the turn (after server + client filtering). Never throws into the send path. Mirrors react’s onToolSelection.

Parameters

ParameterType

info

object

info.clientToolNames

string[]

info.prompt

string

info.serverToolNames

string[]

Returns

void


piiRedaction?

optional piiRedaction: boolean | PiiRedactor

Defined in: src/lib/db/chat/types.ts:684 

Enable best-effort, client-side PII obfuscation (NOT a compliance guarantee). Outbound message text is scanned for personally identifiable information and replaced with tagged placeholders before reaching the LLM provider; responses are de-anonymized automatically. Embedding inputs and the summarization prompt are redacted too. Regex-based detection does not cover names, non-text content, or tool-call arguments.

  • true: one redactor is shared per conversation
  • PiiRedactor instance: bring your own (tune via constructor options)

Inherited from

BaseUseChatStorageOptions.piiRedaction


preProcessors?

optional preProcessors: PromptPreProcessor[]

Defined in: src/lib/db/chat/types.ts:670 

Pre-processors run after the last user message is received but before the first LLM request. Each receives the prompt text and a shared embedding (computed once per request) and may return messages to enrich the conversation. Forwarded to the underlying useChat hook. See createWebSearchPreProcessor, createCryptoPricePreProcessor, createStockPricePreProcessor, createWeatherPreProcessor, or write a custom one matching PromptPreProcessor.

Inherited from

BaseUseChatStorageOptions.preProcessors


resumable?

optional resumable: boolean

Defined in: src/expo/useChatStorage.ts:355 

Opt into resumable streaming. When true, sendMessage sends the resumable capability header, a stable assistantUniqueId is allocated for every turn (so the partial and the resumed completion reconcile onto ONE row), and detach() / resumeStream() become usable. Off by default.

Default

false

serverTools?

optional serverTools: object

Defined in: src/lib/db/chat/types.ts:590 

Configuration for the server tools cache and tool selection.

cache?

optional cache: ToolsCacheBackend

Cache backend; defaults to localStorage with a memory fallback on platforms without localStorage.

cacheExpirationMs?

optional cacheExpirationMs: number

Cache expiration time in milliseconds (default: 86400000 = 1 day)

deferLoading?

optional deferLoading: DeferLoadingConfig

Opt-in defer-loading (Phase 3). OFF by default → tools are sent exactly as today. When enabled, the full server catalog is emitted every turn in a deterministic, byte-stable order ([tool-search] → [hot] → [deferred, name-sorted]) with defer_loading:true on non-hot tools and an Anthropic tool-search tool prepended, so the leading tools prefix stays cacheable. See DeferLoadingConfig.

Inherited from

BaseUseChatStorageOptions.serverTools


signMessage?

optional signMessage: SignMessageFn

Defined in: src/expo/useChatStorage.ts:299 

Function to sign a message for encryption key derivation.


smoothing?

optional smoothing: boolean | StreamSmoothingConfig

Defined in: src/lib/db/chat/types.ts:672 

Output pacing forwarded to useChat. Set false when the UI batches streamed updates.

Inherited from

BaseUseChatStorageOptions.smoothing


toolResultsHistoryExclude?

optional toolResultsHistoryExclude: string[]

Defined in: src/lib/db/chat/types.ts:642 

Tool names whose persisted results must never be replayed to the model.

A turn’s auto-executed tool results are stored as a synthetic [Tool Execution Results] row and, on a replayed send, folded back onto the assistant turn they belong to — that is what lets a follow-up question about a tool’s output work after a reload. Name a tool here when its payload exists for the RENDERER rather than the model: a display card can carry data the model was deliberately never given (People Nearby’s card holds third parties’ snapped coordinates, which the search result strips), and replaying it would hand that data straight back.

Hook-level rather than per-send on purpose: an exclusion that has to be remembered at every call site is one bad send away from leaking.

Inherited from

BaseUseChatStorageOptions.toolResultsHistoryExclude


walletAddress?

optional walletAddress: string

Defined in: src/expo/useChatStorage.ts:294 

Wallet address for field-level encryption. When provided with signMessage, all sensitive content is encrypted at rest.

Last updated on