feat: 0.2.27 - 抽离数据库基础设施模块
- 新增 ias-db crate,集中管理 PostgreSQL 连接池和 SQLx 迁移
- 迁移 ias-service/migrations 到 ias-db/migrations
- ias-main 改用 ias_db::connect_db(),ias-service 只接 PgPool
- 新增操作日志 HTTP 查询接口 (GET /v1/logs, GET /v1/logs/{id})
- 新增操作日志 Web 前端页面,支持按级别/模块/关键词筛选
- 消息队列关键节点增加操作日志写入
- ias-mail 新增 mark_remote_message_seen,IMAP 已读同步
- 工作流配置加载改为文件级容错 (load_configs_with_warnings)
- ias-context 工具调用说明更新为 query_api_docs + call_http_api
- 新增高德地图地理编码 HTTP 能力配置
模块版本: ias-db 0.1.0, ias-ai 0.1.14, ias-context 0.1.6, ias-http 0.1.15, ias-mail 0.1.16, ias-service 0.1.25, ias-main 0.2.27
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
ALTER TABLE ias_context_messages
|
||||
ADD COLUMN IF NOT EXISTS raw_message JSONB;
|
||||
|
||||
ALTER TABLE ias_context_messages
|
||||
ADD COLUMN IF NOT EXISTS external_message_id VARCHAR(255);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_ias_context_messages_external_unique
|
||||
ON ias_context_messages(session_id, role, external_message_id)
|
||||
WHERE external_message_id IS NOT NULL;
|
||||
|
||||
WITH ranked AS (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY scope_key
|
||||
ORDER BY started_at DESC, id DESC
|
||||
) AS rank
|
||||
FROM ias_context_sessions
|
||||
WHERE ended_at IS NULL
|
||||
)
|
||||
UPDATE ias_context_sessions AS session
|
||||
SET
|
||||
ended_at = last_message_at,
|
||||
end_reason = 'active_session_deduplicated',
|
||||
summary = COALESCE(summary, '创建活跃会话唯一约束时自动结束的重复活跃上下文。')
|
||||
FROM ranked
|
||||
WHERE session.id = ranked.id
|
||||
AND ranked.rank > 1;
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_ias_context_sessions_one_active
|
||||
ON ias_context_sessions(scope_key)
|
||||
WHERE ended_at IS NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ias_tool_call_instructions (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
scope_key VARCHAR(768) NOT NULL UNIQUE,
|
||||
channel VARCHAR(64) NOT NULL,
|
||||
account_id VARCHAR(255) NOT NULL,
|
||||
from_user_id VARCHAR(255) NOT NULL,
|
||||
context_label TEXT,
|
||||
content TEXT NOT NULL DEFAULT '',
|
||||
last_reason TEXT,
|
||||
updated_by VARCHAR(64) NOT NULL DEFAULT 'ai',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_ias_tool_call_instructions_scope_updated
|
||||
ON ias_tool_call_instructions(scope_key, updated_at DESC);
|
||||
|
||||
INSERT INTO ias_tool_call_instructions (
|
||||
scope_key,
|
||||
channel,
|
||||
account_id,
|
||||
from_user_id,
|
||||
context_label,
|
||||
content,
|
||||
last_reason,
|
||||
updated_by,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
SELECT
|
||||
scope_key,
|
||||
channel,
|
||||
account_id,
|
||||
from_user_id,
|
||||
context_label,
|
||||
content,
|
||||
last_reason,
|
||||
updated_by,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM ias_additional_system_prompts
|
||||
WHERE content <> ''
|
||||
ON CONFLICT (scope_key) DO NOTHING;
|
||||
Reference in New Issue
Block a user