@superatomai/sdk-node 0.0.3 → 0.0.5
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/README.md +74 -25
- package/dist/index.d.mts +150 -11
- package/dist/index.d.ts +150 -11
- package/dist/index.js +1016 -305
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1014 -304
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@ interface SuperatomSDKConfig {
|
|
|
79
79
|
ANTHROPIC_API_KEY?: string; // Optional: Anthropic API key for LLM
|
|
80
80
|
GROQ_API_KEY?: string; // Optional: Groq API key for LLM
|
|
81
81
|
LLM_PROVIDERS?: LLMProvider[]; // Optional: Custom LLM providers
|
|
82
|
+
logLevel?: LogLevel; // Optional: Log level (errors, warnings, info, verbose) (default: 'info')
|
|
82
83
|
}
|
|
83
84
|
```
|
|
84
85
|
|
|
@@ -87,6 +88,7 @@ interface SuperatomSDKConfig {
|
|
|
87
88
|
- `SA_WEBSOCKET_URL` - WebSocket URL (default: `wss://ws.superatom.ai/websocket`)
|
|
88
89
|
- `ANTHROPIC_API_KEY` - Anthropic API key for Claude models
|
|
89
90
|
- `GROQ_API_KEY` - Groq API key for open-source models
|
|
91
|
+
- `SUPERATOM_LOG_LEVEL` - Log level for SDK logging (errors, warnings, info, verbose) (default: 'info')
|
|
90
92
|
|
|
91
93
|
## Core Features
|
|
92
94
|
|
|
@@ -379,44 +381,91 @@ threadManager.deleteThread(thread.getId());
|
|
|
379
381
|
- `form` - Interactive forms
|
|
380
382
|
- Custom types as needed
|
|
381
383
|
|
|
382
|
-
### 8.
|
|
384
|
+
### 8. Logging System
|
|
383
385
|
|
|
384
|
-
|
|
386
|
+
The SDK includes a comprehensive logging system with environment-based log levels for both terminal and UI log collection.
|
|
385
387
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
+
#### Log Levels
|
|
389
|
+
|
|
390
|
+
The SDK supports hierarchical log levels:
|
|
388
391
|
|
|
389
|
-
|
|
392
|
+
- **`errors`** - Only error logs are shown
|
|
393
|
+
- **`warnings`** - Warning and error logs are shown
|
|
394
|
+
- **`info`** - Info, warning, and error logs are shown (default)
|
|
395
|
+
- **`verbose`** - All logs including debug messages are shown
|
|
390
396
|
|
|
391
|
-
|
|
392
|
-
collector.start();
|
|
397
|
+
#### Configuring Log Level
|
|
393
398
|
|
|
394
|
-
|
|
395
|
-
console.log('This will be captured');
|
|
396
|
-
console.error('Error messages too');
|
|
399
|
+
You can set the log level in three ways:
|
|
397
400
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
**1. Via environment variable (recommended for deployment):**
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
export SUPERATOM_LOG_LEVEL=verbose
|
|
405
|
+
node your-app.js
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**2. Via SDK configuration (overrides environment variable):**
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
import { SuperatomSDK } from '@superatomai/sdk-node';
|
|
412
|
+
|
|
413
|
+
const sdk = new SuperatomSDK({
|
|
414
|
+
apiKey: 'your-api-key',
|
|
415
|
+
projectId: 'your-project-id',
|
|
416
|
+
logLevel: 'verbose', // errors | warnings | info | verbose
|
|
404
417
|
});
|
|
418
|
+
```
|
|
405
419
|
|
|
406
|
-
|
|
407
|
-
|
|
420
|
+
**3. Programmatically at runtime:**
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
import { logger } from '@superatomai/sdk-node';
|
|
424
|
+
|
|
425
|
+
// Change log level at runtime
|
|
426
|
+
logger.setLogLevel('verbose');
|
|
408
427
|
|
|
409
|
-
//
|
|
410
|
-
const
|
|
411
|
-
|
|
428
|
+
// Get current log level
|
|
429
|
+
const currentLevel = logger.getLogLevel(); // returns 'verbose'
|
|
430
|
+
```
|
|
412
431
|
|
|
413
|
-
|
|
414
|
-
|
|
432
|
+
#### Using the Logger
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
import { logger } from '@superatomai/sdk-node';
|
|
415
436
|
|
|
416
|
-
//
|
|
417
|
-
|
|
437
|
+
// These will be filtered based on the configured log level
|
|
438
|
+
logger.error('Critical error occurred'); // Shown at all levels
|
|
439
|
+
logger.warn('Something might be wrong'); // Hidden when level is 'errors'
|
|
440
|
+
logger.info('Processing completed'); // Hidden when level is 'errors' or 'warnings'
|
|
441
|
+
logger.debug('Detailed debug information'); // Only shown when level is 'verbose'
|
|
418
442
|
```
|
|
419
443
|
|
|
444
|
+
#### UI Log Collection
|
|
445
|
+
|
|
446
|
+
The `UILogCollector` also respects the log level configuration. Logs are sent to the frontend and displayed in the terminal based on the configured level.
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
import { UILogCollector } from '@superatomai/sdk-node';
|
|
450
|
+
|
|
451
|
+
const collector = new UILogCollector(
|
|
452
|
+
clientId,
|
|
453
|
+
(msg) => sdk.send(msg),
|
|
454
|
+
'uiblock-123'
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
// These logs are filtered based on log level before being sent to UI
|
|
458
|
+
collector.error('Error message'); // Always sent
|
|
459
|
+
collector.warn('Warning message'); // Sent unless level is 'errors'
|
|
460
|
+
collector.info('Info message'); // Sent unless level is 'errors' or 'warnings'
|
|
461
|
+
collector.debug('Debug message'); // Only sent when level is 'verbose'
|
|
462
|
+
|
|
463
|
+
// Get all collected logs
|
|
464
|
+
const logs = collector.getLogs();
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
**Note:** The log level affects both terminal output and UI log collection, ensuring consistent logging behavior across your application.
|
|
468
|
+
|
|
420
469
|
### 9. Cleanup Service
|
|
421
470
|
|
|
422
471
|
Automatic memory management for threads and UI blocks:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Log levels in hierarchical order
|
|
5
|
+
* - errors: only error logs
|
|
6
|
+
* - warnings: warning + error logs
|
|
7
|
+
* - info: info + warning + error logs
|
|
8
|
+
* - verbose: all logs including debug
|
|
9
|
+
*/
|
|
10
|
+
type LogLevel = 'errors' | 'warnings' | 'info' | 'verbose';
|
|
11
|
+
/**
|
|
12
|
+
* Logger class with environment-based log level support
|
|
13
|
+
*/
|
|
14
|
+
declare class Logger {
|
|
15
|
+
private currentLevel;
|
|
16
|
+
private currentLevelPriority;
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Check if a string is a valid log level
|
|
20
|
+
*/
|
|
21
|
+
private isValidLogLevel;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a message should be logged based on current log level
|
|
24
|
+
*/
|
|
25
|
+
private shouldLog;
|
|
26
|
+
/**
|
|
27
|
+
* Get current log level
|
|
28
|
+
*/
|
|
29
|
+
getLogLevel(): LogLevel;
|
|
30
|
+
/**
|
|
31
|
+
* Set log level programmatically
|
|
32
|
+
*/
|
|
33
|
+
setLogLevel(level: LogLevel): void;
|
|
34
|
+
/**
|
|
35
|
+
* Log info message (shown for info and verbose levels)
|
|
36
|
+
*/
|
|
37
|
+
info(...args: any[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Log error message (shown for all levels)
|
|
40
|
+
*/
|
|
41
|
+
error(...args: any[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Log warning message (shown for warnings, info, and verbose levels)
|
|
44
|
+
*/
|
|
45
|
+
warn(...args: any[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* Log debug message (only shown for verbose level)
|
|
48
|
+
*/
|
|
49
|
+
debug(...args: any[]): void;
|
|
50
|
+
}
|
|
51
|
+
declare const logger: Logger;
|
|
52
|
+
|
|
3
53
|
declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
4
54
|
dsl: z.ZodObject<{
|
|
5
55
|
id: z.ZodString;
|
|
@@ -326,6 +376,72 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
326
376
|
}>;
|
|
327
377
|
type DSLRendererProps = z.infer<typeof DSLRendererPropsSchema>;
|
|
328
378
|
|
|
379
|
+
declare const UserSchema: z.ZodObject<{
|
|
380
|
+
username: z.ZodString;
|
|
381
|
+
email: z.ZodOptional<z.ZodString>;
|
|
382
|
+
password: z.ZodString;
|
|
383
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
384
|
+
role: z.ZodOptional<z.ZodString>;
|
|
385
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
386
|
+
}, "strip", z.ZodTypeAny, {
|
|
387
|
+
username: string;
|
|
388
|
+
password: string;
|
|
389
|
+
email?: string | undefined;
|
|
390
|
+
fullname?: string | undefined;
|
|
391
|
+
role?: string | undefined;
|
|
392
|
+
wsIds?: string[] | undefined;
|
|
393
|
+
}, {
|
|
394
|
+
username: string;
|
|
395
|
+
password: string;
|
|
396
|
+
email?: string | undefined;
|
|
397
|
+
fullname?: string | undefined;
|
|
398
|
+
role?: string | undefined;
|
|
399
|
+
wsIds?: string[] | undefined;
|
|
400
|
+
}>;
|
|
401
|
+
type User = z.infer<typeof UserSchema>;
|
|
402
|
+
declare const UsersDataSchema: z.ZodObject<{
|
|
403
|
+
users: z.ZodArray<z.ZodObject<{
|
|
404
|
+
username: z.ZodString;
|
|
405
|
+
email: z.ZodOptional<z.ZodString>;
|
|
406
|
+
password: z.ZodString;
|
|
407
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
408
|
+
role: z.ZodOptional<z.ZodString>;
|
|
409
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
410
|
+
}, "strip", z.ZodTypeAny, {
|
|
411
|
+
username: string;
|
|
412
|
+
password: string;
|
|
413
|
+
email?: string | undefined;
|
|
414
|
+
fullname?: string | undefined;
|
|
415
|
+
role?: string | undefined;
|
|
416
|
+
wsIds?: string[] | undefined;
|
|
417
|
+
}, {
|
|
418
|
+
username: string;
|
|
419
|
+
password: string;
|
|
420
|
+
email?: string | undefined;
|
|
421
|
+
fullname?: string | undefined;
|
|
422
|
+
role?: string | undefined;
|
|
423
|
+
wsIds?: string[] | undefined;
|
|
424
|
+
}>, "many">;
|
|
425
|
+
}, "strip", z.ZodTypeAny, {
|
|
426
|
+
users: {
|
|
427
|
+
username: string;
|
|
428
|
+
password: string;
|
|
429
|
+
email?: string | undefined;
|
|
430
|
+
fullname?: string | undefined;
|
|
431
|
+
role?: string | undefined;
|
|
432
|
+
wsIds?: string[] | undefined;
|
|
433
|
+
}[];
|
|
434
|
+
}, {
|
|
435
|
+
users: {
|
|
436
|
+
username: string;
|
|
437
|
+
password: string;
|
|
438
|
+
email?: string | undefined;
|
|
439
|
+
fullname?: string | undefined;
|
|
440
|
+
role?: string | undefined;
|
|
441
|
+
wsIds?: string[] | undefined;
|
|
442
|
+
}[];
|
|
443
|
+
}>;
|
|
444
|
+
type UsersData = z.infer<typeof UsersDataSchema>;
|
|
329
445
|
declare const MessageSchema: z.ZodObject<{
|
|
330
446
|
id: z.ZodOptional<z.ZodString>;
|
|
331
447
|
type: z.ZodString;
|
|
@@ -429,6 +545,7 @@ type IncomingMessage = z.infer<typeof IncomingMessageSchema>;
|
|
|
429
545
|
type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
|
|
430
546
|
type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
|
|
431
547
|
type LLMProvider = 'anthropic' | 'groq';
|
|
548
|
+
|
|
432
549
|
interface SuperatomSDKConfig {
|
|
433
550
|
url?: string;
|
|
434
551
|
apiKey: string;
|
|
@@ -440,16 +557,9 @@ interface SuperatomSDKConfig {
|
|
|
440
557
|
ANTHROPIC_API_KEY?: string;
|
|
441
558
|
GROQ_API_KEY?: string;
|
|
442
559
|
LLM_PROVIDERS?: LLMProvider[];
|
|
560
|
+
logLevel?: LogLevel;
|
|
443
561
|
}
|
|
444
562
|
|
|
445
|
-
interface User {
|
|
446
|
-
username: string;
|
|
447
|
-
password: string;
|
|
448
|
-
wsIds: string[];
|
|
449
|
-
}
|
|
450
|
-
interface UsersData {
|
|
451
|
-
users: User[];
|
|
452
|
-
}
|
|
453
563
|
/**
|
|
454
564
|
* UserManager class to handle CRUD operations on users with file persistence
|
|
455
565
|
* and in-memory caching. Changes are synced to file periodically.
|
|
@@ -503,6 +613,18 @@ declare class UserManager {
|
|
|
503
613
|
* @returns The user if found, undefined otherwise
|
|
504
614
|
*/
|
|
505
615
|
getUser(username: string): User | undefined;
|
|
616
|
+
/**
|
|
617
|
+
* Read a user by email
|
|
618
|
+
* @param email - Email to retrieve
|
|
619
|
+
* @returns The user if found, undefined otherwise
|
|
620
|
+
*/
|
|
621
|
+
getUserByEmail(email: string): User | undefined;
|
|
622
|
+
/**
|
|
623
|
+
* Find user by username or email
|
|
624
|
+
* @param identifier - Username or email to search for
|
|
625
|
+
* @returns The user if found, undefined otherwise
|
|
626
|
+
*/
|
|
627
|
+
getUserByUsernameOrEmail(identifier: string): User | undefined;
|
|
506
628
|
/**
|
|
507
629
|
* Read all users
|
|
508
630
|
* @returns Array of all users
|
|
@@ -747,19 +869,26 @@ interface CapturedLog {
|
|
|
747
869
|
* UILogCollector captures logs during user prompt processing
|
|
748
870
|
* and sends them to runtime via ui_logs message with uiBlockId as the message id
|
|
749
871
|
* Logs are sent in real-time for streaming effect in the UI
|
|
872
|
+
* Respects the global log level configuration
|
|
750
873
|
*/
|
|
751
874
|
declare class UILogCollector {
|
|
752
875
|
private logs;
|
|
753
876
|
private uiBlockId;
|
|
754
877
|
private clientId;
|
|
755
878
|
private sendMessage;
|
|
879
|
+
private currentLogLevel;
|
|
756
880
|
constructor(clientId: string, sendMessage: (message: Message) => void, uiBlockId?: string);
|
|
757
881
|
/**
|
|
758
882
|
* Check if logging is enabled (uiBlockId is provided)
|
|
759
883
|
*/
|
|
760
884
|
isEnabled(): boolean;
|
|
885
|
+
/**
|
|
886
|
+
* Check if a message should be logged based on current log level
|
|
887
|
+
*/
|
|
888
|
+
private shouldLog;
|
|
761
889
|
/**
|
|
762
890
|
* Add a log entry with timestamp and immediately send to runtime
|
|
891
|
+
* Only logs that pass the log level filter are captured and sent
|
|
763
892
|
*/
|
|
764
893
|
private addLog;
|
|
765
894
|
/**
|
|
@@ -820,13 +949,14 @@ interface Action {
|
|
|
820
949
|
|
|
821
950
|
/**
|
|
822
951
|
* UIBlock represents a single user and assistant message block in a thread
|
|
823
|
-
* Contains user question, component metadata, component data, and available actions
|
|
952
|
+
* Contains user question, component metadata, component data, text response, and available actions
|
|
824
953
|
*/
|
|
825
954
|
declare class UIBlock {
|
|
826
955
|
private id;
|
|
827
956
|
private userQuestion;
|
|
828
957
|
private generatedComponentMetadata;
|
|
829
958
|
private componentData;
|
|
959
|
+
private textResponse;
|
|
830
960
|
private actions;
|
|
831
961
|
private createdAt;
|
|
832
962
|
/**
|
|
@@ -836,8 +966,9 @@ declare class UIBlock {
|
|
|
836
966
|
* @param generatedComponentMetadata - Optional metadata about the generated component
|
|
837
967
|
* @param actions - Optional array of available actions
|
|
838
968
|
* @param id - Optional custom ID, generates UUID if not provided
|
|
969
|
+
* @param textResponse - Optional text response from LLM
|
|
839
970
|
*/
|
|
840
|
-
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string);
|
|
971
|
+
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string, textResponse?: string | null);
|
|
841
972
|
/**
|
|
842
973
|
* Get the UIBlock ID
|
|
843
974
|
*/
|
|
@@ -882,6 +1013,14 @@ declare class UIBlock {
|
|
|
882
1013
|
* Set or update component data with size and row limits
|
|
883
1014
|
*/
|
|
884
1015
|
setComponentData(data: Record<string, any>): void;
|
|
1016
|
+
/**
|
|
1017
|
+
* Get text response
|
|
1018
|
+
*/
|
|
1019
|
+
getTextResponse(): string | null;
|
|
1020
|
+
/**
|
|
1021
|
+
* Set or update text response
|
|
1022
|
+
*/
|
|
1023
|
+
setTextResponse(textResponse: string | null): void;
|
|
885
1024
|
/**
|
|
886
1025
|
* Get all actions (only if they are resolved, not if fetching)
|
|
887
1026
|
*/
|
|
@@ -1241,4 +1380,4 @@ declare class SuperatomSDK {
|
|
|
1241
1380
|
private storeComponents;
|
|
1242
1381
|
}
|
|
1243
1382
|
|
|
1244
|
-
export { type Action, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type IncomingMessage, LLM, type Message, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, UIBlock, UILogCollector, type User, UserManager, type UsersData };
|
|
1383
|
+
export { type Action, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type IncomingMessage, LLM, type LogLevel, type Message, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, UIBlock, UILogCollector, type User, UserManager, type UsersData, logger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Log levels in hierarchical order
|
|
5
|
+
* - errors: only error logs
|
|
6
|
+
* - warnings: warning + error logs
|
|
7
|
+
* - info: info + warning + error logs
|
|
8
|
+
* - verbose: all logs including debug
|
|
9
|
+
*/
|
|
10
|
+
type LogLevel = 'errors' | 'warnings' | 'info' | 'verbose';
|
|
11
|
+
/**
|
|
12
|
+
* Logger class with environment-based log level support
|
|
13
|
+
*/
|
|
14
|
+
declare class Logger {
|
|
15
|
+
private currentLevel;
|
|
16
|
+
private currentLevelPriority;
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Check if a string is a valid log level
|
|
20
|
+
*/
|
|
21
|
+
private isValidLogLevel;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a message should be logged based on current log level
|
|
24
|
+
*/
|
|
25
|
+
private shouldLog;
|
|
26
|
+
/**
|
|
27
|
+
* Get current log level
|
|
28
|
+
*/
|
|
29
|
+
getLogLevel(): LogLevel;
|
|
30
|
+
/**
|
|
31
|
+
* Set log level programmatically
|
|
32
|
+
*/
|
|
33
|
+
setLogLevel(level: LogLevel): void;
|
|
34
|
+
/**
|
|
35
|
+
* Log info message (shown for info and verbose levels)
|
|
36
|
+
*/
|
|
37
|
+
info(...args: any[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Log error message (shown for all levels)
|
|
40
|
+
*/
|
|
41
|
+
error(...args: any[]): void;
|
|
42
|
+
/**
|
|
43
|
+
* Log warning message (shown for warnings, info, and verbose levels)
|
|
44
|
+
*/
|
|
45
|
+
warn(...args: any[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* Log debug message (only shown for verbose level)
|
|
48
|
+
*/
|
|
49
|
+
debug(...args: any[]): void;
|
|
50
|
+
}
|
|
51
|
+
declare const logger: Logger;
|
|
52
|
+
|
|
3
53
|
declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
4
54
|
dsl: z.ZodObject<{
|
|
5
55
|
id: z.ZodString;
|
|
@@ -326,6 +376,72 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
326
376
|
}>;
|
|
327
377
|
type DSLRendererProps = z.infer<typeof DSLRendererPropsSchema>;
|
|
328
378
|
|
|
379
|
+
declare const UserSchema: z.ZodObject<{
|
|
380
|
+
username: z.ZodString;
|
|
381
|
+
email: z.ZodOptional<z.ZodString>;
|
|
382
|
+
password: z.ZodString;
|
|
383
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
384
|
+
role: z.ZodOptional<z.ZodString>;
|
|
385
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
386
|
+
}, "strip", z.ZodTypeAny, {
|
|
387
|
+
username: string;
|
|
388
|
+
password: string;
|
|
389
|
+
email?: string | undefined;
|
|
390
|
+
fullname?: string | undefined;
|
|
391
|
+
role?: string | undefined;
|
|
392
|
+
wsIds?: string[] | undefined;
|
|
393
|
+
}, {
|
|
394
|
+
username: string;
|
|
395
|
+
password: string;
|
|
396
|
+
email?: string | undefined;
|
|
397
|
+
fullname?: string | undefined;
|
|
398
|
+
role?: string | undefined;
|
|
399
|
+
wsIds?: string[] | undefined;
|
|
400
|
+
}>;
|
|
401
|
+
type User = z.infer<typeof UserSchema>;
|
|
402
|
+
declare const UsersDataSchema: z.ZodObject<{
|
|
403
|
+
users: z.ZodArray<z.ZodObject<{
|
|
404
|
+
username: z.ZodString;
|
|
405
|
+
email: z.ZodOptional<z.ZodString>;
|
|
406
|
+
password: z.ZodString;
|
|
407
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
408
|
+
role: z.ZodOptional<z.ZodString>;
|
|
409
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
410
|
+
}, "strip", z.ZodTypeAny, {
|
|
411
|
+
username: string;
|
|
412
|
+
password: string;
|
|
413
|
+
email?: string | undefined;
|
|
414
|
+
fullname?: string | undefined;
|
|
415
|
+
role?: string | undefined;
|
|
416
|
+
wsIds?: string[] | undefined;
|
|
417
|
+
}, {
|
|
418
|
+
username: string;
|
|
419
|
+
password: string;
|
|
420
|
+
email?: string | undefined;
|
|
421
|
+
fullname?: string | undefined;
|
|
422
|
+
role?: string | undefined;
|
|
423
|
+
wsIds?: string[] | undefined;
|
|
424
|
+
}>, "many">;
|
|
425
|
+
}, "strip", z.ZodTypeAny, {
|
|
426
|
+
users: {
|
|
427
|
+
username: string;
|
|
428
|
+
password: string;
|
|
429
|
+
email?: string | undefined;
|
|
430
|
+
fullname?: string | undefined;
|
|
431
|
+
role?: string | undefined;
|
|
432
|
+
wsIds?: string[] | undefined;
|
|
433
|
+
}[];
|
|
434
|
+
}, {
|
|
435
|
+
users: {
|
|
436
|
+
username: string;
|
|
437
|
+
password: string;
|
|
438
|
+
email?: string | undefined;
|
|
439
|
+
fullname?: string | undefined;
|
|
440
|
+
role?: string | undefined;
|
|
441
|
+
wsIds?: string[] | undefined;
|
|
442
|
+
}[];
|
|
443
|
+
}>;
|
|
444
|
+
type UsersData = z.infer<typeof UsersDataSchema>;
|
|
329
445
|
declare const MessageSchema: z.ZodObject<{
|
|
330
446
|
id: z.ZodOptional<z.ZodString>;
|
|
331
447
|
type: z.ZodString;
|
|
@@ -429,6 +545,7 @@ type IncomingMessage = z.infer<typeof IncomingMessageSchema>;
|
|
|
429
545
|
type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
|
|
430
546
|
type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
|
|
431
547
|
type LLMProvider = 'anthropic' | 'groq';
|
|
548
|
+
|
|
432
549
|
interface SuperatomSDKConfig {
|
|
433
550
|
url?: string;
|
|
434
551
|
apiKey: string;
|
|
@@ -440,16 +557,9 @@ interface SuperatomSDKConfig {
|
|
|
440
557
|
ANTHROPIC_API_KEY?: string;
|
|
441
558
|
GROQ_API_KEY?: string;
|
|
442
559
|
LLM_PROVIDERS?: LLMProvider[];
|
|
560
|
+
logLevel?: LogLevel;
|
|
443
561
|
}
|
|
444
562
|
|
|
445
|
-
interface User {
|
|
446
|
-
username: string;
|
|
447
|
-
password: string;
|
|
448
|
-
wsIds: string[];
|
|
449
|
-
}
|
|
450
|
-
interface UsersData {
|
|
451
|
-
users: User[];
|
|
452
|
-
}
|
|
453
563
|
/**
|
|
454
564
|
* UserManager class to handle CRUD operations on users with file persistence
|
|
455
565
|
* and in-memory caching. Changes are synced to file periodically.
|
|
@@ -503,6 +613,18 @@ declare class UserManager {
|
|
|
503
613
|
* @returns The user if found, undefined otherwise
|
|
504
614
|
*/
|
|
505
615
|
getUser(username: string): User | undefined;
|
|
616
|
+
/**
|
|
617
|
+
* Read a user by email
|
|
618
|
+
* @param email - Email to retrieve
|
|
619
|
+
* @returns The user if found, undefined otherwise
|
|
620
|
+
*/
|
|
621
|
+
getUserByEmail(email: string): User | undefined;
|
|
622
|
+
/**
|
|
623
|
+
* Find user by username or email
|
|
624
|
+
* @param identifier - Username or email to search for
|
|
625
|
+
* @returns The user if found, undefined otherwise
|
|
626
|
+
*/
|
|
627
|
+
getUserByUsernameOrEmail(identifier: string): User | undefined;
|
|
506
628
|
/**
|
|
507
629
|
* Read all users
|
|
508
630
|
* @returns Array of all users
|
|
@@ -747,19 +869,26 @@ interface CapturedLog {
|
|
|
747
869
|
* UILogCollector captures logs during user prompt processing
|
|
748
870
|
* and sends them to runtime via ui_logs message with uiBlockId as the message id
|
|
749
871
|
* Logs are sent in real-time for streaming effect in the UI
|
|
872
|
+
* Respects the global log level configuration
|
|
750
873
|
*/
|
|
751
874
|
declare class UILogCollector {
|
|
752
875
|
private logs;
|
|
753
876
|
private uiBlockId;
|
|
754
877
|
private clientId;
|
|
755
878
|
private sendMessage;
|
|
879
|
+
private currentLogLevel;
|
|
756
880
|
constructor(clientId: string, sendMessage: (message: Message) => void, uiBlockId?: string);
|
|
757
881
|
/**
|
|
758
882
|
* Check if logging is enabled (uiBlockId is provided)
|
|
759
883
|
*/
|
|
760
884
|
isEnabled(): boolean;
|
|
885
|
+
/**
|
|
886
|
+
* Check if a message should be logged based on current log level
|
|
887
|
+
*/
|
|
888
|
+
private shouldLog;
|
|
761
889
|
/**
|
|
762
890
|
* Add a log entry with timestamp and immediately send to runtime
|
|
891
|
+
* Only logs that pass the log level filter are captured and sent
|
|
763
892
|
*/
|
|
764
893
|
private addLog;
|
|
765
894
|
/**
|
|
@@ -820,13 +949,14 @@ interface Action {
|
|
|
820
949
|
|
|
821
950
|
/**
|
|
822
951
|
* UIBlock represents a single user and assistant message block in a thread
|
|
823
|
-
* Contains user question, component metadata, component data, and available actions
|
|
952
|
+
* Contains user question, component metadata, component data, text response, and available actions
|
|
824
953
|
*/
|
|
825
954
|
declare class UIBlock {
|
|
826
955
|
private id;
|
|
827
956
|
private userQuestion;
|
|
828
957
|
private generatedComponentMetadata;
|
|
829
958
|
private componentData;
|
|
959
|
+
private textResponse;
|
|
830
960
|
private actions;
|
|
831
961
|
private createdAt;
|
|
832
962
|
/**
|
|
@@ -836,8 +966,9 @@ declare class UIBlock {
|
|
|
836
966
|
* @param generatedComponentMetadata - Optional metadata about the generated component
|
|
837
967
|
* @param actions - Optional array of available actions
|
|
838
968
|
* @param id - Optional custom ID, generates UUID if not provided
|
|
969
|
+
* @param textResponse - Optional text response from LLM
|
|
839
970
|
*/
|
|
840
|
-
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string);
|
|
971
|
+
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string, textResponse?: string | null);
|
|
841
972
|
/**
|
|
842
973
|
* Get the UIBlock ID
|
|
843
974
|
*/
|
|
@@ -882,6 +1013,14 @@ declare class UIBlock {
|
|
|
882
1013
|
* Set or update component data with size and row limits
|
|
883
1014
|
*/
|
|
884
1015
|
setComponentData(data: Record<string, any>): void;
|
|
1016
|
+
/**
|
|
1017
|
+
* Get text response
|
|
1018
|
+
*/
|
|
1019
|
+
getTextResponse(): string | null;
|
|
1020
|
+
/**
|
|
1021
|
+
* Set or update text response
|
|
1022
|
+
*/
|
|
1023
|
+
setTextResponse(textResponse: string | null): void;
|
|
885
1024
|
/**
|
|
886
1025
|
* Get all actions (only if they are resolved, not if fetching)
|
|
887
1026
|
*/
|
|
@@ -1241,4 +1380,4 @@ declare class SuperatomSDK {
|
|
|
1241
1380
|
private storeComponents;
|
|
1242
1381
|
}
|
|
1243
1382
|
|
|
1244
|
-
export { type Action, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type IncomingMessage, LLM, type Message, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, UIBlock, UILogCollector, type User, UserManager, type UsersData };
|
|
1383
|
+
export { type Action, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type IncomingMessage, LLM, type LogLevel, type Message, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, UIBlock, UILogCollector, type User, UserManager, type UsersData, logger };
|