mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-08-18 20:19:18 +08:00
feat(console): add initial console for Cursor BYOK with provider management and LLM call tracking
This commit is contained in:
@@ -1,38 +1,121 @@
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS conversations (
|
||||
CREATE TABLE conversations (
|
||||
conversation_id TEXT PRIMARY KEY,
|
||||
revision INTEGER NOT NULL DEFAULT 0,
|
||||
head_blob_id BLOB,
|
||||
current_revision_id INTEGER,
|
||||
active_run_id TEXT,
|
||||
updated_at_ms INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS messages (
|
||||
CREATE TABLE messages (
|
||||
conversation_id TEXT NOT NULL,
|
||||
message_seq INTEGER NOT NULL,
|
||||
message_id TEXT NOT NULL,
|
||||
role TEXT NOT NULL,
|
||||
origin TEXT NOT NULL,
|
||||
payload_json TEXT NOT NULL,
|
||||
runtime_event_id TEXT,
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
PRIMARY KEY (conversation_id, message_seq),
|
||||
UNIQUE (conversation_id, message_id),
|
||||
UNIQUE (conversation_id, runtime_event_id),
|
||||
PRIMARY KEY (conversation_id, message_id),
|
||||
FOREIGN KEY (conversation_id) REFERENCES conversations(conversation_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS messages_conversation_seq
|
||||
ON messages(conversation_id, message_seq);
|
||||
CREATE UNIQUE INDEX messages_runtime_event
|
||||
ON messages(conversation_id, runtime_event_id)
|
||||
WHERE runtime_event_id IS NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS blobs (
|
||||
blob_id BLOB PRIMARY KEY CHECK(length(blob_id) = 32),
|
||||
data BLOB NOT NULL,
|
||||
CREATE TABLE conversation_revisions (
|
||||
revision_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
conversation_id TEXT NOT NULL,
|
||||
parent_revision_id INTEGER,
|
||||
state_digest BLOB NOT NULL CHECK(length(state_digest) = 32),
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
CHECK(length(data) >= 0)
|
||||
UNIQUE (conversation_id, state_digest),
|
||||
FOREIGN KEY (conversation_id) REFERENCES conversations(conversation_id),
|
||||
FOREIGN KEY (parent_revision_id) REFERENCES conversation_revisions(revision_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS blob_edges (
|
||||
CREATE INDEX conversation_revisions_parent
|
||||
ON conversation_revisions(conversation_id, parent_revision_id);
|
||||
|
||||
CREATE TABLE revision_messages (
|
||||
revision_id INTEGER NOT NULL,
|
||||
ordinal INTEGER NOT NULL,
|
||||
conversation_id TEXT NOT NULL,
|
||||
message_id TEXT NOT NULL,
|
||||
PRIMARY KEY (revision_id, ordinal),
|
||||
UNIQUE (revision_id, message_id),
|
||||
FOREIGN KEY (revision_id) REFERENCES conversation_revisions(revision_id),
|
||||
FOREIGN KEY (conversation_id, message_id) REFERENCES messages(conversation_id, message_id)
|
||||
);
|
||||
|
||||
CREATE TABLE runs (
|
||||
run_id TEXT PRIMARY KEY,
|
||||
conversation_id TEXT NOT NULL,
|
||||
base_revision_id INTEGER NOT NULL,
|
||||
head_revision_id INTEGER NOT NULL,
|
||||
parent_run_id TEXT,
|
||||
parent_tool_call_id TEXT,
|
||||
run_kind TEXT NOT NULL,
|
||||
subagent_kind TEXT,
|
||||
status TEXT NOT NULL,
|
||||
provider_call_index INTEGER NOT NULL DEFAULT -1,
|
||||
turn_usage_json TEXT NOT NULL DEFAULT 'null',
|
||||
failure_category TEXT,
|
||||
failure_summary TEXT,
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
updated_at_ms INTEGER NOT NULL,
|
||||
FOREIGN KEY (conversation_id) REFERENCES conversations(conversation_id),
|
||||
FOREIGN KEY (base_revision_id) REFERENCES conversation_revisions(revision_id),
|
||||
FOREIGN KEY (head_revision_id) REFERENCES conversation_revisions(revision_id)
|
||||
);
|
||||
|
||||
CREATE INDEX runs_conversation_status
|
||||
ON runs(conversation_id, status);
|
||||
|
||||
CREATE TABLE tool_rounds (
|
||||
round_id TEXT PRIMARY KEY,
|
||||
run_id TEXT NOT NULL,
|
||||
base_revision_id INTEGER NOT NULL,
|
||||
assistant_json TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
version INTEGER NOT NULL DEFAULT 0,
|
||||
next_completion_seq INTEGER NOT NULL DEFAULT 0,
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
updated_at_ms INTEGER NOT NULL,
|
||||
FOREIGN KEY (run_id) REFERENCES runs(run_id),
|
||||
FOREIGN KEY (base_revision_id) REFERENCES conversation_revisions(revision_id)
|
||||
);
|
||||
|
||||
CREATE INDEX tool_rounds_run_status
|
||||
ON tool_rounds(run_id, status);
|
||||
|
||||
CREATE TABLE tool_round_calls (
|
||||
round_id TEXT NOT NULL,
|
||||
call_index INTEGER NOT NULL,
|
||||
call_id TEXT NOT NULL,
|
||||
model_call_id TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
arguments_json TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
completion_seq INTEGER,
|
||||
result_content TEXT,
|
||||
result_is_error INTEGER,
|
||||
committed_revision_id INTEGER,
|
||||
completed_at_ms INTEGER,
|
||||
PRIMARY KEY (round_id, call_index),
|
||||
UNIQUE (round_id, call_id),
|
||||
UNIQUE (round_id, completion_seq),
|
||||
FOREIGN KEY (round_id) REFERENCES tool_rounds(round_id),
|
||||
FOREIGN KEY (committed_revision_id) REFERENCES conversation_revisions(revision_id)
|
||||
);
|
||||
|
||||
CREATE TABLE blobs (
|
||||
blob_id BLOB PRIMARY KEY CHECK(length(blob_id) = 32),
|
||||
data BLOB NOT NULL,
|
||||
created_at_ms INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE blob_edges (
|
||||
parent_blob_id BLOB NOT NULL,
|
||||
child_blob_id BLOB NOT NULL,
|
||||
field_name TEXT NOT NULL,
|
||||
@@ -41,53 +124,4 @@ CREATE TABLE IF NOT EXISTS blob_edges (
|
||||
FOREIGN KEY (child_blob_id) REFERENCES blobs(blob_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS blob_edges_child ON blob_edges(child_blob_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS runs (
|
||||
request_id TEXT PRIMARY KEY,
|
||||
run_id TEXT,
|
||||
conversation_id TEXT,
|
||||
revision INTEGER,
|
||||
append_seqno INTEGER NOT NULL DEFAULT -1,
|
||||
status TEXT NOT NULL,
|
||||
provider_call_index INTEGER NOT NULL DEFAULT 0,
|
||||
turn_usage_json TEXT NOT NULL DEFAULT '{}',
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
updated_at_ms INTEGER NOT NULL,
|
||||
FOREIGN KEY (conversation_id) REFERENCES conversations(conversation_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS runs_conversation_status
|
||||
ON runs(conversation_id, status);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS run_tool_results (
|
||||
request_id TEXT NOT NULL,
|
||||
batch_index INTEGER NOT NULL,
|
||||
call_index INTEGER NOT NULL,
|
||||
completion_seq INTEGER NOT NULL,
|
||||
call_id TEXT NOT NULL,
|
||||
output_json TEXT NOT NULL,
|
||||
is_error INTEGER NOT NULL,
|
||||
completed_at_ms INTEGER NOT NULL,
|
||||
PRIMARY KEY (request_id, batch_index, call_index),
|
||||
UNIQUE (request_id, call_id),
|
||||
FOREIGN KEY (request_id) REFERENCES runs(request_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS outbox (
|
||||
outbox_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
request_id TEXT NOT NULL,
|
||||
operation_key TEXT NOT NULL,
|
||||
operation_kind TEXT NOT NULL,
|
||||
payload BLOB NOT NULL,
|
||||
dependency_blob_ids_json TEXT NOT NULL DEFAULT '[]',
|
||||
attempts INTEGER NOT NULL DEFAULT 0,
|
||||
acked_at_ms INTEGER,
|
||||
created_at_ms INTEGER NOT NULL,
|
||||
updated_at_ms INTEGER NOT NULL,
|
||||
UNIQUE(request_id, operation_key),
|
||||
FOREIGN KEY (request_id) REFERENCES runs(request_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS outbox_pending
|
||||
ON outbox(request_id, acked_at_ms, outbox_id);
|
||||
CREATE INDEX blob_edges_child ON blob_edges(child_blob_id);
|
||||
|
||||
Reference in New Issue
Block a user