@superatomai/sdk-web 0.0.20 → 0.0.22

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
@@ -259,6 +259,7 @@ var AuthVerifyResponseMessageSchema = z.object({
259
259
  });
260
260
  var UserPromptRequestPayloadSchema = z.object({
261
261
  prompt: z.string(),
262
+ userId: z.string().optional(),
262
263
  SA_RUNTIME: z.object({
263
264
  threadId: z.string(),
264
265
  uiBlockId: z.string()
@@ -272,17 +273,18 @@ var UserPromptRequestMessageSchema = z.object({
272
273
  to: MessageParticipantSchema.optional(),
273
274
  payload: UserPromptRequestPayloadSchema
274
275
  });
276
+ var ComponentPropsSchema = z.object({
277
+ query: z.string().or(z.record(z.string(), z.unknown())).optional(),
278
+ title: z.string().optional(),
279
+ description: z.string().optional(),
280
+ config: z.record(z.string(), z.unknown()).optional()
281
+ }).passthrough();
275
282
  var ComponentSchema = z.object({
276
283
  id: z.string(),
277
284
  name: z.string(),
278
285
  type: z.string(),
279
286
  description: z.string(),
280
- props: z.object({
281
- query: z.string().optional(),
282
- title: z.string().optional(),
283
- description: z.string().optional(),
284
- config: z.record(z.string(), z.unknown()).optional()
285
- }),
287
+ props: ComponentPropsSchema,
286
288
  category: z.string().optional(),
287
289
  keywords: z.array(z.string()).optional()
288
290
  });
@@ -304,6 +306,7 @@ var UserPromptResponseMessageSchema = z.object({
304
306
  });
305
307
  var UserPromptSuggestionsRequestPayloadSchema = z.object({
306
308
  prompt: z.string(),
309
+ userId: z.string().optional(),
307
310
  limit: z.number().int().positive().default(5)
308
311
  });
309
312
  var UserPromptSuggestionsRequestMessageSchema = z.object({
@@ -332,10 +335,13 @@ var UserPromptSuggestionsResponseMessageSchema = z.object({
332
335
  });
333
336
  var DashCompRequestPayloadSchema = z.object({
334
337
  prompt: z.string(),
338
+ userId: z.string().optional(),
335
339
  SA_RUNTIME: z.object({
336
340
  threadId: z.string().optional(),
337
341
  uiBlockId: z.string().optional()
338
- }).optional()
342
+ }).optional(),
343
+ existingComponents: z.array(ComponentSchema).optional(),
344
+ req_type: z.enum(["create", "update", "filter"]).optional()
339
345
  });
340
346
  var DashCompRequestMessageSchema = z.object({
341
347
  id: z.string(),
@@ -350,13 +356,24 @@ z.object({
350
356
  action: z.enum(["get", "create", "update", "delete"]),
351
357
  params: z.record(z.string(), z.unknown())
352
358
  });
359
+ z.object({
360
+ filterId: z.string(),
361
+ filterField: z.string(),
362
+ targetComponentId: z.string(),
363
+ targetField: z.string()
364
+ });
353
365
  var DashCompResponsePayloadSchema = z.object({
354
366
  success: z.boolean(),
355
367
  errors: z.array(z.string()).optional(),
356
368
  data: z.object({
369
+ // For create/update requests
357
370
  component: ComponentSchema.optional(),
358
371
  reasoning: z.string().optional(),
359
- dataSource: z.enum(["database", "external_tool", "none"]).optional()
372
+ dataSource: z.enum(["database", "external_tool", "none"]).optional(),
373
+ // For filter requests
374
+ filterComponent: ComponentSchema.optional(),
375
+ updatedComponents: z.array(ComponentSchema).optional(),
376
+ filterBindings: z.record(z.string(), z.unknown()).optional()
360
377
  }).optional()
361
378
  });
362
379
  z.object({
@@ -446,6 +463,7 @@ var UILogsMessageSchema = z.object({
446
463
  payload: UILogsPayloadSchema
447
464
  });
448
465
  var ActionsRequestPayloadSchema = z.object({
466
+ userId: z.string().optional(),
449
467
  SA_RUNTIME: z.object({
450
468
  threadId: z.string(),
451
469
  uiBlockId: z.string()
@@ -957,7 +975,7 @@ async function sendAuthVerifyRequest(client, token, timeout) {
957
975
  }
958
976
 
959
977
  // src/services/userPrompt.ts
960
- async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, responseMode, onStream, timeout) {
978
+ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout) {
961
979
  const messageId = `user_prompt_req_msg_${Date.now()}`;
962
980
  const message = UserPromptRequestMessageSchema.parse({
963
981
  id: messageId,
@@ -970,6 +988,7 @@ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, respon
970
988
  },
971
989
  payload: {
972
990
  prompt,
991
+ userId,
973
992
  SA_RUNTIME: {
974
993
  threadId,
975
994
  uiBlockId
@@ -997,7 +1016,7 @@ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, respon
997
1016
  }
998
1017
  }
999
1018
  }
1000
- async function sendUserPromptSuggestionsRequest(client, prompt, limit = 5, timeout) {
1019
+ async function sendUserPromptSuggestionsRequest(client, prompt, userId, limit = 5, timeout) {
1001
1020
  if (!prompt || prompt.trim().length === 0) {
1002
1021
  return null;
1003
1022
  }
@@ -1013,6 +1032,7 @@ async function sendUserPromptSuggestionsRequest(client, prompt, limit = 5, timeo
1013
1032
  },
1014
1033
  payload: {
1015
1034
  prompt,
1035
+ userId,
1016
1036
  limit
1017
1037
  }
1018
1038
  });
@@ -1772,6 +1792,7 @@ async function getActions(client, options) {
1772
1792
  from: { type: client.type },
1773
1793
  to: { type: "data-agent" },
1774
1794
  payload: {
1795
+ userId: options.userId,
1775
1796
  SA_RUNTIME: options.SA_RUNTIME
1776
1797
  }
1777
1798
  });
@@ -2217,7 +2238,7 @@ async function getKbNodeTags(client, timeout) {
2217
2238
 
2218
2239
  // src/services/dash-comp.ts
2219
2240
  async function sendDashCompRequest(client, options) {
2220
- const { prompt, threadId, uiBlockId, timeout } = options;
2241
+ const { prompt, userId, threadId, uiBlockId, timeout, existingComponents, reqType } = options;
2221
2242
  const messageId = `dash_comp_req_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2222
2243
  const message = DashCompRequestMessageSchema.parse({
2223
2244
  id: messageId,
@@ -2230,10 +2251,13 @@ async function sendDashCompRequest(client, options) {
2230
2251
  },
2231
2252
  payload: {
2232
2253
  prompt,
2254
+ userId,
2233
2255
  SA_RUNTIME: threadId || uiBlockId ? {
2234
2256
  threadId,
2235
2257
  uiBlockId
2236
- } : void 0
2258
+ } : void 0,
2259
+ existingComponents,
2260
+ req_type: reqType
2237
2261
  }
2238
2262
  });
2239
2263
  try {
@@ -2245,6 +2269,15 @@ async function sendDashCompRequest(client, options) {
2245
2269
  errors: payload.errors || ["Unknown error occurred"]
2246
2270
  };
2247
2271
  }
2272
+ if (reqType === "filter") {
2273
+ return {
2274
+ success: true,
2275
+ filterComponent: payload.data?.filterComponent,
2276
+ updatedComponents: payload.data?.updatedComponents,
2277
+ filterBindings: payload.data?.filterBindings,
2278
+ reasoning: payload.data?.reasoning
2279
+ };
2280
+ }
2248
2281
  return {
2249
2282
  success: true,
2250
2283
  component: payload.data?.component,
@@ -2544,20 +2577,22 @@ var SuperatomClient = class {
2544
2577
  /**
2545
2578
  * Send a user prompt request
2546
2579
  * Delegates to user prompt service
2580
+ * @param userId - User ID for the request
2547
2581
  * @param responseMode - 'component' for component response (default), 'text' for text streaming
2548
2582
  * @param onStream - Optional callback for streaming text chunks (only for text mode)
2549
2583
  */
2550
- async sendUserPromptRequest(prompt, threadId, uiBlockId, responseMode, onStream, timeout) {
2584
+ async sendUserPromptRequest(prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout) {
2551
2585
  this.log("info", "Sending user prompt request with streaming support");
2552
- return sendUserPromptRequest(this, prompt, threadId, uiBlockId, responseMode, onStream, timeout);
2586
+ return sendUserPromptRequest(this, prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout);
2553
2587
  }
2554
2588
  /**
2555
2589
  * Send a user prompt suggestions request
2556
2590
  * Delegates to user prompt service
2591
+ * @param userId - User ID for the request
2557
2592
  */
2558
- async sendUserPromptSuggestionsRequest(prompt, limit = 5, timeout) {
2593
+ async sendUserPromptSuggestionsRequest(prompt, userId, limit = 5, timeout) {
2559
2594
  this.log("info", "Sending user prompt suggestions request");
2560
- return sendUserPromptSuggestionsRequest(this, prompt, limit, timeout);
2595
+ return sendUserPromptSuggestionsRequest(this, prompt, userId, limit, timeout);
2561
2596
  }
2562
2597
  /**
2563
2598
  * Request bundle from server
@@ -2586,6 +2621,7 @@ var SuperatomClient = class {
2586
2621
  /**
2587
2622
  * Get AI-powered component suggestions based on a query
2588
2623
  * Delegates to component service
2624
+ * @param userId - User ID for the request
2589
2625
  */
2590
2626
  async getActions(options) {
2591
2627
  this.log("info", "Requesting actions");