molecule-core/platform/migrations/009_activity_logs.sql
Hongming Wang 24fec62d7f initial commit — Molecule AI platform
Forked clean from public hackathon repo (Starfire-AgentTeam, BSL 1.1)
with full rebrand to Molecule AI under github.com/Molecule-AI/molecule-monorepo.

Brand: Starfire → Molecule AI.
Slug: starfire / agent-molecule → molecule.
Env vars: STARFIRE_* → MOLECULE_*.
Go module: github.com/agent-molecule/platform → github.com/Molecule-AI/molecule-monorepo/platform.
Python packages: starfire_plugin → molecule_plugin, starfire_agent → molecule_agent.
DB: agentmolecule → molecule.

History truncated; see public repo for prior commits and contributor
attribution. Verified green: go test -race ./... (platform), pytest
(workspace-template 1129 + sdk 132), vitest (canvas 352), build (mcp).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 11:55:37 -07:00

25 lines
1.6 KiB
SQL

-- Activity logs: comprehensive logging for A2A communication, task updates, agent actions, and errors.
CREATE TABLE IF NOT EXISTS activity_logs (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
workspace_id UUID NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,
activity_type TEXT NOT NULL, -- 'a2a_send', 'a2a_receive', 'task_update', 'agent_log', 'error'
source_id UUID, -- workspace that initiated the action
target_id UUID, -- workspace that received the action (for A2A)
method TEXT, -- A2A method name (e.g. 'message/send') or task action
summary TEXT, -- Human-readable summary
request_body JSONB, -- Request payload (for A2A)
response_body JSONB, -- Response payload (for A2A)
duration_ms INTEGER, -- How long the operation took
status TEXT DEFAULT 'ok', -- 'ok', 'error', 'timeout'
error_detail TEXT, -- Error message if status != 'ok'
created_at TIMESTAMPTZ DEFAULT now()
);
-- Composite index covers (workspace_id) prefix and (workspace_id, activity_type) lookups.
-- Separate idx_activity_created_at kept for global retention cleanup queries.
CREATE INDEX IF NOT EXISTS idx_activity_ws_type_time ON activity_logs(workspace_id, activity_type, created_at DESC);
CREATE INDEX IF NOT EXISTS idx_activity_created_at ON activity_logs(created_at);
-- Add current_task to workspaces for showing what the agent is currently working on.
ALTER TABLE workspaces ADD COLUMN IF NOT EXISTS current_task TEXT;