@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.cjs CHANGED
@@ -396,6 +396,40 @@ var UILogsMessageSchema = zod.z.object({
396
396
  to: MessageParticipantSchema.optional(),
397
397
  payload: UILogsPayloadSchema
398
398
  });
399
+ var ActionsRequestPayloadSchema = zod.z.object({
400
+ SA_RUNTIME: zod.z.object({
401
+ threadId: zod.z.string(),
402
+ uiBlockId: zod.z.string()
403
+ }).optional()
404
+ });
405
+ var ActionsRequestMessageSchema = zod.z.object({
406
+ id: zod.z.string(),
407
+ from: MessageParticipantSchema,
408
+ type: zod.z.literal("ACTIONS"),
409
+ payload: ActionsRequestPayloadSchema
410
+ });
411
+ var ActionsResponsePayloadSchema = zod.z.object({
412
+ success: zod.z.boolean(),
413
+ data: zod.z.any().optional(),
414
+ error: zod.z.string().optional()
415
+ });
416
+ var ActionsResponseMessageSchema = zod.z.object({
417
+ id: zod.z.string(),
418
+ type: zod.z.literal("ACTIONS_RES"),
419
+ from: MessageParticipantSchema,
420
+ to: MessageParticipantSchema.optional(),
421
+ payload: ActionsResponsePayloadSchema
422
+ });
423
+ var ComponentsSendPayloadSchema = zod.z.object({
424
+ components: zod.z.array(zod.z.any())
425
+ });
426
+ var ComponentsSendMessageSchema = zod.z.object({
427
+ id: zod.z.string(),
428
+ type: zod.z.literal("COMPONENT_LIST_RES"),
429
+ from: MessageParticipantSchema,
430
+ to: MessageParticipantSchema.optional(),
431
+ payload: ComponentsSendPayloadSchema
432
+ });
399
433
  var UsersRequestPayloadSchema = zod.z.object({
400
434
  operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne"]),
401
435
  data: zod.z.object({
@@ -532,6 +566,7 @@ __export(services_exports, {
532
566
  deleteDashboard: () => deleteDashboard,
533
567
  deleteReport: () => deleteReport,
534
568
  deleteUser: () => deleteUser,
569
+ getActions: () => getActions,
535
570
  getAllDashboards: () => getAllDashboards,
536
571
  getAllReports: () => getAllReports,
537
572
  getAllUsers: () => getAllUsers,
@@ -543,6 +578,7 @@ __export(services_exports, {
543
578
  requestData: () => requestData,
544
579
  sendAuthLoginRequest: () => sendAuthLoginRequest,
545
580
  sendAuthVerifyRequest: () => sendAuthVerifyRequest,
581
+ sendComponents: () => sendComponents,
546
582
  sendUserPromptRequest: () => sendUserPromptRequest,
547
583
  sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
548
584
  updateDashboard: () => updateDashboard,
@@ -557,7 +593,7 @@ async function sendAuthLoginRequest(client, loginDataBase64, timeout) {
557
593
  id: messageId,
558
594
  type: "AUTH_LOGIN_REQ",
559
595
  from: {
560
- type: "runtime"
596
+ type: client.type
561
597
  },
562
598
  to: {
563
599
  type: "data-agent"
@@ -567,6 +603,7 @@ async function sendAuthLoginRequest(client, loginDataBase64, timeout) {
567
603
  }
568
604
  });
569
605
  const response = await client.sendWithResponse(message, timeout);
606
+ console.log("sdk auth login response", response);
570
607
  return response;
571
608
  }
572
609
  async function sendAuthVerifyRequest(client, token, timeout) {
@@ -575,7 +612,7 @@ async function sendAuthVerifyRequest(client, token, timeout) {
575
612
  id: messageId,
576
613
  type: "AUTH_VERIFY_REQ",
577
614
  from: {
578
- type: "runtime"
615
+ type: client.type
579
616
  },
580
617
  to: {
581
618
  type: "data-agent"
@@ -595,7 +632,7 @@ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, timeou
595
632
  id: messageId,
596
633
  type: "USER_PROMPT_REQ",
597
634
  from: {
598
- type: "runtime"
635
+ type: client.type
599
636
  },
600
637
  to: {
601
638
  type: "data-agent"
@@ -620,7 +657,7 @@ async function sendUserPromptSuggestionsRequest(client, prompt, limit = 5, timeo
620
657
  id: messageId,
621
658
  type: "USER_PROMPT_SUGGESTIONS_REQ",
622
659
  from: {
623
- type: "runtime"
660
+ type: client.type
624
661
  },
625
662
  to: {
626
663
  type: "data-agent"
@@ -640,7 +677,7 @@ async function requestBundle(client, options) {
640
677
  const message = BundleRequestMessageSchema.parse({
641
678
  id: messageId,
642
679
  type: "BUNDLE_REQ",
643
- from: { type: "runtime" },
680
+ from: { type: client.type },
644
681
  to: { type: "data-agent" },
645
682
  payload: {}
646
683
  });
@@ -688,12 +725,13 @@ async function requestData(client, options) {
688
725
  const message = DataRequestMessageSchema.parse({
689
726
  id: messageId,
690
727
  type: "DATA_REQ",
691
- from: { type: "runtime" },
728
+ from: { type: client.type },
692
729
  to: { type: "data-agent" },
693
730
  payload: {
694
731
  collection: options.collection,
695
732
  op: options.operation,
696
- params: options.params
733
+ params: options.params,
734
+ SA_RUNTIME: options.SA_RUNTIME
697
735
  }
698
736
  });
699
737
  const response = await client.sendWithResponse(message, options.timeout);
@@ -723,6 +761,23 @@ async function getComponentSuggestions(client, query, options) {
723
761
  error: payload.error
724
762
  };
725
763
  }
764
+ async function sendComponents(client, components) {
765
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
766
+ const ws_msg = {
767
+ id: messageId,
768
+ type: "COMPONENT_LIST_RES",
769
+ from: {
770
+ type: client.type
771
+ },
772
+ to: {
773
+ type: "data-agent"
774
+ },
775
+ payload: {
776
+ components
777
+ }
778
+ };
779
+ client.send(ws_msg);
780
+ }
726
781
 
727
782
  // src/services/users.ts
728
783
  async function createUser(client, username, password, timeout) {
@@ -730,7 +785,7 @@ async function createUser(client, username, password, timeout) {
730
785
  const message = UsersRequestMessageSchema.parse({
731
786
  id: messageId,
732
787
  type: "USERS",
733
- from: { type: "admin" },
788
+ from: { type: client.type },
734
789
  to: { type: "data-agent" },
735
790
  payload: {
736
791
  operation: "create",
@@ -754,7 +809,7 @@ async function updateUser(client, username, password, timeout) {
754
809
  const message = UsersRequestMessageSchema.parse({
755
810
  id: messageId,
756
811
  type: "USERS",
757
- from: { type: "admin" },
812
+ from: { type: client.type },
758
813
  to: { type: "data-agent" },
759
814
  payload: {
760
815
  operation: "update",
@@ -778,7 +833,7 @@ async function deleteUser(client, username, timeout) {
778
833
  const message = UsersRequestMessageSchema.parse({
779
834
  id: messageId,
780
835
  type: "USERS",
781
- from: { type: "admin" },
836
+ from: { type: client.type },
782
837
  to: { type: "data-agent" },
783
838
  payload: {
784
839
  operation: "delete",
@@ -801,7 +856,7 @@ async function getAllUsers(client, timeout) {
801
856
  const message = UsersRequestMessageSchema.parse({
802
857
  id: messageId,
803
858
  type: "USERS",
804
- from: { type: "admin" },
859
+ from: { type: client.type },
805
860
  to: { type: "data-agent" },
806
861
  payload: {
807
862
  operation: "getAll"
@@ -822,7 +877,7 @@ async function getUser(client, username, timeout) {
822
877
  const message = UsersRequestMessageSchema.parse({
823
878
  id: messageId,
824
879
  type: "USERS",
825
- from: { type: "admin" },
880
+ from: { type: client.type },
826
881
  to: { type: "data-agent" },
827
882
  payload: {
828
883
  operation: "getOne",
@@ -847,7 +902,7 @@ async function createDashboard(client, dashboardId, dashboard, timeout) {
847
902
  const message = DashboardsRequestMessageSchema.parse({
848
903
  id: messageId,
849
904
  type: "DASHBOARDS",
850
- from: { type: "admin" },
905
+ from: { type: client.type },
851
906
  to: { type: "data-agent" },
852
907
  payload: {
853
908
  operation: "create",
@@ -872,7 +927,7 @@ async function updateDashboard(client, dashboardId, dashboard, timeout) {
872
927
  const message = DashboardsRequestMessageSchema.parse({
873
928
  id: messageId,
874
929
  type: "DASHBOARDS",
875
- from: { type: "admin" },
930
+ from: { type: client.type },
876
931
  to: { type: "data-agent" },
877
932
  payload: {
878
933
  operation: "update",
@@ -897,7 +952,7 @@ async function deleteDashboard(client, dashboardId, timeout) {
897
952
  const message = DashboardsRequestMessageSchema.parse({
898
953
  id: messageId,
899
954
  type: "DASHBOARDS",
900
- from: { type: "admin" },
955
+ from: { type: client.type },
901
956
  to: { type: "data-agent" },
902
957
  payload: {
903
958
  operation: "delete",
@@ -920,7 +975,7 @@ async function getAllDashboards(client, timeout) {
920
975
  const message = DashboardsRequestMessageSchema.parse({
921
976
  id: messageId,
922
977
  type: "DASHBOARDS",
923
- from: { type: "admin" },
978
+ from: { type: client.type },
924
979
  to: { type: "data-agent" },
925
980
  payload: {
926
981
  operation: "getAll"
@@ -941,7 +996,7 @@ async function getDashboard(client, dashboardId, timeout) {
941
996
  const message = DashboardsRequestMessageSchema.parse({
942
997
  id: messageId,
943
998
  type: "DASHBOARDS",
944
- from: { type: "admin" },
999
+ from: { type: client.type },
945
1000
  to: { type: "data-agent" },
946
1001
  payload: {
947
1002
  operation: "getOne",
@@ -967,7 +1022,7 @@ async function createReport(client, reportId, report, timeout) {
967
1022
  const message = ReportsRequestMessageSchema.parse({
968
1023
  id: messageId,
969
1024
  type: "REPORTS",
970
- from: { type: "admin" },
1025
+ from: { type: client.type },
971
1026
  to: { type: "data-agent" },
972
1027
  payload: {
973
1028
  operation: "create",
@@ -992,7 +1047,7 @@ async function updateReport(client, reportId, report, timeout) {
992
1047
  const message = ReportsRequestMessageSchema.parse({
993
1048
  id: messageId,
994
1049
  type: "REPORTS",
995
- from: { type: "admin" },
1050
+ from: { type: client.type },
996
1051
  to: { type: "data-agent" },
997
1052
  payload: {
998
1053
  operation: "update",
@@ -1017,7 +1072,7 @@ async function deleteReport(client, reportId, timeout) {
1017
1072
  const message = ReportsRequestMessageSchema.parse({
1018
1073
  id: messageId,
1019
1074
  type: "REPORTS",
1020
- from: { type: "admin" },
1075
+ from: { type: client.type },
1021
1076
  to: { type: "data-agent" },
1022
1077
  payload: {
1023
1078
  operation: "delete",
@@ -1040,7 +1095,7 @@ async function getAllReports(client, timeout) {
1040
1095
  const message = ReportsRequestMessageSchema.parse({
1041
1096
  id: messageId,
1042
1097
  type: "REPORTS",
1043
- from: { type: "admin" },
1098
+ from: { type: client.type },
1044
1099
  to: { type: "data-agent" },
1045
1100
  payload: {
1046
1101
  operation: "getAll"
@@ -1061,7 +1116,7 @@ async function getReport(client, reportId, timeout) {
1061
1116
  const message = ReportsRequestMessageSchema.parse({
1062
1117
  id: messageId,
1063
1118
  type: "REPORTS",
1064
- from: { type: "admin" },
1119
+ from: { type: client.type },
1065
1120
  to: { type: "data-agent" },
1066
1121
  payload: {
1067
1122
  operation: "getOne",
@@ -1081,6 +1136,27 @@ async function getReport(client, reportId, timeout) {
1081
1136
  };
1082
1137
  }
1083
1138
 
1139
+ // src/services/actions.ts
1140
+ async function getActions(client, options) {
1141
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
1142
+ const message = ActionsRequestMessageSchema.parse({
1143
+ id: messageId,
1144
+ type: "ACTIONS",
1145
+ from: { type: client.type },
1146
+ to: { type: "data-agent" },
1147
+ payload: {
1148
+ SA_RUNTIME: options.SA_RUNTIME
1149
+ }
1150
+ });
1151
+ const response = await client.sendWithResponse(message, options.timeout);
1152
+ const payload = response.payload;
1153
+ return {
1154
+ success: payload.success,
1155
+ data: payload.data,
1156
+ error: payload.error
1157
+ };
1158
+ }
1159
+
1084
1160
  // src/client.ts
1085
1161
  var SuperatomClient = class {
1086
1162
  constructor(config) {
@@ -1254,7 +1330,7 @@ var SuperatomClient = class {
1254
1330
  }
1255
1331
  const fullMessage = {
1256
1332
  ...message,
1257
- from: message.from || { type: "runtime" }
1333
+ from: message.from || { type: this.config.type }
1258
1334
  };
1259
1335
  try {
1260
1336
  this.socket.send(JSON.stringify(fullMessage));
@@ -1332,6 +1408,12 @@ var SuperatomClient = class {
1332
1408
  getReconnectAttempts() {
1333
1409
  return this.reconnectAttempts;
1334
1410
  }
1411
+ /**
1412
+ * Get client type
1413
+ */
1414
+ get type() {
1415
+ return this.config.type;
1416
+ }
1335
1417
  /**
1336
1418
  * Send a message and wait for response with timeout (alias for sendWithResponse)
1337
1419
  */
@@ -1396,6 +1478,18 @@ var SuperatomClient = class {
1396
1478
  this.log("info", "Requesting component suggestions for query:", query);
1397
1479
  return getComponentSuggestions(this, query, options);
1398
1480
  }
1481
+ /**
1482
+ * Get AI-powered component suggestions based on a query
1483
+ * Delegates to component service
1484
+ */
1485
+ async getActions(options) {
1486
+ this.log("info", "Requesting actions");
1487
+ return getActions(this, options);
1488
+ }
1489
+ async sendComponents(components) {
1490
+ this.log("info", "Sending components");
1491
+ return sendComponents(this, components);
1492
+ }
1399
1493
  // ==================== User Management Methods ====================
1400
1494
  // These methods delegate to user service for admin user CRUD operations
1401
1495
  /**
@@ -1567,6 +1661,10 @@ function hasComponents() {
1567
1661
  // src/index.ts
1568
1662
  var SDK_VERSION = "0.1.0";
1569
1663
 
1664
+ exports.ActionsRequestMessageSchema = ActionsRequestMessageSchema;
1665
+ exports.ActionsRequestPayloadSchema = ActionsRequestPayloadSchema;
1666
+ exports.ActionsResponseMessageSchema = ActionsResponseMessageSchema;
1667
+ exports.ActionsResponsePayloadSchema = ActionsResponsePayloadSchema;
1570
1668
  exports.AuthLoginPayloadSchema = AuthLoginPayloadSchema;
1571
1669
  exports.AuthLoginRequestMessageSchema = AuthLoginRequestMessageSchema;
1572
1670
  exports.AuthLoginResponseMessageSchema = AuthLoginResponseMessageSchema;
@@ -1583,6 +1681,8 @@ exports.BundleRequestMessageSchema = BundleRequestMessageSchema;
1583
1681
  exports.BundleRequestPayloadSchema = BundleRequestPayloadSchema;
1584
1682
  exports.ClientConfigSchema = ClientConfigSchema;
1585
1683
  exports.ComponentSchema = ComponentSchema;
1684
+ exports.ComponentsSendMessageSchema = ComponentsSendMessageSchema;
1685
+ exports.ComponentsSendPayloadSchema = ComponentsSendPayloadSchema;
1586
1686
  exports.DataRequestMessageSchema = DataRequestMessageSchema;
1587
1687
  exports.DataRequestPayloadSchema = DataRequestPayloadSchema;
1588
1688
  exports.DataResponseMessageSchema = DataResponseMessageSchema;