Skip to Content
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-memories

A 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

OptionTypeDefaultDescription
clientKivaAgentMemoriesClient | null | undefined-Client with get / post / patch / delete
enabledbooleantrueRun the initial fetch
agentIdstring-Agent scope of created memories
projectIdstring | nullnullProject scope of created memories
userIdstring | nullnullUser scope of created memories
listParamsRecord<string, string | number | boolean | null | undefined>-Extra query params for the list call

UseKivaAgentMemoriesResult

FieldTypeDescription
memoriesReadonlyArray<KivaAgentMemory>Current list
isLoading / isSavingbooleanFetch / save state
deletingIdstring | nullMemory being deleted
errorstring | nullLast 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}

On this page