@base44-preview/sdk 0.8.17-pr.74.aa2810d → 0.8.17-pr.76.9ab8dcd
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 +0 -2
- package/dist/client.types.d.ts +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/modules/agents.types.d.ts +15 -9
- package/dist/modules/analytics.types.d.ts +3 -0
- package/dist/modules/custom-integrations.types.d.ts +3 -0
- package/dist/modules/entities.types.d.ts +11 -9
- package/dist/modules/integrations.types.d.ts +1 -0
- package/dist/modules/types.d.ts +0 -1
- package/dist/modules/types.js +0 -1
- package/package.json +2 -3
- package/dist/modules/recording.d.ts +0 -8
- package/dist/modules/recording.js +0 -266
- package/dist/modules/recording.types.d.ts +0 -118
- package/dist/modules/recording.types.js +0 -1
package/dist/client.js
CHANGED
|
@@ -11,7 +11,6 @@ import { createAppLogsModule } from "./modules/app-logs.js";
|
|
|
11
11
|
import { createUsersModule } from "./modules/users.js";
|
|
12
12
|
import { RoomsSocket } from "./utils/socket-utils.js";
|
|
13
13
|
import { createAnalyticsModule } from "./modules/analytics.js";
|
|
14
|
-
import { createRecordingModule } from "./modules/recording.js";
|
|
15
14
|
/**
|
|
16
15
|
* Creates a Base44 client.
|
|
17
16
|
*
|
|
@@ -128,7 +127,6 @@ export function createClient(config) {
|
|
|
128
127
|
appId,
|
|
129
128
|
userAuthModule,
|
|
130
129
|
}),
|
|
131
|
-
recording: createRecordingModule(),
|
|
132
130
|
cleanup: () => {
|
|
133
131
|
userModules.analytics.cleanup();
|
|
134
132
|
if (socket) {
|
package/dist/client.types.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ import type { FunctionsModule } from "./modules/functions.types.js";
|
|
|
7
7
|
import type { AgentsModule } from "./modules/agents.types.js";
|
|
8
8
|
import type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
9
9
|
import type { AnalyticsModule } from "./modules/analytics.types.js";
|
|
10
|
-
import type { RecordingModule } from "./modules/recording.types.js";
|
|
11
10
|
/**
|
|
12
11
|
* Options for creating a Base44 client.
|
|
13
12
|
*/
|
|
@@ -84,10 +83,11 @@ export interface Base44Client {
|
|
|
84
83
|
agents: AgentsModule;
|
|
85
84
|
/** {@link AppLogsModule | App logs module} for tracking app usage. */
|
|
86
85
|
appLogs: AppLogsModule;
|
|
87
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* {@link AnalyticsModule | Analytics module} for tracking app usage.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
88
90
|
analytics: AnalyticsModule;
|
|
89
|
-
/** {@link RecordingModule | Recording module} for capturing debug sessions. */
|
|
90
|
-
recording: RecordingModule;
|
|
91
91
|
/** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
|
|
92
92
|
cleanup: () => void;
|
|
93
93
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from
|
|
|
4
4
|
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
5
5
|
export type { Base44Client, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
|
|
6
6
|
export * from "./types.js";
|
|
7
|
-
export type { EntitiesModule, EntityHandler, RealtimeEventType, RealtimeEvent, RealtimeCallback,
|
|
7
|
+
export type { EntitiesModule, EntityHandler, RealtimeEventType, RealtimeEvent, RealtimeCallback, } from "./modules/entities.types.js";
|
|
8
8
|
export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
|
|
9
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
10
|
export type { FunctionsModule } from "./modules/functions.types.js";
|
|
@@ -72,7 +72,7 @@ export interface AgentMessageMetadata {
|
|
|
72
72
|
export interface AgentConversation {
|
|
73
73
|
/** Unique identifier for the conversation. */
|
|
74
74
|
id: string;
|
|
75
|
-
/**
|
|
75
|
+
/** App ID. */
|
|
76
76
|
app_id: string;
|
|
77
77
|
/** Name of the agent in this conversation. */
|
|
78
78
|
agent_name: string;
|
|
@@ -138,9 +138,9 @@ export interface CreateConversationParams {
|
|
|
138
138
|
export interface AgentsModuleConfig {
|
|
139
139
|
/** Axios instance for HTTP requests */
|
|
140
140
|
axios: AxiosInstance;
|
|
141
|
-
/** Function to get WebSocket instance for
|
|
141
|
+
/** Function to get WebSocket instance for realtime updates (lazy initialization) */
|
|
142
142
|
getSocket: () => ReturnType<typeof RoomsSocket>;
|
|
143
|
-
/**
|
|
143
|
+
/** App ID */
|
|
144
144
|
appId: string;
|
|
145
145
|
/** Server URL */
|
|
146
146
|
serverUrl?: string;
|
|
@@ -151,7 +151,7 @@ export interface AgentsModuleConfig {
|
|
|
151
151
|
* Agents module for managing AI agent conversations.
|
|
152
152
|
*
|
|
153
153
|
* This module provides methods to create and manage conversations with AI agents,
|
|
154
|
-
* send messages, and subscribe to
|
|
154
|
+
* send messages, and subscribe to realtime updates. Conversations can be used
|
|
155
155
|
* for chat interfaces, support systems, or any interactive AI app.
|
|
156
156
|
*
|
|
157
157
|
* The agents module enables you to:
|
|
@@ -159,7 +159,7 @@ export interface AgentsModuleConfig {
|
|
|
159
159
|
* - **Create conversations** with agents defined in the app.
|
|
160
160
|
* - **Send messages** from users to agents and receive AI-generated responses.
|
|
161
161
|
* - **Retrieve conversations** individually or as filtered lists with sorting and pagination.
|
|
162
|
-
* - **Subscribe to
|
|
162
|
+
* - **Subscribe to realtime updates** using WebSocket connections to receive instant notifications when new messages arrive.
|
|
163
163
|
* - **Attach metadata** to conversations for tracking context, categories, priorities, or linking to external systems.
|
|
164
164
|
* - **Generate WhatsApp connection URLs** for users to interact with agents through WhatsApp.
|
|
165
165
|
*
|
|
@@ -275,7 +275,7 @@ export interface AgentsModule {
|
|
|
275
275
|
* Adds a message to a conversation.
|
|
276
276
|
*
|
|
277
277
|
* Sends a message to the agent and updates the conversation. This method
|
|
278
|
-
* also updates the
|
|
278
|
+
* also updates the realtime socket to notify any subscribers.
|
|
279
279
|
*
|
|
280
280
|
* @param conversation - The conversation to add the message to.
|
|
281
281
|
* @param message - The message to add.
|
|
@@ -293,19 +293,25 @@ export interface AgentsModule {
|
|
|
293
293
|
*/
|
|
294
294
|
addMessage(conversation: AgentConversation, message: Partial<AgentMessage>): Promise<AgentMessage>;
|
|
295
295
|
/**
|
|
296
|
-
* Subscribes to
|
|
296
|
+
* Subscribes to realtime updates for a conversation.
|
|
297
297
|
*
|
|
298
298
|
* Establishes a WebSocket connection to receive instant updates when new
|
|
299
299
|
* messages are added to the conversation. Returns an unsubscribe function
|
|
300
300
|
* to clean up the connection.
|
|
301
301
|
*
|
|
302
302
|
* @param conversationId - The conversation ID to subscribe to.
|
|
303
|
-
* @param onUpdate - Callback function called when the conversation is updated.
|
|
303
|
+
* @param onUpdate - Callback function called when the conversation is updated. The callback receives a conversation object with the following properties:
|
|
304
|
+
* - `id`: Unique identifier for the conversation.
|
|
305
|
+
* - `agent_name`: Name of the agent in this conversation.
|
|
306
|
+
* - `created_date`: ISO 8601 timestamp of when the conversation was created.
|
|
307
|
+
* - `updated_date`: ISO 8601 timestamp of when the conversation was last updated.
|
|
308
|
+
* - `messages`: Array of messages in the conversation. Each message includes `id`, `role` (`'user'`, `'assistant'`, or `'system'`), `content`, `created_date`, and optionally `tool_calls`, `reasoning`, `file_urls`, and `usage`.
|
|
309
|
+
* - `metadata`: Optional metadata associated with the conversation.
|
|
304
310
|
* @returns Unsubscribe function to stop receiving updates.
|
|
305
311
|
*
|
|
306
312
|
* @example
|
|
307
313
|
* ```typescript
|
|
308
|
-
* // Subscribe to
|
|
314
|
+
* // Subscribe to realtime updates
|
|
309
315
|
* const unsubscribe = base44.agents.subscribeToConversation(
|
|
310
316
|
* 'conv-123',
|
|
311
317
|
* (updatedConversation) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parameters for calling a custom integration endpoint.
|
|
3
|
+
* @internal
|
|
3
4
|
*/
|
|
4
5
|
export interface CustomIntegrationCallParams {
|
|
5
6
|
/**
|
|
@@ -22,6 +23,7 @@ export interface CustomIntegrationCallParams {
|
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Response from a custom integration call.
|
|
26
|
+
* @internal
|
|
25
27
|
*/
|
|
26
28
|
export interface CustomIntegrationCallResponse {
|
|
27
29
|
/**
|
|
@@ -85,6 +87,7 @@ export interface CustomIntegrationCallResponse {
|
|
|
85
87
|
* }
|
|
86
88
|
* );
|
|
87
89
|
* ```
|
|
90
|
+
* @internal
|
|
88
91
|
*/
|
|
89
92
|
export interface CustomIntegrationsModule {
|
|
90
93
|
/**
|
|
@@ -19,10 +19,6 @@ export interface RealtimeEvent {
|
|
|
19
19
|
* Callback function invoked when a realtime event occurs.
|
|
20
20
|
*/
|
|
21
21
|
export type RealtimeCallback = (event: RealtimeEvent) => void;
|
|
22
|
-
/**
|
|
23
|
-
* Function returned from subscribe, call it to unsubscribe.
|
|
24
|
-
*/
|
|
25
|
-
export type Subscription = () => void;
|
|
26
22
|
/**
|
|
27
23
|
* Entity handler providing CRUD operations for a specific entity type.
|
|
28
24
|
*
|
|
@@ -270,10 +266,16 @@ export interface EntityHandler {
|
|
|
270
266
|
/**
|
|
271
267
|
* Subscribes to realtime updates for all records of this entity type.
|
|
272
268
|
*
|
|
273
|
-
*
|
|
269
|
+
* Establishes a WebSocket connection to receive instant updates when any
|
|
270
|
+
* record is created, updated, or deleted. Returns an unsubscribe function
|
|
271
|
+
* to clean up the connection.
|
|
274
272
|
*
|
|
275
|
-
* @param callback -
|
|
276
|
-
*
|
|
273
|
+
* @param callback - Callback function called when an entity changes. The callback receives an event object with the following properties:
|
|
274
|
+
* - `type`: The type of change that occurred - `'create'`, `'update'`, or `'delete'`.
|
|
275
|
+
* - `data`: The entity data after the change.
|
|
276
|
+
* - `id`: The unique identifier of the affected entity.
|
|
277
|
+
* - `timestamp`: ISO 8601 timestamp of when the event occurred.
|
|
278
|
+
* @returns Unsubscribe function to stop receiving updates.
|
|
277
279
|
*
|
|
278
280
|
* @example
|
|
279
281
|
* ```typescript
|
|
@@ -282,11 +284,11 @@ export interface EntityHandler {
|
|
|
282
284
|
* console.log(`Task ${event.id} was ${event.type}d:`, event.data);
|
|
283
285
|
* });
|
|
284
286
|
*
|
|
285
|
-
* // Later,
|
|
287
|
+
* // Later, clean up the subscription
|
|
286
288
|
* unsubscribe();
|
|
287
289
|
* ```
|
|
288
290
|
*/
|
|
289
|
-
subscribe(callback: RealtimeCallback):
|
|
291
|
+
subscribe(callback: RealtimeCallback): () => void;
|
|
290
292
|
}
|
|
291
293
|
/**
|
|
292
294
|
* Entities module for managing app data.
|
package/dist/modules/types.d.ts
CHANGED
package/dist/modules/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/sdk",
|
|
3
|
-
"version": "0.8.17-pr.
|
|
3
|
+
"version": "0.8.17-pr.76.9ab8dcd",
|
|
4
4
|
"description": "JavaScript SDK for Base44 API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,13 +20,12 @@
|
|
|
20
20
|
"prepublishOnly": "npm run build",
|
|
21
21
|
"create-docs": "npm run create-docs:generate && npm run create-docs:process",
|
|
22
22
|
"push-docs": "node scripts/mintlify-post-processing/push-to-docs-repo.js",
|
|
23
|
+
"copy-docs-local": "node scripts/mintlify-post-processing/copy-to-local-docs.js",
|
|
23
24
|
"create-docs:generate": "typedoc",
|
|
24
25
|
"create-docs:process": "node scripts/mintlify-post-processing/file-processing/file-processing.js"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@rrweb/rrweb-plugin-console-record": "^2.0.0-alpha.18",
|
|
28
28
|
"axios": "^1.6.2",
|
|
29
|
-
"rrweb": "^2.0.0-alpha.18",
|
|
30
29
|
"socket.io-client": "^4.7.5",
|
|
31
30
|
"uuid": "^13.0.0"
|
|
32
31
|
},
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { RecordingModule } from "./recording.types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Creates the recording module for the Base44 SDK.
|
|
4
|
-
*
|
|
5
|
-
* @returns Recording module with methods for capturing debug sessions
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare function createRecordingModule(): RecordingModule;
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { record, IncrementalSource, MouseInteractions, } from "rrweb";
|
|
2
|
-
import { getRecordConsolePlugin } from "@rrweb/rrweb-plugin-console-record";
|
|
3
|
-
import { generateUuid } from "../utils/common.js";
|
|
4
|
-
const state = {
|
|
5
|
-
isRecording: false,
|
|
6
|
-
sessionId: null,
|
|
7
|
-
startTime: null,
|
|
8
|
-
events: [],
|
|
9
|
-
stopFn: null,
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Creates the recording module for the Base44 SDK.
|
|
13
|
-
*
|
|
14
|
-
* @returns Recording module with methods for capturing debug sessions
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export function createRecordingModule() {
|
|
18
|
-
return {
|
|
19
|
-
start() {
|
|
20
|
-
if (state.isRecording) {
|
|
21
|
-
throw new Error("Recording is already in progress");
|
|
22
|
-
}
|
|
23
|
-
if (typeof window === "undefined") {
|
|
24
|
-
throw new Error("Recording is only available in browser environments");
|
|
25
|
-
}
|
|
26
|
-
// Reset state
|
|
27
|
-
state.isRecording = true;
|
|
28
|
-
state.sessionId = generateUuid();
|
|
29
|
-
state.startTime = new Date().toISOString();
|
|
30
|
-
state.events = [];
|
|
31
|
-
const stopFn = record({
|
|
32
|
-
emit: (event) => {
|
|
33
|
-
state.events.push(event);
|
|
34
|
-
},
|
|
35
|
-
plugins: [
|
|
36
|
-
getRecordConsolePlugin({
|
|
37
|
-
level: ["log", "warn", "error", "info", "debug"],
|
|
38
|
-
lengthThreshold: 10000,
|
|
39
|
-
stringifyOptions: {
|
|
40
|
-
stringLengthLimit: 5000,
|
|
41
|
-
numOfKeysLimit: 100,
|
|
42
|
-
depthOfLimit: 5,
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
state.stopFn = stopFn !== null && stopFn !== void 0 ? stopFn : null;
|
|
48
|
-
},
|
|
49
|
-
stop() {
|
|
50
|
-
if (!state.isRecording) {
|
|
51
|
-
throw new Error("No recording is in progress");
|
|
52
|
-
}
|
|
53
|
-
// Stop rrweb recording
|
|
54
|
-
if (state.stopFn) {
|
|
55
|
-
state.stopFn();
|
|
56
|
-
state.stopFn = null;
|
|
57
|
-
}
|
|
58
|
-
const endTime = new Date().toISOString();
|
|
59
|
-
const startTime = state.startTime;
|
|
60
|
-
const duration = new Date(endTime).getTime() - new Date(startTime).getTime();
|
|
61
|
-
// Extract data from events
|
|
62
|
-
const consoleEntries = extractConsoleEntries(state.events);
|
|
63
|
-
const userActions = extractUserActions(state.events);
|
|
64
|
-
const report = {
|
|
65
|
-
sessionId: state.sessionId,
|
|
66
|
-
startTime,
|
|
67
|
-
endTime,
|
|
68
|
-
duration,
|
|
69
|
-
console: consoleEntries,
|
|
70
|
-
userActions,
|
|
71
|
-
};
|
|
72
|
-
// Reset state
|
|
73
|
-
state.isRecording = false;
|
|
74
|
-
state.sessionId = null;
|
|
75
|
-
state.startTime = null;
|
|
76
|
-
state.events = [];
|
|
77
|
-
return report;
|
|
78
|
-
},
|
|
79
|
-
isRecording() {
|
|
80
|
-
return state.isRecording;
|
|
81
|
-
},
|
|
82
|
-
toText(report) {
|
|
83
|
-
const lines = [
|
|
84
|
-
"## Debug Session Report",
|
|
85
|
-
`Session ID: ${report.sessionId}`,
|
|
86
|
-
`Duration: ${report.duration}ms`,
|
|
87
|
-
`Recorded: ${report.startTime} to ${report.endTime}`,
|
|
88
|
-
"",
|
|
89
|
-
`### User Actions (${report.userActions.length} actions)`,
|
|
90
|
-
];
|
|
91
|
-
if (report.userActions.length === 0) {
|
|
92
|
-
lines.push("No user actions captured.");
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
for (const action of report.userActions) {
|
|
96
|
-
const timestamp = new Date(action.timestamp).toISOString();
|
|
97
|
-
const valueStr = action.value ? ` = "${action.value}"` : "";
|
|
98
|
-
lines.push(`[${timestamp}] ${action.type}: ${action.target}${valueStr}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
lines.push("");
|
|
102
|
-
lines.push(`### Console Output (${report.console.length} entries)`);
|
|
103
|
-
if (report.console.length === 0) {
|
|
104
|
-
lines.push("No console output captured.");
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
for (const entry of report.console) {
|
|
108
|
-
const timestamp = new Date(entry.timestamp).toISOString();
|
|
109
|
-
lines.push(`[${timestamp}] [${entry.level.toUpperCase()}] ${entry.message}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return lines.join("\n");
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Extracts console entries from rrweb events.
|
|
118
|
-
*/
|
|
119
|
-
function extractConsoleEntries(events) {
|
|
120
|
-
var _a;
|
|
121
|
-
const consoleEntries = [];
|
|
122
|
-
for (const event of events) {
|
|
123
|
-
// rrweb plugin events have type 6
|
|
124
|
-
if (event.type === 6 && ((_a = event.data) === null || _a === void 0 ? void 0 : _a.plugin) === "rrweb/console@1") {
|
|
125
|
-
const payload = event.data.payload;
|
|
126
|
-
if (payload && payload.level && payload.payload) {
|
|
127
|
-
const message = stringifyConsolePayload(payload.payload);
|
|
128
|
-
consoleEntries.push({
|
|
129
|
-
level: payload.level,
|
|
130
|
-
message,
|
|
131
|
-
timestamp: event.timestamp,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return consoleEntries;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Converts console payload array to a readable string.
|
|
140
|
-
*/
|
|
141
|
-
function stringifyConsolePayload(payload) {
|
|
142
|
-
return payload
|
|
143
|
-
.map((item) => {
|
|
144
|
-
if (typeof item === "string") {
|
|
145
|
-
return item;
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
return JSON.stringify(item);
|
|
149
|
-
}
|
|
150
|
-
catch (_a) {
|
|
151
|
-
return String(item);
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
.join(" ");
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Extracts user actions from rrweb events.
|
|
158
|
-
*/
|
|
159
|
-
function extractUserActions(events) {
|
|
160
|
-
const userActions = [];
|
|
161
|
-
// Build a map of node IDs to readable descriptions from the full snapshot
|
|
162
|
-
const nodeMap = buildNodeMap(events);
|
|
163
|
-
for (const event of events) {
|
|
164
|
-
// IncrementalSnapshot events have type 3
|
|
165
|
-
if (event.type !== 3 || !event.data)
|
|
166
|
-
continue;
|
|
167
|
-
const { source, type, id, text } = event.data;
|
|
168
|
-
// Mouse interactions
|
|
169
|
-
if (source === IncrementalSource.MouseInteraction && id !== undefined) {
|
|
170
|
-
const actionType = getMouseInteractionType(type);
|
|
171
|
-
if (actionType) {
|
|
172
|
-
userActions.push({
|
|
173
|
-
type: actionType,
|
|
174
|
-
target: nodeMap.get(id) || `element#${id}`,
|
|
175
|
-
timestamp: event.timestamp,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
// Input events
|
|
180
|
-
if (source === IncrementalSource.Input && id !== undefined) {
|
|
181
|
-
userActions.push({
|
|
182
|
-
type: "input",
|
|
183
|
-
target: nodeMap.get(id) || `input#${id}`,
|
|
184
|
-
value: text ? truncateString(text, 100) : undefined,
|
|
185
|
-
timestamp: event.timestamp,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return userActions;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Maps mouse interaction type number to readable action type.
|
|
193
|
-
*/
|
|
194
|
-
function getMouseInteractionType(type) {
|
|
195
|
-
switch (type) {
|
|
196
|
-
case MouseInteractions.Click:
|
|
197
|
-
return "click";
|
|
198
|
-
case MouseInteractions.DblClick:
|
|
199
|
-
return "dblclick";
|
|
200
|
-
default:
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Builds a map of node IDs to readable descriptions from the full snapshot.
|
|
206
|
-
*/
|
|
207
|
-
function buildNodeMap(events) {
|
|
208
|
-
var _a;
|
|
209
|
-
const nodeMap = new Map();
|
|
210
|
-
// Find the full snapshot (type 2)
|
|
211
|
-
const fullSnapshot = events.find((e) => e.type === 2);
|
|
212
|
-
if (!fullSnapshot)
|
|
213
|
-
return nodeMap;
|
|
214
|
-
// Recursively extract node info
|
|
215
|
-
const extractNodes = (node) => {
|
|
216
|
-
if (!node || typeof node !== "object")
|
|
217
|
-
return;
|
|
218
|
-
if (node.id !== undefined && node.tagName) {
|
|
219
|
-
const parts = [`<${node.tagName.toLowerCase()}`];
|
|
220
|
-
if (node.attributes) {
|
|
221
|
-
if (node.attributes.id) {
|
|
222
|
-
parts[0] += `#${node.attributes.id}`;
|
|
223
|
-
}
|
|
224
|
-
if (node.attributes.class) {
|
|
225
|
-
const firstClass = node.attributes.class.split(" ")[0];
|
|
226
|
-
if (firstClass)
|
|
227
|
-
parts[0] += `.${firstClass}`;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
parts[0] += ">";
|
|
231
|
-
// Add text content hint if available
|
|
232
|
-
if (node.childNodes) {
|
|
233
|
-
for (const child of node.childNodes) {
|
|
234
|
-
if (child.type === 3 && child.textContent) {
|
|
235
|
-
// Text node
|
|
236
|
-
const text = child.textContent.trim().slice(0, 30);
|
|
237
|
-
if (text) {
|
|
238
|
-
parts.push(`"${text}"`);
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
nodeMap.set(node.id, parts.join(" "));
|
|
245
|
-
}
|
|
246
|
-
// Recurse into children
|
|
247
|
-
if (node.childNodes) {
|
|
248
|
-
for (const child of node.childNodes) {
|
|
249
|
-
extractNodes(child);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
// Start from the snapshot data
|
|
254
|
-
if ((_a = fullSnapshot.data) === null || _a === void 0 ? void 0 : _a.node) {
|
|
255
|
-
extractNodes(fullSnapshot.data.node);
|
|
256
|
-
}
|
|
257
|
-
return nodeMap;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Truncates a string to a maximum length.
|
|
261
|
-
*/
|
|
262
|
-
function truncateString(str, maxLength) {
|
|
263
|
-
if (str.length <= maxLength)
|
|
264
|
-
return str;
|
|
265
|
-
return str.slice(0, maxLength - 3) + "...";
|
|
266
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A console log entry captured during recording.
|
|
3
|
-
*/
|
|
4
|
-
export interface ConsoleEntry {
|
|
5
|
-
/** The console method that was called. */
|
|
6
|
-
level: "log" | "warn" | "error" | "info" | "debug";
|
|
7
|
-
/** The logged message content. */
|
|
8
|
-
message: string;
|
|
9
|
-
/** Unix timestamp when the log occurred. */
|
|
10
|
-
timestamp: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A user action captured during recording.
|
|
14
|
-
*/
|
|
15
|
-
export interface UserAction {
|
|
16
|
-
/** The type of interaction. */
|
|
17
|
-
type: "click" | "dblclick" | "input";
|
|
18
|
-
/** Description of the target element. */
|
|
19
|
-
target: string;
|
|
20
|
-
/** Value entered (for input actions). */
|
|
21
|
-
value?: string;
|
|
22
|
-
/** Unix timestamp when the action occurred. */
|
|
23
|
-
timestamp: number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Debug report containing captured session data.
|
|
27
|
-
*/
|
|
28
|
-
export interface DebugReport {
|
|
29
|
-
/** Unique session identifier. */
|
|
30
|
-
sessionId: string;
|
|
31
|
-
/** Recording start time (ISO 8601). */
|
|
32
|
-
startTime: string;
|
|
33
|
-
/** Recording end time (ISO 8601). */
|
|
34
|
-
endTime: string;
|
|
35
|
-
/** Duration in milliseconds. */
|
|
36
|
-
duration: number;
|
|
37
|
-
/** Captured console output. */
|
|
38
|
-
console: ConsoleEntry[];
|
|
39
|
-
/** Captured user actions (clicks, inputs, etc.). */
|
|
40
|
-
userActions: UserAction[];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Recording module for capturing debug sessions.
|
|
44
|
-
*
|
|
45
|
-
* This module captures console output from the running app to help debug issues.
|
|
46
|
-
* It's designed to provide context for AI agents analyzing app problems.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* // Start recording
|
|
51
|
-
* base44.recording.start();
|
|
52
|
-
*
|
|
53
|
-
* // ... user reproduces the issue ...
|
|
54
|
-
*
|
|
55
|
-
* // Stop and get the report
|
|
56
|
-
* const report = base44.recording.stop();
|
|
57
|
-
* console.log(report.console); // All console output
|
|
58
|
-
*
|
|
59
|
-
* // Get text summary for LLM
|
|
60
|
-
* const summary = base44.recording.toText(report);
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export interface RecordingModule {
|
|
64
|
-
/**
|
|
65
|
-
* Starts a debug recording session.
|
|
66
|
-
*
|
|
67
|
-
* Captures console output until stopped.
|
|
68
|
-
* Only one recording can be active at a time.
|
|
69
|
-
*
|
|
70
|
-
* @throws {Error} If a recording is already in progress.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* base44.recording.start();
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
start(): void;
|
|
78
|
-
/**
|
|
79
|
-
* Stops the current recording and returns the captured data.
|
|
80
|
-
*
|
|
81
|
-
* @returns The debug report containing all captured console output.
|
|
82
|
-
* @throws {Error} If no recording is in progress.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const report = base44.recording.stop();
|
|
87
|
-
* console.log(`Captured ${report.console.length} console entries`);
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
stop(): DebugReport;
|
|
91
|
-
/**
|
|
92
|
-
* Checks if a recording is currently in progress.
|
|
93
|
-
*
|
|
94
|
-
* @returns True if recording, false otherwise.
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```typescript
|
|
98
|
-
* if (!base44.recording.isRecording()) {
|
|
99
|
-
* base44.recording.start();
|
|
100
|
-
* }
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
isRecording(): boolean;
|
|
104
|
-
/**
|
|
105
|
-
* Generates a text summary of a debug report for LLM consumption.
|
|
106
|
-
*
|
|
107
|
-
* @param report - The debug report to summarize.
|
|
108
|
-
* @returns A formatted text summary.
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```typescript
|
|
112
|
-
* const report = base44.recording.stop();
|
|
113
|
-
* const summary = base44.recording.toText(report);
|
|
114
|
-
* // Send summary to your backend for LLM processing
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
toText(report: DebugReport): string;
|
|
118
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|