Files
agentik/storage-sqlite
subochev d74af621d8
ci / JVM build + tests (push) Successful in 6m13s
refactor(storage): drop StorageBundle + legacy EventStore, add HttpEventStore
- Remove legacy pw.binom.agentik.messageStore.events.EventStore (EventRecord,
  EventType) and all three impls (in-memory, sqlite, ksqlite) + tests + .sq
- Drop :storage-bundle module entirely; ChatAgent / ChatConversation /
  ConversationLoop / DebugRoutes now take stores individually
  (conversationStore, messageStore, workingMemoryStore, reflectionStore,
  eventStore) instead of StorageBundle
- Delete server endpoints /events/replay and /conversations/{id}/events/replay;
  Route.agentikAgent no longer takes eventStore param
- Add :client/HttpEventStore implementing :event-store/EventStore over HTTP:
  events() -> GET /events/all, agentEvents() -> GET /events,
  conversationEvents(convId) -> GET /conversations/{id}/events;
  exposed via AgentClient.eventStore
- :event-store: add macosX64/macosArm64/linuxArm64 targets to match :client KMP
- :working-memory-api: drop api dep on :message-store-api (no longer needed)
- :storage-{inmemory,sqlite,ksqlite}: drop deps on :storage-bundle
2026-09-20 18:06:46 +03:00
..

:storage-sqlite — SQLite реализация :storage-core (JVM-only)

Что что это

Production persistence для :standalone на SQLDelight:

  • messages — append-only журнал с conversation_id, created_at.
  • working_memory — rolling buffer последних 100 entries, типы в JSON (UserMessage / AssistantMessage / ToolExchange / SystemPrompt).
  • conversations — метаданные (id, title, model, timestamps).
  • reflections — произвольные заметки ("I notice you often prefer short replies").
  • Промпт хранителя (@mem0) индексирован отдельно для быстрого доступа.

Решает: стабильная, локальная, нулевая-настройка БД. Подходит и для desktop-продакшена, и для Android, и для тестов (через Testcontainers).

Где используется

  • :standalone подключает по умолчанию (storage.db = путь из AGENTIK_DB_PATH).

Как подключить

jvmMain.dependencies {
    implementation("pw.binom.agentik:storage-sqlite:0.1.0")
    implementation("pw.binom.agentik:storage-core:0.1.0")
}

val storage = SqliteStorageSystem.open(Path("agentik.db"))
val messages: MessageStore = storage.messages

Версии

gradle/libs.versions.toml → [versions] agentik-storage-sqlite.

Зависит от app.cash.sqldelight:sqlite-driver:2.1.0 (через gradle/libs.versions.toml).

Тесты

./gradlew :storage-sqlite:jvmTest

Покрывают: миграции (через migrations/ каталог и SQLDelight *.sqm), round-trip, race-conditions (concurrent append), paged flow.

Что в схеме (упрощённо)

CREATE TABLE messages (
    id TEXT PRIMARY KEY,
    conversation_id TEXT NOT NULL,
    created_at TEXT NOT NULL,  -- ISO Instant
    kind TEXT NOT NULL,        -- 'user', 'assistant', 'tool_call', 'tool_result'
    body_json TEXT NOT NULL
);
CREATE INDEX idx_messages_conv_time ON messages(conversation_id, created_at);

CREATE TABLE working_memory (
    conversation_id TEXT NOT NULL,
    entry_id TEXT PRIMARY KEY,
    created_at TEXT NOT NULL,
    kind TEXT NOT NULL,
    body_json TEXT NOT NULL
);

Полная схема + миграции — в src/jvmMain/sqldelight/.

Текущий статус

Используется продакшеном. Миграции 1.0+.