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?
optionalactiveToolSets: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?
optionalapiType: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?
optionalautoCreateConversation: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?
optionalautoEmbedMessages: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
trueInherited from
BaseUseChatStorageOptions.autoEmbedMessages
autoFlushOnKeyAvailable?
optionalautoFlushOnKeyAvailable:boolean
Defined in: src/expo/useChatStorage.ts:319
Auto-flush queued operations when key becomes available.
Default
truebaseUrl?
optionalbaseUrl:string
Defined in: src/lib/db/chat/types.ts:550
Base URL for the chat API endpoint
Inherited from
BaseUseChatStorageOptions.baseUrl
chatBackend?
optionalchatBackend: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?
optionalconversationId: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?
optionaldefaultConversationTitle:string
Defined in: src/lib/db/chat/types.ts:546
Title for auto-created conversations (default: “New conversation”)
Inherited from
BaseUseChatStorageOptions.defaultConversationTitle
detachedTools?
optionaldetachedTools: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?
optionalembeddedWalletSigner:EmbeddedWalletSignerFn
Defined in: src/expo/useChatStorage.ts:304
Function for silent signing with Privy embedded wallets.
embeddingModel?
optionalembeddingModel:string
Defined in: src/lib/db/chat/types.ts:614
Embedding model to use when autoEmbedMessages is enabled.
Default
DEFAULT_API_EMBEDDING_MODELInherited from
BaseUseChatStorageOptions.embeddingModel
enableQueue?
optionalenableQueue:boolean
Defined in: src/expo/useChatStorage.ts:314
Enable the in-memory write queue.
Default
trueextraToolSets?
optionalextraToolSets: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?
optionalfileProcessingOptions:object
Defined in: src/lib/db/chat/types.ts:579
Options for file preprocessing behavior
keepOriginalFiles?
optionalkeepOriginalFiles:boolean
Whether to keep original file attachments (default: true)
maxFileSizeBytes?
optionalmaxFileSizeBytes:number
Max file size to process in bytes (default: 10MB)
onError()?
optionalonError: (fileName:string,error:Error) =>void
Callback for errors (non-fatal)
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
void
onProgress()?
optionalonProgress: (current:number,total:number,fileName:string) =>void
Callback for progress updates
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
void
Inherited from
BaseUseChatStorageOptions.fileProcessingOptions
fileProcessors?
optionalfileProcessors: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?
optionalfoldToolResultsInHistory: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()?
optionalgetToken: () =>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()?
optionalgetWalletAddress: () =>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?
optionalhooks: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?
optionalinbox:VaultInbox
Defined in: src/expo/useChatStorage.ts:387
The vault inbox that receives answers finished while no client was attached.
mcpR2Domain?
optionalmcpR2Domain: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?
optionalmemoryStore: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?
optionalminContentLength: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
10Inherited from
BaseUseChatStorageOptions.minContentLength
nerDetector?
optionalnerDetector: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()?
optionalonCancelResult: (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
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
void
onData()?
optionalonData: (chunk:string) =>void
Defined in: src/lib/db/chat/types.ts:552
Callback invoked with each streamed response chunk
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
void
Inherited from
BaseUseChatStorageOptions.onData
onError()?
optionalonError: (error:Error) =>void
Defined in: src/lib/db/chat/types.ts:558
Callback invoked when an error occurs during the request
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
void
Inherited from
BaseUseChatStorageOptions.onError
onFinish()?
optionalonFinish: (response:LlmapiResponseResponse) =>void
Defined in: src/lib/db/chat/types.ts:556
Callback invoked when the response completes successfully
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
void
Inherited from
BaseUseChatStorageOptions.onFinish
onPiiRedacted()?
optionalonPiiRedacted: (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
| Parameter | Type |
|---|---|
|
|
|
Returns
void
Inherited from
BaseUseChatStorageOptions.onPiiRedacted
onServerToolCall()?
optionalonServerToolCall: (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
| Parameter | Type |
|---|---|
|
|
|
Returns
void
Inherited from
BaseUseChatStorageOptions.onServerToolCall
onStreamMeta()?
optionalonStreamMeta: (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
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
void
onThinking()?
optionalonThinking: (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
| Parameter | Type |
|---|---|
|
|
|
Returns
void
Inherited from
BaseUseChatStorageOptions.onThinking
onToolCallArgumentsDelta()?
optionalonToolCallArgumentsDelta: (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
| Parameter | Type |
|---|---|
|
|
Returns
void
Inherited from
BaseUseChatStorageOptions.onToolCallArgumentsDelta
onToolSelection()?
optionalonToolSelection: (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
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
void
piiRedaction?
optionalpiiRedaction: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 conversationPiiRedactorinstance: bring your own (tune via constructor options)
Inherited from
BaseUseChatStorageOptions.piiRedaction
preProcessors?
optionalpreProcessors: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?
optionalresumable: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
falseserverTools?
optionalserverTools:object
Defined in: src/lib/db/chat/types.ts:590
Configuration for the server tools cache and tool selection.
cache?
optionalcache:ToolsCacheBackend
Cache backend; defaults to localStorage with a memory fallback on platforms without localStorage.
cacheExpirationMs?
optionalcacheExpirationMs:number
Cache expiration time in milliseconds (default: 86400000 = 1 day)
deferLoading?
optionaldeferLoading: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?
optionalsignMessage:SignMessageFn
Defined in: src/expo/useChatStorage.ts:299
Function to sign a message for encryption key derivation.
smoothing?
optionalsmoothing: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?
optionaltoolResultsHistoryExclude: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?
optionalwalletAddress: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.