@superatomai/sdk-web 0.0.7 → 0.0.9

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.d.cts CHANGED
@@ -300,6 +300,10 @@ declare const UserPromptRequestPayloadSchema: z.ZodObject<{
300
300
  threadId: z.ZodString;
301
301
  uiBlockId: z.ZodString;
302
302
  }, z.core.$strip>>;
303
+ responseMode: z.ZodOptional<z.ZodEnum<{
304
+ component: "component";
305
+ text: "text";
306
+ }>>;
303
307
  }, z.core.$strip>;
304
308
  type UserPromptRequestPayload = z.infer<typeof UserPromptRequestPayloadSchema>;
305
309
  /**
@@ -323,6 +327,10 @@ declare const UserPromptRequestMessageSchema: z.ZodObject<{
323
327
  threadId: z.ZodString;
324
328
  uiBlockId: z.ZodString;
325
329
  }, z.core.$strip>>;
330
+ responseMode: z.ZodOptional<z.ZodEnum<{
331
+ component: "component";
332
+ text: "text";
333
+ }>>;
326
334
  }, z.core.$strip>;
327
335
  }, z.core.$strip>;
328
336
  type UserPromptRequestMessage = z.infer<typeof UserPromptRequestMessageSchema>;
@@ -868,10 +876,12 @@ declare function sendAuthVerifyRequest(client: SuperatomClient, token: string, t
868
876
  * @param prompt - User's prompt text
869
877
  * @param threadId - Thread ID for conversation context
870
878
  * @param uiBlockId - UI block ID for context
879
+ * @param responseMode - 'component' for component response (default), 'text' for text streaming
880
+ * @param onStream - Optional callback for streaming text chunks (only for text mode)
871
881
  * @param timeout - Request timeout in milliseconds
872
882
  * @returns Server response message
873
883
  */
874
- declare function sendUserPromptRequest(client: SuperatomClient, prompt: string, threadId: string, uiBlockId: string, timeout?: number): Promise<Message>;
884
+ declare function sendUserPromptRequest(client: SuperatomClient, prompt: string, threadId: string, uiBlockId: string, responseMode?: 'component' | 'text', onStream?: (chunk: string) => void, timeout?: number): Promise<Message>;
875
885
  /**
876
886
  * Send a user prompt suggestions request
877
887
  * @param client - SuperatomClient instance
@@ -961,6 +971,9 @@ declare function sendComponents(client: SuperatomClient, components: any[]): Pro
961
971
  */
962
972
  interface User {
963
973
  username: string;
974
+ email?: string;
975
+ fullname?: string;
976
+ role?: string;
964
977
  wsIds: string[];
965
978
  }
966
979
  /**
@@ -968,28 +981,42 @@ interface User {
968
981
  * @param client - SuperatomClient instance
969
982
  * @param username - Username for the new user
970
983
  * @param password - Password for the new user
984
+ * @param email - Email for the new user (optional)
985
+ * @param fullname - Full name for the new user (optional)
986
+ * @param role - Role for the new user (optional)
971
987
  * @param timeout - Request timeout in milliseconds
972
988
  * @returns Server response with success status
973
989
  */
974
- declare function createUser(client: SuperatomClient, username: string, password: string, timeout?: number): Promise<{
990
+ declare function createUser(client: SuperatomClient, username: string, password: string, email?: string, fullname?: string, role?: string, timeout?: number): Promise<{
975
991
  success: boolean;
976
992
  error?: string;
977
993
  message?: string;
978
994
  username?: string;
995
+ email?: string;
996
+ fullname?: string;
997
+ role?: string;
979
998
  }>;
980
999
  /**
981
1000
  * Update an existing user
982
1001
  * @param client - SuperatomClient instance
983
1002
  * @param username - Username to update
984
- * @param password - New password for the user
1003
+ * @param updates - Object containing fields to update (password, email, fullname, role)
985
1004
  * @param timeout - Request timeout in milliseconds
986
1005
  * @returns Server response with success status
987
1006
  */
988
- declare function updateUser(client: SuperatomClient, username: string, password: string, timeout?: number): Promise<{
1007
+ declare function updateUser(client: SuperatomClient, username: string, updates: {
1008
+ password?: string;
1009
+ email?: string;
1010
+ fullname?: string;
1011
+ role?: string;
1012
+ }, timeout?: number): Promise<{
989
1013
  success: boolean;
990
1014
  error?: string;
991
1015
  message?: string;
992
1016
  username?: string;
1017
+ email?: string;
1018
+ fullname?: string;
1019
+ role?: string;
993
1020
  }>;
994
1021
  /**
995
1022
  * Delete a user
@@ -1003,6 +1030,9 @@ declare function deleteUser(client: SuperatomClient, username: string, timeout?:
1003
1030
  error?: string;
1004
1031
  message?: string;
1005
1032
  username?: string;
1033
+ email?: string;
1034
+ fullname?: string;
1035
+ role?: string;
1006
1036
  }>;
1007
1037
  /**
1008
1038
  * Get all users
@@ -1383,8 +1413,10 @@ declare class SuperatomClient {
1383
1413
  /**
1384
1414
  * Send a user prompt request
1385
1415
  * Delegates to user prompt service
1416
+ * @param responseMode - 'component' for component response (default), 'text' for text streaming
1417
+ * @param onStream - Optional callback for streaming text chunks (only for text mode)
1386
1418
  */
1387
- sendUserPromptRequest(prompt: string, threadId: string, uiBlockId: string, timeout?: number): Promise<Message>;
1419
+ sendUserPromptRequest(prompt: string, threadId: string, uiBlockId: string, responseMode?: 'component' | 'text', onStream?: (chunk: string) => void, timeout?: number): Promise<Message>;
1388
1420
  /**
1389
1421
  * Send a user prompt suggestions request
1390
1422
  * Delegates to user prompt service
@@ -1442,21 +1474,32 @@ declare class SuperatomClient {
1442
1474
  * Create a new user
1443
1475
  * Delegates to users service
1444
1476
  */
1445
- createUser(username: string, password: string, timeout?: number): Promise<{
1477
+ createUser(username: string, password: string, email?: string, fullname?: string, role?: string, timeout?: number): Promise<{
1446
1478
  success: boolean;
1447
1479
  error?: string;
1448
1480
  message?: string;
1449
1481
  username?: string;
1482
+ email?: string;
1483
+ fullname?: string;
1484
+ role?: string;
1450
1485
  }>;
1451
1486
  /**
1452
1487
  * Update an existing user
1453
1488
  * Delegates to users service
1454
1489
  */
1455
- updateUser(username: string, password: string, timeout?: number): Promise<{
1490
+ updateUser(username: string, updates: {
1491
+ password?: string;
1492
+ email?: string;
1493
+ fullname?: string;
1494
+ role?: string;
1495
+ }, timeout?: number): Promise<{
1456
1496
  success: boolean;
1457
1497
  error?: string;
1458
1498
  message?: string;
1459
1499
  username?: string;
1500
+ email?: string;
1501
+ fullname?: string;
1502
+ role?: string;
1460
1503
  }>;
1461
1504
  /**
1462
1505
  * Delete a user
@@ -1467,6 +1510,9 @@ declare class SuperatomClient {
1467
1510
  error?: string;
1468
1511
  message?: string;
1469
1512
  username?: string;
1513
+ email?: string;
1514
+ fullname?: string;
1515
+ role?: string;
1470
1516
  }>;
1471
1517
  /**
1472
1518
  * Get all users
package/dist/index.d.ts CHANGED
@@ -300,6 +300,10 @@ declare const UserPromptRequestPayloadSchema: z.ZodObject<{
300
300
  threadId: z.ZodString;
301
301
  uiBlockId: z.ZodString;
302
302
  }, z.core.$strip>>;
303
+ responseMode: z.ZodOptional<z.ZodEnum<{
304
+ component: "component";
305
+ text: "text";
306
+ }>>;
303
307
  }, z.core.$strip>;
304
308
  type UserPromptRequestPayload = z.infer<typeof UserPromptRequestPayloadSchema>;
305
309
  /**
@@ -323,6 +327,10 @@ declare const UserPromptRequestMessageSchema: z.ZodObject<{
323
327
  threadId: z.ZodString;
324
328
  uiBlockId: z.ZodString;
325
329
  }, z.core.$strip>>;
330
+ responseMode: z.ZodOptional<z.ZodEnum<{
331
+ component: "component";
332
+ text: "text";
333
+ }>>;
326
334
  }, z.core.$strip>;
327
335
  }, z.core.$strip>;
328
336
  type UserPromptRequestMessage = z.infer<typeof UserPromptRequestMessageSchema>;
@@ -868,10 +876,12 @@ declare function sendAuthVerifyRequest(client: SuperatomClient, token: string, t
868
876
  * @param prompt - User's prompt text
869
877
  * @param threadId - Thread ID for conversation context
870
878
  * @param uiBlockId - UI block ID for context
879
+ * @param responseMode - 'component' for component response (default), 'text' for text streaming
880
+ * @param onStream - Optional callback for streaming text chunks (only for text mode)
871
881
  * @param timeout - Request timeout in milliseconds
872
882
  * @returns Server response message
873
883
  */
874
- declare function sendUserPromptRequest(client: SuperatomClient, prompt: string, threadId: string, uiBlockId: string, timeout?: number): Promise<Message>;
884
+ declare function sendUserPromptRequest(client: SuperatomClient, prompt: string, threadId: string, uiBlockId: string, responseMode?: 'component' | 'text', onStream?: (chunk: string) => void, timeout?: number): Promise<Message>;
875
885
  /**
876
886
  * Send a user prompt suggestions request
877
887
  * @param client - SuperatomClient instance
@@ -961,6 +971,9 @@ declare function sendComponents(client: SuperatomClient, components: any[]): Pro
961
971
  */
962
972
  interface User {
963
973
  username: string;
974
+ email?: string;
975
+ fullname?: string;
976
+ role?: string;
964
977
  wsIds: string[];
965
978
  }
966
979
  /**
@@ -968,28 +981,42 @@ interface User {
968
981
  * @param client - SuperatomClient instance
969
982
  * @param username - Username for the new user
970
983
  * @param password - Password for the new user
984
+ * @param email - Email for the new user (optional)
985
+ * @param fullname - Full name for the new user (optional)
986
+ * @param role - Role for the new user (optional)
971
987
  * @param timeout - Request timeout in milliseconds
972
988
  * @returns Server response with success status
973
989
  */
974
- declare function createUser(client: SuperatomClient, username: string, password: string, timeout?: number): Promise<{
990
+ declare function createUser(client: SuperatomClient, username: string, password: string, email?: string, fullname?: string, role?: string, timeout?: number): Promise<{
975
991
  success: boolean;
976
992
  error?: string;
977
993
  message?: string;
978
994
  username?: string;
995
+ email?: string;
996
+ fullname?: string;
997
+ role?: string;
979
998
  }>;
980
999
  /**
981
1000
  * Update an existing user
982
1001
  * @param client - SuperatomClient instance
983
1002
  * @param username - Username to update
984
- * @param password - New password for the user
1003
+ * @param updates - Object containing fields to update (password, email, fullname, role)
985
1004
  * @param timeout - Request timeout in milliseconds
986
1005
  * @returns Server response with success status
987
1006
  */
988
- declare function updateUser(client: SuperatomClient, username: string, password: string, timeout?: number): Promise<{
1007
+ declare function updateUser(client: SuperatomClient, username: string, updates: {
1008
+ password?: string;
1009
+ email?: string;
1010
+ fullname?: string;
1011
+ role?: string;
1012
+ }, timeout?: number): Promise<{
989
1013
  success: boolean;
990
1014
  error?: string;
991
1015
  message?: string;
992
1016
  username?: string;
1017
+ email?: string;
1018
+ fullname?: string;
1019
+ role?: string;
993
1020
  }>;
994
1021
  /**
995
1022
  * Delete a user
@@ -1003,6 +1030,9 @@ declare function deleteUser(client: SuperatomClient, username: string, timeout?:
1003
1030
  error?: string;
1004
1031
  message?: string;
1005
1032
  username?: string;
1033
+ email?: string;
1034
+ fullname?: string;
1035
+ role?: string;
1006
1036
  }>;
1007
1037
  /**
1008
1038
  * Get all users
@@ -1383,8 +1413,10 @@ declare class SuperatomClient {
1383
1413
  /**
1384
1414
  * Send a user prompt request
1385
1415
  * Delegates to user prompt service
1416
+ * @param responseMode - 'component' for component response (default), 'text' for text streaming
1417
+ * @param onStream - Optional callback for streaming text chunks (only for text mode)
1386
1418
  */
1387
- sendUserPromptRequest(prompt: string, threadId: string, uiBlockId: string, timeout?: number): Promise<Message>;
1419
+ sendUserPromptRequest(prompt: string, threadId: string, uiBlockId: string, responseMode?: 'component' | 'text', onStream?: (chunk: string) => void, timeout?: number): Promise<Message>;
1388
1420
  /**
1389
1421
  * Send a user prompt suggestions request
1390
1422
  * Delegates to user prompt service
@@ -1442,21 +1474,32 @@ declare class SuperatomClient {
1442
1474
  * Create a new user
1443
1475
  * Delegates to users service
1444
1476
  */
1445
- createUser(username: string, password: string, timeout?: number): Promise<{
1477
+ createUser(username: string, password: string, email?: string, fullname?: string, role?: string, timeout?: number): Promise<{
1446
1478
  success: boolean;
1447
1479
  error?: string;
1448
1480
  message?: string;
1449
1481
  username?: string;
1482
+ email?: string;
1483
+ fullname?: string;
1484
+ role?: string;
1450
1485
  }>;
1451
1486
  /**
1452
1487
  * Update an existing user
1453
1488
  * Delegates to users service
1454
1489
  */
1455
- updateUser(username: string, password: string, timeout?: number): Promise<{
1490
+ updateUser(username: string, updates: {
1491
+ password?: string;
1492
+ email?: string;
1493
+ fullname?: string;
1494
+ role?: string;
1495
+ }, timeout?: number): Promise<{
1456
1496
  success: boolean;
1457
1497
  error?: string;
1458
1498
  message?: string;
1459
1499
  username?: string;
1500
+ email?: string;
1501
+ fullname?: string;
1502
+ role?: string;
1460
1503
  }>;
1461
1504
  /**
1462
1505
  * Delete a user
@@ -1467,6 +1510,9 @@ declare class SuperatomClient {
1467
1510
  error?: string;
1468
1511
  message?: string;
1469
1512
  username?: string;
1513
+ email?: string;
1514
+ fullname?: string;
1515
+ role?: string;
1470
1516
  }>;
1471
1517
  /**
1472
1518
  * Get all users
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(),
@@ -432,7 +433,10 @@ var UsersRequestPayloadSchema = z.object({
432
433
  operation: z.enum(["create", "update", "delete", "getAll", "getOne"]),
433
434
  data: z.object({
434
435
  username: z.string().optional(),
435
- password: z.string().optional()
436
+ email: z.string().email("Invalid email format").optional(),
437
+ password: z.string().optional(),
438
+ fullname: z.string().optional(),
439
+ role: z.string().optional()
436
440
  }).optional()
437
441
  });
438
442
  var UsersRequestMessageSchema = z.object({
@@ -447,13 +451,22 @@ var UsersResponsePayloadSchema = z.object({
447
451
  error: z.string().optional(),
448
452
  data: z.object({
449
453
  username: z.string().optional(),
454
+ email: z.string().optional(),
455
+ fullname: z.string().optional(),
456
+ role: z.string().optional(),
450
457
  message: z.string().optional(),
451
458
  users: z.array(z.object({
452
459
  username: z.string(),
460
+ email: z.string().optional(),
461
+ fullname: z.string().optional(),
462
+ role: z.string().optional(),
453
463
  wsIds: z.array(z.string())
454
464
  })).optional(),
455
465
  user: z.object({
456
466
  username: z.string(),
467
+ email: z.string().optional(),
468
+ fullname: z.string().optional(),
469
+ role: z.string().optional(),
457
470
  wsIds: z.array(z.string())
458
471
  }).optional(),
459
472
  count: z.number().optional()
@@ -624,8 +637,8 @@ async function sendAuthVerifyRequest(client, token, timeout) {
624
637
  }
625
638
 
626
639
  // src/services/userPrompt.ts
627
- async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, timeout) {
628
- const messageId = `msg_${Date.now()}`;
640
+ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, responseMode, onStream, timeout) {
641
+ const messageId = `user_prompt_req_msg_${Date.now()}`;
629
642
  const message = UserPromptRequestMessageSchema.parse({
630
643
  id: messageId,
631
644
  type: "USER_PROMPT_REQ",
@@ -640,11 +653,29 @@ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, timeou
640
653
  SA_RUNTIME: {
641
654
  threadId,
642
655
  uiBlockId
643
- }
656
+ },
657
+ responseMode
644
658
  }
645
659
  });
646
- const response = await client.sendWithResponse(message, timeout);
647
- return response;
660
+ let streamUnsubscribe = null;
661
+ if (responseMode === "text" && onStream) {
662
+ streamUnsubscribe = client.onMessage((msg) => {
663
+ if (msg.type === "USER_PROMPT_STREAM" && msg.id === `stream_${uiBlockId}`) {
664
+ const chunk = msg.payload?.chunk;
665
+ if (chunk) {
666
+ onStream(chunk);
667
+ }
668
+ }
669
+ });
670
+ }
671
+ try {
672
+ const response = await client.sendWithResponse(message, timeout);
673
+ return response;
674
+ } finally {
675
+ if (streamUnsubscribe) {
676
+ streamUnsubscribe();
677
+ }
678
+ }
648
679
  }
649
680
  async function sendUserPromptSuggestionsRequest(client, prompt, limit = 5, timeout) {
650
681
  if (!prompt || prompt.trim().length === 0) {
@@ -778,7 +809,7 @@ async function sendComponents(client, components) {
778
809
  }
779
810
 
780
811
  // src/services/users.ts
781
- async function createUser(client, username, password, timeout) {
812
+ async function createUser(client, username, password, email, fullname, role, timeout) {
782
813
  const messageId = `users_create_${Date.now()}`;
783
814
  const message = UsersRequestMessageSchema.parse({
784
815
  id: messageId,
@@ -789,7 +820,10 @@ async function createUser(client, username, password, timeout) {
789
820
  operation: "create",
790
821
  data: {
791
822
  username,
792
- password
823
+ password,
824
+ email,
825
+ fullname,
826
+ role
793
827
  }
794
828
  }
795
829
  });
@@ -799,10 +833,13 @@ async function createUser(client, username, password, timeout) {
799
833
  success: payload.success,
800
834
  error: payload.error,
801
835
  message: payload.data?.message,
802
- username: payload.data?.username
836
+ username: payload.data?.username,
837
+ email: payload.data?.email,
838
+ fullname: payload.data?.fullname,
839
+ role: payload.data?.role
803
840
  };
804
841
  }
805
- async function updateUser(client, username, password, timeout) {
842
+ async function updateUser(client, username, updates, timeout) {
806
843
  const messageId = `users_update_${Date.now()}`;
807
844
  const message = UsersRequestMessageSchema.parse({
808
845
  id: messageId,
@@ -813,7 +850,7 @@ async function updateUser(client, username, password, timeout) {
813
850
  operation: "update",
814
851
  data: {
815
852
  username,
816
- password
853
+ ...updates
817
854
  }
818
855
  }
819
856
  });
@@ -823,7 +860,10 @@ async function updateUser(client, username, password, timeout) {
823
860
  success: payload.success,
824
861
  error: payload.error,
825
862
  message: payload.data?.message,
826
- username: payload.data?.username
863
+ username: payload.data?.username,
864
+ email: payload.data?.email,
865
+ fullname: payload.data?.fullname,
866
+ role: payload.data?.role
827
867
  };
828
868
  }
829
869
  async function deleteUser(client, username, timeout) {
@@ -846,7 +886,10 @@ async function deleteUser(client, username, timeout) {
846
886
  success: payload.success,
847
887
  error: payload.error,
848
888
  message: payload.data?.message,
849
- username: payload.data?.username
889
+ username: payload.data?.username,
890
+ email: payload.data?.email,
891
+ fullname: payload.data?.fullname,
892
+ role: payload.data?.role
850
893
  };
851
894
  }
852
895
  async function getAllUsers(client, timeout) {
@@ -1439,10 +1482,12 @@ var SuperatomClient = class {
1439
1482
  /**
1440
1483
  * Send a user prompt request
1441
1484
  * Delegates to user prompt service
1485
+ * @param responseMode - 'component' for component response (default), 'text' for text streaming
1486
+ * @param onStream - Optional callback for streaming text chunks (only for text mode)
1442
1487
  */
1443
- async sendUserPromptRequest(prompt, threadId, uiBlockId, timeout) {
1444
- this.log("info", "Sending user prompt request");
1445
- return sendUserPromptRequest(this, prompt, threadId, uiBlockId, timeout);
1488
+ async sendUserPromptRequest(prompt, threadId, uiBlockId, responseMode, onStream, timeout) {
1489
+ this.log("info", "Sending user prompt request with streaming support");
1490
+ return sendUserPromptRequest(this, prompt, threadId, uiBlockId, responseMode, onStream, timeout);
1446
1491
  }
1447
1492
  /**
1448
1493
  * Send a user prompt suggestions request
@@ -1494,17 +1539,17 @@ var SuperatomClient = class {
1494
1539
  * Create a new user
1495
1540
  * Delegates to users service
1496
1541
  */
1497
- async createUser(username, password, timeout) {
1542
+ async createUser(username, password, email, fullname, role, timeout) {
1498
1543
  this.log("info", "Creating user:", username);
1499
- return createUser(this, username, password, timeout);
1544
+ return createUser(this, username, password, email, fullname, role, timeout);
1500
1545
  }
1501
1546
  /**
1502
1547
  * Update an existing user
1503
1548
  * Delegates to users service
1504
1549
  */
1505
- async updateUser(username, password, timeout) {
1550
+ async updateUser(username, updates, timeout) {
1506
1551
  this.log("info", "Updating user:", username);
1507
- return updateUser(this, username, password, timeout);
1552
+ return updateUser(this, username, updates, timeout);
1508
1553
  }
1509
1554
  /**
1510
1555
  * Delete a user