multica/server/migrations/013_runtime_usage.up.sql
Jiayuan 903fbee55d feat(runtimes): add Runtimes tab with usage tracking and connection test
Add a new "Runtimes" sidebar tab to manage local agent runtimes with three
main capabilities: runtime status overview, token usage tracking (reading
Claude Code and Codex CLI local JSONL logs via daemon), and an interactive
connection test that sends a ping through the daemon to verify end-to-end
agent CLI connectivity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 18:28:36 +08:00

16 lines
671 B
SQL

CREATE TABLE runtime_usage (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
runtime_id UUID NOT NULL REFERENCES agent_runtime(id) ON DELETE CASCADE,
date DATE NOT NULL,
provider TEXT NOT NULL,
model TEXT NOT NULL DEFAULT '',
input_tokens BIGINT NOT NULL DEFAULT 0,
output_tokens BIGINT NOT NULL DEFAULT 0,
cache_read_tokens BIGINT NOT NULL DEFAULT 0,
cache_write_tokens BIGINT NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
UNIQUE (runtime_id, date, provider, model)
);
CREATE INDEX idx_runtime_usage_runtime_date ON runtime_usage(runtime_id, date DESC);