@base44-preview/sdk 0.8.5-pr.52.e60528e → 0.8.6-pr.48.d625f02

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.
Files changed (52) hide show
  1. package/dist/client.d.ts +90 -237
  2. package/dist/client.js +141 -25
  3. package/dist/client.types.d.ts +131 -0
  4. package/dist/client.types.js +1 -0
  5. package/dist/index.d.ts +13 -5
  6. package/dist/index.js +2 -3
  7. package/dist/modules/agents.d.ts +2 -23
  8. package/dist/modules/agents.js +3 -1
  9. package/dist/modules/agents.types.d.ts +330 -34
  10. package/dist/modules/app-logs.d.ts +8 -24
  11. package/dist/modules/app-logs.js +9 -19
  12. package/dist/modules/app-logs.types.d.ts +44 -0
  13. package/dist/modules/app-logs.types.js +1 -0
  14. package/dist/modules/app.types.d.ts +27 -0
  15. package/dist/modules/auth.d.ts +10 -78
  16. package/dist/modules/auth.js +24 -42
  17. package/dist/modules/auth.types.d.ts +436 -0
  18. package/dist/modules/auth.types.js +1 -0
  19. package/dist/modules/connectors.d.ts +6 -11
  20. package/dist/modules/connectors.js +6 -7
  21. package/dist/modules/connectors.types.d.ts +68 -2
  22. package/dist/modules/entities.d.ts +8 -5
  23. package/dist/modules/entities.js +22 -62
  24. package/dist/modules/entities.types.d.ts +293 -0
  25. package/dist/modules/entities.types.js +1 -0
  26. package/dist/modules/functions.d.ts +8 -7
  27. package/dist/modules/functions.js +7 -5
  28. package/dist/modules/functions.types.d.ts +50 -0
  29. package/dist/modules/functions.types.js +1 -0
  30. package/dist/modules/integrations.d.ts +8 -5
  31. package/dist/modules/integrations.js +7 -5
  32. package/dist/modules/integrations.types.d.ts +352 -0
  33. package/dist/modules/integrations.types.js +1 -0
  34. package/dist/modules/sso.d.ts +9 -14
  35. package/dist/modules/sso.js +9 -12
  36. package/dist/modules/sso.types.d.ts +44 -0
  37. package/dist/modules/sso.types.js +1 -0
  38. package/dist/types.d.ts +65 -2
  39. package/dist/utils/auth-utils.d.ts +107 -45
  40. package/dist/utils/auth-utils.js +107 -33
  41. package/dist/utils/auth-utils.types.d.ts +146 -0
  42. package/dist/utils/auth-utils.types.js +1 -0
  43. package/dist/utils/axios-client.d.ts +84 -16
  44. package/dist/utils/axios-client.js +74 -13
  45. package/dist/utils/axios-client.types.d.ts +28 -0
  46. package/dist/utils/axios-client.types.js +1 -0
  47. package/dist/utils/common.d.ts +0 -1
  48. package/dist/utils/common.js +1 -2
  49. package/dist/utils/socket-utils.d.ts +2 -2
  50. package/package.json +12 -3
  51. package/dist/utils/app-params.d.ts +0 -11
  52. package/dist/utils/app-params.js +0 -43
@@ -0,0 +1,131 @@
1
+ import type { EntitiesModule } from "./modules/entities.types.js";
2
+ import type { IntegrationsModule } from "./modules/integrations.types.js";
3
+ import type { AuthModule } from "./modules/auth.types.js";
4
+ import type { SsoModule } from "./modules/sso.types.js";
5
+ import type { ConnectorsModule } from "./modules/connectors.types.js";
6
+ import type { FunctionsModule } from "./modules/functions.types.js";
7
+ import type { AgentsModule } from "./modules/agents.types.js";
8
+ import type { AppLogsModule } from "./modules/app-logs.types.js";
9
+ /**
10
+ * Options for creating a Base44 client.
11
+ */
12
+ export interface CreateClientOptions {
13
+ /**
14
+ * Optional error handler that will be called whenever an API error occurs.
15
+ */
16
+ onError?: (error: Error) => void;
17
+ }
18
+ /**
19
+ * Configuration for creating a Base44 client.
20
+ */
21
+ export interface CreateClientConfig {
22
+ /**
23
+ * The Base44 server URL. Defaults to "https://base44.app".
24
+ * @internal
25
+ */
26
+ serverUrl?: string;
27
+ /**
28
+ * The base URL of the app, which is used for login redirects.
29
+ * @internal
30
+ */
31
+ appBaseUrl?: string;
32
+ /**
33
+ * The Base44 app ID.
34
+ *
35
+ * You can find the `appId` in the browser URL when you're in the app editor.
36
+ * It's the string between `/apps/` and `/editor/`.
37
+ */
38
+ appId: string;
39
+ /**
40
+ * User authentication token. Used to authenticate as a specific user.
41
+ */
42
+ token?: string;
43
+ /**
44
+ * Service role authentication token. Use this in the backend when you need elevated permissions to access data available to the app's admin or perform admin operations. This token should be kept secret and never exposed in the app's frontend. Typically, you get this token from a request to a backend function using {@linkcode createClientFromRequest | createClientFromRequest()}.
45
+ */
46
+ serviceToken?: string;
47
+ /**
48
+ * Whether authentication is required. If true, redirects to login if not authenticated.
49
+ * @internal
50
+ */
51
+ requiresAuth?: boolean;
52
+ /**
53
+ * Version string for functions API.
54
+ * @internal
55
+ */
56
+ functionsVersion?: string;
57
+ /**
58
+ * Additional headers to include in API requests.
59
+ * @internal
60
+ */
61
+ headers?: Record<string, string>;
62
+ /**
63
+ * Additional client options.
64
+ */
65
+ options?: CreateClientOptions;
66
+ }
67
+ /**
68
+ * The Base44 client instance.
69
+ *
70
+ * Provides access to all SDK modules for interacting with the app.
71
+ */
72
+ export interface Base44Client {
73
+ /** {@link EntitiesModule | Entities module} for CRUD operations on your data models. */
74
+ entities: EntitiesModule;
75
+ /** {@link IntegrationsModule | Integrations module} for calling pre-built integration endpoints. */
76
+ integrations: IntegrationsModule;
77
+ /** {@link AuthModule | Auth module} for user authentication and management. */
78
+ auth: AuthModule;
79
+ /** {@link FunctionsModule | Functions module} for invoking custom backend functions. */
80
+ functions: FunctionsModule;
81
+ /** {@link AgentsModule | Agents module} for managing AI agent conversations. */
82
+ agents: AgentsModule;
83
+ /** {@link AppLogsModule | App logs module} for tracking app usage. */
84
+ appLogs: AppLogsModule;
85
+ /** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
86
+ cleanup: () => void;
87
+ /**
88
+ * Sets a new authentication token for all subsequent requests.
89
+ *
90
+ * Updates the token for both HTTP requests and WebSocket connections.
91
+ *
92
+ * @param newToken - The new authentication token.
93
+ */
94
+ setToken(newToken: string): void;
95
+ /**
96
+ * Gets the current client configuration.
97
+ * @internal
98
+ */
99
+ getConfig(): {
100
+ serverUrl: string;
101
+ appId: string;
102
+ requiresAuth: boolean;
103
+ };
104
+ /**
105
+ * Provides access to supported modules with elevated permissions.
106
+ *
107
+ * Service role authentication provides elevated permissions for backend operations. Unlike user authentication, which is scoped to a specific user's permissions, service role authentication has access to the data and operations available to the app's admin.
108
+ *
109
+ * @throws {Error} When accessed without providing a serviceToken during client creation
110
+ */
111
+ readonly asServiceRole: {
112
+ /** {@link EntitiesModule | Entities module} with elevated permissions. */
113
+ entities: EntitiesModule;
114
+ /** {@link IntegrationsModule | Integrations module} with elevated permissions. */
115
+ integrations: IntegrationsModule;
116
+ /** {@link SsoModule | SSO module} for generating SSO tokens.
117
+ * @internal
118
+ */
119
+ sso: SsoModule;
120
+ /** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */
121
+ connectors: ConnectorsModule;
122
+ /** {@link FunctionsModule | Functions module} with elevated permissions. */
123
+ functions: FunctionsModule;
124
+ /** {@link AgentsModule | Agents module} with elevated permissions. */
125
+ agents: AgentsModule;
126
+ /** {@link AppLogsModule | App logs module} with elevated permissions. */
127
+ appLogs: AppLogsModule;
128
+ /** Cleanup function to disconnect WebSocket connections. */
129
+ cleanup: () => void;
130
+ };
131
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,7 +1,15 @@
1
- import { createClient, createClientFromRequest, type Base44Client } from "./client.js";
2
- import { Base44Error } from "./utils/axios-client.js";
1
+ import { createClient, createClientFromRequest, type Base44Client, type CreateClientConfig, type CreateClientOptions } from "./client.js";
2
+ import { Base44Error, type Base44ErrorJSON } from "./utils/axios-client.js";
3
3
  import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from "./utils/auth-utils.js";
4
- import { appParams } from "./utils/app-params.js";
5
- export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, appParams };
6
- export type { Base44Client };
4
+ export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
5
+ export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
7
6
  export * from "./types.js";
7
+ export type { EntitiesModule, EntityHandler, } from "./modules/entities.types.js";
8
+ export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
9
+ export type { IntegrationsModule, IntegrationPackage, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
10
+ export type { FunctionsModule } from "./modules/functions.types.js";
11
+ export type { AgentsModule, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
12
+ export type { AppLogsModule } from "./modules/app-logs.types.js";
13
+ export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
14
+ export type { ConnectorsModule } from "./modules/connectors.types.js";
15
+ export type { GetAccessTokenOptions, SaveAccessTokenOptions, RemoveAccessTokenOptions, GetLoginUrlOptions, } from "./utils/auth-utils.types.js";
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
- import { createClient, createClientFromRequest } from "./client.js";
1
+ import { createClient, createClientFromRequest, } from "./client.js";
2
2
  import { Base44Error } from "./utils/axios-client.js";
3
3
  import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, } from "./utils/auth-utils.js";
4
- import { appParams } from "./utils/app-params.js";
5
- export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, appParams };
4
+ export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
6
5
  export * from "./types.js";
@@ -1,23 +1,2 @@
1
- import { RoomsSocket } from "../utils/socket-utils.js";
2
- import { AgentConversation, AgentMessage } from "./agents.types.js";
3
- import { AxiosInstance } from "axios";
4
- import { ModelFilterParams } from "../types.js";
5
- export type AgentsModuleConfig = {
6
- axios: AxiosInstance;
7
- socket: ReturnType<typeof RoomsSocket>;
8
- appId: string;
9
- serverUrl?: string;
10
- token?: string;
11
- };
12
- export declare function createAgentsModule({ axios, socket, appId, serverUrl, token, }: AgentsModuleConfig): {
13
- getConversations: () => Promise<AgentConversation[]>;
14
- getConversation: (conversationId: string) => Promise<AgentConversation | undefined>;
15
- listConversations: (filterParams: ModelFilterParams) => Promise<AgentConversation[]>;
16
- createConversation: (conversation: {
17
- agent_name: string;
18
- metadata?: Record<string, any>;
19
- }) => Promise<AgentConversation>;
20
- addMessage: (conversation: AgentConversation, message: AgentMessage) => Promise<AgentMessage>;
21
- subscribeToConversation: (conversationId: string, onUpdate?: (conversation: AgentConversation) => void) => () => void;
22
- getWhatsAppConnectURL: (agentName: string) => string;
23
- };
1
+ import { AgentsModule, AgentsModuleConfig } from "./agents.types.js";
2
+ export declare function createAgentsModule({ axios, getSocket, appId, serverUrl, token, }: AgentsModuleConfig): AgentsModule;
@@ -1,5 +1,5 @@
1
1
  import { getAccessToken } from "../utils/auth-utils.js";
2
- export function createAgentsModule({ axios, socket, appId, serverUrl, token, }) {
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 }) => {
@@ -1,44 +1,340 @@
1
- export type AgentConversation = {
1
+ import { AxiosInstance } from "axios";
2
+ import { RoomsSocket } from "../utils/socket-utils";
3
+ import { ModelFilterParams } from "../types";
4
+ /**
5
+ * Reasoning information for an agent message.
6
+ *
7
+ * Contains details about the agent's reasoning process when generating a response.
8
+ */
9
+ export interface AgentMessageReasoning {
10
+ /** When reasoning started. */
11
+ start_date: string;
12
+ /** When reasoning ended. */
13
+ end_date?: string;
14
+ /** Reasoning content. */
15
+ content: string;
16
+ }
17
+ /**
18
+ * A tool call made by the agent.
19
+ *
20
+ * Represents a function or tool that the agent invoked during message generation.
21
+ */
22
+ export interface AgentMessageToolCall {
23
+ /** Tool call ID. */
2
24
  id: string;
25
+ /** Name of the tool called. */
26
+ name: string;
27
+ /** Arguments passed to the tool as JSON string. */
28
+ arguments_string: string;
29
+ /** Status of the tool call. */
30
+ status: "running" | "success" | "error" | "stopped";
31
+ /** Results from the tool call. */
32
+ results?: string;
33
+ }
34
+ /**
35
+ * Token usage statistics for an agent message.
36
+ *
37
+ * Tracks the number of tokens consumed when generating the message.
38
+ */
39
+ export interface AgentMessageUsage {
40
+ /** Number of tokens in the prompt. */
41
+ prompt_tokens?: number;
42
+ /** Number of tokens in the completion. */
43
+ completion_tokens?: number;
44
+ }
45
+ /**
46
+ * Custom context provided with an agent message.
47
+ *
48
+ * Additional contextual information that can be passed to the agent.
49
+ */
50
+ export interface AgentMessageCustomContext {
51
+ /** Context message. */
52
+ message: string;
53
+ /** Associated data for the context. */
54
+ data: Record<string, any>;
55
+ /** Type of context. */
56
+ type: string;
57
+ }
58
+ /**
59
+ * Metadata about when and by whom a message was created.
60
+ */
61
+ export interface AgentMessageMetadata {
62
+ /** When the message was created. */
63
+ created_date: string;
64
+ /** Email of the user who created the message. */
65
+ created_by_email: string;
66
+ /** Full name of the user who created the message. */
67
+ created_by_full_name: string;
68
+ }
69
+ /**
70
+ * An agent conversation containing messages exchanged with an AI agent.
71
+ */
72
+ export interface AgentConversation {
73
+ /** Unique identifier for the conversation. */
74
+ id: string;
75
+ /** Application ID. */
3
76
  app_id: string;
77
+ /** Name of the agent in this conversation. */
4
78
  agent_name: string;
79
+ /** ID of the user who created the conversation. */
5
80
  created_by_id: string;
81
+ /** When the conversation was created. */
82
+ created_date: string;
83
+ /** When the conversation was last updated. */
84
+ updated_date: string;
85
+ /** Array of messages in the conversation. */
6
86
  messages: AgentMessage[];
87
+ /** Optional metadata associated with the conversation. */
7
88
  metadata?: Record<string, any>;
8
- };
9
- export type AgentMessage = {
89
+ }
90
+ /**
91
+ * A message in an agent conversation.
92
+ */
93
+ export interface AgentMessage {
94
+ /** Unique identifier for the message. */
10
95
  id: string;
96
+ /** Role of the message sender. */
11
97
  role: "user" | "assistant" | "system";
12
- reasoning?: {
13
- start_date: string;
14
- end_date?: string;
15
- content: string;
16
- };
17
- content?: string | Record<string, any> | null;
18
- file_urls?: string[] | null;
19
- tool_calls?: {
20
- id: string;
21
- name: string;
22
- arguments_string: string;
23
- status: "running" | "success" | "error" | "stopped";
24
- results?: string | null;
25
- }[] | null;
26
- usage?: {
27
- prompt_tokens?: number;
28
- completion_tokens?: number;
29
- } | null;
98
+ /** When the message was created. */
99
+ created_date: string;
100
+ /** When the message was last updated. */
101
+ updated_date: string;
102
+ /** Optional reasoning information for the message. */
103
+ reasoning?: AgentMessageReasoning | null;
104
+ /** Message content. */
105
+ content?: string | Record<string, any>;
106
+ /** URLs to files attached to the message. */
107
+ file_urls?: string[];
108
+ /** Tool calls made by the agent. */
109
+ tool_calls?: AgentMessageToolCall[];
110
+ /** Token usage statistics. */
111
+ usage?: AgentMessageUsage;
112
+ /** Whether the message is hidden from the user. */
30
113
  hidden?: boolean;
31
- custom_context?: {
32
- message: string;
33
- data: Record<string, any>;
34
- type: string;
35
- }[] | null;
36
- model?: string | null;
37
- checkpoint_id?: string | null;
38
- metadata?: {
39
- created_date: string;
40
- created_by_email: string;
41
- created_by_full_name: string | null;
42
- };
114
+ /** Custom context provided with the message. */
115
+ custom_context?: AgentMessageCustomContext[];
116
+ /** Model used to generate the message. */
117
+ model?: string;
118
+ /** Checkpoint ID for the message. */
119
+ checkpoint_id?: string;
120
+ /** Metadata about when and by whom the message was created. */
121
+ metadata?: AgentMessageMetadata;
122
+ /** Additional custom parameters for the message. */
43
123
  additional_message_params?: Record<string, any>;
44
- };
124
+ }
125
+ /**
126
+ * Parameters for creating a new conversation.
127
+ */
128
+ export interface CreateConversationParams {
129
+ /** The name of the agent to create a conversation with. */
130
+ agent_name: string;
131
+ /** Optional metadata to attach to the conversation. */
132
+ metadata?: Record<string, any>;
133
+ }
134
+ /**
135
+ * Configuration for creating the agents module.
136
+ * @internal
137
+ */
138
+ export interface AgentsModuleConfig {
139
+ /** Axios instance for HTTP requests */
140
+ axios: AxiosInstance;
141
+ /** Function to get WebSocket instance for real-time updates (lazy initialization) */
142
+ getSocket: () => ReturnType<typeof RoomsSocket>;
143
+ /** Application ID */
144
+ appId: string;
145
+ /** Server URL */
146
+ serverUrl?: string;
147
+ /** Authentication token */
148
+ token?: string;
149
+ }
150
+ /**
151
+ * Agents module for managing AI agent conversations.
152
+ *
153
+ * This module provides methods to create and manage conversations with AI agents,
154
+ * send messages, and subscribe to real-time updates. Conversations can be used
155
+ * for chat interfaces, support systems, or any interactive AI app.
156
+ *
157
+ * The agents module enables you to:
158
+ *
159
+ * - **Create conversations** with agents defined in the app.
160
+ * - **Send messages** from users to agents and receive AI-generated responses.
161
+ * - **Retrieve conversations** individually or as filtered lists with sorting and pagination.
162
+ * - **Subscribe to real-time updates** using WebSocket connections to receive instant notifications when new messages arrive.
163
+ * - **Attach metadata** to conversations for tracking context, categories, priorities, or linking to external systems.
164
+ * - **Generate WhatsApp connection URLs** for users to interact with agents through WhatsApp.
165
+ *
166
+ * The agents module operates with a two-level hierarchy:
167
+ *
168
+ * 1. **Conversations**: Top-level containers that represent a dialogue with a specific agent. Each conversation has a unique ID, is associated with an agent by name, and belongs to the user who created it. Conversations can include optional metadata for tracking app-specific context like ticket IDs, categories, or custom fields.
169
+ *
170
+ * 2. **Messages**: Individual exchanges within a conversation. Each message has a role, content, and optional metadata like token usage, tool calls, file attachments, and reasoning information. Messages are stored as an array within their parent conversation.
171
+ *
172
+ * This module is available to use with a client in all authentication modes:
173
+ *
174
+ * - **Anonymous or User authentication** (`base44.agents`): Access is scoped to the current user's permissions. Anonymous users can create conversations but can't retrieve them later, while authenticated users can access conversations they created.
175
+ * - **Service role authentication** (`base44.asServiceRole.agents`): Operations have elevated admin-level permissions. Can access all conversations that the app's admin role has access to.
176
+ *
177
+ */
178
+ export interface AgentsModule {
179
+ /**
180
+ * Gets all conversations from all agents in the app.
181
+ *
182
+ * Retrieves all conversations. Use {@linkcode listConversations | listConversations()} to filter which conversations are returned, apply sorting, or paginate results. Use {@linkcode getConversation | getConversation()} to retrieve a specific conversation by ID.
183
+ *
184
+ * @returns Promise resolving to an array of conversations.
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * // Get all conversations
189
+ * const conversations = await base44.agents.getConversations();
190
+ * console.log(`Total conversations: ${conversations.length}`);
191
+ * ```
192
+ *
193
+ * @see {@linkcode listConversations | listConversations()} for filtering, sorting, and pagination
194
+ * @see {@linkcode getConversation | getConversation()} for retrieving a specific conversation by ID
195
+ */
196
+ getConversations(): Promise<AgentConversation[]>;
197
+ /**
198
+ * Gets a specific conversation by ID.
199
+ *
200
+ * Retrieves a single conversation using its unique identifier. To retrieve
201
+ * all conversations, use {@linkcode getConversations | getConversations()} To filter, sort, or paginate conversations, use {@linkcode listConversations | listConversations()}.
202
+ *
203
+ * @param conversationId - The unique identifier of the conversation.
204
+ * @returns Promise resolving to the conversation, or undefined if not found.
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * // Get a specific conversation by ID
209
+ * const conversation = await base44.agents.getConversation('conv-123');
210
+ * if (conversation) {
211
+ * console.log(`Conversation has ${conversation.messages.length} messages`);
212
+ * }
213
+ * ```
214
+ *
215
+ * @see {@linkcode getConversations | getConversations()} for retrieving all conversations
216
+ * @see {@linkcode listConversations | listConversations()} for filtering and sorting conversations
217
+ */
218
+ getConversation(conversationId: string): Promise<AgentConversation | undefined>;
219
+ /**
220
+ * Lists conversations with filtering, sorting, and pagination.
221
+ *
222
+ * Provides querying capabilities including filtering by fields, sorting, pagination, and field selection. For cases where you need all conversations without filtering, use {@linkcode getConversations | getConversations()}. To retrieve a specific conversation by ID, use {@linkcode getConversation | getConversation()}.
223
+ *
224
+ * @param filterParams - Filter parameters for querying conversations.
225
+ * @returns Promise resolving to an array of filtered conversations.
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * // List recent conversations with pagination
230
+ * const recentConversations = await base44.agents.listConversations({
231
+ * limit: 10,
232
+ * sort: '-created_date'
233
+ * });
234
+ * ```
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * // Filter by agent and metadata
239
+ * const supportConversations = await base44.agents.listConversations({
240
+ * q: {
241
+ * agent_name: 'support-agent',
242
+ * 'metadata.priority': 'high'
243
+ * },
244
+ * sort: '-created_date',
245
+ * limit: 20
246
+ * });
247
+ * ```
248
+ *
249
+ * @see {@linkcode getConversations | getConversations()} for retrieving all conversations without filtering
250
+ * @see {@linkcode getConversation | getConversation()} for retrieving a specific conversation by ID
251
+ */
252
+ listConversations(filterParams: ModelFilterParams): Promise<AgentConversation[]>;
253
+ /**
254
+ * Creates a new conversation with an agent.
255
+ *
256
+ * @param conversation - Conversation details including agent name and optional metadata.
257
+ * @returns Promise resolving to the created conversation.
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * // Create a new conversation with metadata
262
+ * const conversation = await base44.agents.createConversation({
263
+ * agent_name: 'support-agent',
264
+ * metadata: {
265
+ * order_id: 'ORD-789',
266
+ * product_id: 'PROD-456',
267
+ * category: 'technical-support'
268
+ * }
269
+ * });
270
+ * console.log(`Created conversation: ${conversation.id}`);
271
+ * ```
272
+ */
273
+ createConversation(conversation: CreateConversationParams): Promise<AgentConversation>;
274
+ /**
275
+ * Adds a message to a conversation.
276
+ *
277
+ * Sends a message to the agent and updates the conversation. This method
278
+ * also updates the real-time socket to notify any subscribers.
279
+ *
280
+ * @param conversation - The conversation to add the message to.
281
+ * @param message - The message to add.
282
+ * @returns Promise resolving to the created message.
283
+ *
284
+ * @example
285
+ * ```typescript
286
+ * // Send a message to the agent
287
+ * const message = await base44.agents.addMessage(conversation, {
288
+ * role: 'user',
289
+ * content: 'Hello, I need help with my order #12345'
290
+ * });
291
+ * console.log(`Message sent with ID: ${message.id}`);
292
+ * ```
293
+ */
294
+ addMessage(conversation: AgentConversation, message: Partial<AgentMessage>): Promise<AgentMessage>;
295
+ /**
296
+ * Subscribes to real-time updates for a conversation.
297
+ *
298
+ * Establishes a WebSocket connection to receive instant updates when new
299
+ * messages are added to the conversation. Returns an unsubscribe function
300
+ * to clean up the connection.
301
+ *
302
+ * @param conversationId - The conversation ID to subscribe to.
303
+ * @param onUpdate - Callback function called when the conversation is updated.
304
+ * @returns Unsubscribe function to stop receiving updates.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * // Subscribe to real-time updates
309
+ * const unsubscribe = base44.agents.subscribeToConversation(
310
+ * 'conv-123',
311
+ * (updatedConversation) => {
312
+ * const latestMessage = updatedConversation.messages[updatedConversation.messages.length - 1];
313
+ * console.log('New message:', latestMessage.content);
314
+ * }
315
+ * );
316
+ *
317
+ * // Later, clean up the subscription
318
+ * unsubscribe();
319
+ * ```
320
+ */
321
+ subscribeToConversation(conversationId: string, onUpdate?: (conversation: AgentConversation) => void): () => void;
322
+ /**
323
+ * Gets WhatsApp connection URL for an agent.
324
+ *
325
+ * Generates a URL that users can use to connect with the agent through WhatsApp.
326
+ * The URL includes authentication if a token is available.
327
+ *
328
+ * @param agentName - The name of the agent.
329
+ * @returns WhatsApp connection URL.
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * // Get WhatsApp connection URL
334
+ * const whatsappUrl = base44.agents.getWhatsAppConnectURL('support-agent');
335
+ * console.log(`Connect through WhatsApp: ${whatsappUrl}`);
336
+ * // User can open this URL to start a WhatsApp conversation
337
+ * ```
338
+ */
339
+ getWhatsAppConnectURL(agentName: string): string;
340
+ }
@@ -1,27 +1,11 @@
1
1
  import { AxiosInstance } from "axios";
2
+ import { AppLogsModule } from "./app-logs.types";
2
3
  /**
3
- * Creates the app logs module for the Base44 SDK
4
- * @param {AxiosInstance} axios - Axios instance
5
- * @param {string} appId - Application ID
6
- * @returns {Object} App logs module
4
+ * Creates the app logs module for the Base44 SDK.
5
+ *
6
+ * @param axios - Axios instance
7
+ * @param appId - Application ID
8
+ * @returns App logs module with methods for tracking and analyzing app usage
9
+ * @internal
7
10
  */
8
- export declare function createAppLogsModule(axios: AxiosInstance, appId: string): {
9
- /**
10
- * Log user activity in the app
11
- * @param {string} pageName - Name of the page being visited
12
- * @returns {Promise<void>}
13
- */
14
- logUserInApp(pageName: string): Promise<void>;
15
- /**
16
- * Fetch app logs with optional parameters
17
- * @param {Object} params - Query parameters for filtering logs
18
- * @returns {Promise<any>} App logs data
19
- */
20
- fetchLogs(params?: Record<string, any>): Promise<any>;
21
- /**
22
- * Get app statistics
23
- * @param {Object} params - Query parameters for filtering stats
24
- * @returns {Promise<any>} App statistics
25
- */
26
- getStats(params?: Record<string, any>): Promise<any>;
27
- };
11
+ export declare function createAppLogsModule(axios: AxiosInstance, appId: string): AppLogsModule;
@@ -1,34 +1,24 @@
1
1
  /**
2
- * Creates the app logs module for the Base44 SDK
3
- * @param {AxiosInstance} axios - Axios instance
4
- * @param {string} appId - Application ID
5
- * @returns {Object} App logs module
2
+ * Creates the app logs module for the Base44 SDK.
3
+ *
4
+ * @param axios - Axios instance
5
+ * @param appId - Application ID
6
+ * @returns App logs module with methods for tracking and analyzing app usage
7
+ * @internal
6
8
  */
7
9
  export function createAppLogsModule(axios, appId) {
8
10
  const baseURL = `/app-logs/${appId}`;
9
11
  return {
10
- /**
11
- * Log user activity in the app
12
- * @param {string} pageName - Name of the page being visited
13
- * @returns {Promise<void>}
14
- */
12
+ // Log user activity in the app
15
13
  async logUserInApp(pageName) {
16
14
  await axios.post(`${baseURL}/log-user-in-app/${pageName}`);
17
15
  },
18
- /**
19
- * Fetch app logs with optional parameters
20
- * @param {Object} params - Query parameters for filtering logs
21
- * @returns {Promise<any>} App logs data
22
- */
16
+ // Fetch app logs with optional parameters
23
17
  async fetchLogs(params = {}) {
24
18
  const response = await axios.get(baseURL, { params });
25
19
  return response;
26
20
  },
27
- /**
28
- * Get app statistics
29
- * @param {Object} params - Query parameters for filtering stats
30
- * @returns {Promise<any>} App statistics
31
- */
21
+ // Get app statistics
32
22
  async getStats(params = {}) {
33
23
  const response = await axios.get(`${baseURL}/stats`, { params });
34
24
  return response;