@base44-preview/sdk 0.8.13-pr.72.b37eb76 → 0.8.16-pr.71.6dfec93

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.
@@ -22,16 +22,46 @@ export function createAgentsModule({ axios, getSocket, appId, serverUrl, token,
22
22
  ...conversation,
23
23
  messages: [...(conversation.messages || []), message],
24
24
  });
25
- return axios.post(`${baseURL}/conversations/${conversation.id}/messages`, message);
25
+ return axios.post(`${baseURL}/conversations/${conversation.id}/messages`, { ...message, api_version: "v2" });
26
26
  };
27
27
  const subscribeToConversation = (conversationId, onUpdate) => {
28
28
  const room = `/agent-conversations/${conversationId}`;
29
29
  const socket = getSocket();
30
+ // Store the promise for initial conversation state
31
+ let currentConversation;
32
+ const conversationPromise = getConversation(conversationId).then((conv) => {
33
+ currentConversation = conv;
34
+ return conv;
35
+ });
30
36
  return socket.subscribeToRoom(room, {
31
37
  connect: () => { },
32
- update_model: ({ data: jsonStr }) => {
33
- const conv = JSON.parse(jsonStr);
34
- onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(conv);
38
+ update_model: async ({ data: jsonStr }) => {
39
+ const data = JSON.parse(jsonStr);
40
+ // Check if this is v2 format with _agent_message
41
+ if (data._agent_message) {
42
+ // Wait for initial conversation to be loaded
43
+ await conversationPromise;
44
+ const message = data._agent_message;
45
+ // Update local conversation state
46
+ if (currentConversation) {
47
+ const messages = currentConversation.messages || [];
48
+ const existingIndex = messages.findIndex((m) => m.id === message.id);
49
+ const updatedMessages = existingIndex !== -1
50
+ ? messages.map((m, i) => (i === existingIndex ? message : m))
51
+ : [...messages, message];
52
+ currentConversation = {
53
+ ...currentConversation,
54
+ messages: updatedMessages,
55
+ };
56
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(currentConversation);
57
+ }
58
+ }
59
+ else {
60
+ // Old format: full conversation object
61
+ const conv = data;
62
+ currentConversation = conv;
63
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(conv);
64
+ }
35
65
  },
36
66
  });
37
67
  };
@@ -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.6dfec93",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",