@base44-preview/sdk 0.8.13-pr.63.6dc705a → 0.8.13-pr.71.692df4a
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/client.js +1 -8
- package/dist/client.types.d.ts +0 -5
- package/dist/modules/agents.js +29 -4
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -47,11 +47,7 @@ import { createAnalyticsModule } from "./modules/analytics.js";
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
export function createClient(config) {
|
|
50
|
-
const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, appBaseUrl, options, functionsVersion, headers: optionalHeaders,
|
|
51
|
-
// Config takes precedence, fallback to URL query param in browser
|
|
52
|
-
const urlHasStagingDb = typeof window !== "undefined"
|
|
53
|
-
&& new URLSearchParams(window.location.search).get("use_staging_db") === "true";
|
|
54
|
-
const useStagingDb = configUseStagingDb !== null && configUseStagingDb !== void 0 ? configUseStagingDb : urlHasStagingDb;
|
|
50
|
+
const { serverUrl = "https://base44.app", appId, token, serviceToken, requiresAuth = false, appBaseUrl, options, functionsVersion, headers: optionalHeaders, } = config;
|
|
55
51
|
const socketConfig = {
|
|
56
52
|
serverUrl,
|
|
57
53
|
mountPath: "/ws-user-apps/socket.io/",
|
|
@@ -71,7 +67,6 @@ export function createClient(config) {
|
|
|
71
67
|
const headers = {
|
|
72
68
|
...optionalHeaders,
|
|
73
69
|
"X-App-Id": String(appId),
|
|
74
|
-
"Base44-Use-Staging-DB": String(useStagingDb),
|
|
75
70
|
};
|
|
76
71
|
const functionHeaders = functionsVersion
|
|
77
72
|
? {
|
|
@@ -304,7 +299,6 @@ export function createClientFromRequest(request) {
|
|
|
304
299
|
const appId = request.headers.get("Base44-App-Id");
|
|
305
300
|
const serverUrlHeader = request.headers.get("Base44-Api-Url");
|
|
306
301
|
const functionsVersion = request.headers.get("Base44-Functions-Version");
|
|
307
|
-
const useStagingDb = request.headers.get("Base44-Use-Staging-DB") === "true";
|
|
308
302
|
const stateHeader = request.headers.get("Base44-State");
|
|
309
303
|
if (!appId) {
|
|
310
304
|
throw new Error("Base44-App-Id header is required, but is was not found on the request");
|
|
@@ -339,7 +333,6 @@ export function createClientFromRequest(request) {
|
|
|
339
333
|
token: userToken,
|
|
340
334
|
serviceToken: serviceRoleToken,
|
|
341
335
|
functionsVersion: functionsVersion !== null && functionsVersion !== void 0 ? functionsVersion : undefined,
|
|
342
|
-
useStagingDb: useStagingDb !== null && useStagingDb !== void 0 ? useStagingDb : undefined,
|
|
343
336
|
headers: additionalHeaders,
|
|
344
337
|
});
|
|
345
338
|
}
|
package/dist/client.types.d.ts
CHANGED
|
@@ -60,11 +60,6 @@ export interface CreateClientConfig {
|
|
|
60
60
|
* @internal
|
|
61
61
|
*/
|
|
62
62
|
headers?: Record<string, string>;
|
|
63
|
-
/**
|
|
64
|
-
* Whether to use the staging database. Defaults to false.
|
|
65
|
-
* When true, API requests will use the staging database instead of production.
|
|
66
|
-
*/
|
|
67
|
-
useStagingDb?: boolean;
|
|
68
63
|
/**
|
|
69
64
|
* Additional client options.
|
|
70
65
|
*/
|
package/dist/modules/agents.js
CHANGED
|
@@ -22,16 +22,41 @@ 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
|
|
34
|
-
|
|
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
|
+
currentConversation = {
|
|
48
|
+
...currentConversation,
|
|
49
|
+
messages: [...(currentConversation.messages || []), message],
|
|
50
|
+
};
|
|
51
|
+
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(currentConversation);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// Old format: full conversation object
|
|
56
|
+
const conv = data;
|
|
57
|
+
currentConversation = conv;
|
|
58
|
+
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(conv);
|
|
59
|
+
}
|
|
35
60
|
},
|
|
36
61
|
});
|
|
37
62
|
};
|