File size: 2,727 Bytes
1cf8f01
eecbedf
13e47b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1cf8f01
 
 
 
 
 
 
 
 
 
 
 
 
13e47b9
 
 
 
 
 
 
 
 
 
eecbedf
 
 
1cf8f01
eecbedf
 
 
1cf8f01
 
 
4fc8652
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import mongoose from "mongoose";

// Schema for chat messages
const MessageSchema = new mongoose.Schema({
  role: {
    type: String,
    required: true,
    enum: ["user", "assistant"]
  },
  content: {
    type: String,
    required: true
  },
  timestamp: {
    type: Date,
    default: Date.now
  }
});

// Schema for agent tasks
const AgentTaskSchema = new mongoose.Schema({
  id: String,
  description: String,
  status: {
    type: String,
    enum: ["pending", "in-progress", "completed", "failed"]
  },
  result: String
});

// Schema for agent files
const AgentFileSchema = new mongoose.Schema({
  path: String,
  content: String
});

// Schema for agent sessions
const AgentSessionSchema = new mongoose.Schema({
  projectName: String,
  description: String,
  tasks: [AgentTaskSchema],
  files: [AgentFileSchema],
  createdAt: {
    type: Date,
    default: Date.now
  },
  updatedAt: {
    type: Date,
    default: Date.now
  }
});

const ProjectSchema = new mongoose.Schema({
  space_id: {
    type: String,
    required: true,
  },
  user_id: {
    type: String,
    required: true,
  },
  prompts: {
    type: [String],
    default: [],
  },
  // Chat sessions
  chatSessions: {
    type: [MessageSchema],
    default: []
  },
  // Agent sessions
  agentSessions: {
    type: [AgentSessionSchema],
    default: []
  },
  _createdAt: {
    type: Date,
    default: Date.now,
  },
  _updatedAt: {
    type: Date,
    default: Date.now,
  },
});

// Mock Project model for local storage
// This replaces the Mongoose model with a simple interface

export interface Project {
  _id?: string;
  space_id: string;
  user_id: string;
  prompts: string[];
  chatSessions: any[];
  agentSessions: any[];
  _createdAt: Date;
  _updatedAt: Date;
}

// Mock model functions
const Project = {
  findOne: async (query: any) => {
    // This would normally query MongoDB, but we'll simulate it
    console.log("Using local storage instead of MongoDB for Project.findOne");
    return null;
  },
  find: async (query: any) => {
    // This would normally query MongoDB, but we'll simulate it
    console.log("Using local storage instead of MongoDB for Project.find");
    return [];
  },
  create: async (data: any) => {
    // This would normally create a document in MongoDB, but we'll simulate it
    console.log("Using local storage instead of MongoDB for Project.create");
    return { ...data, _id: Math.random().toString(36).substr(2, 9) };
  },
  updateOne: async (query: any, update: any) => {
    // This would normally update a document in MongoDB, but we'll simulate it
    console.log("Using local storage instead of MongoDB for Project.updateOne");
    return { modifiedCount: 1 };
  }
};

export default Project;