-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathagent.model.ts
More file actions
34 lines (30 loc) · 1.44 KB
/
agent.model.ts
File metadata and controls
34 lines (30 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import mongoose, { Schema } from 'mongoose'
import { IAgentRun, IAgentStepLog } from './agent.type'
import { AgentRoles, RunStatuses, StepStatuses } from './agent.constant'
const agentConfigSchema = new Schema({
agentId: { type: String, required: true },
name: { type: String, required: true },
type: { type: String, enum: AgentRoles, required: true },
systemPrompt: { type: String, required: true },
tools: [{ type: String }],
priority: { type: Number, default: 1 },
isActive: { type: Boolean, default: true }
}, { _id: false })
const agentRunSchema = new Schema<IAgentRun>({
runName: { type: String, required: true },
status: { type: String, enum: RunStatuses, default: 'pending' },
agents: [agentConfigSchema],
currentAgent: { type: String },
startedAt: { type: Date },
completedAt: { type: Date }
}, { timestamps: true })
const agentStepLogSchema = new Schema<IAgentStepLog>({
runId: { type: 'ObjectId', ref: 'AgentRun', required: true },
agentId: { type: String, required: true },
inputPrompt: { type: String, required: true },
output: { type: String, required: true },
status: { type: String, enum: StepStatuses, required: true },
executionTimeMs: { type: Number, required: true }
}, { timestamps: true })
export const AgentRunModel = mongoose.model<IAgentRun>('AgentRun', agentRunSchema)
export const AgentStepLogModel = mongoose.model<IAgentStepLog>('AgentStepLog', agentStepLogSchema)