Initial import of streamline

This commit is contained in:
2026-11-16 17:26:44 -08:00
commit 8e4aec1855
1221 changed files with 274256 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
-- 开放平台 / Skill 的使用痕迹(见 control-server/src/openapi_usage.ts、管理台「开放平台 → 使用情况」)。
--
-- 1. tasks.created_channel:建单入口。'cli' = 命令行 / Skill 以本人身份建的单;NULL = 面板等网页入口
-- (开放平台 Key 建的单仍按 created_via_key_id 非空认,不重复记)。纯新增可空列,PG 上是元数据操作。
-- 2. openapi_cli_sessions 补 created_at / last_used_at:授权了多少台电脑、最近还在不在用。
-- 0052 上线后发出的会话没有 created_at,按 NULL 处理(统计里算「时间未知」)。
-- 3. openapi_usage_events:每次开放平台 / 命令行调用一行,只记谁、哪个接口、结果码、哪个 Agent,
-- 不记请求体。保留 180 天,由写入方顺手清理。
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS created_channel text;
CREATE INDEX IF NOT EXISTS tasks_created_channel_created
ON tasks (created_channel, created_at) WHERE created_channel IS NOT NULL;
-- GET /api/cli/v1/tasks 按本人列单。
CREATE INDEX IF NOT EXISTS tasks_creator_email_created ON tasks (creator_email, created_at);
ALTER TABLE openapi_cli_sessions ADD COLUMN IF NOT EXISTS created_at bigint;
ALTER TABLE openapi_cli_sessions ADD COLUMN IF NOT EXISTS last_used_at bigint;
CREATE TABLE IF NOT EXISTS openapi_usage_events (
id text PRIMARY KEY,
at bigint NOT NULL,
-- 'openapi'(API Key)| 'cli'(命令行 / Skill 会话)
channel text NOT NULL,
-- openapi:Key id;cli:登录邮箱
actor text NOT NULL,
-- 'POST /openapi/v1/tasks' 这样的「方法 + 路由模板」,不带具体 id
route text NOT NULL,
status bigint NOT NULL,
-- 客户端自报的 Agent(claude-code / codex / cursor / terminal),只有命令行会带
agent text,
client_version text,
task_id text
);
CREATE INDEX IF NOT EXISTS openapi_usage_events_at ON openapi_usage_events (at);
CREATE INDEX IF NOT EXISTS openapi_usage_events_actor ON openapi_usage_events (channel, actor, at);