@superatomai/sdk-web 0.0.5 → 0.0.7

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/index.js CHANGED
@@ -394,6 +394,40 @@ var UILogsMessageSchema = z.object({
394
394
  to: MessageParticipantSchema.optional(),
395
395
  payload: UILogsPayloadSchema
396
396
  });
397
+ var ActionsRequestPayloadSchema = z.object({
398
+ SA_RUNTIME: z.object({
399
+ threadId: z.string(),
400
+ uiBlockId: z.string()
401
+ }).optional()
402
+ });
403
+ var ActionsRequestMessageSchema = z.object({
404
+ id: z.string(),
405
+ from: MessageParticipantSchema,
406
+ type: z.literal("ACTIONS"),
407
+ payload: ActionsRequestPayloadSchema
408
+ });
409
+ var ActionsResponsePayloadSchema = z.object({
410
+ success: z.boolean(),
411
+ data: z.any().optional(),
412
+ error: z.string().optional()
413
+ });
414
+ var ActionsResponseMessageSchema = z.object({
415
+ id: z.string(),
416
+ type: z.literal("ACTIONS_RES"),
417
+ from: MessageParticipantSchema,
418
+ to: MessageParticipantSchema.optional(),
419
+ payload: ActionsResponsePayloadSchema
420
+ });
421
+ var ComponentsSendPayloadSchema = z.object({
422
+ components: z.array(z.any())
423
+ });
424
+ var ComponentsSendMessageSchema = z.object({
425
+ id: z.string(),
426
+ type: z.literal("COMPONENT_LIST_RES"),
427
+ from: MessageParticipantSchema,
428
+ to: MessageParticipantSchema.optional(),
429
+ payload: ComponentsSendPayloadSchema
430
+ });
397
431
  var UsersRequestPayloadSchema = z.object({
398
432
  operation: z.enum(["create", "update", "delete", "getAll", "getOne"]),
399
433
  data: z.object({
@@ -530,6 +564,7 @@ __export(services_exports, {
530
564
  deleteDashboard: () => deleteDashboard,
531
565
  deleteReport: () => deleteReport,
532
566
  deleteUser: () => deleteUser,
567
+ getActions: () => getActions,
533
568
  getAllDashboards: () => getAllDashboards,
534
569
  getAllReports: () => getAllReports,
535
570
  getAllUsers: () => getAllUsers,
@@ -541,6 +576,7 @@ __export(services_exports, {
541
576
  requestData: () => requestData,
542
577
  sendAuthLoginRequest: () => sendAuthLoginRequest,
543
578
  sendAuthVerifyRequest: () => sendAuthVerifyRequest,
579
+ sendComponents: () => sendComponents,
544
580
  sendUserPromptRequest: () => sendUserPromptRequest,
545
581
  sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
546
582
  updateDashboard: () => updateDashboard,
@@ -555,7 +591,7 @@ async function sendAuthLoginRequest(client, loginDataBase64, timeout) {
555
591
  id: messageId,
556
592
  type: "AUTH_LOGIN_REQ",
557
593
  from: {
558
- type: "runtime"
594
+ type: client.type
559
595
  },
560
596
  to: {
561
597
  type: "data-agent"
@@ -565,6 +601,7 @@ async function sendAuthLoginRequest(client, loginDataBase64, timeout) {
565
601
  }
566
602
  });
567
603
  const response = await client.sendWithResponse(message, timeout);
604
+ console.log("sdk auth login response", response);
568
605
  return response;
569
606
  }
570
607
  async function sendAuthVerifyRequest(client, token, timeout) {
@@ -573,7 +610,7 @@ async function sendAuthVerifyRequest(client, token, timeout) {
573
610
  id: messageId,
574
611
  type: "AUTH_VERIFY_REQ",
575
612
  from: {
576
- type: "runtime"
613
+ type: client.type
577
614
  },
578
615
  to: {
579
616
  type: "data-agent"
@@ -593,7 +630,7 @@ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, timeou
593
630
  id: messageId,
594
631
  type: "USER_PROMPT_REQ",
595
632
  from: {
596
- type: "runtime"
633
+ type: client.type
597
634
  },
598
635
  to: {
599
636
  type: "data-agent"
@@ -618,7 +655,7 @@ async function sendUserPromptSuggestionsRequest(client, prompt, limit = 5, timeo
618
655
  id: messageId,
619
656
  type: "USER_PROMPT_SUGGESTIONS_REQ",
620
657
  from: {
621
- type: "runtime"
658
+ type: client.type
622
659
  },
623
660
  to: {
624
661
  type: "data-agent"
@@ -638,7 +675,7 @@ async function requestBundle(client, options) {
638
675
  const message = BundleRequestMessageSchema.parse({
639
676
  id: messageId,
640
677
  type: "BUNDLE_REQ",
641
- from: { type: "runtime" },
678
+ from: { type: client.type },
642
679
  to: { type: "data-agent" },
643
680
  payload: {}
644
681
  });
@@ -686,12 +723,13 @@ async function requestData(client, options) {
686
723
  const message = DataRequestMessageSchema.parse({
687
724
  id: messageId,
688
725
  type: "DATA_REQ",
689
- from: { type: "runtime" },
726
+ from: { type: client.type },
690
727
  to: { type: "data-agent" },
691
728
  payload: {
692
729
  collection: options.collection,
693
730
  op: options.operation,
694
- params: options.params
731
+ params: options.params,
732
+ SA_RUNTIME: options.SA_RUNTIME
695
733
  }
696
734
  });
697
735
  const response = await client.sendWithResponse(message, options.timeout);
@@ -721,6 +759,23 @@ async function getComponentSuggestions(client, query, options) {
721
759
  error: payload.error
722
760
  };
723
761
  }
762
+ async function sendComponents(client, components) {
763
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
764
+ const ws_msg = {
765
+ id: messageId,
766
+ type: "COMPONENT_LIST_RES",
767
+ from: {
768
+ type: client.type
769
+ },
770
+ to: {
771
+ type: "data-agent"
772
+ },
773
+ payload: {
774
+ components
775
+ }
776
+ };
777
+ client.send(ws_msg);
778
+ }
724
779
 
725
780
  // src/services/users.ts
726
781
  async function createUser(client, username, password, timeout) {
@@ -728,7 +783,7 @@ async function createUser(client, username, password, timeout) {
728
783
  const message = UsersRequestMessageSchema.parse({
729
784
  id: messageId,
730
785
  type: "USERS",
731
- from: { type: "admin" },
786
+ from: { type: client.type },
732
787
  to: { type: "data-agent" },
733
788
  payload: {
734
789
  operation: "create",
@@ -752,7 +807,7 @@ async function updateUser(client, username, password, timeout) {
752
807
  const message = UsersRequestMessageSchema.parse({
753
808
  id: messageId,
754
809
  type: "USERS",
755
- from: { type: "admin" },
810
+ from: { type: client.type },
756
811
  to: { type: "data-agent" },
757
812
  payload: {
758
813
  operation: "update",
@@ -776,7 +831,7 @@ async function deleteUser(client, username, timeout) {
776
831
  const message = UsersRequestMessageSchema.parse({
777
832
  id: messageId,
778
833
  type: "USERS",
779
- from: { type: "admin" },
834
+ from: { type: client.type },
780
835
  to: { type: "data-agent" },
781
836
  payload: {
782
837
  operation: "delete",
@@ -799,7 +854,7 @@ async function getAllUsers(client, timeout) {
799
854
  const message = UsersRequestMessageSchema.parse({
800
855
  id: messageId,
801
856
  type: "USERS",
802
- from: { type: "admin" },
857
+ from: { type: client.type },
803
858
  to: { type: "data-agent" },
804
859
  payload: {
805
860
  operation: "getAll"
@@ -820,7 +875,7 @@ async function getUser(client, username, timeout) {
820
875
  const message = UsersRequestMessageSchema.parse({
821
876
  id: messageId,
822
877
  type: "USERS",
823
- from: { type: "admin" },
878
+ from: { type: client.type },
824
879
  to: { type: "data-agent" },
825
880
  payload: {
826
881
  operation: "getOne",
@@ -845,7 +900,7 @@ async function createDashboard(client, dashboardId, dashboard, timeout) {
845
900
  const message = DashboardsRequestMessageSchema.parse({
846
901
  id: messageId,
847
902
  type: "DASHBOARDS",
848
- from: { type: "admin" },
903
+ from: { type: client.type },
849
904
  to: { type: "data-agent" },
850
905
  payload: {
851
906
  operation: "create",
@@ -870,7 +925,7 @@ async function updateDashboard(client, dashboardId, dashboard, timeout) {
870
925
  const message = DashboardsRequestMessageSchema.parse({
871
926
  id: messageId,
872
927
  type: "DASHBOARDS",
873
- from: { type: "admin" },
928
+ from: { type: client.type },
874
929
  to: { type: "data-agent" },
875
930
  payload: {
876
931
  operation: "update",
@@ -895,7 +950,7 @@ async function deleteDashboard(client, dashboardId, timeout) {
895
950
  const message = DashboardsRequestMessageSchema.parse({
896
951
  id: messageId,
897
952
  type: "DASHBOARDS",
898
- from: { type: "admin" },
953
+ from: { type: client.type },
899
954
  to: { type: "data-agent" },
900
955
  payload: {
901
956
  operation: "delete",
@@ -918,7 +973,7 @@ async function getAllDashboards(client, timeout) {
918
973
  const message = DashboardsRequestMessageSchema.parse({
919
974
  id: messageId,
920
975
  type: "DASHBOARDS",
921
- from: { type: "admin" },
976
+ from: { type: client.type },
922
977
  to: { type: "data-agent" },
923
978
  payload: {
924
979
  operation: "getAll"
@@ -939,7 +994,7 @@ async function getDashboard(client, dashboardId, timeout) {
939
994
  const message = DashboardsRequestMessageSchema.parse({
940
995
  id: messageId,
941
996
  type: "DASHBOARDS",
942
- from: { type: "admin" },
997
+ from: { type: client.type },
943
998
  to: { type: "data-agent" },
944
999
  payload: {
945
1000
  operation: "getOne",
@@ -965,7 +1020,7 @@ async function createReport(client, reportId, report, timeout) {
965
1020
  const message = ReportsRequestMessageSchema.parse({
966
1021
  id: messageId,
967
1022
  type: "REPORTS",
968
- from: { type: "admin" },
1023
+ from: { type: client.type },
969
1024
  to: { type: "data-agent" },
970
1025
  payload: {
971
1026
  operation: "create",
@@ -990,7 +1045,7 @@ async function updateReport(client, reportId, report, timeout) {
990
1045
  const message = ReportsRequestMessageSchema.parse({
991
1046
  id: messageId,
992
1047
  type: "REPORTS",
993
- from: { type: "admin" },
1048
+ from: { type: client.type },
994
1049
  to: { type: "data-agent" },
995
1050
  payload: {
996
1051
  operation: "update",
@@ -1015,7 +1070,7 @@ async function deleteReport(client, reportId, timeout) {
1015
1070
  const message = ReportsRequestMessageSchema.parse({
1016
1071
  id: messageId,
1017
1072
  type: "REPORTS",
1018
- from: { type: "admin" },
1073
+ from: { type: client.type },
1019
1074
  to: { type: "data-agent" },
1020
1075
  payload: {
1021
1076
  operation: "delete",
@@ -1038,7 +1093,7 @@ async function getAllReports(client, timeout) {
1038
1093
  const message = ReportsRequestMessageSchema.parse({
1039
1094
  id: messageId,
1040
1095
  type: "REPORTS",
1041
- from: { type: "admin" },
1096
+ from: { type: client.type },
1042
1097
  to: { type: "data-agent" },
1043
1098
  payload: {
1044
1099
  operation: "getAll"
@@ -1059,7 +1114,7 @@ async function getReport(client, reportId, timeout) {
1059
1114
  const message = ReportsRequestMessageSchema.parse({
1060
1115
  id: messageId,
1061
1116
  type: "REPORTS",
1062
- from: { type: "admin" },
1117
+ from: { type: client.type },
1063
1118
  to: { type: "data-agent" },
1064
1119
  payload: {
1065
1120
  operation: "getOne",
@@ -1079,6 +1134,27 @@ async function getReport(client, reportId, timeout) {
1079
1134
  };
1080
1135
  }
1081
1136
 
1137
+ // src/services/actions.ts
1138
+ async function getActions(client, options) {
1139
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
1140
+ const message = ActionsRequestMessageSchema.parse({
1141
+ id: messageId,
1142
+ type: "ACTIONS",
1143
+ from: { type: client.type },
1144
+ to: { type: "data-agent" },
1145
+ payload: {
1146
+ SA_RUNTIME: options.SA_RUNTIME
1147
+ }
1148
+ });
1149
+ const response = await client.sendWithResponse(message, options.timeout);
1150
+ const payload = response.payload;
1151
+ return {
1152
+ success: payload.success,
1153
+ data: payload.data,
1154
+ error: payload.error
1155
+ };
1156
+ }
1157
+
1082
1158
  // src/client.ts
1083
1159
  var SuperatomClient = class {
1084
1160
  constructor(config) {
@@ -1252,7 +1328,7 @@ var SuperatomClient = class {
1252
1328
  }
1253
1329
  const fullMessage = {
1254
1330
  ...message,
1255
- from: message.from || { type: "runtime" }
1331
+ from: message.from || { type: this.config.type }
1256
1332
  };
1257
1333
  try {
1258
1334
  this.socket.send(JSON.stringify(fullMessage));
@@ -1330,6 +1406,12 @@ var SuperatomClient = class {
1330
1406
  getReconnectAttempts() {
1331
1407
  return this.reconnectAttempts;
1332
1408
  }
1409
+ /**
1410
+ * Get client type
1411
+ */
1412
+ get type() {
1413
+ return this.config.type;
1414
+ }
1333
1415
  /**
1334
1416
  * Send a message and wait for response with timeout (alias for sendWithResponse)
1335
1417
  */
@@ -1394,6 +1476,18 @@ var SuperatomClient = class {
1394
1476
  this.log("info", "Requesting component suggestions for query:", query);
1395
1477
  return getComponentSuggestions(this, query, options);
1396
1478
  }
1479
+ /**
1480
+ * Get AI-powered component suggestions based on a query
1481
+ * Delegates to component service
1482
+ */
1483
+ async getActions(options) {
1484
+ this.log("info", "Requesting actions");
1485
+ return getActions(this, options);
1486
+ }
1487
+ async sendComponents(components) {
1488
+ this.log("info", "Sending components");
1489
+ return sendComponents(this, components);
1490
+ }
1397
1491
  // ==================== User Management Methods ====================
1398
1492
  // These methods delegate to user service for admin user CRUD operations
1399
1493
  /**
@@ -1565,6 +1659,6 @@ function hasComponents() {
1565
1659
  // src/index.ts
1566
1660
  var SDK_VERSION = "0.1.0";
1567
1661
 
1568
- export { AuthLoginPayloadSchema, AuthLoginRequestMessageSchema, AuthLoginResponseMessageSchema, AuthLoginResponsePayloadSchema, AuthVerifyPayloadSchema, AuthVerifyRequestMessageSchema, AuthVerifyResponseMessageSchema, AuthVerifyResponsePayloadSchema, BundleChunkMessageSchema, BundleChunkPayloadSchema, BundleErrorMessageSchema, BundleErrorPayloadSchema, BundleRequestMessageSchema, BundleRequestPayloadSchema, ClientConfigSchema, ComponentSchema, DataRequestMessageSchema, DataRequestPayloadSchema, DataResponseMessageSchema, DataResponsePayloadSchema, MessageParticipantSchema, MessageSchema, SDK_VERSION, SuperatomClient, UILogEntrySchema, UILogsMessageSchema, UILogsPayloadSchema, UserPromptRequestMessageSchema, UserPromptRequestPayloadSchema, UserPromptResponseMessageSchema, UserPromptResponsePayloadSchema, UserPromptSuggestionsRequestMessageSchema, UserPromptSuggestionsRequestPayloadSchema, UserPromptSuggestionsResponseMessageSchema, UserPromptSuggestionsResponsePayloadSchema, getComponent, getComponents, hasComponents, services_exports as services, setup };
1662
+ export { ActionsRequestMessageSchema, ActionsRequestPayloadSchema, ActionsResponseMessageSchema, ActionsResponsePayloadSchema, AuthLoginPayloadSchema, AuthLoginRequestMessageSchema, AuthLoginResponseMessageSchema, AuthLoginResponsePayloadSchema, AuthVerifyPayloadSchema, AuthVerifyRequestMessageSchema, AuthVerifyResponseMessageSchema, AuthVerifyResponsePayloadSchema, BundleChunkMessageSchema, BundleChunkPayloadSchema, BundleErrorMessageSchema, BundleErrorPayloadSchema, BundleRequestMessageSchema, BundleRequestPayloadSchema, ClientConfigSchema, ComponentSchema, ComponentsSendMessageSchema, ComponentsSendPayloadSchema, DataRequestMessageSchema, DataRequestPayloadSchema, DataResponseMessageSchema, DataResponsePayloadSchema, MessageParticipantSchema, MessageSchema, SDK_VERSION, SuperatomClient, UILogEntrySchema, UILogsMessageSchema, UILogsPayloadSchema, UserPromptRequestMessageSchema, UserPromptRequestPayloadSchema, UserPromptResponseMessageSchema, UserPromptResponsePayloadSchema, UserPromptSuggestionsRequestMessageSchema, UserPromptSuggestionsRequestPayloadSchema, UserPromptSuggestionsResponseMessageSchema, UserPromptSuggestionsResponsePayloadSchema, getComponent, getComponents, hasComponents, services_exports as services, setup };
1569
1663
  //# sourceMappingURL=index.js.map
1570
1664
  //# sourceMappingURL=index.js.map