feat: Agent System Prompts MVP (B) - database, backend API, and frontend integration

This commit is contained in:
Apple
2025-11-30 14:04:48 -08:00
parent bca81dc719
commit 1830109a95
10 changed files with 624 additions and 173 deletions

View File

@@ -0,0 +1,23 @@
-- Create agent_prompts table
CREATE TABLE IF NOT EXISTS agent_prompts (
id text PRIMARY KEY DEFAULT ('ap_' || substr(md5(random()::text), 1, 12)),
agent_id text NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
kind text NOT NULL CHECK (kind IN ('core', 'safety', 'governance', 'tools')),
content text NOT NULL,
version integer NOT NULL DEFAULT 1,
created_at timestamptz NOT NULL DEFAULT NOW(),
updated_at timestamptz NOT NULL DEFAULT NOW(),
created_by text,
note text,
is_active boolean NOT NULL DEFAULT true
);
-- Create indexes
CREATE UNIQUE INDEX IF NOT EXISTS ux_agent_prompts_agent_kind_version ON agent_prompts(agent_id, kind, version);
CREATE INDEX IF NOT EXISTS ix_agent_prompts_agent_id ON agent_prompts(agent_id);
CREATE INDEX IF NOT EXISTS ix_agent_prompts_agent_kind_active ON agent_prompts(agent_id, kind) WHERE is_active = true;
-- Grant permissions (adjust based on your RBAC)
GRANT ALL ON agent_prompts TO postgres;
-- GRANT SELECT, INSERT, UPDATE ON agent_prompts TO app_user; -- Uncomment if needed