@superatomai/sdk-web 0.0.8 → 0.0.10
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/README.md +128 -3
- package/dist/index.cjs +231 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +164 -3
- package/dist/index.d.ts +164 -3
- package/dist/index.js +231 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -250,7 +250,8 @@ var UserPromptRequestPayloadSchema = z.object({
|
|
|
250
250
|
SA_RUNTIME: z.object({
|
|
251
251
|
threadId: z.string(),
|
|
252
252
|
uiBlockId: z.string()
|
|
253
|
-
}).optional()
|
|
253
|
+
}).optional(),
|
|
254
|
+
responseMode: z.enum(["component", "text"]).optional()
|
|
254
255
|
});
|
|
255
256
|
var UserPromptRequestMessageSchema = z.object({
|
|
256
257
|
id: z.string(),
|
|
@@ -548,6 +549,44 @@ z.object({
|
|
|
548
549
|
to: MessageParticipantSchema.optional(),
|
|
549
550
|
payload: ReportsResponsePayloadSchema
|
|
550
551
|
});
|
|
552
|
+
var BookmarkDataSchema = z.object({
|
|
553
|
+
id: z.number().optional(),
|
|
554
|
+
uiblock: z.any(),
|
|
555
|
+
// JSON object
|
|
556
|
+
created_at: z.string().optional(),
|
|
557
|
+
updated_at: z.string().optional()
|
|
558
|
+
});
|
|
559
|
+
var BookmarksRequestPayloadSchema = z.object({
|
|
560
|
+
operation: z.enum(["create", "update", "delete", "getAll", "getOne"]),
|
|
561
|
+
data: z.object({
|
|
562
|
+
id: z.number().optional(),
|
|
563
|
+
uiblock: z.any().optional()
|
|
564
|
+
}).optional()
|
|
565
|
+
});
|
|
566
|
+
var BookmarksRequestMessageSchema = z.object({
|
|
567
|
+
id: z.string(),
|
|
568
|
+
type: z.literal("BOOKMARKS"),
|
|
569
|
+
from: MessageParticipantSchema,
|
|
570
|
+
to: MessageParticipantSchema.optional(),
|
|
571
|
+
payload: BookmarksRequestPayloadSchema
|
|
572
|
+
});
|
|
573
|
+
var BookmarksResponsePayloadSchema = z.object({
|
|
574
|
+
success: z.boolean(),
|
|
575
|
+
error: z.string().optional(),
|
|
576
|
+
data: z.union([
|
|
577
|
+
BookmarkDataSchema,
|
|
578
|
+
z.array(BookmarkDataSchema)
|
|
579
|
+
]).optional(),
|
|
580
|
+
count: z.number().optional(),
|
|
581
|
+
message: z.string().optional()
|
|
582
|
+
});
|
|
583
|
+
z.object({
|
|
584
|
+
id: z.string(),
|
|
585
|
+
type: z.literal("BOOKMARKS_RES"),
|
|
586
|
+
from: MessageParticipantSchema,
|
|
587
|
+
to: MessageParticipantSchema.optional(),
|
|
588
|
+
payload: BookmarksResponsePayloadSchema
|
|
589
|
+
});
|
|
551
590
|
var ClientConfigSchema = z.object({
|
|
552
591
|
userId: z.string(),
|
|
553
592
|
projectId: z.string(),
|
|
@@ -570,16 +609,20 @@ __export(services_exports, {
|
|
|
570
609
|
QuerySpecSchema: () => QuerySpecSchema,
|
|
571
610
|
UIComponentSchema: () => UIComponentSchema,
|
|
572
611
|
UIElementSchema: () => UIElementSchema,
|
|
612
|
+
createBookmark: () => createBookmark,
|
|
573
613
|
createDashboard: () => createDashboard,
|
|
574
614
|
createReport: () => createReport,
|
|
575
615
|
createUser: () => createUser,
|
|
616
|
+
deleteBookmark: () => deleteBookmark,
|
|
576
617
|
deleteDashboard: () => deleteDashboard,
|
|
577
618
|
deleteReport: () => deleteReport,
|
|
578
619
|
deleteUser: () => deleteUser,
|
|
579
620
|
getActions: () => getActions,
|
|
621
|
+
getAllBookmarks: () => getAllBookmarks,
|
|
580
622
|
getAllDashboards: () => getAllDashboards,
|
|
581
623
|
getAllReports: () => getAllReports,
|
|
582
624
|
getAllUsers: () => getAllUsers,
|
|
625
|
+
getBookmark: () => getBookmark,
|
|
583
626
|
getComponentSuggestions: () => getComponentSuggestions,
|
|
584
627
|
getDashboard: () => getDashboard,
|
|
585
628
|
getReport: () => getReport,
|
|
@@ -591,6 +634,7 @@ __export(services_exports, {
|
|
|
591
634
|
sendComponents: () => sendComponents,
|
|
592
635
|
sendUserPromptRequest: () => sendUserPromptRequest,
|
|
593
636
|
sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
|
|
637
|
+
updateBookmark: () => updateBookmark,
|
|
594
638
|
updateDashboard: () => updateDashboard,
|
|
595
639
|
updateReport: () => updateReport,
|
|
596
640
|
updateUser: () => updateUser
|
|
@@ -636,8 +680,8 @@ async function sendAuthVerifyRequest(client, token, timeout) {
|
|
|
636
680
|
}
|
|
637
681
|
|
|
638
682
|
// src/services/userPrompt.ts
|
|
639
|
-
async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, timeout) {
|
|
640
|
-
const messageId = `
|
|
683
|
+
async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, responseMode, onStream, timeout) {
|
|
684
|
+
const messageId = `user_prompt_req_msg_${Date.now()}`;
|
|
641
685
|
const message = UserPromptRequestMessageSchema.parse({
|
|
642
686
|
id: messageId,
|
|
643
687
|
type: "USER_PROMPT_REQ",
|
|
@@ -652,11 +696,29 @@ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, timeou
|
|
|
652
696
|
SA_RUNTIME: {
|
|
653
697
|
threadId,
|
|
654
698
|
uiBlockId
|
|
655
|
-
}
|
|
699
|
+
},
|
|
700
|
+
responseMode
|
|
656
701
|
}
|
|
657
702
|
});
|
|
658
|
-
|
|
659
|
-
|
|
703
|
+
let streamUnsubscribe = null;
|
|
704
|
+
if (responseMode === "text" && onStream) {
|
|
705
|
+
streamUnsubscribe = client.onMessage((msg) => {
|
|
706
|
+
if (msg.type === "USER_PROMPT_STREAM" && msg.id === `stream_${uiBlockId}`) {
|
|
707
|
+
const chunk = msg.payload?.chunk;
|
|
708
|
+
if (chunk) {
|
|
709
|
+
onStream(chunk);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
try {
|
|
715
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
716
|
+
return response;
|
|
717
|
+
} finally {
|
|
718
|
+
if (streamUnsubscribe) {
|
|
719
|
+
streamUnsubscribe();
|
|
720
|
+
}
|
|
721
|
+
}
|
|
660
722
|
}
|
|
661
723
|
async function sendUserPromptSuggestionsRequest(client, prompt, limit = 5, timeout) {
|
|
662
724
|
if (!prompt || prompt.trim().length === 0) {
|
|
@@ -1158,6 +1220,122 @@ async function getReport(client, reportId, timeout) {
|
|
|
1158
1220
|
};
|
|
1159
1221
|
}
|
|
1160
1222
|
|
|
1223
|
+
// src/services/bookmarks/index.ts
|
|
1224
|
+
async function createBookmark(client, uiblock, timeout) {
|
|
1225
|
+
const messageId = `bookmarks_create_${Date.now()}`;
|
|
1226
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1227
|
+
id: messageId,
|
|
1228
|
+
type: "BOOKMARKS",
|
|
1229
|
+
from: { type: client.type },
|
|
1230
|
+
to: { type: "data-agent" },
|
|
1231
|
+
payload: {
|
|
1232
|
+
operation: "create",
|
|
1233
|
+
data: {
|
|
1234
|
+
uiblock
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1239
|
+
const payload = response.payload;
|
|
1240
|
+
return {
|
|
1241
|
+
success: payload.success,
|
|
1242
|
+
error: payload.error,
|
|
1243
|
+
message: payload.message,
|
|
1244
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
async function updateBookmark(client, id, uiblock, timeout) {
|
|
1248
|
+
const messageId = `bookmarks_update_${Date.now()}`;
|
|
1249
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1250
|
+
id: messageId,
|
|
1251
|
+
type: "BOOKMARKS",
|
|
1252
|
+
from: { type: client.type },
|
|
1253
|
+
to: { type: "data-agent" },
|
|
1254
|
+
payload: {
|
|
1255
|
+
operation: "update",
|
|
1256
|
+
data: {
|
|
1257
|
+
id,
|
|
1258
|
+
uiblock
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
});
|
|
1262
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1263
|
+
const payload = response.payload;
|
|
1264
|
+
return {
|
|
1265
|
+
success: payload.success,
|
|
1266
|
+
error: payload.error,
|
|
1267
|
+
message: payload.message,
|
|
1268
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
async function deleteBookmark(client, id, timeout) {
|
|
1272
|
+
const messageId = `bookmarks_delete_${Date.now()}`;
|
|
1273
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1274
|
+
id: messageId,
|
|
1275
|
+
type: "BOOKMARKS",
|
|
1276
|
+
from: { type: client.type },
|
|
1277
|
+
to: { type: "data-agent" },
|
|
1278
|
+
payload: {
|
|
1279
|
+
operation: "delete",
|
|
1280
|
+
data: {
|
|
1281
|
+
id
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1286
|
+
const payload = response.payload;
|
|
1287
|
+
return {
|
|
1288
|
+
success: payload.success,
|
|
1289
|
+
error: payload.error,
|
|
1290
|
+
message: payload.message,
|
|
1291
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
async function getAllBookmarks(client, timeout) {
|
|
1295
|
+
const messageId = `bookmarks_getall_${Date.now()}`;
|
|
1296
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1297
|
+
id: messageId,
|
|
1298
|
+
type: "BOOKMARKS",
|
|
1299
|
+
from: { type: client.type },
|
|
1300
|
+
to: { type: "data-agent" },
|
|
1301
|
+
payload: {
|
|
1302
|
+
operation: "getAll"
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1306
|
+
const payload = response.payload;
|
|
1307
|
+
return {
|
|
1308
|
+
success: payload.success,
|
|
1309
|
+
error: payload.error,
|
|
1310
|
+
data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
|
|
1311
|
+
count: payload.count,
|
|
1312
|
+
message: payload.message
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
async function getBookmark(client, id, timeout) {
|
|
1316
|
+
const messageId = `bookmarks_getone_${Date.now()}`;
|
|
1317
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1318
|
+
id: messageId,
|
|
1319
|
+
type: "BOOKMARKS",
|
|
1320
|
+
from: { type: client.type },
|
|
1321
|
+
to: { type: "data-agent" },
|
|
1322
|
+
payload: {
|
|
1323
|
+
operation: "getOne",
|
|
1324
|
+
data: {
|
|
1325
|
+
id
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1330
|
+
const payload = response.payload;
|
|
1331
|
+
return {
|
|
1332
|
+
success: payload.success,
|
|
1333
|
+
error: payload.error,
|
|
1334
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data,
|
|
1335
|
+
message: payload.message
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1161
1339
|
// src/services/actions.ts
|
|
1162
1340
|
async function getActions(client, options) {
|
|
1163
1341
|
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
@@ -1463,10 +1641,12 @@ var SuperatomClient = class {
|
|
|
1463
1641
|
/**
|
|
1464
1642
|
* Send a user prompt request
|
|
1465
1643
|
* Delegates to user prompt service
|
|
1644
|
+
* @param responseMode - 'component' for component response (default), 'text' for text streaming
|
|
1645
|
+
* @param onStream - Optional callback for streaming text chunks (only for text mode)
|
|
1466
1646
|
*/
|
|
1467
|
-
async sendUserPromptRequest(prompt, threadId, uiBlockId, timeout) {
|
|
1468
|
-
this.log("info", "Sending user prompt request");
|
|
1469
|
-
return sendUserPromptRequest(this, prompt, threadId, uiBlockId, timeout);
|
|
1647
|
+
async sendUserPromptRequest(prompt, threadId, uiBlockId, responseMode, onStream, timeout) {
|
|
1648
|
+
this.log("info", "Sending user prompt request with streaming support");
|
|
1649
|
+
return sendUserPromptRequest(this, prompt, threadId, uiBlockId, responseMode, onStream, timeout);
|
|
1470
1650
|
}
|
|
1471
1651
|
/**
|
|
1472
1652
|
* Send a user prompt suggestions request
|
|
@@ -1596,6 +1776,48 @@ var SuperatomClient = class {
|
|
|
1596
1776
|
this.log("info", "Fetching dashboard:", dashboardId);
|
|
1597
1777
|
return getDashboard(this, dashboardId, timeout);
|
|
1598
1778
|
}
|
|
1779
|
+
// ==================== Bookmark Management Methods ====================
|
|
1780
|
+
// These methods delegate to bookmark service for bookmark CRUD operations
|
|
1781
|
+
/**
|
|
1782
|
+
* Create a new bookmark
|
|
1783
|
+
* Delegates to bookmarks service
|
|
1784
|
+
*/
|
|
1785
|
+
async createBookmark(uiblock, timeout) {
|
|
1786
|
+
this.log("info", "Creating bookmark");
|
|
1787
|
+
return createBookmark(this, uiblock, timeout);
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Update an existing bookmark
|
|
1791
|
+
* Delegates to bookmarks service
|
|
1792
|
+
*/
|
|
1793
|
+
async updateBookmark(id, uiblock, timeout) {
|
|
1794
|
+
this.log("info", "Updating bookmark:", id);
|
|
1795
|
+
return updateBookmark(this, id, uiblock, timeout);
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Delete a bookmark
|
|
1799
|
+
* Delegates to bookmarks service
|
|
1800
|
+
*/
|
|
1801
|
+
async deleteBookmark(id, timeout) {
|
|
1802
|
+
this.log("info", "Deleting bookmark:", id);
|
|
1803
|
+
return deleteBookmark(this, id, timeout);
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Get all bookmarks
|
|
1807
|
+
* Delegates to bookmarks service
|
|
1808
|
+
*/
|
|
1809
|
+
async getAllBookmarks(timeout) {
|
|
1810
|
+
this.log("info", "Fetching all bookmarks");
|
|
1811
|
+
return getAllBookmarks(this, timeout);
|
|
1812
|
+
}
|
|
1813
|
+
/**
|
|
1814
|
+
* Get a specific bookmark by ID
|
|
1815
|
+
* Delegates to bookmarks service
|
|
1816
|
+
*/
|
|
1817
|
+
async getBookmark(id, timeout) {
|
|
1818
|
+
this.log("info", "Fetching bookmark:", id);
|
|
1819
|
+
return getBookmark(this, id, timeout);
|
|
1820
|
+
}
|
|
1599
1821
|
// ==================== Report Management Methods ====================
|
|
1600
1822
|
// These methods delegate to report service for admin report CRUD operations
|
|
1601
1823
|
/**
|