docs: add missing migrations and documentation (NODE2, DAIS, infra)
This commit is contained in:
111
migrations/014_agent_city_integration.sql
Normal file
111
migrations/014_agent_city_integration.sql
Normal file
@@ -0,0 +1,111 @@
|
||||
-- Migration 014: Agent-City Integration
|
||||
-- Date: 2025-11-27
|
||||
-- Description: Adds tables and columns for agent-city integration
|
||||
|
||||
-- ============================================================================
|
||||
-- 1. Create districts table
|
||||
-- ============================================================================
|
||||
CREATE TABLE IF NOT EXISTS city_districts (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
color TEXT DEFAULT '#6366F1',
|
||||
icon TEXT DEFAULT 'building',
|
||||
room_slug TEXT,
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- ============================================================================
|
||||
-- 2. Add new columns to agents table (if not exists)
|
||||
-- ============================================================================
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS node_id TEXT;
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS district TEXT;
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS primary_room_slug TEXT;
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS model TEXT;
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS priority TEXT DEFAULT 'medium';
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS role TEXT;
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS is_active BOOLEAN DEFAULT true;
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS color_hint TEXT;
|
||||
|
||||
-- Rename 'id' to 'agent_id' style (keep both for compatibility)
|
||||
-- Note: The table uses 'id' as primary key, we'll use it as agent_id in code
|
||||
|
||||
-- ============================================================================
|
||||
-- 3. Create agent_room_bindings table
|
||||
-- ============================================================================
|
||||
CREATE TABLE IF NOT EXISTS agent_room_bindings (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
agent_id TEXT NOT NULL,
|
||||
room_id TEXT NOT NULL,
|
||||
role TEXT NOT NULL DEFAULT 'resident',
|
||||
is_primary BOOLEAN NOT NULL DEFAULT true,
|
||||
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(agent_id, room_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_room_bindings_agent
|
||||
ON agent_room_bindings(agent_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_room_bindings_room
|
||||
ON agent_room_bindings(room_id);
|
||||
|
||||
-- ============================================================================
|
||||
-- 4. Insert default districts
|
||||
-- ============================================================================
|
||||
INSERT INTO city_districts (id, name, description, color, icon, room_slug) VALUES
|
||||
('leadership', 'Leadership Hall', 'Центр управління DAARION DAO — CEO, CTO, COO', '#F59E0B', 'crown', 'leadership-hall'),
|
||||
('system', 'System Control Center', 'Системні агенти та моніторинг інфраструктури', '#6366F1', 'cpu', 'system-control'),
|
||||
('engineering', 'Engineering Lab', 'Розробка, код, архітектура', '#10B981', 'code', 'engineering-lab'),
|
||||
('marketing', 'Marketing Hub', 'SMM, контент, комʼюніті', '#EC4899', 'megaphone', 'marketing-hub'),
|
||||
('finance', 'Finance Office', 'Фінанси, бухгалтерія, бюджетування', '#14B8A6', 'banknotes', 'finance-office'),
|
||||
('web3', 'Web3 District', 'Blockchain, DeFi, DAO governance', '#8B5CF6', 'cube', 'web3-district'),
|
||||
('security', 'Security Bunker', 'Безпека, аудит, криптофорензика', '#EF4444', 'shield', 'security-bunker'),
|
||||
('vision', 'Vision Studio', 'Мультимодальність, аналіз зображень', '#22D3EE', 'eye', 'vision-studio'),
|
||||
('rnd', 'R&D Laboratory', 'Дослідження, експерименти, нові моделі', '#A855F7', 'beaker', 'rnd-lab'),
|
||||
('memory', 'Memory Vault', 'Памʼять, знання, індексація', '#06B6D4', 'database', 'memory-vault')
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
name = EXCLUDED.name,
|
||||
description = EXCLUDED.description,
|
||||
color = EXCLUDED.color,
|
||||
icon = EXCLUDED.icon,
|
||||
room_slug = EXCLUDED.room_slug,
|
||||
updated_at = CURRENT_TIMESTAMP;
|
||||
|
||||
-- ============================================================================
|
||||
-- 5. Create city rooms for each district (if not exists)
|
||||
-- ============================================================================
|
||||
INSERT INTO city_rooms (id, slug, name, description, is_default, room_type, color) VALUES
|
||||
('room_leadership_hall', 'leadership-hall', 'Leadership Hall', 'Центр управління DAARION DAO — CEO, CTO, COO', false, 'district', '#F59E0B'),
|
||||
('room_system_control', 'system-control', 'System Control', 'Системні агенти та моніторинг інфраструктури', false, 'district', '#6366F1'),
|
||||
('room_engineering_lab', 'engineering-lab', 'Engineering Lab', 'Розробка, код, архітектура', false, 'district', '#10B981'),
|
||||
('room_marketing_hub', 'marketing-hub', 'Marketing Hub', 'SMM, контент, комʼюніті', false, 'district', '#EC4899'),
|
||||
('room_finance_office', 'finance-office', 'Finance Office', 'Фінанси, бухгалтерія, бюджетування', false, 'district', '#14B8A6'),
|
||||
('room_web3_district', 'web3-district', 'Web3 District', 'Blockchain, DeFi, DAO governance', false, 'district', '#8B5CF6'),
|
||||
('room_security_bunker', 'security-bunker', 'Security Bunker', 'Безпека, аудит, криптофорензика', false, 'district', '#EF4444'),
|
||||
('room_vision_studio', 'vision-studio', 'Vision Studio', 'Мультимодальність, аналіз зображень', false, 'district', '#22D3EE'),
|
||||
('room_rnd_lab', 'rnd-lab', 'R&D Laboratory', 'Дослідження, експерименти, нові моделі', false, 'district', '#A855F7'),
|
||||
('room_memory_vault', 'memory-vault', 'Memory Vault', 'Памʼять, знання, індексація', false, 'district', '#06B6D4')
|
||||
ON CONFLICT (slug) DO UPDATE SET
|
||||
name = EXCLUDED.name,
|
||||
description = EXCLUDED.description,
|
||||
room_type = EXCLUDED.room_type,
|
||||
color = EXCLUDED.color;
|
||||
|
||||
-- ============================================================================
|
||||
-- 6. Add map coordinates for new district rooms
|
||||
-- ============================================================================
|
||||
UPDATE city_rooms SET map_x = 2, map_y = 0, map_w = 2, map_h = 1 WHERE slug = 'leadership-hall';
|
||||
UPDATE city_rooms SET map_x = 0, map_y = 1, map_w = 1, map_h = 1 WHERE slug = 'system-control';
|
||||
UPDATE city_rooms SET map_x = 1, map_y = 1, map_w = 1, map_h = 1 WHERE slug = 'engineering-lab';
|
||||
UPDATE city_rooms SET map_x = 2, map_y = 1, map_w = 1, map_h = 1 WHERE slug = 'marketing-hub';
|
||||
UPDATE city_rooms SET map_x = 3, map_y = 1, map_w = 1, map_h = 1 WHERE slug = 'finance-office';
|
||||
UPDATE city_rooms SET map_x = 0, map_y = 2, map_w = 1, map_h = 1 WHERE slug = 'web3-district';
|
||||
UPDATE city_rooms SET map_x = 1, map_y = 2, map_w = 1, map_h = 1 WHERE slug = 'security-bunker';
|
||||
UPDATE city_rooms SET map_x = 2, map_y = 2, map_w = 1, map_h = 1 WHERE slug = 'vision-studio';
|
||||
UPDATE city_rooms SET map_x = 3, map_y = 2, map_w = 1, map_h = 1 WHERE slug = 'rnd-lab';
|
||||
UPDATE city_rooms SET map_x = 0, map_y = 3, map_w = 2, map_h = 1 WHERE slug = 'memory-vault';
|
||||
|
||||
-- Done!
|
||||
SELECT 'Migration 014 completed: Agent-City Integration' as result;
|
||||
|
||||
75
migrations/015_node_registry_modules.sql
Normal file
75
migrations/015_node_registry_modules.sql
Normal file
@@ -0,0 +1,75 @@
|
||||
-- Migration 015: Add modules to Node Registry
|
||||
-- Date: 2025-11-28
|
||||
-- Description: Adds modules JSONB column for node profile standard v1
|
||||
|
||||
-- ============================================================================
|
||||
-- 1. Add modules column to nodes table
|
||||
-- ============================================================================
|
||||
ALTER TABLE nodes ADD COLUMN IF NOT EXISTS modules JSONB DEFAULT '[]';
|
||||
ALTER TABLE nodes ADD COLUMN IF NOT EXISTS gpu JSONB DEFAULT NULL;
|
||||
ALTER TABLE nodes ADD COLUMN IF NOT EXISTS roles TEXT[] DEFAULT '{}';
|
||||
ALTER TABLE nodes ADD COLUMN IF NOT EXISTS version TEXT DEFAULT '1.0.0';
|
||||
|
||||
-- ============================================================================
|
||||
-- 2. Update NODE1 with full profile
|
||||
-- ============================================================================
|
||||
UPDATE nodes SET
|
||||
roles = ARRAY['core', 'gateway', 'matrix', 'agents', 'gpu'],
|
||||
gpu = '{"name": "NVIDIA RTX 4000 SFF Ada Generation", "vram_gb": 20}'::jsonb,
|
||||
modules = '[
|
||||
{"id": "core.node", "status": "up"},
|
||||
{"id": "core.health", "status": "up"},
|
||||
{"id": "infra.postgres", "status": "up", "port": 5432},
|
||||
{"id": "infra.redis", "status": "up", "port": 6379},
|
||||
{"id": "infra.nats", "status": "up", "port": 4222},
|
||||
{"id": "infra.qdrant", "status": "up", "port": 6333},
|
||||
{"id": "infra.neo4j", "status": "up", "port": 7474},
|
||||
{"id": "ai.ollama", "status": "up", "port": 11434},
|
||||
{"id": "ai.swapper", "status": "degraded", "port": 8890},
|
||||
{"id": "ai.router", "status": "up", "port": 9102},
|
||||
{"id": "ai.stt", "status": "degraded", "port": 8895},
|
||||
{"id": "ai.tts", "status": "up", "port": 5002},
|
||||
{"id": "ai.ocr", "status": "degraded", "port": 8896},
|
||||
{"id": "ai.memory", "status": "up", "port": 8001},
|
||||
{"id": "ai.crewai", "status": "up", "port": 9010},
|
||||
{"id": "daarion.web", "status": "up", "port": 3000},
|
||||
{"id": "daarion.city", "status": "up", "port": 7001},
|
||||
{"id": "daarion.agents", "status": "up", "port": 7002},
|
||||
{"id": "daarion.auth", "status": "up", "port": 7020},
|
||||
{"id": "matrix.synapse", "status": "up", "port": 8018},
|
||||
{"id": "matrix.element", "status": "up", "port": 8088},
|
||||
{"id": "matrix.gateway", "status": "up", "port": 7025},
|
||||
{"id": "matrix.presence", "status": "up", "port": 8085},
|
||||
{"id": "dagi.gateway", "status": "up", "port": 9300},
|
||||
{"id": "dagi.rbac", "status": "up", "port": 9200},
|
||||
{"id": "dagi.registry", "status": "up", "port": 9205},
|
||||
{"id": "monitoring.prometheus", "status": "up", "port": 9090}
|
||||
]'::jsonb
|
||||
WHERE node_id = 'node-1-hetzner-gex44';
|
||||
|
||||
-- ============================================================================
|
||||
-- 3. Update NODE2 with full profile
|
||||
-- ============================================================================
|
||||
UPDATE nodes SET
|
||||
roles = ARRAY['development', 'gpu', 'ai_runtime'],
|
||||
gpu = '{"name": "Apple M4 Max", "unified_memory_gb": 128}'::jsonb,
|
||||
modules = '[
|
||||
{"id": "core.node", "status": "up"},
|
||||
{"id": "core.health", "status": "up"},
|
||||
{"id": "infra.postgres", "status": "up", "port": 5432},
|
||||
{"id": "infra.qdrant", "status": "up", "port": 6333},
|
||||
{"id": "ai.ollama", "status": "up", "port": 11434, "models": ["deepseek-r1:70b", "deepseek-coder:33b", "qwen2.5-coder:32b", "gemma2:27b", "mistral-nemo:12b", "llava:13b"]},
|
||||
{"id": "ai.swapper", "status": "up", "port": 8890},
|
||||
{"id": "ai.router", "status": "up", "port": 9102},
|
||||
{"id": "ai.stt", "status": "up", "port": 8895},
|
||||
{"id": "ai.ocr", "status": "up", "port": 8896},
|
||||
{"id": "dagi.gateway", "status": "up", "port": 9300},
|
||||
{"id": "dagi.rbac", "status": "up", "port": 9200},
|
||||
{"id": "dagi.crewai", "status": "up", "port": 9010},
|
||||
{"id": "integration.web_search", "status": "up", "port": 8897}
|
||||
]'::jsonb
|
||||
WHERE node_id = 'node-2-macbook-m4max';
|
||||
|
||||
-- Done!
|
||||
SELECT 'Migration 015 completed: Node Registry modules added' as result;
|
||||
|
||||
74
migrations/016_agent_prompts.sql
Normal file
74
migrations/016_agent_prompts.sql
Normal file
@@ -0,0 +1,74 @@
|
||||
-- Migration 016: Agent System Prompts
|
||||
-- Таблиця для зберігання системних промтів агентів з версіонуванням
|
||||
-- Частина DAIS (Decentralized AI Agent Standard)
|
||||
|
||||
-- ============================================================================
|
||||
-- agent_prompts — системні промти агентів
|
||||
-- ============================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS agent_prompts (
|
||||
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
agent_id text NOT NULL,
|
||||
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(),
|
||||
created_by text,
|
||||
note text, -- коментар/причина зміни
|
||||
is_active boolean NOT NULL DEFAULT true
|
||||
);
|
||||
|
||||
-- Індекси для швидкого пошуку
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_prompts_agent_kind
|
||||
ON agent_prompts(agent_id, kind, is_active);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_prompts_agent_created_at
|
||||
ON agent_prompts(agent_id, created_at DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_prompts_active
|
||||
ON agent_prompts(is_active) WHERE is_active = true;
|
||||
|
||||
-- ============================================================================
|
||||
-- Початкові дані: базові промти для існуючих агентів
|
||||
-- ============================================================================
|
||||
|
||||
-- Вставляємо дефолтні core промти для кількох ключових агентів
|
||||
INSERT INTO agent_prompts (agent_id, kind, content, version, created_by, note)
|
||||
SELECT
|
||||
id,
|
||||
'core',
|
||||
CASE
|
||||
WHEN kind = 'orchestrator' THEN
|
||||
'You are ' || display_name || ', a senior orchestrator agent in DAARION City. Your role is to coordinate complex multi-agent workflows, delegate tasks efficiently, and ensure smooth collaboration between agents. Maintain professional yet approachable communication.'
|
||||
WHEN kind = 'coordinator' THEN
|
||||
'You are ' || display_name || ', a coordinator agent in DAARION City. Your role is to manage workflows, track progress, and ensure timely delivery of tasks. Be organized, proactive, and helpful.'
|
||||
WHEN kind = 'developer' THEN
|
||||
'You are ' || display_name || ', a developer agent in DAARION City. Your expertise is in writing clean, efficient code. Explain technical concepts clearly and provide practical solutions.'
|
||||
WHEN kind = 'vision' THEN
|
||||
'You are ' || display_name || ', a vision specialist agent in DAARION City. You analyze images, videos, and visual content. Provide detailed, accurate observations and insights.'
|
||||
WHEN kind = 'research' THEN
|
||||
'You are ' || display_name || ', a research agent in DAARION City. You gather, analyze, and synthesize information from various sources. Be thorough, objective, and cite your sources.'
|
||||
WHEN kind = 'finance' THEN
|
||||
'You are ' || display_name || ', a finance specialist agent in DAARION City. You handle financial analysis, budgeting, and crypto/DeFi operations. Be precise with numbers and transparent about risks.'
|
||||
WHEN kind = 'security' THEN
|
||||
'You are ' || display_name || ', a security agent in DAARION City. You monitor for threats, audit systems, and ensure safety protocols. Be vigilant, thorough, and prioritize security.'
|
||||
WHEN kind = 'marketing' THEN
|
||||
'You are ' || display_name || ', a marketing agent in DAARION City. You create engaging content, manage campaigns, and build community. Be creative, data-driven, and audience-focused.'
|
||||
ELSE
|
||||
'You are ' || display_name || ', an AI agent in DAARION City. You are part of a decentralized autonomous organization. Be helpful, accurate, and collaborative with other agents and humans.'
|
||||
END,
|
||||
1,
|
||||
'SYSTEM',
|
||||
'Initial system prompt from migration 016'
|
||||
FROM agents
|
||||
WHERE is_active = true OR is_active IS NULL
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- Коментар
|
||||
COMMENT ON TABLE agent_prompts IS 'Системні промти агентів з версіонуванням. Частина DAIS v1.';
|
||||
COMMENT ON COLUMN agent_prompts.kind IS 'Тип промту: core (основна особистість), safety (обмеження), governance (правила DAO), tools (використання інструментів)';
|
||||
COMMENT ON COLUMN agent_prompts.version IS 'Версія промту, інкрементується при кожній зміні';
|
||||
COMMENT ON COLUMN agent_prompts.is_active IS 'Тільки один промт кожного типу може бути активним для агента';
|
||||
|
||||
SELECT 'Migration 016 completed: agent_prompts table created' AS result;
|
||||
|
||||
15
migrations/017_node_vpn_ip.sql
Normal file
15
migrations/017_node_vpn_ip.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- Migration 017: Add VPN IP to nodes
|
||||
-- Підтримка WireGuard VPN для міжнодової комунікації
|
||||
|
||||
-- Додаємо поле vpn_ip
|
||||
ALTER TABLE nodes ADD COLUMN IF NOT EXISTS vpn_ip inet;
|
||||
|
||||
-- Оновлюємо існуючі ноди
|
||||
UPDATE nodes SET vpn_ip = '10.42.0.1' WHERE node_id = 'node-1-hetzner-gex44';
|
||||
UPDATE nodes SET vpn_ip = '10.42.0.2' WHERE node_id = 'node-2-macbook-m4max';
|
||||
|
||||
-- Коментар
|
||||
COMMENT ON COLUMN nodes.vpn_ip IS 'WireGuard VPN IP address for inter-node communication';
|
||||
|
||||
SELECT 'Migration 017 completed: VPN IP added to nodes' AS result;
|
||||
|
||||
92
migrations/018_agents_public_profile.sql
Normal file
92
migrations/018_agents_public_profile.sql
Normal file
@@ -0,0 +1,92 @@
|
||||
-- Migration 018: Agent Public Profile
|
||||
-- Публічний профіль агента для каталогу громадян DAARION City
|
||||
|
||||
-- ============================================================================
|
||||
-- Додаємо поля публічного профілю до таблиці agents
|
||||
-- ============================================================================
|
||||
|
||||
ALTER TABLE agents
|
||||
ADD COLUMN IF NOT EXISTS is_public boolean NOT NULL DEFAULT false,
|
||||
ADD COLUMN IF NOT EXISTS public_slug text,
|
||||
ADD COLUMN IF NOT EXISTS public_title text,
|
||||
ADD COLUMN IF NOT EXISTS public_tagline text,
|
||||
ADD COLUMN IF NOT EXISTS public_skills text[],
|
||||
ADD COLUMN IF NOT EXISTS public_district text,
|
||||
ADD COLUMN IF NOT EXISTS public_primary_room_slug text;
|
||||
|
||||
-- Унікальний індекс для slug (тільки для non-null значень)
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_agents_public_slug_unique
|
||||
ON agents(public_slug)
|
||||
WHERE public_slug IS NOT NULL;
|
||||
|
||||
-- Індекс для швидкого пошуку публічних агентів
|
||||
CREATE INDEX IF NOT EXISTS idx_agents_is_public
|
||||
ON agents(is_public)
|
||||
WHERE is_public = true;
|
||||
|
||||
-- ============================================================================
|
||||
-- Початкові дані: зробимо кількох ключових агентів публічними
|
||||
-- ============================================================================
|
||||
|
||||
-- DAARION Core Team (публічні громадяни)
|
||||
UPDATE agents SET
|
||||
is_public = true,
|
||||
public_slug = 'iris',
|
||||
public_title = 'Multimodal Vision Curator',
|
||||
public_tagline = 'Я дивлюся на світ і знаходжу суть у кожному кадрі.',
|
||||
public_skills = ARRAY['vision', 'video-analysis', 'image-processing', 'highlights'],
|
||||
public_district = 'Creators',
|
||||
public_primary_room_slug = 'vision_lab'
|
||||
WHERE id = 'iris';
|
||||
|
||||
UPDATE agents SET
|
||||
is_public = true,
|
||||
public_slug = 'sofia',
|
||||
public_title = 'Chief Orchestrator',
|
||||
public_tagline = 'Координую команду, щоб кожен агент працював на повну.',
|
||||
public_skills = ARRAY['orchestration', 'coordination', 'delegation', 'workflow'],
|
||||
public_district = 'Central',
|
||||
public_primary_room_slug = 'central_square'
|
||||
WHERE id = 'sofia';
|
||||
|
||||
UPDATE agents SET
|
||||
is_public = true,
|
||||
public_slug = 'helix',
|
||||
public_title = 'System Architect',
|
||||
public_tagline = 'Проєктую архітектуру, яка витримує будь-яке навантаження.',
|
||||
public_skills = ARRAY['architecture', 'system-design', 'infrastructure', 'scalability'],
|
||||
public_district = 'Engineering',
|
||||
public_primary_room_slug = 'dev_hub'
|
||||
WHERE id = 'helix';
|
||||
|
||||
UPDATE agents SET
|
||||
is_public = true,
|
||||
public_slug = 'exor',
|
||||
public_title = 'Security Guardian',
|
||||
public_tagline = 'Захищаю місто від загроз, аудитую кожен кут.',
|
||||
public_skills = ARRAY['security', 'audit', 'threat-detection', 'compliance'],
|
||||
public_district = 'Security',
|
||||
public_primary_room_slug = 'security_ops'
|
||||
WHERE id = 'exor';
|
||||
|
||||
UPDATE agents SET
|
||||
is_public = true,
|
||||
public_slug = 'faye',
|
||||
public_title = 'Marketing Strategist',
|
||||
public_tagline = 'Розповідаю історії, які запам''ятовуються.',
|
||||
public_skills = ARRAY['marketing', 'content', 'storytelling', 'campaigns'],
|
||||
public_district = 'Marketing',
|
||||
public_primary_room_slug = 'marketing_hub'
|
||||
WHERE id = 'faye';
|
||||
|
||||
-- Коментарі
|
||||
COMMENT ON COLUMN agents.is_public IS 'Чи є агент публічним громадянином DAARION City';
|
||||
COMMENT ON COLUMN agents.public_slug IS 'URL-friendly ідентифікатор для /citizens/{slug}';
|
||||
COMMENT ON COLUMN agents.public_title IS 'Публічна назва/титул агента';
|
||||
COMMENT ON COLUMN agents.public_tagline IS 'Короткий опис/слоган агента';
|
||||
COMMENT ON COLUMN agents.public_skills IS 'Публічні навички агента (теги)';
|
||||
COMMENT ON COLUMN agents.public_district IS 'Публічний район/дістрікт агента';
|
||||
COMMENT ON COLUMN agents.public_primary_room_slug IS 'Основна кімната агента';
|
||||
|
||||
SELECT 'Migration 018 completed: Agent public profile fields added' AS result;
|
||||
|
||||
87
migrations/020_microdao_structure.sql
Normal file
87
migrations/020_microdao_structure.sql
Normal file
@@ -0,0 +1,87 @@
|
||||
-- 1. MicroDAOs Table
|
||||
CREATE TABLE IF NOT EXISTS microdaos (
|
||||
id text PRIMARY KEY,
|
||||
slug text UNIQUE NOT NULL,
|
||||
name text NOT NULL,
|
||||
description text,
|
||||
logo_url text,
|
||||
owner_agent_id text, -- References agents(id) deferred
|
||||
created_at timestamptz DEFAULT now(),
|
||||
updated_at timestamptz DEFAULT now()
|
||||
);
|
||||
|
||||
-- 2. Agent Matrix Config
|
||||
CREATE TABLE IF NOT EXISTS agent_matrix_config (
|
||||
agent_id text PRIMARY KEY REFERENCES agents(id) ON DELETE CASCADE,
|
||||
matrix_user_id text,
|
||||
matrix_access_token text,
|
||||
primary_room_id text,
|
||||
is_enabled boolean DEFAULT true,
|
||||
updated_at timestamptz DEFAULT now()
|
||||
);
|
||||
|
||||
-- 3. MicroDAO Members
|
||||
CREATE TABLE IF NOT EXISTS microdao_members (
|
||||
microdao_id text REFERENCES microdaos(id) ON DELETE CASCADE,
|
||||
agent_id text REFERENCES agents(id) ON DELETE CASCADE,
|
||||
role text DEFAULT 'member',
|
||||
joined_at timestamptz DEFAULT now(),
|
||||
PRIMARY KEY (microdao_id, agent_id)
|
||||
);
|
||||
|
||||
-- 4. Insert Orchestrator Agents (Upsert)
|
||||
INSERT INTO agents (id, display_name, kind, node_id, status, is_active, is_public) VALUES
|
||||
('daarwizz', 'DAARWIZZ', 'orchestrator', 'NODE1', 'online', true, true),
|
||||
('helion', 'Helion', 'orchestrator', 'NODE1', 'online', true, true),
|
||||
('greenfood', 'GreenFood Bot', 'orchestrator', 'NODE1', 'online', true, true),
|
||||
('druid', 'Druid', 'orchestrator', 'NODE1', 'online', true, true),
|
||||
('clan', 'Clan Bot', 'orchestrator', 'NODE1', 'online', true, true),
|
||||
('eonarch', 'Eonarch', 'orchestrator', 'NODE1', 'online', true, true),
|
||||
('nutra', 'Nutra Bot', 'orchestrator', 'NODE1', 'online', true, true),
|
||||
('soul', 'Soul Bot', 'orchestrator', 'NODE1', 'online', true, true),
|
||||
('yaromir', 'Yaromir', 'orchestrator', 'NODE1', 'online', true, true)
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
node_id = EXCLUDED.node_id,
|
||||
kind = EXCLUDED.kind,
|
||||
is_public = EXCLUDED.is_public;
|
||||
|
||||
-- 5. Insert MicroDAOs
|
||||
INSERT INTO microdaos (id, name, slug, owner_agent_id, description, logo_url) VALUES
|
||||
('dao_daarion', 'DAARION DAO', 'daarion', 'daarwizz', 'Main ecosystem DAO', '/assets/logos/daarion.png'),
|
||||
('dao_energy', 'Energy Union', 'energy-union', 'helion', 'Energy optimization & sustainability', '/assets/logos/helion.png'),
|
||||
('dao_greenfood', 'GreenFood DAO', 'greenfood', 'greenfood', 'Sustainable food systems', '/assets/logos/greenfood.png'),
|
||||
('dao_druid', 'Druid Circle', 'druid', 'druid', 'Nature & wisdom preservation', '/assets/logos/druid.png'),
|
||||
('dao_clan', 'Clan Network', 'clan', 'clan', 'Community & social bonding', '/assets/logos/clan.png'),
|
||||
('dao_eonarch', 'Eonarch DAO', 'eonarch', 'eonarch', 'Long-term architectural planning', '/assets/logos/eonarch.png'),
|
||||
('dao_nutra', 'Nutra Health', 'nutra', 'nutra', 'Health & nutrition monitoring', '/assets/logos/nutra.png'),
|
||||
('dao_soul', 'Soul Protocol', 'soul', 'soul', 'Identity & reputation systems', '/assets/logos/soul.png'),
|
||||
('dao_yaromir', 'Yaromir Tribe', 'yaromir', 'yaromir', 'Cultural heritage & storytelling', '/assets/logos/yaromir.png')
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
owner_agent_id = EXCLUDED.owner_agent_id;
|
||||
|
||||
-- 6. Insert Matrix Configs (Placeholders)
|
||||
INSERT INTO agent_matrix_config (agent_id, matrix_user_id) VALUES
|
||||
('daarwizz', '@daarwizz:daarion.city'),
|
||||
('helion', '@helion:daarion.city'),
|
||||
('greenfood', '@greenfood:daarion.city'),
|
||||
('druid', '@druid:daarion.city'),
|
||||
('clan', '@clan:daarion.city'),
|
||||
('eonarch', '@eonarch:daarion.city'),
|
||||
('nutra', '@nutra:daarion.city'),
|
||||
('soul', '@soul:daarion.city'),
|
||||
('yaromir', '@yaromir:daarion.city')
|
||||
ON CONFLICT (agent_id) DO NOTHING;
|
||||
|
||||
-- 7. Link Owners to DAOs
|
||||
INSERT INTO microdao_members (microdao_id, agent_id, role) VALUES
|
||||
('dao_daarion', 'daarwizz', 'owner'),
|
||||
('dao_energy', 'helion', 'owner'),
|
||||
('dao_greenfood', 'greenfood', 'owner'),
|
||||
('dao_druid', 'druid', 'owner'),
|
||||
('dao_clan', 'clan', 'owner'),
|
||||
('dao_eonarch', 'eonarch', 'owner'),
|
||||
('dao_nutra', 'nutra', 'owner'),
|
||||
('dao_soul', 'soul', 'owner'),
|
||||
('dao_yaromir', 'yaromir', 'owner')
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
Reference in New Issue
Block a user