@superatomai/sdk-web 0.0.17 → 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
@@ -70,6 +70,13 @@ var UIElementSchema = zod.z.lazy(
70
70
  }).optional()
71
71
  })
72
72
  );
73
+ var PageSchema = zod.z.object({
74
+ id: zod.z.string(),
75
+ name: zod.z.string(),
76
+ order: zod.z.number(),
77
+ icon: zod.z.string().optional(),
78
+ render: UIElementSchema
79
+ });
73
80
  var UIComponentSchema = zod.z.object({
74
81
  id: zod.z.string(),
75
82
  name: zod.z.string().optional(),
@@ -89,7 +96,11 @@ var UIComponentSchema = zod.z.object({
89
96
  })
90
97
  ).optional(),
91
98
  data: zod.z.record(zod.z.string(), zod.z.any()).optional(),
92
- render: UIElementSchema,
99
+ // OLD: Single page (optional for backward compatibility)
100
+ render: UIElementSchema.optional(),
101
+ // NEW: Multi-page support
102
+ pages: zod.z.array(PageSchema).optional(),
103
+ defaultPageId: zod.z.string().optional(),
93
104
  query: QuerySpecSchema.optional()
94
105
  });
95
106
  var DSLRendererPropsSchema = zod.z.object({
@@ -179,7 +190,8 @@ var UIComponentSchema2 = zod.z.object({
179
190
  })
180
191
  ).optional(),
181
192
  data: zod.z.record(zod.z.string(), zod.z.any()).optional(),
182
- render: UIElementSchema2,
193
+ // Made optional to align with dashboards schema (dashboards use pages instead)
194
+ render: UIElementSchema2.optional(),
183
195
  query: QuerySpecSchema2.optional()
184
196
  });
185
197
  var DSLRendererPropsSchema2 = zod.z.object({
@@ -320,6 +332,42 @@ var UserPromptSuggestionsResponseMessageSchema = zod.z.object({
320
332
  to: MessageParticipantSchema.optional(),
321
333
  payload: UserPromptSuggestionsResponsePayloadSchema
322
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
+ });
323
371
  var BundleRequestPayloadSchema = zod.z.object({
324
372
  devbundlereq: zod.z.boolean().optional().default(false)
325
373
  });
@@ -814,6 +862,7 @@ __export(services_exports, {
814
862
  DSLRendererPropsSchema: () => DSLRendererPropsSchema,
815
863
  ExpressionSchema: () => ExpressionSchema,
816
864
  ForDirectiveSchema: () => ForDirectiveSchema,
865
+ PageSchema: () => PageSchema,
817
866
  QuerySpecSchema: () => QuerySpecSchema,
818
867
  UIComponentSchema: () => UIComponentSchema,
819
868
  UIElementSchema: () => UIElementSchema,
@@ -858,6 +907,7 @@ __export(services_exports, {
858
907
  sendAuthLoginRequest: () => sendAuthLoginRequest,
859
908
  sendAuthVerifyRequest: () => sendAuthVerifyRequest,
860
909
  sendComponents: () => sendComponents,
910
+ sendDashCompRequest: () => sendDashCompRequest,
861
911
  sendUserPromptRequest: () => sendUserPromptRequest,
862
912
  sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
863
913
  updateBookmark: () => updateBookmark,
@@ -2164,6 +2214,51 @@ async function getKbNodeTags(client, timeout) {
2164
2214
  };
2165
2215
  }
2166
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
+
2167
2262
  // src/client.ts
2168
2263
  var SuperatomClient = class {
2169
2264
  constructor(config) {
@@ -2831,6 +2926,32 @@ var SuperatomClient = class {
2831
2926
  this.log("info", "Fetching KB node tags");
2832
2927
  return getKbNodeTags(this, timeout);
2833
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
+ }
2834
2955
  /**
2835
2956
  * Internal logging
2836
2957
  */