vzcode 1.33.0 → 1.35.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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Validates incoming request data for AI chat messages
3
+ */
4
+ export const validateRequest = (req, res) => {
5
+ const { content, chatId } = req.body;
6
+
7
+ if (!content || typeof content !== 'string') {
8
+ res.status(400).json({
9
+ error:
10
+ 'Invalid request: content is required and must be a string',
11
+ });
12
+ return false;
13
+ }
14
+
15
+ if (!chatId || typeof chatId !== 'string') {
16
+ res.status(400).json({
17
+ error:
18
+ 'Invalid request: chatId is required and must be a string',
19
+ });
20
+ return false;
21
+ }
22
+
23
+ return true;
24
+ };
@@ -0,0 +1,2 @@
1
+ // Re-export the refactored handleAIChatMessage from the new modular structure
2
+ export { handleAIChatMessage } from './aiChatHandler/index.js';
@@ -14,6 +14,7 @@ import { json1Presence } from '../ot.js';
14
14
  import { computeInitialDocument } from './computeInitialDocument.js';
15
15
  import { handleAIAssist } from './handleAIAssist.js';
16
16
  import { handleAICopilot } from './handleAICopilot.js';
17
+ import { handleAIChatMessage } from './handleAIChatMessage.js';
17
18
  import { isDirectory } from './isDirectory.js';
18
19
  import { createToken } from './livekit.js';
19
20
  import './setupEnv.js';
@@ -112,6 +113,13 @@ app.post(
112
113
  handleAICopilot(),
113
114
  );
114
115
 
116
+ // Handle AI Chat Message requests.
117
+ app.post(
118
+ '/ai-chat-message',
119
+ bodyParser.json(),
120
+ handleAIChatMessage(shareDBDoc),
121
+ );
122
+
115
123
  // Livekit Token Generator
116
124
  app.get('/livekit-token', async (req, res) => {
117
125
  const { room, username } = req.query;