@studious-lms/server 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/models/class.d.ts +24 -2
  2. package/dist/models/class.d.ts.map +1 -1
  3. package/dist/models/class.js +180 -81
  4. package/dist/models/class.js.map +1 -1
  5. package/dist/models/worksheet.d.ts +34 -34
  6. package/dist/pipelines/aiLabChat.d.ts +57 -2
  7. package/dist/pipelines/aiLabChat.d.ts.map +1 -1
  8. package/dist/pipelines/aiLabChat.js +252 -113
  9. package/dist/pipelines/aiLabChat.js.map +1 -1
  10. package/dist/pipelines/gradeWorksheet.d.ts +4 -4
  11. package/dist/routers/_app.d.ts +138 -56
  12. package/dist/routers/_app.d.ts.map +1 -1
  13. package/dist/routers/class.d.ts +24 -3
  14. package/dist/routers/class.d.ts.map +1 -1
  15. package/dist/routers/class.js +3 -3
  16. package/dist/routers/class.js.map +1 -1
  17. package/dist/routers/labChat.d.ts +10 -1
  18. package/dist/routers/labChat.d.ts.map +1 -1
  19. package/dist/routers/labChat.js +6 -3
  20. package/dist/routers/labChat.js.map +1 -1
  21. package/dist/routers/message.d.ts +11 -0
  22. package/dist/routers/message.d.ts.map +1 -1
  23. package/dist/routers/message.js +10 -3
  24. package/dist/routers/message.js.map +1 -1
  25. package/dist/routers/worksheet.d.ts +24 -24
  26. package/dist/services/class.d.ts +24 -2
  27. package/dist/services/class.d.ts.map +1 -1
  28. package/dist/services/class.js +18 -6
  29. package/dist/services/class.js.map +1 -1
  30. package/dist/services/labChat.d.ts +5 -1
  31. package/dist/services/labChat.d.ts.map +1 -1
  32. package/dist/services/labChat.js +96 -4
  33. package/dist/services/labChat.js.map +1 -1
  34. package/dist/services/message.d.ts +8 -0
  35. package/dist/services/message.d.ts.map +1 -1
  36. package/dist/services/message.js +74 -2
  37. package/dist/services/message.js.map +1 -1
  38. package/dist/services/worksheet.d.ts +18 -18
  39. package/package.json +1 -1
  40. package/prisma/schema.prisma +1 -1
  41. package/src/models/class.ts +189 -84
  42. package/src/pipelines/aiLabChat.ts +291 -118
  43. package/src/routers/class.ts +1 -1
  44. package/src/routers/labChat.ts +7 -0
  45. package/src/routers/message.ts +13 -0
  46. package/src/services/class.ts +14 -7
  47. package/src/services/labChat.ts +108 -2
  48. package/src/services/message.ts +93 -0
@@ -18,10 +18,10 @@ export declare function findWorksheetById(id: string): import(".prisma/client").
18
18
  updatedAt: Date;
19
19
  order: number | null;
20
20
  markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
21
- question: string;
22
- points: number;
23
21
  worksheetId: string;
22
+ question: string;
24
23
  answer: string;
24
+ points: number;
25
25
  }[];
26
26
  } & {
27
27
  id: string;
@@ -88,10 +88,10 @@ export declare function findQuestionsByWorksheetId(worksheetId: string): import(
88
88
  updatedAt: Date;
89
89
  order: number | null;
90
90
  markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
91
- question: string;
92
- points: number;
93
91
  worksheetId: string;
92
+ question: string;
94
93
  answer: string;
94
+ points: number;
95
95
  }[]>;
96
96
  /** Create a worksheet question. */
97
97
  export declare function createWorksheetQuestion(data: {
@@ -110,10 +110,10 @@ export declare function createWorksheetQuestion(data: {
110
110
  updatedAt: Date;
111
111
  order: number | null;
112
112
  markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
113
- question: string;
114
- points: number;
115
113
  worksheetId: string;
114
+ question: string;
116
115
  answer: string;
116
+ points: number;
117
117
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
118
118
  /** Update question order. */
119
119
  export declare function updateWorksheetQuestionOrder(id: string, order: number): import(".prisma/client").Prisma.Prisma__WorksheetQuestionClient<{
@@ -124,10 +124,10 @@ export declare function updateWorksheetQuestionOrder(id: string, order: number):
124
124
  updatedAt: Date;
125
125
  order: number | null;
126
126
  markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
127
- question: string;
128
- points: number;
129
127
  worksheetId: string;
128
+ question: string;
130
129
  answer: string;
130
+ points: number;
131
131
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
132
132
  /** Update a worksheet question. */
133
133
  export declare function updateWorksheetQuestion(id: string, data: {
@@ -145,10 +145,10 @@ export declare function updateWorksheetQuestion(id: string, data: {
145
145
  updatedAt: Date;
146
146
  order: number | null;
147
147
  markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
148
- question: string;
149
- points: number;
150
148
  worksheetId: string;
149
+ question: string;
151
150
  answer: string;
151
+ points: number;
152
152
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
153
153
  /** Delete a worksheet question. */
154
154
  export declare function deleteWorksheetQuestion(id: string): import(".prisma/client").Prisma.Prisma__WorksheetQuestionClient<{
@@ -159,10 +159,10 @@ export declare function deleteWorksheetQuestion(id: string): import(".prisma/cli
159
159
  updatedAt: Date;
160
160
  order: number | null;
161
161
  markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
162
- question: string;
163
- points: number;
164
162
  worksheetId: string;
163
+ question: string;
165
164
  answer: string;
165
+ points: number;
166
166
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
167
167
  /** @returns Submission by ID. */
168
168
  export declare function findSubmissionById(id: string): import(".prisma/client").Prisma.Prisma__SubmissionClient<{
@@ -192,12 +192,12 @@ export declare function findWorksheetResponseBySubmissionAndWorksheet(submission
192
192
  updatedAt: Date | null;
193
193
  feedback: string | null;
194
194
  studentId: string;
195
+ points: number;
195
196
  response: string;
196
197
  isCorrect: boolean;
197
198
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
198
- points: number;
199
- questionId: string;
200
199
  studentWorksheetResponseId: string | null;
200
+ questionId: string;
201
201
  })[];
202
202
  } & {
203
203
  id: string;
@@ -222,12 +222,12 @@ export declare function findOrCreateWorksheetResponse(submissionId: string, work
222
222
  updatedAt: Date | null;
223
223
  feedback: string | null;
224
224
  studentId: string;
225
+ points: number;
225
226
  response: string;
226
227
  isCorrect: boolean;
227
228
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
228
- points: number;
229
- questionId: string;
230
229
  studentWorksheetResponseId: string | null;
230
+ questionId: string;
231
231
  })[];
232
232
  } & {
233
233
  id: string;
@@ -256,12 +256,12 @@ export declare function createWorksheetResponse(data: {
256
256
  updatedAt: Date | null;
257
257
  feedback: string | null;
258
258
  studentId: string;
259
+ points: number;
259
260
  response: string;
260
261
  isCorrect: boolean;
261
262
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
262
- points: number;
263
- questionId: string;
264
263
  studentWorksheetResponseId: string | null;
264
+ questionId: string;
265
265
  })[];
266
266
  } & {
267
267
  id: string;
@@ -282,12 +282,12 @@ export declare function findWorksheetResponseById(id: string): import(".prisma/c
282
282
  updatedAt: Date | null;
283
283
  feedback: string | null;
284
284
  studentId: string;
285
+ points: number;
285
286
  response: string;
286
287
  isCorrect: boolean;
287
288
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
288
- points: number;
289
- questionId: string;
290
289
  studentWorksheetResponseId: string | null;
290
+ questionId: string;
291
291
  }[];
292
292
  } & {
293
293
  id: string;
@@ -308,12 +308,12 @@ export declare function findWorksheetResponseWithResponses(id: string, questionI
308
308
  updatedAt: Date | null;
309
309
  feedback: string | null;
310
310
  studentId: string;
311
+ points: number;
311
312
  response: string;
312
313
  isCorrect: boolean;
313
314
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
314
- points: number;
315
- questionId: string;
316
315
  studentWorksheetResponseId: string | null;
316
+ questionId: string;
317
317
  }[];
318
318
  } & {
319
319
  id: string;
@@ -334,10 +334,10 @@ export declare function findWorksheetQuestionById(id: string): import(".prisma/c
334
334
  updatedAt: Date;
335
335
  order: number | null;
336
336
  markScheme: import("@prisma/client/runtime/library.js").JsonValue | null;
337
- question: string;
338
- points: number;
339
337
  worksheetId: string;
338
+ question: string;
340
339
  answer: string;
340
+ points: number;
341
341
  } | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
342
342
  /** Update student's question progress. */
343
343
  export declare function updateStudentQuestionProgress(id: string, data: {
@@ -352,12 +352,12 @@ export declare function updateStudentQuestionProgress(id: string, data: {
352
352
  updatedAt: Date | null;
353
353
  feedback: string | null;
354
354
  studentId: string;
355
+ points: number;
355
356
  response: string;
356
357
  isCorrect: boolean;
357
358
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
358
- points: number;
359
- questionId: string;
360
359
  studentWorksheetResponseId: string | null;
360
+ questionId: string;
361
361
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
362
362
  /** Create student question progress. */
363
363
  export declare function createStudentQuestionProgress(data: {
@@ -374,12 +374,12 @@ export declare function createStudentQuestionProgress(data: {
374
374
  updatedAt: Date | null;
375
375
  feedback: string | null;
376
376
  studentId: string;
377
+ points: number;
377
378
  response: string;
378
379
  isCorrect: boolean;
379
380
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
380
- points: number;
381
- questionId: string;
382
381
  studentWorksheetResponseId: string | null;
382
+ questionId: string;
383
383
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
384
384
  /** @returns Student's progress for a question. */
385
385
  export declare function findStudentQuestionProgress(studentId: string, questionId: string, studentWorksheetResponseId: string): import(".prisma/client").Prisma.Prisma__StudentQuestionProgressClient<{
@@ -389,12 +389,12 @@ export declare function findStudentQuestionProgress(studentId: string, questionI
389
389
  updatedAt: Date | null;
390
390
  feedback: string | null;
391
391
  studentId: string;
392
+ points: number;
392
393
  response: string;
393
394
  isCorrect: boolean;
394
395
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
395
- points: number;
396
- questionId: string;
397
396
  studentWorksheetResponseId: string | null;
397
+ questionId: string;
398
398
  } | null, null, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
399
399
  /** Update progress for grading (AI feedback, marks). */
400
400
  export declare function updateStudentQuestionProgressForGrading(id: string, data: {
@@ -410,12 +410,12 @@ export declare function updateStudentQuestionProgressForGrading(id: string, data
410
410
  updatedAt: Date | null;
411
411
  feedback: string | null;
412
412
  studentId: string;
413
+ points: number;
413
414
  response: string;
414
415
  isCorrect: boolean;
415
416
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
416
- points: number;
417
- questionId: string;
418
417
  studentWorksheetResponseId: string | null;
418
+ questionId: string;
419
419
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
420
420
  /** Create progress record for grading pipeline. */
421
421
  export declare function createStudentQuestionProgressForGrading(data: {
@@ -434,12 +434,12 @@ export declare function createStudentQuestionProgressForGrading(data: {
434
434
  updatedAt: Date | null;
435
435
  feedback: string | null;
436
436
  studentId: string;
437
+ points: number;
437
438
  response: string;
438
439
  isCorrect: boolean;
439
440
  markschemeState: import("@prisma/client/runtime/library.js").JsonValue | null;
440
- points: number;
441
- questionId: string;
442
441
  studentWorksheetResponseId: string | null;
442
+ questionId: string;
443
443
  }, never, import("@prisma/client/runtime/library.js").DefaultArgs, import(".prisma/client").Prisma.PrismaClientOptions>;
444
444
  /** Create a comment on a worksheet response. */
445
445
  export declare function createComment(data: {
@@ -1,4 +1,54 @@
1
- import { Assignment, Class, File, Section, User } from "@prisma/client";
1
+ import type { Assignment, Class, File, Section, User } from "@prisma/client";
2
+ /** Extended class data for AI context (schema-aware) */
3
+ type ClassContextData = {
4
+ class: Class;
5
+ sections: Section[];
6
+ markSchemes: {
7
+ id: string;
8
+ structured: string;
9
+ }[];
10
+ gradingBoundaries: {
11
+ id: string;
12
+ structured: string;
13
+ }[];
14
+ worksheets: {
15
+ id: string;
16
+ name: string;
17
+ questionCount: number;
18
+ }[];
19
+ files: File[];
20
+ students: (User & {
21
+ profile?: {
22
+ displayName: string | null;
23
+ } | null;
24
+ })[];
25
+ teachers: (User & {
26
+ profile?: {
27
+ displayName: string | null;
28
+ } | null;
29
+ })[];
30
+ assignments: (Assignment & {
31
+ section?: {
32
+ id: string;
33
+ name: string;
34
+ order?: number | null;
35
+ } | null;
36
+ markScheme?: {
37
+ id: string;
38
+ } | null;
39
+ gradingBoundary?: {
40
+ id: string;
41
+ } | null;
42
+ })[];
43
+ };
44
+ /**
45
+ * Builds schema-aware context for the AI from class data.
46
+ * Formats entities with IDs so the model can reference them when creating assignments.
47
+ */
48
+ export declare const buildClassContextForAI: (data: ClassContextData) => string;
49
+ /**
50
+ * @deprecated Use buildClassContextForAI for schema-aware context. Kept for compatibility.
51
+ */
2
52
  export declare const getBaseSystemPrompt: (context: Class, members: User[], assignments: Assignment[], files: File[], sections: Section[]) => string;
3
53
  /**
4
54
  * Generate labchat responses
@@ -16,6 +66,11 @@ export declare const generateAndSendLabIntroduction: (labChatId: string, convers
16
66
  /**
17
67
  * Generate and send AI response to teacher message
18
68
  * Uses the stored context directly from database
69
+ * @param emitOptions - When provided, emits lab-response-completed/failed on teacher channel
19
70
  */
20
- export declare const generateAndSendLabResponse: (labChatId: string, teacherMessage: string, conversationId: string) => Promise<void>;
71
+ export declare const generateAndSendLabResponse: (labChatId: string, teacherMessage: string, conversationId: string, emitOptions?: {
72
+ classId: string;
73
+ messageId: string;
74
+ }) => Promise<void>;
75
+ export {};
21
76
  //# sourceMappingURL=aiLabChat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aiLabChat.d.ts","sourceRoot":"/","sources":["pipelines/aiLabChat.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA4ExE,eAAO,MAAM,mBAAmB,GAAI,SAAS,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,aAA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