feat: polish mindspace decoupling flows

This commit is contained in:
john
2026-07-03 00:34:03 +08:00
parent b258004dad
commit 506a551438
40 changed files with 10037 additions and 2370 deletions
+52
View File
@@ -11,6 +11,8 @@ CREATE TABLE IF NOT EXISTS h5_users (
status ENUM('active', 'suspended', 'disabled') NOT NULL DEFAULT 'active',
plan_type VARCHAR(32) NOT NULL DEFAULT 'free',
workspace_root VARCHAR(512) NOT NULL,
low_balance_gift_eligible TINYINT(1) NOT NULL DEFAULT 0,
low_balance_gift_granted_at BIGINT NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
UNIQUE KEY uq_h5_users_slug (slug),
@@ -121,11 +123,14 @@ CREATE TABLE IF NOT EXISTS h5_upload_sessions (
temporary_storage_key VARCHAR(512) NOT NULL,
checksum CHAR(64) NULL,
completed_asset_id CHAR(36) NULL,
source_session_id VARCHAR(128) NULL,
source_message_id VARCHAR(128) NULL,
status ENUM('reserved', 'uploaded', 'completed', 'cancelled', 'expired', 'failed') NOT NULL DEFAULT 'reserved',
expires_at BIGINT NOT NULL,
created_at BIGINT NOT NULL,
completed_at BIGINT NULL,
KEY idx_h5_upload_user_status (user_id, status, expires_at),
KEY idx_h5_upload_source_session (user_id, source_session_id),
CONSTRAINT fk_h5_upload_user FOREIGN KEY (user_id) REFERENCES h5_users(id) ON DELETE CASCADE,
CONSTRAINT fk_h5_upload_space FOREIGN KEY (space_id) REFERENCES h5_user_spaces(id) ON DELETE CASCADE,
CONSTRAINT fk_h5_upload_category FOREIGN KEY (category_id) REFERENCES h5_space_categories(id) ON DELETE CASCADE
@@ -348,6 +353,7 @@ CREATE TABLE IF NOT EXISTS h5_user_path_grants (
CREATE TABLE IF NOT EXISTS h5_user_sessions (
agent_session_id VARCHAR(128) NOT NULL PRIMARY KEY,
user_id CHAR(36) NOT NULL,
origin ENUM('h5', 'wechat') NOT NULL DEFAULT 'h5',
created_at BIGINT NOT NULL,
KEY idx_h5_user_sessions_user (user_id),
CONSTRAINT fk_h5_session_user FOREIGN KEY (user_id) REFERENCES h5_users(id) ON DELETE CASCADE
@@ -383,6 +389,52 @@ CREATE TABLE IF NOT EXISTS h5_agent_run_events (
CONSTRAINT fk_h5_agent_run_event_run FOREIGN KEY (run_id) REFERENCES h5_agent_runs(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS h5_conversation_packages (
id VARCHAR(64) PRIMARY KEY,
user_id CHAR(36) NOT NULL,
session_id VARCHAR(128) NOT NULL,
title VARCHAR(255) NULL,
status ENUM('active', 'archived', 'deleted') NOT NULL DEFAULT 'active',
storage_prefix VARCHAR(512) NULL,
manifest_asset_id CHAR(36) NULL,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL,
UNIQUE KEY uq_h5_conversation_package_session (user_id, session_id),
KEY idx_h5_conversation_package_user_updated (user_id, updated_at),
CONSTRAINT fk_h5_conversation_package_user FOREIGN KEY (user_id) REFERENCES h5_users(id) ON DELETE CASCADE,
CONSTRAINT fk_h5_conversation_package_manifest FOREIGN KEY (manifest_asset_id) REFERENCES h5_assets(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS h5_conversation_artifacts (
id VARCHAR(64) PRIMARY KEY,
package_id VARCHAR(64) NOT NULL,
asset_id CHAR(36) NULL,
page_id CHAR(36) NULL,
publication_id CHAR(36) NULL,
agent_run_id CHAR(36) NULL,
message_id VARCHAR(128) NULL,
role VARCHAR(32) NULL,
artifact_kind VARCHAR(64) NOT NULL,
display_name VARCHAR(255) NULL,
mime_type VARCHAR(128) NULL,
size_bytes BIGINT NULL,
storage_key VARCHAR(512) NULL,
canonical_url VARCHAR(512) NULL,
sort_order INT NOT NULL DEFAULT 0,
created_at BIGINT NOT NULL,
KEY idx_h5_conversation_artifact_package (package_id, sort_order, created_at),
KEY idx_h5_conversation_artifact_asset (asset_id),
KEY idx_h5_conversation_artifact_page (page_id),
KEY idx_h5_conversation_artifact_publication (publication_id),
KEY idx_h5_conversation_artifact_run (agent_run_id),
KEY idx_h5_conversation_artifact_message (message_id),
CONSTRAINT fk_h5_conversation_artifact_package FOREIGN KEY (package_id) REFERENCES h5_conversation_packages(id) ON DELETE CASCADE,
CONSTRAINT fk_h5_conversation_artifact_asset FOREIGN KEY (asset_id) REFERENCES h5_assets(id) ON DELETE SET NULL,
CONSTRAINT fk_h5_conversation_artifact_page FOREIGN KEY (page_id) REFERENCES h5_page_records(id) ON DELETE SET NULL,
CONSTRAINT fk_h5_conversation_artifact_publication FOREIGN KEY (publication_id) REFERENCES h5_publish_records(id) ON DELETE SET NULL,
CONSTRAINT fk_h5_conversation_artifact_run FOREIGN KEY (agent_run_id) REFERENCES h5_agent_runs(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS h5_session_billing_state (
agent_session_id VARCHAR(128) NOT NULL PRIMARY KEY,
user_id CHAR(36) NOT NULL,