vzcode 1.35.0 → 1.37.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.
package/dist/index.html CHANGED
@@ -20,7 +20,7 @@
20
20
  href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
21
21
  rel="stylesheet"
22
22
  />
23
- <script type="module" crossorigin src="/assets/index-ajiBaTmx.js"></script>
23
+ <script type="module" crossorigin src="/assets/index-BRU-VQpy.js"></script>
24
24
  <link rel="stylesheet" crossorigin href="/assets/index-lvLw6dCW.css">
25
25
  </head>
26
26
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "1.35.0",
3
+ "version": "1.37.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -117,6 +117,8 @@ function App() {
117
117
  setLiveKitToken={setLiveKitToken}
118
118
  liveKitConnection={liveKitConnection}
119
119
  setLiveKitConnection={setLiveKitConnection}
120
+ aiChatEndpoint="/ai-chat-message"
121
+ aiChatOptions={{}}
120
122
  >
121
123
  <LiveKitRoom
122
124
  audio={true}
@@ -118,6 +118,8 @@ export type VZCodeContextValue = {
118
118
  setIsAIChatOpen: (isAIChatOpen: boolean) => void;
119
119
  aiChatFocused: boolean;
120
120
  toggleAIChatFocused: () => void;
121
+ aiChatEndpoint?: string;
122
+ aiChatOptions?: { [key: string]: any };
121
123
  setSearchResults: (files: ShareDBDoc<VizContent>) => void;
122
124
  setSearchFileVisibility: (
123
125
  files: ShareDBDoc<VizContent>,
@@ -198,6 +200,8 @@ export const VZCodeProvider = ({
198
200
  setLiveKitRoom,
199
201
  liveKitConnection,
200
202
  setLiveKitConnection,
203
+ aiChatEndpoint,
204
+ aiChatOptions,
201
205
  }: {
202
206
  content: VizContent;
203
207
  shareDBDoc: ShareDBDoc<VizContent>;
@@ -216,6 +220,8 @@ export const VZCodeProvider = ({
216
220
  setLiveKitRoom?: (state: string) => void;
217
221
  liveKitConnection?: boolean;
218
222
  setLiveKitConnection?: (state: boolean) => void;
223
+ aiChatEndpoint?: string;
224
+ aiChatOptions?: { [key: string]: any };
219
225
  }) => {
220
226
  // Auto-run Pretter after local changes.
221
227
  const { prettierError, runPrettierRef } = usePrettier({
@@ -450,6 +456,8 @@ export const VZCodeProvider = ({
450
456
  setIsAIChatOpen,
451
457
  aiChatFocused,
452
458
  toggleAIChatFocused,
459
+ aiChatEndpoint,
460
+ aiChatOptions,
453
461
 
454
462
  isSettingsOpen,
455
463
  setIsSettingsOpen,
@@ -89,6 +89,8 @@ export const VZMiddle = ({
89
89
  aiAssistTooltipText,
90
90
  aiAssistClickOverride,
91
91
  aiCopilotEndpoint,
92
+ aiChatEndpoint,
93
+ aiChatOptions,
92
94
  customInteractRules,
93
95
  esLintSource,
94
96
  }: {
@@ -98,6 +100,8 @@ export const VZMiddle = ({
98
100
  aiAssistTooltipText?: string;
99
101
  aiAssistClickOverride?: () => void;
100
102
  aiCopilotEndpoint?: string;
103
+ aiChatEndpoint?: string;
104
+ aiChatOptions?: { [key: string]: any };
101
105
  customInteractRules?: Array<InteractRule>;
102
106
  esLintSource: (
103
107
  view: EditorView,
@@ -5,20 +5,32 @@ import { MessageList } from './MessageList';
5
5
  import { ChatInput } from './ChatInput';
6
6
  import './styles.scss';
7
7
 
8
+ const defaultAIChatEndpoint = '/ai-chat-message';
9
+
8
10
  export const AIChat = () => {
9
11
  const [message, setMessage] = useState('');
10
12
  const [isLoading, setIsLoading] = useState(false);
11
13
  const [currentChatId] = useState(() => uuidv4());
12
14
 
13
- const { aiChatFocused, content } =
14
- useContext(VZCodeContext);
15
+ const {
16
+ aiChatFocused,
17
+ content,
18
+ aiChatEndpoint = defaultAIChatEndpoint,
19
+ aiChatOptions = {},
20
+ } = useContext(VZCodeContext);
15
21
 
16
22
  // Get current chat data from content
17
23
  const currentChat = content?.chats?.[currentChatId];
18
- const messages = currentChat?.messages || [];
24
+ const rawMessages = currentChat?.messages || [];
19
25
  const aiScratchpad = currentChat?.aiScratchpad;
20
26
  const aiStatus = currentChat?.aiStatus;
21
27
 
28
+ // Transform messages to ensure they have required id field
29
+ const messages = rawMessages.map((msg, index) => ({
30
+ ...msg,
31
+ id: msg.id || `msg-${index}`,
32
+ }));
33
+
22
34
  const handleSendMessage = useCallback(async () => {
23
35
  if (!message.trim() || isLoading) return;
24
36
 
@@ -28,12 +40,13 @@ export const AIChat = () => {
28
40
  // Call backend endpoint for AI response
29
41
  // The server will handle all ShareDB operations including adding the user message
30
42
  try {
31
- const response = await fetch('/ai-chat-message', {
43
+ const response = await fetch(aiChatEndpoint, {
32
44
  method: 'POST',
33
45
  headers: {
34
46
  'Content-Type': 'application/json',
35
47
  },
36
48
  body: JSON.stringify({
49
+ ...aiChatOptions,
37
50
  content: message.trim(),
38
51
  chatId: currentChatId,
39
52
  }),
@@ -15,7 +15,7 @@ export const createLLMFunction = (shareDBDoc, chatId) => {
15
15
  const chatModel = new ChatOpenAI({
16
16
  modelName:
17
17
  process.env.VIZHUB_EDIT_WITH_AI_MODEL_NAME ||
18
- 'gpt-4o-mini',
18
+ 'anthropic/claude-sonnet-4',
19
19
  configuration: {
20
20
  apiKey: process.env.VIZHUB_EDIT_WITH_AI_API_KEY,
21
21
  baseURL: process.env.VIZHUB_EDIT_WITH_AI_BASE_URL,