summaryrefslogtreecommitdiff
path: root/migrations/010_agent_tables.sql
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-28 22:19:28 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-28 22:19:28 -1000
commit05b1930e04ac222d73ffb2f45c1b1febb69f893d (patch)
treebc451d72b5265ff044c4655ed90685c601688b6d /migrations/010_agent_tables.sql
parent058ff7d699f088edb851336928dd3eea2934cc07 (diff)
Add Agent Context API for external agent integration
Phase 1: Authentication and read-only context - POST /agent/auth/request - request access with name + agent_id - GET /agent/auth/poll - poll for approval status - POST /agent/auth/approve|deny - user approval (browser auth required) - GET /agent/context - 7-day timeline context (agent session required) Phase 1.5: Browser-only agent endpoints (HTML pages) - GET /agent/web/request - request page with token - GET /agent/web/status - status page with polling - GET /agent/web/context - context page with timeline data WebSocket notifications: - GET /ws/notifications - push agent requests to browsers - Approval modal with trust indicators and countdown timer Database: - agents table for registered agent tracking - agent_sessions table for pending/active sessions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'migrations/010_agent_tables.sql')
-rw-r--r--migrations/010_agent_tables.sql30
1 files changed, 30 insertions, 0 deletions
diff --git a/migrations/010_agent_tables.sql b/migrations/010_agent_tables.sql
new file mode 100644
index 0000000..23e1c2c
--- /dev/null
+++ b/migrations/010_agent_tables.sql
@@ -0,0 +1,30 @@
+-- Agent Context API tables
+-- Migration: 010_agent_tables.sql
+
+-- Registered/approved agents (identity binding)
+CREATE TABLE IF NOT EXISTS agents (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ name TEXT NOT NULL,
+ agent_id TEXT NOT NULL UNIQUE, -- UUID from agent
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ last_seen DATETIME,
+ trusted BOOLEAN DEFAULT 1 -- can be revoked
+);
+
+-- Pending access requests and active sessions
+CREATE TABLE IF NOT EXISTS agent_sessions (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ request_token TEXT NOT NULL UNIQUE,
+ agent_name TEXT NOT NULL,
+ agent_id TEXT NOT NULL,
+ status TEXT DEFAULT 'pending', -- pending, approved, denied, expired
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
+ expires_at DATETIME NOT NULL, -- request expires after 5 min
+ session_token TEXT, -- populated on approval
+ session_expires_at DATETIME -- session TTL (1 hour)
+);
+
+CREATE INDEX IF NOT EXISTS idx_agent_sessions_request ON agent_sessions(request_token);
+CREATE INDEX IF NOT EXISTS idx_agent_sessions_session ON agent_sessions(session_token);
+CREATE INDEX IF NOT EXISTS idx_agent_sessions_status ON agent_sessions(status);
+CREATE INDEX IF NOT EXISTS idx_agents_agent_id ON agents(agent_id);