Checkpoint: Phase 7 complete: Orchestrator Agent добавлен в /agents с меткой CROWN/SYSTEM, кнопками Configure и Open Chat. /chat читает конфиг оркестратора из БД (модель, промпт, инструменты). AgentDetailModal поддерживает isOrchestrator. 24 теста пройдены.
This commit is contained in:
@@ -40,7 +40,7 @@ async function main() {
|
||||
CONSTRAINT \`agentMetrics_requestId_unique\` UNIQUE(\`requestId\`)
|
||||
)`,
|
||||
|
||||
// agents
|
||||
// agents — full schema with isSystem and isOrchestrator
|
||||
`CREATE TABLE IF NOT EXISTS \`agents\` (
|
||||
\`id\` int AUTO_INCREMENT NOT NULL,
|
||||
\`userId\` int NOT NULL,
|
||||
@@ -60,6 +60,8 @@ async function main() {
|
||||
\`maxRequestsPerHour\` int DEFAULT 100,
|
||||
\`isActive\` boolean DEFAULT true,
|
||||
\`isPublic\` boolean DEFAULT false,
|
||||
\`isSystem\` boolean DEFAULT false,
|
||||
\`isOrchestrator\` boolean DEFAULT false,
|
||||
\`tags\` json,
|
||||
\`metadata\` json,
|
||||
\`createdAt\` timestamp NOT NULL DEFAULT (now()),
|
||||
@@ -101,6 +103,19 @@ async function main() {
|
||||
CONSTRAINT \`browserSessions_sessionId_unique\` UNIQUE(\`sessionId\`)
|
||||
)`,
|
||||
|
||||
// agentHistory — conversation history per agent
|
||||
`CREATE TABLE IF NOT EXISTS \`agentHistory\` (
|
||||
\`id\` int AUTO_INCREMENT NOT NULL,
|
||||
\`agentId\` int NOT NULL,
|
||||
\`sessionId\` varchar(64),
|
||||
\`role\` enum('user','assistant','system','tool') NOT NULL,
|
||||
\`content\` text NOT NULL,
|
||||
\`toolCalls\` json,
|
||||
\`metadata\` json,
|
||||
\`createdAt\` timestamp NOT NULL DEFAULT (now()),
|
||||
CONSTRAINT \`agentHistory_id\` PRIMARY KEY(\`id\`)
|
||||
)`,
|
||||
|
||||
// Indexes
|
||||
`CREATE INDEX IF NOT EXISTS \`agentAccessControl_agentId_tool_idx\` ON \`agentAccessControl\` (\`agentId\`,\`tool\`)`,
|
||||
`CREATE INDEX IF NOT EXISTS \`agentMetrics_agentId_idx\` ON \`agentMetrics\` (\`agentId\`)`,
|
||||
@@ -108,6 +123,7 @@ async function main() {
|
||||
`CREATE INDEX IF NOT EXISTS \`agents_userId_idx\` ON \`agents\` (\`userId\`)`,
|
||||
`CREATE INDEX IF NOT EXISTS \`agents_model_idx\` ON \`agents\` (\`model\`)`,
|
||||
`CREATE INDEX IF NOT EXISTS \`browserSessions_agentId_idx\` ON \`browserSessions\` (\`agentId\`)`,
|
||||
`CREATE INDEX IF NOT EXISTS \`agentHistory_agentId_idx\` ON \`agentHistory\` (\`agentId\`)`,
|
||||
];
|
||||
|
||||
for (const stmt of statements) {
|
||||
@@ -118,12 +134,36 @@ async function main() {
|
||||
} catch (e) {
|
||||
if (e.code === 'ER_DUP_KEYNAME' || e.message.includes('Duplicate key name')) {
|
||||
console.log('⚠ Index already exists (ok)');
|
||||
} else if (e.message.includes('already exists')) {
|
||||
console.log('⚠ Already exists (ok)');
|
||||
} else {
|
||||
console.error('✗ Error:', e.message.slice(0, 120));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ALTER TABLE to add missing columns to existing tables
|
||||
const alterStatements = [
|
||||
`ALTER TABLE \`agents\` ADD COLUMN IF NOT EXISTS \`isSystem\` boolean DEFAULT false`,
|
||||
`ALTER TABLE \`agents\` ADD COLUMN IF NOT EXISTS \`isOrchestrator\` boolean DEFAULT false`,
|
||||
];
|
||||
|
||||
console.log('\n--- Applying ALTER TABLE migrations ---');
|
||||
for (const stmt of alterStatements) {
|
||||
try {
|
||||
await conn.query(stmt);
|
||||
const col = stmt.match(/ADD COLUMN.*?`(\w+)`/)?.[1] || 'column';
|
||||
console.log('✓ Added column:', col);
|
||||
} catch (e) {
|
||||
if (e.message.includes('Duplicate column name') || e.message.includes('already exists')) {
|
||||
const col = stmt.match(/ADD COLUMN.*?`(\w+)`/)?.[1] || 'column';
|
||||
console.log('⚠ Column already exists:', col, '(ok)');
|
||||
} else {
|
||||
console.error('✗ ALTER error:', e.message.slice(0, 120));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [tables] = await conn.query('SHOW TABLES');
|
||||
console.log('\n✅ All tables:', tables.map(t => Object.values(t)[0]).join(', '));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user