@base44-preview/sdk 0.8.5-pr.52.e60528e → 0.8.6-pr.52.c427ddb
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 +23 -10
- package/dist/modules/agents.d.ts +2 -2
- package/dist/modules/agents.js +3 -1
- package/dist/utils/app-params.js +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -30,9 +30,15 @@ export function createClient(config) {
|
|
|
30
30
|
appId,
|
|
31
31
|
token,
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
let socket = null;
|
|
34
|
+
const getSocket = () => {
|
|
35
|
+
if (!socket) {
|
|
36
|
+
socket = RoomsSocket({
|
|
37
|
+
config: socketConfig,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return socket;
|
|
41
|
+
};
|
|
36
42
|
const headers = {
|
|
37
43
|
...optionalHeaders,
|
|
38
44
|
"X-App-Id": String(appId),
|
|
@@ -78,7 +84,7 @@ export function createClient(config) {
|
|
|
78
84
|
functions: createFunctionsModule(functionsAxiosClient, appId),
|
|
79
85
|
agents: createAgentsModule({
|
|
80
86
|
axios: axiosClient,
|
|
81
|
-
|
|
87
|
+
getSocket,
|
|
82
88
|
appId,
|
|
83
89
|
serverUrl,
|
|
84
90
|
token,
|
|
@@ -86,7 +92,9 @@ export function createClient(config) {
|
|
|
86
92
|
appLogs: createAppLogsModule(axiosClient, appId),
|
|
87
93
|
users: createUsersModule(axiosClient, appId),
|
|
88
94
|
cleanup: () => {
|
|
89
|
-
socket
|
|
95
|
+
if (socket) {
|
|
96
|
+
socket.disconnect();
|
|
97
|
+
}
|
|
90
98
|
},
|
|
91
99
|
};
|
|
92
100
|
const serviceRoleModules = {
|
|
@@ -97,14 +105,16 @@ export function createClient(config) {
|
|
|
97
105
|
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId),
|
|
98
106
|
agents: createAgentsModule({
|
|
99
107
|
axios: serviceRoleAxiosClient,
|
|
100
|
-
|
|
108
|
+
getSocket,
|
|
101
109
|
appId,
|
|
102
110
|
serverUrl,
|
|
103
111
|
token,
|
|
104
112
|
}),
|
|
105
113
|
appLogs: createAppLogsModule(serviceRoleAxiosClient, appId),
|
|
106
114
|
cleanup: () => {
|
|
107
|
-
socket
|
|
115
|
+
if (socket) {
|
|
116
|
+
socket.disconnect();
|
|
117
|
+
}
|
|
108
118
|
},
|
|
109
119
|
};
|
|
110
120
|
// Always try to get token from localStorage or URL parameters
|
|
@@ -140,9 +150,12 @@ export function createClient(config) {
|
|
|
140
150
|
*/
|
|
141
151
|
setToken(newToken) {
|
|
142
152
|
userModules.auth.setToken(newToken);
|
|
143
|
-
socket
|
|
144
|
-
|
|
145
|
-
|
|
153
|
+
if (socket) {
|
|
154
|
+
socket.updateConfig({
|
|
155
|
+
token: newToken,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
socketConfig.token = newToken;
|
|
146
159
|
},
|
|
147
160
|
/**
|
|
148
161
|
* Get current configuration
|
package/dist/modules/agents.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { AxiosInstance } from "axios";
|
|
|
4
4
|
import { ModelFilterParams } from "../types.js";
|
|
5
5
|
export type AgentsModuleConfig = {
|
|
6
6
|
axios: AxiosInstance;
|
|
7
|
-
|
|
7
|
+
getSocket: () => ReturnType<typeof RoomsSocket>;
|
|
8
8
|
appId: string;
|
|
9
9
|
serverUrl?: string;
|
|
10
10
|
token?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare function createAgentsModule({ axios,
|
|
12
|
+
export declare function createAgentsModule({ axios, getSocket, appId, serverUrl, token, }: AgentsModuleConfig): {
|
|
13
13
|
getConversations: () => Promise<AgentConversation[]>;
|
|
14
14
|
getConversation: (conversationId: string) => Promise<AgentConversation | undefined>;
|
|
15
15
|
listConversations: (filterParams: ModelFilterParams) => Promise<AgentConversation[]>;
|
package/dist/modules/agents.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getAccessToken } from "../utils/auth-utils.js";
|
|
2
|
-
export function createAgentsModule({ axios,
|
|
2
|
+
export function createAgentsModule({ axios, getSocket, appId, serverUrl, token, }) {
|
|
3
3
|
const baseURL = `/apps/${appId}/agents`;
|
|
4
4
|
const getConversations = () => {
|
|
5
5
|
return axios.get(`${baseURL}/conversations`);
|
|
@@ -17,6 +17,7 @@ export function createAgentsModule({ axios, socket, appId, serverUrl, token, })
|
|
|
17
17
|
};
|
|
18
18
|
const addMessage = async (conversation, message) => {
|
|
19
19
|
const room = `/agent-conversations/${conversation.id}`;
|
|
20
|
+
const socket = getSocket();
|
|
20
21
|
await socket.updateModel(room, {
|
|
21
22
|
...conversation,
|
|
22
23
|
messages: [...(conversation.messages || []), message],
|
|
@@ -25,6 +26,7 @@ export function createAgentsModule({ axios, socket, appId, serverUrl, token, })
|
|
|
25
26
|
};
|
|
26
27
|
const subscribeToConversation = (conversationId, onUpdate) => {
|
|
27
28
|
const room = `/agent-conversations/${conversationId}`;
|
|
29
|
+
const socket = getSocket();
|
|
28
30
|
return socket.subscribeToRoom(room, {
|
|
29
31
|
connect: () => { },
|
|
30
32
|
update_model: ({ data: jsonStr }) => {
|
package/dist/utils/app-params.js
CHANGED
|
@@ -34,7 +34,7 @@ const getAppParams = () => {
|
|
|
34
34
|
localStorage.removeItem('token');
|
|
35
35
|
}
|
|
36
36
|
return {
|
|
37
|
-
appId: getAppParamValue("app_id"
|
|
37
|
+
appId: getAppParamValue("app_id"),
|
|
38
38
|
token: getAppParamValue("access_token", { removeFromUrl: true }),
|
|
39
39
|
fromUrl: getAppParamValue("from_url", { defaultValue: window.location.href }),
|
|
40
40
|
functionsVersion: getAppParamValue("functions_version", { defaultValue: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION }),
|