Files
Dumitru Picalau 657dc07831 feat(ai): assistant overhaul: tool registry, server-kept chats, search index, security, page tools, web search, saved chats, images, permissions, derivation NOT (schema 10), OpenAI Responses API (#64)
Phases 2 to 8 of the AI assistant overhaul plus fixes from real-model chats: one tool registry with native tool calls, server-kept chat logs with prompt caching, an FTS5 library index with opt-in meaning search, keys bound to their address and a guard on every AI route, page tools and opt-in web search, saved chats with streaming, Try again, a context meter and compaction, chat images, delete/category/tag permissions with Undo, constraint and test cards, card fixes and previews, questions with answers to click, the derivation NOT toggle (schema v10, community catalog 0021), request fixes for the newest Claude models, and OpenAI's Responses API. Review fixes: Try again clears the old turn's fixes and answers, category Undo removes only what it made, a failed delete rolls back in order, not_matches patterns are checked, busy chats refuse a second request, and chat search ignores stored JSON.
2026-10-14 14:56:12 +02:00

35 lines
1.3 KiB
SQL

-- AI assistant chats, kept on the server so a follow-up sees everything
-- the model saw: its tool calls, their results and the proposal cards.
--
-- ai_chats.snapshot the library overview frozen when the chat started, so
-- the prompt prefix stays the same and model servers can
-- reuse what they already read
-- ai_chats.meta JSON: tool format, offered tools, proposal status,
-- the library fingerprint at the last message, and how
-- much of the log is shortened or left out
-- ai_chat_messages the turn log, one JSON entry per row in order: user
-- messages as sent, model steps, tool results, nudges
--
-- Local-only, never exported or published.
-- NOTE: the migration runner splits on the semicolon char, so comments
-- must avoid it.
CREATE TABLE IF NOT EXISTS ai_chats (
id TEXT PRIMARY KEY,
title TEXT NOT NULL DEFAULT '',
snapshot TEXT NOT NULL DEFAULT '',
meta TEXT NOT NULL DEFAULT '{}',
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_ai_chats_updated_at ON ai_chats(updated_at DESC);
CREATE TABLE IF NOT EXISTS ai_chat_messages (
chat_id TEXT NOT NULL,
seq INTEGER NOT NULL,
body TEXT NOT NULL,
created_at TEXT NOT NULL,
PRIMARY KEY (chat_id, seq)
);