datasource db { provider = "sqlite" url = "file:./dev.db" } generator client { provider = "prisma-client-py" recursive_type_depth = 5 interface = "asyncio" } // User model to mirror Auth provider users model User { id String @id // This should match the Supabase user ID email String @unique name String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt // Relations AgentGraphs AgentGraph[] AgentGraphExecutions AgentGraphExecution[] AgentGraphExecutionSchedules AgentGraphExecutionSchedule[] @@index([id]) @@index([email]) } // This model describes the Agent Graph/Flow (Multi Agent System). model AgentGraph { id String @default(uuid()) version Int @default(1) name String? description String? isActive Boolean @default(true) isTemplate Boolean @default(false) // Link to User model userId String user User @relation(fields: [userId], references: [id]) AgentNodes AgentNode[] AgentGraphExecution AgentGraphExecution[] AgentGraphExecutionSchedule AgentGraphExecutionSchedule[] // All sub-graphs are defined within this 1-level depth list (even if it's a nested graph). AgentSubGraphs AgentGraph[] @relation("AgentSubGraph") agentGraphParentId String? AgentGraphParent AgentGraph? @relation("AgentSubGraph", fields: [agentGraphParentId, version], references: [id, version]) @@id(name: "graphVersionId", [id, version]) } // This model describes a single node in the Agent Graph/Flow (Multi Agent System). model AgentNode { id String @id @default(uuid()) agentBlockId String AgentBlock AgentBlock @relation(fields: [agentBlockId], references: [id]) agentGraphId String agentGraphVersion Int @default(1) AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version]) // List of consumed input, that the parent node should provide. Input AgentNodeLink[] @relation("AgentNodeSink") // List of produced output, that the child node should be executed. Output AgentNodeLink[] @relation("AgentNodeSource") // JSON serialized dict[str, str] containing predefined input values. constantInput String @default("{}") // JSON serialized dict[str, str] containing the node metadata. metadata String @default("{}") ExecutionHistory AgentNodeExecution[] } // This model describes the link between two AgentNodes. model AgentNodeLink { id String @id @default(uuid()) // Output of a node is connected to the source of the link. agentNodeSourceId String AgentNodeSource AgentNode @relation("AgentNodeSource", fields: [agentNodeSourceId], references: [id]) sourceName String // Input of a node is connected to the sink of the link. agentNodeSinkId String AgentNodeSink AgentNode @relation("AgentNodeSink", fields: [agentNodeSinkId], references: [id]) sinkName String // Default: the data coming from the source can only be consumed by the sink once, Static: input data will be reused. isStatic Boolean @default(false) } // This model describes a component that will be executed by the AgentNode. model AgentBlock { id String @id @default(uuid()) name String @unique // We allow a block to have multiple types of input & output. // Serialized object-typed `jsonschema` with top-level properties as input/output name. inputSchema String outputSchema String // Prisma requires explicit back-references. ReferencedByAgentNode AgentNode[] } // This model describes the execution of an AgentGraph. model AgentGraphExecution { id String @id @default(uuid()) agentGraphId String agentGraphVersion Int @default(1) AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version]) AgentNodeExecutions AgentNodeExecution[] // Link to User model userId String user User @relation(fields: [userId], references: [id]) } // This model describes the execution of an AgentNode. model AgentNodeExecution { id String @id @default(uuid()) agentGraphExecutionId String AgentGraphExecution AgentGraphExecution @relation(fields: [agentGraphExecutionId], references: [id]) agentNodeId String AgentNode AgentNode @relation(fields: [agentNodeId], references: [id]) Input AgentNodeExecutionInputOutput[] @relation("AgentNodeExecutionInput") Output AgentNodeExecutionInputOutput[] @relation("AgentNodeExecutionOutput") // sqlite does not support enum // enum Status { INCOMPLETE, QUEUED, RUNNING, SUCCESS, FAILED } executionStatus String // Final JSON serialized input data for the node execution. executionData String? addedTime DateTime @default(now()) queuedTime DateTime? startedTime DateTime? endedTime DateTime? } // This model describes the output of an AgentNodeExecution. model AgentNodeExecutionInputOutput { id String @id @default(uuid()) name String data String time DateTime @default(now()) // Prisma requires explicit back-references. referencedByInputExecId String? ReferencedByInputExec AgentNodeExecution? @relation("AgentNodeExecutionInput", fields: [referencedByInputExecId], references: [id]) referencedByOutputExecId String? ReferencedByOutputExec AgentNodeExecution? @relation("AgentNodeExecutionOutput", fields: [referencedByOutputExecId], references: [id]) // Input and Output pin names are unique for each AgentNodeExecution. @@unique([referencedByInputExecId, referencedByOutputExecId, name]) } // This model describes the recurring execution schedule of an Agent. model AgentGraphExecutionSchedule { id String @id agentGraphId String agentGraphVersion Int @default(1) AgentGraph AgentGraph @relation(fields: [agentGraphId, agentGraphVersion], references: [id, version]) schedule String // cron expression isEnabled Boolean @default(true) inputData String // JSON serialized object // default and set the value on each update, lastUpdated field has no time zone. lastUpdated DateTime @updatedAt // Link to User model userId String user User @relation(fields: [userId], references: [id]) @@index([isEnabled]) }