@superatomai/sdk-web 0.0.18 → 0.0.19

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
@@ -332,6 +332,42 @@ var UserPromptSuggestionsResponseMessageSchema = zod.z.object({
332
332
  to: MessageParticipantSchema.optional(),
333
333
  payload: UserPromptSuggestionsResponsePayloadSchema
334
334
  });
335
+ var DashCompRequestPayloadSchema = zod.z.object({
336
+ prompt: zod.z.string(),
337
+ SA_RUNTIME: zod.z.object({
338
+ threadId: zod.z.string().optional(),
339
+ uiBlockId: zod.z.string().optional()
340
+ }).optional()
341
+ });
342
+ var DashCompRequestMessageSchema = zod.z.object({
343
+ id: zod.z.string(),
344
+ type: zod.z.literal("DASH_COMP_REQ"),
345
+ from: MessageParticipantSchema,
346
+ to: MessageParticipantSchema.optional(),
347
+ payload: DashCompRequestPayloadSchema
348
+ });
349
+ zod.z.object({
350
+ toolId: zod.z.string(),
351
+ toolName: zod.z.string(),
352
+ action: zod.z.enum(["get", "create", "update", "delete"]),
353
+ params: zod.z.record(zod.z.string(), zod.z.unknown())
354
+ });
355
+ var DashCompResponsePayloadSchema = zod.z.object({
356
+ success: zod.z.boolean(),
357
+ errors: zod.z.array(zod.z.string()).optional(),
358
+ data: zod.z.object({
359
+ component: ComponentSchema.optional(),
360
+ reasoning: zod.z.string().optional(),
361
+ dataSource: zod.z.enum(["database", "external_tool", "none"]).optional()
362
+ }).optional()
363
+ });
364
+ zod.z.object({
365
+ id: zod.z.string(),
366
+ type: zod.z.literal("DASH_COMP_RES"),
367
+ from: MessageParticipantSchema,
368
+ to: MessageParticipantSchema.optional(),
369
+ payload: DashCompResponsePayloadSchema
370
+ });
335
371
  var BundleRequestPayloadSchema = zod.z.object({
336
372
  devbundlereq: zod.z.boolean().optional().default(false)
337
373
  });
@@ -871,6 +907,7 @@ __export(services_exports, {
871
907
  sendAuthLoginRequest: () => sendAuthLoginRequest,
872
908
  sendAuthVerifyRequest: () => sendAuthVerifyRequest,
873
909
  sendComponents: () => sendComponents,
910
+ sendDashCompRequest: () => sendDashCompRequest,
874
911
  sendUserPromptRequest: () => sendUserPromptRequest,
875
912
  sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
876
913
  updateBookmark: () => updateBookmark,
@@ -2177,6 +2214,51 @@ async function getKbNodeTags(client, timeout) {
2177
2214
  };
2178
2215
  }
2179
2216
 
2217
+ // src/services/dash-comp.ts
2218
+ async function sendDashCompRequest(client, options) {
2219
+ const { prompt, threadId, uiBlockId, timeout } = options;
2220
+ const messageId = `dash_comp_req_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2221
+ const message = DashCompRequestMessageSchema.parse({
2222
+ id: messageId,
2223
+ type: "DASH_COMP_REQ",
2224
+ from: {
2225
+ type: client.type
2226
+ },
2227
+ to: {
2228
+ type: "data-agent"
2229
+ },
2230
+ payload: {
2231
+ prompt,
2232
+ SA_RUNTIME: threadId || uiBlockId ? {
2233
+ threadId,
2234
+ uiBlockId
2235
+ } : void 0
2236
+ }
2237
+ });
2238
+ try {
2239
+ const response = await client.sendWithResponse(message, timeout);
2240
+ const payload = response.payload;
2241
+ if (!payload.success) {
2242
+ return {
2243
+ success: false,
2244
+ errors: payload.errors || ["Unknown error occurred"]
2245
+ };
2246
+ }
2247
+ return {
2248
+ success: true,
2249
+ component: payload.data?.component,
2250
+ reasoning: payload.data?.reasoning,
2251
+ dataSource: payload.data?.dataSource
2252
+ };
2253
+ } catch (error) {
2254
+ const errorMessage = error instanceof Error ? error.message : "Request failed";
2255
+ return {
2256
+ success: false,
2257
+ errors: [errorMessage]
2258
+ };
2259
+ }
2260
+ }
2261
+
2180
2262
  // src/client.ts
2181
2263
  var SuperatomClient = class {
2182
2264
  constructor(config) {
@@ -2844,6 +2926,32 @@ var SuperatomClient = class {
2844
2926
  this.log("info", "Fetching KB node tags");
2845
2927
  return getKbNodeTags(this, timeout);
2846
2928
  }
2929
+ // ==================== Dashboard Component Methods ====================
2930
+ // These methods delegate to dash-comp service for component selection
2931
+ /**
2932
+ * Request a dashboard component based on user prompt
2933
+ * Uses LLM to pick the best component and generate props
2934
+ * Supports both database queries and external tools as data sources
2935
+ * Delegates to dash-comp service
2936
+ *
2937
+ * @example
2938
+ * ```typescript
2939
+ * const response = await client.sendDashCompRequest({
2940
+ * prompt: "Show me a bar chart of sales by category",
2941
+ * threadId: "thread-123",
2942
+ * });
2943
+ *
2944
+ * if (response.success && response.component) {
2945
+ * console.log('Component:', response.component.name);
2946
+ * console.log('Props:', response.component.props);
2947
+ * console.log('Data source:', response.dataSource);
2948
+ * }
2949
+ * ```
2950
+ */
2951
+ async sendDashCompRequest(options) {
2952
+ this.log("info", "Sending dash comp request for prompt:", options.prompt.substring(0, 50) + "...");
2953
+ return sendDashCompRequest(this, options);
2954
+ }
2847
2955
  /**
2848
2956
  * Internal logging
2849
2957
  */