Persist and retrieve local chat sessions and messages using SQLite with stable conversation IDs and queryable metadata. Use when storing chat context for a local-first desktop AI assistant.
{
"conversationId": "string",
"operation": "create|append|list|get|search|export",
"messages": [
{
"messageId": "string",
"role": "user|assistant|system",
"content": "string",
"createdAt": "ISO-8601 string",
"tags": ["optional", "labels"]
}
],
"query": {
"limit": 50,
"timeRange": { "from": "ISO|null", "to": "ISO|null" },
"tagFilters": ["optional"],
"includeCitations": true
},
"requestContext": { "requestId": "string" }
}
写入/读出都使用统一结构(示例):
{
"ok": true,
"code": "SUCCESS|null",
"data": { "conversation": {}, "messages": [], "total": 0 }
}
失败:
{
"ok": false,
"code": "<error-code>",
"message": "human-readable",
"retryable": true,
"nextAction": "what to do"
}
conversationId、messageId)。conversationId、createdAt、tags、必要的 sourceDocId)创建索引。create:当 conversationId 不存在时创建(或由 orchestrator 决定)。append:追加消息并返回成功与写入计数。get:按会话 ID 取指定消息范围。search:按时间/标签过滤取候选上下文。NOT_FOUND(在失败策略里写清楚)。DB_UNAVAILABLE(retryable=true)。NOT_FOUND(retryable=false)。INVALID_PARAMS(retryable=false)。ai-response-orchestrator / markdown-summarizer 完成)。