feat: add wechat publish recovery and conversation memory

This commit is contained in:
john
2026-06-29 06:59:37 +08:00
parent ea19ffb5fa
commit e80831ad4f
12 changed files with 2308 additions and 38 deletions
+40
View File
@@ -1032,3 +1032,43 @@ CREATE TABLE IF NOT EXISTS h5_experience (
KEY idx_h5_experience_scope_updated (scope, updated_at),
FULLTEXT KEY ftx_h5_experience (title, body)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS h5_conversation_messages (
id CHAR(64) PRIMARY KEY,
user_id CHAR(36) NOT NULL,
agent_session_id VARCHAR(128) NOT NULL,
message_key VARCHAR(128) NOT NULL,
sequence_no INT NOT NULL DEFAULT 0,
role VARCHAR(32) NOT NULL,
text MEDIUMTEXT NOT NULL,
raw_json LONGTEXT NULL,
analyzed_at BIGINT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
UNIQUE KEY uq_h5_conversation_message (agent_session_id, message_key),
KEY idx_h5_conversation_user_created (user_id, created_at),
KEY idx_h5_conversation_user_analyzed (user_id, analyzed_at),
CONSTRAINT fk_h5_conversation_user FOREIGN KEY (user_id) REFERENCES h5_users(id) ON DELETE CASCADE,
CONSTRAINT fk_h5_conversation_session FOREIGN KEY (agent_session_id) REFERENCES h5_user_sessions(agent_session_id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS h5_user_memory_items (
id CHAR(64) PRIMARY KEY,
user_id CHAR(36) NOT NULL,
label ENUM('preference', 'habit', 'interest', 'goal', 'fact', 'experience', 'knowledge') NOT NULL DEFAULT 'fact',
memory_hash CHAR(64) NOT NULL,
memory_text TEXT NOT NULL,
evidence_message_id CHAR(64) NULL,
source_session_id VARCHAR(128) NULL,
confidence DECIMAL(4,3) NOT NULL DEFAULT 0.600,
status ENUM('active', 'archived', 'deleted') NOT NULL DEFAULT 'active',
raw_json JSON NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
UNIQUE KEY uq_h5_user_memory_hash (user_id, memory_hash),
KEY idx_h5_user_memory_user_label (user_id, label, updated_at),
KEY idx_h5_user_memory_session (source_session_id),
CONSTRAINT fk_h5_user_memory_user FOREIGN KEY (user_id) REFERENCES h5_users(id) ON DELETE CASCADE,
CONSTRAINT fk_h5_user_memory_evidence FOREIGN KEY (evidence_message_id) REFERENCES h5_conversation_messages(id) ON DELETE SET NULL,
CONSTRAINT fk_h5_user_memory_session FOREIGN KEY (source_session_id) REFERENCES h5_user_sessions(agent_session_id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;