-- Migration 007: A2A Tasks Schema -- Creates a2a_tasks table for Agent-to-Agent protocol task persistence -- Replaces in-memory HashMap with durable storage -- A2A Tasks table DEFINE TABLE a2a_tasks SCHEMAFULL; DEFINE FIELD id ON TABLE a2a_tasks TYPE record; DEFINE FIELD task_id ON TABLE a2a_tasks TYPE string ASSERT $value != NONE; DEFINE FIELD state ON TABLE a2a_tasks TYPE string ASSERT $value INSIDE ["waiting", "working", "completed", "failed"] DEFAULT "waiting"; DEFINE FIELD message ON TABLE a2a_tasks TYPE option; DEFINE FIELD result ON TABLE a2a_tasks TYPE option; DEFINE FIELD error ON TABLE a2a_tasks TYPE option; DEFINE FIELD metadata ON TABLE a2a_tasks TYPE option; DEFINE FIELD created_at ON TABLE a2a_tasks TYPE datetime DEFAULT time::now(); DEFINE FIELD updated_at ON TABLE a2a_tasks TYPE datetime DEFAULT time::now() VALUE time::now(); -- Indexes for efficient queries DEFINE INDEX idx_a2a_tasks_task_id ON TABLE a2a_tasks COLUMNS task_id UNIQUE; DEFINE INDEX idx_a2a_tasks_state ON TABLE a2a_tasks COLUMNS state; DEFINE INDEX idx_a2a_tasks_created_at ON TABLE a2a_tasks COLUMNS created_at; DEFINE INDEX idx_a2a_tasks_state_created ON TABLE a2a_tasks COLUMNS state, created_at;