Hooks
useKivaAgentMemories
Backend glue for the KivaAgent memory manager — list, create, update and delete /v1/ai/memories with optimistic local state.
iOSAndroidExpo Go
Installation
pnpm dlx @kivacore/ui-cli add @kivacore/rn-hooks-use-kiva-agent-memoriesA verbatim port of the web hook (no React Query — plain local state with optimistic updates). Feed its result into KivaAgentMemoriesView.
Usage
import { KivaAgentMemoriesView } from '@/components/kiva-native/kiva-agent';
import { useKivaAgentMemories } from '@/hooks/kiva-native/use-kiva-agent-memories';
const memories = useKivaAgentMemories({ client, agentId: AGENT_ID, userId: user?.id });
<KivaAgentMemoriesView
memories={memories.memories}
loading={memories.isLoading}
saving={memories.isSaving}
deletingId={memories.deletingId}
error={memories.error}
onCreate={memories.create}
onUpdate={memories.update}
onDelete={memories.remove} />API Reference
UseKivaAgentMemoriesArgs
| Option | Type | Default | Description |
|---|---|---|---|
client | KivaAgentMemoriesClient | null | undefined | - | Client with get / post / patch / delete |
enabled | boolean | true | Run the initial fetch |
agentId | string | - | Agent scope of created memories |
projectId | string | null | null | Project scope of created memories |
userId | string | null | null | User scope of created memories |
listParams | Record<string, string | number | boolean | null | undefined> | - | Extra query params for the list call |
UseKivaAgentMemoriesResult
| Field | Type | Description |
|---|---|---|
memories | ReadonlyArray<KivaAgentMemory> | Current list |
isLoading / isSaving | boolean | Fetch / save state |
deletingId | string | null | Memory being deleted |
error | string | null | Last error message |
refresh | () => Promise<void> | Re-fetch GET /v1/ai/memories |
create | (form: KivaAgentMemoryFormState) => Promise<KivaAgentMemory | null> | POST /v1/ai/memories |
update | (memory, form) => Promise<KivaAgentMemory | null> | PATCH /v1/ai/memories/{id} |
remove | (memory) => Promise<boolean> | DELETE /v1/ai/memories/{id} |