@studious-lms/server 1.15.0 → 1.16.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 (113) hide show
  1. package/.github/workflows/deploy.yml +1 -1
  2. package/dist/instrument.js +3 -3
  3. package/dist/instrument.js.map +1 -1
  4. package/dist/models/announcement.d.ts +0 -2
  5. package/dist/models/announcement.d.ts.map +1 -1
  6. package/dist/models/auth.d.ts +0 -8
  7. package/dist/models/auth.d.ts.map +1 -1
  8. package/dist/models/auth.js +2 -4
  9. package/dist/models/auth.js.map +1 -1
  10. package/dist/models/event.d.ts +0 -2
  11. package/dist/models/event.d.ts.map +1 -1
  12. package/dist/models/file.d.ts +0 -24
  13. package/dist/models/file.d.ts.map +1 -1
  14. package/dist/models/marketing.d.ts +15 -2
  15. package/dist/models/marketing.d.ts.map +1 -1
  16. package/dist/models/marketing.js +4 -12
  17. package/dist/models/marketing.js.map +1 -1
  18. package/dist/pipelines/aiLabChat.d.ts.map +1 -1
  19. package/dist/pipelines/aiLabChat.js +26 -34
  20. package/dist/pipelines/aiLabChat.js.map +1 -1
  21. package/dist/pipelines/gradeWorksheet.d.ts.map +1 -1
  22. package/dist/pipelines/gradeWorksheet.js +75 -36
  23. package/dist/pipelines/gradeWorksheet.js.map +1 -1
  24. package/dist/pipelines/labChatPrompt.d.ts.map +1 -1
  25. package/dist/pipelines/labChatPrompt.js +3 -6
  26. package/dist/pipelines/labChatPrompt.js.map +1 -1
  27. package/dist/routers/_app.d.ts +26 -222
  28. package/dist/routers/_app.d.ts.map +1 -1
  29. package/dist/routers/assignment.d.ts +0 -10
  30. package/dist/routers/assignment.d.ts.map +1 -1
  31. package/dist/routers/auth.d.ts +0 -2
  32. package/dist/routers/auth.d.ts.map +1 -1
  33. package/dist/routers/auth.js +2 -15
  34. package/dist/routers/auth.js.map +1 -1
  35. package/dist/routers/class.d.ts +0 -4
  36. package/dist/routers/class.d.ts.map +1 -1
  37. package/dist/routers/event.d.ts +0 -2
  38. package/dist/routers/event.d.ts.map +1 -1
  39. package/dist/routers/marketing.d.ts +13 -0
  40. package/dist/routers/marketing.d.ts.map +1 -1
  41. package/dist/routers/school.d.ts +0 -4
  42. package/dist/routers/school.d.ts.map +1 -1
  43. package/dist/routers/user.d.ts +0 -89
  44. package/dist/routers/user.d.ts.map +1 -1
  45. package/dist/routers/user.js +2 -19
  46. package/dist/routers/user.js.map +1 -1
  47. package/dist/seedDatabase.d.ts +0 -2
  48. package/dist/seedDatabase.d.ts.map +1 -1
  49. package/dist/services/aiChatStream.d.ts +0 -2
  50. package/dist/services/aiChatStream.d.ts.map +1 -1
  51. package/dist/services/aiChatStream.js +4 -31
  52. package/dist/services/aiChatStream.js.map +1 -1
  53. package/dist/services/aiProposalTools.d.ts.map +1 -1
  54. package/dist/services/aiProposalTools.js +7 -7
  55. package/dist/services/aiProposalTools.js.map +1 -1
  56. package/dist/services/aiTools.js +3 -3
  57. package/dist/services/aiTools.js.map +1 -1
  58. package/dist/services/assignment.d.ts +0 -10
  59. package/dist/services/assignment.d.ts.map +1 -1
  60. package/dist/services/auth.d.ts +0 -2
  61. package/dist/services/auth.d.ts.map +1 -1
  62. package/dist/services/auth.js +4 -13
  63. package/dist/services/auth.js.map +1 -1
  64. package/dist/services/class.d.ts +0 -4
  65. package/dist/services/class.d.ts.map +1 -1
  66. package/dist/services/event.d.ts +0 -2
  67. package/dist/services/event.d.ts.map +1 -1
  68. package/dist/services/marketing.d.ts +14 -1
  69. package/dist/services/marketing.d.ts.map +1 -1
  70. package/dist/services/marketing.js +5 -5
  71. package/dist/services/marketing.js.map +1 -1
  72. package/dist/services/openaiDocumentGen.d.ts +0 -12
  73. package/dist/services/openaiDocumentGen.d.ts.map +1 -1
  74. package/dist/services/openaiDocumentGen.js +63 -130
  75. package/dist/services/openaiDocumentGen.js.map +1 -1
  76. package/dist/services/school.d.ts +0 -4
  77. package/dist/services/school.d.ts.map +1 -1
  78. package/dist/utils/email.d.ts.map +1 -1
  79. package/dist/utils/email.js +3 -7
  80. package/dist/utils/email.js.map +1 -1
  81. package/package.json +1 -1
  82. package/prisma/schema.prisma +0 -3
  83. package/src/instrument.ts +1 -1
  84. package/src/models/auth.ts +0 -4
  85. package/src/models/marketing.ts +2 -10
  86. package/src/pipelines/aiLabChat.ts +28 -41
  87. package/src/pipelines/gradeWorksheet.ts +95 -38
  88. package/src/pipelines/labChatPrompt.ts +1 -4
  89. package/src/routers/auth.ts +0 -13
  90. package/src/routers/user.ts +0 -26
  91. package/src/services/aiChatStream.ts +3 -30
  92. package/src/services/aiProposalTools.ts +5 -6
  93. package/src/services/aiTools.ts +1 -1
  94. package/src/services/auth.ts +2 -14
  95. package/src/services/marketing.ts +3 -3
  96. package/src/services/openaiDocumentGen.ts +64 -146
  97. package/src/utils/email.ts +1 -5
  98. package/tests/integration/globalSetup.ts +18 -10
  99. package/tests/integration/routers/auth.test.ts +18 -13
  100. package/dist/lib/legal.d.ts +0 -3
  101. package/dist/lib/legal.d.ts.map +0 -1
  102. package/dist/lib/legal.js +0 -6
  103. package/dist/lib/legal.js.map +0 -1
  104. package/dist/services/userPrivacy.d.ts +0 -86
  105. package/dist/services/userPrivacy.d.ts.map +0 -1
  106. package/dist/services/userPrivacy.js +0 -184
  107. package/dist/services/userPrivacy.js.map +0 -1
  108. package/prisma/migrations/20260611120000_add_user_terms_acceptance/migration.sql +0 -3
  109. package/src/lib/legal.ts +0 -2
  110. package/src/services/userPrivacy.ts +0 -196
  111. package/tests/helpers/registerInput.ts +0 -20
  112. package/tests/unit/services/aiChatStream.test.ts +0 -92
  113. package/tests/unit/services/openaiDocumentGen.test.ts +0 -65
@@ -21,9 +21,7 @@ export declare const authRouter: import("@trpc/server").TRPCBuiltRouter<{
21
21
  username: string;
22
22
  email: string;
23
23
  password: string;
24
- termsVersion: "2025-11";
25
24
  confirmPassword: string;
26
- agreeToTerms: true;
27
25
  };
28
26
  output: {
29
27
  user: {
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"/","sources":["routers/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8CxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DrB,CAAC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"/","sources":["routers/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmCxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DrB,CAAC"}
@@ -1,9 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d1a28eb6-8a65-51d4-91b1-0850796f9caf")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3c1fd22e-5583-52a3-9f05-0ba551964a14")}catch(e){}}();
3
3
  import { z } from "zod";
4
4
  import { TRPCError } from "@trpc/server";
5
5
  import { createTRPCRouter, protectedProcedure, publicProcedure, } from "../trpc.js";
6
- import { CURRENT_TERMS_VERSION } from "../lib/legal.js";
7
6
  import { register, login, logout, check, resendVerificationEmail, verify, requestPasswordReset, resetPassword, } from "../services/auth.js";
8
7
  const loginSchema = z.object({
9
8
  username: z.string(),
@@ -15,16 +14,6 @@ const registerSchema = z
15
14
  email: z.string().email("Invalid email address"),
16
15
  password: z.string().min(6, "Password must be at least 6 characters"),
17
16
  confirmPassword: z.string(),
18
- agreeToTerms: z.literal(true, {
19
- errorMap: () => ({
20
- message: "You must accept the Terms of Service and Privacy Policy",
21
- }),
22
- }),
23
- termsVersion: z.literal(CURRENT_TERMS_VERSION, {
24
- errorMap: () => ({
25
- message: "Please accept the current Terms of Service and Privacy Policy",
26
- }),
27
- }),
28
17
  })
29
18
  .refine((data) => data.password === data.confirmPassword, {
30
19
  message: "Passwords don't match",
@@ -37,8 +26,6 @@ export const authRouter = createTRPCRouter({
37
26
  username: input.username,
38
27
  email: input.email,
39
28
  password: input.password,
40
- agreeToTerms: input.agreeToTerms,
41
- termsVersion: input.termsVersion,
42
29
  })),
43
30
  login: publicProcedure
44
31
  .input(loginSchema)
@@ -84,4 +71,4 @@ export const authRouter = createTRPCRouter({
84
71
  .mutation(({ input }) => resetPassword(input.token, input.password)),
85
72
  });
86
73
  //# sourceMappingURL=auth.js.map
87
- //# debugId=d1a28eb6-8a65-51d4-91b1-0850796f9caf
74
+ //# debugId=3c1fd22e-5583-52a3-9f05-0ba551964a14
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sources":["routers/auth.ts"],"sourceRoot":"/","sourcesContent":["import { z } from \"zod\";\nimport { TRPCError } from \"@trpc/server\";\nimport {\n createTRPCRouter,\n protectedProcedure,\n publicProcedure,\n} from \"../trpc.js\";\nimport { CURRENT_TERMS_VERSION } from \"../lib/legal.js\";\nimport {\n register,\n login,\n logout,\n check,\n resendVerificationEmail,\n verify,\n requestPasswordReset,\n resetPassword,\n} from \"../services/auth.js\";\n\nconst loginSchema = z.object({\n username: z.string(),\n password: z.string(),\n});\n\nconst registerSchema = z\n .object({\n username: z.string().min(3, \"Username must be at least 3 characters\"),\n email: z.string().email(\"Invalid email address\"),\n password: z.string().min(6, \"Password must be at least 6 characters\"),\n confirmPassword: z.string(),\n agreeToTerms: z.literal(true, {\n errorMap: () => ({\n message: \"You must accept the Terms of Service and Privacy Policy\",\n }),\n }),\n termsVersion: z.literal(CURRENT_TERMS_VERSION, {\n errorMap: () => ({\n message: \"Please accept the current Terms of Service and Privacy Policy\",\n }),\n }),\n })\n .refine((data) => data.password === data.confirmPassword, {\n message: \"Passwords don't match\",\n path: [\"confirmPassword\"],\n });\n\nexport const authRouter = createTRPCRouter({\n register: publicProcedure\n .input(registerSchema)\n .mutation(({ input }) =>\n register({\n username: input.username,\n email: input.email,\n password: input.password,\n agreeToTerms: input.agreeToTerms,\n termsVersion: input.termsVersion,\n })\n ),\n\n login: publicProcedure\n .input(loginSchema)\n .mutation(({ input }) => login(input)),\n\n logout: protectedProcedure.mutation(({ ctx }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"Not authenticated\",\n });\n }\n return logout(ctx.user.id);\n }),\n\n check: protectedProcedure.query(({ ctx }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"Not authenticated\",\n });\n }\n return check(ctx.user.id);\n }),\n\n resendVerificationEmail: publicProcedure\n .input(z.object({ email: z.string().email() }))\n .mutation(({ input }) => resendVerificationEmail(input.email)),\n\n verify: publicProcedure\n .input(z.object({ token: z.string() }))\n .mutation(({ input }) => verify(input.token)),\n\n requestPasswordReset: publicProcedure\n .input(z.object({ email: z.string().email() }))\n .mutation(({ input }) => requestPasswordReset(input.email)),\n\n resetPassword: publicProcedure\n .input(\n z\n .object({\n token: z.string(),\n password: z.string().min(6, \"Password must be at least 6 characters\"),\n confirmPassword: z.string(),\n })\n .refine((data) => data.password === data.confirmPassword, {\n message: \"Passwords don't match\",\n path: [\"confirmPassword\"],\n })\n )\n .mutation(({ input }) => resetPassword(input.token, input.password)),\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,S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AAK,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CACvE,CAAC,CAAC","debug_id":"d1a28eb6-8a65-51d4-91b1-0850796f9caf"}
1
+ {"version":3,"file":"auth.js","sources":["routers/auth.ts"],"sourceRoot":"/","sourcesContent":["import { z } from \"zod\";\nimport { TRPCError } from \"@trpc/server\";\nimport {\n createTRPCRouter,\n protectedProcedure,\n publicProcedure,\n} from \"../trpc.js\";\nimport {\n register,\n login,\n logout,\n check,\n resendVerificationEmail,\n verify,\n requestPasswordReset,\n resetPassword,\n} from \"../services/auth.js\";\n\nconst loginSchema = z.object({\n username: z.string(),\n password: z.string(),\n});\n\nconst registerSchema = z\n .object({\n username: z.string().min(3, \"Username must be at least 3 characters\"),\n email: z.string().email(\"Invalid email address\"),\n password: z.string().min(6, \"Password must be at least 6 characters\"),\n confirmPassword: z.string(),\n })\n .refine((data) => data.password === data.confirmPassword, {\n message: \"Passwords don't match\",\n path: [\"confirmPassword\"],\n });\n\nexport const authRouter = createTRPCRouter({\n register: publicProcedure\n .input(registerSchema)\n .mutation(({ input }) =>\n register({\n username: input.username,\n email: input.email,\n password: input.password,\n })\n ),\n\n login: publicProcedure\n .input(loginSchema)\n .mutation(({ input }) => login(input)),\n\n logout: protectedProcedure.mutation(({ ctx }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"Not authenticated\",\n });\n }\n return logout(ctx.user.id);\n }),\n\n check: protectedProcedure.query(({ ctx }) => {\n if (!ctx.user) {\n throw new TRPCError({\n code: \"UNAUTHORIZED\",\n message: \"Not authenticated\",\n });\n }\n return check(ctx.user.id);\n }),\n\n resendVerificationEmail: publicProcedure\n .input(z.object({ email: z.string().email() }))\n .mutation(({ input }) => resendVerificationEmail(input.email)),\n\n verify: publicProcedure\n .input(z.object({ token: z.string() }))\n .mutation(({ input }) => verify(input.token)),\n\n requestPasswordReset: publicProcedure\n .input(z.object({ email: z.string().email() }))\n .mutation(({ input }) => requestPasswordReset(input.email)),\n\n resetPassword: publicProcedure\n .input(\n z\n .object({\n token: z.string(),\n password: z.string().min(6, \"Password must be at least 6 characters\"),\n confirmPassword: z.string(),\n })\n .refine((data) => data.password === data.confirmPassword, {\n message: \"Passwords don't match\",\n path: [\"confirmPassword\"],\n })\n )\n .mutation(({ input }) => resetPassword(input.token, input.password)),\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,oBAAoB,EACpB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wCAAwC,CAAC;IACrE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAChD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wCAAwC,CAAC;IACrE,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;CAC5B,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,eAAe,EAAE;IACxD,OAAO,EAAE,uBAAuB;IAChC,IAAI,EAAE,CAAC,iBAAiB,CAAC;CAC1B,CAAC,C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964a14"}
@@ -297,8 +297,6 @@ export declare const classRouter: import("@trpc/server").TRPCBuiltRouter<{
297
297
  email: string;
298
298
  password: string;
299
299
  verified: boolean;
300
- termsAcceptedAt: Date | null;
301
- termsVersion: string | null;
302
300
  schoolId: string | null;
303
301
  }[];
304
302
  students: {
@@ -307,8 +305,6 @@ export declare const classRouter: import("@trpc/server").TRPCBuiltRouter<{
307
305
  email: string;
308
306
  password: string;
309
307
  verified: boolean;
310
- termsAcceptedAt: Date | null;
311
- termsVersion: string | null;
312
308
  schoolId: string | null;
313
309
  }[];
314
310
  } & {
@@ -1 +1 @@
1
- {"version":3,"file":"class.d.ts","sourceRoot":"/","sources":["routers/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2CxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuStB,CAAC"}
@@ -28,8 +28,6 @@ export declare const eventRouter: import("@trpc/server").TRPCBuiltRouter<{
28
28
  email: string;
29
29
  password: string;
30
30
  verified: boolean;
31
- termsAcceptedAt: Date | null;
32
- termsVersion: string | null;
33
31
  schoolId: string | null;
34
32
  } | null;
35
33
  class: ({
@@ -1 +1 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"/","sources":["routers/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsBxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDtB,CAAC"}
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"/","sources":["routers/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsBxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDtB,CAAC"}
@@ -44,12 +44,25 @@ export declare const marketingRouter: import("@trpc/server").TRPCBuiltRouter<{
44
44
  id: string;
45
45
  };
46
46
  output: {
47
+ type: string;
47
48
  status: string;
48
49
  id: string;
50
+ website: string | null;
49
51
  name: string;
50
52
  submittedAt: Date | null;
53
+ address: string;
51
54
  city: string;
52
55
  country: string;
56
+ numberOfStudents: number;
57
+ numberOfTeachers: number;
58
+ contactName: string | null;
59
+ contactRole: string | null;
60
+ contactEmail: string | null;
61
+ contactPhone: string | null;
62
+ eligibilityInformation: string | null;
63
+ whyHelp: string | null;
64
+ additionalInformation: string | null;
65
+ reviewedAt: Date | null;
53
66
  } | null;
54
67
  meta: object;
55
68
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"marketing.d.ts","sourceRoot":"/","sources":["routers/marketing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmC1B,CAAC"}
1
+ {"version":3,"file":"marketing.d.ts","sourceRoot":"/","sources":["routers/marketing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmC1B,CAAC"}
@@ -317,8 +317,6 @@ export declare const schoolRouter: import("@trpc/server").TRPCBuiltRouter<{
317
317
  email: string;
318
318
  password: string;
319
319
  verified: boolean;
320
- termsAcceptedAt: Date | null;
321
- termsVersion: string | null;
322
320
  schoolId: string | null;
323
321
  }[];
324
322
  students: {
@@ -327,8 +325,6 @@ export declare const schoolRouter: import("@trpc/server").TRPCBuiltRouter<{
327
325
  email: string;
328
326
  password: string;
329
327
  verified: boolean;
330
- termsAcceptedAt: Date | null;
331
- termsVersion: string | null;
332
328
  schoolId: string | null;
333
329
  }[];
334
330
  } & {
@@ -1 +1 @@
1
- {"version":3,"file":"school.d.ts","sourceRoot":"/","sources":["routers/school.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmCxB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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Router: import("@trpc/server").TRPCBuiltRouter<{
76
76
  };
77
77
  meta: object;
78
78
  }>;
79
- exportData: import("@trpc/server").TRPCQueryProcedure<{
80
- input: void;
81
- output: {
82
- exportedAt: string;
83
- user: {
84
- id: string;
85
- username: string;
86
- email: string;
87
- verified: boolean;
88
- termsAcceptedAt: Date | null;
89
- termsVersion: string | null;
90
- profile: {
91
- id: string;
92
- userId: string;
93
- displayName: string | null;
94
- bio: string | null;
95
- location: string | null;
96
- website: string | null;
97
- createdAt: Date;
98
- updatedAt: Date;
99
- profilePicture: string | null;
100
- profilePictureThumbnail: string | null;
101
- } | null;
102
- teacherIn: {
103
- section: string;
104
- id: string;
105
- name: string;
106
- subject: string;
107
- }[];
108
- studentIn: {
109
- section: string;
110
- id: string;
111
- name: string;
112
- subject: string;
113
- }[];
114
- submissions: {
115
- assignment: {
116
- id: string;
117
- classId: string;
118
- title: string;
119
- };
120
- id: string;
121
- createdAt: Date;
122
- extendedResponse: string | null;
123
- gradeReceived: number | null;
124
- submittedAt: Date | null;
125
- }[];
126
- events: {
127
- id: string;
128
- location: string | null;
129
- name: string | null;
130
- startTime: Date;
131
- endTime: Date;
132
- remarks: string | null;
133
- }[];
134
- notificationsReceived: {
135
- id: string;
136
- createdAt: Date;
137
- title: string;
138
- content: string;
139
- read: boolean;
140
- }[];
141
- schoolMemberships: {
142
- status: import(".prisma/client").$Enums.SchoolMembershipStatus;
143
- school: {
144
- id: string;
145
- name: string;
146
- };
147
- role: import(".prisma/client").$Enums.SchoolMembershipRole;
148
- }[];
149
- sentMessages: {
150
- id: string;
151
- createdAt: Date;
152
- content: string;
153
- conversationId: string;
154
- }[];
155
- };
156
- };
157
- meta: object;
158
- }>;
159
- deleteAccount: import("@trpc/server").TRPCMutationProcedure<{
160
- input: {
161
- confirmUsername: string;
162
- };
163
- output: {
164
- success: boolean;
165
- };
166
- meta: object;
167
- }>;
168
79
  }>>;
169
80
  //# sourceMappingURL=user.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"/","sources":["routers/user.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqExB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCrB,CAAC"}
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"/","sources":["routers/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiExB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgBrB,CAAC"}
@@ -1,10 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="10c9f9c2-5706-58e3-b2db-3ca52ac3e956")}catch(e){}}();
3
- import { TRPCError } from "@trpc/server";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7b0b6e3d-022d-5fe3-a54e-a8f4a40964f3")}catch(e){}}();
4
3
  import { z } from "zod";
5
4
  import { createTRPCRouter, protectedProcedure } from "../trpc.js";
6
5
  import { getProfile, updateProfile, getUploadUrl, } from "../services/user.js";
7
- import { deleteUserAccount, exportUserData, } from "../services/userPrivacy.js";
8
6
  const fileUploadSchema = z.object({
9
7
  filePath: z.string().min(1, "File path is required"),
10
8
  fileName: z.string().min(1, "File name is required"),
@@ -59,21 +57,6 @@ export const userRouter = createTRPCRouter({
59
57
  getUploadUrl: protectedProcedure
60
58
  .input(getUploadUrlSchema)
61
59
  .mutation(({ ctx, input }) => getUploadUrl(ctx.user.id, input.fileName, input.fileType)),
62
- exportData: protectedProcedure.query(({ ctx }) => exportUserData(ctx.user.id)),
63
- deleteAccount: protectedProcedure
64
- .input(z.object({
65
- confirmUsername: z.string().min(1),
66
- }))
67
- .mutation(async ({ ctx, input }) => {
68
- const profile = await getProfile(ctx.user.id);
69
- if (profile.username !== input.confirmUsername) {
70
- throw new TRPCError({
71
- code: "BAD_REQUEST",
72
- message: "Username confirmation does not match",
73
- });
74
- }
75
- return deleteUserAccount(ctx.user.id);
76
- }),
77
60
  });
78
61
  //# sourceMappingURL=user.js.map
79
- //# debugId=10c9f9c2-5706-58e3-b2db-3ca52ac3e956
62
+ //# debugId=7b0b6e3d-022d-5fe3-a54e-a8f4a40964f3
@@ -1 +1 @@
1
- {"version":3,"file":"user.js","sources":["routers/user.ts"],"sourceRoot":"/","sourcesContent":["import { TRPCError } from \"@trpc/server\";\nimport { z } from \"zod\";\nimport { createTRPCRouter, protectedProcedure } from \"../trpc.js\";\nimport {\n getProfile,\n updateProfile,\n getUploadUrl,\n} from \"../services/user.js\";\nimport {\n deleteUserAccount,\n exportUserData,\n} from \"../services/userPrivacy.js\";\n\nconst fileUploadSchema = z.object({\n filePath: z.string().min(1, \"File path is required\"),\n fileName: z.string().min(1, \"File name is required\"),\n fileType: z\n .string()\n .regex(\n /^image\\/(jpeg|jpg|png|gif|webp)$/i,\n \"Only image files (JPEG, PNG, GIF, WebP) are allowed\"\n ),\n fileSize: z.number().max(5 * 1024 * 1024, \"File size must be less than 5MB\"),\n});\n\nconst dicebearSchema = z.object({\n url: z.string().url(\"Invalid DiceBear avatar URL\"),\n});\n\nconst profileSchema = z.object({\n displayName: z\n .string()\n .nullable()\n .optional()\n .transform((val) => (val === null ? undefined : val)),\n bio: z\n .string()\n .nullable()\n .optional()\n .transform((val) => (val === null ? undefined : val)),\n location: z\n .string()\n .nullable()\n .optional()\n .transform((val) => (val === null ? undefined : val)),\n website: z\n .union([\n z.string().url(),\n z.literal(\"\"),\n z.null().transform(() => undefined),\n ])\n .optional(),\n});\n\nconst updateProfileSchema = z.object({\n profile: profileSchema.optional(),\n profilePicture: fileUploadSchema.optional(),\n dicebearAvatar: dicebearSchema.optional(),\n});\n\nconst getUploadUrlSchema = z.object({\n fileName: z.string().min(1, \"File name is required\"),\n fileType: z\n .string()\n .regex(\n /^image\\/(jpeg|jpg|png|gif|webp)$/i,\n \"Only image files are allowed\"\n ),\n});\n\nexport const userRouter = createTRPCRouter({\n getProfile: protectedProcedure.query(({ ctx }) =>\n getProfile(ctx.user!.id)\n ),\n\n updateProfile: protectedProcedure\n .input(updateProfileSchema)\n .mutation(({ ctx, input }) =>\n updateProfile(ctx.user!.id, input)\n ),\n\n getUploadUrl: protectedProcedure\n .input(getUploadUrlSchema)\n .mutation(({ ctx, input }) =>\n getUploadUrl(ctx.user!.id, input.fileName, input.fileType)\n ),\n\n exportData: protectedProcedure.query(({ ctx }) =>\n exportUserData(ctx.user!.id),\n ),\n\n deleteAccount: protectedProcedure\n .input(\n z.object({\n confirmUsername: z.string().min(1),\n }),\n )\n .mutation(async ({ ctx, input }) => {\n const profile = await getProfile(ctx.user!.id);\n if (profile.username !== input.confirmUsername) {\n throw new TRPCError({\n code: \"BAD_REQUEST\",\n message: \"Username confirmation does not match\",\n });\n }\n return deleteUserAccount(ctx.user!.id);\n }),\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EACL,UAAU,EACV,aAAa,EACb,YAAY,GACb,MA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B;SAC7B,KAAK,CAAC,kBAAkB,CAAC;SACzB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAC3B,YAAY,CAAC,GAAG,CAAC,IAAK,CAAC,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAC3D;IAEH,UAAU,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAC/C,cAAc,CAAC,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC,CAC7B;IAED,aAAa,EAAE,kBAAkB;SAC9B,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;KACnC,CAAC,CACH;SACA,QAAQ,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;QACjC,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC,CAAC;QAC/C,IAAI,OAAO,CAAC,QAAQ,KAAK,KAAK,CAAC,eAAe,EAAE,CAAC;YAC/C,MAAM,IAAI,SAAS,CAAC;gBAClB,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,sCAAsC;aAChD,CAAC,CAAC;QACL,CAAC;QACD,OAAO,iBAAiB,CAAC,GAAG,CAAC,IAAK,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC,CAAC;CACL,CAAC,CAAC","debug_id":"10c9f9c2-5706-58e3-b2db-3ca52ac3e956"}
1
+ {"version":3,"file":"user.js","sources":["routers/user.ts"],"sourceRoot":"/","sourcesContent":["import { z } from \"zod\";\nimport { createTRPCRouter, protectedProcedure } from \"../trpc.js\";\nimport {\n getProfile,\n updateProfile,\n getUploadUrl,\n} from \"../services/user.js\";\n\nconst fileUploadSchema = z.object({\n filePath: z.string().min(1, \"File path is required\"),\n fileName: z.string().min(1, \"File name is required\"),\n fileType: z\n .string()\n .regex(\n /^image\\/(jpeg|jpg|png|gif|webp)$/i,\n \"Only image files (JPEG, PNG, GIF, WebP) are allowed\"\n ),\n fileSize: z.number().max(5 * 1024 * 1024, \"File size must be less than 5MB\"),\n});\n\nconst dicebearSchema = z.object({\n url: z.string().url(\"Invalid DiceBear avatar URL\"),\n});\n\nconst profileSchema = z.object({\n displayName: z\n .string()\n .nullable()\n .optional()\n .transform((val) => (val === null ? undefined : val)),\n bio: z\n .string()\n .nullable()\n .optional()\n .transform((val) => (val === null ? undefined : val)),\n location: z\n .string()\n .nullable()\n .optional()\n .transform((val) => (val === null ? undefined : val)),\n website: z\n .union([\n z.string().url(),\n z.literal(\"\"),\n z.null().transform(() => undefined),\n ])\n .optional(),\n});\n\nconst updateProfileSchema = z.object({\n profile: profileSchema.optional(),\n profilePicture: fileUploadSchema.optional(),\n dicebearAvatar: dicebearSchema.optional(),\n});\n\nconst getUploadUrlSchema = z.object({\n fileName: z.string().min(1, \"File name is required\"),\n fileType: z\n .string()\n .regex(\n /^image\\/(jpeg|jpg|png|gif|webp)$/i,\n \"Only image files are allowed\"\n ),\n});\n\nexport const userRouter = createTRPCRouter({\n getProfile: protectedProcedure.query(({ ctx }) =>\n getProfile(ctx.user!.id)\n ),\n\n updateProfile: protectedProcedure\n .input(updateProfileSchema)\n .mutation(({ ctx, input }) =>\n updateProfile(ctx.user!.id, input)\n ),\n\n getUploadUrl: protectedProcedure\n .input(getUploadUrlSchema)\n .mutation(({ ctx, input }) =>\n getUploadUrl(ctx.user!.id, input.fileName, input.fileType)\n ),\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EACL,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,MAAM,gBAAgB,GAAG,CAAC,CA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AAC,GAAG,CAAC,IAAK,CAAC,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAC3D;CACJ,CAAC,CAAC","debug_id":"7b0b6e3d-022d-5fe3-a54e-a8f4a40964f3"}
@@ -5,8 +5,6 @@ export declare function createUser(email: string, password: string, username: st
5
5
  email: string;
6
6
  password: string;
7
7
  verified: boolean;
8
- termsAcceptedAt: Date | null;
9
- termsVersion: string | null;
10
8
  schoolId: string | null;
11
9
  }>;
12
10
  export declare function addNotification(userId: string, title: string, content: string): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"seedDatabase.d.ts","sourceRoot":"/","sources":["seedDatabase.ts"],"names":[],"mappings":"AAwBA,wBAAsB,aAAa,kBA+ElC;AA6CD,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;;;GAKjF;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;GAQnF;AA+HD,eAAO,MAAM,YAAY,qBAskDxB,CAAC"}
1
+ {"version":3,"file":"seedDatabase.d.ts","sourceRoot":"/","sources":["seedDatabase.ts"],"names":[],"mappings":"AAwBA,wBAAsB,aAAa,kBA+ElC;AA6CD,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;;;;GAKjF;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;GAQnF;AA+HD,eAAO,MAAM,YAAY,qBAskDxB,CAAC"}
@@ -58,8 +58,6 @@ export declare function applyResolvedFormatsToStreamParts(parts: StreamPart[], d
58
58
  }>): StreamPart[];
59
59
  /** Attach file IDs to `generate_document` tool parts for inline download chips. */
60
60
  export declare function enrichStreamPartsWithGeneratedFiles(parts: StreamPart[], files: GeneratedDocFileLink[]): StreamPart[];
61
- /** Mark deferred tools completed (file linked) or failed (generation did not produce a file). */
62
- export declare function finalizeDeferredToolParts(parts: StreamPart[]): StreamPart[];
63
61
  export interface StreamChatOptions {
64
62
  conversationId: string;
65
63
  aiMessageId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"aiChatStream.d.ts","sourceRoot":"/","sources":["services/aiChatStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAA2B,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,IAAI,CAAC;AAS9E,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,KAAK,EAAE,OAAO,CAAC;IACf,6EAA6E;IAC7E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;CAChC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IACE,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;CAC9C,CAAC;AAEN,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,M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mBD,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,2EAA2E;IAC3E,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAuI3B"}
@@ -12,7 +12,7 @@
12
12
  * terminal `message-stream-complete` / `message-updated` events.
13
13
  */
14
14
 
15
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5a03c108-e33a-50c7-a5fd-24f570b1b507")}catch(e){}}();
15
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8b3ecdb4-6453-5bf3-a9c6-a0b07061c768")}catch(e){}}();
16
16
  import { streamText, stepCountIs } from 'ai';
17
17
  import { openai } from '@ai-sdk/openai';
18
18
  import { getRedis } from '../lib/redis.js';
@@ -42,11 +42,6 @@ export function applyResolvedFormatsToStreamParts(parts, docs) {
42
42
  return doc ? { ...part, format: doc.format } : part;
43
43
  });
44
44
  }
45
- /** Tools that queue async work after the model stream; UI stays loading until the pipeline finishes. */
46
- const DEFERRED_COMPLETION_TOOLS = new Set(['generate_document']);
47
- function isDeferredCompletionTool(toolName) {
48
- return DEFERRED_COMPLETION_TOOLS.has(toolName);
49
- }
50
45
  /** Attach file IDs to `generate_document` tool parts for inline download chips. */
51
46
  export function enrichStreamPartsWithGeneratedFiles(parts, files) {
52
47
  if (files.length === 0)
@@ -79,24 +74,10 @@ export function enrichStreamPartsWithGeneratedFiles(parts, files) {
79
74
  ...part,
80
75
  fileId: file.fileId,
81
76
  fileName: file.fileName,
82
- status: 'completed',
83
77
  ...(file.format ? { format: file.format } : {}),
84
78
  };
85
79
  });
86
80
  }
87
- /** Mark deferred tools completed (file linked) or failed (generation did not produce a file). */
88
- export function finalizeDeferredToolParts(parts) {
89
- return parts.map((part) => {
90
- if (part.type !== 'tool' || !isDeferredCompletionTool(part.toolName)) {
91
- return part;
92
- }
93
- if (part.fileId)
94
- return { ...part, status: 'completed' };
95
- if (part.status === 'executing')
96
- return { ...part, status: 'failed' };
97
- return part;
98
- });
99
- }
100
81
  function toolFieldFromInput(input, key) {
101
82
  if (input && typeof input === 'object') {
102
83
  const val = input[key];
@@ -201,15 +182,7 @@ export async function streamChatResponse(options) {
201
182
  }
202
183
  case 'tool-result':
203
184
  case 'tool-error': {
204
- const failed = part.type === 'tool-error';
205
- const deferred = isDeferredCompletionTool(part.toolName);
206
- // Deferred tools (e.g. generate_document) only queue work during the
207
- // stream — keep the spinner until the pipeline attaches a file.
208
- const status = failed
209
- ? 'failed'
210
- : deferred
211
- ? 'executing'
212
- : 'completed';
185
+ const status = part.type === 'tool-error' ? 'failed' : 'completed';
213
186
  const title = toolTitleFromInput(part.input);
214
187
  const format = toolFieldFromInput(part.input, 'format');
215
188
  const idx = toolPartIndexById.get(part.toolCallId);
@@ -225,7 +198,7 @@ export async function streamChatResponse(options) {
225
198
  toolName: part.toolName,
226
199
  input: part.input,
227
200
  output: part.type === 'tool-result' ? part.output : undefined,
228
- status: failed ? 'failed' : 'completed',
201
+ status,
229
202
  });
230
203
  await broadcast('message-tool-call', {
231
204
  messageId: aiMessageId,
@@ -251,4 +224,4 @@ export async function streamChatResponse(options) {
251
224
  }
252
225
  }
253
226
  //# sourceMappingURL=aiChatStream.js.map
254
- //# debugId=5a03c108-e33a-50c7-a5fd-24f570b1b507
227
+ //# debugId=8b3ecdb4-6453-5bf3-a9c6-a0b07061c768
@@ -1 +1 @@
1
- {"version":3,"file":"aiChatStream.js","sources":["services/aiChatStream.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Shared AI chat streaming helper.\n *\n * Runs a genuine token-by-token stream via the Vercel AI SDK (`streamText`)\n * against OpenAI — the same provider the rest of the app's inference uses\n * (`OPENAI_API_KEY`). Real text tokens are broadcast over Pusher as they are\n * produced, and real tool calls are broadcast inline (in the order the model\n * invokes them) instead of being derived after the fact from a JSON blob.\n *\n * Callers own persistence: this helper returns the accumulated text and the\n * ordered tool calls so the pipeline can write `content`/`meta` and emit the\n * terminal `message-stream-complete` / `message-updated` events.\n */\nimport { streamText, stepCountIs, type ModelMessage, type ToolSet } from 'ai';\nimport { openai } from '@ai-sdk/openai';\nimport { getRedis } from '../lib/redis.js';\nimport { pusher, chatChannel } from '../lib/pusher.js';\nimport { logger } from '../utils/logger.js';\n\nconst STREAM_REDIS_TTL = 600; // 10 minutes\nconst STREAM_KEY_PREFIX = 'stream:';\n\n/** Default streaming model — matches the existing streamAIResponse path. */\nexport const DEFAULT_STREAM_MODEL = 'gpt-4o-mini';\n\nexport interface StreamedToolCall {\n toolName: string;\n /** Args the model passed to the tool. */\n input: unknown;\n /** Value the tool returned (undefined for client-side / no-result tools). */\n output?: unknown;\n status: 'completed' | 'failed';\n}\n\n/**\n * An ordered fragment of an AI message. The message is a sequence of these\n * parts in the exact order the model produced them, so a tool call rendered\n * \"between paragraph 1 and 2\" is represented as\n * `[{text}, {tool}, {text}]` — enabling true inline rendering (and reload\n * persistence) instead of text and tool calls living in separate buckets.\n */\nexport type StreamPart =\n | { type: 'text'; text: string }\n | {\n type: 'tool';\n toolCallId: string;\n toolName: string;\n /** Concrete entity label (e.g. assignment title / search query), if any. */\n title?: string;\n /** Requested output type from the tool args (pdf, pptx, xlsx, …). */\n format?: string;\n /** Set after generated files are persisted on the message. */\n fileId?: string;\n fileName?: string;\n status: 'executing' | 'completed' | 'failed';\n };\n\nexport interface GeneratedDocFileLink {\n title: string;\n fileId: string;\n fileName: string;\n format?: string;\n}\n\n/** Apply pipeline-resolved formats onto generate_document tool parts. */\nexport function applyResolvedFormatsToStreamParts(\n parts: StreamPart[],\n docs: Array<{ title: string; format: string }>,\n): StreamPart[] {\n if (docs.length === 0) return parts;\n\n const pending = [...docs];\n const takeDoc = (title?: string) => {\n if (title) {\n const idx = pending.findIndex(\n (d) => d.title.trim().toLowerCase() === title.trim().toLowerCase(),\n );\n if (idx >= 0) return pending.splice(idx, 1)[0];\n }\n return pending.shift();\n };\n\n return parts.map((part) => {\n if (part.type !== 'tool' || part.toolName !== 'generate_document') return part;\n const doc = takeDoc(part.title);\n return doc ? { ...part, format: doc.format } : part;\n });\n}\n\n/** Tools that queue async work after the model stream; UI stays loading until the pipeline finishes. */\nconst DEFERRED_COMPLETION_TOOLS = new Set(['generate_document']);\n\nfunction isDeferredCompletionTool(toolName: string): boolean {\n return DEFERRED_COMPLETION_TOOLS.has(toolName);\n}\n\n/** Attach file IDs to `generate_document` tool parts for inline download chips. */\nexport function enrichStreamPartsWithGeneratedFiles(\n parts: StreamPart[],\n files: GeneratedDocFileLink[],\n): StreamPart[] {\n if (files.length === 0) return parts;\n\n const docToolIndices = parts\n .map((part, index) => ({ part, index }))\n .filter(\n ({ part }) =>\n part.type === 'tool' && part.toolName === 'generate_document',\n );\n\n const unmatched = [...files];\n const fileForTool = (toolTitle?: string): GeneratedDocFileLink | undefined => {\n if (toolTitle) {\n const idx = unmatched.findIndex(\n (f) => f.title.trim().toLowerCase() === toolTitle.trim().toLowerCase(),\n );\n if (idx >= 0) return unmatched.splice(idx, 1)[0];\n }\n return unmatched.shift();\n };\n\n const fileByIndex = new Map<number, GeneratedDocFileLink>();\n for (const { part, index } of docToolIndices) {\n if (part.type !== 'tool') continue;\n const file = fileForTool(part.title);\n if (file) fileByIndex.set(index, file);\n }\n\n return parts.map((part, index) => {\n const file = fileByIndex.get(index);\n if (!file || part.type !== 'tool') return part;\n return {\n ...part,\n fileId: file.fileId,\n fileName: file.fileName,\n status: 'completed',\n ...(file.format ? { format: file.format } : {}),\n };\n });\n}\n\n/** Mark deferred tools completed (file linked) or failed (generation did not produce a file). */\nexport function finalizeDeferredToolParts(parts: StreamPart[]): StreamPart[] {\n return parts.map((part) => {\n if (part.type !== 'tool' || !isDeferredCompletionTool(part.toolName)) {\n return part;\n }\n if (part.fileId) return { ...part, status: 'completed' };\n if (part.status === 'executing') return { ...part, status: 'failed' };\n return part;\n });\n}\n\nfunction toolFieldFromInput(input: unknown, key: string): string | undefined {\n if (input && typeof input === 'object') {\n const val = (input as Record<string, unknown>)[key];\n if (typeof val === 'string' && val.trim()) return val.trim();\n }\n return undefined;\n}\n\n/** Pull a human-meaningful label out of a tool's input args, if present. */\nfunction toolTitleFromInput(input: unknown): string | undefined {\n for (const key of ['title', 'name', 'query'] as const) {\n const val = toolFieldFromInput(input, key);\n if (val) return val;\n }\n return undefined;\n}\n\nexport interface StreamChatOptions {\n conversationId: string;\n aiMessageId: string;\n system: string;\n messages: ModelMessage[];\n tools?: ToolSet;\n model?: string;\n temperature?: number;\n maxOutputTokens?: number;\n /** Max agent steps (tool round-trips). Defaults to 6. */\n maxSteps?: number;\n}\n\nexport interface StreamChatResult {\n text: string;\n toolCalls: StreamedToolCall[];\n /** Ordered text/tool parts, in the exact order the model produced them. */\n parts: StreamPart[];\n}\n\n/**\n * Stream a chat completion, broadcasting real text chunks and tool-call\n * events over Pusher. Does NOT persist the message or emit the terminal\n * stream-complete event — the caller does that once it has assembled the\n * final `content`/`meta` (e.g. PDF attachments, structured proposals).\n */\nexport async function streamChatResponse(\n options: StreamChatOptions,\n): Promise<StreamChatResult> {\n const {\n conversationId,\n aiMessageId,\n system,\n messages,\n tools,\n model = DEFAULT_STREAM_MODEL,\n temperature = 0.7,\n maxOutputTokens = 4096,\n maxSteps = 6,\n } = options;\n\n const redis = getRedis();\n const streamKey = `${STREAM_KEY_PREFIX}${aiMessageId}`;\n if (redis) {\n await redis.set(streamKey, '', 'EX', STREAM_REDIS_TTL);\n }\n\n let fullText = '';\n const parts: StreamPart[] = [];\n const toolCalls: StreamedToolCall[] = [];\n // Map AI SDK toolCallId -> index in `parts` so the executing indicator can\n // be flipped to completed/failed in place (preserving its position).\n const toolPartIndexById = new Map<string, number>();\n\n const appendText = (text: string) => {\n fullText += text;\n const last = parts[parts.length - 1];\n if (last && last.type === 'text') {\n last.text += text;\n } else {\n parts.push({ type: 'text', text });\n }\n };\n\n const broadcast = async (event: string, payload: Record<string, unknown>) => {\n try {\n await pusher.trigger(chatChannel(conversationId), event, payload);\n } catch (err) {\n logger.warn(`Failed to broadcast ${event}`, { err, aiMessageId });\n }\n };\n\n try {\n const result = streamText({\n model: openai(model),\n system,\n messages,\n ...(tools ? { tools } : {}),\n temperature,\n maxOutputTokens,\n stopWhen: stepCountIs(maxSteps),\n });\n\n // `fullStream` yields text deltas AND tool events in a single, correctly\n // ordered sequence — this is what makes inline tool calls possible. We\n // build an ordered `parts` list and broadcast each event as it happens.\n for await (const part of result.fullStream) {\n switch (part.type) {\n case 'text-delta': {\n appendText(part.text);\n if (redis) {\n await redis.append(streamKey, part.text).catch(() => {});\n }\n await broadcast('message-stream-chunk', {\n messageId: aiMessageId,\n chunk: part.text,\n });\n break;\n }\n case 'tool-call': {\n const title = toolTitleFromInput(part.input);\n const format = toolFieldFromInput(part.input, 'format');\n toolPartIndexById.set(part.toolCallId, parts.length);\n parts.push({\n type: 'tool',\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(title ? { title } : {}),\n ...(format ? { format } : {}),\n status: 'executing',\n });\n await broadcast('message-tool-call', {\n messageId: aiMessageId,\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(title ? { title } : {}),\n ...(format ? { format } : {}),\n status: 'executing',\n });\n break;\n }\n case 'tool-result':\n case 'tool-error': {\n const failed = part.type === 'tool-error';\n const deferred = isDeferredCompletionTool(part.toolName);\n // Deferred tools (e.g. generate_document) only queue work during the\n // stream — keep the spinner until the pipeline attaches a file.\n const status: 'executing' | 'completed' | 'failed' = failed\n ? 'failed'\n : deferred\n ? 'executing'\n : 'completed';\n const title = toolTitleFromInput(part.input);\n const format = toolFieldFromInput(part.input, 'format');\n const idx = toolPartIndexById.get(part.toolCallId);\n if (idx !== undefined) {\n const existing = parts[idx];\n if (existing && existing.type === 'tool') {\n existing.status = status;\n if (format) existing.format = format;\n }\n }\n toolCalls.push({\n toolName: part.toolName,\n input: part.input,\n output: part.type === 'tool-result' ? part.output : undefined,\n status: failed ? 'failed' : 'completed',\n });\n await broadcast('message-tool-call', {\n messageId: aiMessageId,\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(title ? { title } : {}),\n ...(format ? { format } : {}),\n status,\n });\n break;\n }\n default:\n // ignore reasoning/source/step/finish/raw parts\n break;\n }\n }\n\n return { text: fullText, toolCalls, parts };\n } finally {\n if (redis) {\n await redis.del(streamKey).catch(() => {});\n }\n }\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAmC,MAAM,IAAI,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,gBAAgB,GAAG,GAA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C,KAAK;wBACjB,MAAM,EAAE,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;wBAC7D,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW;qBACxC,CAAC,CAAC;oBACH,MAAM,SAAS,CAAC,mBAAmB,EAAE;wBACnC,SAAS,EAAE,WAAW;wBACtB,UAAU,EAAE,IAAI,CAAC,UAAU;wBAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;wBACvB,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wBAC3B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;wBAC7B,MAAM;qBACP,CAAC,CAAC;oBACH,MAAM;gBACR,CAAC;gBACD;oBACE,gDAAgD;oBAChD,MAAM;YACV,CAAC;QACH,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC9C,CAAC;YAAS,CAAC;QACT,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;AACH,CAAC","debug_id":"5a03c108-e33a-50c7-a5fd-24f570b1b507"}
1
+ {"version":3,"file":"aiChatStream.js","sources":["services/aiChatStream.ts"],"sourceRoot":"/","sourcesContent":["/**\n * Shared AI chat streaming helper.\n *\n * Runs a genuine token-by-token stream via the Vercel AI SDK (`streamText`)\n * against OpenAI — the same provider the rest of the app's inference uses\n * (`OPENAI_API_KEY`). Real text tokens are broadcast over Pusher as they are\n * produced, and real tool calls are broadcast inline (in the order the model\n * invokes them) instead of being derived after the fact from a JSON blob.\n *\n * Callers own persistence: this helper returns the accumulated text and the\n * ordered tool calls so the pipeline can write `content`/`meta` and emit the\n * terminal `message-stream-complete` / `message-updated` events.\n */\nimport { streamText, stepCountIs, type ModelMessage, type ToolSet } from 'ai';\nimport { openai } from '@ai-sdk/openai';\nimport { getRedis } from '../lib/redis.js';\nimport { pusher, chatChannel } from '../lib/pusher.js';\nimport { logger } from '../utils/logger.js';\n\nconst STREAM_REDIS_TTL = 600; // 10 minutes\nconst STREAM_KEY_PREFIX = 'stream:';\n\n/** Default streaming model — matches the existing streamAIResponse path. */\nexport const DEFAULT_STREAM_MODEL = 'gpt-4o-mini';\n\nexport interface StreamedToolCall {\n toolName: string;\n /** Args the model passed to the tool. */\n input: unknown;\n /** Value the tool returned (undefined for client-side / no-result tools). */\n output?: unknown;\n status: 'completed' | 'failed';\n}\n\n/**\n * An ordered fragment of an AI message. The message is a sequence of these\n * parts in the exact order the model produced them, so a tool call rendered\n * \"between paragraph 1 and 2\" is represented as\n * `[{text}, {tool}, {text}]` — enabling true inline rendering (and reload\n * persistence) instead of text and tool calls living in separate buckets.\n */\nexport type StreamPart =\n | { type: 'text'; text: string }\n | {\n type: 'tool';\n toolCallId: string;\n toolName: string;\n /** Concrete entity label (e.g. assignment title / search query), if any. */\n title?: string;\n /** Requested output type from the tool args (pdf, pptx, xlsx, …). */\n format?: string;\n /** Set after generated files are persisted on the message. */\n fileId?: string;\n fileName?: string;\n status: 'executing' | 'completed' | 'failed';\n };\n\nexport interface GeneratedDocFileLink {\n title: string;\n fileId: string;\n fileName: string;\n format?: string;\n}\n\n/** Apply pipeline-resolved formats onto generate_document tool parts. */\nexport function applyResolvedFormatsToStreamParts(\n parts: StreamPart[],\n docs: Array<{ title: string; format: string }>,\n): StreamPart[] {\n if (docs.length === 0) return parts;\n\n const pending = [...docs];\n const takeDoc = (title?: string) => {\n if (title) {\n const idx = pending.findIndex(\n (d) => d.title.trim().toLowerCase() === title.trim().toLowerCase(),\n );\n if (idx >= 0) return pending.splice(idx, 1)[0];\n }\n return pending.shift();\n };\n\n return parts.map((part) => {\n if (part.type !== 'tool' || part.toolName !== 'generate_document') return part;\n const doc = takeDoc(part.title);\n return doc ? { ...part, format: doc.format } : part;\n });\n}\n\n/** Attach file IDs to `generate_document` tool parts for inline download chips. */\nexport function enrichStreamPartsWithGeneratedFiles(\n parts: StreamPart[],\n files: GeneratedDocFileLink[],\n): StreamPart[] {\n if (files.length === 0) return parts;\n\n const docToolIndices = parts\n .map((part, index) => ({ part, index }))\n .filter(\n ({ part }) =>\n part.type === 'tool' && part.toolName === 'generate_document',\n );\n\n const unmatched = [...files];\n const fileForTool = (toolTitle?: string): GeneratedDocFileLink | undefined => {\n if (toolTitle) {\n const idx = unmatched.findIndex(\n (f) => f.title.trim().toLowerCase() === toolTitle.trim().toLowerCase(),\n );\n if (idx >= 0) return unmatched.splice(idx, 1)[0];\n }\n return unmatched.shift();\n };\n\n const fileByIndex = new Map<number, GeneratedDocFileLink>();\n for (const { part, index } of docToolIndices) {\n if (part.type !== 'tool') continue;\n const file = fileForTool(part.title);\n if (file) fileByIndex.set(index, file);\n }\n\n return parts.map((part, index) => {\n const file = fileByIndex.get(index);\n if (!file || part.type !== 'tool') return part;\n return {\n ...part,\n fileId: file.fileId,\n fileName: file.fileName,\n ...(file.format ? { format: file.format } : {}),\n };\n });\n}\n\nfunction toolFieldFromInput(input: unknown, key: string): string | undefined {\n if (input && typeof input === 'object') {\n const val = (input as Record<string, unknown>)[key];\n if (typeof val === 'string' && val.trim()) return val.trim();\n }\n return undefined;\n}\n\n/** Pull a human-meaningful label out of a tool's input args, if present. */\nfunction toolTitleFromInput(input: unknown): string | undefined {\n for (const key of ['title', 'name', 'query'] as const) {\n const val = toolFieldFromInput(input, key);\n if (val) return val;\n }\n return undefined;\n}\n\nexport interface StreamChatOptions {\n conversationId: string;\n aiMessageId: string;\n system: string;\n messages: ModelMessage[];\n tools?: ToolSet;\n model?: string;\n temperature?: number;\n maxOutputTokens?: number;\n /** Max agent steps (tool round-trips). Defaults to 6. */\n maxSteps?: number;\n}\n\nexport interface StreamChatResult {\n text: string;\n toolCalls: StreamedToolCall[];\n /** Ordered text/tool parts, in the exact order the model produced them. */\n parts: StreamPart[];\n}\n\n/**\n * Stream a chat completion, broadcasting real text chunks and tool-call\n * events over Pusher. Does NOT persist the message or emit the terminal\n * stream-complete event — the caller does that once it has assembled the\n * final `content`/`meta` (e.g. PDF attachments, structured proposals).\n */\nexport async function streamChatResponse(\n options: StreamChatOptions,\n): Promise<StreamChatResult> {\n const {\n conversationId,\n aiMessageId,\n system,\n messages,\n tools,\n model = DEFAULT_STREAM_MODEL,\n temperature = 0.7,\n maxOutputTokens = 4096,\n maxSteps = 6,\n } = options;\n\n const redis = getRedis();\n const streamKey = `${STREAM_KEY_PREFIX}${aiMessageId}`;\n if (redis) {\n await redis.set(streamKey, '', 'EX', STREAM_REDIS_TTL);\n }\n\n let fullText = '';\n const parts: StreamPart[] = [];\n const toolCalls: StreamedToolCall[] = [];\n // Map AI SDK toolCallId -> index in `parts` so the executing indicator can\n // be flipped to completed/failed in place (preserving its position).\n const toolPartIndexById = new Map<string, number>();\n\n const appendText = (text: string) => {\n fullText += text;\n const last = parts[parts.length - 1];\n if (last && last.type === 'text') {\n last.text += text;\n } else {\n parts.push({ type: 'text', text });\n }\n };\n\n const broadcast = async (event: string, payload: Record<string, unknown>) => {\n try {\n await pusher.trigger(chatChannel(conversationId), event, payload);\n } catch (err) {\n logger.warn(`Failed to broadcast ${event}`, { err, aiMessageId });\n }\n };\n\n try {\n const result = streamText({\n model: openai(model),\n system,\n messages,\n ...(tools ? { tools } : {}),\n temperature,\n maxOutputTokens,\n stopWhen: stepCountIs(maxSteps),\n });\n\n // `fullStream` yields text deltas AND tool events in a single, correctly\n // ordered sequence — this is what makes inline tool calls possible. We\n // build an ordered `parts` list and broadcast each event as it happens.\n for await (const part of result.fullStream) {\n switch (part.type) {\n case 'text-delta': {\n appendText(part.text);\n if (redis) {\n await redis.append(streamKey, part.text).catch(() => {});\n }\n await broadcast('message-stream-chunk', {\n messageId: aiMessageId,\n chunk: part.text,\n });\n break;\n }\n case 'tool-call': {\n const title = toolTitleFromInput(part.input);\n const format = toolFieldFromInput(part.input, 'format');\n toolPartIndexById.set(part.toolCallId, parts.length);\n parts.push({\n type: 'tool',\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(title ? { title } : {}),\n ...(format ? { format } : {}),\n status: 'executing',\n });\n await broadcast('message-tool-call', {\n messageId: aiMessageId,\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(title ? { title } : {}),\n ...(format ? { format } : {}),\n status: 'executing',\n });\n break;\n }\n case 'tool-result':\n case 'tool-error': {\n const status: 'completed' | 'failed' =\n part.type === 'tool-error' ? 'failed' : 'completed';\n const title = toolTitleFromInput(part.input);\n const format = toolFieldFromInput(part.input, 'format');\n const idx = toolPartIndexById.get(part.toolCallId);\n if (idx !== undefined) {\n const existing = parts[idx];\n if (existing && existing.type === 'tool') {\n existing.status = status;\n if (format) existing.format = format;\n }\n }\n toolCalls.push({\n toolName: part.toolName,\n input: part.input,\n output: part.type === 'tool-result' ? part.output : undefined,\n status,\n });\n await broadcast('message-tool-call', {\n messageId: aiMessageId,\n toolCallId: part.toolCallId,\n toolName: part.toolName,\n ...(title ? { title } : {}),\n ...(format ? { format } : {}),\n status,\n });\n break;\n }\n default:\n // ignore reasoning/source/step/finish/raw parts\n break;\n }\n }\n\n return { text: fullText, toolCalls, parts };\n } finally {\n if (redis) {\n await redis.del(streamKey).catch(() => {});\n }\n }\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAmC,MAAM,IAAI,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,kBAAkB,C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CAAC","debug_id":"8b3ecdb4-6453-5bf3-a9c6-a0b07061c768"}
@@ -1 +1 @@
1
- {"version":3,"file":"aiProposalTools.d.ts","sourceRoot":"/","sources":["services/aiProposalTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,IAAI,CAAC;AAE9C,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACZ,MAAM,mCAAmC,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,IAAI,EAAE,WAAW,EAAE,CAAC;CACrB;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAEjD;AAuDD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAmLjE"}
1
+ {"version":3,"file":"aiProposalTools.d.ts","sourceRoot":"/","sources":["services/aiProposalTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,IAAI,CAAC;AAE9C,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,WAAW,EACZ,MAAM,mCAAmC,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,IAAI,EAAE,WAAW,EAAE,CAAC;CACrB;AAED,wBAAgB,kBAAkB,IAAI,YAAY,CAEjD;AAuDD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAkLjE"}
@@ -16,7 +16,7 @@
16
16
  * typed execute args).
17
17
  */
18
18
 
19
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0c9ff67f-a8a4-5232-b858-905d3275b385")}catch(e){}}();
19
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d31c780d-ad85-5261-92f8-54f6cf38ad3c")}catch(e){}}();
20
20
  import { jsonSchema } from 'ai';
21
21
  import { v4 } from 'uuid';
22
22
  export function createLabProposals() {
@@ -174,11 +174,6 @@ export function labProposalTools(proposals) {
174
174
  inputSchema: jsonSchema({
175
175
  type: 'object',
176
176
  properties: {
177
- title: { type: 'string', description: 'Document title' },
178
- content: {
179
- type: 'string',
180
- description: 'Full body — markdown or plain text with headings, lists, tables, slide notes, etc.',
181
- },
182
177
  format: {
183
178
  type: 'string',
184
179
  description: 'Output file type. REQUIRED. pptx=slides/presentation, xlsx/csv=spreadsheet/data, docx=Word handout, pdf=printable doc, md/txt/html=text, png/jpeg/gif=image, py/js/ts=code.',
@@ -188,6 +183,11 @@ export function labProposalTools(proposals) {
188
183
  'py', 'js', 'ts', 'css', 'sh',
189
184
  ],
190
185
  },
186
+ title: { type: 'string', description: 'Document title' },
187
+ content: {
188
+ type: 'string',
189
+ description: 'Full body — markdown or plain text with headings, lists, tables, slide notes, etc.',
190
+ },
191
191
  },
192
192
  required: ['title', 'content', 'format'],
193
193
  }),
@@ -204,4 +204,4 @@ export function labProposalTools(proposals) {
204
204
  };
205
205
  }
206
206
  //# sourceMappingURL=aiProposalTools.js.map
207
- //# debugId=0c9ff67f-a8a4-5232-b858-905d3275b385
207
+ //# debugId=d31c780d-ad85-5261-92f8-54f6cf38ad3c