diff --git a/agents-manage-api/package.json b/agents-manage-api/package.json index 97a8d3383..61b428877 100644 --- a/agents-manage-api/package.json +++ b/agents-manage-api/package.json @@ -20,12 +20,16 @@ "typecheck:watch": "tsc --noEmit --watch" }, "dependencies": { + "@ai-sdk/anthropic": "^1.1.9", + "@ai-sdk/google": "^1.0.22", + "@ai-sdk/openai": "^1.0.19", "@hono/node-server": "^1.14.3", "@hono/swagger-ui": "^0.5.1", "@hono/zod-openapi": "^1.0.2", "@inkeep/agents-core": "workspace:^", "@nangohq/node": "^0.69.5", "@nangohq/types": "^0.69.5", + "ai": "^4.1.11", "dotenv": "^17.2.1", "drizzle-orm": "^0.44.4", "hono": "^4.10.3", diff --git a/agents-manage-api/scripts/README.md b/agents-manage-api/scripts/README.md new file mode 100644 index 000000000..0921ec4d5 --- /dev/null +++ b/agents-manage-api/scripts/README.md @@ -0,0 +1,112 @@ +# Evaluation Scripts + +This directory contains utility scripts for running and testing evaluations. + +## Available Scripts + +### `run-conversation-evaluation.ts` + +A script that demonstrates how to run conversation evaluations on an existing conversation. + +**What it does:** + +1. Connects to your existing database (no migrations needed) +2. Verifies an existing conversation exists in the database +3. Creates an evaluator using the `createEvaluator` API +4. Creates a conversation evaluation config using `createConversationEvaluationConfig` API +5. Links the evaluator to the config using `linkEvaluatorToConfig` API +6. Runs the evaluation using the EvaluationService +7. Displays the results with scores and reasoning + +**Configuration:** + +Edit the script to set your conversation ID and tenant/project: + +```typescript +const EXISTING_CONVERSATION_ID = 'ukegsy5b0e02tc9fsbr0p'; +const TENANT_ID = 'inkeep'; // Update with your tenant ID +const PROJECT_ID = 'default'; // Update with your project ID +``` + +**How to run:** + +```bash +cd agents-manage-api +pnpm tsx scripts/run-conversation-evaluation.ts +``` + +**Environment Requirements:** + +The script uses the environment variables from your `.env` file. Make sure you have: + +- `ANTHROPIC_API_KEY` - Required for running evaluations with Claude +- `DB_FILE_NAME` - SQLite database file path (optional, uses in-memory by default) + +**Output:** + +The script will output: +- Tenant, project, and conversation IDs created +- Evaluation results including: + - Status (done/failed) + - Reasoning from the LLM + - Structured evaluation scores: + - Response Quality (1-5) + - Professionalism (1-5) + - Resolution Progress (1-5) + - Empathy (1-5) + - Overall Score + - Strengths identified + - Areas for improvement + +**Example Output:** + +``` +================================================================================ +EVALUATION RESULTS +================================================================================ + +Tenant ID: test-tenant-abc123 +Project ID: default +Conversation ID: conv-xyz789 +Evaluation Config ID: eval-config-def456 + +Total Results: 1 +Duration: 3245ms + +-------------------------------------------------------------------------------- +Result ID: eval-result-001 +Status: done + +Reasoning: +The agent provided helpful, professional responses with good empathy... + +Evaluation Scores: +{ + "responseQuality": 4, + "professionalism": 5, + "resolution": 4, + "empathy": 4, + "overallScore": 4.25, + "strengths": [ + "Polite and professional tone", + "Proactive in providing tracking information" + ], + "areasForImprovement": [ + "Could have offered additional assistance" + ] +} +================================================================================ +``` + +## Adding New Scripts + +When adding new evaluation scripts: + +1. Use TypeScript for type safety +2. Import from `@inkeep/agents-core` for database operations +3. Use the logger for structured logging +4. Include comprehensive error handling +5. Provide clear output formatting +6. Document environment requirements +7. Add usage instructions to this README + diff --git a/agents-manage-api/scripts/run-conversation-evaluation.ts b/agents-manage-api/scripts/run-conversation-evaluation.ts new file mode 100644 index 000000000..4e0582001 --- /dev/null +++ b/agents-manage-api/scripts/run-conversation-evaluation.ts @@ -0,0 +1,357 @@ +#!/usr/bin/env tsx + +import type { DatabaseClient } from '@inkeep/agents-core'; +import { + createConversationEvaluationConfig, + createEvaluator, + generateId, + getConversation, + getLogger, + linkEvaluatorToConfig, + loadEnvironmentFiles, +} from '@inkeep/agents-core'; +import dbClient from '../src/data/db/dbClient'; +import { runConversationEvaluation } from '../src/services/EvaluationService'; + +loadEnvironmentFiles(); + +const logger = getLogger('EvaluationScript'); + +// Configuration +const EXISTING_CONVERSATION_ID = 'cfbtzwukwufv3bqgo0gh6'; +const TENANT_ID = 'default'; // Update this with your tenant ID +const PROJECT_ID = 'test-agents'; // Update this with your project ID + +interface ScriptResult { + success: boolean; + tenantId: string; + projectId: string; + conversationId: string; + evaluationConfigId?: string; + results?: unknown; + error?: string; +} + +async function verifyConversation(db: DatabaseClient) { + logger.info( + { conversationId: EXISTING_CONVERSATION_ID, tenantId: TENANT_ID, projectId: PROJECT_ID }, + 'Verifying conversation exists' + ); + + // First, let's check what conversations exist in the database + const { conversations } = await import('@inkeep/agents-core'); + const { eq } = await import('drizzle-orm'); + + // Check for the specific conversation + const specificConversation = await db + .select() + .from(conversations) + .where(eq(conversations.id, EXISTING_CONVERSATION_ID)) + .limit(1); + + // Also list some recent conversations to help debug + const recentConversations = await db + .select({ + id: conversations.id, + tenantId: conversations.tenantId, + projectId: conversations.projectId, + title: conversations.title, + createdAt: conversations.createdAt, + }) + .from(conversations) + .limit(10); + + logger.info( + { + conversationId: EXISTING_CONVERSATION_ID, + foundSpecificConversation: specificConversation.map((c: any) => ({ + id: c.id, + tenantId: c.tenantId, + projectId: c.projectId, + })), + recentConversations: recentConversations.map((c) => ({ + id: c.id, + tenantId: c.tenantId, + projectId: c.projectId, + title: c.title, + })), + totalFound: recentConversations.length, + }, + 'Database conversations' + ); + + const conversation = await getConversation(db)({ + scopes: { tenantId: TENANT_ID, projectId: PROJECT_ID }, + conversationId: EXISTING_CONVERSATION_ID, + }); + + if (!conversation) { + throw new Error( + `Conversation ${EXISTING_CONVERSATION_ID} not found for tenant ${TENANT_ID} and project ${PROJECT_ID}. Check the foundConversations in logs above to see actual tenant/project IDs.` + ); + } + + logger.info( + { + conversationId: conversation.id, + activeSubAgentId: conversation.activeSubAgentId, + title: conversation.title, + }, + 'Conversation found' + ); + + return conversation; +} + +async function setupEvaluator(db: DatabaseClient, tenantId: string) { + const evaluatorId = `evaluator-${generateId()}`; + + logger.info({ evaluatorId, tenantId }, 'Creating test evaluator'); + + const evaluator = await createEvaluator(db)({ + tenantId, + id: evaluatorId, + name: 'Customer Satisfaction Evaluator', + description: 'Evaluates the quality of customer support interactions', + prompt: `You are evaluating a customer support conversation. +Assess the following aspects: +1. Response Quality: Were the agent's responses helpful and accurate? +2. Professionalism: Was the agent polite and professional? +3. Resolution: Did the conversation move towards resolving the customer's issue? +4. Empathy: Did the agent show understanding of the customer's concern? + +Rate each aspect on a scale of 1-5, where 5 is excellent and 1 is poor. +Provide an overall score as the average of all aspects.`, + schema: { + type: 'object', + properties: { + responseQuality: { + type: 'number', + description: 'Quality of responses (1-5)', + minimum: 1, + maximum: 5, + }, + professionalism: { + type: 'number', + description: 'Professionalism level (1-5)', + minimum: 1, + maximum: 5, + }, + resolution: { + type: 'number', + description: 'Progress towards resolution (1-5)', + minimum: 1, + maximum: 5, + }, + empathy: { + type: 'number', + description: 'Empathy shown (1-5)', + minimum: 1, + maximum: 5, + }, + overallScore: { + type: 'number', + description: 'Overall score (average of all aspects)', + minimum: 1, + maximum: 5, + }, + strengths: { + type: 'array', + items: { type: 'string' }, + description: 'Key strengths identified', + }, + areasForImprovement: { + type: 'array', + items: { type: 'string' }, + description: 'Areas that could be improved', + }, + }, + required: [ + 'responseQuality', + 'professionalism', + 'resolution', + 'empathy', + 'overallScore', + 'strengths', + 'areasForImprovement', + ], + }, + modelConfig: { + model: 'claude-sonnet-4-20250514', + providerOptions: { + temperature: 0.3, + maxTokens: 2048, + }, + }, + }); + + logger.info({ evaluatorId: evaluator.id }, 'Created evaluator'); + + return evaluator.id; +} + +async function setupEvaluationConfig( + db: DatabaseClient, + tenantId: string, + projectId: string, + evaluatorId: string, + conversationId: string +) { + const configId = `eval-config-${generateId()}`; + + logger.info({ configId, tenantId, conversationId }, 'Creating conversation evaluation config'); + + const config = await createConversationEvaluationConfig(db)({ + tenantId, + id: configId, + name: 'Support Quality Evaluation', + description: 'Evaluates specific customer support conversation', + isActive: true, + conversationFilter: { + projectIds: [projectId], + conversationIds: [conversationId], + }, + sampleRate: 1.0, + modelConfig: null, + }); + + // Link the evaluator to the config + await linkEvaluatorToConfig(db)({ + tenantId, + conversationEvaluationConfigId: config.id, + evaluatorId, + }); + + logger.info( + { configId: config.id, evaluatorId }, + 'Created evaluation config and linked evaluator' + ); + + return config.id; +} + +async function main(): Promise { + const startTime = Date.now(); + + try { + logger.info({}, 'Starting conversation evaluation script'); + + // Log database connection info + logger.info( + { + DB_FILE_NAME: process.env.DB_FILE_NAME, + TURSO_DATABASE_URL: process.env.TURSO_DATABASE_URL ? 'SET' : 'NOT SET', + ENVIRONMENT: process.env.ENVIRONMENT, + }, + 'Database configuration' + ); + + const db = dbClient; + + // Verify the existing conversation exists + await verifyConversation(db); + + // Create evaluator and evaluation config + const evaluatorId = await setupEvaluator(db, TENANT_ID); + const evaluationConfigId = await setupEvaluationConfig( + db, + TENANT_ID, + PROJECT_ID, + evaluatorId, + EXISTING_CONVERSATION_ID + ); + + logger.info( + { + conversationEvaluationConfigId: evaluationConfigId, + tenantId: TENANT_ID, + conversationId: EXISTING_CONVERSATION_ID, + }, + 'Running conversation evaluation' + ); + + const results = await runConversationEvaluation(db)({ + scopes: { tenantId: TENANT_ID }, + conversationEvaluationConfigId: evaluationConfigId, + }); + + const duration = Date.now() - startTime; + + logger.info( + { + resultCount: results.length, + durationMs: duration, + results: results.map((r) => ({ + id: r.id, + status: r.status, + reasoning: r.reasoning, + metadata: r.metadata, + })), + }, + 'Evaluation completed successfully' + ); + + console.log('\n' + '='.repeat(80)); + console.log('EVALUATION RESULTS'); + console.log('='.repeat(80)); + console.log(`\nTenant ID: ${TENANT_ID}`); + console.log(`Project ID: ${PROJECT_ID}`); + console.log(`Conversation ID: ${EXISTING_CONVERSATION_ID}`); + console.log(`Evaluation Config ID: ${evaluationConfigId}`); + console.log(`\nTotal Results: ${results.length}`); + console.log(`Duration: ${duration}ms`); + + for (const result of results) { + console.log('\n' + '-'.repeat(80)); + console.log(`Result ID: ${result.id}`); + console.log(`Status: ${result.status}`); + console.log(`\nReasoning:\n${result.reasoning}`); + console.log(`\nEvaluation Scores:`); + console.log(JSON.stringify(result.metadata, null, 2)); + } + + console.log('\n' + '='.repeat(80) + '\n'); + + return { + success: true, + tenantId: TENANT_ID, + projectId: PROJECT_ID, + conversationId: EXISTING_CONVERSATION_ID, + evaluationConfigId, + results: results.map((r) => ({ + id: r.id, + status: r.status, + reasoning: r.reasoning, + metadata: r.metadata, + })), + }; + } catch (error) { + const duration = Date.now() - startTime; + logger.error({ error, durationMs: duration }, 'Evaluation script failed'); + console.error('\n❌ Evaluation failed:', error); + + return { + success: false, + tenantId: TENANT_ID, + projectId: PROJECT_ID, + conversationId: EXISTING_CONVERSATION_ID, + error: error instanceof Error ? error.message : 'Unknown error', + }; + } +} + +// Run the script +main() + .then((result) => { + if (result.success) { + console.log('\n✅ Evaluation script completed successfully!'); + process.exit(0); + } else { + console.error('\n❌ Evaluation script failed!'); + process.exit(1); + } + }) + .catch((error) => { + console.error('\n❌ Fatal error:', error); + process.exit(1); + }); diff --git a/agents-manage-api/src/env.ts b/agents-manage-api/src/env.ts index b82e603d1..aba3f64a8 100644 --- a/agents-manage-api/src/env.ts +++ b/agents-manage-api/src/env.ts @@ -9,6 +9,7 @@ const envSchema = z.object({ ENVIRONMENT: z.enum(['development', 'production', 'pentest', 'test']).optional(), AGENTS_MANAGE_API_URL: z.string().optional().default('http://localhost:3002'), AGENTS_RUN_API_URL: z.string().optional().default('http://localhost:3003'), + AGENTS_MANAGE_UI_URL: z.string().optional().default('http://localhost:3000'), DB_FILE_NAME: z.string().optional(), TURSO_DATABASE_URL: z.string().optional(), TURSO_AUTH_TOKEN: z.string().optional(), diff --git a/agents-manage-api/src/routes/evaluations.ts b/agents-manage-api/src/routes/evaluations.ts new file mode 100644 index 000000000..d2b8c8071 --- /dev/null +++ b/agents-manage-api/src/routes/evaluations.ts @@ -0,0 +1,2107 @@ +import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi'; +import { + commonGetErrorResponses, + conversations, + createApiError, + createConversationEvaluationConfig, + createDataset, + createDatasetItem, + createEvalResult, + createEvalTestSuiteConfig, + createEvaluator, + deleteConversationEvaluationConfig, + deleteDataset, + deleteDatasetItem, + deleteEvalResult, + deleteEvalTestSuiteConfig, + deleteEvaluator, + getConversation, + getConversationEvaluationConfig, + getDataset, + getDatasetItem, + getEvalResult, + getEvalResultsByConversation, + getEvalResultsByEvaluator, + getEvalTestSuiteConfig, + getEvaluator, + listConversationEvaluationConfigs, + listDatasetItems, + listDatasets, + listEvalTestSuiteConfigs, + listEvaluators, + startConversationEvaluationConfig, + stopConversationEvaluationConfig, + TenantParamsSchema, + updateConversationEvaluationConfig, + updateDataset, + updateDatasetItem, + updateEvalResult, + updateEvalTestSuiteConfig, + updateEvaluator, +} from '@inkeep/agents-core'; +import { and, eq } from 'drizzle-orm'; +import dbClient from '../data/db/dbClient'; +import { getLogger } from '../logger'; +import { runConversationEvaluation, runDatasetEval } from '../services/EvaluationService'; + +const logger = getLogger('evaluations'); + +const app = new OpenAPIHono(); + +// Request/Response schemas + +const ConversationIdParamsSchema = TenantParamsSchema.extend({ + conversationId: z.string().openapi({ param: { name: 'conversationId', in: 'path' } }), +}); + +const EvaluatorIdParamsSchema = TenantParamsSchema.extend({ + evaluatorId: z.string().openapi({ param: { name: 'evaluatorId', in: 'path' } }), +}); + +const EvalResultIdParamsSchema = z.object({ + id: z.string().openapi({ param: { name: 'id', in: 'path' } }), +}); + +const RunConversationEvaluationRequestSchema = z + .object({ + conversationEvaluationConfigId: z.string(), + }) + .openapi('RunConversationEvaluationRequest'); + +const RunDatasetEvalRequestSchema = z + .object({ + testSuiteConfigId: z.string(), + datasetId: z.string(), + agentId: z.string(), + evaluatorIds: z.array(z.string()), + }) + .openapi('RunDatasetEvalRequest'); + +const CreateEvalResultRequestSchema = z + .object({ + conversationId: z.string(), + evaluatorId: z.string(), + status: z.enum(['pending', 'done', 'failed']), + reasoning: z.string().optional(), + metadata: z.record(z.string(), z.unknown()).optional(), + suiteRunId: z.string().optional(), + datasetItemId: z.string().optional(), + }) + .openapi('CreateEvalResultRequest'); + +const UpdateEvalResultRequestSchema = z + .object({ + status: z.enum(['pending', 'done', 'failed']).optional(), + reasoning: z.string().optional(), + metadata: z.record(z.string(), z.unknown()).optional(), + }) + .openapi('UpdateEvalResultRequest'); + +const EvalResultSchema = z + .object({ + id: z.string(), + suiteRunId: z.string().nullable(), + datasetItemId: z.string().nullable(), + conversationId: z.string(), + status: z.enum(['pending', 'done', 'failed']), + evaluatorId: z.string(), + reasoning: z.string().nullable(), + metadata: z.record(z.string(), z.unknown()).nullable(), + createdAt: z.string(), + updatedAt: z.string(), + }) + .openapi('EvalResult'); + +const EvalResultResponseSchema = z + .object({ + data: EvalResultSchema, + }) + .openapi('EvalResultResponse'); + +const EvalResultsListResponseSchema = z + .object({ + data: z.array(EvalResultSchema), + }) + .openapi('EvalResultsListResponse'); + +const CreateEvaluatorRequestSchema = z + .object({ + name: z.string().min(1), + description: z.string().optional(), + prompt: z.string().min(1), + schema: z.record(z.string(), z.unknown()), + modelConfig: z.record(z.string(), z.unknown()).optional(), + id: z.string().optional(), + }) + .openapi('CreateEvaluatorRequest'); + +const EvaluatorSchema = z + .object({ + tenantId: z.string(), + id: z.string(), + name: z.string(), + description: z.string().nullable(), + prompt: z.string(), + schema: z.record(z.string(), z.unknown()), + modelConfig: z.record(z.string(), z.unknown()).nullable(), + createdAt: z.string(), + updatedAt: z.string(), + }) + .openapi('Evaluator'); + +const EvaluatorResponseSchema = z + .object({ + data: EvaluatorSchema, + }) + .openapi('EvaluatorResponse'); + +const EvaluatorsListResponseSchema = z + .object({ + data: z.array(EvaluatorSchema), + }) + .openapi('EvaluatorsListResponse'); + +const UpdateEvaluatorRequestSchema = z + .object({ + name: z.string().optional(), + description: z.string().optional(), + prompt: z.string().optional(), + schema: z.record(z.string(), z.unknown()).optional(), + modelConfig: z.record(z.string(), z.unknown()).optional(), + }) + .openapi('UpdateEvaluatorRequest'); + +const ConversationFilterSchema = z + .object({ + agentIds: z.array(z.string()).optional(), + projectIds: z.array(z.string()).optional(), + dateRange: z.object({ startDate: z.string(), endDate: z.string() }).optional(), + conversationIds: z.array(z.string()).optional(), + }) + .partial(); + +const ConversationEvaluationConfigSchema = z + .object({ + tenantId: z.string(), + id: z.string(), + name: z.string(), + description: z.string(), + conversationFilter: ConversationFilterSchema.nullable().optional(), + modelConfig: z.record(z.string(), z.unknown()).nullable().optional(), + sampleRate: z.number().nullable().optional(), + isActive: z.boolean(), + createdAt: z.string(), + updatedAt: z.string(), + }) + .openapi('ConversationEvaluationConfig'); + +const ConversationEvaluationConfigResponseSchema = z + .object({ + data: ConversationEvaluationConfigSchema, + }) + .openapi('ConversationEvaluationConfigResponse'); + +const ConversationEvaluationConfigListResponseSchema = z + .object({ + data: z.array(ConversationEvaluationConfigSchema), + }) + .openapi('ConversationEvaluationConfigListResponse'); + +const CreateConversationEvaluationConfigRequestSchema = z + .object({ + id: z.string().optional(), + name: z.string().min(1), + description: z.string().optional(), + conversationFilter: ConversationFilterSchema.optional(), + modelConfig: z.record(z.string(), z.unknown()).optional(), + sampleRate: z.number().optional(), + isActive: z.boolean().optional(), + }) + .openapi('CreateConversationEvaluationConfigRequest'); + +const UpdateConversationEvaluationConfigRequestSchema = z + .object({ + name: z.string().optional(), + description: z.string().optional(), + conversationFilter: ConversationFilterSchema.optional(), + modelConfig: z.record(z.string(), z.unknown()).optional(), + sampleRate: z.number().optional(), + isActive: z.boolean().optional(), + }) + .openapi('UpdateConversationEvaluationConfigRequest'); + +const ConversationEvaluationConfigIdParamsSchema = TenantParamsSchema.extend({ + id: z.string().openapi({ param: { name: 'id', in: 'path' } }), +}); + +const DatasetIdParamsSchema = TenantParamsSchema.extend({ + datasetId: z.string().openapi({ param: { name: 'datasetId', in: 'path' } }), +}); + +const CreateDatasetRequestSchema = z + .object({ + id: z.string().optional(), + name: z.string().min(1), + description: z.string().optional(), + metadata: z.record(z.string(), z.unknown()).optional(), + }) + .openapi('CreateDatasetRequest'); + +const UpdateDatasetRequestSchema = z + .object({ + name: z.string().optional(), + description: z.string().optional(), + metadata: z.record(z.string(), z.unknown()).optional(), + }) + .openapi('UpdateDatasetRequest'); + +const DatasetSchema = z + .object({ + tenantId: z.string(), + id: z.string(), + name: z.string(), + description: z.string(), + metadata: z.record(z.string(), z.unknown()).nullable(), + createdAt: z.string(), + updatedAt: z.string(), + }) + .openapi('Dataset'); + +const DatasetResponseSchema = z + .object({ + data: DatasetSchema, + }) + .openapi('DatasetResponse'); + +const DatasetListResponseSchema = z + .object({ + data: z.array(DatasetSchema), + }) + .openapi('DatasetListResponse'); + +const DatasetItemIdParamsSchema = z.object({ + id: z.string().openapi({ param: { name: 'id', in: 'path' } }), +}); + +const DatasetItemDatasetIdParamsSchema = z.object({ + datasetId: z.string().openapi({ param: { name: 'datasetId', in: 'path' } }), +}); + +const MessageContentSchema = z.union([ + z.string(), + z.array( + z.object({ + type: z.string(), + text: z.string().optional(), + image_url: z.object({ url: z.string() }).optional(), + }) + ), +]); + +const CreateDatasetItemRequestSchema = z + .object({ + id: z.string().optional(), + datasetId: z.string(), + input: z + .object({ + messages: z.array( + z.object({ + role: z.string(), + content: MessageContentSchema, + }) + ), + headers: z.record(z.string(), z.string()).optional(), + }) + .optional(), + expectedOutput: z + .array( + z.object({ + role: z.string(), + content: MessageContentSchema, + }) + ) + .optional(), + simulationConfig: z + .object({ + userPersona: z.string(), + initialMessage: z.string().optional(), + maxTurns: z.number().optional(), + stoppingCondition: z.string().optional(), + simulatingAgentDefinition: z.object({ + name: z.string(), + description: z.string(), + prompt: z.string(), + model: z.string(), + temperature: z.number().optional(), + }), + }) + .optional(), + }) + .openapi('CreateDatasetItemRequest'); + +const UpdateDatasetItemRequestSchema = z + .object({ + input: z + .object({ + messages: z.array( + z.object({ + role: z.string(), + content: MessageContentSchema, + }) + ), + headers: z.record(z.string(), z.string()).optional(), + }) + .optional(), + expectedOutput: z + .array( + z.object({ + role: z.string(), + content: MessageContentSchema, + }) + ) + .optional(), + simulationConfig: z + .object({ + userPersona: z.string(), + initialMessage: z.string().optional(), + maxTurns: z.number().optional(), + stoppingCondition: z.string().optional(), + simulatingAgentDefinition: z.object({ + name: z.string(), + description: z.string(), + prompt: z.string(), + model: z.string(), + temperature: z.number().optional(), + }), + }) + .optional(), + }) + .openapi('UpdateDatasetItemRequest'); + +const DatasetItemSchema = z + .object({ + id: z.string(), + datasetId: z.string(), + input: z.unknown(), + expectedOutput: z.unknown().nullable(), + simulationConfig: z.unknown().nullable(), + createdAt: z.string(), + updatedAt: z.string(), + }) + .openapi('DatasetItem'); + +const DatasetItemResponseSchema = z + .object({ + data: DatasetItemSchema, + }) + .openapi('DatasetItemResponse'); + +const DatasetItemListResponseSchema = z + .object({ + data: z.array(DatasetItemSchema), + }) + .openapi('DatasetItemListResponse'); + +const EvalTestSuiteConfigIdParamsSchema = TenantParamsSchema.extend({ + id: z.string().openapi({ param: { name: 'id', in: 'path' } }), +}); + +const CreateEvalTestSuiteConfigRequestSchema = z + .object({ + id: z.string().optional(), + name: z.string().min(1), + description: z.string().optional(), + modelConfig: z.record(z.string(), z.unknown()).optional(), + runFrequency: z.string().min(1), + }) + .openapi('CreateEvalTestSuiteConfigRequest'); + +const UpdateEvalTestSuiteConfigRequestSchema = z + .object({ + name: z.string().optional(), + description: z.string().optional(), + modelConfig: z.record(z.string(), z.unknown()).optional(), + runFrequency: z.string().optional(), + }) + .openapi('UpdateEvalTestSuiteConfigRequest'); + +const EvalTestSuiteConfigSchema = z + .object({ + tenantId: z.string(), + id: z.string(), + name: z.string(), + description: z.string(), + modelConfig: z.record(z.string(), z.unknown()).nullable(), + runFrequency: z.string(), + createdAt: z.string(), + updatedAt: z.string(), + }) + .openapi('EvalTestSuiteConfig'); + +const EvalTestSuiteConfigResponseSchema = z + .object({ + data: EvalTestSuiteConfigSchema, + }) + .openapi('EvalTestSuiteConfigResponse'); + +const EvalTestSuiteConfigListResponseSchema = z + .object({ + data: z.array(EvalTestSuiteConfigSchema), + }) + .openapi('EvalTestSuiteConfigListResponse'); + + +// EVALUATORS + + +// POST /evaluations/evaluators +app.openapi( + createRoute({ + method: 'post', + path: '/evaluators', + summary: 'Create Evaluator', + operationId: 'create-evaluator', + tags: ['Evaluations'], + request: { + params: TenantParamsSchema, + body: { + content: { + 'application/json': { + schema: CreateEvaluatorRequestSchema, + }, + }, + }, + }, + responses: { + 201: { + description: 'Evaluator created', + content: { + 'application/json': { + schema: EvaluatorResponseSchema, + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + const body = c.req.valid('json'); + + try { + const row = await createEvaluator(dbClient)({ + tenantId, + id: body.id, + name: body.name, + description: body.description, + prompt: body.prompt, + schema: body.schema, + modelConfig: body.modelConfig, + }); + + return c.json({ data: row }, 201) as any; + } catch (error) { + logger.error({ error, tenantId, body }, 'Failed to create evaluator'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to create evaluator' }), + 500 + ) as any; + } + } +); + +// GET /evaluations/evaluators/{evaluatorId} +app.openapi( + createRoute({ + method: 'get', + path: '/evaluators/{evaluatorId}', + summary: 'Get Evaluator', + operationId: 'get-evaluator', + tags: ['Evaluations'], + request: { + params: EvaluatorIdParamsSchema, + }, + responses: { + 200: { + description: 'Evaluator details', + content: { + 'application/json': { + schema: z.object({ + data: z.unknown(), + }), + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, evaluatorId } = c.req.valid('param'); + + try { + const evaluator = await getEvaluator(dbClient)({ tenantId, evaluatorId }); + + if (!evaluator) { + return c.json( + createApiError({ code: 'not_found', message: 'Evaluator not found' }), + 404 + ) as any; + } + + return c.json({ data: evaluator }) as any; + } catch (error) { + logger.error({ error, tenantId, evaluatorId }, 'Failed to get evaluator'); + + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to get evaluator', + }), + 500 + ) as any; + } + } +); + +// GET /evaluations/evaluators +app.openapi( + createRoute({ + method: 'get', + path: '/evaluators', + summary: 'List Evaluators', + operationId: 'list-evaluators', + tags: ['Evaluations'], + request: { params: TenantParamsSchema }, + responses: { + 200: { + description: 'Evaluators', + content: { 'application/json': { schema: EvaluatorsListResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + const rows = await listEvaluators(dbClient)({ tenantId }); + return c.json({ data: rows }) as any; + } +); + +// PUT /evaluations/evaluators/{evaluatorId} +app.openapi( + createRoute({ + method: 'put', + path: '/evaluators/{evaluatorId}', + summary: 'Update Evaluator', + operationId: 'update-evaluator', + tags: ['Evaluations'], + request: { + params: EvaluatorIdParamsSchema, + body: { content: { 'application/json': { schema: UpdateEvaluatorRequestSchema } } }, + }, + responses: { + 200: { + description: 'Evaluator updated', + content: { 'application/json': { schema: EvaluatorResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, evaluatorId } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const updated = await updateEvaluator(dbClient)({ tenantId, evaluatorId, ...body }); + if (!updated) { + return c.json( + createApiError({ code: 'not_found', message: 'Evaluator not found' }), + 404 + ) as any; + } + return c.json({ data: updated }) as any; + } catch (error) { + logger.error({ error, tenantId, evaluatorId, body }, 'Failed to update evaluator'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to update evaluator' }), + 500 + ) as any; + } + } +); + +// DELETE /evaluations/evaluators/{evaluatorId} +app.openapi( + createRoute({ + method: 'delete', + path: '/evaluators/{evaluatorId}', + summary: 'Delete Evaluator', + operationId: 'delete-evaluator', + tags: ['Evaluations'], + request: { params: EvaluatorIdParamsSchema }, + responses: { + 204: { description: 'Evaluator deleted' }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, evaluatorId } = c.req.valid('param'); + try { + const deleted = await deleteEvaluator(dbClient)({ tenantId, evaluatorId }); + if (!deleted) { + return c.json( + createApiError({ code: 'not_found', message: 'Evaluator not found' }), + 404 + ) as any; + } + return c.body(null, 204); + } catch (error) { + logger.error({ error, tenantId, evaluatorId }, 'Failed to delete evaluator'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to delete evaluator' }), + 500 + ) as any; + } + } +); + +// POST /evaluations/configs +app.openapi( + createRoute({ + method: 'post', + path: '/configs', + summary: 'Create Conversation Evaluation Config', + operationId: 'create-conversation-evaluation-config', + tags: ['Evaluations'], + request: { + params: TenantParamsSchema, + body: { + content: { + 'application/json': { schema: CreateConversationEvaluationConfigRequestSchema }, + }, + }, + }, + responses: { + 201: { + description: 'Config created', + content: { 'application/json': { schema: ConversationEvaluationConfigResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const row = await createConversationEvaluationConfig(dbClient)({ + tenantId, + id: body.id, + name: body.name, + description: body.description, + conversationFilter: body.conversationFilter, + modelConfig: body.modelConfig, + sampleRate: body.sampleRate, + isActive: body.isActive, + }); + return c.json({ data: row }, 201) as any; + } catch (error) { + logger.error({ error, tenantId, body }, 'Failed to create conversation eval config'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to create config' }), + 500 + ) as any; + } + } +); + +// GET /evaluations/configs/{id} +app.openapi( + createRoute({ + method: 'get', + path: '/configs/{id}', + summary: 'Get Conversation Evaluation Config', + operationId: 'get-conversation-evaluation-config', + tags: ['Evaluations'], + request: { params: ConversationEvaluationConfigIdParamsSchema }, + responses: { + 200: { + description: 'Config', + content: { 'application/json': { schema: ConversationEvaluationConfigResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, id } = c.req.valid('param'); + try { + const row = await getConversationEvaluationConfig(dbClient)({ + tenantId, + conversationEvaluationConfigId: id, + }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Config not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, tenantId, id }, 'Failed to get conversation eval config'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to get config' }), + 500 + ) as any; + } + } +); + +// GET /evaluations/configs +app.openapi( + createRoute({ + method: 'get', + path: '/configs', + summary: 'List Conversation Evaluation Configs', + operationId: 'list-conversation-evaluation-configs', + tags: ['Evaluations'], + request: { params: TenantParamsSchema }, + responses: { + 200: { + description: 'Configs', + content: { 'application/json': { schema: ConversationEvaluationConfigListResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + try { + const rows = await listConversationEvaluationConfigs(dbClient)({ tenantId }); + return c.json({ data: rows }) as any; + } catch (error) { + logger.error({ error, tenantId }, 'Failed to list conversation eval configs'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to list configs' }), + 500 + ) as any; + } + } +); + +// PUT /evaluations/configs/{id} +app.openapi( + createRoute({ + method: 'put', + path: '/configs/{id}', + summary: 'Update Conversation Evaluation Config', + operationId: 'update-conversation-evaluation-config', + tags: ['Evaluations'], + request: { + params: ConversationEvaluationConfigIdParamsSchema, + body: { + content: { + 'application/json': { schema: UpdateConversationEvaluationConfigRequestSchema }, + }, + }, + }, + responses: { + 200: { + description: 'Updated config', + content: { 'application/json': { schema: ConversationEvaluationConfigResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, id } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const row = await updateConversationEvaluationConfig(dbClient)({ + tenantId, + id, + ...body, + }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Config not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, tenantId, id, body }, 'Failed to update conversation eval config'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to update config' }), + 500 + ) as any; + } + } +); + +// DELETE /evaluations/configs/{id} +app.openapi( + createRoute({ + method: 'delete', + path: '/configs/{id}', + summary: 'Delete Conversation Evaluation Config', + operationId: 'delete-conversation-evaluation-config', + tags: ['Evaluations'], + request: { params: ConversationEvaluationConfigIdParamsSchema }, + responses: { + 204: { description: 'Deleted' }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, id } = c.req.valid('param'); + try { + const row = await deleteConversationEvaluationConfig(dbClient)({ tenantId, id }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Config not found' }), + 404 + ) as any; + } + return c.body(null, 204); + } catch (error) { + logger.error({ error, tenantId, id }, 'Failed to delete conversation eval config'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to delete config' }), + 500 + ) as any; + } + } +); + +// POST /evaluations/configs/{id}/start +app.openapi( + createRoute({ + method: 'post', + path: '/configs/{id}/start', + summary: 'Start Conversation Evaluation Config', + operationId: 'start-conversation-evaluation-config', + tags: ['Evaluations'], + request: { params: ConversationEvaluationConfigIdParamsSchema }, + responses: { + 200: { + description: 'Started', + content: { 'application/json': { schema: ConversationEvaluationConfigResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, id } = c.req.valid('param'); + try { + const row = await startConversationEvaluationConfig(dbClient)({ tenantId, id }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Config not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, tenantId, id }, 'Failed to start conversation eval config'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to start config' }), + 500 + ) as any; + } + } +); + +// POST /evaluations/configs/{id}/stop +app.openapi( + createRoute({ + method: 'post', + path: '/configs/{id}/stop', + summary: 'Stop Conversation Evaluation Config', + operationId: 'stop-conversation-evaluation-config', + tags: ['Evaluations'], + request: { params: ConversationEvaluationConfigIdParamsSchema }, + responses: { + 200: { + description: 'Stopped', + content: { 'application/json': { schema: ConversationEvaluationConfigResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, id } = c.req.valid('param'); + try { + const row = await stopConversationEvaluationConfig(dbClient)({ tenantId, id }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Config not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, tenantId, id }, 'Failed to stop conversation eval config'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to stop config' }), + 500 + ) as any; + } + } +); + + +// DATASETS + + +// POST /evaluations/datasets +app.openapi( + createRoute({ + method: 'post', + path: '/datasets', + summary: 'Create Dataset', + operationId: 'create-dataset', + tags: ['Evaluations'], + request: { + params: TenantParamsSchema, + body: { + content: { + 'application/json': { schema: CreateDatasetRequestSchema }, + }, + }, + }, + responses: { + 201: { + description: 'Dataset created', + content: { 'application/json': { schema: DatasetResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const row = await createDataset(dbClient)({ + tenantId, + id: body.id, + name: body.name, + description: body.description, + metadata: body.metadata, + }); + return c.json({ data: row }, 201) as any; + } catch (error) { + logger.error({ error, tenantId, body }, 'Failed to create dataset'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to create dataset' }), + 500 + ) as any; + } + } +); + +// GET /evaluations/datasets/{datasetId} +app.openapi( + createRoute({ + method: 'get', + path: '/datasets/{datasetId}', + summary: 'Get Dataset', + operationId: 'get-dataset', + tags: ['Evaluations'], + request: { params: DatasetIdParamsSchema }, + responses: { + 200: { + description: 'Dataset', + content: { 'application/json': { schema: DatasetResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, datasetId } = c.req.valid('param'); + try { + const row = await getDataset(dbClient)({ tenantId, datasetId }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Dataset not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, tenantId, datasetId }, 'Failed to get dataset'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to get dataset' }), + 500 + ) as any; + } + } +); + +// GET /evaluations/datasets +app.openapi( + createRoute({ + method: 'get', + path: '/datasets', + summary: 'List Datasets', + operationId: 'list-datasets', + tags: ['Evaluations'], + request: { params: TenantParamsSchema }, + responses: { + 200: { + description: 'Datasets', + content: { 'application/json': { schema: DatasetListResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + try { + const rows = await listDatasets(dbClient)({ tenantId }); + return c.json({ data: rows }) as any; + } catch (error) { + logger.error({ error, tenantId }, 'Failed to list datasets'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to list datasets' }), + 500 + ) as any; + } + } +); + +// PUT /evaluations/datasets/{datasetId} +app.openapi( + createRoute({ + method: 'put', + path: '/datasets/{datasetId}', + summary: 'Update Dataset', + operationId: 'update-dataset', + tags: ['Evaluations'], + request: { + params: DatasetIdParamsSchema, + body: { content: { 'application/json': { schema: UpdateDatasetRequestSchema } } }, + }, + responses: { + 200: { + description: 'Updated dataset', + content: { 'application/json': { schema: DatasetResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, datasetId } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const row = await updateDataset(dbClient)({ + tenantId, + datasetId, + ...body, + }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Dataset not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, tenantId, datasetId, body }, 'Failed to update dataset'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to update dataset' }), + 500 + ) as any; + } + } +); + +// DELETE /evaluations/datasets/{datasetId} +app.openapi( + createRoute({ + method: 'delete', + path: '/datasets/{datasetId}', + summary: 'Delete Dataset', + operationId: 'delete-dataset', + tags: ['Evaluations'], + request: { params: DatasetIdParamsSchema }, + responses: { + 204: { description: 'Deleted' }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, datasetId } = c.req.valid('param'); + try { + const row = await deleteDataset(dbClient)({ tenantId, datasetId }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Dataset not found' }), + 404 + ) as any; + } + return c.body(null, 204); + } catch (error) { + logger.error({ error, tenantId, datasetId }, 'Failed to delete dataset'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to delete dataset' }), + 500 + ) as any; + } + } +); + + +// DATASET ITEMS + +// POST /evaluations/datasets/{datasetId}/items +app.openapi( + createRoute({ + method: 'post', + path: '/datasets/{datasetId}/items', + summary: 'Create Dataset Item', + operationId: 'create-dataset-item', + tags: ['Evaluations'], + request: { + params: DatasetItemDatasetIdParamsSchema, + body: { + content: { + 'application/json': { schema: CreateDatasetItemRequestSchema.omit({ datasetId: true }) }, + }, + }, + }, + responses: { + 201: { + description: 'Dataset item created', + content: { 'application/json': { schema: DatasetItemResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { datasetId } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const row = await createDatasetItem(dbClient)({ + id: body.id, + datasetId, + input: body.input as any, + expectedOutput: body.expectedOutput as any, + simulationConfig: body.simulationConfig as any, + }); + return c.json({ data: row }, 201) as any; + } catch (error) { + logger.error({ error, datasetId, body }, 'Failed to create dataset item'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to create dataset item' }), + 500 + ) as any; + } + } +); + +// GET /evaluations/datasets/{datasetId}/items +app.openapi( + createRoute({ + method: 'get', + path: '/datasets/{datasetId}/items', + summary: 'List Dataset Items', + operationId: 'list-dataset-items', + tags: ['Evaluations'], + request: { params: DatasetItemDatasetIdParamsSchema }, + responses: { + 200: { + description: 'Dataset items', + content: { 'application/json': { schema: DatasetItemListResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { datasetId } = c.req.valid('param'); + try { + const rows = await listDatasetItems(dbClient)({ datasetId }); + return c.json({ data: rows }) as any; + } catch (error) { + logger.error({ error, datasetId }, 'Failed to list dataset items'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to list dataset items' }), + 500 + ) as any; + } + } +); + +// GET /evaluations/dataset-items/{id} +app.openapi( + createRoute({ + method: 'get', + path: '/dataset-items/{id}', + summary: 'Get Dataset Item', + operationId: 'get-dataset-item', + tags: ['Evaluations'], + request: { params: DatasetItemIdParamsSchema }, + responses: { + 200: { + description: 'Dataset item', + content: { 'application/json': { schema: DatasetItemResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { id } = c.req.valid('param'); + try { + const row = await getDatasetItem(dbClient)({ id }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Dataset item not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, id }, 'Failed to get dataset item'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to get dataset item' }), + 500 + ) as any; + } + } +); + +// PUT /evaluations/dataset-items/{id} +app.openapi( + createRoute({ + method: 'put', + path: '/dataset-items/{id}', + summary: 'Update Dataset Item', + operationId: 'update-dataset-item', + tags: ['Evaluations'], + request: { + params: DatasetItemIdParamsSchema, + body: { content: { 'application/json': { schema: UpdateDatasetItemRequestSchema } } }, + }, + responses: { + 200: { + description: 'Updated dataset item', + content: { 'application/json': { schema: DatasetItemResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { id } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const row = await updateDatasetItem(dbClient)({ + id, + input: body.input as any, + expectedOutput: body.expectedOutput as any, + simulationConfig: body.simulationConfig as any, + }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Dataset item not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, id, body }, 'Failed to update dataset item'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to update dataset item' }), + 500 + ) as any; + } + } +); + +// DELETE /evaluations/dataset-items/{id} +app.openapi( + createRoute({ + method: 'delete', + path: '/dataset-items/{id}', + summary: 'Delete Dataset Item', + operationId: 'delete-dataset-item', + tags: ['Evaluations'], + request: { params: DatasetItemIdParamsSchema }, + responses: { + 204: { description: 'Deleted' }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { id } = c.req.valid('param'); + try { + const row = await deleteDatasetItem(dbClient)({ id }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Dataset item not found' }), + 404 + ) as any; + } + return c.body(null, 204); + } catch (error) { + logger.error({ error, id }, 'Failed to delete dataset item'); + return c.json( + createApiError({ code: 'internal_server_error', message: 'Failed to delete dataset item' }), + 500 + ) as any; + } + } +); + + +// TEST SUITE CONFIGS + + +// POST /evaluations/test-suite-configs +app.openapi( + createRoute({ + method: 'post', + path: '/test-suite-configs', + summary: 'Create Eval Test Suite Config', + operationId: 'create-eval-test-suite-config', + tags: ['Evaluations'], + request: { + params: TenantParamsSchema, + body: { + content: { + 'application/json': { schema: CreateEvalTestSuiteConfigRequestSchema }, + }, + }, + }, + responses: { + 201: { + description: 'Test suite config created', + content: { 'application/json': { schema: EvalTestSuiteConfigResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const row = await createEvalTestSuiteConfig(dbClient)({ + tenantId, + id: body.id, + name: body.name, + description: body.description, + modelConfig: body.modelConfig, + runFrequency: body.runFrequency, + }); + return c.json({ data: row }, 201) as any; + } catch (error) { + logger.error({ error, tenantId, body }, 'Failed to create test suite config'); + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to create test suite config', + }), + 500 + ) as any; + } + } +); + +// GET /evaluations/test-suite-configs/{id} +app.openapi( + createRoute({ + method: 'get', + path: '/test-suite-configs/{id}', + summary: 'Get Eval Test Suite Config', + operationId: 'get-eval-test-suite-config', + tags: ['Evaluations'], + request: { params: EvalTestSuiteConfigIdParamsSchema }, + responses: { + 200: { + description: 'Test suite config', + content: { 'application/json': { schema: EvalTestSuiteConfigResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, id } = c.req.valid('param'); + try { + const row = await getEvalTestSuiteConfig(dbClient)({ tenantId, evalTestSuiteConfigId: id }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Test suite config not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, tenantId, id }, 'Failed to get test suite config'); + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to get test suite config', + }), + 500 + ) as any; + } + } +); + +// GET /evaluations/test-suite-configs +app.openapi( + createRoute({ + method: 'get', + path: '/test-suite-configs', + summary: 'List Eval Test Suite Configs', + operationId: 'list-eval-test-suite-configs', + tags: ['Evaluations'], + request: { params: TenantParamsSchema }, + responses: { + 200: { + description: 'Test suite configs', + content: { 'application/json': { schema: EvalTestSuiteConfigListResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + try { + const rows = await listEvalTestSuiteConfigs(dbClient)({ tenantId }); + return c.json({ data: rows }) as any; + } catch (error) { + logger.error({ error, tenantId }, 'Failed to list test suite configs'); + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to list test suite configs', + }), + 500 + ) as any; + } + } +); + +// PUT /evaluations/test-suite-configs/{id} +app.openapi( + createRoute({ + method: 'put', + path: '/test-suite-configs/{id}', + summary: 'Update Eval Test Suite Config', + operationId: 'update-eval-test-suite-config', + tags: ['Evaluations'], + request: { + params: EvalTestSuiteConfigIdParamsSchema, + body: { content: { 'application/json': { schema: UpdateEvalTestSuiteConfigRequestSchema } } }, + }, + responses: { + 200: { + description: 'Updated test suite config', + content: { 'application/json': { schema: EvalTestSuiteConfigResponseSchema } }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, id } = c.req.valid('param'); + const body = c.req.valid('json'); + try { + const row = await updateEvalTestSuiteConfig(dbClient)({ + tenantId, + id, + ...body, + }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Test suite config not found' }), + 404 + ) as any; + } + return c.json({ data: row }) as any; + } catch (error) { + logger.error({ error, tenantId, id, body }, 'Failed to update test suite config'); + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to update test suite config', + }), + 500 + ) as any; + } + } +); + +// DELETE /evaluations/test-suite-configs/{id} +app.openapi( + createRoute({ + method: 'delete', + path: '/test-suite-configs/{id}', + summary: 'Delete Eval Test Suite Config', + operationId: 'delete-eval-test-suite-config', + tags: ['Evaluations'], + request: { params: EvalTestSuiteConfigIdParamsSchema }, + responses: { + 204: { description: 'Deleted' }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, id } = c.req.valid('param'); + try { + const row = await deleteEvalTestSuiteConfig(dbClient)({ tenantId, id }); + if (!row) { + return c.json( + createApiError({ code: 'not_found', message: 'Test suite config not found' }), + 404 + ) as any; + } + return c.body(null, 204); + } catch (error) { + logger.error({ error, tenantId, id }, 'Failed to delete test suite config'); + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to delete test suite config', + }), + 500 + ) as any; + } + } +); + + +// RUN OPERATIONS + + +// POST /evaluations/conversations/run +app.openapi( + createRoute({ + method: 'post', + path: '/conversations/run', + summary: 'Run Conversation Evaluation', + operationId: 'run-conversation-evaluation', + tags: ['Evaluations'], + request: { + params: TenantParamsSchema, + body: { + content: { + 'application/json': { + schema: RunConversationEvaluationRequestSchema, + }, + }, + }, + }, + responses: { + 200: { + description: 'Evaluation results', + content: { + 'application/json': { + schema: EvalResultsListResponseSchema, + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + const { conversationEvaluationConfigId } = c.req.valid('json'); + + try { + const results = await runConversationEvaluation(dbClient)({ + scopes: { tenantId }, + conversationEvaluationConfigId, + }); + + return c.json({ data: results }) as any; + } catch (error) { + logger.error( + { + error, + tenantId, + conversationEvaluationConfigId, + }, + 'Failed to run conversation evaluation' + ); + + const errorMessage = + error instanceof Error ? error.message : 'Failed to run conversation evaluation'; + + return c.json( + createApiError({ + code: 'internal_server_error', + message: errorMessage, + }), + 500 + ) as any; + } + } +); + +// POST /evaluations/datasets/run +app.openapi( + createRoute({ + method: 'post', + path: '/datasets/run', + summary: 'Run Dataset Evaluation', + operationId: 'run-dataset-evaluation', + tags: ['Evaluations'], + request: { + params: TenantParamsSchema, + body: { + content: { + 'application/json': { + schema: RunDatasetEvalRequestSchema, + }, + }, + }, + }, + responses: { + 200: { + description: 'Evaluation results', + content: { + 'application/json': { + schema: EvalResultsListResponseSchema, + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + const { testSuiteConfigId, datasetId, agentId, evaluatorIds } = c.req.valid('json'); + + try { + const results = await runDatasetEval(dbClient)({ + scopes: { tenantId }, + testSuiteConfigId, + datasetId, + agentId, + evaluatorIds, + }); + + return c.json({ data: results }) as any; + } catch (error) { + logger.error( + { + error, + tenantId, + testSuiteConfigId, + datasetId, + agentId, + evaluatorIds, + }, + 'Failed to run dataset evaluation' + ); + + const errorMessage = error instanceof Error ? error.message : 'Failed to run dataset evaluation'; + + return c.json( + createApiError({ + code: 'internal_server_error', + message: errorMessage, + }), + 500 + ) as any; + } + } +); + + +// EVALUATION RESULTS + + +// POST /evaluations/results +app.openapi( + createRoute({ + method: 'post', + path: '/results', + summary: 'Create Evaluation Result', + operationId: 'create-eval-result', + tags: ['Evaluations'], + request: { + params: TenantParamsSchema, + body: { + content: { + 'application/json': { + schema: CreateEvalResultRequestSchema, + }, + }, + }, + }, + responses: { + 201: { + description: 'Evaluation result created', + content: { + 'application/json': { + schema: EvalResultResponseSchema, + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId } = c.req.valid('param'); + const resultData = c.req.valid('json'); + + try { + // Fetch conversation to get projectId + const conversation = await dbClient.query.conversations.findFirst({ + where: and( + eq(conversations.tenantId, tenantId), + eq(conversations.id, resultData.conversationId) + ), + }); + + if (!conversation) { + throw createApiError({ code: 'not_found', message: 'Conversation not found' }); + } + + const result = await createEvalResult(dbClient)({ + tenantId, + projectId: conversation.projectId, + conversationId: resultData.conversationId, + evaluatorId: resultData.evaluatorId, + status: resultData.status, + reasoning: resultData.reasoning, + metadata: resultData.metadata, + suiteRunId: resultData.suiteRunId, + datasetItemId: resultData.datasetItemId, + }); + + logger.info({ tenantId, resultId: result.id }, 'Evaluation result created'); + + return c.json({ data: result }, 201) as any; + } catch (error) { + logger.error({ error, tenantId, resultData }, 'Failed to create evaluation result'); + + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to create evaluation result', + }), + 500 + ) as any; + } + } +); + +// GET /evaluations/results/{id} +app.openapi( + createRoute({ + method: 'get', + path: '/results/{id}', + summary: 'Get Evaluation Result by ID', + operationId: 'get-eval-result-by-id', + tags: ['Evaluations'], + request: { + params: EvalResultIdParamsSchema, + }, + responses: { + 200: { + description: 'Evaluation result', + content: { + 'application/json': { + schema: EvalResultResponseSchema, + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { id } = c.req.valid('param'); + + try { + const result = await getEvalResult(dbClient)({ id }); + if (!result) { + return c.json( + createApiError({ code: 'not_found', message: 'Evaluation result not found' }), + 404 + ) as any; + } + return c.json({ data: result }) as any; + } catch (error) { + logger.error({ error, id }, 'Failed to get evaluation result'); + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to get evaluation result', + }), + 500 + ) as any; + } + } +); + +// GET /evaluations/results/conversation/{conversationId} +app.openapi( + createRoute({ + method: 'get', + path: '/results/conversation/{conversationId}', + summary: 'Get Evaluation Results by Conversation', + operationId: 'get-eval-results-by-conversation', + tags: ['Evaluations'], + request: { + params: ConversationIdParamsSchema, + }, + responses: { + 200: { + description: 'Evaluation results', + content: { + 'application/json': { + schema: EvalResultsListResponseSchema, + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { conversationId } = c.req.valid('param'); + + try { + const results = await getEvalResultsByConversation(dbClient)({ + conversationId, + }); + + return c.json({ data: results }) as any; + } catch (error) { + logger.error({ error, conversationId }, 'Failed to get evaluation results'); + + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to get evaluation results', + }), + 500 + ) as any; + } + } +); + +// GET /evaluations/results/evaluator/{evaluatorId} +app.openapi( + createRoute({ + method: 'get', + path: '/results/evaluator/{evaluatorId}', + summary: 'Get Evaluation Results by Evaluator', + operationId: 'get-eval-results-by-evaluator', + tags: ['Evaluations'], + request: { + params: EvaluatorIdParamsSchema, + }, + responses: { + 200: { + description: 'Evaluation results', + content: { + 'application/json': { + schema: EvalResultsListResponseSchema, + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, evaluatorId } = c.req.valid('param'); + + try { + const results = await getEvalResultsByEvaluator(dbClient)({ + evaluatorId, + }); + + return c.json({ data: results }) as any; + } catch (error) { + logger.error({ error, tenantId, evaluatorId }, 'Failed to get evaluation results'); + + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to get evaluation results', + }), + 500 + ) as any; + } + } +); + +// PATCH /evaluations/results/{id} +app.openapi( + createRoute({ + method: 'patch', + path: '/results/{id}', + summary: 'Update Evaluation Result', + operationId: 'update-eval-result', + tags: ['Evaluations'], + request: { + params: EvalResultIdParamsSchema, + body: { + content: { + 'application/json': { + schema: UpdateEvalResultRequestSchema, + }, + }, + }, + }, + responses: { + 200: { + description: 'Evaluation result updated', + content: { + 'application/json': { + schema: EvalResultResponseSchema, + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { id } = c.req.valid('param'); + const updateData = c.req.valid('json'); + + try { + if (!updateData.status) { + return c.json( + createApiError({ + code: 'bad_request', + message: 'Status is required for update', + }), + 400 + ) as any; + } + + const result = await updateEvalResult(dbClient)({ + id, + status: updateData.status, + reasoning: updateData.reasoning, + metadata: updateData.metadata, + }); + + logger.info({ resultId: id }, 'Evaluation result updated'); + + return c.json({ data: result }) as any; + } catch (error) { + logger.error({ error, id, updateData }, 'Failed to update evaluation result'); + + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to update evaluation result', + }), + 500 + ) as any; + } + } +); + +// DELETE /evaluations/results/{id} +app.openapi( + createRoute({ + method: 'delete', + path: '/results/{id}', + summary: 'Delete Evaluation Result', + operationId: 'delete-eval-result', + tags: ['Evaluations'], + request: { + params: EvalResultIdParamsSchema, + }, + responses: { + 204: { + description: 'Evaluation result deleted successfully', + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { id } = c.req.valid('param'); + + try { + const deleted = await deleteEvalResult(dbClient)({ id }); + + if (!deleted) { + return c.json( + createApiError({ code: 'not_found', message: 'Evaluation result not found' }), + 404 + ) as any; + } + + logger.info({ resultId: id }, 'Evaluation result deleted'); + return c.body(null, 204); + } catch (error) { + logger.error({ error, id }, 'Failed to delete evaluation result'); + + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to delete evaluation result', + }), + 500 + ) as any; + } + } +); + + +// CONVERSATIONS (Helper) + + +// GET /evaluations/conversations/{conversationId} +app.openapi( + createRoute({ + method: 'get', + path: '/conversations/{conversationId}', + summary: 'Get Conversation for Evaluation', + operationId: 'get-conversation-for-evaluation', + tags: ['Evaluations'], + request: { + params: ConversationIdParamsSchema.extend({ + projectId: z.string().openapi({ param: { name: 'projectId', in: 'path' } }), + }), + }, + responses: { + 200: { + description: 'Conversation details', + content: { + 'application/json': { + schema: z.object({ + data: z.unknown(), + }), + }, + }, + }, + ...commonGetErrorResponses, + }, + }), + async (c) => { + const { tenantId, projectId, conversationId } = c.req.valid('param'); + + try { + const conversation = await getConversation(dbClient)({ + scopes: { tenantId, projectId }, + conversationId, + }); + + if (!conversation) { + return c.json( + createApiError({ code: 'not_found', message: 'Conversation not found' }), + 404 + ) as any; + } + + return c.json({ data: conversation }) as any; + } catch (error) { + logger.error({ error, tenantId, projectId, conversationId }, 'Failed to get conversation'); + + return c.json( + createApiError({ + code: 'internal_server_error', + message: 'Failed to get conversation', + }), + 500 + ) as any; + } + } +); + +export default app; + diff --git a/agents-manage-api/src/routes/index.ts b/agents-manage-api/src/routes/index.ts index 08a57db5c..0153a61ed 100644 --- a/agents-manage-api/src/routes/index.ts +++ b/agents-manage-api/src/routes/index.ts @@ -7,6 +7,7 @@ import contextConfigsRoutes from './contextConfigs'; import credentialStoresRoutes from './credentialStores'; import credentialsRoutes from './credentials'; import dataComponentsRoutes from './dataComponents'; +import evaluationsRoutes from './evaluations'; import externalAgentsRoutes from './externalAgents'; import functionsRoutes from './functions'; import functionToolsRoutes from './functionTools'; @@ -26,6 +27,9 @@ const app = new OpenAPIHono(); // Mount projects route first (no projectId in path) app.route('/projects', projectsRoutes); +// Mount evaluations routes at tenant level +app.route('/evaluations', evaluationsRoutes); + // Mount existing routes under project scope app.route('/projects/:projectId/agents/:agentId/sub-agents', subAgentsRoutes); app.route('/projects/:projectId/agents/:agentId/sub-agent-relations', subAgentRelationsRoutes); diff --git a/agents-manage-api/src/services/EvaluationService.ts b/agents-manage-api/src/services/EvaluationService.ts new file mode 100644 index 000000000..93c310e05 --- /dev/null +++ b/agents-manage-api/src/services/EvaluationService.ts @@ -0,0 +1,846 @@ +import { openai } from '@ai-sdk/openai'; +import type { DatabaseClient, FullAgentDefinition, ModelSettings } from '@inkeep/agents-core'; +import { + agents, + createEvalResult, + getAgentIdFromConversation, + getConversationEvaluationConfig, + getConversationHistory, + getConversationsForEvaluation, + getDataset, + getEvaluatorsForConfig, + getFullAgent, + jsonSchemaToZod, + listDatasetItems, + updateEvalResult, +} from '@inkeep/agents-core'; +import type { LanguageModel } from 'ai'; +import { generateObject, generateText } from 'ai'; +import { and, eq } from 'drizzle-orm'; +import { z } from 'zod'; +import { env } from '../env'; +import { getLogger } from '../logger'; + +const logger = getLogger('EvaluationService'); + +interface ActivityItem { + id?: string; + timestamp?: string; + [key: string]: unknown; +} + +interface ConversationDetail { + conversationId: string; + traceId?: string; + agentId?: string; + agentName?: string; + conversationStartTime?: string | null; + conversationEndTime?: string | null; + duration: number; + activities?: ActivityItem[]; + [key: string]: unknown; +} + +interface PrettifiedTrace { + metadata: { + conversationId: string; + traceId?: string; + agentId?: string; + agentName?: string; + exportedAt: string; + }; + timing: { + startTime: string; + endTime: string; + durationMs: number; + }; + timeline: Array>; +} + +export interface EvalInput { + agentDefinition: FullAgentDefinition; + conversationHistory: Array<{ + role: string; + content: any; + [key: string]: unknown; + }>; + trace: PrettifiedTrace; +} + +function formatConversationAsPrettifiedTrace(conversation: ConversationDetail): PrettifiedTrace { + const trace: PrettifiedTrace = { + metadata: { + conversationId: conversation.conversationId, + traceId: conversation.traceId, + agentName: conversation.agentName, + agentId: conversation.agentId, + exportedAt: new Date().toISOString(), + }, + timing: { + startTime: conversation.conversationStartTime || '', + endTime: conversation.conversationEndTime || '', + durationMs: conversation.duration, + }, + timeline: (conversation.activities || []).map((activity) => { + const { id: _id, ...rest } = activity; + return { + ...rest, + }; + }), + }; + + return trace; +} + +async function fetchTraceFromSigNoz(conversationId: string): Promise { + const manageUIUrl = env.AGENTS_MANAGE_UI_URL; + + try { + logger.debug({ conversationId, manageUIUrl }, 'Fetching trace from SigNoz'); + + const traceResponse = await fetch(`${manageUIUrl}/api/signoz/conversations/${conversationId}`); + + if (!traceResponse.ok) { + logger.warn( + { conversationId, status: traceResponse.status, statusText: traceResponse.statusText }, + 'Failed to fetch trace from SigNoz' + ); + return null; + } + + const conversationDetail = (await traceResponse.json()) as ConversationDetail; + + logger.debug( + { conversationId, activityCount: conversationDetail.activities?.length || 0 }, + 'Trace fetched successfully' + ); + + const prettifiedTrace = formatConversationAsPrettifiedTrace(conversationDetail); + return prettifiedTrace; + } catch (error) { + logger.warn( + { error, conversationId, manageUIUrl }, + 'Failed to fetch trace from SigNoz, will continue without trace' + ); + return null; + } +} + +interface RunConversationEvaluationParams { + scopes: { tenantId: string }; + conversationEvaluationConfigId: string; +} + +/** + * Run conversation evaluation based on a conversation evaluation config + */ +export const runConversationEvaluation = + (db: DatabaseClient) => + async ( + params: RunConversationEvaluationParams + ): Promise> => { + const { scopes, conversationEvaluationConfigId } = params; + const { tenantId } = scopes; + + logger.info({ tenantId, conversationEvaluationConfigId }, 'Starting conversation evaluation'); + + const config = await getConversationEvaluationConfig(db)({ + tenantId, + conversationEvaluationConfigId, + }); + + if (!config) { + throw new Error( + `Conversation evaluation config not found: ${conversationEvaluationConfigId}` + ); + } + + if (!config.isActive) { + throw new Error( + `Conversation evaluation config is not active: ${conversationEvaluationConfigId}` + ); + } + + const evaluators = await getEvaluatorsForConfig(db)({ + tenantId, + conversationEvaluationConfigId, + }); + + if (evaluators.length === 0) { + throw new Error(`No evaluators found for config: ${conversationEvaluationConfigId}`); + } + + logger.info( + { tenantId, conversationEvaluationConfigId, evaluatorCount: evaluators.length }, + 'Found evaluators for config' + ); + + const conversations = await getConversationsForEvaluation(db)({ + scopes: { tenantId }, + filter: config.conversationFilter ?? undefined, + }); + + logger.info( + { tenantId, conversationEvaluationConfigId, conversationCount: conversations.length }, + 'Found conversations for evaluation' + ); + + let conversationsToEvaluate = conversations; + + if (config.sampleRate && config.sampleRate < 1 && conversations.length > 0) { + const sampleCount = Math.max(1, Math.floor(conversations.length * config.sampleRate)); + conversationsToEvaluate = conversations.sort(() => Math.random() - 0.5).slice(0, sampleCount); + + logger.info( + { tenantId, conversationEvaluationConfigId, sampleCount, totalCount: conversations.length }, + 'Applied sample rate to conversations' + ); + } + + const results: Array = []; + + for (const conversation of conversationsToEvaluate) { + for (const evaluator of evaluators) { + try { + logger.info( + { tenantId, conversationId: conversation.id, evaluatorId: evaluator.id }, + 'Running evaluation' + ); + + const evalResult = await createEvalResult(db)({ + tenantId, + projectId: conversation.projectId, + conversationId: conversation.id, + evaluatorId: evaluator.id, + status: 'pending', + }); + + try { + const evaluationResult = await executeEvaluation(db, { + conversation, + evaluator, + config, + tenantId, + projectId: conversation.projectId, + }); + + await updateEvalResult(db)({ + id: evalResult.id, + status: 'done', + reasoning: evaluationResult.reasoning, + metadata: evaluationResult.metadata, + }); + + const updatedResult = await updateEvalResult(db)({ + id: evalResult.id, + status: 'done', + reasoning: evaluationResult.reasoning, + metadata: evaluationResult.metadata, + }); + + if (updatedResult) { + results.push(updatedResult); + } + + logger.info( + { + tenantId, + conversationId: conversation.id, + evaluatorId: evaluator.id, + resultId: evalResult.id, + }, + 'Evaluation completed successfully' + ); + } catch (error) { + logger.error( + { + error, + tenantId, + conversationId: conversation.id, + evaluatorId: evaluator.id, + resultId: evalResult.id, + }, + 'Evaluation execution failed' + ); + + const errorMessage = error instanceof Error ? error.message : 'Unknown error'; + await updateEvalResult(db)({ + id: evalResult.id, + status: 'failed', + reasoning: `Evaluation failed: ${errorMessage}`, + metadata: { error: errorMessage }, + }); + + const failedResult = await updateEvalResult(db)({ + id: evalResult.id, + status: 'failed', + reasoning: `Evaluation failed: ${errorMessage}`, + metadata: { error: errorMessage }, + }); + + if (failedResult) { + results.push(failedResult); + } + } + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + const errorDetails = + error && typeof error === 'object' && 'cause' in error + ? (error.cause as { message?: string; code?: string }) + : null; + logger.error( + { + error: { + message: errorMessage, + details: errorDetails, + fullError: error, + }, + tenantId, + conversationId: conversation.id, + evaluatorId: evaluator.id, + }, + 'Failed to create or update eval result' + ); + } + } + } + + logger.info( + { tenantId, conversationEvaluationConfigId, resultCount: results.length }, + 'Conversation evaluation completed' + ); + + return results; + }; + +interface ExecuteEvaluationParams { + conversation: typeof import('@inkeep/agents-core').conversations.$inferSelect; + evaluator: typeof import('@inkeep/agents-core').evaluator.$inferSelect; + config: typeof import('@inkeep/agents-core').conversationEvaluationConfig.$inferSelect; + tenantId: string; + projectId: string; +} + +interface EvaluationResult { + reasoning: string; + metadata: Record; +} + +/** + * Execute an evaluation by calling the LLM with the evaluator prompt and conversation data + * Now includes agent definition and optionally trace in the evaluation context + */ +async function executeEvaluation( + db: DatabaseClient, + params: ExecuteEvaluationParams +): Promise { + const { conversation, evaluator, config, tenantId, projectId } = params; + + const conversationHistory = await getConversationHistory(db)({ + scopes: { tenantId, projectId }, + conversationId: conversation.id, + options: { + includeInternal: false, + limit: 100, + }, + }); + + let agentDefinition: FullAgentDefinition | null = null; + let agentId: string | null = null; + + try { + agentId = await getAgentIdFromConversation(db)({ + tenantId, + projectId, + activeSubAgentId: conversation.activeSubAgentId, + }); + + if (agentId) { + agentDefinition = await getFullAgent( + db, + logger + )({ + scopes: { tenantId, projectId, agentId }, + }); + } + } catch (error) { + logger.warn( + { error, conversationId: conversation.id, activeSubAgentId: conversation.activeSubAgentId }, + 'Failed to fetch agent definition for evaluation' + ); + } + + const prettifiedTrace = await fetchTraceFromSigNoz(conversation.id); + + const conversationText = JSON.stringify(conversationHistory, null, 2); + const agentDefinitionText = agentDefinition + ? JSON.stringify(agentDefinition, null, 2) + : 'Agent definition not available'; + const traceText = prettifiedTrace + ? JSON.stringify(prettifiedTrace, null, 2) + : 'Trace data not available'; + + const modelConfig: ModelSettings = (evaluator.modelConfig ?? + config.modelConfig ?? + {}) as ModelSettings; + + const evaluationPrompt = buildEvalInputEvaluationPrompt( + evaluator.prompt, + agentDefinitionText, + conversationText, + traceText, + evaluator.schema + ); + + const llmResponse = await callLLM({ + prompt: evaluationPrompt, + modelConfig, + schema: evaluator.schema, + }); + + return { + reasoning: llmResponse.reasoning || 'Evaluation completed', + metadata: { + ...llmResponse.result, + model: 'gpt-4o', + provider: 'openai', + conversationMessageCount: conversationHistory.length, + agentId, + hasAgentDefinition: !!agentDefinition, + hasTrace: !!prettifiedTrace, + traceActivityCount: prettifiedTrace?.timeline.length || 0, + }, + }; +} + +/** + * Get the language model for evaluations + * Using OpenAI GPT-4o for reliable structured outputs + */ +function getEvaluationModel(_config?: ModelSettings): LanguageModel { + // TODO: Support configurable models from ModelSettings + return openai('gpt-4o'); +} + +interface CallLLMParams { + prompt: string; + modelConfig: ModelSettings; + schema: Record; +} + +interface LLMResponse { + reasoning: string; + result: Record; +} + +/** + * Call LLM API using AI SDK's generateObject for structured output + */ +async function callLLM(params: CallLLMParams): Promise { + const { prompt, modelConfig, schema } = params; + + const languageModel = getEvaluationModel(modelConfig); + const providerOptions = modelConfig?.providerOptions || {}; + + // Convert JSON schema to Zod schema + const resultSchema = jsonSchemaToZod(schema); + + // Create the evaluation result schema with reasoning + const evaluationSchema = z.object({ + assessment: resultSchema, + reasoning: z.string().describe('Detailed reasoning for the evaluation'), + }); + + type EvaluationSchemaType = z.infer; + + try { + // Try generateObject first - this should work with proper schema + const result = await generateObject({ + model: languageModel, + schema: evaluationSchema, + prompt, + temperature: (providerOptions.temperature as number) ?? 0.3, + maxTokens: + (providerOptions.maxTokens as number) ?? (providerOptions.max_tokens as number) ?? 4096, + }); + + const typedResult = result.object as EvaluationSchemaType; + + return { + reasoning: typedResult.reasoning, + result: typedResult.assessment as Record, + }; + } catch (error) { + // Fallback to generateText with JSON parsing if generateObject fails + // This handles SDK schema conversion bugs + logger.warn( + { error: error instanceof Error ? error.message : String(error) }, + 'generateObject failed, falling back to generateText with JSON parsing' + ); + + const requiredFields = Array.isArray(schema.required) ? schema.required : []; + const schemaProperties = schema.properties || {}; + + const promptWithSchema = `${prompt} + +IMPORTANT: Return your response as a valid JSON object with this EXACT structure: +{ + "assessment": { + ${JSON.stringify(schemaProperties, null, 4).split('\n').slice(1, -1).join('\n')} + }, + "reasoning": "Your detailed reasoning explaining the evaluation" +} + +The "assessment" object must contain all required fields: ${requiredFields.join(', ')}.`; + + const result = await generateText({ + model: languageModel, + prompt: promptWithSchema, + temperature: (providerOptions.temperature as number) ?? 0.3, + maxTokens: + (providerOptions.maxTokens as number) ?? (providerOptions.max_tokens as number) ?? 4096, + }); + + // Clean up the response text (remove markdown code blocks if present) + const cleanedText = result.text + .replace(/^```json\s*/i, '') + .replace(/^```\s*/i, '') + .replace(/\s*```$/i, '') + .trim(); + + // Parse the JSON response + let parsedResult: any; + try { + parsedResult = JSON.parse(cleanedText); + } catch (parseError) { + throw new Error(`Failed to parse JSON response: ${parseError instanceof Error ? parseError.message : String(parseError)}`); + } + + // Handle case where LLM returns the schema directly without the wrapper + // If it has all the assessment fields but no "assessment" wrapper, wrap it + if (parsedResult.reasoning && !parsedResult.assessment) { + // Check if it has the assessment fields directly + const requiredFields = Array.isArray(schema.required) ? schema.required : []; + const hasAssessmentFields = requiredFields.length > 0 && requiredFields.every((field: string) => field in parsedResult); + if (hasAssessmentFields) { + parsedResult = { + assessment: Object.fromEntries( + Object.entries(parsedResult).filter(([key]) => key !== 'reasoning') + ), + reasoning: parsedResult.reasoning, + }; + } + } + + // Validate and return + const validatedResult = evaluationSchema.parse(parsedResult); + + return { + reasoning: validatedResult.reasoning, + result: validatedResult.assessment as Record, + }; + } +} + +interface RunDatasetEvalParams { + scopes: { tenantId: string }; + testSuiteConfigId: string; + datasetId: string; + agentId: string; + evaluatorIds: string[]; +} + +/** + * Run dataset evaluation based on a test suite config + * + * This function: + * 1. Fetches the test suite config + * 2. Creates an evalTestSuiteRun record + * 3. Gets all dataset items from the dataset + * 4. Gets the evaluators specified + * 5. For each dataset item: + * - Simulates running it through the agent + * - Runs each evaluator on the result + * - Creates eval results for each evaluation + */ +export const runDatasetEval = + (db: DatabaseClient) => + async ( + params: RunDatasetEvalParams + ): Promise> => { + const { scopes, testSuiteConfigId, datasetId, agentId, evaluatorIds } = params; + const { tenantId } = scopes; + + logger.info({ tenantId, testSuiteConfigId, datasetId, agentId }, 'Starting dataset evaluation'); + + // Fetch agent to get projectId + const agent = await db.query.agents.findFirst({ + where: and(eq(agents.tenantId, tenantId), eq(agents.id, agentId)), + }); + + if (!agent) { + throw new Error(`Agent not found: ${agentId}`); + } + + const projectId = agent.projectId; + + const dataset = await getDataset(db)({ tenantId, datasetId }); + if (!dataset) { + throw new Error(`Dataset not found: ${datasetId}`); + } + + const datasetItems = await listDatasetItems(db)({ datasetId }); + if (datasetItems.length === 0) { + throw new Error(`No dataset items found for dataset: ${datasetId}`); + } + + logger.info( + { tenantId, testSuiteConfigId, datasetId, itemCount: datasetItems.length }, + 'Found dataset items for evaluation' + ); + + const results: Array = []; + + for (const datasetItem of datasetItems) { + for (const evaluatorId of evaluatorIds) { + try { + logger.info( + { tenantId, datasetItemId: datasetItem.id, evaluatorId }, + 'Running dataset item evaluation' + ); + + const evalResult = await createEvalResult(db)({ + tenantId, + projectId, + conversationId: `dataset_eval_${datasetItem.id}`, + evaluatorId, + status: 'pending', + datasetItemId: datasetItem.id, + }); + + try { + const evaluationResult = await executeDatasetItemEvaluation(db, { + datasetItem, + evaluatorId, + tenantId, + }); + + const updatedResult = await updateEvalResult(db)({ + id: evalResult.id, + status: 'done', + reasoning: evaluationResult.reasoning, + metadata: evaluationResult.metadata, + }); + + if (updatedResult) { + results.push(updatedResult); + } + + logger.info( + { + tenantId, + datasetItemId: datasetItem.id, + evaluatorId, + resultId: evalResult.id, + }, + 'Dataset item evaluation completed successfully' + ); + } catch (error) { + logger.error( + { + error, + tenantId, + datasetItemId: datasetItem.id, + evaluatorId, + resultId: evalResult.id, + }, + 'Dataset item evaluation failed' + ); + + const errorMessage = error instanceof Error ? error.message : 'Unknown error'; + const failedResult = await updateEvalResult(db)({ + id: evalResult.id, + status: 'failed', + reasoning: `Evaluation failed: ${errorMessage}`, + metadata: { error: errorMessage }, + }); + + if (failedResult) { + results.push(failedResult); + } + } + } catch (error) { + logger.error( + { error, tenantId, datasetItemId: datasetItem.id, evaluatorId }, + 'Failed to create or update eval result for dataset item' + ); + } + } + } + + logger.info( + { tenantId, testSuiteConfigId, datasetId, resultCount: results.length }, + 'Dataset evaluation completed' + ); + + return results; + }; + +interface ExecuteDatasetItemEvaluationParams { + datasetItem: typeof import('@inkeep/agents-core').datasetItem.$inferSelect; + evaluatorId: string; + tenantId: string; +} + +/** + * Execute an evaluation on a dataset item + */ +async function executeDatasetItemEvaluation( + db: DatabaseClient, + params: ExecuteDatasetItemEvaluationParams +): Promise { + const { datasetItem, evaluatorId, tenantId } = params; + + const evaluator = await db.query.evaluator.findFirst({ + where: (t, { eq, and }) => and(eq(t.tenantId, tenantId), eq(t.id, evaluatorId)), + }); + + if (!evaluator) { + throw new Error(`Evaluator not found: ${evaluatorId}`); + } + + const inputText = formatDatasetItemInput(datasetItem); + const expectedOutputText = formatDatasetItemExpectedOutput(datasetItem); + + const modelConfig: ModelSettings = (evaluator.modelConfig ?? {}) as ModelSettings; + + const evaluationPrompt = buildDatasetItemEvaluationPrompt( + evaluator.prompt, + inputText, + expectedOutputText, + evaluator.schema + ); + + const llmResponse = await callLLM({ + prompt: evaluationPrompt, + modelConfig, + schema: evaluator.schema, + }); + + return { + reasoning: llmResponse.reasoning || 'Evaluation completed', + metadata: { + ...llmResponse.result, + model: 'gpt-4o', + provider: 'openai', + datasetItemId: datasetItem.id, + }, + }; +} + +/** + * Format dataset item input for evaluation prompt + */ +function formatDatasetItemInput(datasetItem: any): string { + if (!datasetItem.input) { + return 'No input provided'; + } + + if (typeof datasetItem.input === 'string') { + return datasetItem.input; + } + + if (datasetItem.input.messages) { + return datasetItem.input.messages + .map((msg: any) => { + const role = msg.role === 'user' ? 'User' : 'Assistant'; + const content = + typeof msg.content === 'string' + ? msg.content + : msg.content?.text || JSON.stringify(msg.content); + return `${role}: ${content}`; + }) + .join('\n\n'); + } + + return JSON.stringify(datasetItem.input, null, 2); +} + +/** + * Format dataset item expected output for evaluation prompt + */ +function formatDatasetItemExpectedOutput(datasetItem: any): string { + if (!datasetItem.expectedOutput) { + return 'No expected output provided'; + } + + if (typeof datasetItem.expectedOutput === 'string') { + return datasetItem.expectedOutput; + } + + if (Array.isArray(datasetItem.expectedOutput)) { + return datasetItem.expectedOutput + .map((msg: any) => { + const role = msg.role === 'user' ? 'User' : 'Assistant'; + const content = + typeof msg.content === 'string' + ? msg.content + : msg.content?.text || JSON.stringify(msg.content); + return `${role}: ${content}`; + }) + .join('\n\n'); + } + + return JSON.stringify(datasetItem.expectedOutput, null, 2); +} + +/** + * Build the evaluation prompt for a dataset item + */ +function buildDatasetItemEvaluationPrompt( + evaluatorPrompt: string, + inputText: string, + expectedOutputText: string, + schema: Record +): string { + const schemaDescription = JSON.stringify(schema, null, 2); + + return `${evaluatorPrompt} + +Input: +${inputText} + +Expected Output: +${expectedOutputText} + +Please evaluate this dataset item according to the following schema and return your evaluation as JSON: +${schemaDescription} + +Return your evaluation as a JSON object matching the schema above. Include a "reasoning" field explaining your evaluation.`; +} + +function buildEvalInputEvaluationPrompt( + evaluatorPrompt: string, + agentDefinitionText: string, + conversationText: string, + traceText: string, + schema: Record +): string { + const schemaDescription = JSON.stringify(schema, null, 2); + + return `${evaluatorPrompt} + +Agent Definition: +${agentDefinitionText} + +Conversation History: +${conversationText} + +Execution Trace: +${traceText} + +Please evaluate this conversation according to the following schema and return your evaluation as JSON: +${schemaDescription} + +Return your evaluation as a JSON object matching the schema above. Include a "reasoning" field explaining your evaluation.`; +} diff --git a/agents-manage-ui/src/app/[tenantId]/evaluations/datasets/page.tsx b/agents-manage-ui/src/app/[tenantId]/evaluations/datasets/page.tsx new file mode 100644 index 000000000..86351041f --- /dev/null +++ b/agents-manage-ui/src/app/[tenantId]/evaluations/datasets/page.tsx @@ -0,0 +1,53 @@ +import { Database } from 'lucide-react'; +import FullPageError from '@/components/errors/full-page-error'; +import { DatasetsList } from '@/components/evaluations/datasets-list'; +import { BodyTemplate } from '@/components/layout/body-template'; +import EmptyState from '@/components/layout/empty-state'; +import { MainContent } from '@/components/layout/main-content'; +import { PageHeader } from '@/components/layout/page-header'; +import { fetchDatasets } from '@/lib/api/evaluations-client'; + +export const dynamic = 'force-dynamic'; + +async function DatasetsPage({ params }: PageProps<'/[tenantId]/evaluations/datasets'>) { + const { tenantId } = await params; + + let datasets: Awaited>; + try { + datasets = await fetchDatasets(tenantId); + } catch (error) { + return ; + } + + return ( + + + {datasets.data.length > 0 ? ( + <> + + + + ) : ( + } + /> + )} + + + ); +} + +export default DatasetsPage; + diff --git a/agents-manage-ui/src/app/[tenantId]/evaluations/evaluators/page.tsx b/agents-manage-ui/src/app/[tenantId]/evaluations/evaluators/page.tsx new file mode 100644 index 000000000..6e3fbe9ca --- /dev/null +++ b/agents-manage-ui/src/app/[tenantId]/evaluations/evaluators/page.tsx @@ -0,0 +1,53 @@ +import { FlaskConical } from 'lucide-react'; +import FullPageError from '@/components/errors/full-page-error'; +import { EvaluatorsList } from '@/components/evaluations/evaluators-list'; +import { BodyTemplate } from '@/components/layout/body-template'; +import EmptyState from '@/components/layout/empty-state'; +import { MainContent } from '@/components/layout/main-content'; +import { PageHeader } from '@/components/layout/page-header'; +import { fetchEvaluators } from '@/lib/api/evaluations-client'; + +export const dynamic = 'force-dynamic'; + +async function EvaluatorsPage({ params }: PageProps<'/[tenantId]/evaluations/evaluators'>) { + const { tenantId } = await params; + + let evaluators: Awaited>; + try { + evaluators = await fetchEvaluators(tenantId); + } catch (error) { + return ; + } + + return ( + + + {evaluators.data.length > 0 ? ( + <> + + + + ) : ( + } + /> + )} + + + ); +} + +export default EvaluatorsPage; + diff --git a/agents-manage-ui/src/app/[tenantId]/evaluations/page.tsx b/agents-manage-ui/src/app/[tenantId]/evaluations/page.tsx new file mode 100644 index 000000000..ff7e13e87 --- /dev/null +++ b/agents-manage-ui/src/app/[tenantId]/evaluations/page.tsx @@ -0,0 +1,76 @@ +import { ClipboardList, Database, FlaskConical } from 'lucide-react'; +import Link from 'next/link'; +import { BodyTemplate } from '@/components/layout/body-template'; +import { MainContent } from '@/components/layout/main-content'; +import { PageHeader } from '@/components/layout/page-header'; +import { Button } from '@/components/ui/button'; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; + +export const dynamic = 'force-dynamic'; + +async function EvaluationsPage({ params }: PageProps<'/[tenantId]/evaluations'>) { + const { tenantId } = await params; + + return ( + + + + +
+ + +
+ + Evaluators +
+ + Create and manage evaluators to assess agent performance + +
+ + + + + +
+ + + +
+ + Datasets +
+ Create and manage test datasets for evaluations +
+ + + + + +
+ + + +
+ + Test Suites +
+ Configure automated test suite runs and schedules +
+ + + + + +
+
+
+
+ ); +} + +export default EvaluationsPage; + diff --git a/agents-manage-ui/src/app/[tenantId]/evaluations/test-suites/page.tsx b/agents-manage-ui/src/app/[tenantId]/evaluations/test-suites/page.tsx new file mode 100644 index 000000000..6b62cc490 --- /dev/null +++ b/agents-manage-ui/src/app/[tenantId]/evaluations/test-suites/page.tsx @@ -0,0 +1,53 @@ +import { ClipboardList } from 'lucide-react'; +import FullPageError from '@/components/errors/full-page-error'; +import { TestSuitesList } from '@/components/evaluations/test-suites-list'; +import { BodyTemplate } from '@/components/layout/body-template'; +import EmptyState from '@/components/layout/empty-state'; +import { MainContent } from '@/components/layout/main-content'; +import { PageHeader } from '@/components/layout/page-header'; +import { fetchEvalTestSuiteConfigs } from '@/lib/api/evaluations-client'; + +export const dynamic = 'force-dynamic'; + +async function TestSuitesPage({ params }: PageProps<'/[tenantId]/evaluations/test-suites'>) { + const { tenantId } = await params; + + let testSuites: Awaited>; + try { + testSuites = await fetchEvalTestSuiteConfigs(tenantId); + } catch (error) { + return ; + } + + return ( + + + {testSuites.data.length > 0 ? ( + <> + + + + ) : ( + } + /> + )} + + + ); +} + +export default TestSuitesPage; + diff --git a/agents-manage-ui/src/components/evaluations/dataset-item.tsx b/agents-manage-ui/src/components/evaluations/dataset-item.tsx new file mode 100644 index 000000000..e08c42391 --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/dataset-item.tsx @@ -0,0 +1,38 @@ +import Link from 'next/link'; +import { formatDate } from '@/app/utils/format-date'; +import type { Dataset } from '@/lib/api/evaluations-client'; +import { + ItemCardContent, + ItemCardDescription, + ItemCardFooter, + ItemCardHeader, + ItemCardLink, + ItemCardRoot, + ItemCardTitle, +} from '../ui/item-card'; + +interface DatasetItemProps extends Dataset { + tenantId: string; +} + +export function DatasetItem({ id, name, description, createdAt, tenantId }: DatasetItemProps) { + const href = `/${tenantId}/evaluations/datasets/${id}`; + + return ( + + + + {name} + + + + + + {description || 'No description'} + + + + + + ); +} diff --git a/agents-manage-ui/src/components/evaluations/datasets-list.tsx b/agents-manage-ui/src/components/evaluations/datasets-list.tsx new file mode 100644 index 000000000..565350e83 --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/datasets-list.tsx @@ -0,0 +1,20 @@ +import type { Dataset } from '@/lib/api/evaluations-client'; +import { DatasetItem } from './dataset-item'; +import { NewDatasetItem } from './new-dataset-item'; + +interface DatasetsListProps { + tenantId: string; + datasets: Dataset[]; +} + +export function DatasetsList({ tenantId, datasets }: DatasetsListProps) { + return ( +
+ + {datasets?.map((dataset: Dataset) => ( + + ))} +
+ ); +} + diff --git a/agents-manage-ui/src/components/evaluations/evaluator-item.tsx b/agents-manage-ui/src/components/evaluations/evaluator-item.tsx new file mode 100644 index 000000000..d253d0b9d --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/evaluator-item.tsx @@ -0,0 +1,38 @@ +import Link from 'next/link'; +import { formatDate } from '@/app/utils/format-date'; +import type { Evaluator } from '@/lib/api/evaluations-client'; +import { + ItemCardContent, + ItemCardDescription, + ItemCardFooter, + ItemCardHeader, + ItemCardLink, + ItemCardRoot, + ItemCardTitle, +} from '../ui/item-card'; + +interface EvaluatorItemProps extends Evaluator { + tenantId: string; +} + +export function EvaluatorItem({ id, name, description, createdAt, tenantId }: EvaluatorItemProps) { + const href = `/${tenantId}/evaluations/evaluators/${id}`; + + return ( + + + + {name} + + + + + + {description || 'No description'} + + + + + + ); +} diff --git a/agents-manage-ui/src/components/evaluations/evaluators-list.tsx b/agents-manage-ui/src/components/evaluations/evaluators-list.tsx new file mode 100644 index 000000000..d2be62071 --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/evaluators-list.tsx @@ -0,0 +1,20 @@ +import type { Evaluator } from '@/lib/api/evaluations-client'; +import { EvaluatorItem } from './evaluator-item'; +import { NewEvaluatorItem } from './new-evaluator-item'; + +interface EvaluatorsListProps { + tenantId: string; + evaluators: Evaluator[]; +} + +export function EvaluatorsList({ tenantId, evaluators }: EvaluatorsListProps) { + return ( +
+ + {evaluators?.map((evaluator: Evaluator) => ( + + ))} +
+ ); +} + diff --git a/agents-manage-ui/src/components/evaluations/new-dataset-item.tsx b/agents-manage-ui/src/components/evaluations/new-dataset-item.tsx new file mode 100644 index 000000000..96518b69a --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/new-dataset-item.tsx @@ -0,0 +1,38 @@ +import { Plus } from 'lucide-react'; +import Link from 'next/link'; +import { + ItemCardContent, + ItemCardDescription, + ItemCardHeader, + ItemCardLink, + ItemCardRoot, + ItemCardTitle, +} from '../ui/item-card'; + +interface NewDatasetItemProps { + tenantId: string; +} + +export function NewDatasetItem({ tenantId }: NewDatasetItemProps) { + const href = `/${tenantId}/evaluations/datasets/new`; + + return ( + + + +
+ + New Dataset +
+
+
+ + + + Create a new dataset with test cases + + + +
+ ); +} diff --git a/agents-manage-ui/src/components/evaluations/new-evaluator-item.tsx b/agents-manage-ui/src/components/evaluations/new-evaluator-item.tsx new file mode 100644 index 000000000..ce9c7b7ef --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/new-evaluator-item.tsx @@ -0,0 +1,38 @@ +import { Plus } from 'lucide-react'; +import Link from 'next/link'; +import { + ItemCardContent, + ItemCardDescription, + ItemCardHeader, + ItemCardLink, + ItemCardRoot, + ItemCardTitle, +} from '../ui/item-card'; + +interface NewEvaluatorItemProps { + tenantId: string; +} + +export function NewEvaluatorItem({ tenantId }: NewEvaluatorItemProps) { + const href = `/${tenantId}/evaluations/evaluators/new`; + + return ( + + + +
+ + New Evaluator +
+
+
+ + + + Create a new evaluator to assess agent performance + + + +
+ ); +} diff --git a/agents-manage-ui/src/components/evaluations/new-test-suite-item.tsx b/agents-manage-ui/src/components/evaluations/new-test-suite-item.tsx new file mode 100644 index 000000000..8b2104372 --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/new-test-suite-item.tsx @@ -0,0 +1,38 @@ +import { Plus } from 'lucide-react'; +import Link from 'next/link'; +import { + ItemCardContent, + ItemCardDescription, + ItemCardHeader, + ItemCardLink, + ItemCardRoot, + ItemCardTitle, +} from '../ui/item-card'; + +interface NewTestSuiteItemProps { + tenantId: string; +} + +export function NewTestSuiteItem({ tenantId }: NewTestSuiteItemProps) { + const href = `/${tenantId}/evaluations/test-suites/new`; + + return ( + + + +
+ + New Test Suite +
+
+
+ + + + Create a new test suite configuration + + + +
+ ); +} diff --git a/agents-manage-ui/src/components/evaluations/test-suite-item.tsx b/agents-manage-ui/src/components/evaluations/test-suite-item.tsx new file mode 100644 index 000000000..8d89e5868 --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/test-suite-item.tsx @@ -0,0 +1,45 @@ +import Link from 'next/link'; +import { formatDate } from '@/app/utils/format-date'; +import type { EvalTestSuiteConfig } from '@/lib/api/evaluations-client'; +import { + ItemCardContent, + ItemCardDescription, + ItemCardFooter, + ItemCardHeader, + ItemCardLink, + ItemCardRoot, + ItemCardTitle, +} from '../ui/item-card'; + +interface TestSuiteItemProps extends EvalTestSuiteConfig { + tenantId: string; +} + +export function TestSuiteItem({ + id, + name, + description, + runFrequency, + createdAt, + tenantId, +}: TestSuiteItemProps) { + const href = `/${tenantId}/evaluations/test-suites/${id}`; + + return ( + + + + {name} + + + + + + {description || 'No description'} + + + + + + ); +} diff --git a/agents-manage-ui/src/components/evaluations/test-suites-list.tsx b/agents-manage-ui/src/components/evaluations/test-suites-list.tsx new file mode 100644 index 000000000..3da890932 --- /dev/null +++ b/agents-manage-ui/src/components/evaluations/test-suites-list.tsx @@ -0,0 +1,19 @@ +import type { EvalTestSuiteConfig } from '@/lib/api/evaluations-client'; +import { NewTestSuiteItem } from './new-test-suite-item'; +import { TestSuiteItem } from './test-suite-item'; + +interface TestSuitesListProps { + tenantId: string; + testSuites: EvalTestSuiteConfig[]; +} + +export function TestSuitesList({ tenantId, testSuites }: TestSuitesListProps) { + return ( +
+ + {testSuites?.map((suite: EvalTestSuiteConfig) => ( + + ))} +
+ ); +} diff --git a/agents-manage-ui/src/components/sidebar-nav/sidebar-nav.tsx b/agents-manage-ui/src/components/sidebar-nav/sidebar-nav.tsx index 1eb7230a9..f2fb52d0f 100644 --- a/agents-manage-ui/src/components/sidebar-nav/sidebar-nav.tsx +++ b/agents-manage-ui/src/components/sidebar-nav/sidebar-nav.tsx @@ -4,6 +4,7 @@ import { Activity, BookOpen, Component, + FlaskConical, Globe, Key, Layers, @@ -85,6 +86,11 @@ export function AppSidebar({ ...props }: React.ComponentProps) { url: `/${tenantId}/projects/${projectId}/traces`, icon: Activity, }, + { + title: 'Evaluations', + url: `/${tenantId}/evaluations`, + icon: FlaskConical, + }, { title: 'Components', url: `/${tenantId}/projects/${projectId}/components`, @@ -107,6 +113,11 @@ export function AppSidebar({ ...props }: React.ComponentProps) { url: `/${tenantId}/projects`, icon: Layers, }, + { + title: 'Evaluations', + url: `/${tenantId}/evaluations`, + icon: FlaskConical, + }, ]; return ( diff --git a/agents-manage-ui/src/lib/api/evaluations-client.ts b/agents-manage-ui/src/lib/api/evaluations-client.ts new file mode 100644 index 000000000..6f0ee968c --- /dev/null +++ b/agents-manage-ui/src/lib/api/evaluations-client.ts @@ -0,0 +1,171 @@ +import type { ListResponse } from '../types/response'; +import { makeManagementApiRequest } from './api-config'; +import { validateTenantId } from './resource-validation'; + +export interface Evaluator { + tenantId: string; + id: string; + name: string; + description: string | null; + prompt: string; + schema: Record; + modelConfig: Record | null; + createdAt: string; + updatedAt: string; +} + +export interface Dataset { + tenantId: string; + id: string; + name: string; + description: string; + metadata: Record | null; + createdAt: string; + updatedAt: string; +} + +export interface DatasetItem { + id: string; + datasetId: string; + input: unknown; + expectedOutput: unknown | null; + simulationConfig: unknown | null; + createdAt: string; + updatedAt: string; +} + +export interface ConversationEvaluationConfig { + tenantId: string; + id: string; + name: string; + description: string; + conversationFilter: { + agentIds?: string[]; + projectIds?: string[]; + dateRange?: { startDate: string; endDate: string }; + conversationIds?: string[]; + } | null; + modelConfig: Record | null; + sampleRate: number | null; + isActive: boolean; + createdAt: string; + updatedAt: string; +} + +export interface EvalTestSuiteConfig { + tenantId: string; + id: string; + name: string; + description: string; + modelConfig: Record | null; + runFrequency: string; + createdAt: string; + updatedAt: string; +} + +export interface EvalResult { + id: string; + suiteRunId: string | null; + datasetItemId: string | null; + conversationId: string; + status: 'pending' | 'done' | 'failed'; + evaluatorId: string; + reasoning: string | null; + metadata: Record | null; + createdAt: string; + updatedAt: string; +} + +export async function fetchEvaluators(tenantId: string): Promise> { + validateTenantId(tenantId); + return makeManagementApiRequest>( + `tenants/${tenantId}/evaluations/evaluators` + ); +} + +export async function fetchDatasets(tenantId: string): Promise> { + validateTenantId(tenantId); + return makeManagementApiRequest>( + `tenants/${tenantId}/evaluations/datasets` + ); +} + +export async function fetchDataset(tenantId: string, datasetId: string): Promise<{ data: Dataset }> { + validateTenantId(tenantId); + return makeManagementApiRequest<{ data: Dataset }>( + `tenants/${tenantId}/evaluations/datasets/${datasetId}` + ); +} + +export async function fetchDatasetItems(datasetId: string): Promise> { + return makeManagementApiRequest>( + `tenants/*/evaluations/datasets/${datasetId}/items` + ); +} + +export async function fetchConversationEvaluationConfigs( + tenantId: string +): Promise> { + validateTenantId(tenantId); + return makeManagementApiRequest>( + `tenants/${tenantId}/evaluations/configs` + ); +} + +export async function fetchEvalTestSuiteConfigs( + tenantId: string +): Promise> { + validateTenantId(tenantId); + return makeManagementApiRequest>( + `tenants/${tenantId}/evaluations/test-suite-configs` + ); +} + +export async function createDataset( + tenantId: string, + data: { name: string; description?: string; metadata?: Record } +): Promise<{ data: Dataset }> { + validateTenantId(tenantId); + return makeManagementApiRequest<{ data: Dataset }>( + `tenants/${tenantId}/evaluations/datasets`, + { + method: 'POST', + body: JSON.stringify(data), + } + ); +} + +export async function deleteDataset(tenantId: string, datasetId: string): Promise { + validateTenantId(tenantId); + await makeManagementApiRequest(`tenants/${tenantId}/evaluations/datasets/${datasetId}`, { + method: 'DELETE', + }); +} + +export async function createEvaluator( + tenantId: string, + data: { + name: string; + description?: string; + prompt: string; + schema: Record; + modelConfig?: Record; + } +): Promise<{ data: Evaluator }> { + validateTenantId(tenantId); + return makeManagementApiRequest<{ data: Evaluator }>( + `tenants/${tenantId}/evaluations/evaluators`, + { + method: 'POST', + body: JSON.stringify(data), + } + ); +} + +export async function deleteEvaluator(tenantId: string, evaluatorId: string): Promise { + validateTenantId(tenantId); + await makeManagementApiRequest(`tenants/${tenantId}/evaluations/evaluators/${evaluatorId}`, { + method: 'DELETE', + }); +} + diff --git a/agents-run-api/src/utils/data-component-schema.ts b/agents-run-api/src/utils/data-component-schema.ts index e3298f9a2..57105613c 100644 --- a/agents-run-api/src/utils/data-component-schema.ts +++ b/agents-run-api/src/utils/data-component-schema.ts @@ -1,55 +1,2 @@ -import { z } from 'zod'; -import { getLogger } from '../logger'; - -const logger = getLogger('DataComponentSchema'); - -/** - * Converts JSON Schema objects to Zod schema types - */ -export function jsonSchemaToZod(jsonSchema: any): z.ZodType { - if (!jsonSchema || typeof jsonSchema !== 'object') { - logger.warn({ jsonSchema }, 'Invalid JSON schema provided, using string fallback'); - return z.string(); - } - - switch (jsonSchema.type) { - case 'object': - if (jsonSchema.properties) { - const shape: Record> = {}; - for (const [key, prop] of Object.entries(jsonSchema.properties)) { - shape[key] = jsonSchemaToZod(prop); - } - return z.object(shape); - } - return z.record(z.string(), z.unknown()); - - case 'array': { - const itemSchema = jsonSchema.items ? jsonSchemaToZod(jsonSchema.items) : z.unknown(); - return z.array(itemSchema); - } - - case 'string': - return z.string(); - - case 'number': - case 'integer': - return z.number(); - - case 'boolean': - return z.boolean(); - - case 'null': - return z.null(); - - default: - // Log unsupported types for monitoring - logger.warn( - { - unsupportedType: jsonSchema.type, - schema: jsonSchema, - }, - 'Unsupported JSON schema type, using unknown validation' - ); - return z.unknown(); - } -} +// Re-export from agents-core for backwards compatibility +export { jsonSchemaToZod } from '@inkeep/agents-core'; diff --git a/packages/agents-core/drizzle/0015_yielding_natasha_romanoff.sql b/packages/agents-core/drizzle/0015_yielding_natasha_romanoff.sql new file mode 100644 index 000000000..66364af88 --- /dev/null +++ b/packages/agents-core/drizzle/0015_yielding_natasha_romanoff.sql @@ -0,0 +1,111 @@ +CREATE TABLE `conversation_evaluation_config` ( + `tenant_id` text NOT NULL, + `id` text NOT NULL, + `name` text NOT NULL, + `description` text NOT NULL, + `conversation_filter` blob, + `model_config` blob, + `sample_rate` real, + `is_active` integer NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + PRIMARY KEY(`tenant_id`, `id`) +); +--> statement-breakpoint +CREATE TABLE `conversation_evaluation_config_evaluator` ( + `id` text PRIMARY KEY NOT NULL, + `conversation_evaluation_config_id` text NOT NULL, + `evaluator_id` text NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`conversation_evaluation_config_id`) REFERENCES `conversation_evaluation_config`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`evaluator_id`) REFERENCES `evaluator`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +CREATE TABLE `dataset` ( + `tenant_id` text NOT NULL, + `id` text NOT NULL, + `name` text NOT NULL, + `description` text NOT NULL, + `metadata` blob, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + PRIMARY KEY(`tenant_id`, `id`) +); +--> statement-breakpoint +CREATE TABLE `dataset_item` ( + `id` text PRIMARY KEY NOT NULL, + `dataset_id` text NOT NULL, + `input` blob, + `expected_output` blob, + `simulation_config` blob, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`dataset_id`) REFERENCES `dataset`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +CREATE TABLE `eval_result` ( + `id` text PRIMARY KEY NOT NULL, + `suite_run_id` text, + `dataset_item_id` text, + `conversation_id` text NOT NULL, + `status` text NOT NULL, + `evaluator_id` text NOT NULL, + `reasoning` text, + `metadata` blob, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`evaluator_id`) REFERENCES `evaluator`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`dataset_item_id`) REFERENCES `dataset_item`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +CREATE TABLE `eval_test_suite_config` ( + `tenant_id` text NOT NULL, + `id` text NOT NULL, + `name` text NOT NULL, + `description` text NOT NULL, + `model_config` blob, + `run_frequency` text NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + PRIMARY KEY(`tenant_id`, `id`) +); +--> statement-breakpoint +CREATE TABLE `eval_test_suite_run` ( + `id` text PRIMARY KEY NOT NULL, + `name` text NOT NULL, + `description` text NOT NULL, + `dataset_id` text NOT NULL, + `agent_id` text NOT NULL, + `test_suite_config_id` text NOT NULL, + `status` text NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`dataset_id`) REFERENCES `dataset`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`agent_id`) REFERENCES `agent`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`test_suite_config_id`) REFERENCES `eval_test_suite_config`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +CREATE TABLE `eval_test_suite_run_evaluators` ( + `id` text PRIMARY KEY NOT NULL, + `eval_test_suite_run_id` text NOT NULL, + `evaluator_id` text NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`eval_test_suite_run_id`) REFERENCES `eval_test_suite_run`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`evaluator_id`) REFERENCES `evaluator`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +CREATE TABLE `evaluator` ( + `tenant_id` text NOT NULL, + `id` text NOT NULL, + `name` text NOT NULL, + `description` text NOT NULL, + `prompt` text NOT NULL, + `schema` blob NOT NULL, + `model_config` blob, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + PRIMARY KEY(`tenant_id`, `id`) +); diff --git a/packages/agents-core/drizzle/0016_yellow_pretty_boy.sql b/packages/agents-core/drizzle/0016_yellow_pretty_boy.sql new file mode 100644 index 000000000..afb63a9a0 --- /dev/null +++ b/packages/agents-core/drizzle/0016_yellow_pretty_boy.sql @@ -0,0 +1,82 @@ +PRAGMA foreign_keys=OFF;--> statement-breakpoint +CREATE TABLE `__new_conversation_evaluation_config_evaluator` ( + `id` text PRIMARY KEY NOT NULL, + `conversation_evaluation_config_id` text NOT NULL, + `tenant_id` text NOT NULL, + `evaluator_id` text NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`conversation_evaluation_config_id`) REFERENCES `conversation_evaluation_config`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`tenant_id`,`evaluator_id`) REFERENCES `evaluator`(`tenant_id`,`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +INSERT INTO `__new_conversation_evaluation_config_evaluator`("id", "conversation_evaluation_config_id", "tenant_id", "evaluator_id", "created_at", "updated_at") +SELECT + cece.id, + cece.conversation_evaluation_config_id, + cec.tenant_id, + cece.evaluator_id, + cece.created_at, + cece.updated_at +FROM `conversation_evaluation_config_evaluator` cece +JOIN `conversation_evaluation_config` cec ON cece.conversation_evaluation_config_id = cec.id;--> statement-breakpoint +DROP TABLE `conversation_evaluation_config_evaluator`;--> statement-breakpoint +ALTER TABLE `__new_conversation_evaluation_config_evaluator` RENAME TO `conversation_evaluation_config_evaluator`;--> statement-breakpoint +PRAGMA foreign_keys=ON;--> statement-breakpoint +CREATE TABLE `__new_eval_result` ( + `id` text PRIMARY KEY NOT NULL, + `suite_run_id` text, + `dataset_item_id` text, + `conversation_id` text NOT NULL, + `status` text NOT NULL, + `tenant_id` text NOT NULL, + `evaluator_id` text NOT NULL, + `reasoning` text, + `metadata` blob, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`conversation_id`) REFERENCES `conversations`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`tenant_id`,`evaluator_id`) REFERENCES `evaluator`(`tenant_id`,`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`dataset_item_id`) REFERENCES `dataset_item`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +INSERT INTO `__new_eval_result`("id", "suite_run_id", "dataset_item_id", "conversation_id", "status", "tenant_id", "evaluator_id", "reasoning", "metadata", "created_at", "updated_at") +SELECT + er.id, + er.suite_run_id, + er.dataset_item_id, + er.conversation_id, + er.status, + c.tenant_id, + er.evaluator_id, + er.reasoning, + er.metadata, + er.created_at, + er.updated_at +FROM `eval_result` er +JOIN `conversations` c ON er.conversation_id = c.id;--> statement-breakpoint +DROP TABLE `eval_result`;--> statement-breakpoint +ALTER TABLE `__new_eval_result` RENAME TO `eval_result`;--> statement-breakpoint +CREATE TABLE `__new_eval_test_suite_run_evaluators` ( + `id` text PRIMARY KEY NOT NULL, + `eval_test_suite_run_id` text NOT NULL, + `tenant_id` text NOT NULL, + `evaluator_id` text NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`eval_test_suite_run_id`) REFERENCES `eval_test_suite_run`(`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`tenant_id`,`evaluator_id`) REFERENCES `evaluator`(`tenant_id`,`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +INSERT INTO `__new_eval_test_suite_run_evaluators`("id", "eval_test_suite_run_id", "tenant_id", "evaluator_id", "created_at", "updated_at") +SELECT + etsre.id, + etsre.eval_test_suite_run_id, + e.tenant_id, + etsre.evaluator_id, + etsre.created_at, + etsre.updated_at +FROM `eval_test_suite_run_evaluators` etsre +JOIN `evaluator` e ON etsre.evaluator_id = e.id;--> statement-breakpoint +DROP TABLE `eval_test_suite_run_evaluators`;--> statement-breakpoint +ALTER TABLE `__new_eval_test_suite_run_evaluators` RENAME TO `eval_test_suite_run_evaluators`; \ No newline at end of file diff --git a/packages/agents-core/drizzle/0017_colossal_kate_bishop.sql b/packages/agents-core/drizzle/0017_colossal_kate_bishop.sql new file mode 100644 index 000000000..1fce15ce7 --- /dev/null +++ b/packages/agents-core/drizzle/0017_colossal_kate_bishop.sql @@ -0,0 +1,25 @@ +PRAGMA foreign_keys=OFF;--> statement-breakpoint +CREATE TABLE `__new_conversation_evaluation_config_evaluator` ( + `id` text PRIMARY KEY NOT NULL, + `conversation_evaluation_config_id` text NOT NULL, + `tenant_id` text NOT NULL, + `evaluator_id` text NOT NULL, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`tenant_id`,`conversation_evaluation_config_id`) REFERENCES `conversation_evaluation_config`(`tenant_id`,`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`tenant_id`,`evaluator_id`) REFERENCES `evaluator`(`tenant_id`,`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +INSERT INTO `__new_conversation_evaluation_config_evaluator`("id", "conversation_evaluation_config_id", "tenant_id", "evaluator_id", "created_at", "updated_at") +SELECT + cece.id, + cece.conversation_evaluation_config_id, + cec.tenant_id, + cece.evaluator_id, + cece.created_at, + cece.updated_at +FROM `conversation_evaluation_config_evaluator` cece +JOIN `conversation_evaluation_config` cec ON cece.conversation_evaluation_config_id = cec.id;--> statement-breakpoint +DROP TABLE `conversation_evaluation_config_evaluator`;--> statement-breakpoint +ALTER TABLE `__new_conversation_evaluation_config_evaluator` RENAME TO `conversation_evaluation_config_evaluator`;--> statement-breakpoint +PRAGMA foreign_keys=ON; \ No newline at end of file diff --git a/packages/agents-core/drizzle/0018_calm_ultimo.sql b/packages/agents-core/drizzle/0018_calm_ultimo.sql new file mode 100644 index 000000000..ccaabc02a --- /dev/null +++ b/packages/agents-core/drizzle/0018_calm_ultimo.sql @@ -0,0 +1,40 @@ +PRAGMA foreign_keys=OFF;--> statement-breakpoint +CREATE TABLE `__new_eval_result` ( + `id` text PRIMARY KEY NOT NULL, + `suite_run_id` text, + `dataset_item_id` text, + `conversation_id` text NOT NULL, + `status` text NOT NULL, + `tenant_id` text NOT NULL, + `project_id` text NOT NULL, + `evaluator_id` text NOT NULL, + `reasoning` text, + `metadata` blob, + `created_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + `updated_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (`tenant_id`,`project_id`,`conversation_id`) REFERENCES `conversations`(`tenant_id`,`project_id`,`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`tenant_id`,`evaluator_id`) REFERENCES `evaluator`(`tenant_id`,`id`) ON UPDATE no action ON DELETE cascade, + FOREIGN KEY (`dataset_item_id`) REFERENCES `dataset_item`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +INSERT INTO `__new_eval_result`("id", "suite_run_id", "dataset_item_id", "conversation_id", "status", "tenant_id", "project_id", "evaluator_id", "reasoning", "metadata", "created_at", "updated_at") +SELECT + er.id, + er.suite_run_id, + er.dataset_item_id, + er.conversation_id, + er.status, + er.tenant_id, + COALESCE(c.project_id, a.project_id, 'default') as project_id, + er.evaluator_id, + er.reasoning, + er.metadata, + er.created_at, + er.updated_at +FROM `eval_result` er +LEFT JOIN `conversations` c ON er.conversation_id = c.id AND er.tenant_id = c.tenant_id +LEFT JOIN `eval_test_suite_run` etsr ON er.suite_run_id = etsr.id +LEFT JOIN `agent` a ON etsr.agent_id = a.id AND er.tenant_id = a.tenant_id;--> statement-breakpoint +DROP TABLE `eval_result`;--> statement-breakpoint +ALTER TABLE `__new_eval_result` RENAME TO `eval_result`;--> statement-breakpoint +PRAGMA foreign_keys=ON; \ No newline at end of file diff --git a/packages/agents-core/drizzle/meta/0015_snapshot.json b/packages/agents-core/drizzle/meta/0015_snapshot.json new file mode 100644 index 000000000..4cb3defa5 --- /dev/null +++ b/packages/agents-core/drizzle/meta/0015_snapshot.json @@ -0,0 +1,3770 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "7c5d64c5-ad6b-4fb7-a4df-7d38582441d3", + "prevId": "4c4e4522-61a2-455c-bbc2-01ea34976bc6", + "tables": { + "agent": { + "name": "agent", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_sub_agent_id": { + "name": "default_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_config_id": { + "name": "context_config_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_updates": { + "name": "status_updates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "agent_project_fk": { + "name": "agent_project_fk", + "tableFrom": "agent", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "agent_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "agent_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "api_keys": { + "name": "api_keys", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_prefix": { + "name": "key_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "api_keys_public_id_unique": { + "name": "api_keys_public_id_unique", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "api_keys_tenant_agent_idx": { + "name": "api_keys_tenant_agent_idx", + "columns": [ + "tenant_id", + "agent_id" + ], + "isUnique": false + }, + "api_keys_prefix_idx": { + "name": "api_keys_prefix_idx", + "columns": [ + "key_prefix" + ], + "isUnique": false + }, + "api_keys_public_id_idx": { + "name": "api_keys_public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "api_keys_project_fk": { + "name": "api_keys_project_fk", + "tableFrom": "api_keys", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_keys_agent_fk": { + "name": "api_keys_agent_fk", + "tableFrom": "api_keys", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifact_components": { + "name": "artifact_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "props": { + "name": "props", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "artifact_components_project_fk": { + "name": "artifact_components_project_fk", + "tableFrom": "artifact_components", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "artifact_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "artifact_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_cache": { + "name": "context_cache", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_config_id": { + "name": "context_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_variable_key": { + "name": "context_variable_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "request_hash": { + "name": "request_hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fetch_source": { + "name": "fetch_source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fetch_duration_ms": { + "name": "fetch_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "context_cache_lookup_idx": { + "name": "context_cache_lookup_idx", + "columns": [ + "conversation_id", + "context_config_id", + "context_variable_key" + ], + "isUnique": false + } + }, + "foreignKeys": { + "context_cache_project_fk": { + "name": "context_cache_project_fk", + "tableFrom": "context_cache", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_cache_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "context_cache_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_configs": { + "name": "context_configs", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers_schema": { + "name": "headers_schema", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_variables": { + "name": "context_variables", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "context_configs_agent_fk": { + "name": "context_configs_agent_fk", + "tableFrom": "context_configs", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_configs_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "context_configs_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversation_evaluation_config": { + "name": "conversation_evaluation_config", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_filter": { + "name": "conversation_filter", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sample_rate": { + "name": "sample_rate", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "conversation_evaluation_config_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "conversation_evaluation_config_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversation_evaluation_config_evaluator": { + "name": "conversation_evaluation_config_evaluator", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "conversation_evaluation_config_id": { + "name": "conversation_evaluation_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "conv_eval_config_evaluator_config_fk": { + "name": "conv_eval_config_evaluator_config_fk", + "tableFrom": "conversation_evaluation_config_evaluator", + "tableTo": "conversation_evaluation_config", + "columnsFrom": [ + "conversation_evaluation_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conv_eval_config_evaluator_evaluator_fk": { + "name": "conv_eval_config_evaluator_evaluator_fk", + "tableFrom": "conversation_evaluation_config_evaluator", + "tableTo": "evaluator", + "columnsFrom": [ + "evaluator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversations": { + "name": "conversations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_sub_agent_id": { + "name": "active_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_context_resolution": { + "name": "last_context_resolution", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "conversations_project_fk": { + "name": "conversations_project_fk", + "tableFrom": "conversations", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversations_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "conversations_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "credential_references": { + "name": "credential_references", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_store_id": { + "name": "credential_store_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "retrieval_params": { + "name": "retrieval_params", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "credential_references_project_fk": { + "name": "credential_references_project_fk", + "tableFrom": "credential_references", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "credential_references_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "credential_references_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "data_components": { + "name": "data_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "props": { + "name": "props", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "render": { + "name": "render", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "data_components_project_fk": { + "name": "data_components_project_fk", + "tableFrom": "data_components", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "data_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "data_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dataset": { + "name": "dataset", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "dataset_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "dataset_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dataset_item": { + "name": "dataset_item", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "dataset_id": { + "name": "dataset_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input": { + "name": "input", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expected_output": { + "name": "expected_output", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "simulation_config": { + "name": "simulation_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "dataset_item_dataset_fk": { + "name": "dataset_item_dataset_fk", + "tableFrom": "dataset_item", + "tableTo": "dataset", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_result": { + "name": "eval_result", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "suite_run_id": { + "name": "suite_run_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dataset_item_id": { + "name": "dataset_item_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_result_conversation_fk": { + "name": "eval_result_conversation_fk", + "tableFrom": "eval_result", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_result_evaluator_fk": { + "name": "eval_result_evaluator_fk", + "tableFrom": "eval_result", + "tableTo": "evaluator", + "columnsFrom": [ + "evaluator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_result_dataset_item_fk": { + "name": "eval_result_dataset_item_fk", + "tableFrom": "eval_result", + "tableTo": "dataset_item", + "columnsFrom": [ + "dataset_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_config": { + "name": "eval_test_suite_config", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "run_frequency": { + "name": "run_frequency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "eval_test_suite_config_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "eval_test_suite_config_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_run": { + "name": "eval_test_suite_run", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dataset_id": { + "name": "dataset_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "test_suite_config_id": { + "name": "test_suite_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_test_suite_run_dataset_fk": { + "name": "eval_test_suite_run_dataset_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "dataset", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_agent_fk": { + "name": "eval_test_suite_run_agent_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "agent", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_config_fk": { + "name": "eval_test_suite_run_config_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "eval_test_suite_config", + "columnsFrom": [ + "test_suite_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_run_evaluators": { + "name": "eval_test_suite_run_evaluators", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "eval_test_suite_run_id": { + "name": "eval_test_suite_run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_test_suite_run_evaluators_run_fk": { + "name": "eval_test_suite_run_evaluators_run_fk", + "tableFrom": "eval_test_suite_run_evaluators", + "tableTo": "eval_test_suite_run", + "columnsFrom": [ + "eval_test_suite_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_evaluators_evaluator_fk": { + "name": "eval_test_suite_run_evaluators_evaluator_fk", + "tableFrom": "eval_test_suite_run_evaluators", + "tableTo": "evaluator", + "columnsFrom": [ + "evaluator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "evaluator": { + "name": "evaluator", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schema": { + "name": "schema", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "evaluator_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "evaluator_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "external_agents": { + "name": "external_agents", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_reference_id": { + "name": "credential_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "external_agents_project_fk": { + "name": "external_agents_project_fk", + "tableFrom": "external_agents", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "external_agents_credential_reference_fk": { + "name": "external_agents_credential_reference_fk", + "tableFrom": "external_agents", + "tableTo": "credential_references", + "columnsFrom": [ + "tenant_id", + "project_id", + "credential_reference_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "external_agents_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "external_agents_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "function_tools": { + "name": "function_tools", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "function_id": { + "name": "function_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "function_tools_agent_fk": { + "name": "function_tools_agent_fk", + "tableFrom": "function_tools", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "function_tools_function_fk": { + "name": "function_tools_function_fk", + "tableFrom": "function_tools", + "tableTo": "functions", + "columnsFrom": [ + "tenant_id", + "project_id", + "function_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "function_tools_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "function_tools_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "functions": { + "name": "functions", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_schema": { + "name": "input_schema", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "execute_code": { + "name": "execute_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dependencies": { + "name": "dependencies", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "functions_project_fk": { + "name": "functions_project_fk", + "tableFrom": "functions", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "functions_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "functions_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ledger_artifacts": { + "name": "ledger_artifacts", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'source'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parts": { + "name": "parts", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mime": { + "name": "mime", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'context'" + }, + "allowed_agents": { + "name": "allowed_agents", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "derived_from": { + "name": "derived_from", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "ledger_artifacts_task_id_idx": { + "name": "ledger_artifacts_task_id_idx", + "columns": [ + "task_id" + ], + "isUnique": false + }, + "ledger_artifacts_tool_call_id_idx": { + "name": "ledger_artifacts_tool_call_id_idx", + "columns": [ + "tool_call_id" + ], + "isUnique": false + }, + "ledger_artifacts_context_id_idx": { + "name": "ledger_artifacts_context_id_idx", + "columns": [ + "context_id" + ], + "isUnique": false + }, + "ledger_artifacts_task_context_name_unique": { + "name": "ledger_artifacts_task_context_name_unique", + "columns": [ + "task_id", + "context_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "ledger_artifacts_project_fk": { + "name": "ledger_artifacts_project_fk", + "tableFrom": "ledger_artifacts", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "ledger_artifacts_tenant_id_project_id_id_task_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id", + "task_id" + ], + "name": "ledger_artifacts_tenant_id_project_id_id_task_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "messages": { + "name": "messages", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_sub_agent_id": { + "name": "from_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_sub_agent_id": { + "name": "to_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "from_external_sub_agent_id": { + "name": "from_external_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_external_sub_agent_id": { + "name": "to_external_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "from_team_agent_id": { + "name": "from_team_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_team_agent_id": { + "name": "to_team_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'user-facing'" + }, + "message_type": { + "name": "message_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'chat'" + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parent_message_id": { + "name": "parent_message_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "a2a_task_id": { + "name": "a2a_task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "a2a_session_id": { + "name": "a2a_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "messages_project_fk": { + "name": "messages_project_fk", + "tableFrom": "messages", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "messages_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "messages_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "projects": { + "name": "projects", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "projects_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "projects_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_artifact_components": { + "name": "sub_agent_artifact_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifact_component_id": { + "name": "artifact_component_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_artifact_components_sub_agent_fk": { + "name": "sub_agent_artifact_components_sub_agent_fk", + "tableFrom": "sub_agent_artifact_components", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_artifact_components_artifact_component_fk": { + "name": "sub_agent_artifact_components_artifact_component_fk", + "tableFrom": "sub_agent_artifact_components", + "tableTo": "artifact_components", + "columnsFrom": [ + "tenant_id", + "project_id", + "artifact_component_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_artifact_components_tenant_id_project_id_agent_id_sub_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id", + "id" + ], + "name": "sub_agent_artifact_components_tenant_id_project_id_agent_id_sub_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_data_components": { + "name": "sub_agent_data_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data_component_id": { + "name": "data_component_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_data_components_sub_agent_fk": { + "name": "sub_agent_data_components_sub_agent_fk", + "tableFrom": "sub_agent_data_components", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_data_components_data_component_fk": { + "name": "sub_agent_data_components_data_component_fk", + "tableFrom": "sub_agent_data_components", + "tableTo": "data_components", + "columnsFrom": [ + "tenant_id", + "project_id", + "data_component_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_data_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "sub_agent_data_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_external_agent_relations": { + "name": "sub_agent_external_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_agent_id": { + "name": "external_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_external_agent_relations_sub_agent_fk": { + "name": "sub_agent_external_agent_relations_sub_agent_fk", + "tableFrom": "sub_agent_external_agent_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_external_agent_relations_external_agent_fk": { + "name": "sub_agent_external_agent_relations_external_agent_fk", + "tableFrom": "sub_agent_external_agent_relations", + "tableTo": "external_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "external_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_external_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_external_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_function_tool_relations": { + "name": "sub_agent_function_tool_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "function_tool_id": { + "name": "function_tool_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_function_tool_relations_sub_agent_fk": { + "name": "sub_agent_function_tool_relations_sub_agent_fk", + "tableFrom": "sub_agent_function_tool_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_function_tool_relations_function_tool_fk": { + "name": "sub_agent_function_tool_relations_function_tool_fk", + "tableFrom": "sub_agent_function_tool_relations", + "tableTo": "function_tools", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "function_tool_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_function_tool_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_function_tool_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_relations": { + "name": "sub_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_sub_agent_id": { + "name": "source_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_sub_agent_id": { + "name": "target_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "relation_type": { + "name": "relation_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_relations_agent_fk": { + "name": "sub_agent_relations_agent_fk", + "tableFrom": "sub_agent_relations", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_team_agent_relations": { + "name": "sub_agent_team_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_agent_id": { + "name": "target_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_team_agent_relations_sub_agent_fk": { + "name": "sub_agent_team_agent_relations_sub_agent_fk", + "tableFrom": "sub_agent_team_agent_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_team_agent_relations_target_agent_fk": { + "name": "sub_agent_team_agent_relations_target_agent_fk", + "tableFrom": "sub_agent_team_agent_relations", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "target_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_team_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_team_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_tool_relations": { + "name": "sub_agent_tool_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_id": { + "name": "tool_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "selected_tools": { + "name": "selected_tools", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_tool_relations_agent_fk": { + "name": "sub_agent_tool_relations_agent_fk", + "tableFrom": "sub_agent_tool_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_tool_relations_tool_fk": { + "name": "sub_agent_tool_relations_tool_fk", + "tableFrom": "sub_agent_tool_relations", + "tableTo": "tools", + "columnsFrom": [ + "tenant_id", + "project_id", + "tool_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_tool_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_tool_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agents": { + "name": "sub_agents", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_history_config": { + "name": "conversation_history_config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agents_agents_fk": { + "name": "sub_agents_agents_fk", + "tableFrom": "sub_agents", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agents_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agents_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "task_relations": { + "name": "task_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parent_task_id": { + "name": "parent_task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "child_task_id": { + "name": "child_task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "relation_type": { + "name": "relation_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'parent_child'" + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "task_relations_project_fk": { + "name": "task_relations_project_fk", + "tableFrom": "task_relations", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_relations_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "task_relations_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tasks": { + "name": "tasks", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "tasks_sub_agent_fk": { + "name": "tasks_sub_agent_fk", + "tableFrom": "tasks", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tasks_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "tasks_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tools": { + "name": "tools", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_reference_id": { + "name": "credential_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "capabilities": { + "name": "capabilities", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "tools_project_fk": { + "name": "tools_project_fk", + "tableFrom": "tools", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tools_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "tools_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/agents-core/drizzle/meta/0016_snapshot.json b/packages/agents-core/drizzle/meta/0016_snapshot.json new file mode 100644 index 000000000..f32b37eb0 --- /dev/null +++ b/packages/agents-core/drizzle/meta/0016_snapshot.json @@ -0,0 +1,3797 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "ef1b4deb-0f40-414f-9237-7a9096997a4b", + "prevId": "7c5d64c5-ad6b-4fb7-a4df-7d38582441d3", + "tables": { + "agent": { + "name": "agent", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_sub_agent_id": { + "name": "default_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_config_id": { + "name": "context_config_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_updates": { + "name": "status_updates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "agent_project_fk": { + "name": "agent_project_fk", + "tableFrom": "agent", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "agent_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "agent_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "api_keys": { + "name": "api_keys", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_prefix": { + "name": "key_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "api_keys_public_id_unique": { + "name": "api_keys_public_id_unique", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "api_keys_tenant_agent_idx": { + "name": "api_keys_tenant_agent_idx", + "columns": [ + "tenant_id", + "agent_id" + ], + "isUnique": false + }, + "api_keys_prefix_idx": { + "name": "api_keys_prefix_idx", + "columns": [ + "key_prefix" + ], + "isUnique": false + }, + "api_keys_public_id_idx": { + "name": "api_keys_public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "api_keys_project_fk": { + "name": "api_keys_project_fk", + "tableFrom": "api_keys", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_keys_agent_fk": { + "name": "api_keys_agent_fk", + "tableFrom": "api_keys", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifact_components": { + "name": "artifact_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "props": { + "name": "props", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "artifact_components_project_fk": { + "name": "artifact_components_project_fk", + "tableFrom": "artifact_components", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "artifact_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "artifact_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_cache": { + "name": "context_cache", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_config_id": { + "name": "context_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_variable_key": { + "name": "context_variable_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "request_hash": { + "name": "request_hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fetch_source": { + "name": "fetch_source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fetch_duration_ms": { + "name": "fetch_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "context_cache_lookup_idx": { + "name": "context_cache_lookup_idx", + "columns": [ + "conversation_id", + "context_config_id", + "context_variable_key" + ], + "isUnique": false + } + }, + "foreignKeys": { + "context_cache_project_fk": { + "name": "context_cache_project_fk", + "tableFrom": "context_cache", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_cache_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "context_cache_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_configs": { + "name": "context_configs", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers_schema": { + "name": "headers_schema", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_variables": { + "name": "context_variables", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "context_configs_agent_fk": { + "name": "context_configs_agent_fk", + "tableFrom": "context_configs", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_configs_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "context_configs_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversation_evaluation_config": { + "name": "conversation_evaluation_config", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_filter": { + "name": "conversation_filter", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sample_rate": { + "name": "sample_rate", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "conversation_evaluation_config_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "conversation_evaluation_config_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversation_evaluation_config_evaluator": { + "name": "conversation_evaluation_config_evaluator", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "conversation_evaluation_config_id": { + "name": "conversation_evaluation_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "conv_eval_config_evaluator_config_fk": { + "name": "conv_eval_config_evaluator_config_fk", + "tableFrom": "conversation_evaluation_config_evaluator", + "tableTo": "conversation_evaluation_config", + "columnsFrom": [ + "conversation_evaluation_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conv_eval_config_evaluator_evaluator_fk": { + "name": "conv_eval_config_evaluator_evaluator_fk", + "tableFrom": "conversation_evaluation_config_evaluator", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversations": { + "name": "conversations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_sub_agent_id": { + "name": "active_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_context_resolution": { + "name": "last_context_resolution", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "conversations_project_fk": { + "name": "conversations_project_fk", + "tableFrom": "conversations", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversations_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "conversations_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "credential_references": { + "name": "credential_references", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_store_id": { + "name": "credential_store_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "retrieval_params": { + "name": "retrieval_params", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "credential_references_project_fk": { + "name": "credential_references_project_fk", + "tableFrom": "credential_references", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "credential_references_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "credential_references_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "data_components": { + "name": "data_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "props": { + "name": "props", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "render": { + "name": "render", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "data_components_project_fk": { + "name": "data_components_project_fk", + "tableFrom": "data_components", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "data_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "data_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dataset": { + "name": "dataset", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "dataset_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "dataset_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dataset_item": { + "name": "dataset_item", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "dataset_id": { + "name": "dataset_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input": { + "name": "input", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expected_output": { + "name": "expected_output", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "simulation_config": { + "name": "simulation_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "dataset_item_dataset_fk": { + "name": "dataset_item_dataset_fk", + "tableFrom": "dataset_item", + "tableTo": "dataset", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_result": { + "name": "eval_result", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "suite_run_id": { + "name": "suite_run_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dataset_item_id": { + "name": "dataset_item_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_result_conversation_fk": { + "name": "eval_result_conversation_fk", + "tableFrom": "eval_result", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_result_evaluator_fk": { + "name": "eval_result_evaluator_fk", + "tableFrom": "eval_result", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_result_dataset_item_fk": { + "name": "eval_result_dataset_item_fk", + "tableFrom": "eval_result", + "tableTo": "dataset_item", + "columnsFrom": [ + "dataset_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_config": { + "name": "eval_test_suite_config", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "run_frequency": { + "name": "run_frequency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "eval_test_suite_config_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "eval_test_suite_config_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_run": { + "name": "eval_test_suite_run", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dataset_id": { + "name": "dataset_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "test_suite_config_id": { + "name": "test_suite_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_test_suite_run_dataset_fk": { + "name": "eval_test_suite_run_dataset_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "dataset", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_agent_fk": { + "name": "eval_test_suite_run_agent_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "agent", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_config_fk": { + "name": "eval_test_suite_run_config_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "eval_test_suite_config", + "columnsFrom": [ + "test_suite_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_run_evaluators": { + "name": "eval_test_suite_run_evaluators", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "eval_test_suite_run_id": { + "name": "eval_test_suite_run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_test_suite_run_evaluators_run_fk": { + "name": "eval_test_suite_run_evaluators_run_fk", + "tableFrom": "eval_test_suite_run_evaluators", + "tableTo": "eval_test_suite_run", + "columnsFrom": [ + "eval_test_suite_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_evaluators_evaluator_fk": { + "name": "eval_test_suite_run_evaluators_evaluator_fk", + "tableFrom": "eval_test_suite_run_evaluators", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "evaluator": { + "name": "evaluator", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schema": { + "name": "schema", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "evaluator_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "evaluator_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "external_agents": { + "name": "external_agents", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_reference_id": { + "name": "credential_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "external_agents_project_fk": { + "name": "external_agents_project_fk", + "tableFrom": "external_agents", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "external_agents_credential_reference_fk": { + "name": "external_agents_credential_reference_fk", + "tableFrom": "external_agents", + "tableTo": "credential_references", + "columnsFrom": [ + "tenant_id", + "project_id", + "credential_reference_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "external_agents_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "external_agents_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "function_tools": { + "name": "function_tools", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "function_id": { + "name": "function_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "function_tools_agent_fk": { + "name": "function_tools_agent_fk", + "tableFrom": "function_tools", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "function_tools_function_fk": { + "name": "function_tools_function_fk", + "tableFrom": "function_tools", + "tableTo": "functions", + "columnsFrom": [ + "tenant_id", + "project_id", + "function_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "function_tools_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "function_tools_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "functions": { + "name": "functions", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_schema": { + "name": "input_schema", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "execute_code": { + "name": "execute_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dependencies": { + "name": "dependencies", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "functions_project_fk": { + "name": "functions_project_fk", + "tableFrom": "functions", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "functions_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "functions_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ledger_artifacts": { + "name": "ledger_artifacts", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'source'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parts": { + "name": "parts", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mime": { + "name": "mime", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'context'" + }, + "allowed_agents": { + "name": "allowed_agents", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "derived_from": { + "name": "derived_from", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "ledger_artifacts_task_id_idx": { + "name": "ledger_artifacts_task_id_idx", + "columns": [ + "task_id" + ], + "isUnique": false + }, + "ledger_artifacts_tool_call_id_idx": { + "name": "ledger_artifacts_tool_call_id_idx", + "columns": [ + "tool_call_id" + ], + "isUnique": false + }, + "ledger_artifacts_context_id_idx": { + "name": "ledger_artifacts_context_id_idx", + "columns": [ + "context_id" + ], + "isUnique": false + }, + "ledger_artifacts_task_context_name_unique": { + "name": "ledger_artifacts_task_context_name_unique", + "columns": [ + "task_id", + "context_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "ledger_artifacts_project_fk": { + "name": "ledger_artifacts_project_fk", + "tableFrom": "ledger_artifacts", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "ledger_artifacts_tenant_id_project_id_id_task_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id", + "task_id" + ], + "name": "ledger_artifacts_tenant_id_project_id_id_task_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "messages": { + "name": "messages", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_sub_agent_id": { + "name": "from_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_sub_agent_id": { + "name": "to_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "from_external_sub_agent_id": { + "name": "from_external_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_external_sub_agent_id": { + "name": "to_external_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "from_team_agent_id": { + "name": "from_team_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_team_agent_id": { + "name": "to_team_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'user-facing'" + }, + "message_type": { + "name": "message_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'chat'" + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parent_message_id": { + "name": "parent_message_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "a2a_task_id": { + "name": "a2a_task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "a2a_session_id": { + "name": "a2a_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "messages_project_fk": { + "name": "messages_project_fk", + "tableFrom": "messages", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "messages_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "messages_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "projects": { + "name": "projects", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "projects_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "projects_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_artifact_components": { + "name": "sub_agent_artifact_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifact_component_id": { + "name": "artifact_component_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_artifact_components_sub_agent_fk": { + "name": "sub_agent_artifact_components_sub_agent_fk", + "tableFrom": "sub_agent_artifact_components", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_artifact_components_artifact_component_fk": { + "name": "sub_agent_artifact_components_artifact_component_fk", + "tableFrom": "sub_agent_artifact_components", + "tableTo": "artifact_components", + "columnsFrom": [ + "tenant_id", + "project_id", + "artifact_component_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_artifact_components_tenant_id_project_id_agent_id_sub_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id", + "id" + ], + "name": "sub_agent_artifact_components_tenant_id_project_id_agent_id_sub_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_data_components": { + "name": "sub_agent_data_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data_component_id": { + "name": "data_component_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_data_components_sub_agent_fk": { + "name": "sub_agent_data_components_sub_agent_fk", + "tableFrom": "sub_agent_data_components", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_data_components_data_component_fk": { + "name": "sub_agent_data_components_data_component_fk", + "tableFrom": "sub_agent_data_components", + "tableTo": "data_components", + "columnsFrom": [ + "tenant_id", + "project_id", + "data_component_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_data_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "sub_agent_data_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_external_agent_relations": { + "name": "sub_agent_external_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_agent_id": { + "name": "external_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_external_agent_relations_sub_agent_fk": { + "name": "sub_agent_external_agent_relations_sub_agent_fk", + "tableFrom": "sub_agent_external_agent_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_external_agent_relations_external_agent_fk": { + "name": "sub_agent_external_agent_relations_external_agent_fk", + "tableFrom": "sub_agent_external_agent_relations", + "tableTo": "external_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "external_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_external_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_external_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_function_tool_relations": { + "name": "sub_agent_function_tool_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "function_tool_id": { + "name": "function_tool_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_function_tool_relations_sub_agent_fk": { + "name": "sub_agent_function_tool_relations_sub_agent_fk", + "tableFrom": "sub_agent_function_tool_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_function_tool_relations_function_tool_fk": { + "name": "sub_agent_function_tool_relations_function_tool_fk", + "tableFrom": "sub_agent_function_tool_relations", + "tableTo": "function_tools", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "function_tool_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_function_tool_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_function_tool_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_relations": { + "name": "sub_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_sub_agent_id": { + "name": "source_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_sub_agent_id": { + "name": "target_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "relation_type": { + "name": "relation_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_relations_agent_fk": { + "name": "sub_agent_relations_agent_fk", + "tableFrom": "sub_agent_relations", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_team_agent_relations": { + "name": "sub_agent_team_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_agent_id": { + "name": "target_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_team_agent_relations_sub_agent_fk": { + "name": "sub_agent_team_agent_relations_sub_agent_fk", + "tableFrom": "sub_agent_team_agent_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_team_agent_relations_target_agent_fk": { + "name": "sub_agent_team_agent_relations_target_agent_fk", + "tableFrom": "sub_agent_team_agent_relations", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "target_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_team_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_team_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_tool_relations": { + "name": "sub_agent_tool_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_id": { + "name": "tool_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "selected_tools": { + "name": "selected_tools", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_tool_relations_agent_fk": { + "name": "sub_agent_tool_relations_agent_fk", + "tableFrom": "sub_agent_tool_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_tool_relations_tool_fk": { + "name": "sub_agent_tool_relations_tool_fk", + "tableFrom": "sub_agent_tool_relations", + "tableTo": "tools", + "columnsFrom": [ + "tenant_id", + "project_id", + "tool_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_tool_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_tool_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agents": { + "name": "sub_agents", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_history_config": { + "name": "conversation_history_config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agents_agents_fk": { + "name": "sub_agents_agents_fk", + "tableFrom": "sub_agents", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agents_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agents_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "task_relations": { + "name": "task_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parent_task_id": { + "name": "parent_task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "child_task_id": { + "name": "child_task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "relation_type": { + "name": "relation_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'parent_child'" + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "task_relations_project_fk": { + "name": "task_relations_project_fk", + "tableFrom": "task_relations", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_relations_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "task_relations_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tasks": { + "name": "tasks", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "tasks_sub_agent_fk": { + "name": "tasks_sub_agent_fk", + "tableFrom": "tasks", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tasks_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "tasks_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tools": { + "name": "tools", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_reference_id": { + "name": "credential_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "capabilities": { + "name": "capabilities", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "tools_project_fk": { + "name": "tools_project_fk", + "tableFrom": "tools", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tools_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "tools_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/agents-core/drizzle/meta/0017_snapshot.json b/packages/agents-core/drizzle/meta/0017_snapshot.json new file mode 100644 index 000000000..232401455 --- /dev/null +++ b/packages/agents-core/drizzle/meta/0017_snapshot.json @@ -0,0 +1,3799 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "9d88b8f1-4a39-40bd-bdb0-193494753fb2", + "prevId": "ef1b4deb-0f40-414f-9237-7a9096997a4b", + "tables": { + "agent": { + "name": "agent", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_sub_agent_id": { + "name": "default_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_config_id": { + "name": "context_config_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_updates": { + "name": "status_updates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "agent_project_fk": { + "name": "agent_project_fk", + "tableFrom": "agent", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "agent_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "agent_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "api_keys": { + "name": "api_keys", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_prefix": { + "name": "key_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "api_keys_public_id_unique": { + "name": "api_keys_public_id_unique", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "api_keys_tenant_agent_idx": { + "name": "api_keys_tenant_agent_idx", + "columns": [ + "tenant_id", + "agent_id" + ], + "isUnique": false + }, + "api_keys_prefix_idx": { + "name": "api_keys_prefix_idx", + "columns": [ + "key_prefix" + ], + "isUnique": false + }, + "api_keys_public_id_idx": { + "name": "api_keys_public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "api_keys_project_fk": { + "name": "api_keys_project_fk", + "tableFrom": "api_keys", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_keys_agent_fk": { + "name": "api_keys_agent_fk", + "tableFrom": "api_keys", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifact_components": { + "name": "artifact_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "props": { + "name": "props", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "artifact_components_project_fk": { + "name": "artifact_components_project_fk", + "tableFrom": "artifact_components", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "artifact_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "artifact_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_cache": { + "name": "context_cache", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_config_id": { + "name": "context_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_variable_key": { + "name": "context_variable_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "request_hash": { + "name": "request_hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fetch_source": { + "name": "fetch_source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fetch_duration_ms": { + "name": "fetch_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "context_cache_lookup_idx": { + "name": "context_cache_lookup_idx", + "columns": [ + "conversation_id", + "context_config_id", + "context_variable_key" + ], + "isUnique": false + } + }, + "foreignKeys": { + "context_cache_project_fk": { + "name": "context_cache_project_fk", + "tableFrom": "context_cache", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_cache_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "context_cache_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_configs": { + "name": "context_configs", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers_schema": { + "name": "headers_schema", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_variables": { + "name": "context_variables", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "context_configs_agent_fk": { + "name": "context_configs_agent_fk", + "tableFrom": "context_configs", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_configs_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "context_configs_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversation_evaluation_config": { + "name": "conversation_evaluation_config", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_filter": { + "name": "conversation_filter", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sample_rate": { + "name": "sample_rate", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "conversation_evaluation_config_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "conversation_evaluation_config_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversation_evaluation_config_evaluator": { + "name": "conversation_evaluation_config_evaluator", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "conversation_evaluation_config_id": { + "name": "conversation_evaluation_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "conv_eval_config_evaluator_config_fk": { + "name": "conv_eval_config_evaluator_config_fk", + "tableFrom": "conversation_evaluation_config_evaluator", + "tableTo": "conversation_evaluation_config", + "columnsFrom": [ + "tenant_id", + "conversation_evaluation_config_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conv_eval_config_evaluator_evaluator_fk": { + "name": "conv_eval_config_evaluator_evaluator_fk", + "tableFrom": "conversation_evaluation_config_evaluator", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversations": { + "name": "conversations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_sub_agent_id": { + "name": "active_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_context_resolution": { + "name": "last_context_resolution", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "conversations_project_fk": { + "name": "conversations_project_fk", + "tableFrom": "conversations", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversations_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "conversations_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "credential_references": { + "name": "credential_references", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_store_id": { + "name": "credential_store_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "retrieval_params": { + "name": "retrieval_params", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "credential_references_project_fk": { + "name": "credential_references_project_fk", + "tableFrom": "credential_references", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "credential_references_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "credential_references_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "data_components": { + "name": "data_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "props": { + "name": "props", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "render": { + "name": "render", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "data_components_project_fk": { + "name": "data_components_project_fk", + "tableFrom": "data_components", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "data_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "data_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dataset": { + "name": "dataset", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "dataset_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "dataset_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dataset_item": { + "name": "dataset_item", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "dataset_id": { + "name": "dataset_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input": { + "name": "input", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expected_output": { + "name": "expected_output", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "simulation_config": { + "name": "simulation_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "dataset_item_dataset_fk": { + "name": "dataset_item_dataset_fk", + "tableFrom": "dataset_item", + "tableTo": "dataset", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_result": { + "name": "eval_result", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "suite_run_id": { + "name": "suite_run_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dataset_item_id": { + "name": "dataset_item_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_result_conversation_fk": { + "name": "eval_result_conversation_fk", + "tableFrom": "eval_result", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_result_evaluator_fk": { + "name": "eval_result_evaluator_fk", + "tableFrom": "eval_result", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_result_dataset_item_fk": { + "name": "eval_result_dataset_item_fk", + "tableFrom": "eval_result", + "tableTo": "dataset_item", + "columnsFrom": [ + "dataset_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_config": { + "name": "eval_test_suite_config", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "run_frequency": { + "name": "run_frequency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "eval_test_suite_config_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "eval_test_suite_config_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_run": { + "name": "eval_test_suite_run", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dataset_id": { + "name": "dataset_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "test_suite_config_id": { + "name": "test_suite_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_test_suite_run_dataset_fk": { + "name": "eval_test_suite_run_dataset_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "dataset", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_agent_fk": { + "name": "eval_test_suite_run_agent_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "agent", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_config_fk": { + "name": "eval_test_suite_run_config_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "eval_test_suite_config", + "columnsFrom": [ + "test_suite_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_run_evaluators": { + "name": "eval_test_suite_run_evaluators", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "eval_test_suite_run_id": { + "name": "eval_test_suite_run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_test_suite_run_evaluators_run_fk": { + "name": "eval_test_suite_run_evaluators_run_fk", + "tableFrom": "eval_test_suite_run_evaluators", + "tableTo": "eval_test_suite_run", + "columnsFrom": [ + "eval_test_suite_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_evaluators_evaluator_fk": { + "name": "eval_test_suite_run_evaluators_evaluator_fk", + "tableFrom": "eval_test_suite_run_evaluators", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "evaluator": { + "name": "evaluator", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schema": { + "name": "schema", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "evaluator_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "evaluator_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "external_agents": { + "name": "external_agents", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_reference_id": { + "name": "credential_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "external_agents_project_fk": { + "name": "external_agents_project_fk", + "tableFrom": "external_agents", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "external_agents_credential_reference_fk": { + "name": "external_agents_credential_reference_fk", + "tableFrom": "external_agents", + "tableTo": "credential_references", + "columnsFrom": [ + "tenant_id", + "project_id", + "credential_reference_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "external_agents_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "external_agents_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "function_tools": { + "name": "function_tools", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "function_id": { + "name": "function_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "function_tools_agent_fk": { + "name": "function_tools_agent_fk", + "tableFrom": "function_tools", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "function_tools_function_fk": { + "name": "function_tools_function_fk", + "tableFrom": "function_tools", + "tableTo": "functions", + "columnsFrom": [ + "tenant_id", + "project_id", + "function_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "function_tools_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "function_tools_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "functions": { + "name": "functions", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_schema": { + "name": "input_schema", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "execute_code": { + "name": "execute_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dependencies": { + "name": "dependencies", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "functions_project_fk": { + "name": "functions_project_fk", + "tableFrom": "functions", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "functions_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "functions_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ledger_artifacts": { + "name": "ledger_artifacts", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'source'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parts": { + "name": "parts", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mime": { + "name": "mime", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'context'" + }, + "allowed_agents": { + "name": "allowed_agents", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "derived_from": { + "name": "derived_from", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "ledger_artifacts_task_id_idx": { + "name": "ledger_artifacts_task_id_idx", + "columns": [ + "task_id" + ], + "isUnique": false + }, + "ledger_artifacts_tool_call_id_idx": { + "name": "ledger_artifacts_tool_call_id_idx", + "columns": [ + "tool_call_id" + ], + "isUnique": false + }, + "ledger_artifacts_context_id_idx": { + "name": "ledger_artifacts_context_id_idx", + "columns": [ + "context_id" + ], + "isUnique": false + }, + "ledger_artifacts_task_context_name_unique": { + "name": "ledger_artifacts_task_context_name_unique", + "columns": [ + "task_id", + "context_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "ledger_artifacts_project_fk": { + "name": "ledger_artifacts_project_fk", + "tableFrom": "ledger_artifacts", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "ledger_artifacts_tenant_id_project_id_id_task_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id", + "task_id" + ], + "name": "ledger_artifacts_tenant_id_project_id_id_task_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "messages": { + "name": "messages", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_sub_agent_id": { + "name": "from_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_sub_agent_id": { + "name": "to_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "from_external_sub_agent_id": { + "name": "from_external_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_external_sub_agent_id": { + "name": "to_external_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "from_team_agent_id": { + "name": "from_team_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_team_agent_id": { + "name": "to_team_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'user-facing'" + }, + "message_type": { + "name": "message_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'chat'" + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parent_message_id": { + "name": "parent_message_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "a2a_task_id": { + "name": "a2a_task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "a2a_session_id": { + "name": "a2a_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "messages_project_fk": { + "name": "messages_project_fk", + "tableFrom": "messages", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "messages_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "messages_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "projects": { + "name": "projects", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "projects_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "projects_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_artifact_components": { + "name": "sub_agent_artifact_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifact_component_id": { + "name": "artifact_component_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_artifact_components_sub_agent_fk": { + "name": "sub_agent_artifact_components_sub_agent_fk", + "tableFrom": "sub_agent_artifact_components", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_artifact_components_artifact_component_fk": { + "name": "sub_agent_artifact_components_artifact_component_fk", + "tableFrom": "sub_agent_artifact_components", + "tableTo": "artifact_components", + "columnsFrom": [ + "tenant_id", + "project_id", + "artifact_component_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_artifact_components_tenant_id_project_id_agent_id_sub_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id", + "id" + ], + "name": "sub_agent_artifact_components_tenant_id_project_id_agent_id_sub_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_data_components": { + "name": "sub_agent_data_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data_component_id": { + "name": "data_component_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_data_components_sub_agent_fk": { + "name": "sub_agent_data_components_sub_agent_fk", + "tableFrom": "sub_agent_data_components", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_data_components_data_component_fk": { + "name": "sub_agent_data_components_data_component_fk", + "tableFrom": "sub_agent_data_components", + "tableTo": "data_components", + "columnsFrom": [ + "tenant_id", + "project_id", + "data_component_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_data_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "sub_agent_data_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_external_agent_relations": { + "name": "sub_agent_external_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_agent_id": { + "name": "external_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_external_agent_relations_sub_agent_fk": { + "name": "sub_agent_external_agent_relations_sub_agent_fk", + "tableFrom": "sub_agent_external_agent_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_external_agent_relations_external_agent_fk": { + "name": "sub_agent_external_agent_relations_external_agent_fk", + "tableFrom": "sub_agent_external_agent_relations", + "tableTo": "external_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "external_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_external_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_external_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_function_tool_relations": { + "name": "sub_agent_function_tool_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "function_tool_id": { + "name": "function_tool_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_function_tool_relations_sub_agent_fk": { + "name": "sub_agent_function_tool_relations_sub_agent_fk", + "tableFrom": "sub_agent_function_tool_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_function_tool_relations_function_tool_fk": { + "name": "sub_agent_function_tool_relations_function_tool_fk", + "tableFrom": "sub_agent_function_tool_relations", + "tableTo": "function_tools", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "function_tool_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_function_tool_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_function_tool_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_relations": { + "name": "sub_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_sub_agent_id": { + "name": "source_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_sub_agent_id": { + "name": "target_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "relation_type": { + "name": "relation_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_relations_agent_fk": { + "name": "sub_agent_relations_agent_fk", + "tableFrom": "sub_agent_relations", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_team_agent_relations": { + "name": "sub_agent_team_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_agent_id": { + "name": "target_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_team_agent_relations_sub_agent_fk": { + "name": "sub_agent_team_agent_relations_sub_agent_fk", + "tableFrom": "sub_agent_team_agent_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_team_agent_relations_target_agent_fk": { + "name": "sub_agent_team_agent_relations_target_agent_fk", + "tableFrom": "sub_agent_team_agent_relations", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "target_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_team_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_team_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_tool_relations": { + "name": "sub_agent_tool_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_id": { + "name": "tool_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "selected_tools": { + "name": "selected_tools", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_tool_relations_agent_fk": { + "name": "sub_agent_tool_relations_agent_fk", + "tableFrom": "sub_agent_tool_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_tool_relations_tool_fk": { + "name": "sub_agent_tool_relations_tool_fk", + "tableFrom": "sub_agent_tool_relations", + "tableTo": "tools", + "columnsFrom": [ + "tenant_id", + "project_id", + "tool_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_tool_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_tool_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agents": { + "name": "sub_agents", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_history_config": { + "name": "conversation_history_config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agents_agents_fk": { + "name": "sub_agents_agents_fk", + "tableFrom": "sub_agents", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agents_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agents_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "task_relations": { + "name": "task_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parent_task_id": { + "name": "parent_task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "child_task_id": { + "name": "child_task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "relation_type": { + "name": "relation_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'parent_child'" + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "task_relations_project_fk": { + "name": "task_relations_project_fk", + "tableFrom": "task_relations", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_relations_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "task_relations_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tasks": { + "name": "tasks", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "tasks_sub_agent_fk": { + "name": "tasks_sub_agent_fk", + "tableFrom": "tasks", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tasks_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "tasks_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tools": { + "name": "tools", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_reference_id": { + "name": "credential_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "capabilities": { + "name": "capabilities", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "tools_project_fk": { + "name": "tools_project_fk", + "tableFrom": "tools", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tools_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "tools_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/agents-core/drizzle/meta/0018_snapshot.json b/packages/agents-core/drizzle/meta/0018_snapshot.json new file mode 100644 index 000000000..237f5488c --- /dev/null +++ b/packages/agents-core/drizzle/meta/0018_snapshot.json @@ -0,0 +1,3810 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "7e80bb4b-af5b-442a-ad3e-e134a06fe7b2", + "prevId": "9d88b8f1-4a39-40bd-bdb0-193494753fb2", + "tables": { + "agent": { + "name": "agent", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_sub_agent_id": { + "name": "default_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_config_id": { + "name": "context_config_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_updates": { + "name": "status_updates", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "agent_project_fk": { + "name": "agent_project_fk", + "tableFrom": "agent", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "agent_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "agent_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "api_keys": { + "name": "api_keys", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "public_id": { + "name": "public_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key_prefix": { + "name": "key_prefix", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "api_keys_public_id_unique": { + "name": "api_keys_public_id_unique", + "columns": [ + "public_id" + ], + "isUnique": true + }, + "api_keys_tenant_agent_idx": { + "name": "api_keys_tenant_agent_idx", + "columns": [ + "tenant_id", + "agent_id" + ], + "isUnique": false + }, + "api_keys_prefix_idx": { + "name": "api_keys_prefix_idx", + "columns": [ + "key_prefix" + ], + "isUnique": false + }, + "api_keys_public_id_idx": { + "name": "api_keys_public_id_idx", + "columns": [ + "public_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "api_keys_project_fk": { + "name": "api_keys_project_fk", + "tableFrom": "api_keys", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_keys_agent_fk": { + "name": "api_keys_agent_fk", + "tableFrom": "api_keys", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "artifact_components": { + "name": "artifact_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "props": { + "name": "props", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "artifact_components_project_fk": { + "name": "artifact_components_project_fk", + "tableFrom": "artifact_components", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "artifact_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "artifact_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_cache": { + "name": "context_cache", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_config_id": { + "name": "context_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_variable_key": { + "name": "context_variable_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "request_hash": { + "name": "request_hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fetched_at": { + "name": "fetched_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fetch_source": { + "name": "fetch_source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fetch_duration_ms": { + "name": "fetch_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "context_cache_lookup_idx": { + "name": "context_cache_lookup_idx", + "columns": [ + "conversation_id", + "context_config_id", + "context_variable_key" + ], + "isUnique": false + } + }, + "foreignKeys": { + "context_cache_project_fk": { + "name": "context_cache_project_fk", + "tableFrom": "context_cache", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_cache_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "context_cache_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "context_configs": { + "name": "context_configs", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers_schema": { + "name": "headers_schema", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_variables": { + "name": "context_variables", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "context_configs_agent_fk": { + "name": "context_configs_agent_fk", + "tableFrom": "context_configs", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "context_configs_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "context_configs_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversation_evaluation_config": { + "name": "conversation_evaluation_config", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_filter": { + "name": "conversation_filter", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sample_rate": { + "name": "sample_rate", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "conversation_evaluation_config_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "conversation_evaluation_config_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversation_evaluation_config_evaluator": { + "name": "conversation_evaluation_config_evaluator", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "conversation_evaluation_config_id": { + "name": "conversation_evaluation_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "conv_eval_config_evaluator_config_fk": { + "name": "conv_eval_config_evaluator_config_fk", + "tableFrom": "conversation_evaluation_config_evaluator", + "tableTo": "conversation_evaluation_config", + "columnsFrom": [ + "tenant_id", + "conversation_evaluation_config_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conv_eval_config_evaluator_evaluator_fk": { + "name": "conv_eval_config_evaluator_evaluator_fk", + "tableFrom": "conversation_evaluation_config_evaluator", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "conversations": { + "name": "conversations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_sub_agent_id": { + "name": "active_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_context_resolution": { + "name": "last_context_resolution", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "conversations_project_fk": { + "name": "conversations_project_fk", + "tableFrom": "conversations", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "conversations_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "conversations_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "credential_references": { + "name": "credential_references", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_store_id": { + "name": "credential_store_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "retrieval_params": { + "name": "retrieval_params", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "credential_references_project_fk": { + "name": "credential_references_project_fk", + "tableFrom": "credential_references", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "credential_references_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "credential_references_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "data_components": { + "name": "data_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "props": { + "name": "props", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "render": { + "name": "render", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "data_components_project_fk": { + "name": "data_components_project_fk", + "tableFrom": "data_components", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "data_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "data_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dataset": { + "name": "dataset", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "dataset_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "dataset_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "dataset_item": { + "name": "dataset_item", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "dataset_id": { + "name": "dataset_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input": { + "name": "input", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expected_output": { + "name": "expected_output", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "simulation_config": { + "name": "simulation_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "dataset_item_dataset_fk": { + "name": "dataset_item_dataset_fk", + "tableFrom": "dataset_item", + "tableTo": "dataset", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_result": { + "name": "eval_result", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "suite_run_id": { + "name": "suite_run_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dataset_item_id": { + "name": "dataset_item_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_result_conversation_fk": { + "name": "eval_result_conversation_fk", + "tableFrom": "eval_result", + "tableTo": "conversations", + "columnsFrom": [ + "tenant_id", + "project_id", + "conversation_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_result_evaluator_fk": { + "name": "eval_result_evaluator_fk", + "tableFrom": "eval_result", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_result_dataset_item_fk": { + "name": "eval_result_dataset_item_fk", + "tableFrom": "eval_result", + "tableTo": "dataset_item", + "columnsFrom": [ + "dataset_item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_config": { + "name": "eval_test_suite_config", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "run_frequency": { + "name": "run_frequency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "eval_test_suite_config_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "eval_test_suite_config_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_run": { + "name": "eval_test_suite_run", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dataset_id": { + "name": "dataset_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "test_suite_config_id": { + "name": "test_suite_config_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_test_suite_run_dataset_fk": { + "name": "eval_test_suite_run_dataset_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "dataset", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_agent_fk": { + "name": "eval_test_suite_run_agent_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "agent", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_config_fk": { + "name": "eval_test_suite_run_config_fk", + "tableFrom": "eval_test_suite_run", + "tableTo": "eval_test_suite_config", + "columnsFrom": [ + "test_suite_config_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "eval_test_suite_run_evaluators": { + "name": "eval_test_suite_run_evaluators", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "eval_test_suite_run_id": { + "name": "eval_test_suite_run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "evaluator_id": { + "name": "evaluator_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "eval_test_suite_run_evaluators_run_fk": { + "name": "eval_test_suite_run_evaluators_run_fk", + "tableFrom": "eval_test_suite_run_evaluators", + "tableTo": "eval_test_suite_run", + "columnsFrom": [ + "eval_test_suite_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "eval_test_suite_run_evaluators_evaluator_fk": { + "name": "eval_test_suite_run_evaluators_evaluator_fk", + "tableFrom": "eval_test_suite_run_evaluators", + "tableTo": "evaluator", + "columnsFrom": [ + "tenant_id", + "evaluator_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "evaluator": { + "name": "evaluator", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schema": { + "name": "schema", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_config": { + "name": "model_config", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "evaluator_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "evaluator_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "external_agents": { + "name": "external_agents", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_reference_id": { + "name": "credential_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "external_agents_project_fk": { + "name": "external_agents_project_fk", + "tableFrom": "external_agents", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "external_agents_credential_reference_fk": { + "name": "external_agents_credential_reference_fk", + "tableFrom": "external_agents", + "tableTo": "credential_references", + "columnsFrom": [ + "tenant_id", + "project_id", + "credential_reference_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "external_agents_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "external_agents_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "function_tools": { + "name": "function_tools", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "function_id": { + "name": "function_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "function_tools_agent_fk": { + "name": "function_tools_agent_fk", + "tableFrom": "function_tools", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "function_tools_function_fk": { + "name": "function_tools_function_fk", + "tableFrom": "function_tools", + "tableTo": "functions", + "columnsFrom": [ + "tenant_id", + "project_id", + "function_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "function_tools_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "function_tools_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "functions": { + "name": "functions", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "input_schema": { + "name": "input_schema", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "execute_code": { + "name": "execute_code", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dependencies": { + "name": "dependencies", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "functions_project_fk": { + "name": "functions_project_fk", + "tableFrom": "functions", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "functions_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "functions_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ledger_artifacts": { + "name": "ledger_artifacts", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'source'" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parts": { + "name": "parts", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "mime": { + "name": "mime", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'context'" + }, + "allowed_agents": { + "name": "allowed_agents", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "derived_from": { + "name": "derived_from", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "ledger_artifacts_task_id_idx": { + "name": "ledger_artifacts_task_id_idx", + "columns": [ + "task_id" + ], + "isUnique": false + }, + "ledger_artifacts_tool_call_id_idx": { + "name": "ledger_artifacts_tool_call_id_idx", + "columns": [ + "tool_call_id" + ], + "isUnique": false + }, + "ledger_artifacts_context_id_idx": { + "name": "ledger_artifacts_context_id_idx", + "columns": [ + "context_id" + ], + "isUnique": false + }, + "ledger_artifacts_task_context_name_unique": { + "name": "ledger_artifacts_task_context_name_unique", + "columns": [ + "task_id", + "context_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "ledger_artifacts_project_fk": { + "name": "ledger_artifacts_project_fk", + "tableFrom": "ledger_artifacts", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "ledger_artifacts_tenant_id_project_id_id_task_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id", + "task_id" + ], + "name": "ledger_artifacts_tenant_id_project_id_id_task_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "messages": { + "name": "messages", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "from_sub_agent_id": { + "name": "from_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_sub_agent_id": { + "name": "to_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "from_external_sub_agent_id": { + "name": "from_external_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_external_sub_agent_id": { + "name": "to_external_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "from_team_agent_id": { + "name": "from_team_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "to_team_agent_id": { + "name": "to_team_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'user-facing'" + }, + "message_type": { + "name": "message_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'chat'" + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parent_message_id": { + "name": "parent_message_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "a2a_task_id": { + "name": "a2a_task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "a2a_session_id": { + "name": "a2a_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "messages_project_fk": { + "name": "messages_project_fk", + "tableFrom": "messages", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "messages_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "messages_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "projects": { + "name": "projects", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "projects_tenant_id_id_pk": { + "columns": [ + "tenant_id", + "id" + ], + "name": "projects_tenant_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_artifact_components": { + "name": "sub_agent_artifact_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "artifact_component_id": { + "name": "artifact_component_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_artifact_components_sub_agent_fk": { + "name": "sub_agent_artifact_components_sub_agent_fk", + "tableFrom": "sub_agent_artifact_components", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_artifact_components_artifact_component_fk": { + "name": "sub_agent_artifact_components_artifact_component_fk", + "tableFrom": "sub_agent_artifact_components", + "tableTo": "artifact_components", + "columnsFrom": [ + "tenant_id", + "project_id", + "artifact_component_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_artifact_components_tenant_id_project_id_agent_id_sub_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id", + "id" + ], + "name": "sub_agent_artifact_components_tenant_id_project_id_agent_id_sub_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_data_components": { + "name": "sub_agent_data_components", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "data_component_id": { + "name": "data_component_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_data_components_sub_agent_fk": { + "name": "sub_agent_data_components_sub_agent_fk", + "tableFrom": "sub_agent_data_components", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_data_components_data_component_fk": { + "name": "sub_agent_data_components_data_component_fk", + "tableFrom": "sub_agent_data_components", + "tableTo": "data_components", + "columnsFrom": [ + "tenant_id", + "project_id", + "data_component_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_data_components_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "sub_agent_data_components_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_external_agent_relations": { + "name": "sub_agent_external_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "external_agent_id": { + "name": "external_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_external_agent_relations_sub_agent_fk": { + "name": "sub_agent_external_agent_relations_sub_agent_fk", + "tableFrom": "sub_agent_external_agent_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_external_agent_relations_external_agent_fk": { + "name": "sub_agent_external_agent_relations_external_agent_fk", + "tableFrom": "sub_agent_external_agent_relations", + "tableTo": "external_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "external_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_external_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_external_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_function_tool_relations": { + "name": "sub_agent_function_tool_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "function_tool_id": { + "name": "function_tool_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_function_tool_relations_sub_agent_fk": { + "name": "sub_agent_function_tool_relations_sub_agent_fk", + "tableFrom": "sub_agent_function_tool_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_function_tool_relations_function_tool_fk": { + "name": "sub_agent_function_tool_relations_function_tool_fk", + "tableFrom": "sub_agent_function_tool_relations", + "tableTo": "function_tools", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "function_tool_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_function_tool_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_function_tool_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_relations": { + "name": "sub_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_sub_agent_id": { + "name": "source_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_sub_agent_id": { + "name": "target_sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "relation_type": { + "name": "relation_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_relations_agent_fk": { + "name": "sub_agent_relations_agent_fk", + "tableFrom": "sub_agent_relations", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_team_agent_relations": { + "name": "sub_agent_team_agent_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "target_agent_id": { + "name": "target_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_team_agent_relations_sub_agent_fk": { + "name": "sub_agent_team_agent_relations_sub_agent_fk", + "tableFrom": "sub_agent_team_agent_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_team_agent_relations_target_agent_fk": { + "name": "sub_agent_team_agent_relations_target_agent_fk", + "tableFrom": "sub_agent_team_agent_relations", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "target_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_team_agent_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_team_agent_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agent_tool_relations": { + "name": "sub_agent_tool_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_id": { + "name": "tool_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "selected_tools": { + "name": "selected_tools", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agent_tool_relations_agent_fk": { + "name": "sub_agent_tool_relations_agent_fk", + "tableFrom": "sub_agent_tool_relations", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sub_agent_tool_relations_tool_fk": { + "name": "sub_agent_tool_relations_tool_fk", + "tableFrom": "sub_agent_tool_relations", + "tableTo": "tools", + "columnsFrom": [ + "tenant_id", + "project_id", + "tool_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agent_tool_relations_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agent_tool_relations_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sub_agents": { + "name": "sub_agents", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "conversation_history_config": { + "name": "conversation_history_config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models": { + "name": "models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stop_when": { + "name": "stop_when", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "sub_agents_agents_fk": { + "name": "sub_agents_agents_fk", + "tableFrom": "sub_agents", + "tableTo": "agent", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sub_agents_tenant_id_project_id_agent_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "name": "sub_agents_tenant_id_project_id_agent_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "task_relations": { + "name": "task_relations", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parent_task_id": { + "name": "parent_task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "child_task_id": { + "name": "child_task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "relation_type": { + "name": "relation_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'parent_child'" + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "task_relations_project_fk": { + "name": "task_relations_project_fk", + "tableFrom": "task_relations", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_relations_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "task_relations_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tasks": { + "name": "tasks", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sub_agent_id": { + "name": "sub_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "tasks_sub_agent_fk": { + "name": "tasks_sub_agent_fk", + "tableFrom": "tasks", + "tableTo": "sub_agents", + "columnsFrom": [ + "tenant_id", + "project_id", + "agent_id", + "sub_agent_id" + ], + "columnsTo": [ + "tenant_id", + "project_id", + "agent_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tasks_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "tasks_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tools": { + "name": "tools", + "columns": { + "tenant_id": { + "name": "tenant_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "config": { + "name": "config", + "type": "blob", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credential_reference_id": { + "name": "credential_reference_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "capabilities": { + "name": "capabilities", + "type": "blob", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "tools_project_fk": { + "name": "tools_project_fk", + "tableFrom": "tools", + "tableTo": "projects", + "columnsFrom": [ + "tenant_id", + "project_id" + ], + "columnsTo": [ + "tenant_id", + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "tools_tenant_id_project_id_id_pk": { + "columns": [ + "tenant_id", + "project_id", + "id" + ], + "name": "tools_tenant_id_project_id_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/agents-core/drizzle/meta/_journal.json b/packages/agents-core/drizzle/meta/_journal.json index 187f93d88..33dfe611c 100644 --- a/packages/agents-core/drizzle/meta/_journal.json +++ b/packages/agents-core/drizzle/meta/_journal.json @@ -106,6 +106,34 @@ "when": 1761227891220, "tag": "0014_broad_hellfire_club", "breakpoints": true + }, + { + "idx": 15, + "version": "6", + "when": 1762356571291, + "tag": "0015_yielding_natasha_romanoff", + "breakpoints": true + }, + { + "idx": 16, + "version": "6", + "when": 1762356703460, + "tag": "0016_yellow_pretty_boy", + "breakpoints": true + }, + { + "idx": 17, + "version": "6", + "when": 1762356785040, + "tag": "0017_colossal_kate_bishop", + "breakpoints": true + }, + { + "idx": 18, + "version": "6", + "when": 1762357022031, + "tag": "0018_calm_ultimo", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/agents-core/src/data-access/eval.ts b/packages/agents-core/src/data-access/eval.ts new file mode 100644 index 000000000..dcb225611 --- /dev/null +++ b/packages/agents-core/src/data-access/eval.ts @@ -0,0 +1,818 @@ +import { and, eq, gte, inArray, lte } from 'drizzle-orm'; +import type { DatabaseClient } from '../db/client'; +import { + conversationEvaluationConfig, + conversationEvaluationConfigEvaluator, + conversations, + dataset, + datasetItem, + evalResult, + evalTestSuiteConfig, + evaluator, + subAgents, +} from '../db/schema'; + +/** + * Get conversations for evaluation based on filter criteria + */ +export const getConversationsForEvaluation = + (db: DatabaseClient) => + async (params: { + scopes: { tenantId: string }; + filter?: { + agentIds?: string[]; + projectIds?: string[]; + dateRange?: { + startDate: string; + endDate: string; + }; + conversationIds?: string[]; + }; + }): Promise<(typeof conversations.$inferSelect)[]> => { + const { tenantId } = params.scopes; + const { filter } = params; + + const needsAgentJoin = Boolean(filter?.agentIds?.length); + const whereClauses = [ + eq(conversations.tenantId, tenantId), + ...(filter?.projectIds?.length ? [inArray(conversations.projectId, filter.projectIds)] : []), + ...(filter?.dateRange + ? [ + gte(conversations.createdAt, filter.dateRange.startDate), + lte(conversations.createdAt, filter.dateRange.endDate), + ] + : []), + ...(filter?.conversationIds?.length + ? [inArray(conversations.id, filter.conversationIds)] + : []), + ]; + + // If filtering by agentIds, join subAgents to resolve activeSubAgentId -> agentId + if (needsAgentJoin) { + const rows = await db + .select({ c: conversations }) + .from(conversations) + .innerJoin( + subAgents, + and( + eq(conversations.activeSubAgentId, subAgents.id), + eq(conversations.tenantId, subAgents.tenantId), + eq(conversations.projectId, subAgents.projectId) + ) + ) + .where(and(...whereClauses, inArray(subAgents.agentId, filter!.agentIds!))); + + return rows.map((r) => r.c); + } + + // Otherwise, simple query + return await db + .select() + .from(conversations) + .where(and(...whereClauses)); + }; + +/** + * Get conversation evaluation config by ID + */ +export const getConversationEvaluationConfig = + (db: DatabaseClient) => + async (params: { tenantId: string; conversationEvaluationConfigId: string }) => { + const { tenantId, conversationEvaluationConfigId } = params; + + return await db.query.conversationEvaluationConfig.findFirst({ + where: and( + eq(conversationEvaluationConfig.tenantId, tenantId), + eq(conversationEvaluationConfig.id, conversationEvaluationConfigId) + ), + }); + }; + +/** + * Get evaluators for a conversation evaluation config + * Uses a join to fetch evaluators linked to a config in a single query + */ +export const getEvaluatorsForConfig = + (db: DatabaseClient) => + async (params: { + tenantId: string; + conversationEvaluationConfigId: string; + }): Promise<(typeof evaluator.$inferSelect)[]> => { + const { tenantId, conversationEvaluationConfigId } = params; + + const rows = await db + .select({ evaluator }) + .from(conversationEvaluationConfigEvaluator) + .innerJoin( + evaluator, + and( + eq(conversationEvaluationConfigEvaluator.evaluatorId, evaluator.id), + eq(evaluator.tenantId, tenantId) + ) + ) + .where( + eq( + conversationEvaluationConfigEvaluator.conversationEvaluationConfigId, + conversationEvaluationConfigId + ) + ); + + return rows.map((r) => r.evaluator); + }; + +/** + * Create eval result + */ +export const createEvalResult = + (db: DatabaseClient) => + async (params: { + tenantId: string; + projectId: string; + conversationId: string; + evaluatorId: string; + status: 'pending' | 'done' | 'failed'; + reasoning?: string; + metadata?: Record; + suiteRunId?: string; + datasetItemId?: string; + }) => { + const [result] = await db + .insert(evalResult) + .values({ + id: `eval_result_${Date.now()}`, + tenantId: params.tenantId, + projectId: params.projectId, + conversationId: params.conversationId, + evaluatorId: params.evaluatorId, + status: params.status, + reasoning: params.reasoning, + metadata: params.metadata, + suiteRunId: params.suiteRunId, + datasetItemId: params.datasetItemId, + }) + .returning(); + + return result; + }; + +/** + * Update eval result status and data + */ +export const updateEvalResult = + (db: DatabaseClient) => + async (params: { + id: string; + status: 'pending' | 'done' | 'failed'; + reasoning?: string; + metadata?: Record; + }) => { + const now = new Date().toISOString(); + const updates: Record = { + status: params.status, + updatedAt: now + }; + + if (params.reasoning !== undefined) updates.reasoning = params.reasoning; + if (params.metadata !== undefined) updates.metadata = params.metadata; + + const [result] = await db + .update(evalResult) + .set(updates) + .where(eq(evalResult.id, params.id)) + .returning(); + + return result; + }; + +/** + * Get eval results by conversation + */ +export const getEvalResultsByConversation = + (db: DatabaseClient) => async (params: { conversationId: string }) => { + const { conversationId } = params; + + return await db.query.evalResult.findMany({ + where: eq(evalResult.conversationId, conversationId), + orderBy: (evalResult, { desc }) => [desc(evalResult.createdAt)], + }); + }; + +/** + * Get eval results by evaluator + */ +export const getEvalResultsByEvaluator = + (db: DatabaseClient) => async (params: { evaluatorId: string }) => { + const { evaluatorId } = params; + + return await db.query.evalResult.findMany({ + where: eq(evalResult.evaluatorId, evaluatorId), + orderBy: (evalResult, { desc }) => [desc(evalResult.createdAt)], + }); + }; + +/** + * Get eval result by id + */ +export const getEvalResult = (db: DatabaseClient) => async (params: { id: string }) => { + return await db.query.evalResult.findFirst({ + where: eq(evalResult.id, params.id), + }); +}; + +/** + * Get agentId from a conversation's activeSubAgentId + */ +export const getAgentIdFromConversation = + (db: DatabaseClient) => + async (params: { tenantId: string; projectId: string; activeSubAgentId: string }) => { + const subAgent = await db.query.subAgents.findFirst({ + where: and( + eq(subAgents.tenantId, params.tenantId), + eq(subAgents.projectId, params.projectId), + eq(subAgents.id, params.activeSubAgentId) + ), + }); + + return subAgent?.agentId || null; + }; + +/** + * Delete eval result by id + */ +export const deleteEvalResult = (db: DatabaseClient) => async (params: { id: string }) => { + const [deleted] = await db.delete(evalResult).where(eq(evalResult.id, params.id)).returning(); + + return deleted ?? null; +}; + +/** + * Create evaluator + */ +export const createEvaluator = + (db: DatabaseClient) => + async (params: { + tenantId: string; + id?: string; + name: string; + description?: string; + prompt: string; + schema: Record; + modelConfig?: Record; + }) => { + const now = new Date().toISOString(); + const [row] = await db + .insert(evaluator) + .values({ + tenantId: params.tenantId, + id: params.id ?? `evaluator_${Date.now()}`, + name: params.name, + description: params.description ?? '', + prompt: params.prompt, + schema: params.schema, + modelConfig: params.modelConfig as any, + createdAt: now, + updatedAt: now, + }) + .returning(); + + return row; + }; + +/** + * Get evaluator by id (tenant-scoped) + */ +export const getEvaluator = + (db: DatabaseClient) => async (params: { tenantId: string; evaluatorId: string }) => { + return await db.query.evaluator.findFirst({ + where: and(eq(evaluator.tenantId, params.tenantId), eq(evaluator.id, params.evaluatorId)), + }); + }; + +/** + * List evaluators (tenant-scoped) + */ +export const listEvaluators = (db: DatabaseClient) => async (params: { tenantId: string }) => { + return await db.query.evaluator.findMany({ + where: eq(evaluator.tenantId, params.tenantId), + orderBy: (t, { desc }) => [desc(t.createdAt)], + }); +}; + +/** + * Update evaluator + */ +export const updateEvaluator = + (db: DatabaseClient) => + async (params: { + tenantId: string; + evaluatorId: string; + name?: string; + description?: string; + prompt?: string; + schema?: Record; + modelConfig?: Record; + }) => { + const now = new Date().toISOString(); + const updates: Record = { updatedAt: now }; + + if (params.name !== undefined) updates.name = params.name; + if (params.description !== undefined) updates.description = params.description; + if (params.prompt !== undefined) updates.prompt = params.prompt; + if (params.schema !== undefined) updates.schema = params.schema; + if (params.modelConfig !== undefined) updates.modelConfig = params.modelConfig; + + const [row] = await db + .update(evaluator) + .set(updates) + .where(and(eq(evaluator.tenantId, params.tenantId), eq(evaluator.id, params.evaluatorId))) + .returning(); + + return row ?? null; + }; + +/** + * Delete evaluator + */ +export const deleteEvaluator = + (db: DatabaseClient) => async (params: { tenantId: string; evaluatorId: string }) => { + const [row] = await db + .delete(evaluator) + .where(and(eq(evaluator.tenantId, params.tenantId), eq(evaluator.id, params.evaluatorId))) + .returning(); + + return row ?? null; + }; + +/** + * Conversation Evaluation Config - Create + */ +export const createConversationEvaluationConfig = + (db: DatabaseClient) => + async (params: { + tenantId: string; + id?: string; + name: string; + description?: string | null; + conversationFilter?: { + agentIds?: string[]; + projectIds?: string[]; + dateRange?: { startDate: string; endDate: string }; + conversationIds?: string[]; + } | null; + modelConfig?: Record | null; + sampleRate?: number | null; + isActive?: boolean; + }) => { + const now = new Date().toISOString(); + const [row] = await db + .insert(conversationEvaluationConfig) + .values({ + tenantId: params.tenantId, + id: params.id ?? `conv_eval_cfg_${Date.now()}`, + name: params.name, + description: params.description ?? '', + conversationFilter: params.conversationFilter ?? undefined, + modelConfig: params.modelConfig ?? undefined, + sampleRate: params.sampleRate ?? undefined, + isActive: params.isActive ?? true, + createdAt: now, + updatedAt: now, + }) + .returning(); + + return row; + }; + +/** + * Conversation Evaluation Config - List (by tenant) + */ +export const listConversationEvaluationConfigs = + (db: DatabaseClient) => async (params: { tenantId: string }) => { + return await db.query.conversationEvaluationConfig.findMany({ + where: eq(conversationEvaluationConfig.tenantId, params.tenantId), + orderBy: (t, { desc }) => [desc(t.createdAt)], + }); + }; + +/** + * Conversation Evaluation Config - Update + */ +export const updateConversationEvaluationConfig = + (db: DatabaseClient) => + async (params: { + tenantId: string; + id: string; + name?: string; + description?: string; + conversationFilter?: { + agentIds?: string[]; + projectIds?: string[]; + dateRange?: { startDate: string; endDate: string }; + conversationIds?: string[]; + }; + modelConfig?: Record; + sampleRate?: number; + isActive?: boolean; + }) => { + const now = new Date().toISOString(); + const updates: Record = { updatedAt: now }; + + if (params.name !== undefined) updates.name = params.name; + if (params.description !== undefined) updates.description = params.description; + if (params.conversationFilter !== undefined) updates.conversationFilter = params.conversationFilter; + if (params.modelConfig !== undefined) updates.modelConfig = params.modelConfig; + if (params.sampleRate !== undefined) updates.sampleRate = params.sampleRate; + if (params.isActive !== undefined) updates.isActive = params.isActive; + + const [row] = await db + .update(conversationEvaluationConfig) + .set(updates) + .where( + and( + eq(conversationEvaluationConfig.tenantId, params.tenantId), + eq(conversationEvaluationConfig.id, params.id) + ) + ) + .returning(); + + return row ?? null; + }; + +/** + * Conversation Evaluation Config - Delete + */ +export const deleteConversationEvaluationConfig = + (db: DatabaseClient) => async (params: { tenantId: string; id: string }) => { + const [row] = await db + .delete(conversationEvaluationConfig) + .where( + and( + eq(conversationEvaluationConfig.tenantId, params.tenantId), + eq(conversationEvaluationConfig.id, params.id) + ) + ) + .returning(); + + return row ?? null; + }; + +/** + * Conversation Evaluation Config - Start (isActive=true) + */ +export const startConversationEvaluationConfig = + (db: DatabaseClient) => async (params: { tenantId: string; id: string }) => { + return await updateConversationEvaluationConfig(db)({ + tenantId: params.tenantId, + id: params.id, + isActive: true, + }); + }; + +/** + * Conversation Evaluation Config - Stop (isActive=false) + */ +export const stopConversationEvaluationConfig = + (db: DatabaseClient) => async (params: { tenantId: string; id: string }) => { + return await updateConversationEvaluationConfig(db)({ + tenantId: params.tenantId, + id: params.id, + isActive: false, + }); + }; + +/** + * Link an evaluator to a conversation evaluation config + */ +export const linkEvaluatorToConfig = + (db: DatabaseClient) => + async (params: { + tenantId: string; + conversationEvaluationConfigId: string; + evaluatorId: string; + }) => { + const now = new Date().toISOString(); + const [row] = await db + .insert(conversationEvaluationConfigEvaluator) + .values({ + id: `${Date.now()}_${Math.random().toString(36).substring(7)}`, + tenantId: params.tenantId, + conversationEvaluationConfigId: params.conversationEvaluationConfigId, + evaluatorId: params.evaluatorId, + createdAt: now, + updatedAt: now, + }) + .returning(); + + return row; + }; + +/** + * Dataset - Create + */ +export const createDataset = + (db: DatabaseClient) => + async (params: { + tenantId: string; + id?: string; + name: string; + description?: string; + metadata?: Record; + }) => { + const now = new Date().toISOString(); + const [row] = await db + .insert(dataset) + .values({ + tenantId: params.tenantId, + id: params.id ?? `dataset_${Date.now()}`, + name: params.name, + description: params.description ?? '', + metadata: params.metadata ?? undefined, + createdAt: now, + updatedAt: now, + }) + .returning(); + + return row; + }; + +/** + * Dataset - Get by ID (tenant-scoped) + */ +export const getDataset = + (db: DatabaseClient) => async (params: { tenantId: string; datasetId: string }) => { + return await db.query.dataset.findFirst({ + where: and(eq(dataset.tenantId, params.tenantId), eq(dataset.id, params.datasetId)), + }); + }; + +/** + * Dataset - List (tenant-scoped) + */ +export const listDatasets = (db: DatabaseClient) => async (params: { tenantId: string }) => { + return await db.query.dataset.findMany({ + where: eq(dataset.tenantId, params.tenantId), + orderBy: (t, { desc }) => [desc(t.createdAt)], + }); +}; + +/** + * Dataset - Update + */ +export const updateDataset = + (db: DatabaseClient) => + async (params: { + tenantId: string; + datasetId: string; + name?: string; + description?: string; + metadata?: Record; + }) => { + const now = new Date().toISOString(); + const updates: Record = { updatedAt: now }; + + if (params.name !== undefined) updates.name = params.name; + if (params.description !== undefined) updates.description = params.description; + if (params.metadata !== undefined) updates.metadata = params.metadata; + + const [row] = await db + .update(dataset) + .set(updates) + .where(and(eq(dataset.tenantId, params.tenantId), eq(dataset.id, params.datasetId))) + .returning(); + + return row ?? null; + }; + +/** + * Dataset - Delete + */ +export const deleteDataset = + (db: DatabaseClient) => async (params: { tenantId: string; datasetId: string }) => { + const [row] = await db + .delete(dataset) + .where(and(eq(dataset.tenantId, params.tenantId), eq(dataset.id, params.datasetId))) + .returning(); + + return row ?? null; + }; + +/** + * Dataset Item - Create + */ +export const createDatasetItem = + (db: DatabaseClient) => + async (params: { + id?: string; + datasetId: string; + input?: { + messages: Array<{ role: string; content: unknown }>; + headers?: Record; + }; + expectedOutput?: Array<{ role: string; content: unknown }>; + simulationConfig?: { + userPersona: string; + initialMessage?: string; + maxTurns?: number; + stoppingCondition?: string; + simulatingAgentDefinition: { + name: string; + description: string; + prompt: string; + modelConfig?: Record; + }; + }; + }) => { + const now = new Date().toISOString(); + const [row] = await db + .insert(datasetItem) + .values({ + id: params.id ?? `dataset_item_${Date.now()}`, + datasetId: params.datasetId, + input: (params.input as any) ?? undefined, + expectedOutput: (params.expectedOutput as any) ?? undefined, + simulationConfig: (params.simulationConfig as any) ?? undefined, + createdAt: now, + updatedAt: now, + }) + .returning(); + + return row; + }; + +/** + * Dataset Item - Get by ID + */ +export const getDatasetItem = (db: DatabaseClient) => async (params: { id: string }) => { + return await db.query.datasetItem.findFirst({ + where: eq(datasetItem.id, params.id), + }); +}; + +/** + * Dataset Item - List (by dataset ID) + */ +export const listDatasetItems = (db: DatabaseClient) => async (params: { datasetId: string }) => { + return await db.query.datasetItem.findMany({ + where: eq(datasetItem.datasetId, params.datasetId), + orderBy: (t, { desc }) => [desc(t.createdAt)], + }); +}; + +/** + * Dataset Item - Update + */ +export const updateDatasetItem = + (db: DatabaseClient) => + async (params: { + id: string; + input?: { + messages: Array<{ role: string; content: unknown }>; + headers?: Record; + }; + expectedOutput?: Array<{ role: string; content: unknown }>; + simulationConfig?: { + userPersona: string; + initialMessage?: string; + maxTurns?: number; + stoppingCondition?: string; + simulatingAgentDefinition: { + name: string; + description: string; + prompt: string; + modelConfig?: Record; + }; + }; + }) => { + const now = new Date().toISOString(); + const updates: Record = { updatedAt: now }; + + if (params.input !== undefined) updates.input = params.input; + if (params.expectedOutput !== undefined) updates.expectedOutput = params.expectedOutput; + if (params.simulationConfig !== undefined) updates.simulationConfig = params.simulationConfig; + + const [row] = await db + .update(datasetItem) + .set(updates) + .where(eq(datasetItem.id, params.id)) + .returning(); + + return row ?? null; + }; + +/** + * Dataset Item - Delete + */ +export const deleteDatasetItem = (db: DatabaseClient) => async (params: { id: string }) => { + const [row] = await db.delete(datasetItem).where(eq(datasetItem.id, params.id)).returning(); + + return row ?? null; +}; + +/** + * Eval Test Suite Config - Create + */ +export const createEvalTestSuiteConfig = + (db: DatabaseClient) => + async (params: { + tenantId: string; + id?: string; + name: string; + description?: string; + modelConfig?: Record; + runFrequency: string; + }) => { + const now = new Date().toISOString(); + const [row] = await db + .insert(evalTestSuiteConfig) + .values({ + tenantId: params.tenantId, + id: params.id ?? `eval_test_suite_cfg_${Date.now()}`, + name: params.name, + description: params.description ?? '', + modelConfig: params.modelConfig as any, + runFrequency: params.runFrequency, + createdAt: now, + updatedAt: now, + }) + .returning(); + + return row; + }; + +/** + * Eval Test Suite Config - Get by ID (tenant-scoped) + */ +export const getEvalTestSuiteConfig = + (db: DatabaseClient) => async (params: { tenantId: string; evalTestSuiteConfigId: string }) => { + return await db.query.evalTestSuiteConfig.findFirst({ + where: and( + eq(evalTestSuiteConfig.tenantId, params.tenantId), + eq(evalTestSuiteConfig.id, params.evalTestSuiteConfigId) + ), + }); + }; + +/** + * Eval Test Suite Config - List (tenant-scoped) + */ +export const listEvalTestSuiteConfigs = + (db: DatabaseClient) => async (params: { tenantId: string }) => { + return await db.query.evalTestSuiteConfig.findMany({ + where: eq(evalTestSuiteConfig.tenantId, params.tenantId), + orderBy: (t, { desc }) => [desc(t.createdAt)], + }); + }; + +/** + * Eval Test Suite Config - Update + */ +export const updateEvalTestSuiteConfig = + (db: DatabaseClient) => + async (params: { + tenantId: string; + id: string; + name?: string; + description?: string; + modelConfig?: Record; + runFrequency?: string; + }) => { + const now = new Date().toISOString(); + const updates: Record = { updatedAt: now }; + + if (params.name !== undefined) updates.name = params.name; + if (params.description !== undefined) updates.description = params.description; + if (params.modelConfig !== undefined) updates.modelConfig = params.modelConfig; + if (params.runFrequency !== undefined) updates.runFrequency = params.runFrequency; + + const [row] = await db + .update(evalTestSuiteConfig) + .set(updates) + .where( + and( + eq(evalTestSuiteConfig.tenantId, params.tenantId), + eq(evalTestSuiteConfig.id, params.id) + ) + ) + .returning(); + + return row ?? null; + }; + +/** + * Eval Test Suite Config - Delete + */ +export const deleteEvalTestSuiteConfig = + (db: DatabaseClient) => async (params: { tenantId: string; id: string }) => { + const [row] = await db + .delete(evalTestSuiteConfig) + .where( + and( + eq(evalTestSuiteConfig.tenantId, params.tenantId), + eq(evalTestSuiteConfig.id, params.id) + ) + ) + .returning(); + + return row ?? null; + }; + diff --git a/packages/agents-core/src/data-access/index.ts b/packages/agents-core/src/data-access/index.ts index 7a5393dc4..97a4f42b9 100644 --- a/packages/agents-core/src/data-access/index.ts +++ b/packages/agents-core/src/data-access/index.ts @@ -10,6 +10,7 @@ export * from './contextConfigs'; export * from './conversations'; export * from './credentialReferences'; export * from './dataComponents'; +export * from './eval'; export * from './externalAgents'; export * from './functions'; export * from './functionTools'; diff --git a/packages/agents-core/src/db/schema.ts b/packages/agents-core/src/db/schema.ts index 299e33a6b..b50365509 100644 --- a/packages/agents-core/src/db/schema.ts +++ b/packages/agents-core/src/db/schema.ts @@ -5,6 +5,7 @@ import { index, integer, primaryKey, + real, sqliteTable, text, unique, @@ -23,7 +24,7 @@ import type { ToolMcpConfig, ToolServerCapabilities, } from '../types/utility'; -import type { AgentStopWhen, StopWhen, SubAgentStopWhen } from '../validation/schemas'; +import type { AgentStopWhen, ModelSettings, StopWhen, SubAgentStopWhen } from '../validation/schemas'; const tenantScoped = { tenantId: text('tenant_id').notNull(), @@ -679,6 +680,223 @@ export const credentialReferences = sqliteTable( ] ); +export const dataset = sqliteTable( + 'dataset', + { + ...tenantScoped, + ...uiProperties, + metadata: blob('metadata', { mode: 'json' }).$type>(), + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.tenantId, table.id] }), + ] +); + +export const datasetItem = sqliteTable( + 'dataset_item', + { + id: text('id').notNull(), + datasetId: text('dataset_id').notNull(), + input: blob('input', { mode: 'json' }).$type<{ + messages: Array<{ role: string; content: MessageContent }>; + headers?: Record; + }>(), + expectedOutput: blob('expected_output', { mode: 'json' }).$type>(), + simulationConfig: blob('simulation_config', { mode: 'json' }).$type<{ + userPersona: string; + initialMessage?: string; + maxTurns?: number; + stoppingCondition?: string; + simulatingAgentDefinition: { + name: string; + description: string; + prompt: string; + model: string; + temperature?: number; + }; + }>(), + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.id] }), + foreignKey({ + columns: [table.datasetId], + foreignColumns: [dataset.id], + name: 'dataset_item_dataset_fk', + }).onDelete('cascade'), + ] +); + +export const evaluator = sqliteTable( + 'evaluator', + { + ...tenantScoped, + ...uiProperties, + prompt: text('prompt').notNull(), + schema: blob('schema', { mode: 'json' }).$type>().notNull(), + modelConfig: blob('model_config', { mode: 'json' }).$type(), + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.tenantId, table.id] }), + ] +); + +export const evalTestSuiteConfig = sqliteTable( + 'eval_test_suite_config', + { + ...tenantScoped, + ...uiProperties, + modelConfig: blob('model_config', { mode: 'json' }).$type(), + runFrequency: text('run_frequency').notNull(), // e.g., 'weekly', 'daily', 'monthly', + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.tenantId, table.id] }), + ] +); + +export const evalTestSuiteRun = sqliteTable( + 'eval_test_suite_run', + { + id: text('id').notNull(), + name: text('name').notNull(), + description: text('description').notNull(), + datasetId: text('dataset_id').notNull(), + agentId: text('agent_id').notNull(), + testSuiteConfigId: text('test_suite_config_id').notNull(), + status: text('status').$type<'pending'|'done'|'failed'>().notNull(), + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.id] }), + foreignKey({ + columns: [table.datasetId], + foreignColumns: [dataset.id], + name: 'eval_test_suite_run_dataset_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.agentId], + foreignColumns: [agents.id], + name: 'eval_test_suite_run_agent_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.testSuiteConfigId], + foreignColumns: [evalTestSuiteConfig.id], + name: 'eval_test_suite_run_config_fk', + }).onDelete('cascade'), + ] +); + +export const evalTestSuiteRunEvaluator = sqliteTable( + 'eval_test_suite_run_evaluators', + { + id: text('id').notNull(), + evalTestSuiteRunId: text('eval_test_suite_run_id').notNull(), + tenantId: text('tenant_id').notNull(), + evaluatorId: text('evaluator_id').notNull(), + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.id] }), + foreignKey({ + columns: [table.evalTestSuiteRunId], + foreignColumns: [evalTestSuiteRun.id], + name: 'eval_test_suite_run_evaluators_run_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.tenantId, table.evaluatorId], + foreignColumns: [evaluator.tenantId, evaluator.id], + name: 'eval_test_suite_run_evaluators_evaluator_fk', + }).onDelete('cascade'), + ] +); + +export const evalResult = sqliteTable( + 'eval_result', + { + id: text('id').notNull(), + suiteRunId: text('suite_run_id'), + datasetItemId: text('dataset_item_id'), + conversationId: text('conversation_id').notNull(), + status: text('status').$type<'pending'|'done'|'failed'>().notNull(), + tenantId: text('tenant_id').notNull(), + projectId: text('project_id').notNull(), + evaluatorId: text('evaluator_id').notNull(), + reasoning: text('reasoning'), + metadata: blob('metadata', { mode: 'json' }).$type>(), + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.id] }), + foreignKey({ + columns: [table.tenantId, table.projectId, table.conversationId], + foreignColumns: [conversations.tenantId, conversations.projectId, conversations.id], + name: 'eval_result_conversation_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.tenantId, table.evaluatorId], + foreignColumns: [evaluator.tenantId, evaluator.id], + name: 'eval_result_evaluator_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.datasetItemId], + foreignColumns: [datasetItem.id], + name: 'eval_result_dataset_item_fk', + }).onDelete('cascade'), + ] +); + +export const +conversationEvaluationConfig = sqliteTable( + 'conversation_evaluation_config', + { + ...tenantScoped, + ...uiProperties, + conversationFilter: blob('conversation_filter', { mode: 'json' }).$type<{ + agentIds?: string[]; + projectIds?: string[]; + dateRange?: { + startDate: string; + endDate: string; + }; + conversationIds?: string[]; + }>(), + modelConfig: blob('model_config', { mode: 'json' }).$type(), + sampleRate: real('sample_rate'), + isActive: integer('is_active', { mode: 'boolean' }).notNull(), + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.tenantId, table.id] }), + ] +); + +export const conversationEvaluationConfigEvaluator = sqliteTable( + 'conversation_evaluation_config_evaluator', + { + id: text('id').notNull(), + conversationEvaluationConfigId: text('conversation_evaluation_config_id').notNull(), + tenantId: text('tenant_id').notNull(), + evaluatorId: text('evaluator_id').notNull(), + ...timestamps, + }, + (table) => [ + primaryKey({ columns: [table.id] }), + foreignKey({ + columns: [table.tenantId, table.conversationEvaluationConfigId], + foreignColumns: [conversationEvaluationConfig.tenantId, conversationEvaluationConfig.id], + name: 'conv_eval_config_evaluator_config_fk', + }).onDelete('cascade'), + foreignKey({ + columns: [table.tenantId, table.evaluatorId], + foreignColumns: [evaluator.tenantId, evaluator.id], + name: 'conv_eval_config_evaluator_evaluator_fk', + }).onDelete('cascade'), + ] +); + export const tasksRelations = relations(tasks, ({ one, many }) => ({ project: one(projects, { fields: [tasks.tenantId, tasks.projectId], @@ -783,6 +1001,7 @@ export const agentRelations = relations(agents, ({ one, many }) => ({ references: [contextConfigs.id], }), functionTools: many(functionTools), + evalTestSuiteRuns: many(evalTestSuiteRun), })); export const externalAgentsRelations = relations(externalAgents, ({ one, many }) => ({ @@ -1056,3 +1275,94 @@ export const subAgentTeamAgentRelationsRelations = relations( }), }) ); + +export const datasetRelations = relations(dataset, ({ many }) => ({ + items: many(datasetItem), + evalTestSuiteRuns: many(evalTestSuiteRun), +})); + +export const datasetItemRelations = relations(datasetItem, ({ one, many }) => ({ + dataset: one(dataset, { + fields: [datasetItem.datasetId], + references: [dataset.id], + }), + evalResults: many(evalResult), +})); + +export const evaluatorRelations = relations(evaluator, ({ many }) => ({ + evalResults: many(evalResult), + evalTestSuiteRuns: many(evalTestSuiteRunEvaluator), +})); + +export const evalTestSuiteConfigRelations = relations(evalTestSuiteConfig, ({ many }) => ({ + runs: many(evalTestSuiteRun), +})); + +export const evalTestSuiteRunRelations = relations(evalTestSuiteRun, ({ one, many }) => ({ + dataset: one(dataset, { + fields: [evalTestSuiteRun.datasetId], + references: [dataset.id], + }), + agent: one(agents, { + fields: [evalTestSuiteRun.agentId], + references: [agents.id], + }), + testSuiteConfig: one(evalTestSuiteConfig, { + fields: [evalTestSuiteRun.testSuiteConfigId], + references: [evalTestSuiteConfig.id], + }), + evaluators: many(evalTestSuiteRunEvaluator), + results: many(evalResult), +})); + +export const evalTestSuiteRunEvaluatorRelations = relations(evalTestSuiteRunEvaluator, ({ one }) => ({ + evalTestSuiteRun: one(evalTestSuiteRun, { + fields: [evalTestSuiteRunEvaluator.evalTestSuiteRunId], + references: [evalTestSuiteRun.id], + }), + evaluator: one(evaluator, { + fields: [evalTestSuiteRunEvaluator.evaluatorId], + references: [evaluator.id], + }), +})); + +export const conversationEvaluationConfigRelations = relations(conversationEvaluationConfig, ({ many }) => ({ + evaluators: many(conversationEvaluationConfigEvaluator), +})); + +export const conversationEvaluationConfigEvaluatorRelations = relations(conversationEvaluationConfigEvaluator, ({ one }) => ({ + conversationEvaluationConfig: one(conversationEvaluationConfig, { + fields: [conversationEvaluationConfigEvaluator.conversationEvaluationConfigId], + references: [conversationEvaluationConfig.id], + }), + evaluator: one(evaluator, { + fields: [conversationEvaluationConfigEvaluator.evaluatorId], + references: [evaluator.id], + }), +})); + +export const evalResultRelations = relations(evalResult, ({ one }) => ({ + conversation: one(conversations, { + fields: [evalResult.conversationId], + references: [conversations.id], + relationName: 'conversationEvalResults', + }), + evaluator: one(evaluator, { + fields: [evalResult.evaluatorId], + references: [evaluator.id], + }), + datasetItem: one(datasetItem, { + fields: [evalResult.datasetItemId], + references: [datasetItem.id], + }), + evalTestSuiteRun: one(evalTestSuiteRun, { + fields: [evalResult.suiteRunId], + references: [evalTestSuiteRun.id], + }), +})); + +export const conversationsEvalRelations = relations(conversations, ({ many }) => ({ + evalResults: many(evalResult, { + relationName: 'conversationEvalResults', + }), +})); \ No newline at end of file diff --git a/packages/agents-core/src/utils/index.ts b/packages/agents-core/src/utils/index.ts index c220c56fc..f90ff6eac 100644 --- a/packages/agents-core/src/utils/index.ts +++ b/packages/agents-core/src/utils/index.ts @@ -4,6 +4,7 @@ export * from './conversations'; export * from './credential-store-utils'; export * from './error'; export * from './execution'; +export * from './json-schema-to-zod'; export * from './logger'; export * from './mcp-client'; export * from './schema-conversion'; diff --git a/packages/agents-core/src/utils/json-schema-to-zod.ts b/packages/agents-core/src/utils/json-schema-to-zod.ts new file mode 100644 index 000000000..59682c822 --- /dev/null +++ b/packages/agents-core/src/utils/json-schema-to-zod.ts @@ -0,0 +1,56 @@ +import { z } from 'zod'; + +/** + * Converts JSON Schema objects to Zod schema types + * Supports: object, array, string, number, integer, boolean, null, enum, required fields + */ +export function jsonSchemaToZod(jsonSchema: any): z.ZodType { + if (!jsonSchema || typeof jsonSchema !== 'object') { + return z.unknown(); + } + + switch (jsonSchema.type) { + case 'object': + if (jsonSchema.properties) { + const shape: Record> = {}; + for (const [key, prop] of Object.entries(jsonSchema.properties)) { + let zodType = jsonSchemaToZod(prop); + + // Handle optional fields + if (!jsonSchema.required?.includes(key)) { + zodType = zodType.optional(); + } + + shape[key] = zodType; + } + return z.object(shape); + } + return z.record(z.string(), z.unknown()); + + case 'array': { + const itemSchema = jsonSchema.items ? jsonSchemaToZod(jsonSchema.items) : z.unknown(); + return z.array(itemSchema); + } + + case 'string': + if (jsonSchema.enum && Array.isArray(jsonSchema.enum) && jsonSchema.enum.length > 0) { + const [first, ...rest] = jsonSchema.enum; + return z.enum([first, ...rest]); + } + return z.string(); + + case 'number': + case 'integer': + return z.number(); + + case 'boolean': + return z.boolean(); + + case 'null': + return z.null(); + + default: + return z.unknown(); + } +} + diff --git a/packages/agents-sdk/src/evaluationClient.ts b/packages/agents-sdk/src/evaluationClient.ts new file mode 100644 index 000000000..a64fd57ae --- /dev/null +++ b/packages/agents-sdk/src/evaluationClient.ts @@ -0,0 +1,539 @@ +import { apiFetch, getLogger } from '@inkeep/agents-core'; + +const logger = getLogger('evaluationClient'); + +export interface TestSuiteConfig { + tenantId: string; + id: string; + name: string; + description: string; + modelConfig?: Record | null; + runFrequency: string; + createdAt: string; + updatedAt: string; +} + +export interface CreateTestSuiteConfigParams { + id?: string; + name: string; + description?: string; + modelConfig?: Record; + runFrequency: string; +} + +export interface UpdateTestSuiteConfigParams { + name?: string; + description?: string; + modelConfig?: Record; + runFrequency?: string; +} + +/** + * Create a test suite config via HTTP API + */ +export async function createTestSuiteConfigViaAPI( + tenantId: string, + apiUrl: string, + configData: CreateTestSuiteConfigParams, + apiKey?: string +): Promise { + logger.info( + { + tenantId, + configName: configData.name, + apiUrl, + }, + 'Creating test suite config via API' + ); + + const url = `${apiUrl}/tenants/${tenantId}/eval-test-suite-configs`; + + const headers: Record = {}; + if (apiKey) { + headers.Authorization = `Bearer ${apiKey}`; + } + + let response: Response; + try { + response = await apiFetch(url, { + method: 'POST', + headers, + body: JSON.stringify(configData), + }); + } catch (fetchError) { + logger.error( + { + error: fetchError instanceof Error ? fetchError.message : 'Unknown fetch error', + url, + tenantId, + }, + 'Fetch request failed' + ); + throw fetchError; + } + + if (!response.ok) { + const errorText = await response.text(); + let errorMessage = `Failed to create test suite config: ${response.status} ${response.statusText}`; + + try { + const errorJson = JSON.parse(errorText); + if (errorJson.error) { + errorMessage = errorJson.error; + } + } catch { + if (errorText) { + errorMessage = errorText; + } + } + + logger.error( + { + status: response.status, + error: errorMessage, + }, + 'Failed to create test suite config via API' + ); + + throw new Error(errorMessage); + } + + const result = (await response.json()) as { data: TestSuiteConfig }; + + logger.info( + { + configId: result.data.id, + }, + 'Successfully created test suite config via API' + ); + + return result.data; +} + +/** + * Get a test suite config via HTTP API + */ +export async function getTestSuiteConfigViaAPI( + tenantId: string, + configId: string, + apiUrl: string, + apiKey?: string +): Promise { + logger.info( + { + tenantId, + configId, + apiUrl, + }, + 'Getting test suite config via API' + ); + + const url = `${apiUrl}/tenants/${tenantId}/eval-test-suite-configs/${configId}`; + + const headers: Record = {}; + if (apiKey) { + headers.Authorization = `Bearer ${apiKey}`; + } + + let response: Response; + try { + response = await apiFetch(url, { + method: 'GET', + headers, + }); + } catch (fetchError) { + logger.error( + { + error: fetchError instanceof Error ? fetchError.message : 'Unknown fetch error', + url, + tenantId, + configId, + }, + 'Fetch request failed' + ); + throw fetchError; + } + + if (!response.ok) { + const errorText = await response.text(); + let errorMessage = `Failed to get test suite config: ${response.status} ${response.statusText}`; + + try { + const errorJson = JSON.parse(errorText); + if (errorJson.error) { + errorMessage = errorJson.error; + } + } catch { + if (errorText) { + errorMessage = errorText; + } + } + + logger.error( + { + status: response.status, + error: errorMessage, + }, + 'Failed to get test suite config via API' + ); + + throw new Error(errorMessage); + } + + const result = (await response.json()) as { data: TestSuiteConfig }; + + logger.info( + { + configId: result.data.id, + }, + 'Successfully retrieved test suite config via API' + ); + + return result.data; +} + +/** + * List all test suite configs via HTTP API + */ +export async function listTestSuiteConfigsViaAPI( + tenantId: string, + apiUrl: string, + apiKey?: string +): Promise { + logger.info( + { + tenantId, + apiUrl, + }, + 'Listing test suite configs via API' + ); + + const url = `${apiUrl}/tenants/${tenantId}/eval-test-suite-configs`; + + const headers: Record = {}; + if (apiKey) { + headers.Authorization = `Bearer ${apiKey}`; + } + + let response: Response; + try { + response = await apiFetch(url, { + method: 'GET', + headers, + }); + } catch (fetchError) { + logger.error( + { + error: fetchError instanceof Error ? fetchError.message : 'Unknown fetch error', + url, + tenantId, + }, + 'Fetch request failed' + ); + throw fetchError; + } + + if (!response.ok) { + const errorText = await response.text(); + let errorMessage = `Failed to list test suite configs: ${response.status} ${response.statusText}`; + + try { + const errorJson = JSON.parse(errorText); + if (errorJson.error) { + errorMessage = errorJson.error; + } + } catch { + if (errorText) { + errorMessage = errorText; + } + } + + logger.error( + { + status: response.status, + error: errorMessage, + }, + 'Failed to list test suite configs via API' + ); + + throw new Error(errorMessage); + } + + const result = (await response.json()) as { data: TestSuiteConfig[] }; + + logger.info( + { + count: result.data.length, + }, + 'Successfully listed test suite configs via API' + ); + + return result.data; +} + +/** + * Update a test suite config via HTTP API + */ +export async function updateTestSuiteConfigViaAPI( + tenantId: string, + configId: string, + apiUrl: string, + configData: UpdateTestSuiteConfigParams, + apiKey?: string +): Promise { + logger.info( + { + tenantId, + configId, + apiUrl, + }, + 'Updating test suite config via API' + ); + + const url = `${apiUrl}/tenants/${tenantId}/eval-test-suite-configs/${configId}`; + + const headers: Record = {}; + if (apiKey) { + headers.Authorization = `Bearer ${apiKey}`; + } + + let response: Response; + try { + response = await apiFetch(url, { + method: 'PUT', + headers, + body: JSON.stringify(configData), + }); + } catch (fetchError) { + logger.error( + { + error: fetchError instanceof Error ? fetchError.message : 'Unknown fetch error', + url, + tenantId, + configId, + }, + 'Fetch request failed' + ); + throw fetchError; + } + + if (!response.ok) { + const errorText = await response.text(); + let errorMessage = `Failed to update test suite config: ${response.status} ${response.statusText}`; + + try { + const errorJson = JSON.parse(errorText); + if (errorJson.error) { + errorMessage = errorJson.error; + } + } catch { + if (errorText) { + errorMessage = errorText; + } + } + + logger.error( + { + status: response.status, + error: errorMessage, + }, + 'Failed to update test suite config via API' + ); + + throw new Error(errorMessage); + } + + const result = (await response.json()) as { data: TestSuiteConfig }; + + logger.info( + { + configId: result.data.id, + }, + 'Successfully updated test suite config via API' + ); + + return result.data; +} + +/** + * Delete a test suite config via HTTP API + */ +export async function deleteTestSuiteConfigViaAPI( + tenantId: string, + configId: string, + apiUrl: string, + apiKey?: string +): Promise { + logger.info( + { + tenantId, + configId, + apiUrl, + }, + 'Deleting test suite config via API' + ); + + const url = `${apiUrl}/tenants/${tenantId}/eval-test-suite-configs/${configId}`; + + const headers: Record = {}; + if (apiKey) { + headers.Authorization = `Bearer ${apiKey}`; + } + + let response: Response; + try { + response = await apiFetch(url, { + method: 'DELETE', + headers, + }); + } catch (fetchError) { + logger.error( + { + error: fetchError instanceof Error ? fetchError.message : 'Unknown fetch error', + url, + tenantId, + configId, + }, + 'Fetch request failed' + ); + throw fetchError; + } + + if (!response.ok) { + const errorText = await response.text(); + let errorMessage = `Failed to delete test suite config: ${response.status} ${response.statusText}`; + + try { + const errorJson = JSON.parse(errorText); + if (errorJson.error) { + errorMessage = errorJson.error; + } + } catch { + if (errorText) { + errorMessage = errorText; + } + } + + logger.error( + { + status: response.status, + error: errorMessage, + }, + 'Failed to delete test suite config via API' + ); + + throw new Error(errorMessage); + } + + const result = (await response.json()) as { data: TestSuiteConfig }; + + logger.info( + { + configId: result.data.id, + }, + 'Successfully deleted test suite config via API' + ); + + return result.data; +} + +/** + * Run dataset evaluation via API + */ +export async function runDatasetEvalViaAPI( + tenantId: string, + apiUrl: string, + params: { + testSuiteConfigId: string; + datasetId: string; + agentId: string; + evaluatorIds: string[]; + }, + apiKey?: string +): Promise | null; + createdAt: string; + updatedAt: string; +}>> { + logger.info( + { + tenantId, + testSuiteConfigId: params.testSuiteConfigId, + datasetId: params.datasetId, + agentId: params.agentId, + evaluatorCount: params.evaluatorIds.length, + }, + 'Running dataset evaluation via API' + ); + + const url = `${apiUrl}/${tenantId}/evaluations/datasets/run`; + const headers: Record = { + 'Content-Type': 'application/json', + }; + + if (apiKey) { + headers.Authorization = `Bearer ${apiKey}`; + } + + const response = await fetch(url, { + method: 'POST', + headers, + body: JSON.stringify(params), + }); + + if (!response.ok) { + const errorText = await response.text(); + let errorMessage = `Failed to run dataset evaluation: ${response.status} ${response.statusText}`; + + try { + const errorJson = JSON.parse(errorText); + if (errorJson.error) { + errorMessage = errorJson.error; + } + } catch { + if (errorText) { + errorMessage = errorText; + } + } + + logger.error( + { + status: response.status, + error: errorMessage, + }, + 'Failed to run dataset evaluation via API' + ); + + throw new Error(errorMessage); + } + + const result = (await response.json()) as { data: Array<{ + id: string; + suiteRunId: string | null; + datasetItemId: string | null; + conversationId: string; + status: 'pending' | 'done' | 'failed'; + evaluatorId: string; + reasoning: string | null; + metadata: Record | null; + createdAt: string; + updatedAt: string; + }> }; + + logger.info( + { + resultCount: result.data.length, + }, + 'Successfully ran dataset evaluation via API' + ); + + return result.data; +} + diff --git a/packages/agents-sdk/src/index.ts b/packages/agents-sdk/src/index.ts index 6ffa7cbd6..761f24afb 100644 --- a/packages/agents-sdk/src/index.ts +++ b/packages/agents-sdk/src/index.ts @@ -26,6 +26,17 @@ export { createEnvironmentSettings, registerEnvironmentSettings, } from './environment-settings'; +export { + type CreateTestSuiteConfigParams, + createTestSuiteConfigViaAPI, + deleteTestSuiteConfigViaAPI, + getTestSuiteConfigViaAPI, + listTestSuiteConfigsViaAPI, + runDatasetEvalViaAPI, + type TestSuiteConfig, + type UpdateTestSuiteConfigParams, + updateTestSuiteConfigViaAPI, +} from './evaluationClient'; export { ExternalAgent, externalAgent, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8fe0680fd..80cf4771b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -351,6 +351,15 @@ importers: agents-manage-api: dependencies: + '@ai-sdk/anthropic': + specifier: ^1.1.9 + version: 1.2.12(zod@4.1.12) + '@ai-sdk/google': + specifier: ^1.0.22 + version: 1.2.22(zod@4.1.12) + '@ai-sdk/openai': + specifier: ^1.0.19 + version: 1.3.24(zod@4.1.12) '@hono/node-server': specifier: ^1.14.3 version: 1.19.6(hono@4.10.4) @@ -1154,6 +1163,12 @@ packages: '@adobe/css-tools@4.4.4': resolution: {integrity: sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==} + '@ai-sdk/anthropic@1.2.12': + resolution: {integrity: sha512-YSzjlko7JvuiyQFmI9RN1tNZdEiZxc+6xld/0tq/VkJaHpEzGAb1yiNxxvmYVcjvfu/PcvCxAAYXmTYQQ63IHQ==} + engines: {node: '>=18'} + peerDependencies: + zod: ^4.1.11 + '@ai-sdk/anthropic@2.0.2': resolution: {integrity: sha512-R3xmEbbntgdKo/S3TDuW77RYALpo/OKQm4oSjQmryDAFiVGB6X6guZAr7FWt48C4fKGROScAu+y1MJTbzisfOQ==} engines: {node: '>=18'} @@ -1184,6 +1199,12 @@ packages: peerDependencies: zod: ^4.1.11 + '@ai-sdk/openai@1.3.24': + resolution: {integrity: sha512-GYXnGJTHRTZc4gJMSmFRgEQudjqd4PUN0ZjQhPwOAYH1yOAvQoG/Ikqs+HyISRbLPCrhbZnPKCNHuRU4OfpW0Q==} + engines: {node: '>=18'} + peerDependencies: + zod: ^4.1.11 + '@ai-sdk/openai@2.0.11': resolution: {integrity: sha512-t4i+vS825EC0Gc2DdTsC5UkXIu1ScOi363noTD8DuFZp6WFPHRnW6HCyEQKxEm6cNjv3BW89rdXWqq932IFJhA==} engines: {node: '>=18'} @@ -1234,6 +1255,16 @@ packages: resolution: {integrity: sha512-6o7Y2SeO9vFKB8lArHXehNuusnpddKPk7xqL7T2/b+OvXMRIXUO1rR4wcv1hAFUAT9avGZshty3Wlua/XA7TvA==} engines: {node: '>=18'} + '@ai-sdk/react@1.2.12': + resolution: {integrity: sha512-jK1IZZ22evPZoQW3vlkZ7wvjYGYF+tRBKXtrcolduIkQ/m/sOAVcVeVDUDvh1T91xCnWCdUGCPZg2avZ90mv3g==} + engines: {node: '>=18'} + peerDependencies: + react: ^18 || ^19 || ^19.0.0-rc + zod: ^4.1.11 + peerDependenciesMeta: + zod: + optional: true + '@ai-sdk/react@2.0.11': resolution: {integrity: sha512-XL73e7RSOQjYRCJQ96sDY6TxrMJK9YBgI518E6Jy306BjRwy5XyY94e/DN71TE6VpiwDzxixlymfDK90Ro95Jg==} engines: {node: '>=18'} @@ -5270,6 +5301,9 @@ packages: '@types/degit@2.8.6': resolution: {integrity: sha512-y0M7sqzsnHB6cvAeTCBPrCQNQiZe8U4qdzf8uBVmOWYap5MMTN/gB2iEqrIqFiYcsyvP74GnGD5tgsHttielFw==} + '@types/diff-match-patch@1.0.36': + resolution: {integrity: sha512-xFdR6tkm0MWvBfO8xXCSsinYxHcqkQUlcHeSpMC2ukzOb6lwQAfDmW+Qt0AvlGd8HpsS28qKsB+oPeJn9I39jg==} + '@types/estree-jsx@1.0.5': resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==} @@ -6558,6 +6592,9 @@ packages: devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} + diff-match-patch@1.0.5: + resolution: {integrity: sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==} + dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -7958,6 +7995,11 @@ packages: engines: {node: '>=6'} hasBin: true + jsondiffpatch@0.6.0: + resolution: {integrity: sha512-3QItJOXp2AP1uv7waBkao5nCvhEv+QmJAd38Ybq7wNI74Q+BBmnLn4EDKz6yI9xGAIQoUF87qHt+kc1IVxB4zQ==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + jsonfile@4.0.0: resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} @@ -16966,6 +17008,8 @@ snapshots: '@types/degit@2.8.6': {} + '@types/diff-match-patch@1.0.36': {} + '@types/estree-jsx@1.0.5': dependencies: '@types/estree': 1.0.8 @@ -18401,6 +18445,8 @@ snapshots: dependencies: dequal: 2.0.3 + diff-match-patch@1.0.5: {} + dir-glob@3.0.1: dependencies: path-type: 4.0.0 @@ -20013,6 +20059,12 @@ snapshots: json5@2.2.3: {} + jsondiffpatch@0.6.0: + dependencies: + '@types/diff-match-patch': 1.0.36 + chalk: 5.6.2 + diff-match-patch: 1.0.5 + jsonfile@4.0.0: optionalDependencies: graceful-fs: 4.2.11 diff --git a/test-agents/agents/faulty-api-agent.ts b/test-agents/agents/faulty-api-agent.ts new file mode 100644 index 000000000..241a0da3b --- /dev/null +++ b/test-agents/agents/faulty-api-agent.ts @@ -0,0 +1,28 @@ +import { agent, subAgent } from '@inkeep/agents-sdk'; +import { faultyApiTool } from '../tools/faulty-api-tool'; + +export const faultyApiWeatherAgent = agent({ + id: 'faulty-api-weather-agent', + name: `Weather Agent (Faulty API MCP)`, + defaultSubAgent: subAgent({ + id: 'faulty-api-weather-assistant', + name: `Weather Assistant`, + description: `A weather forecasting agent that provides weather information for any location. Uses tools to convert addresses to coordinates.`, + prompt: `You are a helpful weather assistant that provides comprehensive weather information for any location worldwide. + +When users ask about weather: +1. First, use your faulty API tool to convert the location name or address into coordinates +2. Then provide weather information based on those coordinates +3. Present the information in a clear, user-friendly format + +You help users by: +- Converting location names and addresses to geographic coordinates +- Providing current weather conditions +- Sharing temperature, humidity, wind, and precipitation data +- Offering helpful weather-related advice + +Always be friendly and informative when helping users with weather queries.`, + canUse: () => [faultyApiTool], + }), +}); +