@superatomai/sdk-web 0.0.1-mds

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 ADDED
@@ -0,0 +1,3845 @@
1
+ import { z } from 'zod';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __export = (target, all) => {
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+ var ExpressionSchema = z.object({
9
+ $exp: z.string(),
10
+ $deps: z.array(z.string()).optional()
11
+ });
12
+ var BindingSchema = z.object({
13
+ $bind: z.string(),
14
+ $transform: z.array(
15
+ z.object({
16
+ name: z.string(),
17
+ args: z.array(z.any()).optional()
18
+ })
19
+ ).optional()
20
+ });
21
+ var ForDirectiveSchema = z.object({
22
+ in: z.union([ExpressionSchema, BindingSchema, z.string()]),
23
+ as: z.string(),
24
+ key: z.string().optional(),
25
+ index: z.string().optional()
26
+ });
27
+ var QuerySpecSchema = z.object({
28
+ graphql: z.string().optional(),
29
+ sql: z.string().optional(),
30
+ variables: z.record(z.string(), z.any()).optional(),
31
+ params: z.record(z.string(), z.any()).optional(),
32
+ key: z.string().optional(),
33
+ refetchPolicy: z.enum(["cache-first", "network-only", "cache-and-network"]).optional(),
34
+ dependencies: z.array(z.string()).optional()
35
+ });
36
+ var UIElementSchema = z.lazy(
37
+ () => z.object({
38
+ id: z.string(),
39
+ type: z.string(),
40
+ key: z.union([z.string(), ExpressionSchema]).optional(),
41
+ props: z.record(z.string(), z.any()).optional(),
42
+ query: QuerySpecSchema.optional(),
43
+ if: ExpressionSchema.optional(),
44
+ elseIf: ExpressionSchema.optional(),
45
+ for: ForDirectiveSchema.optional(),
46
+ "link-to": z.union([
47
+ z.string(),
48
+ ExpressionSchema,
49
+ BindingSchema,
50
+ z.object({
51
+ ui: z.union([z.string(), ExpressionSchema, BindingSchema]),
52
+ params: z.record(z.string(), z.any()).optional()
53
+ })
54
+ ]).optional(),
55
+ _meta: z.object({
56
+ id: z.string().optional(),
57
+ version: z.string().optional(),
58
+ created: z.string().optional(),
59
+ lastModified: z.string().optional()
60
+ }).optional(),
61
+ children: z.any().optional(),
62
+ else: UIElementSchema.optional(),
63
+ slots: z.record(z.string(), z.union([UIElementSchema, z.array(UIElementSchema)])).optional(),
64
+ platform: z.object({
65
+ web: z.any().optional(),
66
+ ios: z.any().optional(),
67
+ android: z.any().optional()
68
+ }).optional()
69
+ })
70
+ );
71
+ var PageSchema = z.object({
72
+ id: z.string(),
73
+ name: z.string(),
74
+ order: z.number(),
75
+ icon: z.string().optional(),
76
+ render: UIElementSchema
77
+ });
78
+ var UIComponentSchema = z.object({
79
+ id: z.string(),
80
+ name: z.string().optional(),
81
+ props: z.record(z.string(), z.any()).optional(),
82
+ states: z.record(z.string(), z.any()).optional(),
83
+ methods: z.record(
84
+ z.string(),
85
+ z.object({
86
+ fn: z.string(),
87
+ params: z.record(z.string(), z.any()).optional()
88
+ })
89
+ ).optional(),
90
+ effects: z.array(
91
+ z.object({
92
+ fn: z.string(),
93
+ deps: z.array(z.string()).optional()
94
+ })
95
+ ).optional(),
96
+ data: z.record(z.string(), z.any()).optional(),
97
+ // OLD: Single page (optional for backward compatibility)
98
+ render: UIElementSchema.optional(),
99
+ // NEW: Multi-page support
100
+ pages: z.array(PageSchema).optional(),
101
+ defaultPageId: z.string().optional(),
102
+ query: QuerySpecSchema.optional()
103
+ });
104
+ var DSLRendererPropsSchema = z.object({
105
+ dsl: UIComponentSchema,
106
+ data: z.record(z.string(), z.any()).optional(),
107
+ context: z.record(z.string(), z.any()).optional()
108
+ });
109
+ var ExpressionSchema2 = z.object({
110
+ $exp: z.string(),
111
+ $deps: z.array(z.string()).optional()
112
+ });
113
+ var BindingSchema2 = z.object({
114
+ $bind: z.string(),
115
+ $transform: z.array(
116
+ z.object({
117
+ name: z.string(),
118
+ args: z.array(z.any()).optional()
119
+ })
120
+ ).optional()
121
+ });
122
+ var ForDirectiveSchema2 = z.object({
123
+ in: z.union([ExpressionSchema2, BindingSchema2, z.string()]),
124
+ as: z.string(),
125
+ key: z.string().optional(),
126
+ index: z.string().optional()
127
+ });
128
+ var QuerySpecSchema2 = z.object({
129
+ graphql: z.string().optional(),
130
+ sql: z.string().optional(),
131
+ variables: z.record(z.string(), z.any()).optional(),
132
+ params: z.record(z.string(), z.any()).optional(),
133
+ key: z.string().optional(),
134
+ refetchPolicy: z.enum(["cache-first", "network-only", "cache-and-network"]).optional(),
135
+ dependencies: z.array(z.string()).optional()
136
+ });
137
+ var UIElementSchema2 = z.lazy(
138
+ () => z.object({
139
+ id: z.string(),
140
+ type: z.string(),
141
+ key: z.union([z.string(), ExpressionSchema2]).optional(),
142
+ props: z.record(z.string(), z.any()).optional(),
143
+ query: QuerySpecSchema2.optional(),
144
+ if: ExpressionSchema2.optional(),
145
+ elseIf: ExpressionSchema2.optional(),
146
+ for: ForDirectiveSchema2.optional(),
147
+ "link-to": z.union([
148
+ z.string(),
149
+ ExpressionSchema2,
150
+ BindingSchema2,
151
+ z.object({
152
+ ui: z.union([z.string(), ExpressionSchema2, BindingSchema2]),
153
+ params: z.record(z.string(), z.any()).optional()
154
+ })
155
+ ]).optional(),
156
+ _meta: z.object({
157
+ id: z.string().optional(),
158
+ version: z.string().optional(),
159
+ created: z.string().optional(),
160
+ lastModified: z.string().optional()
161
+ }).optional(),
162
+ children: z.any().optional(),
163
+ else: UIElementSchema2.optional(),
164
+ slots: z.record(z.string(), z.union([UIElementSchema2, z.array(UIElementSchema2)])).optional(),
165
+ platform: z.object({
166
+ web: z.any().optional(),
167
+ ios: z.any().optional(),
168
+ android: z.any().optional()
169
+ }).optional()
170
+ })
171
+ );
172
+ var UIComponentSchema2 = z.object({
173
+ id: z.string(),
174
+ name: z.string().optional(),
175
+ props: z.record(z.string(), z.any()).optional(),
176
+ states: z.record(z.string(), z.any()).optional(),
177
+ methods: z.record(
178
+ z.string(),
179
+ z.object({
180
+ fn: z.string(),
181
+ params: z.record(z.string(), z.any()).optional()
182
+ })
183
+ ).optional(),
184
+ effects: z.array(
185
+ z.object({
186
+ fn: z.string(),
187
+ deps: z.array(z.string()).optional()
188
+ })
189
+ ).optional(),
190
+ data: z.record(z.string(), z.any()).optional(),
191
+ // Made optional to align with dashboards schema (dashboards use pages instead)
192
+ render: UIElementSchema2.optional(),
193
+ query: QuerySpecSchema2.optional()
194
+ });
195
+ var DSLRendererPropsSchema2 = z.object({
196
+ dsl: UIComponentSchema2,
197
+ data: z.record(z.string(), z.any()).optional(),
198
+ context: z.record(z.string(), z.any()).optional()
199
+ });
200
+
201
+ // src/types.ts
202
+ var MessageParticipantSchema = z.object({
203
+ id: z.string().optional(),
204
+ type: z.string().optional()
205
+ });
206
+ var MessageSchema = z.object({
207
+ id: z.string(),
208
+ type: z.string(),
209
+ from: MessageParticipantSchema,
210
+ to: MessageParticipantSchema.optional(),
211
+ payload: z.unknown()
212
+ });
213
+ var AuthLoginPayloadSchema = z.object({
214
+ login_data: z.string()
215
+ // Base64 encoded login data (username + SHA-1 hashed password)
216
+ });
217
+ var AuthLoginRequestMessageSchema = z.object({
218
+ id: z.string(),
219
+ type: z.literal("AUTH_LOGIN_REQ"),
220
+ from: MessageParticipantSchema,
221
+ to: MessageParticipantSchema.optional(),
222
+ payload: AuthLoginPayloadSchema
223
+ });
224
+ var AuthLoginResponsePayloadSchema = z.object({
225
+ success: z.boolean(),
226
+ error: z.string().optional(),
227
+ data: z.unknown().optional()
228
+ // User ID or additional auth data
229
+ });
230
+ var AuthLoginResponseMessageSchema = z.object({
231
+ id: z.string(),
232
+ type: z.literal("AUTH_LOGIN_RES"),
233
+ from: MessageParticipantSchema,
234
+ to: MessageParticipantSchema.optional(),
235
+ payload: AuthLoginResponsePayloadSchema
236
+ });
237
+ var AuthVerifyPayloadSchema = z.object({
238
+ token: z.string()
239
+ // Base64 encoded authentication token
240
+ });
241
+ var AuthVerifyRequestMessageSchema = z.object({
242
+ id: z.string(),
243
+ type: z.literal("AUTH_VERIFY_REQ"),
244
+ from: MessageParticipantSchema,
245
+ to: MessageParticipantSchema.optional(),
246
+ payload: AuthVerifyPayloadSchema
247
+ });
248
+ var AuthVerifyResponsePayloadSchema = z.object({
249
+ success: z.boolean(),
250
+ error: z.string().optional(),
251
+ data: z.unknown().optional()
252
+ });
253
+ var AuthVerifyResponseMessageSchema = z.object({
254
+ id: z.string(),
255
+ type: z.literal("AUTH_VERIFY_RES"),
256
+ from: MessageParticipantSchema,
257
+ to: MessageParticipantSchema.optional(),
258
+ payload: AuthVerifyResponsePayloadSchema
259
+ });
260
+ var UserPromptRequestPayloadSchema = z.object({
261
+ prompt: z.string(),
262
+ userId: z.string().optional(),
263
+ SA_RUNTIME: z.object({
264
+ threadId: z.string(),
265
+ uiBlockId: z.string()
266
+ }).optional(),
267
+ responseMode: z.enum(["component", "text"]).optional()
268
+ });
269
+ var UserPromptRequestMessageSchema = z.object({
270
+ id: z.string(),
271
+ type: z.literal("USER_PROMPT_REQ"),
272
+ from: MessageParticipantSchema,
273
+ to: MessageParticipantSchema.optional(),
274
+ payload: UserPromptRequestPayloadSchema
275
+ });
276
+ var ComponentPropsSchema = z.object({
277
+ query: z.string().or(z.record(z.string(), z.unknown())).nullable().optional(),
278
+ title: z.string().optional(),
279
+ description: z.string().optional(),
280
+ config: z.record(z.string(), z.unknown()).optional()
281
+ }).passthrough();
282
+ var ComponentSchema = z.object({
283
+ id: z.string(),
284
+ name: z.string(),
285
+ type: z.string(),
286
+ description: z.string(),
287
+ props: ComponentPropsSchema,
288
+ category: z.string().optional(),
289
+ keywords: z.array(z.string()).optional()
290
+ });
291
+ var UserPromptResponsePayloadSchema = z.object({
292
+ success: z.boolean(),
293
+ error: z.string().optional(),
294
+ data: z.object({
295
+ component: ComponentSchema.optional()
296
+ }).optional(),
297
+ uiBlockId: z.string().optional(),
298
+ threadId: z.string().optional()
299
+ });
300
+ var UserPromptResponseMessageSchema = z.object({
301
+ id: z.string(),
302
+ type: z.literal("USER_PROMPT_RES"),
303
+ from: MessageParticipantSchema,
304
+ to: MessageParticipantSchema.optional(),
305
+ payload: UserPromptResponsePayloadSchema
306
+ });
307
+ var UserPromptSuggestionsRequestPayloadSchema = z.object({
308
+ prompt: z.string(),
309
+ userId: z.string().optional(),
310
+ limit: z.number().int().positive().default(5)
311
+ });
312
+ var UserPromptSuggestionsRequestMessageSchema = z.object({
313
+ id: z.string(),
314
+ type: z.literal("USER_PROMPT_SUGGESTIONS_REQ"),
315
+ from: MessageParticipantSchema,
316
+ to: MessageParticipantSchema.optional(),
317
+ payload: UserPromptSuggestionsRequestPayloadSchema
318
+ });
319
+ var UserPromptSuggestionsResponsePayloadSchema = z.object({
320
+ success: z.boolean(),
321
+ error: z.string().optional(),
322
+ data: z.object({
323
+ prompt: z.string(),
324
+ suggestions: z.array(ComponentSchema),
325
+ count: z.number(),
326
+ message: z.string().optional()
327
+ }).optional()
328
+ });
329
+ var UserPromptSuggestionsResponseMessageSchema = z.object({
330
+ id: z.string(),
331
+ type: z.literal("USER_PROMPT_SUGGESTIONS_RES"),
332
+ from: MessageParticipantSchema,
333
+ to: MessageParticipantSchema.optional(),
334
+ payload: UserPromptSuggestionsResponsePayloadSchema
335
+ });
336
+ var DashCompRequestPayloadSchema = z.object({
337
+ prompt: z.string(),
338
+ userId: z.string().optional(),
339
+ SA_RUNTIME: z.object({
340
+ threadId: z.string().optional(),
341
+ uiBlockId: z.string().optional()
342
+ }).optional(),
343
+ existingComponents: z.array(ComponentSchema).optional(),
344
+ req_type: z.enum(["create", "update", "filter"]).optional()
345
+ });
346
+ var DashCompRequestMessageSchema = z.object({
347
+ id: z.string(),
348
+ type: z.literal("DASH_COMP_REQ"),
349
+ from: MessageParticipantSchema,
350
+ to: MessageParticipantSchema.optional(),
351
+ payload: DashCompRequestPayloadSchema
352
+ });
353
+ z.object({
354
+ toolId: z.string(),
355
+ toolName: z.string(),
356
+ action: z.enum(["get", "create", "update", "delete"]),
357
+ params: z.record(z.string(), z.unknown())
358
+ });
359
+ z.object({
360
+ filterId: z.string(),
361
+ filterField: z.string(),
362
+ targetComponentId: z.string(),
363
+ targetField: z.string()
364
+ });
365
+ var DashCompResponsePayloadSchema = z.object({
366
+ success: z.boolean(),
367
+ errors: z.array(z.string()).optional(),
368
+ data: z.object({
369
+ // For create/update requests
370
+ component: ComponentSchema.optional(),
371
+ reasoning: z.string().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()
377
+ }).optional()
378
+ });
379
+ z.object({
380
+ id: z.string(),
381
+ type: z.literal("DASH_COMP_RES"),
382
+ from: MessageParticipantSchema,
383
+ to: MessageParticipantSchema.optional(),
384
+ payload: DashCompResponsePayloadSchema
385
+ });
386
+ var BundleRequestPayloadSchema = z.object({
387
+ devbundlereq: z.boolean().optional().default(false)
388
+ });
389
+ var BundleRequestMessageSchema = z.object({
390
+ id: z.string(),
391
+ type: z.literal("BUNDLE_REQ"),
392
+ from: MessageParticipantSchema,
393
+ to: MessageParticipantSchema.optional(),
394
+ payload: BundleRequestPayloadSchema
395
+ });
396
+ var BundleChunkPayloadSchema = z.object({
397
+ chunk: z.string(),
398
+ chunkIndex: z.number(),
399
+ totalChunks: z.number(),
400
+ isComplete: z.boolean(),
401
+ progress: z.number()
402
+ });
403
+ var BundleChunkMessageSchema = z.object({
404
+ id: z.string(),
405
+ type: z.literal("BUNDLE_CHUNK"),
406
+ from: MessageParticipantSchema,
407
+ to: MessageParticipantSchema.optional(),
408
+ payload: BundleChunkPayloadSchema
409
+ });
410
+ var BundleErrorPayloadSchema = z.object({
411
+ error: z.string()
412
+ });
413
+ var BundleErrorMessageSchema = z.object({
414
+ id: z.string(),
415
+ type: z.literal("BUNDLE_RES"),
416
+ from: MessageParticipantSchema,
417
+ to: MessageParticipantSchema.optional(),
418
+ payload: BundleErrorPayloadSchema
419
+ });
420
+ var DataRequestPayloadSchema = z.object({
421
+ collection: z.string(),
422
+ op: z.string(),
423
+ params: z.record(z.string(), z.unknown()).optional(),
424
+ SA_RUNTIME: z.record(z.string(), z.unknown()).optional()
425
+ });
426
+ var DataRequestMessageSchema = z.object({
427
+ id: z.string(),
428
+ type: z.literal("DATA_REQ"),
429
+ from: MessageParticipantSchema,
430
+ to: MessageParticipantSchema.optional(),
431
+ payload: DataRequestPayloadSchema
432
+ });
433
+ var DataResponsePayloadSchema = z.object({
434
+ collection: z.string(),
435
+ op: z.string(),
436
+ data: z.unknown(),
437
+ executionMs: z.number().optional(),
438
+ error: z.string().optional()
439
+ });
440
+ var DataResponseMessageSchema = z.object({
441
+ id: z.string(),
442
+ type: z.literal("DATA_RES"),
443
+ from: MessageParticipantSchema,
444
+ to: MessageParticipantSchema.optional(),
445
+ payload: DataResponsePayloadSchema
446
+ });
447
+ var UILogEntrySchema = z.object({
448
+ timestamp: z.number(),
449
+ level: z.enum(["info", "error", "warn", "debug"]),
450
+ message: z.string(),
451
+ type: z.enum(["explanation", "query", "general"]).optional(),
452
+ data: z.record(z.string(), z.unknown()).optional()
453
+ });
454
+ var UILogsPayloadSchema = z.object({
455
+ logs: z.array(UILogEntrySchema)
456
+ });
457
+ var UILogsMessageSchema = z.object({
458
+ id: z.string(),
459
+ // uiBlockId
460
+ type: z.literal("UI_LOGS"),
461
+ from: MessageParticipantSchema,
462
+ to: MessageParticipantSchema.optional(),
463
+ payload: UILogsPayloadSchema
464
+ });
465
+ var ActionsRequestPayloadSchema = z.object({
466
+ userId: z.string().optional(),
467
+ SA_RUNTIME: z.object({
468
+ threadId: z.string(),
469
+ uiBlockId: z.string()
470
+ }).optional()
471
+ });
472
+ var ActionsRequestMessageSchema = z.object({
473
+ id: z.string(),
474
+ from: MessageParticipantSchema,
475
+ type: z.literal("ACTIONS"),
476
+ payload: ActionsRequestPayloadSchema
477
+ });
478
+ var ActionsResponsePayloadSchema = z.object({
479
+ success: z.boolean(),
480
+ data: z.any().optional(),
481
+ error: z.string().optional()
482
+ });
483
+ var ActionsResponseMessageSchema = z.object({
484
+ id: z.string(),
485
+ type: z.literal("ACTIONS_RES"),
486
+ from: MessageParticipantSchema,
487
+ to: MessageParticipantSchema.optional(),
488
+ payload: ActionsResponsePayloadSchema
489
+ });
490
+ var ComponentsSendPayloadSchema = z.object({
491
+ components: z.array(z.any())
492
+ });
493
+ var ComponentsSendMessageSchema = z.object({
494
+ id: z.string(),
495
+ type: z.literal("COMPONENT_LIST_RES"),
496
+ from: MessageParticipantSchema,
497
+ to: MessageParticipantSchema.optional(),
498
+ payload: ComponentsSendPayloadSchema
499
+ });
500
+ var UserQueryFiltersSchema = z.object({
501
+ username: z.string().optional(),
502
+ email: z.string().optional(),
503
+ role: z.string().optional(),
504
+ fullname: z.string().optional(),
505
+ id: z.number().optional()
506
+ });
507
+ var UsersRequestPayloadSchema = z.object({
508
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
509
+ data: z.object({
510
+ id: z.number().optional(),
511
+ username: z.string().optional(),
512
+ email: z.string().email("Invalid email format").optional(),
513
+ password: z.string().optional(),
514
+ fullname: z.string().optional(),
515
+ role: z.string().optional(),
516
+ userInfo: z.record(z.string(), z.unknown()).optional(),
517
+ // Query operation fields
518
+ filters: UserQueryFiltersSchema.optional(),
519
+ limit: z.number().optional(),
520
+ sort: z.enum(["ASC", "DESC"]).optional()
521
+ }).optional()
522
+ });
523
+ var UsersRequestMessageSchema = z.object({
524
+ id: z.string(),
525
+ type: z.literal("USERS"),
526
+ from: MessageParticipantSchema,
527
+ to: MessageParticipantSchema.optional(),
528
+ payload: UsersRequestPayloadSchema
529
+ });
530
+ var UsersResponsePayloadSchema = z.object({
531
+ success: z.boolean(),
532
+ error: z.string().optional(),
533
+ data: z.object({
534
+ username: z.string().optional(),
535
+ email: z.string().optional(),
536
+ fullname: z.string().optional(),
537
+ role: z.string().optional(),
538
+ message: z.string().optional(),
539
+ users: z.array(z.object({
540
+ id: z.number(),
541
+ username: z.string(),
542
+ email: z.string().optional(),
543
+ fullname: z.string().optional(),
544
+ role: z.string().optional(),
545
+ userInfo: z.record(z.string(), z.unknown()).optional(),
546
+ wsIds: z.array(z.string()).optional(),
547
+ createdAt: z.string().optional(),
548
+ updatedAt: z.string().optional()
549
+ })).optional(),
550
+ user: z.object({
551
+ id: z.number(),
552
+ username: z.string(),
553
+ email: z.string().optional(),
554
+ fullname: z.string().optional(),
555
+ role: z.string().optional(),
556
+ userInfo: z.record(z.string(), z.unknown()).optional(),
557
+ wsIds: z.array(z.string()).optional(),
558
+ createdAt: z.string().optional(),
559
+ updatedAt: z.string().optional()
560
+ }).optional(),
561
+ count: z.number().optional()
562
+ }).optional()
563
+ });
564
+ z.object({
565
+ id: z.string(),
566
+ type: z.literal("USERS_RES"),
567
+ from: MessageParticipantSchema,
568
+ to: MessageParticipantSchema.optional(),
569
+ payload: UsersResponsePayloadSchema
570
+ });
571
+ var DashboardQueryFiltersSchema = z.object({
572
+ dashboardId: z.string().optional(),
573
+ projectId: z.string().optional(),
574
+ createdBy: z.string().optional(),
575
+ updatedBy: z.string().optional(),
576
+ name: z.string().optional(),
577
+ published: z.boolean().optional()
578
+ });
579
+ var DashboardsRequestPayloadSchema = z.object({
580
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
581
+ data: z.object({
582
+ id: z.number().optional(),
583
+ dashboardId: z.string().optional(),
584
+ projectId: z.string().optional(),
585
+ name: z.string().optional(),
586
+ description: z.string().optional(),
587
+ published: z.boolean().optional(),
588
+ createdBy: z.string().optional(),
589
+ updatedBy: z.string().optional(),
590
+ allowedUsers: z.array(z.string()).optional(),
591
+ dashboard: DSLRendererPropsSchema.optional(),
592
+ // Query operation fields
593
+ filters: DashboardQueryFiltersSchema.optional(),
594
+ limit: z.number().optional(),
595
+ sort: z.enum(["ASC", "DESC"]).optional()
596
+ }).optional()
597
+ });
598
+ var DashboardsRequestMessageSchema = z.object({
599
+ id: z.string(),
600
+ type: z.literal("DASHBOARDS"),
601
+ from: MessageParticipantSchema,
602
+ to: MessageParticipantSchema.optional(),
603
+ payload: DashboardsRequestPayloadSchema
604
+ });
605
+ var DashboardsResponsePayloadSchema = z.object({
606
+ success: z.boolean(),
607
+ error: z.string().optional(),
608
+ data: z.object({
609
+ dashboardId: z.string().optional(),
610
+ dashboard: DSLRendererPropsSchema.optional(),
611
+ dashboards: z.array(z.object({
612
+ dashboardId: z.string(),
613
+ dashboard: DSLRendererPropsSchema
614
+ })).optional(),
615
+ count: z.number().optional(),
616
+ message: z.string().optional()
617
+ }).optional()
618
+ });
619
+ z.object({
620
+ id: z.string(),
621
+ type: z.literal("DASHBOARDS_RES"),
622
+ from: MessageParticipantSchema,
623
+ to: MessageParticipantSchema.optional(),
624
+ payload: DashboardsResponsePayloadSchema
625
+ });
626
+ var ReportQueryFiltersSchema = z.object({
627
+ reportId: z.string().optional(),
628
+ projectId: z.string().optional(),
629
+ createdBy: z.string().optional(),
630
+ updatedBy: z.string().optional(),
631
+ name: z.string().optional(),
632
+ published: z.boolean().optional()
633
+ });
634
+ var ReportsRequestPayloadSchema = z.object({
635
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
636
+ data: z.object({
637
+ id: z.number().optional(),
638
+ reportId: z.string().optional(),
639
+ projectId: z.string().optional(),
640
+ name: z.string().optional(),
641
+ description: z.string().optional(),
642
+ published: z.boolean().optional(),
643
+ createdBy: z.string().optional(),
644
+ updatedBy: z.string().optional(),
645
+ report: DSLRendererPropsSchema2.optional(),
646
+ // Query operation fields
647
+ filters: ReportQueryFiltersSchema.optional(),
648
+ limit: z.number().optional(),
649
+ sort: z.enum(["ASC", "DESC"]).optional()
650
+ }).optional()
651
+ });
652
+ var ReportsRequestMessageSchema = z.object({
653
+ id: z.string(),
654
+ type: z.literal("REPORTS"),
655
+ from: MessageParticipantSchema,
656
+ to: MessageParticipantSchema.optional(),
657
+ payload: ReportsRequestPayloadSchema
658
+ });
659
+ var ReportsResponsePayloadSchema = z.object({
660
+ success: z.boolean(),
661
+ error: z.string().optional(),
662
+ data: z.object({
663
+ reportId: z.string().optional(),
664
+ report: DSLRendererPropsSchema2.optional(),
665
+ reports: z.array(z.object({
666
+ reportId: z.string(),
667
+ report: DSLRendererPropsSchema2
668
+ })).optional(),
669
+ count: z.number().optional(),
670
+ message: z.string().optional()
671
+ }).optional()
672
+ });
673
+ z.object({
674
+ id: z.string(),
675
+ type: z.literal("REPORTS_RES"),
676
+ from: MessageParticipantSchema,
677
+ to: MessageParticipantSchema.optional(),
678
+ payload: ReportsResponsePayloadSchema
679
+ });
680
+ var UIQueryFiltersSchema = z.object({
681
+ uiId: z.string().optional(),
682
+ projectId: z.string().optional(),
683
+ createdBy: z.string().optional(),
684
+ updatedBy: z.string().optional(),
685
+ name: z.string().optional()
686
+ });
687
+ var UIsRequestPayloadSchema = z.object({
688
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
689
+ data: z.object({
690
+ id: z.number().optional(),
691
+ uiId: z.string().optional(),
692
+ projectId: z.string().optional(),
693
+ name: z.string().optional(),
694
+ description: z.string().optional(),
695
+ createdBy: z.string().optional(),
696
+ updatedBy: z.string().optional(),
697
+ ui: DSLRendererPropsSchema.optional(),
698
+ // Query operation fields
699
+ filters: UIQueryFiltersSchema.optional(),
700
+ limit: z.number().optional(),
701
+ sort: z.enum(["ASC", "DESC"]).optional()
702
+ }).optional()
703
+ });
704
+ var UIsRequestMessageSchema = z.object({
705
+ id: z.string(),
706
+ type: z.literal("UIS"),
707
+ from: MessageParticipantSchema,
708
+ to: MessageParticipantSchema.optional(),
709
+ payload: UIsRequestPayloadSchema
710
+ });
711
+ var UIsResponsePayloadSchema = z.object({
712
+ success: z.boolean(),
713
+ error: z.string().optional(),
714
+ data: z.object({
715
+ uiId: z.union([z.string(), z.number()]).optional(),
716
+ ui: DSLRendererPropsSchema.optional(),
717
+ uis: z.array(z.object({
718
+ uiId: z.string(),
719
+ ui: DSLRendererPropsSchema.optional()
720
+ })).optional(),
721
+ count: z.number().optional(),
722
+ message: z.string().optional()
723
+ }).optional()
724
+ });
725
+ z.object({
726
+ id: z.string(),
727
+ type: z.literal("UIS_RES"),
728
+ from: MessageParticipantSchema,
729
+ to: MessageParticipantSchema.optional(),
730
+ payload: UIsResponsePayloadSchema
731
+ });
732
+ var DBUIBlockSchema = z.object({
733
+ id: z.string(),
734
+ component: z.record(z.string(), z.any()).nullable(),
735
+ analysis: z.string().nullable(),
736
+ user_prompt: z.string()
737
+ });
738
+ var BookmarkDataSchema = z.object({
739
+ id: z.number().optional(),
740
+ uiblock: DBUIBlockSchema,
741
+ created_at: z.string().optional(),
742
+ updated_at: z.string().optional()
743
+ });
744
+ var BookmarkQueryFiltersSchema = z.object({
745
+ userId: z.string().optional(),
746
+ threadId: z.string().optional(),
747
+ name: z.string().optional()
748
+ });
749
+ var BookmarksRequestPayloadSchema = z.object({
750
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
751
+ data: z.object({
752
+ id: z.number().optional(),
753
+ userId: z.string().optional(),
754
+ threadId: z.string().optional(),
755
+ name: z.string().optional(),
756
+ description: z.string().optional(),
757
+ uiblock: DBUIBlockSchema.optional(),
758
+ // Query operation fields
759
+ filters: BookmarkQueryFiltersSchema.optional(),
760
+ limit: z.number().optional(),
761
+ sort: z.enum(["ASC", "DESC"]).optional()
762
+ }).optional()
763
+ });
764
+ var BookmarksRequestMessageSchema = z.object({
765
+ id: z.string(),
766
+ type: z.literal("BOOKMARKS"),
767
+ from: MessageParticipantSchema,
768
+ to: MessageParticipantSchema.optional(),
769
+ payload: BookmarksRequestPayloadSchema
770
+ });
771
+ var BookmarksResponsePayloadSchema = z.object({
772
+ success: z.boolean(),
773
+ error: z.string().optional(),
774
+ data: z.union([
775
+ BookmarkDataSchema,
776
+ z.array(BookmarkDataSchema)
777
+ ]).optional(),
778
+ count: z.number().optional(),
779
+ message: z.string().optional()
780
+ });
781
+ z.object({
782
+ id: z.string(),
783
+ type: z.literal("BOOKMARKS_RES"),
784
+ from: MessageParticipantSchema,
785
+ to: MessageParticipantSchema.optional(),
786
+ payload: BookmarksResponsePayloadSchema
787
+ });
788
+ var ArtifactDataSchema = z.object({
789
+ id: z.number().optional(),
790
+ name: z.string(),
791
+ createdBy: z.string().nullable().optional(),
792
+ dsl: z.record(z.string(), z.any()).nullable().optional(),
793
+ type: z.string().nullable().optional(),
794
+ filters: z.any().nullable().optional(),
795
+ status: z.string().nullable().optional(),
796
+ deleted: z.boolean().optional(),
797
+ createdAt: z.string().optional(),
798
+ updatedAt: z.string().optional()
799
+ });
800
+ var ArtifactsQueryFiltersSchema = z.object({
801
+ createdBy: z.string().optional(),
802
+ type: z.string().optional(),
803
+ status: z.string().optional(),
804
+ name: z.string().optional(),
805
+ deleted: z.boolean().optional(),
806
+ createdAt: z.string().optional()
807
+ });
808
+ var ArtifactsRequestPayloadSchema = z.object({
809
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
810
+ data: z.object({
811
+ id: z.number().optional(),
812
+ name: z.string().optional(),
813
+ createdBy: z.string().optional(),
814
+ dsl: z.record(z.string(), z.any()).optional(),
815
+ status: z.string().optional(),
816
+ deleted: z.boolean().optional(),
817
+ limit: z.number().optional(),
818
+ offset: z.number().optional(),
819
+ // Query operation fields
820
+ filters: ArtifactsQueryFiltersSchema.optional(),
821
+ sort: z.enum(["ASC", "DESC"]).optional(),
822
+ // Menu grouping fields
823
+ type: z.string().optional(),
824
+ menuId: z.number().optional(),
825
+ artifactGroupName: z.string().optional(),
826
+ artifactGroupId: z.string().optional(),
827
+ artifactGroupIcon: z.string().optional()
828
+ }).optional()
829
+ });
830
+ var ArtifactsRequestMessageSchema = z.object({
831
+ id: z.string(),
832
+ type: z.literal("ARTIFACTS"),
833
+ from: MessageParticipantSchema,
834
+ to: MessageParticipantSchema.optional(),
835
+ payload: ArtifactsRequestPayloadSchema
836
+ });
837
+ var ArtifactsResponsePayloadSchema = z.object({
838
+ success: z.boolean(),
839
+ error: z.string().optional(),
840
+ data: z.union([
841
+ ArtifactDataSchema,
842
+ z.array(ArtifactDataSchema)
843
+ ]).optional(),
844
+ count: z.number().optional(),
845
+ message: z.string().optional()
846
+ });
847
+ z.object({
848
+ id: z.string(),
849
+ type: z.literal("ARTIFACTS_RES"),
850
+ from: MessageParticipantSchema,
851
+ to: MessageParticipantSchema.optional(),
852
+ payload: ArtifactsResponsePayloadSchema
853
+ });
854
+ var KbNodeTypeSchema = z.enum(["global", "user", "query"]);
855
+ var KbNodeDataSchema = z.object({
856
+ id: z.number().optional(),
857
+ title: z.string(),
858
+ content: z.string(),
859
+ category: z.string().nullable().optional(),
860
+ tags: z.array(z.string()).nullable().optional(),
861
+ type: KbNodeTypeSchema.nullable().optional(),
862
+ createdBy: z.string(),
863
+ updatedBy: z.string().optional(),
864
+ createdAt: z.string().optional(),
865
+ updatedAt: z.string().optional()
866
+ });
867
+ var KbNodesQueryFiltersSchema = z.object({
868
+ query: z.string().optional(),
869
+ category: z.string().optional(),
870
+ tags: z.array(z.string()).optional(),
871
+ type: KbNodeTypeSchema.optional(),
872
+ createdBy: z.string().optional()
873
+ });
874
+ var KbNodesRequestPayloadSchema = z.object({
875
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "search", "getByCategory", "getByUser", "getCategories", "getTags"]),
876
+ data: z.object({
877
+ id: z.number().optional(),
878
+ title: z.string().optional(),
879
+ content: z.string().optional(),
880
+ category: z.string().optional(),
881
+ tags: z.array(z.string()).optional(),
882
+ type: KbNodeTypeSchema.optional(),
883
+ createdBy: z.string().optional(),
884
+ updatedBy: z.string().optional(),
885
+ userId: z.string().optional(),
886
+ // Query/search operation fields
887
+ query: z.string().optional(),
888
+ filters: KbNodesQueryFiltersSchema.optional(),
889
+ limit: z.number().optional(),
890
+ offset: z.number().optional()
891
+ }).optional()
892
+ });
893
+ var KbNodesRequestMessageSchema = z.object({
894
+ id: z.string(),
895
+ type: z.literal("KB_NODES"),
896
+ from: MessageParticipantSchema,
897
+ to: MessageParticipantSchema.optional(),
898
+ payload: KbNodesRequestPayloadSchema
899
+ });
900
+ var KbNodesResponsePayloadSchema = z.object({
901
+ success: z.boolean(),
902
+ error: z.string().optional(),
903
+ data: z.object({
904
+ // Single node operations
905
+ id: z.number().optional(),
906
+ title: z.string().optional(),
907
+ content: z.string().optional(),
908
+ category: z.string().nullable().optional(),
909
+ tags: z.array(z.string()).nullable().optional(),
910
+ type: KbNodeTypeSchema.nullable().optional(),
911
+ createdBy: z.string().optional(),
912
+ updatedBy: z.string().optional(),
913
+ createdAt: z.string().optional(),
914
+ updatedAt: z.string().optional(),
915
+ message: z.string().optional(),
916
+ // GetOne response
917
+ node: KbNodeDataSchema.optional(),
918
+ // List operations
919
+ nodes: z.array(KbNodeDataSchema).optional(),
920
+ count: z.number().optional(),
921
+ // getByCategory/getByUser
922
+ userId: z.string().optional(),
923
+ // getCategories
924
+ categories: z.array(z.string()).optional()
925
+ // getTags
926
+ }).optional()
927
+ });
928
+ var KbNodesResponseMessageSchema = z.object({
929
+ id: z.string(),
930
+ type: z.literal("KB_NODES_RES"),
931
+ from: MessageParticipantSchema,
932
+ to: MessageParticipantSchema.optional(),
933
+ payload: KbNodesResponsePayloadSchema
934
+ });
935
+ var MenuDataSchema = z.object({
936
+ id: z.number().optional(),
937
+ name: z.string(),
938
+ componentName: z.string(),
939
+ icon: z.string().nullable().optional(),
940
+ userMessage: z.string().nullable().optional(),
941
+ parentId: z.number().nullable().optional(),
942
+ sortOrder: z.number().optional(),
943
+ props: z.record(z.string(), z.unknown()).nullable().optional(),
944
+ isActive: z.boolean().optional(),
945
+ createdAt: z.string().optional(),
946
+ updatedAt: z.string().optional(),
947
+ children: z.lazy(() => z.array(MenuDataSchema)).optional(),
948
+ menuJson: z.record(z.string(), z.unknown()).nullable().optional(),
949
+ version: z.number().optional()
950
+ });
951
+ var MenuQueryFiltersSchema = z.object({
952
+ parentId: z.number().nullable().optional(),
953
+ isActive: z.boolean().optional()
954
+ });
955
+ var MenusRequestPayloadSchema = z.object({
956
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "query", "getRootMenus", "getChildMenus", "getHierarchy", "reorder"]),
957
+ data: z.object({
958
+ id: z.number().optional(),
959
+ name: z.string().optional(),
960
+ componentName: z.string().optional(),
961
+ icon: z.string().optional(),
962
+ userMessage: z.string().optional(),
963
+ parentId: z.number().nullable().optional(),
964
+ sortOrder: z.number().optional(),
965
+ props: z.record(z.string(), z.unknown()).optional(),
966
+ isActive: z.boolean().optional(),
967
+ // Query operation fields
968
+ filters: MenuQueryFiltersSchema.optional(),
969
+ limit: z.number().optional(),
970
+ sort: z.enum(["ASC", "DESC"]).optional(),
971
+ // Reorder operation
972
+ items: z.array(z.object({
973
+ id: z.number(),
974
+ sortOrder: z.number()
975
+ })).optional()
976
+ }).optional()
977
+ });
978
+ var MenusRequestMessageSchema = z.object({
979
+ id: z.string(),
980
+ type: z.literal("MENUS"),
981
+ from: MessageParticipantSchema,
982
+ to: MessageParticipantSchema.optional(),
983
+ payload: MenusRequestPayloadSchema
984
+ });
985
+ var MenusResponsePayloadSchema = z.object({
986
+ success: z.boolean(),
987
+ error: z.string().optional(),
988
+ data: z.union([
989
+ MenuDataSchema,
990
+ z.array(MenuDataSchema)
991
+ ]).optional(),
992
+ count: z.number().optional(),
993
+ message: z.string().optional()
994
+ });
995
+ var MenusResponseMessageSchema = z.object({
996
+ id: z.string(),
997
+ type: z.literal("MENUS_RES"),
998
+ from: MessageParticipantSchema,
999
+ to: MessageParticipantSchema.optional(),
1000
+ payload: MenusResponsePayloadSchema
1001
+ });
1002
+ var SchemaColumnStatisticsSchema = z.object({
1003
+ distinct: z.number().optional(),
1004
+ min: z.number().optional(),
1005
+ max: z.number().optional()
1006
+ });
1007
+ var SchemaColumnSchema = z.object({
1008
+ name: z.string(),
1009
+ type: z.string(),
1010
+ nativeType: z.string(),
1011
+ nullable: z.boolean(),
1012
+ description: z.string(),
1013
+ statistics: SchemaColumnStatisticsSchema.optional(),
1014
+ cardinality: z.enum(["unique", "high", "medium", "low"]).optional(),
1015
+ sampleValues: z.array(z.string()).optional()
1016
+ });
1017
+ var SchemaTableSchema = z.object({
1018
+ name: z.string(),
1019
+ fullName: z.string(),
1020
+ rowCount: z.number(),
1021
+ description: z.string(),
1022
+ columns: z.array(SchemaColumnSchema)
1023
+ });
1024
+ var SchemaRelationshipSchema = z.object({
1025
+ from: z.string(),
1026
+ to: z.string(),
1027
+ type: z.string(),
1028
+ keys: z.array(z.string())
1029
+ });
1030
+ var DatabaseSchemaSchema = z.object({
1031
+ database: z.string(),
1032
+ databaseType: z.string().optional(),
1033
+ schema: z.string(),
1034
+ description: z.string(),
1035
+ tables: z.array(SchemaTableSchema),
1036
+ relationships: z.array(SchemaRelationshipSchema).optional()
1037
+ });
1038
+ var SchemaRequestPayloadSchema = z.object({
1039
+ /** If true, returns the formatted documentation string in addition to raw JSON */
1040
+ formatted: z.boolean().optional()
1041
+ });
1042
+ var SchemaRequestMessageSchema = z.object({
1043
+ id: z.string(),
1044
+ type: z.literal("SCHEMA_REQ"),
1045
+ from: MessageParticipantSchema,
1046
+ to: MessageParticipantSchema.optional(),
1047
+ payload: SchemaRequestPayloadSchema
1048
+ });
1049
+ var SchemaResponsePayloadSchema = z.object({
1050
+ success: z.boolean(),
1051
+ error: z.string().optional(),
1052
+ data: z.object({
1053
+ schema: DatabaseSchemaSchema,
1054
+ /** Formatted schema documentation (only if formatted: true was requested) */
1055
+ formatted: z.string().optional()
1056
+ }).optional()
1057
+ });
1058
+ z.object({
1059
+ id: z.string(),
1060
+ type: z.literal("SCHEMA_RES"),
1061
+ from: MessageParticipantSchema,
1062
+ to: MessageParticipantSchema.optional(),
1063
+ payload: SchemaResponsePayloadSchema
1064
+ });
1065
+ var ClientConfigSchema = z.object({
1066
+ userId: z.string(),
1067
+ projectId: z.string(),
1068
+ baseUrl: z.string().default("wss://ws.superatom.ai/websocket"),
1069
+ type: z.string().default("runtime"),
1070
+ maxReconnectAttempts: z.number().min(0).default(Infinity),
1071
+ initialReconnectDelay: z.number().min(0).default(1e3),
1072
+ maxReconnectDelay: z.number().min(0).default(3e4),
1073
+ defaultTimeout: z.number().min(0).default(3e4),
1074
+ debug: z.boolean().default(false)
1075
+ });
1076
+
1077
+ // src/services/index.ts
1078
+ var services_exports = {};
1079
+ __export(services_exports, {
1080
+ BindingSchema: () => BindingSchema,
1081
+ DSLRendererPropsSchema: () => DSLRendererPropsSchema,
1082
+ ExpressionSchema: () => ExpressionSchema,
1083
+ ForDirectiveSchema: () => ForDirectiveSchema,
1084
+ PageSchema: () => PageSchema,
1085
+ QuerySpecSchema: () => QuerySpecSchema,
1086
+ UIComponentSchema: () => UIComponentSchema,
1087
+ UIElementSchema: () => UIElementSchema,
1088
+ createArtifact: () => createArtifact,
1089
+ createBookmark: () => createBookmark,
1090
+ createDashboard: () => createDashboard,
1091
+ createKbNode: () => createKbNode,
1092
+ createMenu: () => createMenu,
1093
+ createReport: () => createReport,
1094
+ createUI: () => createUI,
1095
+ createUser: () => createUser,
1096
+ deleteArtifact: () => deleteArtifact,
1097
+ deleteBookmark: () => deleteBookmark,
1098
+ deleteDashboard: () => deleteDashboard,
1099
+ deleteKbNode: () => deleteKbNode,
1100
+ deleteMenu: () => deleteMenu,
1101
+ deleteReport: () => deleteReport,
1102
+ deleteUI: () => deleteUI,
1103
+ deleteUser: () => deleteUser,
1104
+ getActions: () => getActions,
1105
+ getAllArtifacts: () => getAllArtifacts,
1106
+ getAllBookmarks: () => getAllBookmarks,
1107
+ getAllDashboards: () => getAllDashboards,
1108
+ getAllKbNodes: () => getAllKbNodes,
1109
+ getAllMenus: () => getAllMenus,
1110
+ getAllReports: () => getAllReports,
1111
+ getAllUIs: () => getAllUIs,
1112
+ getAllUsers: () => getAllUsers,
1113
+ getArtifact: () => getArtifact,
1114
+ getBookmark: () => getBookmark,
1115
+ getChildMenus: () => getChildMenus,
1116
+ getComponentSuggestions: () => getComponentSuggestions,
1117
+ getDashboard: () => getDashboard,
1118
+ getKbNode: () => getKbNode,
1119
+ getKbNodeCategories: () => getKbNodeCategories,
1120
+ getKbNodeTags: () => getKbNodeTags,
1121
+ getKbNodesByCategory: () => getKbNodesByCategory,
1122
+ getKbNodesByUser: () => getKbNodesByUser,
1123
+ getMenu: () => getMenu,
1124
+ getMenusHierarchy: () => getMenusHierarchy,
1125
+ getReport: () => getReport,
1126
+ getRootMenus: () => getRootMenus,
1127
+ getSchema: () => getSchema,
1128
+ getUI: () => getUI,
1129
+ getUser: () => getUser,
1130
+ queryArtifacts: () => queryArtifacts,
1131
+ queryBookmarks: () => queryBookmarks,
1132
+ queryDashboards: () => queryDashboards,
1133
+ queryMenus: () => queryMenus,
1134
+ queryReports: () => queryReports,
1135
+ queryUIs: () => queryUIs,
1136
+ queryUsers: () => queryUsers,
1137
+ reorderMenus: () => reorderMenus,
1138
+ requestBundle: () => requestBundle,
1139
+ requestData: () => requestData,
1140
+ searchKbNodes: () => searchKbNodes,
1141
+ sendAuthLoginRequest: () => sendAuthLoginRequest,
1142
+ sendAuthVerifyRequest: () => sendAuthVerifyRequest,
1143
+ sendComponents: () => sendComponents,
1144
+ sendDashCompRequest: () => sendDashCompRequest,
1145
+ sendUserPromptRequest: () => sendUserPromptRequest,
1146
+ sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
1147
+ updateArtifact: () => updateArtifact,
1148
+ updateBookmark: () => updateBookmark,
1149
+ updateDashboard: () => updateDashboard,
1150
+ updateKbNode: () => updateKbNode,
1151
+ updateMenu: () => updateMenu,
1152
+ updateReport: () => updateReport,
1153
+ updateUI: () => updateUI,
1154
+ updateUser: () => updateUser
1155
+ });
1156
+
1157
+ // src/services/auth.ts
1158
+ async function sendAuthLoginRequest(client, loginDataBase64, timeout) {
1159
+ const messageId = `login_${Date.now()}`;
1160
+ const message = AuthLoginRequestMessageSchema.parse({
1161
+ id: messageId,
1162
+ type: "AUTH_LOGIN_REQ",
1163
+ from: {
1164
+ type: client.type
1165
+ },
1166
+ to: {
1167
+ type: "data-agent"
1168
+ },
1169
+ payload: {
1170
+ login_data: loginDataBase64
1171
+ }
1172
+ });
1173
+ const response = await client.sendWithResponse(message, timeout);
1174
+ console.log("sdk auth login response", response);
1175
+ return response;
1176
+ }
1177
+ async function sendAuthVerifyRequest(client, token, timeout) {
1178
+ const messageId = `verify_${Date.now()}`;
1179
+ const message = AuthVerifyRequestMessageSchema.parse({
1180
+ id: messageId,
1181
+ type: "AUTH_VERIFY_REQ",
1182
+ from: {
1183
+ type: client.type
1184
+ },
1185
+ to: {
1186
+ type: "data-agent"
1187
+ },
1188
+ payload: {
1189
+ token
1190
+ }
1191
+ });
1192
+ const response = await client.sendWithResponse(message, timeout);
1193
+ return response;
1194
+ }
1195
+
1196
+ // src/services/userPrompt.ts
1197
+ async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout) {
1198
+ const messageId = `user_prompt_req_msg_${Date.now()}`;
1199
+ const message = UserPromptRequestMessageSchema.parse({
1200
+ id: messageId,
1201
+ type: "USER_PROMPT_REQ",
1202
+ from: {
1203
+ type: client.type
1204
+ },
1205
+ to: {
1206
+ type: "data-agent"
1207
+ },
1208
+ payload: {
1209
+ prompt,
1210
+ userId,
1211
+ SA_RUNTIME: {
1212
+ threadId,
1213
+ uiBlockId
1214
+ },
1215
+ responseMode
1216
+ }
1217
+ });
1218
+ let streamUnsubscribe = null;
1219
+ if (responseMode === "text" && onStream) {
1220
+ streamUnsubscribe = client.onMessage((msg) => {
1221
+ if (msg.type === "USER_PROMPT_STREAM" && msg.id === `stream_${uiBlockId}`) {
1222
+ const chunk = msg.payload?.chunk;
1223
+ if (chunk) {
1224
+ onStream(chunk);
1225
+ }
1226
+ }
1227
+ });
1228
+ }
1229
+ try {
1230
+ const response = await client.sendWithResponse(message, timeout);
1231
+ return response;
1232
+ } finally {
1233
+ if (streamUnsubscribe) {
1234
+ streamUnsubscribe();
1235
+ }
1236
+ }
1237
+ }
1238
+ async function sendUserPromptSuggestionsRequest(client, prompt, userId, limit = 5, timeout) {
1239
+ if (!prompt || prompt.trim().length === 0) {
1240
+ return null;
1241
+ }
1242
+ const messageId = `suggestions_${Date.now()}`;
1243
+ const message = UserPromptSuggestionsRequestMessageSchema.parse({
1244
+ id: messageId,
1245
+ type: "USER_PROMPT_SUGGESTIONS_REQ",
1246
+ from: {
1247
+ type: client.type
1248
+ },
1249
+ to: {
1250
+ type: "data-agent"
1251
+ },
1252
+ payload: {
1253
+ prompt,
1254
+ userId,
1255
+ limit
1256
+ }
1257
+ });
1258
+ const response = await client.sendWithResponse(message, timeout);
1259
+ return response;
1260
+ }
1261
+
1262
+ // src/services/bundle.ts
1263
+ async function requestBundle(client, options) {
1264
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
1265
+ const message = BundleRequestMessageSchema.parse({
1266
+ id: messageId,
1267
+ type: "BUNDLE_REQ",
1268
+ from: { type: client.type },
1269
+ to: { type: "data-agent" },
1270
+ payload: { devbundlereq: options?.devbundlereq ?? false }
1271
+ });
1272
+ const chunks = [];
1273
+ let totalChunks = 0;
1274
+ const unsubscribe = client.onMessage((msg) => {
1275
+ try {
1276
+ if (msg.type === "BUNDLE_CHUNK" && msg.id?.startsWith(messageId)) {
1277
+ const chunkMessage = BundleChunkMessageSchema.parse(msg);
1278
+ const payload = chunkMessage.payload;
1279
+ chunks[payload.chunkIndex] = payload.chunk;
1280
+ totalChunks = payload.totalChunks;
1281
+ if (options?.onProgress) {
1282
+ options.onProgress(payload.progress);
1283
+ }
1284
+ }
1285
+ } catch (error) {
1286
+ console.error("[SuperAtom] Failed to parse bundle chunk:", error);
1287
+ }
1288
+ });
1289
+ client.send(message);
1290
+ const timeout = options?.timeout ?? 6e4;
1291
+ const startTime = Date.now();
1292
+ return new Promise((resolve, reject) => {
1293
+ const checkInterval = setInterval(() => {
1294
+ if (Date.now() - startTime > timeout) {
1295
+ clearInterval(checkInterval);
1296
+ unsubscribe();
1297
+ reject(new Error(`Bundle request timeout after ${timeout}ms`));
1298
+ return;
1299
+ }
1300
+ if (totalChunks > 0 && chunks.length === totalChunks) {
1301
+ clearInterval(checkInterval);
1302
+ unsubscribe();
1303
+ const bundle = chunks.join("");
1304
+ resolve(bundle);
1305
+ }
1306
+ }, 100);
1307
+ });
1308
+ }
1309
+
1310
+ // src/services/data.ts
1311
+ async function requestData(client, options) {
1312
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
1313
+ const message = DataRequestMessageSchema.parse({
1314
+ id: messageId,
1315
+ type: "DATA_REQ",
1316
+ from: { type: client.type },
1317
+ to: { type: "data-agent" },
1318
+ payload: {
1319
+ collection: options.collection,
1320
+ op: options.operation,
1321
+ params: options.params,
1322
+ SA_RUNTIME: options.SA_RUNTIME
1323
+ }
1324
+ });
1325
+ const response = await client.sendWithResponse(message, options.timeout);
1326
+ const payload = response.payload;
1327
+ return {
1328
+ data: payload.data,
1329
+ error: payload.error,
1330
+ executionMs: payload.executionMs
1331
+ };
1332
+ }
1333
+
1334
+ // src/services/component.ts
1335
+ async function getComponentSuggestions(client, query, options) {
1336
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
1337
+ const message = {
1338
+ id: messageId,
1339
+ type: "USER_PROMPT_REQ",
1340
+ to: { type: "data-agent" },
1341
+ payload: {
1342
+ prompt: query
1343
+ }
1344
+ };
1345
+ const response = await client.sendWithResponse(message, options?.timeout);
1346
+ const payload = response.payload;
1347
+ return {
1348
+ component: payload.component,
1349
+ error: payload.error
1350
+ };
1351
+ }
1352
+ async function sendComponents(client, components) {
1353
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
1354
+ const ws_msg = {
1355
+ id: messageId,
1356
+ type: "COMPONENT_LIST_RES",
1357
+ from: {
1358
+ type: client.type
1359
+ },
1360
+ to: {
1361
+ type: "data-agent"
1362
+ },
1363
+ payload: {
1364
+ components
1365
+ }
1366
+ };
1367
+ client.send(ws_msg);
1368
+ }
1369
+
1370
+ // src/services/users.ts
1371
+ async function createUser(client, username, password, email, fullname, role, userInfo, timeout) {
1372
+ const messageId = `users_create_${Date.now()}`;
1373
+ const message = UsersRequestMessageSchema.parse({
1374
+ id: messageId,
1375
+ type: "USERS",
1376
+ from: { type: client.type },
1377
+ to: { type: "data-agent" },
1378
+ payload: {
1379
+ operation: "create",
1380
+ data: {
1381
+ username,
1382
+ password,
1383
+ email,
1384
+ fullname,
1385
+ role,
1386
+ userInfo
1387
+ }
1388
+ }
1389
+ });
1390
+ const response = await client.sendWithResponse(message, timeout);
1391
+ const payload = response.payload;
1392
+ return {
1393
+ success: payload.success,
1394
+ error: payload.error,
1395
+ message: payload.data?.message,
1396
+ username: payload.data?.username,
1397
+ email: payload.data?.email,
1398
+ fullname: payload.data?.fullname,
1399
+ role: payload.data?.role
1400
+ };
1401
+ }
1402
+ async function updateUser(client, id, updates, timeout) {
1403
+ const messageId = `users_update_${Date.now()}`;
1404
+ const message = UsersRequestMessageSchema.parse({
1405
+ id: messageId,
1406
+ type: "USERS",
1407
+ from: { type: client.type },
1408
+ to: { type: "data-agent" },
1409
+ payload: {
1410
+ operation: "update",
1411
+ data: {
1412
+ id,
1413
+ ...updates
1414
+ }
1415
+ }
1416
+ });
1417
+ const response = await client.sendWithResponse(message, timeout);
1418
+ const payload = response.payload;
1419
+ return {
1420
+ success: payload.success,
1421
+ error: payload.error,
1422
+ message: payload.data?.message,
1423
+ username: payload.data?.username,
1424
+ email: payload.data?.email,
1425
+ fullname: payload.data?.fullname,
1426
+ role: payload.data?.role
1427
+ };
1428
+ }
1429
+ async function deleteUser(client, id, timeout) {
1430
+ const messageId = `users_delete_${Date.now()}`;
1431
+ const message = UsersRequestMessageSchema.parse({
1432
+ id: messageId,
1433
+ type: "USERS",
1434
+ from: { type: client.type },
1435
+ to: { type: "data-agent" },
1436
+ payload: {
1437
+ operation: "delete",
1438
+ data: {
1439
+ id
1440
+ }
1441
+ }
1442
+ });
1443
+ const response = await client.sendWithResponse(message, timeout);
1444
+ const payload = response.payload;
1445
+ return {
1446
+ success: payload.success,
1447
+ error: payload.error,
1448
+ message: payload.data?.message,
1449
+ username: payload.data?.username,
1450
+ email: payload.data?.email,
1451
+ fullname: payload.data?.fullname,
1452
+ role: payload.data?.role
1453
+ };
1454
+ }
1455
+ async function getAllUsers(client, timeout) {
1456
+ const messageId = `users_getall_${Date.now()}`;
1457
+ const message = UsersRequestMessageSchema.parse({
1458
+ id: messageId,
1459
+ type: "USERS",
1460
+ from: { type: client.type },
1461
+ to: { type: "data-agent" },
1462
+ payload: {
1463
+ operation: "getAll"
1464
+ }
1465
+ });
1466
+ const response = await client.sendWithResponse(message, timeout);
1467
+ const payload = response.payload;
1468
+ return {
1469
+ success: payload.success,
1470
+ error: payload.error,
1471
+ users: payload.data?.users,
1472
+ count: payload.data?.count,
1473
+ message: payload.data?.message
1474
+ };
1475
+ }
1476
+ async function getUser(client, username, timeout) {
1477
+ const messageId = `users_getone_${Date.now()}`;
1478
+ const message = UsersRequestMessageSchema.parse({
1479
+ id: messageId,
1480
+ type: "USERS",
1481
+ from: { type: client.type },
1482
+ to: { type: "data-agent" },
1483
+ payload: {
1484
+ operation: "getOne",
1485
+ data: {
1486
+ username
1487
+ }
1488
+ }
1489
+ });
1490
+ const response = await client.sendWithResponse(message, timeout);
1491
+ const payload = response.payload;
1492
+ return {
1493
+ success: payload.success,
1494
+ error: payload.error,
1495
+ user: payload.data?.user,
1496
+ message: payload.data?.message
1497
+ };
1498
+ }
1499
+ async function queryUsers(client, options = {}, timeout) {
1500
+ const { filters, limit, sort } = options;
1501
+ const messageId = `users_query_${Date.now()}`;
1502
+ const message = UsersRequestMessageSchema.parse({
1503
+ id: messageId,
1504
+ type: "USERS",
1505
+ from: { type: client.type },
1506
+ to: { type: "data-agent" },
1507
+ payload: {
1508
+ operation: "query",
1509
+ data: {
1510
+ filters,
1511
+ limit,
1512
+ sort
1513
+ }
1514
+ }
1515
+ });
1516
+ const response = await client.sendWithResponse(message, timeout);
1517
+ const payload = response.payload;
1518
+ return {
1519
+ success: payload.success,
1520
+ error: payload.error,
1521
+ users: payload.data?.users,
1522
+ count: payload.data?.count,
1523
+ message: payload.data?.message
1524
+ };
1525
+ }
1526
+
1527
+ // src/services/dashboards/index.ts
1528
+ async function createDashboard(client, options, timeout) {
1529
+ const { dashboardId, projectId, name, description, published, createdBy, allowedUsers, dashboard } = options;
1530
+ const messageId = `dashboards_create_${Date.now()}`;
1531
+ const message = DashboardsRequestMessageSchema.parse({
1532
+ id: messageId,
1533
+ type: "DASHBOARDS",
1534
+ from: { type: client.type },
1535
+ to: { type: "data-agent" },
1536
+ payload: {
1537
+ operation: "create",
1538
+ data: {
1539
+ dashboardId,
1540
+ projectId,
1541
+ name,
1542
+ description,
1543
+ published,
1544
+ createdBy,
1545
+ allowedUsers,
1546
+ dashboard
1547
+ }
1548
+ }
1549
+ });
1550
+ const response = await client.sendWithResponse(message, timeout);
1551
+ const payload = response.payload;
1552
+ return {
1553
+ success: payload.success,
1554
+ error: payload.error,
1555
+ message: payload.data?.message,
1556
+ id: payload.data?.id,
1557
+ dashboardId: payload.data?.dashboardId,
1558
+ dashboard: payload.data?.dashboard
1559
+ };
1560
+ }
1561
+ async function updateDashboard(client, options, timeout) {
1562
+ const { id, name, description, published, createdBy, updatedBy, allowedUsers, dashboard } = options;
1563
+ const messageId = `dashboards_update_${Date.now()}`;
1564
+ const message = DashboardsRequestMessageSchema.parse({
1565
+ id: messageId,
1566
+ type: "DASHBOARDS",
1567
+ from: { type: client.type },
1568
+ to: { type: "data-agent" },
1569
+ payload: {
1570
+ operation: "update",
1571
+ data: {
1572
+ id,
1573
+ name,
1574
+ description,
1575
+ published,
1576
+ createdBy,
1577
+ updatedBy,
1578
+ allowedUsers,
1579
+ dashboard
1580
+ }
1581
+ }
1582
+ });
1583
+ const response = await client.sendWithResponse(message, timeout);
1584
+ const payload = response.payload;
1585
+ return {
1586
+ success: payload.success,
1587
+ error: payload.error,
1588
+ message: payload.data?.message,
1589
+ id: payload.data?.id,
1590
+ dashboardId: payload.data?.dashboardId,
1591
+ dashboard: payload.data?.dashboard
1592
+ };
1593
+ }
1594
+ async function deleteDashboard(client, id, timeout) {
1595
+ const messageId = `dashboards_delete_${Date.now()}`;
1596
+ const message = DashboardsRequestMessageSchema.parse({
1597
+ id: messageId,
1598
+ type: "DASHBOARDS",
1599
+ from: { type: client.type },
1600
+ to: { type: "data-agent" },
1601
+ payload: {
1602
+ operation: "delete",
1603
+ data: {
1604
+ id
1605
+ }
1606
+ }
1607
+ });
1608
+ const response = await client.sendWithResponse(message, timeout);
1609
+ const payload = response.payload;
1610
+ return {
1611
+ success: payload.success,
1612
+ error: payload.error,
1613
+ message: payload.data?.message,
1614
+ id: payload.data?.id
1615
+ };
1616
+ }
1617
+ async function getAllDashboards(client, timeout) {
1618
+ const messageId = `dashboards_getall_${Date.now()}`;
1619
+ const message = DashboardsRequestMessageSchema.parse({
1620
+ id: messageId,
1621
+ type: "DASHBOARDS",
1622
+ from: { type: client.type },
1623
+ to: { type: "data-agent" },
1624
+ payload: {
1625
+ operation: "getAll"
1626
+ }
1627
+ });
1628
+ const response = await client.sendWithResponse(message, timeout);
1629
+ const payload = response.payload;
1630
+ return {
1631
+ success: payload.success,
1632
+ error: payload.error,
1633
+ dashboards: payload.data?.dashboards,
1634
+ count: payload.data?.count,
1635
+ message: payload.data?.message
1636
+ };
1637
+ }
1638
+ async function getDashboard(client, id, timeout) {
1639
+ const messageId = `dashboards_getone_${Date.now()}`;
1640
+ const message = DashboardsRequestMessageSchema.parse({
1641
+ id: messageId,
1642
+ type: "DASHBOARDS",
1643
+ from: { type: client.type },
1644
+ to: { type: "data-agent" },
1645
+ payload: {
1646
+ operation: "getOne",
1647
+ data: {
1648
+ id
1649
+ }
1650
+ }
1651
+ });
1652
+ const response = await client.sendWithResponse(message, timeout);
1653
+ const payload = response.payload;
1654
+ return {
1655
+ success: payload.success,
1656
+ error: payload.error,
1657
+ id: payload.data?.id,
1658
+ dashboardId: payload.data?.dashboardId,
1659
+ dashboard: payload.data?.dashboard,
1660
+ message: payload.data?.message
1661
+ };
1662
+ }
1663
+ async function queryDashboards(client, options = {}, timeout) {
1664
+ const { filters, limit, sort } = options;
1665
+ const messageId = `dashboards_query_${Date.now()}`;
1666
+ const message = DashboardsRequestMessageSchema.parse({
1667
+ id: messageId,
1668
+ type: "DASHBOARDS",
1669
+ from: { type: client.type },
1670
+ to: { type: "data-agent" },
1671
+ payload: {
1672
+ operation: "query",
1673
+ data: {
1674
+ filters,
1675
+ limit,
1676
+ sort
1677
+ }
1678
+ }
1679
+ });
1680
+ const response = await client.sendWithResponse(message, timeout);
1681
+ const payload = response.payload;
1682
+ return {
1683
+ success: payload.success,
1684
+ error: payload.error,
1685
+ dashboards: payload.data?.dashboards,
1686
+ count: payload.data?.count,
1687
+ message: payload.data?.message
1688
+ };
1689
+ }
1690
+
1691
+ // src/services/reports/index.ts
1692
+ async function createReport(client, options, timeout) {
1693
+ const { reportId, projectId, name, description, published, createdBy, report } = options;
1694
+ const messageId = `reports_create_${Date.now()}`;
1695
+ const message = ReportsRequestMessageSchema.parse({
1696
+ id: messageId,
1697
+ type: "REPORTS",
1698
+ from: { type: client.type },
1699
+ to: { type: "data-agent" },
1700
+ payload: {
1701
+ operation: "create",
1702
+ data: {
1703
+ reportId,
1704
+ projectId,
1705
+ name,
1706
+ description,
1707
+ published,
1708
+ createdBy,
1709
+ report
1710
+ }
1711
+ }
1712
+ });
1713
+ const response = await client.sendWithResponse(message, timeout);
1714
+ const payload = response.payload;
1715
+ return {
1716
+ success: payload.success,
1717
+ error: payload.error,
1718
+ message: payload.data?.message,
1719
+ id: payload.data?.id,
1720
+ reportId: payload.data?.reportId,
1721
+ report: payload.data?.report
1722
+ };
1723
+ }
1724
+ async function updateReport(client, options, timeout) {
1725
+ const { id, name, description, published, createdBy, updatedBy, report } = options;
1726
+ const messageId = `reports_update_${Date.now()}`;
1727
+ const message = ReportsRequestMessageSchema.parse({
1728
+ id: messageId,
1729
+ type: "REPORTS",
1730
+ from: { type: client.type },
1731
+ to: { type: "data-agent" },
1732
+ payload: {
1733
+ operation: "update",
1734
+ data: {
1735
+ id,
1736
+ name,
1737
+ description,
1738
+ published,
1739
+ createdBy,
1740
+ updatedBy,
1741
+ report
1742
+ }
1743
+ }
1744
+ });
1745
+ const response = await client.sendWithResponse(message, timeout);
1746
+ const payload = response.payload;
1747
+ return {
1748
+ success: payload.success,
1749
+ error: payload.error,
1750
+ message: payload.data?.message,
1751
+ id: payload.data?.id,
1752
+ reportId: payload.data?.reportId,
1753
+ report: payload.data?.report
1754
+ };
1755
+ }
1756
+ async function deleteReport(client, id, timeout) {
1757
+ const messageId = `reports_delete_${Date.now()}`;
1758
+ const message = ReportsRequestMessageSchema.parse({
1759
+ id: messageId,
1760
+ type: "REPORTS",
1761
+ from: { type: client.type },
1762
+ to: { type: "data-agent" },
1763
+ payload: {
1764
+ operation: "delete",
1765
+ data: {
1766
+ id
1767
+ }
1768
+ }
1769
+ });
1770
+ const response = await client.sendWithResponse(message, timeout);
1771
+ const payload = response.payload;
1772
+ return {
1773
+ success: payload.success,
1774
+ error: payload.error,
1775
+ message: payload.data?.message,
1776
+ id: payload.data?.id
1777
+ };
1778
+ }
1779
+ async function getAllReports(client, timeout) {
1780
+ const messageId = `reports_getall_${Date.now()}`;
1781
+ const message = ReportsRequestMessageSchema.parse({
1782
+ id: messageId,
1783
+ type: "REPORTS",
1784
+ from: { type: client.type },
1785
+ to: { type: "data-agent" },
1786
+ payload: {
1787
+ operation: "getAll"
1788
+ }
1789
+ });
1790
+ const response = await client.sendWithResponse(message, timeout);
1791
+ const payload = response.payload;
1792
+ return {
1793
+ success: payload.success,
1794
+ error: payload.error,
1795
+ reports: payload.data?.reports,
1796
+ count: payload.data?.count,
1797
+ message: payload.data?.message
1798
+ };
1799
+ }
1800
+ async function getReport(client, id, timeout) {
1801
+ const messageId = `reports_getone_${Date.now()}`;
1802
+ const message = ReportsRequestMessageSchema.parse({
1803
+ id: messageId,
1804
+ type: "REPORTS",
1805
+ from: { type: client.type },
1806
+ to: { type: "data-agent" },
1807
+ payload: {
1808
+ operation: "getOne",
1809
+ data: {
1810
+ id
1811
+ }
1812
+ }
1813
+ });
1814
+ const response = await client.sendWithResponse(message, timeout);
1815
+ const payload = response.payload;
1816
+ return {
1817
+ success: payload.success,
1818
+ error: payload.error,
1819
+ id: payload.data?.id,
1820
+ reportId: payload.data?.reportId,
1821
+ report: payload.data?.report,
1822
+ message: payload.data?.message
1823
+ };
1824
+ }
1825
+ async function queryReports(client, options = {}, timeout) {
1826
+ const { filters, limit, sort } = options;
1827
+ const messageId = `reports_query_${Date.now()}`;
1828
+ const message = ReportsRequestMessageSchema.parse({
1829
+ id: messageId,
1830
+ type: "REPORTS",
1831
+ from: { type: client.type },
1832
+ to: { type: "data-agent" },
1833
+ payload: {
1834
+ operation: "query",
1835
+ data: {
1836
+ filters,
1837
+ limit,
1838
+ sort
1839
+ }
1840
+ }
1841
+ });
1842
+ const response = await client.sendWithResponse(message, timeout);
1843
+ const payload = response.payload;
1844
+ return {
1845
+ success: payload.success,
1846
+ error: payload.error,
1847
+ reports: payload.data?.reports,
1848
+ count: payload.data?.count,
1849
+ message: payload.data?.message
1850
+ };
1851
+ }
1852
+
1853
+ // src/services/bookmarks/index.ts
1854
+ async function createBookmark(client, options, timeout) {
1855
+ const { userId, uiblock, threadId, name, description } = options;
1856
+ const messageId = `bookmarks_create_${Date.now()}`;
1857
+ const message = BookmarksRequestMessageSchema.parse({
1858
+ id: messageId,
1859
+ type: "BOOKMARKS",
1860
+ from: { type: client.type },
1861
+ to: { type: "data-agent" },
1862
+ payload: {
1863
+ operation: "create",
1864
+ data: {
1865
+ userId,
1866
+ threadId,
1867
+ name,
1868
+ description,
1869
+ uiblock
1870
+ }
1871
+ }
1872
+ });
1873
+ const response = await client.sendWithResponse(message, timeout);
1874
+ const payload = response.payload;
1875
+ return {
1876
+ success: payload.success,
1877
+ error: payload.error,
1878
+ message: payload.message,
1879
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
1880
+ };
1881
+ }
1882
+ async function updateBookmark(client, options, timeout) {
1883
+ const { id, uiblock, threadId, name, description } = options;
1884
+ const messageId = `bookmarks_update_${Date.now()}`;
1885
+ const message = BookmarksRequestMessageSchema.parse({
1886
+ id: messageId,
1887
+ type: "BOOKMARKS",
1888
+ from: { type: client.type },
1889
+ to: { type: "data-agent" },
1890
+ payload: {
1891
+ operation: "update",
1892
+ data: {
1893
+ id,
1894
+ threadId,
1895
+ name,
1896
+ description,
1897
+ uiblock
1898
+ }
1899
+ }
1900
+ });
1901
+ const response = await client.sendWithResponse(message, timeout);
1902
+ const payload = response.payload;
1903
+ return {
1904
+ success: payload.success,
1905
+ error: payload.error,
1906
+ message: payload.message,
1907
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
1908
+ };
1909
+ }
1910
+ async function deleteBookmark(client, id, timeout) {
1911
+ const messageId = `bookmarks_delete_${Date.now()}`;
1912
+ const message = BookmarksRequestMessageSchema.parse({
1913
+ id: messageId,
1914
+ type: "BOOKMARKS",
1915
+ from: { type: client.type },
1916
+ to: { type: "data-agent" },
1917
+ payload: {
1918
+ operation: "delete",
1919
+ data: {
1920
+ id
1921
+ }
1922
+ }
1923
+ });
1924
+ const response = await client.sendWithResponse(message, timeout);
1925
+ const payload = response.payload;
1926
+ return {
1927
+ success: payload.success,
1928
+ error: payload.error,
1929
+ message: payload.message,
1930
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
1931
+ };
1932
+ }
1933
+ async function getAllBookmarks(client, timeout) {
1934
+ const messageId = `bookmarks_getall_${Date.now()}`;
1935
+ const message = BookmarksRequestMessageSchema.parse({
1936
+ id: messageId,
1937
+ type: "BOOKMARKS",
1938
+ from: { type: client.type },
1939
+ to: { type: "data-agent" },
1940
+ payload: {
1941
+ operation: "getAll"
1942
+ }
1943
+ });
1944
+ const response = await client.sendWithResponse(message, timeout);
1945
+ const payload = response.payload;
1946
+ return {
1947
+ success: payload.success,
1948
+ error: payload.error,
1949
+ data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
1950
+ count: payload.count,
1951
+ message: payload.message
1952
+ };
1953
+ }
1954
+ async function getBookmark(client, id, timeout) {
1955
+ const messageId = `bookmarks_getone_${Date.now()}`;
1956
+ const message = BookmarksRequestMessageSchema.parse({
1957
+ id: messageId,
1958
+ type: "BOOKMARKS",
1959
+ from: { type: client.type },
1960
+ to: { type: "data-agent" },
1961
+ payload: {
1962
+ operation: "getOne",
1963
+ data: {
1964
+ id
1965
+ }
1966
+ }
1967
+ });
1968
+ const response = await client.sendWithResponse(message, timeout);
1969
+ const payload = response.payload;
1970
+ return {
1971
+ success: payload.success,
1972
+ error: payload.error,
1973
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data,
1974
+ message: payload.message
1975
+ };
1976
+ }
1977
+ async function queryBookmarks(client, options = {}, timeout) {
1978
+ const { filters, limit, sort } = options;
1979
+ const messageId = `bookmarks_query_${Date.now()}`;
1980
+ const message = BookmarksRequestMessageSchema.parse({
1981
+ id: messageId,
1982
+ type: "BOOKMARKS",
1983
+ from: { type: client.type },
1984
+ to: { type: "data-agent" },
1985
+ payload: {
1986
+ operation: "query",
1987
+ data: {
1988
+ filters,
1989
+ limit,
1990
+ sort
1991
+ }
1992
+ }
1993
+ });
1994
+ const response = await client.sendWithResponse(message, timeout);
1995
+ const payload = response.payload;
1996
+ return {
1997
+ success: payload.success,
1998
+ error: payload.error,
1999
+ data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
2000
+ count: payload.count,
2001
+ message: payload.message
2002
+ };
2003
+ }
2004
+
2005
+ // src/services/artifacts/index.ts
2006
+ async function createArtifact(client, options, timeout) {
2007
+ console.log("[SDK-WEB] createArtifact called with options:", JSON.stringify(options, null, 2));
2008
+ const { name, createdBy, dsl, type, filters, status } = options;
2009
+ console.log("[SDK-WEB] Extracted parameters:", JSON.stringify({
2010
+ name,
2011
+ createdBy,
2012
+ dsl: dsl ? "present" : "undefined",
2013
+ type,
2014
+ filters: filters ? "present" : "undefined",
2015
+ status
2016
+ }, null, 2));
2017
+ const messageId = `artifacts_create_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2018
+ const messageData = {
2019
+ name,
2020
+ createdBy,
2021
+ dsl,
2022
+ type,
2023
+ filters,
2024
+ status
2025
+ };
2026
+ console.log("[SDK-WEB] Sending message data:", JSON.stringify(messageData, null, 2));
2027
+ const message = ArtifactsRequestMessageSchema.parse({
2028
+ id: messageId,
2029
+ type: "ARTIFACTS",
2030
+ from: { type: client.type },
2031
+ to: { type: "data-agent" },
2032
+ payload: {
2033
+ operation: "create",
2034
+ data: messageData
2035
+ }
2036
+ });
2037
+ const response = await client.sendWithResponse(message, timeout);
2038
+ const payload = response.payload;
2039
+ return {
2040
+ success: payload.success,
2041
+ error: payload.error,
2042
+ message: payload.message,
2043
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
2044
+ };
2045
+ }
2046
+ async function updateArtifact(client, options, timeout) {
2047
+ const { id, name, dsl, type, filters, status, deleted } = options;
2048
+ const messageId = `artifacts_update_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2049
+ const message = ArtifactsRequestMessageSchema.parse({
2050
+ id: messageId,
2051
+ type: "ARTIFACTS",
2052
+ from: { type: client.type },
2053
+ to: { type: "data-agent" },
2054
+ payload: {
2055
+ operation: "update",
2056
+ data: {
2057
+ id,
2058
+ name,
2059
+ dsl,
2060
+ type,
2061
+ filters,
2062
+ status,
2063
+ deleted
2064
+ }
2065
+ }
2066
+ });
2067
+ const response = await client.sendWithResponse(message, timeout);
2068
+ const payload = response.payload;
2069
+ return {
2070
+ success: payload.success,
2071
+ error: payload.error,
2072
+ message: payload.message,
2073
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
2074
+ };
2075
+ }
2076
+ async function deleteArtifact(client, id, timeout) {
2077
+ const messageId = `artifacts_delete_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2078
+ const message = ArtifactsRequestMessageSchema.parse({
2079
+ id: messageId,
2080
+ type: "ARTIFACTS",
2081
+ from: { type: client.type },
2082
+ to: { type: "data-agent" },
2083
+ payload: {
2084
+ operation: "delete",
2085
+ data: {
2086
+ id
2087
+ }
2088
+ }
2089
+ });
2090
+ const response = await client.sendWithResponse(message, timeout);
2091
+ const payload = response.payload;
2092
+ return {
2093
+ success: payload.success,
2094
+ error: payload.error,
2095
+ message: payload.message,
2096
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
2097
+ };
2098
+ }
2099
+ async function getAllArtifacts(client, limit, timeout) {
2100
+ const messageId = `artifacts_getall_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2101
+ const message = ArtifactsRequestMessageSchema.parse({
2102
+ id: messageId,
2103
+ type: "ARTIFACTS",
2104
+ from: { type: client.type },
2105
+ to: { type: "data-agent" },
2106
+ payload: {
2107
+ operation: "getAll",
2108
+ data: limit ? { limit } : void 0
2109
+ }
2110
+ });
2111
+ const response = await client.sendWithResponse(message, timeout);
2112
+ const payload = response.payload;
2113
+ return {
2114
+ success: payload.success,
2115
+ error: payload.error,
2116
+ data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
2117
+ count: payload.count,
2118
+ message: payload.message
2119
+ };
2120
+ }
2121
+ async function getArtifact(client, id, timeout) {
2122
+ const messageId = `artifacts_getone_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2123
+ const message = ArtifactsRequestMessageSchema.parse({
2124
+ id: messageId,
2125
+ type: "ARTIFACTS",
2126
+ from: { type: client.type },
2127
+ to: { type: "data-agent" },
2128
+ payload: {
2129
+ operation: "getOne",
2130
+ data: {
2131
+ id
2132
+ }
2133
+ }
2134
+ });
2135
+ const response = await client.sendWithResponse(message, timeout);
2136
+ const payload = response.payload;
2137
+ return {
2138
+ success: payload.success,
2139
+ error: payload.error,
2140
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data,
2141
+ message: payload.message
2142
+ };
2143
+ }
2144
+ async function queryArtifacts(client, options = {}, timeout) {
2145
+ const { filters, limit, offset, sort } = options;
2146
+ const messageId = `artifacts_query_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2147
+ console.log("[SDK-WEB] queryArtifacts - options.filters:", JSON.stringify(filters, null, 2));
2148
+ const messageBeforeParse = {
2149
+ id: messageId,
2150
+ type: "ARTIFACTS",
2151
+ from: { type: client.type },
2152
+ to: { type: "data-agent" },
2153
+ payload: {
2154
+ operation: "query",
2155
+ data: {
2156
+ filters,
2157
+ limit,
2158
+ offset,
2159
+ sort
2160
+ }
2161
+ }
2162
+ };
2163
+ console.log("[SDK-WEB] queryArtifacts - BEFORE parse - payload.data.filters:", JSON.stringify(messageBeforeParse.payload.data.filters, null, 2));
2164
+ const message = ArtifactsRequestMessageSchema.parse(messageBeforeParse);
2165
+ console.log("[SDK-WEB] queryArtifacts - AFTER parse - payload.data.filters:", JSON.stringify(message.payload.data?.filters, null, 2));
2166
+ console.log("[SDK-WEB] queryArtifacts - filters.type:", message.payload.data?.filters?.type);
2167
+ const response = await client.sendWithResponse(message, timeout);
2168
+ const payload = response.payload;
2169
+ return {
2170
+ success: payload.success,
2171
+ error: payload.error,
2172
+ data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
2173
+ count: payload.count,
2174
+ message: payload.message
2175
+ };
2176
+ }
2177
+
2178
+ // src/services/actions.ts
2179
+ async function getActions(client, options) {
2180
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2181
+ const message = ActionsRequestMessageSchema.parse({
2182
+ id: messageId,
2183
+ type: "ACTIONS",
2184
+ from: { type: client.type },
2185
+ to: { type: "data-agent" },
2186
+ payload: {
2187
+ userId: options.userId,
2188
+ SA_RUNTIME: options.SA_RUNTIME
2189
+ }
2190
+ });
2191
+ const response = await client.sendWithResponse(message, options.timeout);
2192
+ const payload = response.payload;
2193
+ return {
2194
+ success: payload.success,
2195
+ data: payload.data,
2196
+ error: payload.error
2197
+ };
2198
+ }
2199
+
2200
+ // src/services/uis/index.ts
2201
+ async function createUI(client, options, timeout) {
2202
+ const { uiId, projectId, name, description, createdBy, ui } = options;
2203
+ const messageId = `uis_create_${Date.now()}`;
2204
+ const message = UIsRequestMessageSchema.parse({
2205
+ id: messageId,
2206
+ type: "UIS",
2207
+ from: { type: client.type },
2208
+ to: { type: "data-agent" },
2209
+ payload: {
2210
+ operation: "create",
2211
+ data: {
2212
+ uiId,
2213
+ projectId,
2214
+ name,
2215
+ description,
2216
+ createdBy,
2217
+ ui
2218
+ }
2219
+ }
2220
+ });
2221
+ const response = await client.sendWithResponse(message, timeout);
2222
+ const payload = response.payload;
2223
+ return {
2224
+ success: payload.success,
2225
+ error: payload.error,
2226
+ message: payload.data?.message,
2227
+ id: payload.data?.id,
2228
+ uiId: payload.data?.uiId,
2229
+ ui: payload.data?.ui
2230
+ };
2231
+ }
2232
+ async function updateUI(client, options, timeout) {
2233
+ const { id, name, description, createdBy, updatedBy, ui } = options;
2234
+ const messageId = `uis_update_${Date.now()}`;
2235
+ const message = UIsRequestMessageSchema.parse({
2236
+ id: messageId,
2237
+ type: "UIS",
2238
+ from: { type: client.type },
2239
+ to: { type: "data-agent" },
2240
+ payload: {
2241
+ operation: "update",
2242
+ data: {
2243
+ id,
2244
+ name,
2245
+ description,
2246
+ createdBy,
2247
+ updatedBy,
2248
+ ui
2249
+ }
2250
+ }
2251
+ });
2252
+ const response = await client.sendWithResponse(message, timeout);
2253
+ const payload = response.payload;
2254
+ return {
2255
+ success: payload.success,
2256
+ error: payload.error,
2257
+ message: payload.data?.message,
2258
+ id: payload.data?.id,
2259
+ uiId: payload.data?.uiId,
2260
+ ui: payload.data?.ui
2261
+ };
2262
+ }
2263
+ async function deleteUI(client, id, timeout) {
2264
+ const messageId = `uis_delete_${Date.now()}`;
2265
+ const message = UIsRequestMessageSchema.parse({
2266
+ id: messageId,
2267
+ type: "UIS",
2268
+ from: { type: client.type },
2269
+ to: { type: "data-agent" },
2270
+ payload: {
2271
+ operation: "delete",
2272
+ data: {
2273
+ id
2274
+ }
2275
+ }
2276
+ });
2277
+ const response = await client.sendWithResponse(message, timeout);
2278
+ const payload = response.payload;
2279
+ return {
2280
+ success: payload.success,
2281
+ error: payload.error,
2282
+ message: payload.data?.message,
2283
+ id: payload.data?.id
2284
+ };
2285
+ }
2286
+ async function getAllUIs(client, timeout) {
2287
+ const messageId = `uis_getall_${Date.now()}`;
2288
+ const message = UIsRequestMessageSchema.parse({
2289
+ id: messageId,
2290
+ type: "UIS",
2291
+ from: { type: client.type },
2292
+ to: { type: "data-agent" },
2293
+ payload: {
2294
+ operation: "getAll"
2295
+ }
2296
+ });
2297
+ const response = await client.sendWithResponse(message, timeout);
2298
+ const payload = response.payload;
2299
+ return {
2300
+ success: payload.success,
2301
+ error: payload.error,
2302
+ uis: payload.data?.uis,
2303
+ count: payload.data?.count,
2304
+ message: payload.data?.message
2305
+ };
2306
+ }
2307
+ async function getUI(client, id, timeout) {
2308
+ const messageId = `uis_getone_${Date.now()}`;
2309
+ const message = UIsRequestMessageSchema.parse({
2310
+ id: messageId,
2311
+ type: "UIS",
2312
+ from: { type: client.type },
2313
+ to: { type: "data-agent" },
2314
+ payload: {
2315
+ operation: "getOne",
2316
+ data: {
2317
+ id
2318
+ }
2319
+ }
2320
+ });
2321
+ const response = await client.sendWithResponse(message, timeout);
2322
+ const payload = response.payload;
2323
+ return {
2324
+ success: payload.success,
2325
+ error: payload.error,
2326
+ id: payload.data?.id,
2327
+ uiId: payload.data?.uiId,
2328
+ ui: payload.data?.ui,
2329
+ message: payload.data?.message
2330
+ };
2331
+ }
2332
+ async function queryUIs(client, options = {}, timeout) {
2333
+ const { filters, limit, sort } = options;
2334
+ const messageId = `uis_query_${Date.now()}`;
2335
+ const message = UIsRequestMessageSchema.parse({
2336
+ id: messageId,
2337
+ type: "UIS",
2338
+ from: { type: client.type },
2339
+ to: { type: "data-agent" },
2340
+ payload: {
2341
+ operation: "query",
2342
+ data: {
2343
+ filters,
2344
+ limit,
2345
+ sort
2346
+ }
2347
+ }
2348
+ });
2349
+ const response = await client.sendWithResponse(message, timeout);
2350
+ const payload = response.payload;
2351
+ return {
2352
+ success: payload.success,
2353
+ error: payload.error,
2354
+ uis: payload.data?.uis,
2355
+ count: payload.data?.count,
2356
+ message: payload.data?.message
2357
+ };
2358
+ }
2359
+
2360
+ // src/services/kb-nodes.ts
2361
+ async function createKbNode(client, title, content, createdBy, category, tags, type, timeout) {
2362
+ const messageId = `kb_nodes_create_${Date.now()}`;
2363
+ const message = KbNodesRequestMessageSchema.parse({
2364
+ id: messageId,
2365
+ type: "KB_NODES",
2366
+ from: { type: client.type },
2367
+ to: { type: "data-agent" },
2368
+ payload: {
2369
+ operation: "create",
2370
+ data: {
2371
+ title,
2372
+ content,
2373
+ createdBy,
2374
+ category,
2375
+ tags,
2376
+ type: type || "query"
2377
+ }
2378
+ }
2379
+ });
2380
+ const response = await client.sendWithResponse(message, timeout);
2381
+ const payload = response.payload;
2382
+ return {
2383
+ success: payload.success,
2384
+ error: payload.error,
2385
+ message: payload.data?.message,
2386
+ node: payload.data ? {
2387
+ id: payload.data.id,
2388
+ title: payload.data.title || title,
2389
+ content: payload.data.content || content,
2390
+ category: payload.data.category,
2391
+ tags: payload.data.tags,
2392
+ type: payload.data.type,
2393
+ createdBy: payload.data.createdBy || createdBy,
2394
+ updatedBy: payload.data.updatedBy,
2395
+ createdAt: payload.data.createdAt,
2396
+ updatedAt: payload.data.updatedAt
2397
+ } : void 0
2398
+ };
2399
+ }
2400
+ async function updateKbNode(client, id, updatedBy, updates, timeout) {
2401
+ const messageId = `kb_nodes_update_${Date.now()}`;
2402
+ const message = KbNodesRequestMessageSchema.parse({
2403
+ id: messageId,
2404
+ type: "KB_NODES",
2405
+ from: { type: client.type },
2406
+ to: { type: "data-agent" },
2407
+ payload: {
2408
+ operation: "update",
2409
+ data: {
2410
+ id,
2411
+ updatedBy,
2412
+ ...updates
2413
+ }
2414
+ }
2415
+ });
2416
+ const response = await client.sendWithResponse(message, timeout);
2417
+ const payload = response.payload;
2418
+ return {
2419
+ success: payload.success,
2420
+ error: payload.error,
2421
+ message: payload.data?.message,
2422
+ node: payload.data ? {
2423
+ id: payload.data.id,
2424
+ title: payload.data.title || "",
2425
+ content: payload.data.content || "",
2426
+ category: payload.data.category,
2427
+ tags: payload.data.tags,
2428
+ type: payload.data.type,
2429
+ createdBy: payload.data.createdBy || "",
2430
+ updatedBy: payload.data.updatedBy,
2431
+ createdAt: payload.data.createdAt,
2432
+ updatedAt: payload.data.updatedAt
2433
+ } : void 0
2434
+ };
2435
+ }
2436
+ async function deleteKbNode(client, id, timeout) {
2437
+ const messageId = `kb_nodes_delete_${Date.now()}`;
2438
+ const message = KbNodesRequestMessageSchema.parse({
2439
+ id: messageId,
2440
+ type: "KB_NODES",
2441
+ from: { type: client.type },
2442
+ to: { type: "data-agent" },
2443
+ payload: {
2444
+ operation: "delete",
2445
+ data: {
2446
+ id
2447
+ }
2448
+ }
2449
+ });
2450
+ const response = await client.sendWithResponse(message, timeout);
2451
+ const payload = response.payload;
2452
+ return {
2453
+ success: payload.success,
2454
+ error: payload.error,
2455
+ message: payload.data?.message
2456
+ };
2457
+ }
2458
+ async function getAllKbNodes(client, limit, offset, timeout) {
2459
+ const messageId = `kb_nodes_getall_${Date.now()}`;
2460
+ const message = KbNodesRequestMessageSchema.parse({
2461
+ id: messageId,
2462
+ type: "KB_NODES",
2463
+ from: { type: client.type },
2464
+ to: { type: "data-agent" },
2465
+ payload: {
2466
+ operation: "getAll",
2467
+ data: {
2468
+ limit,
2469
+ offset
2470
+ }
2471
+ }
2472
+ });
2473
+ const response = await client.sendWithResponse(message, timeout);
2474
+ const payload = response.payload;
2475
+ return {
2476
+ success: payload.success,
2477
+ error: payload.error,
2478
+ nodes: payload.data?.nodes,
2479
+ count: payload.data?.count,
2480
+ message: payload.data?.message
2481
+ };
2482
+ }
2483
+ async function getKbNode(client, id, timeout) {
2484
+ const messageId = `kb_nodes_getone_${Date.now()}`;
2485
+ const message = KbNodesRequestMessageSchema.parse({
2486
+ id: messageId,
2487
+ type: "KB_NODES",
2488
+ from: { type: client.type },
2489
+ to: { type: "data-agent" },
2490
+ payload: {
2491
+ operation: "getOne",
2492
+ data: {
2493
+ id
2494
+ }
2495
+ }
2496
+ });
2497
+ const response = await client.sendWithResponse(message, timeout);
2498
+ const payload = response.payload;
2499
+ return {
2500
+ success: payload.success,
2501
+ error: payload.error,
2502
+ node: payload.data?.node,
2503
+ message: payload.data?.message
2504
+ };
2505
+ }
2506
+ async function searchKbNodes(client, options = {}, timeout) {
2507
+ const { query, category, tags, type, createdBy, limit, offset } = options;
2508
+ const messageId = `kb_nodes_search_${Date.now()}`;
2509
+ const message = KbNodesRequestMessageSchema.parse({
2510
+ id: messageId,
2511
+ type: "KB_NODES",
2512
+ from: { type: client.type },
2513
+ to: { type: "data-agent" },
2514
+ payload: {
2515
+ operation: "search",
2516
+ data: {
2517
+ query,
2518
+ category,
2519
+ tags,
2520
+ type,
2521
+ createdBy,
2522
+ limit,
2523
+ offset
2524
+ }
2525
+ }
2526
+ });
2527
+ const response = await client.sendWithResponse(message, timeout);
2528
+ const payload = response.payload;
2529
+ return {
2530
+ success: payload.success,
2531
+ error: payload.error,
2532
+ nodes: payload.data?.nodes,
2533
+ count: payload.data?.count,
2534
+ message: payload.data?.message
2535
+ };
2536
+ }
2537
+ async function getKbNodesByCategory(client, category, limit, offset, timeout) {
2538
+ const messageId = `kb_nodes_getbycategory_${Date.now()}`;
2539
+ const message = KbNodesRequestMessageSchema.parse({
2540
+ id: messageId,
2541
+ type: "KB_NODES",
2542
+ from: { type: client.type },
2543
+ to: { type: "data-agent" },
2544
+ payload: {
2545
+ operation: "getByCategory",
2546
+ data: {
2547
+ category,
2548
+ limit,
2549
+ offset
2550
+ }
2551
+ }
2552
+ });
2553
+ const response = await client.sendWithResponse(message, timeout);
2554
+ const payload = response.payload;
2555
+ return {
2556
+ success: payload.success,
2557
+ error: payload.error,
2558
+ nodes: payload.data?.nodes,
2559
+ count: payload.data?.count,
2560
+ category: payload.data?.category || category,
2561
+ message: payload.data?.message
2562
+ };
2563
+ }
2564
+ async function getKbNodesByUser(client, userId, limit, offset, timeout) {
2565
+ const messageId = `kb_nodes_getbyuser_${Date.now()}`;
2566
+ const message = KbNodesRequestMessageSchema.parse({
2567
+ id: messageId,
2568
+ type: "KB_NODES",
2569
+ from: { type: client.type },
2570
+ to: { type: "data-agent" },
2571
+ payload: {
2572
+ operation: "getByUser",
2573
+ data: {
2574
+ userId,
2575
+ limit,
2576
+ offset
2577
+ }
2578
+ }
2579
+ });
2580
+ const response = await client.sendWithResponse(message, timeout);
2581
+ const payload = response.payload;
2582
+ return {
2583
+ success: payload.success,
2584
+ error: payload.error,
2585
+ nodes: payload.data?.nodes,
2586
+ count: payload.data?.count,
2587
+ userId: payload.data?.userId || userId,
2588
+ message: payload.data?.message
2589
+ };
2590
+ }
2591
+ async function getKbNodeCategories(client, timeout) {
2592
+ const messageId = `kb_nodes_getcategories_${Date.now()}`;
2593
+ const message = KbNodesRequestMessageSchema.parse({
2594
+ id: messageId,
2595
+ type: "KB_NODES",
2596
+ from: { type: client.type },
2597
+ to: { type: "data-agent" },
2598
+ payload: {
2599
+ operation: "getCategories"
2600
+ }
2601
+ });
2602
+ const response = await client.sendWithResponse(message, timeout);
2603
+ const payload = response.payload;
2604
+ return {
2605
+ success: payload.success,
2606
+ error: payload.error,
2607
+ categories: payload.data?.categories,
2608
+ count: payload.data?.count,
2609
+ message: payload.data?.message
2610
+ };
2611
+ }
2612
+ async function getKbNodeTags(client, timeout) {
2613
+ const messageId = `kb_nodes_gettags_${Date.now()}`;
2614
+ const message = KbNodesRequestMessageSchema.parse({
2615
+ id: messageId,
2616
+ type: "KB_NODES",
2617
+ from: { type: client.type },
2618
+ to: { type: "data-agent" },
2619
+ payload: {
2620
+ operation: "getTags"
2621
+ }
2622
+ });
2623
+ const response = await client.sendWithResponse(message, timeout);
2624
+ const payload = response.payload;
2625
+ const responseData = payload.data;
2626
+ return {
2627
+ success: payload.success,
2628
+ error: payload.error,
2629
+ tags: responseData?.tags,
2630
+ count: payload.data?.count,
2631
+ message: payload.data?.message
2632
+ };
2633
+ }
2634
+
2635
+ // src/services/dash-comp.ts
2636
+ async function sendDashCompRequest(client, options) {
2637
+ const { prompt, userId, threadId, uiBlockId, timeout, existingComponents, reqType } = options;
2638
+ const messageId = `dash_comp_req_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2639
+ const message = DashCompRequestMessageSchema.parse({
2640
+ id: messageId,
2641
+ type: "DASH_COMP_REQ",
2642
+ from: {
2643
+ type: client.type
2644
+ },
2645
+ to: {
2646
+ type: "data-agent"
2647
+ },
2648
+ payload: {
2649
+ prompt,
2650
+ userId,
2651
+ SA_RUNTIME: threadId || uiBlockId ? {
2652
+ threadId,
2653
+ uiBlockId
2654
+ } : void 0,
2655
+ existingComponents,
2656
+ req_type: reqType
2657
+ }
2658
+ });
2659
+ try {
2660
+ const response = await client.sendWithResponse(message, timeout);
2661
+ const payload = response.payload;
2662
+ if (!payload.success) {
2663
+ return {
2664
+ success: false,
2665
+ errors: payload.errors || ["Unknown error occurred"]
2666
+ };
2667
+ }
2668
+ if (reqType === "filter") {
2669
+ return {
2670
+ success: true,
2671
+ filterComponent: payload.data?.filterComponent,
2672
+ updatedComponents: payload.data?.updatedComponents,
2673
+ filterBindings: payload.data?.filterBindings,
2674
+ reasoning: payload.data?.reasoning
2675
+ };
2676
+ }
2677
+ return {
2678
+ success: true,
2679
+ component: payload.data?.component,
2680
+ reasoning: payload.data?.reasoning,
2681
+ dataSource: payload.data?.dataSource
2682
+ };
2683
+ } catch (error) {
2684
+ const errorMessage = error instanceof Error ? error.message : "Request failed";
2685
+ return {
2686
+ success: false,
2687
+ errors: [errorMessage]
2688
+ };
2689
+ }
2690
+ }
2691
+
2692
+ // src/services/menus/index.ts
2693
+ async function createMenu(client, options, timeout) {
2694
+ const { name, componentName, icon, userMessage, parentId, sortOrder, props, isActive } = options;
2695
+ const messageId = `menus_create_${Date.now()}`;
2696
+ const message = MenusRequestMessageSchema.parse({
2697
+ id: messageId,
2698
+ type: "MENUS",
2699
+ from: { type: client.type },
2700
+ to: { type: "data-agent" },
2701
+ payload: {
2702
+ operation: "create",
2703
+ data: {
2704
+ name,
2705
+ componentName,
2706
+ icon,
2707
+ userMessage,
2708
+ parentId,
2709
+ sortOrder,
2710
+ props,
2711
+ isActive
2712
+ }
2713
+ }
2714
+ });
2715
+ const response = await client.sendWithResponse(message, timeout);
2716
+ const payload = response.payload;
2717
+ return {
2718
+ success: payload.success,
2719
+ error: payload.error,
2720
+ message: payload.message,
2721
+ data: payload.data
2722
+ };
2723
+ }
2724
+ async function updateMenu(client, options, timeout) {
2725
+ const { id, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive } = options;
2726
+ const messageId = `menus_update_${Date.now()}`;
2727
+ const message = MenusRequestMessageSchema.parse({
2728
+ id: messageId,
2729
+ type: "MENUS",
2730
+ from: { type: client.type },
2731
+ to: { type: "data-agent" },
2732
+ payload: {
2733
+ operation: "update",
2734
+ data: {
2735
+ id,
2736
+ name,
2737
+ componentName,
2738
+ icon,
2739
+ userMessage,
2740
+ parentId,
2741
+ sortOrder,
2742
+ props,
2743
+ isActive
2744
+ }
2745
+ }
2746
+ });
2747
+ const response = await client.sendWithResponse(message, timeout);
2748
+ const payload = response.payload;
2749
+ return {
2750
+ success: payload.success,
2751
+ error: payload.error,
2752
+ message: payload.message,
2753
+ data: payload.data
2754
+ };
2755
+ }
2756
+ async function deleteMenu(client, id, timeout) {
2757
+ const messageId = `menus_delete_${Date.now()}`;
2758
+ const message = MenusRequestMessageSchema.parse({
2759
+ id: messageId,
2760
+ type: "MENUS",
2761
+ from: { type: client.type },
2762
+ to: { type: "data-agent" },
2763
+ payload: {
2764
+ operation: "delete",
2765
+ data: {
2766
+ id
2767
+ }
2768
+ }
2769
+ });
2770
+ const response = await client.sendWithResponse(message, timeout);
2771
+ const payload = response.payload;
2772
+ return {
2773
+ success: payload.success,
2774
+ error: payload.error,
2775
+ message: payload.message,
2776
+ data: payload.data
2777
+ };
2778
+ }
2779
+ async function getAllMenus(client, timeout) {
2780
+ const messageId = `menus_getall_${Date.now()}`;
2781
+ const message = MenusRequestMessageSchema.parse({
2782
+ id: messageId,
2783
+ type: "MENUS",
2784
+ from: { type: client.type },
2785
+ to: { type: "data-agent" },
2786
+ payload: {
2787
+ operation: "getAll"
2788
+ }
2789
+ });
2790
+ const response = await client.sendWithResponse(message, timeout);
2791
+ const payload = response.payload;
2792
+ return {
2793
+ success: payload.success,
2794
+ error: payload.error,
2795
+ menus: Array.isArray(payload.data) ? payload.data : void 0,
2796
+ count: payload.count,
2797
+ message: payload.message
2798
+ };
2799
+ }
2800
+ async function getMenu(client, id, timeout) {
2801
+ const messageId = `menus_getone_${Date.now()}`;
2802
+ const message = MenusRequestMessageSchema.parse({
2803
+ id: messageId,
2804
+ type: "MENUS",
2805
+ from: { type: client.type },
2806
+ to: { type: "data-agent" },
2807
+ payload: {
2808
+ operation: "getOne",
2809
+ data: {
2810
+ id
2811
+ }
2812
+ }
2813
+ });
2814
+ const response = await client.sendWithResponse(message, timeout);
2815
+ const payload = response.payload;
2816
+ return {
2817
+ success: payload.success,
2818
+ error: payload.error,
2819
+ menu: payload.data,
2820
+ message: payload.message
2821
+ };
2822
+ }
2823
+ async function getRootMenus(client, timeout) {
2824
+ const messageId = `menus_getrootmenus_${Date.now()}`;
2825
+ const message = MenusRequestMessageSchema.parse({
2826
+ id: messageId,
2827
+ type: "MENUS",
2828
+ from: { type: client.type },
2829
+ to: { type: "data-agent" },
2830
+ payload: {
2831
+ operation: "getRootMenus"
2832
+ }
2833
+ });
2834
+ const response = await client.sendWithResponse(message, timeout);
2835
+ const payload = response.payload;
2836
+ return {
2837
+ success: payload.success,
2838
+ error: payload.error,
2839
+ menus: Array.isArray(payload.data) ? payload.data : void 0,
2840
+ count: payload.count,
2841
+ message: payload.message
2842
+ };
2843
+ }
2844
+ async function getChildMenus(client, parentId, timeout) {
2845
+ const messageId = `menus_getchildmenus_${Date.now()}`;
2846
+ const message = MenusRequestMessageSchema.parse({
2847
+ id: messageId,
2848
+ type: "MENUS",
2849
+ from: { type: client.type },
2850
+ to: { type: "data-agent" },
2851
+ payload: {
2852
+ operation: "getChildMenus",
2853
+ data: {
2854
+ parentId
2855
+ }
2856
+ }
2857
+ });
2858
+ const response = await client.sendWithResponse(message, timeout);
2859
+ const payload = response.payload;
2860
+ return {
2861
+ success: payload.success,
2862
+ error: payload.error,
2863
+ menus: Array.isArray(payload.data) ? payload.data : void 0,
2864
+ count: payload.count,
2865
+ message: payload.message
2866
+ };
2867
+ }
2868
+ async function getMenusHierarchy(client, timeout) {
2869
+ const messageId = `menus_gethierarchy_${Date.now()}`;
2870
+ const message = MenusRequestMessageSchema.parse({
2871
+ id: messageId,
2872
+ type: "MENUS",
2873
+ from: { type: client.type },
2874
+ to: { type: "data-agent" },
2875
+ payload: {
2876
+ operation: "getHierarchy"
2877
+ }
2878
+ });
2879
+ const response = await client.sendWithResponse(message, timeout);
2880
+ const payload = response.payload;
2881
+ return {
2882
+ success: payload.success,
2883
+ error: payload.error,
2884
+ menus: Array.isArray(payload.data) ? payload.data : void 0,
2885
+ count: payload.count,
2886
+ message: payload.message
2887
+ };
2888
+ }
2889
+ async function queryMenus(client, options = {}, timeout) {
2890
+ const { filters, limit, sort } = options;
2891
+ const messageId = `menus_query_${Date.now()}`;
2892
+ const message = MenusRequestMessageSchema.parse({
2893
+ id: messageId,
2894
+ type: "MENUS",
2895
+ from: { type: client.type },
2896
+ to: { type: "data-agent" },
2897
+ payload: {
2898
+ operation: "query",
2899
+ data: {
2900
+ filters,
2901
+ limit,
2902
+ sort
2903
+ }
2904
+ }
2905
+ });
2906
+ const response = await client.sendWithResponse(message, timeout);
2907
+ const payload = response.payload;
2908
+ return {
2909
+ success: payload.success,
2910
+ error: payload.error,
2911
+ menus: Array.isArray(payload.data) ? payload.data : void 0,
2912
+ count: payload.count,
2913
+ message: payload.message
2914
+ };
2915
+ }
2916
+ async function reorderMenus(client, items, timeout) {
2917
+ const messageId = `menus_reorder_${Date.now()}`;
2918
+ const message = MenusRequestMessageSchema.parse({
2919
+ id: messageId,
2920
+ type: "MENUS",
2921
+ from: { type: client.type },
2922
+ to: { type: "data-agent" },
2923
+ payload: {
2924
+ operation: "reorder",
2925
+ data: {
2926
+ items
2927
+ }
2928
+ }
2929
+ });
2930
+ const response = await client.sendWithResponse(message, timeout);
2931
+ const payload = response.payload;
2932
+ return {
2933
+ success: payload.success,
2934
+ error: payload.error,
2935
+ message: payload.message,
2936
+ data: Array.isArray(payload.data) ? payload.data : void 0
2937
+ };
2938
+ }
2939
+
2940
+ // src/services/schema.ts
2941
+ async function getSchema(client, options = {}) {
2942
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2943
+ const message = SchemaRequestMessageSchema.parse({
2944
+ id: messageId,
2945
+ type: "SCHEMA_REQ",
2946
+ from: { type: client.type },
2947
+ to: { type: "data-agent" },
2948
+ payload: {
2949
+ formatted: options.formatted ?? false
2950
+ }
2951
+ });
2952
+ const response = await client.sendWithResponse(message, options.timeout);
2953
+ const payload = response.payload;
2954
+ return {
2955
+ success: payload.success,
2956
+ error: payload.error,
2957
+ data: payload.data
2958
+ };
2959
+ }
2960
+
2961
+ // src/client.ts
2962
+ var SuperatomClient = class {
2963
+ constructor(config) {
2964
+ this.socket = null;
2965
+ this.reconnectAttempts = 0;
2966
+ this.reconnectTimer = null;
2967
+ this.shouldReconnect = true;
2968
+ this.messageHandlers = /* @__PURE__ */ new Set();
2969
+ this.connectionHandlers = /* @__PURE__ */ new Set();
2970
+ this.disconnectionHandlers = /* @__PURE__ */ new Set();
2971
+ this.errorHandlers = /* @__PURE__ */ new Set();
2972
+ this.connectPromise = null;
2973
+ this.connectResolve = null;
2974
+ const parsed = ClientConfigSchema.parse(config);
2975
+ this.config = parsed;
2976
+ }
2977
+ /**
2978
+ * Get WebSocket URL with query parameters
2979
+ */
2980
+ getWebSocketUrl() {
2981
+ const params = new URLSearchParams({
2982
+ userId: this.config.userId,
2983
+ projectId: this.config.projectId,
2984
+ type: this.config.type
2985
+ });
2986
+ return `${this.config.baseUrl}?${params.toString()}`;
2987
+ }
2988
+ /**
2989
+ * Calculate reconnection delay with exponential backoff
2990
+ */
2991
+ calculateReconnectDelay() {
2992
+ const delay = Math.min(
2993
+ this.config.initialReconnectDelay * Math.pow(2, this.reconnectAttempts),
2994
+ this.config.maxReconnectDelay
2995
+ );
2996
+ return delay + Math.random() * 1e3;
2997
+ }
2998
+ /**
2999
+ * Schedule reconnection attempt
3000
+ */
3001
+ scheduleReconnect() {
3002
+ if (!this.shouldReconnect) {
3003
+ return;
3004
+ }
3005
+ if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
3006
+ const error = new Error("Max reconnection attempts reached");
3007
+ this.log("error", error.message);
3008
+ this.errorHandlers.forEach((handler) => handler(error));
3009
+ return;
3010
+ }
3011
+ const delay = this.calculateReconnectDelay();
3012
+ this.log("info", `Scheduling reconnection attempt ${this.reconnectAttempts + 1} in ${delay}ms`);
3013
+ this.reconnectTimer = setTimeout(() => {
3014
+ this.reconnectAttempts++;
3015
+ this.connect();
3016
+ }, delay);
3017
+ }
3018
+ /**
3019
+ * Setup WebSocket event handlers
3020
+ */
3021
+ setupSocketHandlers() {
3022
+ if (!this.socket) {
3023
+ return;
3024
+ }
3025
+ this.socket.onopen = () => {
3026
+ this.log("info", "Connected to SuperAtom");
3027
+ this.reconnectAttempts = 0;
3028
+ if (this.connectResolve) {
3029
+ this.connectResolve();
3030
+ this.connectResolve = null;
3031
+ }
3032
+ this.connectionHandlers.forEach((handler) => handler());
3033
+ };
3034
+ this.socket.onmessage = (event) => {
3035
+ try {
3036
+ const parsed = JSON.parse(event.data);
3037
+ const message = MessageSchema.parse(parsed);
3038
+ this.messageHandlers.forEach((handler) => handler(message));
3039
+ } catch (error) {
3040
+ this.log("error", "Failed to parse message:", error);
3041
+ const err = error instanceof Error ? error : new Error("Parse error");
3042
+ this.errorHandlers.forEach((handler) => handler(err));
3043
+ }
3044
+ };
3045
+ this.socket.onclose = (event) => {
3046
+ this.log("info", "Disconnected from SuperAtom", {
3047
+ code: event.code,
3048
+ reason: event.reason,
3049
+ wasClean: event.wasClean
3050
+ });
3051
+ this.disconnectionHandlers.forEach((handler) => handler());
3052
+ if (this.shouldReconnect && !event.wasClean) {
3053
+ this.scheduleReconnect();
3054
+ }
3055
+ };
3056
+ this.socket.onerror = (error) => {
3057
+ this.log("error", "WebSocket error:", error);
3058
+ this.errorHandlers.forEach((handler) => handler(error));
3059
+ };
3060
+ }
3061
+ /**
3062
+ * Connect to SuperAtom WebSocket server
3063
+ * Returns a Promise that resolves when the connection is established
3064
+ * The Promise never rejects - failures are logged silently and auto-reconnect is triggered
3065
+ */
3066
+ connect() {
3067
+ if (this.socket?.readyState === WebSocket.OPEN) {
3068
+ this.log("warn", "Already connected");
3069
+ return Promise.resolve();
3070
+ }
3071
+ if (this.socket?.readyState === WebSocket.CONNECTING && this.connectPromise) {
3072
+ this.log("warn", "Connection already in progress");
3073
+ return this.connectPromise;
3074
+ }
3075
+ this.connectPromise = new Promise((resolve) => {
3076
+ this.connectResolve = resolve;
3077
+ });
3078
+ try {
3079
+ this.socket = new WebSocket(this.getWebSocketUrl());
3080
+ this.setupSocketHandlers();
3081
+ } catch (error) {
3082
+ this.log("error", "Failed to create WebSocket:", error);
3083
+ const err = error instanceof Error ? error : new Error("Connection failed");
3084
+ this.errorHandlers.forEach((handler) => handler(err));
3085
+ this.scheduleReconnect();
3086
+ }
3087
+ return this.connectPromise;
3088
+ }
3089
+ /**
3090
+ * Disconnect from WebSocket server
3091
+ */
3092
+ disconnect() {
3093
+ this.shouldReconnect = false;
3094
+ if (this.reconnectTimer) {
3095
+ clearTimeout(this.reconnectTimer);
3096
+ this.reconnectTimer = null;
3097
+ }
3098
+ if (this.socket) {
3099
+ this.socket.close(1e3, "Client disconnect");
3100
+ this.socket = null;
3101
+ }
3102
+ this.reconnectAttempts = 0;
3103
+ }
3104
+ /**
3105
+ * Update client configuration
3106
+ */
3107
+ updateConfig(config) {
3108
+ const merged = { ...this.config, ...config };
3109
+ const parsed = ClientConfigSchema.parse(merged);
3110
+ this.config = parsed;
3111
+ }
3112
+ /**
3113
+ * Reconnect with new configuration
3114
+ * Disconnects from existing connection and reconnects with updated config
3115
+ * Returns a Promise that resolves when the new connection is established
3116
+ */
3117
+ reconnectWithConfig(config) {
3118
+ this.updateConfig(config);
3119
+ if (this.socket) {
3120
+ this.disconnect();
3121
+ }
3122
+ this.shouldReconnect = true;
3123
+ return this.connect();
3124
+ }
3125
+ /**
3126
+ * Send a message to the server
3127
+ */
3128
+ send(message) {
3129
+ if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
3130
+ throw new Error("WebSocket is not connected");
3131
+ }
3132
+ const fullMessage = {
3133
+ ...message,
3134
+ from: message.from || { type: this.config.type }
3135
+ };
3136
+ try {
3137
+ this.socket.send(JSON.stringify(fullMessage));
3138
+ } catch (error) {
3139
+ this.log("error", "Failed to send message:", error);
3140
+ throw error;
3141
+ }
3142
+ }
3143
+ /**
3144
+ * Send a message and wait for a response with the same ID
3145
+ * Uses closure-based approach - no global state management needed
3146
+ */
3147
+ async sendWithResponse(message, timeout) {
3148
+ const messageId = message.id || `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
3149
+ const messageWithId = { ...message, id: messageId };
3150
+ const timeoutMs = timeout ?? this.config.defaultTimeout;
3151
+ this.send(messageWithId);
3152
+ return new Promise((resolve, reject) => {
3153
+ let isResolved = false;
3154
+ const responseHandler = (msg) => {
3155
+ if (msg.id === messageId && !isResolved) {
3156
+ isResolved = true;
3157
+ clearTimeout(timer);
3158
+ unsubscribe();
3159
+ resolve(msg);
3160
+ }
3161
+ };
3162
+ const unsubscribe = this.onMessage(responseHandler);
3163
+ const timer = setTimeout(() => {
3164
+ if (!isResolved) {
3165
+ isResolved = true;
3166
+ unsubscribe();
3167
+ reject(new Error(`Request timeout after ${timeoutMs}ms`));
3168
+ }
3169
+ }, timeoutMs);
3170
+ });
3171
+ }
3172
+ /**
3173
+ * Register message handler
3174
+ */
3175
+ onMessage(handler) {
3176
+ this.messageHandlers.add(handler);
3177
+ return () => this.messageHandlers.delete(handler);
3178
+ }
3179
+ /**
3180
+ * Register connection handler
3181
+ */
3182
+ onConnect(handler) {
3183
+ this.connectionHandlers.add(handler);
3184
+ return () => this.connectionHandlers.delete(handler);
3185
+ }
3186
+ /**
3187
+ * Register disconnection handler
3188
+ */
3189
+ onDisconnect(handler) {
3190
+ this.disconnectionHandlers.add(handler);
3191
+ return () => this.disconnectionHandlers.delete(handler);
3192
+ }
3193
+ /**
3194
+ * Register error handler
3195
+ */
3196
+ onError(handler) {
3197
+ this.errorHandlers.add(handler);
3198
+ return () => this.errorHandlers.delete(handler);
3199
+ }
3200
+ /**
3201
+ * Check if client is connected
3202
+ */
3203
+ isConnected() {
3204
+ return this.socket?.readyState === WebSocket.OPEN;
3205
+ }
3206
+ /**
3207
+ * Get current reconnection attempts
3208
+ */
3209
+ getReconnectAttempts() {
3210
+ return this.reconnectAttempts;
3211
+ }
3212
+ /**
3213
+ * Get client type
3214
+ */
3215
+ get type() {
3216
+ return this.config.type;
3217
+ }
3218
+ /**
3219
+ * Send a message and wait for response with timeout (alias for sendWithResponse)
3220
+ */
3221
+ async ask(message, options) {
3222
+ return this.sendWithResponse(message, options?.timeout);
3223
+ }
3224
+ // ==================== Service Methods ====================
3225
+ // These methods delegate to service functions for better code organization
3226
+ /**
3227
+ * Send authentication login request
3228
+ * Delegates to auth service
3229
+ */
3230
+ async sendAuthLoginRequest(loginDataBase64, timeout) {
3231
+ this.log("info", "Sending auth login request");
3232
+ return sendAuthLoginRequest(this, loginDataBase64, timeout);
3233
+ }
3234
+ /**
3235
+ * Send authentication verify request
3236
+ * Delegates to auth service
3237
+ */
3238
+ async sendAuthVerifyRequest(token, timeout) {
3239
+ this.log("info", "Sending auth verify request");
3240
+ return sendAuthVerifyRequest(this, token, timeout);
3241
+ }
3242
+ /**
3243
+ * Send a user prompt request
3244
+ * Delegates to user prompt service
3245
+ * @param userId - User ID for the request
3246
+ * @param responseMode - 'component' for component response (default), 'text' for text streaming
3247
+ * @param onStream - Optional callback for streaming text chunks (only for text mode)
3248
+ */
3249
+ async sendUserPromptRequest(prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout) {
3250
+ this.log("info", "Sending user prompt request with streaming support");
3251
+ return sendUserPromptRequest(this, prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout);
3252
+ }
3253
+ /**
3254
+ * Send a user prompt suggestions request
3255
+ * Delegates to user prompt service
3256
+ * @param userId - User ID for the request
3257
+ */
3258
+ async sendUserPromptSuggestionsRequest(prompt, userId, limit = 5, timeout) {
3259
+ this.log("info", "Sending user prompt suggestions request");
3260
+ return sendUserPromptSuggestionsRequest(this, prompt, userId, limit, timeout);
3261
+ }
3262
+ /**
3263
+ * Request bundle from server
3264
+ * Delegates to bundle service
3265
+ */
3266
+ async requestBundle(options) {
3267
+ this.log("info", "Requesting bundle from server");
3268
+ return requestBundle(this, options);
3269
+ }
3270
+ /**
3271
+ * Request data from a collection
3272
+ * Delegates to data service
3273
+ */
3274
+ async requestData(options) {
3275
+ this.log("info", `Requesting data from collection: ${options.collection}, operation: ${options.operation}`);
3276
+ return requestData(this, options);
3277
+ }
3278
+ /**
3279
+ * Get AI-powered component suggestions based on a query
3280
+ * Delegates to component service
3281
+ */
3282
+ async getComponentSuggestions(query, options) {
3283
+ this.log("info", "Requesting component suggestions for query:", query);
3284
+ return getComponentSuggestions(this, query, options);
3285
+ }
3286
+ /**
3287
+ * Get AI-powered component suggestions based on a query
3288
+ * Delegates to component service
3289
+ * @param userId - User ID for the request
3290
+ */
3291
+ async getActions(options) {
3292
+ this.log("info", "Requesting actions");
3293
+ return getActions(this, options);
3294
+ }
3295
+ async sendComponents(components) {
3296
+ this.log("info", "Sending components");
3297
+ return sendComponents(this, components);
3298
+ }
3299
+ // ==================== User Management Methods ====================
3300
+ // These methods delegate to user service for admin user CRUD operations
3301
+ /**
3302
+ * Create a new user
3303
+ * Delegates to users service
3304
+ */
3305
+ async createUser(username, password, email, fullname, role, userInfo, timeout) {
3306
+ this.log("info", "Creating user:", username);
3307
+ return createUser(this, username, password, email, fullname, role, userInfo, timeout);
3308
+ }
3309
+ /**
3310
+ * Update an existing user
3311
+ * Delegates to users service
3312
+ */
3313
+ async updateUser(id, updates, timeout) {
3314
+ this.log("info", "Updating user:", id);
3315
+ return updateUser(this, id, updates, timeout);
3316
+ }
3317
+ /**
3318
+ * Delete a user
3319
+ * Delegates to users service
3320
+ */
3321
+ async deleteUser(id, timeout) {
3322
+ this.log("info", "Deleting user:", id);
3323
+ return deleteUser(this, id, timeout);
3324
+ }
3325
+ /**
3326
+ * Get all users
3327
+ * Delegates to users service
3328
+ */
3329
+ async getAllUsers(timeout) {
3330
+ this.log("info", "Fetching all users");
3331
+ return getAllUsers(this, timeout);
3332
+ }
3333
+ /**
3334
+ * Get a specific user by username
3335
+ * Delegates to users service
3336
+ */
3337
+ async getUser(username, timeout) {
3338
+ this.log("info", "Fetching user:", username);
3339
+ return getUser(this, username, timeout);
3340
+ }
3341
+ /**
3342
+ * Query users with filters, limit, and sort
3343
+ * Delegates to users service
3344
+ */
3345
+ async queryUsers(options = {}, timeout) {
3346
+ this.log("info", "Querying users with filters:", options.filters);
3347
+ return queryUsers(this, options, timeout);
3348
+ }
3349
+ // ==================== Dashboard Management Methods ====================
3350
+ // These methods delegate to dashboard service for admin dashboard CRUD operations
3351
+ /**
3352
+ * Create a new dashboard
3353
+ * Delegates to dashboards service
3354
+ */
3355
+ async createDashboard(options, timeout) {
3356
+ this.log("info", "Creating dashboard:", options.dashboardId, options.projectId);
3357
+ return createDashboard(this, options, timeout);
3358
+ }
3359
+ /**
3360
+ * Update an existing dashboard
3361
+ * Delegates to dashboards service
3362
+ */
3363
+ async updateDashboard(options, timeout) {
3364
+ this.log("info", "Updating dashboard:", options.id);
3365
+ return updateDashboard(this, options, timeout);
3366
+ }
3367
+ /**
3368
+ * Delete a dashboard
3369
+ * Delegates to dashboards service
3370
+ */
3371
+ async deleteDashboard(id, timeout) {
3372
+ this.log("info", "Deleting dashboard:", id);
3373
+ return deleteDashboard(this, id, timeout);
3374
+ }
3375
+ /**
3376
+ * Get all dashboards
3377
+ * Delegates to dashboards service
3378
+ */
3379
+ async getAllDashboards(timeout) {
3380
+ this.log("info", "Fetching all dashboards");
3381
+ return getAllDashboards(this, timeout);
3382
+ }
3383
+ /**
3384
+ * Get a specific dashboard by ID
3385
+ * Delegates to dashboards service
3386
+ */
3387
+ async getDashboard(id, timeout) {
3388
+ this.log("info", "Fetching dashboard:", id);
3389
+ return getDashboard(this, id, timeout);
3390
+ }
3391
+ /**
3392
+ * Query dashboards with filters
3393
+ * Delegates to dashboards service
3394
+ */
3395
+ async queryDashboards(options, timeout) {
3396
+ this.log("info", "Querying dashboards with filters:", options?.filters);
3397
+ return queryDashboards(this, options, timeout);
3398
+ }
3399
+ // ==================== Bookmark Management Methods ====================
3400
+ // These methods delegate to bookmark service for bookmark CRUD operations
3401
+ /**
3402
+ * Create a new bookmark
3403
+ * Delegates to bookmarks service
3404
+ */
3405
+ async createBookmark(options, timeout) {
3406
+ this.log("info", "Creating bookmark for user:", options.userId);
3407
+ return createBookmark(this, options, timeout);
3408
+ }
3409
+ /**
3410
+ * Update an existing bookmark
3411
+ * Delegates to bookmarks service
3412
+ */
3413
+ async updateBookmark(options, timeout) {
3414
+ this.log("info", "Updating bookmark:", options.id);
3415
+ return updateBookmark(this, options, timeout);
3416
+ }
3417
+ /**
3418
+ * Delete a bookmark
3419
+ * Delegates to bookmarks service
3420
+ */
3421
+ async deleteBookmark(id, timeout) {
3422
+ this.log("info", "Deleting bookmark:", id);
3423
+ return deleteBookmark(this, id, timeout);
3424
+ }
3425
+ /**
3426
+ * Get all bookmarks
3427
+ * Delegates to bookmarks service
3428
+ */
3429
+ async getAllBookmarks(timeout) {
3430
+ this.log("info", "Fetching all bookmarks");
3431
+ return getAllBookmarks(this, timeout);
3432
+ }
3433
+ /**
3434
+ * Get a specific bookmark by ID
3435
+ * Delegates to bookmarks service
3436
+ */
3437
+ async getBookmark(id, timeout) {
3438
+ this.log("info", "Fetching bookmark:", id);
3439
+ return getBookmark(this, id, timeout);
3440
+ }
3441
+ /**
3442
+ * Query bookmarks with filters, limit, and sort
3443
+ * Delegates to bookmarks service
3444
+ */
3445
+ async queryBookmarks(options = {}, timeout) {
3446
+ this.log("info", "Querying bookmarks with filters:", options.filters);
3447
+ return queryBookmarks(this, options, timeout);
3448
+ }
3449
+ // ==================== Artifact Management Methods ====================
3450
+ // These methods delegate to artifact service for artifact CRUD operations
3451
+ /**
3452
+ * Create a new artifact
3453
+ * Delegates to artifacts service
3454
+ */
3455
+ async createArtifact(options, timeout) {
3456
+ this.log("info", "Creating artifact:", options.name);
3457
+ return createArtifact(this, options, timeout);
3458
+ }
3459
+ /**
3460
+ * Update an existing artifact
3461
+ * Delegates to artifacts service
3462
+ */
3463
+ async updateArtifact(options, timeout) {
3464
+ this.log("info", "Updating artifact:", options.id);
3465
+ return updateArtifact(this, options, timeout);
3466
+ }
3467
+ /**
3468
+ * Delete an artifact (soft delete)
3469
+ * Delegates to artifacts service
3470
+ */
3471
+ async deleteArtifact(id, timeout) {
3472
+ this.log("info", "Deleting artifact:", id);
3473
+ return deleteArtifact(this, id, timeout);
3474
+ }
3475
+ /**
3476
+ * Get all artifacts
3477
+ * Delegates to artifacts service
3478
+ */
3479
+ async getAllArtifacts(limit, timeout) {
3480
+ this.log("info", "Fetching all artifacts");
3481
+ return getAllArtifacts(this, limit, timeout);
3482
+ }
3483
+ /**
3484
+ * Get a specific artifact by ID
3485
+ * Delegates to artifacts service
3486
+ */
3487
+ async getArtifact(id, timeout) {
3488
+ this.log("info", "Fetching artifact:", id);
3489
+ return getArtifact(this, id, timeout);
3490
+ }
3491
+ /**
3492
+ * Query artifacts with filters
3493
+ * Delegates to artifacts service
3494
+ */
3495
+ async queryArtifacts(options = {}, timeout) {
3496
+ this.log("info", "Querying artifacts with filters:", JSON.stringify(options.filters));
3497
+ return queryArtifacts(this, options, timeout);
3498
+ }
3499
+ // ==================== Report Management Methods ====================
3500
+ // These methods delegate to report service for admin report CRUD operations
3501
+ /**
3502
+ * Create a new report
3503
+ * Delegates to reports service
3504
+ */
3505
+ async createReport(options, timeout) {
3506
+ this.log("info", "Creating report:", options.reportId);
3507
+ return createReport(this, options, timeout);
3508
+ }
3509
+ /**
3510
+ * Update an existing report
3511
+ * Delegates to reports service
3512
+ */
3513
+ async updateReport(options, timeout) {
3514
+ this.log("info", "Updating report:", options.id);
3515
+ return updateReport(this, options, timeout);
3516
+ }
3517
+ /**
3518
+ * Delete a report
3519
+ * Delegates to reports service
3520
+ */
3521
+ async deleteReport(id, timeout) {
3522
+ this.log("info", "Deleting report:", id);
3523
+ return deleteReport(this, id, timeout);
3524
+ }
3525
+ /**
3526
+ * Get all reports
3527
+ * Delegates to reports service
3528
+ */
3529
+ async getAllReports(timeout) {
3530
+ this.log("info", "Fetching all reports");
3531
+ return getAllReports(this, timeout);
3532
+ }
3533
+ /**
3534
+ * Get a specific report by ID
3535
+ * Delegates to reports service
3536
+ */
3537
+ async getReport(id, timeout) {
3538
+ this.log("info", "Fetching report:", id);
3539
+ return getReport(this, id, timeout);
3540
+ }
3541
+ /**
3542
+ * Query reports with filters
3543
+ * Delegates to reports service
3544
+ */
3545
+ async queryReports(options, timeout) {
3546
+ this.log("info", "Querying reports with filters:", options?.filters);
3547
+ return queryReports(this, options, timeout);
3548
+ }
3549
+ // ==================== UI Management Methods ====================
3550
+ // These methods delegate to uis service for admin UI CRUD operations
3551
+ /**
3552
+ * Create a new UI
3553
+ * Delegates to uis service
3554
+ */
3555
+ async createUI(options, timeout) {
3556
+ this.log("info", "Creating UI:", options.uiId);
3557
+ return createUI(this, options, timeout);
3558
+ }
3559
+ /**
3560
+ * Update an existing UI
3561
+ * Delegates to uis service
3562
+ */
3563
+ async updateUI(options, timeout) {
3564
+ this.log("info", "Updating UI:", options.id);
3565
+ return updateUI(this, options, timeout);
3566
+ }
3567
+ /**
3568
+ * Delete a UI
3569
+ * Delegates to uis service
3570
+ */
3571
+ async deleteUI(id, timeout) {
3572
+ this.log("info", "Deleting UI:", id);
3573
+ return deleteUI(this, id, timeout);
3574
+ }
3575
+ /**
3576
+ * Get all UIs
3577
+ * Delegates to uis service
3578
+ */
3579
+ async getAllUIs(timeout) {
3580
+ this.log("info", "Fetching all UIs");
3581
+ return getAllUIs(this, timeout);
3582
+ }
3583
+ /**
3584
+ * Get a specific UI by ID
3585
+ * Delegates to uis service
3586
+ */
3587
+ async getUI(id, timeout) {
3588
+ this.log("info", "Fetching UI:", id);
3589
+ return getUI(this, id, timeout);
3590
+ }
3591
+ /**
3592
+ * Query UIs with filters
3593
+ * Delegates to uis service
3594
+ */
3595
+ async queryUIs(options, timeout) {
3596
+ this.log("info", "Querying UIs with filters:", options?.filters);
3597
+ return queryUIs(this, options, timeout);
3598
+ }
3599
+ // ==================== KB Nodes (Knowledge Base) Management Methods ====================
3600
+ // These methods delegate to kb-nodes service for knowledge base CRUD operations
3601
+ /**
3602
+ * Create a new knowledge base node
3603
+ * Delegates to kb-nodes service
3604
+ */
3605
+ async createKbNode(title, content, createdBy, category, tags, type, timeout) {
3606
+ this.log("info", "Creating KB node:", title);
3607
+ return createKbNode(this, title, content, createdBy, category, tags, type, timeout);
3608
+ }
3609
+ /**
3610
+ * Update an existing knowledge base node
3611
+ * Delegates to kb-nodes service
3612
+ */
3613
+ async updateKbNode(id, updatedBy, updates, timeout) {
3614
+ this.log("info", "Updating KB node:", id);
3615
+ return updateKbNode(this, id, updatedBy, updates, timeout);
3616
+ }
3617
+ /**
3618
+ * Delete a knowledge base node
3619
+ * Delegates to kb-nodes service
3620
+ */
3621
+ async deleteKbNode(id, timeout) {
3622
+ this.log("info", "Deleting KB node:", id);
3623
+ return deleteKbNode(this, id, timeout);
3624
+ }
3625
+ /**
3626
+ * Get all knowledge base nodes
3627
+ * Delegates to kb-nodes service
3628
+ */
3629
+ async getAllKbNodes(limit, offset, timeout) {
3630
+ this.log("info", "Fetching all KB nodes");
3631
+ return getAllKbNodes(this, limit, offset, timeout);
3632
+ }
3633
+ /**
3634
+ * Get a specific knowledge base node by ID
3635
+ * Delegates to kb-nodes service
3636
+ */
3637
+ async getKbNode(id, timeout) {
3638
+ this.log("info", "Fetching KB node:", id);
3639
+ return getKbNode(this, id, timeout);
3640
+ }
3641
+ /**
3642
+ * Search knowledge base nodes with full-text search and filters
3643
+ * Delegates to kb-nodes service
3644
+ */
3645
+ async searchKbNodes(options = {}, timeout) {
3646
+ this.log("info", "Searching KB nodes with query:", options.query);
3647
+ return searchKbNodes(this, options, timeout);
3648
+ }
3649
+ /**
3650
+ * Get knowledge base nodes by category
3651
+ * Delegates to kb-nodes service
3652
+ */
3653
+ async getKbNodesByCategory(category, limit, offset, timeout) {
3654
+ this.log("info", "Fetching KB nodes by category:", category);
3655
+ return getKbNodesByCategory(this, category, limit, offset, timeout);
3656
+ }
3657
+ /**
3658
+ * Get knowledge base nodes by user (creator)
3659
+ * Delegates to kb-nodes service
3660
+ */
3661
+ async getKbNodesByUser(userId, limit, offset, timeout) {
3662
+ this.log("info", "Fetching KB nodes by user:", userId);
3663
+ return getKbNodesByUser(this, userId, limit, offset, timeout);
3664
+ }
3665
+ /**
3666
+ * Get all unique categories from knowledge base nodes
3667
+ * Delegates to kb-nodes service
3668
+ */
3669
+ async getKbNodeCategories(timeout) {
3670
+ this.log("info", "Fetching KB node categories");
3671
+ return getKbNodeCategories(this, timeout);
3672
+ }
3673
+ /**
3674
+ * Get all unique tags from knowledge base nodes
3675
+ * Delegates to kb-nodes service
3676
+ */
3677
+ async getKbNodeTags(timeout) {
3678
+ this.log("info", "Fetching KB node tags");
3679
+ return getKbNodeTags(this, timeout);
3680
+ }
3681
+ // ==================== Dashboard Component Methods ====================
3682
+ // These methods delegate to dash-comp service for component selection
3683
+ /**
3684
+ * Request a dashboard component based on user prompt
3685
+ * Uses LLM to pick the best component and generate props
3686
+ * Supports both database queries and external tools as data sources
3687
+ * Delegates to dash-comp service
3688
+ *
3689
+ * @example
3690
+ * ```typescript
3691
+ * const response = await client.sendDashCompRequest({
3692
+ * prompt: "Show me a bar chart of sales by category",
3693
+ * threadId: "thread-123",
3694
+ * });
3695
+ *
3696
+ * if (response.success && response.component) {
3697
+ * console.log('Component:', response.component.name);
3698
+ * console.log('Props:', response.component.props);
3699
+ * console.log('Data source:', response.dataSource);
3700
+ * }
3701
+ * ```
3702
+ */
3703
+ async sendDashCompRequest(options) {
3704
+ this.log("info", "Sending dash comp request for prompt:", options.prompt.substring(0, 50) + "...");
3705
+ return sendDashCompRequest(this, options);
3706
+ }
3707
+ // ==================== Menu Management Methods ====================
3708
+ // These methods delegate to menus service for menu CRUD operations
3709
+ /**
3710
+ * Create a new menu
3711
+ * Delegates to menus service
3712
+ */
3713
+ async createMenu(options, timeout) {
3714
+ this.log("info", "Creating menu:", options.name);
3715
+ return createMenu(this, options, timeout);
3716
+ }
3717
+ /**
3718
+ * Update an existing menu
3719
+ * Delegates to menus service
3720
+ */
3721
+ async updateMenu(options, timeout) {
3722
+ this.log("info", "Updating menu:", options.id);
3723
+ return updateMenu(this, options, timeout);
3724
+ }
3725
+ /**
3726
+ * Delete a menu
3727
+ * Delegates to menus service
3728
+ */
3729
+ async deleteMenu(id, timeout) {
3730
+ this.log("info", "Deleting menu:", id);
3731
+ return deleteMenu(this, id, timeout);
3732
+ }
3733
+ /**
3734
+ * Get all menus
3735
+ * Delegates to menus service
3736
+ */
3737
+ async getAllMenus(timeout) {
3738
+ this.log("info", "Fetching all menus");
3739
+ return getAllMenus(this, timeout);
3740
+ }
3741
+ /**
3742
+ * Get a specific menu by ID
3743
+ * Delegates to menus service
3744
+ */
3745
+ async getMenu(id, timeout) {
3746
+ this.log("info", "Fetching menu:", id);
3747
+ return getMenu(this, id, timeout);
3748
+ }
3749
+ /**
3750
+ * Get root menus (top-level sidebar items)
3751
+ * Delegates to menus service
3752
+ */
3753
+ async getRootMenus(timeout) {
3754
+ this.log("info", "Fetching root menus");
3755
+ return getRootMenus(this, timeout);
3756
+ }
3757
+ /**
3758
+ * Get child menus by parent ID
3759
+ * Delegates to menus service
3760
+ */
3761
+ async getChildMenus(parentId, timeout) {
3762
+ this.log("info", "Fetching child menus for parent:", parentId);
3763
+ return getChildMenus(this, parentId, timeout);
3764
+ }
3765
+ /**
3766
+ * Get menus with hierarchy (nested structure)
3767
+ * Delegates to menus service
3768
+ */
3769
+ async getMenusHierarchy(timeout) {
3770
+ this.log("info", "Fetching menus hierarchy");
3771
+ return getMenusHierarchy(this, timeout);
3772
+ }
3773
+ /**
3774
+ * Query menus with filters
3775
+ * Delegates to menus service
3776
+ */
3777
+ async queryMenus(options, timeout) {
3778
+ this.log("info", "Querying menus with filters:", options?.filters);
3779
+ return queryMenus(this, options, timeout);
3780
+ }
3781
+ /**
3782
+ * Reorder menus
3783
+ * Delegates to menus service
3784
+ */
3785
+ async reorderMenus(items, timeout) {
3786
+ this.log("info", "Reordering", items.length, "menus");
3787
+ return reorderMenus(this, items, timeout);
3788
+ }
3789
+ // ==================== Schema Methods ====================
3790
+ /**
3791
+ * Get the database schema
3792
+ * Retrieves the schema.json containing table definitions, columns, and relationships
3793
+ */
3794
+ async getSchema(options) {
3795
+ this.log("info", "Fetching database schema");
3796
+ return getSchema(this, options);
3797
+ }
3798
+ /**
3799
+ * Internal logging
3800
+ */
3801
+ log(level, ...args) {
3802
+ if (!this.config.debug && level === "debug") {
3803
+ return;
3804
+ }
3805
+ console[level]("[SuperAtom]", ...args);
3806
+ }
3807
+ };
3808
+
3809
+ // src/setup.ts
3810
+ function setup(components) {
3811
+ if (typeof window === "undefined") {
3812
+ throw new Error("setup() can only be called in a browser environment");
3813
+ }
3814
+ window.SUPERATOM = window.SUPERATOM || {};
3815
+ window.SA = window.SUPERATOM;
3816
+ window.SUPERATOM.COMPONENTS = components;
3817
+ if (window.SUPERATOM.runtime?.componentsLoaded) {
3818
+ window.SUPERATOM.runtime.componentsLoaded();
3819
+ }
3820
+ }
3821
+ function getComponents() {
3822
+ if (typeof window === "undefined") {
3823
+ return void 0;
3824
+ }
3825
+ return window.SUPERATOM?.COMPONENTS;
3826
+ }
3827
+ function getComponent(name) {
3828
+ if (typeof window === "undefined") {
3829
+ return void 0;
3830
+ }
3831
+ return window.SUPERATOM?.COMPONENTS?.[name];
3832
+ }
3833
+ function hasComponents() {
3834
+ if (typeof window === "undefined") {
3835
+ return false;
3836
+ }
3837
+ return !!window.SUPERATOM?.COMPONENTS;
3838
+ }
3839
+
3840
+ // src/index.ts
3841
+ var SDK_VERSION = "0.1.0";
3842
+
3843
+ export { ActionsRequestMessageSchema, ActionsRequestPayloadSchema, ActionsResponseMessageSchema, ActionsResponsePayloadSchema, AuthLoginPayloadSchema, AuthLoginRequestMessageSchema, AuthLoginResponseMessageSchema, AuthLoginResponsePayloadSchema, AuthVerifyPayloadSchema, AuthVerifyRequestMessageSchema, AuthVerifyResponseMessageSchema, AuthVerifyResponsePayloadSchema, BundleChunkMessageSchema, BundleChunkPayloadSchema, BundleErrorMessageSchema, BundleErrorPayloadSchema, BundleRequestMessageSchema, BundleRequestPayloadSchema, ClientConfigSchema, ComponentSchema, ComponentsSendMessageSchema, ComponentsSendPayloadSchema, DataRequestMessageSchema, DataRequestPayloadSchema, DataResponseMessageSchema, DataResponsePayloadSchema, KbNodeDataSchema, KbNodesQueryFiltersSchema, KbNodesRequestMessageSchema, KbNodesRequestPayloadSchema, KbNodesResponseMessageSchema, KbNodesResponsePayloadSchema, MenuDataSchema, MenuQueryFiltersSchema, MenusRequestMessageSchema, MenusRequestPayloadSchema, MenusResponseMessageSchema, MenusResponsePayloadSchema, MessageParticipantSchema, MessageSchema, SDK_VERSION, SuperatomClient, UILogEntrySchema, UILogsMessageSchema, UILogsPayloadSchema, UserPromptRequestMessageSchema, UserPromptRequestPayloadSchema, UserPromptResponseMessageSchema, UserPromptResponsePayloadSchema, UserPromptSuggestionsRequestMessageSchema, UserPromptSuggestionsRequestPayloadSchema, UserPromptSuggestionsResponseMessageSchema, UserPromptSuggestionsResponsePayloadSchema, getComponent, getComponents, hasComponents, services_exports as services, setup };
3844
+ //# sourceMappingURL=index.js.map
3845
+ //# sourceMappingURL=index.js.map