UseChatStorageResult
Defined in: src/react/useChatStorage.ts:795
Result returned by useChatStorage hook (React version)
Extends base result with React-specific sendMessage signature.
Extends
BaseUseChatStorageResult
Properties
clearQueue()
clearQueue: () =>
void
Defined in: src/react/useChatStorage.ts:983
Clear all queued operations for the current wallet. Discards pending operations without writing them.
Returns
void
conversationId
conversationId:
string|null
Defined in: src/lib/db/chat/types.ts:1115
Inherited from
BaseUseChatStorageResult.conversationId
createConversation()
createConversation: (
options?:CreateConversationOptions) =>Promise<StoredConversation>
Defined in: src/lib/db/chat/types.ts:1117
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<StoredConversation>
Inherited from
BaseUseChatStorageResult.createConversation
createMemoryEngineTool()
createMemoryEngineTool: (
searchOptions?:Partial<MemoryEngineSearchOptions>) =>ToolConfig
Defined in: src/react/useChatStorage.ts:849
Create a memory engine tool for LLM to search past conversations. The tool is pre-configured with the hook’s storage context and auth.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
Optional search configuration (limit, minSimilarity, etc.) |
Returns
ToolConfig
A ToolConfig that can be passed to sendMessage’s clientTools
Example
const memoryTool = createMemoryEngineTool({ limit: 5 });
await sendMessage({
messages: [...],
clientTools: [memoryTool],
});createMemoryVaultSearchTool()
createMemoryVaultSearchTool: (
searchOptions?:MemoryVaultSearchOptions) =>ToolConfig
Defined in: src/react/useChatStorage.ts:877
Create a memory vault search tool for LLM to search vault memories using semantic similarity. Pre-configured with vault context, auth, and a shared embedding cache that is pre-populated on init.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
Optional search configuration (limit, minSimilarity) |
Returns
ToolConfig
A ToolConfig that can be passed to sendMessage’s clientTools
createMemoryVaultTool()
createMemoryVaultTool: (
options?:MemoryVaultToolOptions) =>ToolConfig
Defined in: src/react/useChatStorage.ts:858
Create a memory vault tool for LLM to save/update persistent memories. The tool is pre-configured with the hook’s vault context and encryption.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
Optional configuration (onSave callback for confirmation) |
Returns
ToolConfig
A ToolConfig that can be passed to sendMessage’s clientTools
createRecallTool()
createRecallTool: (
toolOptions?:RecallToolOptions,callbacks?:RecallToolCallbacks) =>ToolConfig
Defined in: src/react/useChatStorage.ts:885
Create the unified recall_memory tool — single LLM-facing tool that
fuses vault facts and conversation chunks via recall(). Prefer
this over wiring createMemoryVaultSearchTool and the chunk tool
separately; the LLM no longer has to route between two surfaces.
Parameters
| Parameter | Type |
|---|---|
|
| |
|
|
Returns
ToolConfig
createVaultMemory()
createVaultMemory: (
content:string,scope?:string) =>Promise<StoredVaultMemory>
Defined in: src/react/useChatStorage.ts:953
Create a new vault memory with the given content.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
The memory text |
|
|
|
Optional scope (defaults to “private”) |
Returns
Promise<StoredVaultMemory>
deleteConversation()
deleteConversation: (
id:string) =>Promise<boolean>
Defined in: src/lib/db/chat/types.ts:1122
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<boolean>
Inherited from
BaseUseChatStorageResult.deleteConversation
deleteVaultMemory()
deleteVaultMemory: (
id:string) =>Promise<boolean>
Defined in: src/react/useChatStorage.ts:970
Delete a vault memory by its ID (soft delete).
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<boolean>
true if the memory was found and deleted
deliverInbox()
deliverInbox: () =>
Promise<InboxDeliveryResult[]>
Defined in: src/react/useChatStorage.ts:997
Register the inbox public key, then store and remove every answer portal sealed into the inbox.
Returns
Promise<InboxDeliveryResult[]>
flushQueue()
flushQueue: () =>
Promise<FlushResult>
Defined in: src/react/useChatStorage.ts:977
Manually flush all queued operations for the current wallet. Operations are encrypted and written to the database. Requires the encryption key to be available.
Returns
Promise<FlushResult>
getActiveStreams()
getActiveStreams: (
conversationId?:string) =>Promise<ActiveStream[]>
Defined in: src/react/useChatStorage.ts:991
The caller’s generations still running on the portal, optionally for one conversation.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<ActiveStream[]>
getAllFiles()
getAllFiles: (
options?:object) =>Promise<StoredFileWithContext[]>
Defined in: src/react/useChatStorage.ts:829
Get all files from all conversations, sorted by creation date (newest first). Returns files with conversation context for building file browser UIs.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Promise<StoredFileWithContext[]>
getConversation()
getConversation: (
id:string) =>Promise<StoredConversation|null>
Defined in: src/lib/db/chat/types.ts:1118
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredConversation | null>
Inherited from
BaseUseChatStorageResult.getConversation
getConversations()
getConversations: () =>
Promise<StoredConversation[]>
Defined in: src/lib/db/chat/types.ts:1119
Returns
Promise<StoredConversation[]>
Inherited from
BaseUseChatStorageResult.getConversations
getMessageCount()
getMessageCount: (
conversationId:string) =>Promise<number>
Defined in: src/lib/db/chat/types.ts:1135
Total message count for a conversation.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<number>
Inherited from
BaseUseChatStorageResult.getMessageCount
getMessages()
getMessages: (
conversationId:string) =>Promise<StoredMessage[]>
Defined in: src/lib/db/chat/types.ts:1123
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredMessage[]>
Inherited from
BaseUseChatStorageResult.getMessages
getMessageSkeletons()
getMessageSkeletons: (
conversationId:string) =>Promise<MessageSkeleton[]>
Defined in: src/lib/db/chat/types.ts:1133
Whole-thread branch-tree skeleton — no field decryption.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<MessageSkeleton[]>
Inherited from
BaseUseChatStorageResult.getMessageSkeletons
getMessagesPage()
getMessagesPage: (
conversationId:string,options:GetMessagesPageOptions) =>Promise<StoredMessage[]>
Defined in: src/lib/db/chat/types.ts:1128
Paginated display read: the newest limit messages (optionally below
beforeMessageId), ascending, with embedding columns skipped.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Promise<StoredMessage[]>
Inherited from
BaseUseChatStorageResult.getMessagesPage
getVaultMemories()
getVaultMemories: (
options?:object) =>Promise<StoredVaultMemory[]>
Defined in: src/react/useChatStorage.ts:944
Get all vault memories for context injection.
Returns memories sorted by creation date (newest first). Soft-deleted
memories are excluded unless includeDeleted is set.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
Optional filtering (scopes to include, whether to include soft-deleted memories) |
|
|
|
Leave out memories the user switched off. |
|
|
|
Typed memory (PR1) — restrict to these fact types. Omit for no filter. |
|
|
|
‐ |
|
|
|
Include archived (decayed) memories. Default |
|
|
|
Include soft-deleted memories in the result (each carries
|
|
|
|
Include quarantined memories. Default |
|
|
|
Include A2-superseded memories (each carries |
|
|
|
Restrict to these profile kinds. |
|
|
( |
Filter by level. |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
|
‐ |
|
|
Filter by People Nearby visibility. Legacy rows with a NULL column count as “private”. Used by the publish reconciler to fetch the published set to diff against the server index. | |
|
|
|
‐ |
Returns
Promise<StoredVaultMemory[]>
isLoading
isLoading:
boolean
Defined in: src/lib/db/chat/types.ts:1113
Inherited from
BaseUseChatStorageResult.isLoading
openSealedWithInboxKey()
openSealedWithInboxKey: (
sealed:string,sealId:string) =>Promise<string>
Defined in: src/react/useChatStorage.ts:999
Open text that portal sealed to the inbox public key under sealId, such as a reward code.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<string>
queueStatus
queueStatus:
QueueStatus
Defined in: src/react/useChatStorage.ts:988
Current status of the write queue.
recall()
recall: (
query:string,options?:RecallOptions) =>Promise<RecallResult>
Defined in: src/react/useChatStorage.ts:903
Recall memories programmatically via the unified ranked pipeline — the
programmatic twin of createRecallTool. Returns ranked memories
for callers that inject memory into the prompt themselves (e.g.
pre-retrieval injection) instead of exposing a tool to the LLM. Shares
the hook’s warm embedding cache, so a warmed vault ranks in-memory with
a single query-embedding round-trip. Defaults to budget: 'low',
types: ['fact']. Gracefully returns an empty result when auth is
unavailable — pre-retrieval must never crash the submit path.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
Natural language recall query |
|
|
Optional recall configuration (types, budget, limit, scopes, …) |
Returns
Promise<RecallResult>
retainVaultMemory()
retainVaultMemory: (
input:VaultWriteInput) =>Promise<RetainResult>
Defined in: src/react/useChatStorage.ts:867
Write one memory through retain() — cosine auto-merge against the vault,
so an explicit “save this” from a host surface (selection → memory, a
manual add) lands as a re-observation of an existing memory instead of a
duplicate row when the vault already holds the fact. The
memory_vault_save tool writes through this too. Throws without getToken.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<RetainResult>
searchVaultMemories()
searchVaultMemories: (
query:string,searchOptions?:MemoryVaultSearchOptions) =>Promise<VaultSearchResult[]>
Defined in: src/react/useChatStorage.ts:919
Search vault memories programmatically using semantic similarity. Returns structured results sorted by descending similarity. Gracefully returns [] when auth is unavailable.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
Natural language search query |
|
|
Optional search configuration (limit, minSimilarity, scopes) |
Returns
Promise<VaultSearchResult[]>
sendMessage()
sendMessage: (
args:object) =>Promise<SendMessageWithStorageResult>
Defined in: src/react/useChatStorage.ts:824
Sends a message to the AI and automatically persists both the user message and assistant response to the database.
This method handles the complete message lifecycle:
- Ensures a conversation exists (creates one if
autoCreateConversationis enabled) - Optionally includes conversation history for context
- Stores the user message before sending
- Streams the response via the underlying
useChathook - Stores the assistant response (including usage stats, sources, and thinking)
- Handles abort/error states gracefully
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
Override the API type for this specific request.
Useful when different models need different APIs within the same hook instance. |
|
|
|
Pre-generated unique ID for the assistant response message. When provided, the persisted assistant message will use this ID instead of an auto-generated one. This lets the consumer show an in-flight streaming placeholder under the same React key, avoiding an unmount/remount flash when streaming completes and the message is loaded from the database. |
|
|
Client-side tools with optional executors. These tools run in the browser/app and can have JavaScript executor functions. | |
|
|
Dynamic filter for client-side tools based on prompt embeddings. Receives the prompt embedding(s) (or null for short messages) and all client tools, returns tool names to include. Tools not in the returned list are excluded from the request. Example | |
|
|
|
Explicitly specify the conversation ID to send this message to. If provided, bypasses the automatic conversation detection/creation. Useful when sending a message immediately after creating a conversation, to avoid race conditions with React state updates. |
|
|
|
Optional embedding cache, shared with the caller. Every send that needs tool selection embeds the user text once (see
Keyed on the text as passed in (before WHICH MEANS SHARING TAKES ONE MORE STEP, and skipping it costs you the dedupe silently: pass
the plain Long messages are not deduped. Past Omit it and nothing changes: every send embeds independently, exactly as before. |
|
|
|
Additional context from preprocessed file attachments. Contains extracted text from Excel, Word, PDF, and other document files. Injected as a system message so it’s available throughout the conversation. |
|
|
File attachments to include with the message (images, documents, etc.). Files with image MIME types and URLs are sent as image content parts. File metadata is stored with the message (URLs are stripped if they’re data URIs). | |
|
|
() => |
Callback to get activity phases AFTER streaming completes.
Use this instead of If both |
|
|
|
Custom HTTP headers to include with the API request. Useful for passing additional authentication, tracking, or feature flags. |
|
|
|
User-selected image generation model for server-side enforcement. |
|
|
|
Whether to automatically include previous messages from the conversation as context.
When true, fetches stored messages and prepends them to the request.
Ignored if Default |
|
|
|
Maximum number of historical messages to include when Default |
|
|
|
Maximum number of tokens to generate in the response. Use this to limit response length and control costs. |
|
|
|
Maximum number of tool execution rounds before forcing the model to respond with text.
After this many rounds, Default |
|
|
|
Additional context from memory/RAG system to include in the request. Typically contains retrieved relevant information from past conversations. |
|
|
The message array to send to the AI. Uses the modern array format that supports multimodal content (text, images, files). The last user message in this array will be extracted and stored in the database. When Example | |
|
|
|
The model identifier to use for this request (e.g., “fireworks/accounts/fireworks/models/kimi-k2p5”). If not specified, uses the default model configured on the server. |
|
|
( |
Per-request callback invoked with each streamed response chunk.
Overrides the hook-level |
|
|
( |
Called once, after the turn’s attachments are preprocessed and before the request is sent,
with one FileProcessingStatus per attached file (images sent as |
|
|
( |
Per-request callback for thinking/reasoning chunks. Called with delta chunks as the model “thinks” through a problem. Use this to display thinking progress in the UI. |
|
|
|
Parent message ID for branching (edit/regenerate). Sets on the user message. |
|
|
|
Per-request override for PII redaction. When set, takes precedence over the
hook-level Scope: applies to this call’s outbound LLM request, its embedding inputs
(tool-filtering and the stored message/chunk embeddings), and the
summarization prompt. Vault/memory tool embeddings are governed by the
hook-level redactor since the vault spans conversations. |
|
|
Reasoning configuration for o-series and other reasoning models. Controls reasoning effort level and whether to include reasoning summary. | |
|
|
|
Additional context from search results to include in the request. Typically contains relevant information from web or document searches. |
|
|
Server-side tools to include from /api/v1/tools.
Example | |
|
|
|
Skip all storage operations (conversation, messages, embeddings, media). Use this for one-off tasks like title generation where you don’t want to pollute the database with utility messages. When true:
Default Example |
|
|
Search sources to attach to the stored message for citation/reference. Note: Sources are also automatically extracted from tool_call_events in the response. | |
|
|
|
Override the text content persisted for the user message, instead of
extracting it from the last user turn of The wire payload ( Set this to the user’s actual text so the wire keeps the injected context
while the persisted user content reflects only what the user typed. This
drives everything derived from the stored user text: the DB row, the chat
bubble, the stored message embedding, the embedding reused for
server/client tool selection (so tool filtering keys off the typed text,
not the injected context), AND the prompt and embedding handed to
Pass |
|
|
|
Enable progressive summarization of conversation history. When enabled, older messages are summarized into a compact text using a cheap model, while recent messages are kept verbatim. This reduces input tokens by 50-70% for long conversations. Requires Default |
|
|
|
Minimum number of recent messages to always keep verbatim (never summarized). Ensures the LLM always has immediate conversational context. Even if these messages exceed the token threshold, they are kept. Default |
|
|
|
Model to use for generating conversation summaries. Should be a cheap, fast model since summarization is a straightforward task. Default |
|
|
|
Token threshold for conversation history before summarization triggers. When the total token count of the cached summary + unsummarized messages exceeds this value, older messages are summarized to fit within the budget. How to choose a value:
The fixed overhead (system prompt + tools + memory ≈ 3,500 tokens) is NOT included — it is additive. Total input ≈ overhead + threshold + current message. Default |
|
|
|
Controls randomness in the response (0.0 to 2.0). Lower values make output more deterministic, higher values more creative. |
|
|
Extended thinking configuration for Anthropic models (Claude). Enables the model to think through complex problems step by step before generating the final response. | |
|
|
|
Activity phases for tracking the request lifecycle in the UI. Each phase represents a step like “Searching”, “Thinking”, “Generating”. The final phase is automatically marked as completed when stored. Note: If you need activity phases that are added during streaming (e.g., server tool calls),
use |
|
|
|
Controls which tool the model should use:
|
Returns
Promise<SendMessageWithStorageResult>
Example
const result = await sendMessage({
content: "Explain quantum computing",
model: "fireworks/accounts/fireworks/models/kimi-k2p5",
includeHistory: true,
onData: (chunk) => setStreamingText(prev => prev + chunk),
});
if (result.error) {
console.error("Failed:", result.error);
} else {
console.log("Stored message ID:", result.assistantMessage.uniqueId);
}setConversationId()
setConversationId: (
id:string|null) =>void
Defined in: src/lib/db/chat/types.ts:1116
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
void
Inherited from
BaseUseChatStorageResult.setConversationId
stop()
stop: () =>
void
Defined in: src/lib/db/chat/types.ts:1114
Returns
void
Inherited from
BaseUseChatStorageResult.stop
updateConversationPinned()
updateConversationPinned: (
id:string,pinned:boolean) =>Promise<boolean>
Defined in: src/lib/db/chat/types.ts:1121
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<boolean>
Inherited from
BaseUseChatStorageResult.updateConversationPinned
updateConversationTitle()
updateConversationTitle: (
id:string,title:string) =>Promise<boolean>
Defined in: src/lib/db/chat/types.ts:1120
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<boolean>
Inherited from
BaseUseChatStorageResult.updateConversationTitle
updateVaultMemory()
updateVaultMemory: (
id:string,content:string,scope?:string) =>Promise<StoredVaultMemory|null>
Defined in: src/react/useChatStorage.ts:960
Update an existing vault memory’s content.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
‐ |
|
|
|
Optional new scope for the memory |
Returns
Promise<StoredVaultMemory | null>
the updated memory, or null if not found
vaultEmbeddingCache
vaultEmbeddingCache:
VaultEmbeddingCache
Defined in: src/react/useChatStorage.ts:935
The shared vault embedding cache. Use this to eagerly embed content when saving vault memories (via eagerEmbedContent).
Shared per (database, walletAddress, embeddingModel) rather than owned by
this hook instance: every useChatStorage on the same three gets this exact
object, and it outlives their unmounts. Writes and evictions are therefore
visible to all of them — which is the point (a memory deleted through one
hook stops being served by the others) but does mean clear() clears for
everyone.
warmRecallCache()
warmRecallCache: (
signal?:AbortSignal) =>Promise<number>
Defined in: src/react/useChatStorage.ts:909
Loads the most recent past messages’ vectors, up to the recall cache’s size, so the first recall does not read them all.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<number>
How many it added. It resolves rather than rejects when aborted or signed out, with how many it added before stopping.
watchStream()
watchStream: (
stream:ActiveStream) =>Promise<ResumeStreamResult>
Defined in: src/react/useChatStorage.ts:994
Show a running generation from its first frame; nothing is stored.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<ResumeStreamResult>