@base44-preview/sdk 0.8.13-pr.72.b37eb76 → 0.8.16-pr.71.1ba8bae

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.
@@ -16,22 +16,39 @@ export function createAgentsModule({ axios, getSocket, appId, serverUrl, token,
16
16
  return axios.post(`${baseURL}/conversations`, conversation);
17
17
  };
18
18
  const addMessage = async (conversation, message) => {
19
- const room = `/agent-conversations/${conversation.id}`;
20
- const socket = getSocket();
21
- await socket.updateModel(room, {
22
- ...conversation,
23
- messages: [...(conversation.messages || []), message],
24
- });
25
- return axios.post(`${baseURL}/conversations/${conversation.id}/messages`, message);
19
+ return axios.post(`${baseURL}/conversations/${conversation.id}/messages`, { ...message, api_version: "v2" });
26
20
  };
27
21
  const subscribeToConversation = (conversationId, onUpdate) => {
28
22
  const room = `/agent-conversations/${conversationId}`;
29
23
  const socket = getSocket();
24
+ // Store the promise for initial conversation state
25
+ let currentConversation;
26
+ const conversationPromise = getConversation(conversationId).then((conv) => {
27
+ currentConversation = conv;
28
+ return conv;
29
+ });
30
30
  return socket.subscribeToRoom(room, {
31
31
  connect: () => { },
32
- update_model: ({ data: jsonStr }) => {
33
- const conv = JSON.parse(jsonStr);
34
- onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(conv);
32
+ update_model: async ({ data: jsonStr }) => {
33
+ const data = JSON.parse(jsonStr);
34
+ if (data._message) {
35
+ // Wait for initial conversation to be loaded
36
+ await conversationPromise;
37
+ const message = data._message;
38
+ // Update local conversation state
39
+ if (currentConversation) {
40
+ const messages = currentConversation.messages || [];
41
+ const existingIndex = messages.findIndex((m) => m.id === message.id);
42
+ const updatedMessages = existingIndex !== -1
43
+ ? messages.map((m, i) => (i === existingIndex ? message : m))
44
+ : [...messages, message];
45
+ currentConversation = {
46
+ ...currentConversation,
47
+ messages: updatedMessages,
48
+ };
49
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(currentConversation);
50
+ }
51
+ }
35
52
  },
36
53
  });
37
54
  };
@@ -6,8 +6,8 @@ export const ANALYTICS_SESSION_DURATION_EVENT_NAME = "__session_duration_event__
6
6
  export const ANALYTICS_CONFIG_ENABLE_URL_PARAM_KEY = "analytics-enable";
7
7
  export const ANALYTICS_SESSION_ID_LOCAL_STORAGE_KEY = "base44_analytics_session_id";
8
8
  const defaultConfiguration = {
9
- // default to enabled //
10
- enabled: true,
9
+ // default to disabled //
10
+ enabled: false,
11
11
  maxQueueSize: 1000,
12
12
  throttleTime: 1000,
13
13
  batchSize: 30,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.13-pr.72.b37eb76",
3
+ "version": "0.8.16-pr.71.1ba8bae",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",