@superatomai/sdk-node 0.0.4 → 0.0.6
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 +324 -57
- package/dist/index.d.mts +159 -11
- package/dist/index.d.ts +159 -11
- package/dist/index.js +1726 -472
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1712 -455
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
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
|
+
file(...args: any[]): void;
|
|
51
|
+
}
|
|
52
|
+
declare const logger: Logger;
|
|
53
|
+
|
|
3
54
|
declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
4
55
|
dsl: z.ZodObject<{
|
|
5
56
|
id: z.ZodString;
|
|
@@ -326,6 +377,72 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
326
377
|
}>;
|
|
327
378
|
type DSLRendererProps = z.infer<typeof DSLRendererPropsSchema>;
|
|
328
379
|
|
|
380
|
+
declare const UserSchema: z.ZodObject<{
|
|
381
|
+
username: z.ZodString;
|
|
382
|
+
email: z.ZodOptional<z.ZodString>;
|
|
383
|
+
password: z.ZodString;
|
|
384
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
385
|
+
role: z.ZodOptional<z.ZodString>;
|
|
386
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
387
|
+
}, "strip", z.ZodTypeAny, {
|
|
388
|
+
username: string;
|
|
389
|
+
password: string;
|
|
390
|
+
email?: string | undefined;
|
|
391
|
+
fullname?: string | undefined;
|
|
392
|
+
role?: string | undefined;
|
|
393
|
+
wsIds?: string[] | undefined;
|
|
394
|
+
}, {
|
|
395
|
+
username: string;
|
|
396
|
+
password: string;
|
|
397
|
+
email?: string | undefined;
|
|
398
|
+
fullname?: string | undefined;
|
|
399
|
+
role?: string | undefined;
|
|
400
|
+
wsIds?: string[] | undefined;
|
|
401
|
+
}>;
|
|
402
|
+
type User = z.infer<typeof UserSchema>;
|
|
403
|
+
declare const UsersDataSchema: z.ZodObject<{
|
|
404
|
+
users: z.ZodArray<z.ZodObject<{
|
|
405
|
+
username: z.ZodString;
|
|
406
|
+
email: z.ZodOptional<z.ZodString>;
|
|
407
|
+
password: z.ZodString;
|
|
408
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
409
|
+
role: z.ZodOptional<z.ZodString>;
|
|
410
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
411
|
+
}, "strip", z.ZodTypeAny, {
|
|
412
|
+
username: string;
|
|
413
|
+
password: string;
|
|
414
|
+
email?: string | undefined;
|
|
415
|
+
fullname?: string | undefined;
|
|
416
|
+
role?: string | undefined;
|
|
417
|
+
wsIds?: string[] | undefined;
|
|
418
|
+
}, {
|
|
419
|
+
username: string;
|
|
420
|
+
password: string;
|
|
421
|
+
email?: string | undefined;
|
|
422
|
+
fullname?: string | undefined;
|
|
423
|
+
role?: string | undefined;
|
|
424
|
+
wsIds?: string[] | undefined;
|
|
425
|
+
}>, "many">;
|
|
426
|
+
}, "strip", z.ZodTypeAny, {
|
|
427
|
+
users: {
|
|
428
|
+
username: string;
|
|
429
|
+
password: string;
|
|
430
|
+
email?: string | undefined;
|
|
431
|
+
fullname?: string | undefined;
|
|
432
|
+
role?: string | undefined;
|
|
433
|
+
wsIds?: string[] | undefined;
|
|
434
|
+
}[];
|
|
435
|
+
}, {
|
|
436
|
+
users: {
|
|
437
|
+
username: string;
|
|
438
|
+
password: string;
|
|
439
|
+
email?: string | undefined;
|
|
440
|
+
fullname?: string | undefined;
|
|
441
|
+
role?: string | undefined;
|
|
442
|
+
wsIds?: string[] | undefined;
|
|
443
|
+
}[];
|
|
444
|
+
}>;
|
|
445
|
+
type UsersData = z.infer<typeof UsersDataSchema>;
|
|
329
446
|
declare const MessageSchema: z.ZodObject<{
|
|
330
447
|
id: z.ZodOptional<z.ZodString>;
|
|
331
448
|
type: z.ZodString;
|
|
@@ -429,6 +546,7 @@ type IncomingMessage = z.infer<typeof IncomingMessageSchema>;
|
|
|
429
546
|
type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
|
|
430
547
|
type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
|
|
431
548
|
type LLMProvider = 'anthropic' | 'groq';
|
|
549
|
+
|
|
432
550
|
interface SuperatomSDKConfig {
|
|
433
551
|
url?: string;
|
|
434
552
|
apiKey: string;
|
|
@@ -440,16 +558,9 @@ interface SuperatomSDKConfig {
|
|
|
440
558
|
ANTHROPIC_API_KEY?: string;
|
|
441
559
|
GROQ_API_KEY?: string;
|
|
442
560
|
LLM_PROVIDERS?: LLMProvider[];
|
|
561
|
+
logLevel?: LogLevel;
|
|
443
562
|
}
|
|
444
563
|
|
|
445
|
-
interface User {
|
|
446
|
-
username: string;
|
|
447
|
-
password: string;
|
|
448
|
-
wsIds: string[];
|
|
449
|
-
}
|
|
450
|
-
interface UsersData {
|
|
451
|
-
users: User[];
|
|
452
|
-
}
|
|
453
564
|
/**
|
|
454
565
|
* UserManager class to handle CRUD operations on users with file persistence
|
|
455
566
|
* and in-memory caching. Changes are synced to file periodically.
|
|
@@ -503,6 +614,18 @@ declare class UserManager {
|
|
|
503
614
|
* @returns The user if found, undefined otherwise
|
|
504
615
|
*/
|
|
505
616
|
getUser(username: string): User | undefined;
|
|
617
|
+
/**
|
|
618
|
+
* Read a user by email
|
|
619
|
+
* @param email - Email to retrieve
|
|
620
|
+
* @returns The user if found, undefined otherwise
|
|
621
|
+
*/
|
|
622
|
+
getUserByEmail(email: string): User | undefined;
|
|
623
|
+
/**
|
|
624
|
+
* Find user by username or email
|
|
625
|
+
* @param identifier - Username or email to search for
|
|
626
|
+
* @returns The user if found, undefined otherwise
|
|
627
|
+
*/
|
|
628
|
+
getUserByUsernameOrEmail(identifier: string): User | undefined;
|
|
506
629
|
/**
|
|
507
630
|
* Read all users
|
|
508
631
|
* @returns Array of all users
|
|
@@ -709,9 +832,19 @@ interface LLMOptions {
|
|
|
709
832
|
apiKey?: string;
|
|
710
833
|
partial?: (chunk: string) => void;
|
|
711
834
|
}
|
|
835
|
+
interface Tool {
|
|
836
|
+
name: string;
|
|
837
|
+
description: string;
|
|
838
|
+
input_schema: {
|
|
839
|
+
type: string;
|
|
840
|
+
properties: Record<string, any>;
|
|
841
|
+
required?: string[];
|
|
842
|
+
};
|
|
843
|
+
}
|
|
712
844
|
declare class LLM {
|
|
713
845
|
static text(messages: LLMMessages, options?: LLMOptions): Promise<string>;
|
|
714
846
|
static stream<T = string>(messages: LLMMessages, options?: LLMOptions, json?: boolean): Promise<T extends string ? string : any>;
|
|
847
|
+
static streamWithTools(messages: LLMMessages, tools: Tool[], toolHandler: (toolName: string, toolInput: any) => Promise<any>, options?: LLMOptions, maxIterations?: number): Promise<string>;
|
|
715
848
|
/**
|
|
716
849
|
* Parse model string to extract provider and model name
|
|
717
850
|
* @param modelString - Format: "provider/model-name" or just "model-name"
|
|
@@ -725,6 +858,7 @@ declare class LLM {
|
|
|
725
858
|
private static _parseModel;
|
|
726
859
|
private static _anthropicText;
|
|
727
860
|
private static _anthropicStream;
|
|
861
|
+
private static _anthropicStreamWithTools;
|
|
728
862
|
private static _groqText;
|
|
729
863
|
private static _groqStream;
|
|
730
864
|
/**
|
|
@@ -747,19 +881,26 @@ interface CapturedLog {
|
|
|
747
881
|
* UILogCollector captures logs during user prompt processing
|
|
748
882
|
* and sends them to runtime via ui_logs message with uiBlockId as the message id
|
|
749
883
|
* Logs are sent in real-time for streaming effect in the UI
|
|
884
|
+
* Respects the global log level configuration
|
|
750
885
|
*/
|
|
751
886
|
declare class UILogCollector {
|
|
752
887
|
private logs;
|
|
753
888
|
private uiBlockId;
|
|
754
889
|
private clientId;
|
|
755
890
|
private sendMessage;
|
|
891
|
+
private currentLogLevel;
|
|
756
892
|
constructor(clientId: string, sendMessage: (message: Message) => void, uiBlockId?: string);
|
|
757
893
|
/**
|
|
758
894
|
* Check if logging is enabled (uiBlockId is provided)
|
|
759
895
|
*/
|
|
760
896
|
isEnabled(): boolean;
|
|
897
|
+
/**
|
|
898
|
+
* Check if a message should be logged based on current log level
|
|
899
|
+
*/
|
|
900
|
+
private shouldLog;
|
|
761
901
|
/**
|
|
762
902
|
* Add a log entry with timestamp and immediately send to runtime
|
|
903
|
+
* Only logs that pass the log level filter are captured and sent
|
|
763
904
|
*/
|
|
764
905
|
private addLog;
|
|
765
906
|
/**
|
|
@@ -820,13 +961,14 @@ interface Action {
|
|
|
820
961
|
|
|
821
962
|
/**
|
|
822
963
|
* UIBlock represents a single user and assistant message block in a thread
|
|
823
|
-
* Contains user question, component metadata, component data, and available actions
|
|
964
|
+
* Contains user question, component metadata, component data, text response, and available actions
|
|
824
965
|
*/
|
|
825
966
|
declare class UIBlock {
|
|
826
967
|
private id;
|
|
827
968
|
private userQuestion;
|
|
828
969
|
private generatedComponentMetadata;
|
|
829
970
|
private componentData;
|
|
971
|
+
private textResponse;
|
|
830
972
|
private actions;
|
|
831
973
|
private createdAt;
|
|
832
974
|
/**
|
|
@@ -836,8 +978,9 @@ declare class UIBlock {
|
|
|
836
978
|
* @param generatedComponentMetadata - Optional metadata about the generated component
|
|
837
979
|
* @param actions - Optional array of available actions
|
|
838
980
|
* @param id - Optional custom ID, generates UUID if not provided
|
|
981
|
+
* @param textResponse - Optional text response from LLM
|
|
839
982
|
*/
|
|
840
|
-
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string);
|
|
983
|
+
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string, textResponse?: string | null);
|
|
841
984
|
/**
|
|
842
985
|
* Get the UIBlock ID
|
|
843
986
|
*/
|
|
@@ -854,6 +997,7 @@ declare class UIBlock {
|
|
|
854
997
|
* Get component metadata
|
|
855
998
|
*/
|
|
856
999
|
getComponentMetadata(): Record<string, any>;
|
|
1000
|
+
getTextResponse(): string;
|
|
857
1001
|
/**
|
|
858
1002
|
* Set or update component metadata
|
|
859
1003
|
*/
|
|
@@ -882,6 +1026,10 @@ declare class UIBlock {
|
|
|
882
1026
|
* Set or update component data with size and row limits
|
|
883
1027
|
*/
|
|
884
1028
|
setComponentData(data: Record<string, any>): void;
|
|
1029
|
+
/**
|
|
1030
|
+
* Set or update text response
|
|
1031
|
+
*/
|
|
1032
|
+
setTextResponse(textResponse: string | null): void;
|
|
885
1033
|
/**
|
|
886
1034
|
* Get all actions (only if they are resolved, not if fetching)
|
|
887
1035
|
*/
|
|
@@ -1241,4 +1389,4 @@ declare class SuperatomSDK {
|
|
|
1241
1389
|
private storeComponents;
|
|
1242
1390
|
}
|
|
1243
1391
|
|
|
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 };
|
|
1392
|
+
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,56 @@
|
|
|
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
|
+
file(...args: any[]): void;
|
|
51
|
+
}
|
|
52
|
+
declare const logger: Logger;
|
|
53
|
+
|
|
3
54
|
declare const DSLRendererPropsSchema$1: z.ZodObject<{
|
|
4
55
|
dsl: z.ZodObject<{
|
|
5
56
|
id: z.ZodString;
|
|
@@ -326,6 +377,72 @@ declare const DSLRendererPropsSchema: z.ZodObject<{
|
|
|
326
377
|
}>;
|
|
327
378
|
type DSLRendererProps = z.infer<typeof DSLRendererPropsSchema>;
|
|
328
379
|
|
|
380
|
+
declare const UserSchema: z.ZodObject<{
|
|
381
|
+
username: z.ZodString;
|
|
382
|
+
email: z.ZodOptional<z.ZodString>;
|
|
383
|
+
password: z.ZodString;
|
|
384
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
385
|
+
role: z.ZodOptional<z.ZodString>;
|
|
386
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
387
|
+
}, "strip", z.ZodTypeAny, {
|
|
388
|
+
username: string;
|
|
389
|
+
password: string;
|
|
390
|
+
email?: string | undefined;
|
|
391
|
+
fullname?: string | undefined;
|
|
392
|
+
role?: string | undefined;
|
|
393
|
+
wsIds?: string[] | undefined;
|
|
394
|
+
}, {
|
|
395
|
+
username: string;
|
|
396
|
+
password: string;
|
|
397
|
+
email?: string | undefined;
|
|
398
|
+
fullname?: string | undefined;
|
|
399
|
+
role?: string | undefined;
|
|
400
|
+
wsIds?: string[] | undefined;
|
|
401
|
+
}>;
|
|
402
|
+
type User = z.infer<typeof UserSchema>;
|
|
403
|
+
declare const UsersDataSchema: z.ZodObject<{
|
|
404
|
+
users: z.ZodArray<z.ZodObject<{
|
|
405
|
+
username: z.ZodString;
|
|
406
|
+
email: z.ZodOptional<z.ZodString>;
|
|
407
|
+
password: z.ZodString;
|
|
408
|
+
fullname: z.ZodOptional<z.ZodString>;
|
|
409
|
+
role: z.ZodOptional<z.ZodString>;
|
|
410
|
+
wsIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
411
|
+
}, "strip", z.ZodTypeAny, {
|
|
412
|
+
username: string;
|
|
413
|
+
password: string;
|
|
414
|
+
email?: string | undefined;
|
|
415
|
+
fullname?: string | undefined;
|
|
416
|
+
role?: string | undefined;
|
|
417
|
+
wsIds?: string[] | undefined;
|
|
418
|
+
}, {
|
|
419
|
+
username: string;
|
|
420
|
+
password: string;
|
|
421
|
+
email?: string | undefined;
|
|
422
|
+
fullname?: string | undefined;
|
|
423
|
+
role?: string | undefined;
|
|
424
|
+
wsIds?: string[] | undefined;
|
|
425
|
+
}>, "many">;
|
|
426
|
+
}, "strip", z.ZodTypeAny, {
|
|
427
|
+
users: {
|
|
428
|
+
username: string;
|
|
429
|
+
password: string;
|
|
430
|
+
email?: string | undefined;
|
|
431
|
+
fullname?: string | undefined;
|
|
432
|
+
role?: string | undefined;
|
|
433
|
+
wsIds?: string[] | undefined;
|
|
434
|
+
}[];
|
|
435
|
+
}, {
|
|
436
|
+
users: {
|
|
437
|
+
username: string;
|
|
438
|
+
password: string;
|
|
439
|
+
email?: string | undefined;
|
|
440
|
+
fullname?: string | undefined;
|
|
441
|
+
role?: string | undefined;
|
|
442
|
+
wsIds?: string[] | undefined;
|
|
443
|
+
}[];
|
|
444
|
+
}>;
|
|
445
|
+
type UsersData = z.infer<typeof UsersDataSchema>;
|
|
329
446
|
declare const MessageSchema: z.ZodObject<{
|
|
330
447
|
id: z.ZodOptional<z.ZodString>;
|
|
331
448
|
type: z.ZodString;
|
|
@@ -429,6 +546,7 @@ type IncomingMessage = z.infer<typeof IncomingMessageSchema>;
|
|
|
429
546
|
type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
|
|
430
547
|
type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
|
|
431
548
|
type LLMProvider = 'anthropic' | 'groq';
|
|
549
|
+
|
|
432
550
|
interface SuperatomSDKConfig {
|
|
433
551
|
url?: string;
|
|
434
552
|
apiKey: string;
|
|
@@ -440,16 +558,9 @@ interface SuperatomSDKConfig {
|
|
|
440
558
|
ANTHROPIC_API_KEY?: string;
|
|
441
559
|
GROQ_API_KEY?: string;
|
|
442
560
|
LLM_PROVIDERS?: LLMProvider[];
|
|
561
|
+
logLevel?: LogLevel;
|
|
443
562
|
}
|
|
444
563
|
|
|
445
|
-
interface User {
|
|
446
|
-
username: string;
|
|
447
|
-
password: string;
|
|
448
|
-
wsIds: string[];
|
|
449
|
-
}
|
|
450
|
-
interface UsersData {
|
|
451
|
-
users: User[];
|
|
452
|
-
}
|
|
453
564
|
/**
|
|
454
565
|
* UserManager class to handle CRUD operations on users with file persistence
|
|
455
566
|
* and in-memory caching. Changes are synced to file periodically.
|
|
@@ -503,6 +614,18 @@ declare class UserManager {
|
|
|
503
614
|
* @returns The user if found, undefined otherwise
|
|
504
615
|
*/
|
|
505
616
|
getUser(username: string): User | undefined;
|
|
617
|
+
/**
|
|
618
|
+
* Read a user by email
|
|
619
|
+
* @param email - Email to retrieve
|
|
620
|
+
* @returns The user if found, undefined otherwise
|
|
621
|
+
*/
|
|
622
|
+
getUserByEmail(email: string): User | undefined;
|
|
623
|
+
/**
|
|
624
|
+
* Find user by username or email
|
|
625
|
+
* @param identifier - Username or email to search for
|
|
626
|
+
* @returns The user if found, undefined otherwise
|
|
627
|
+
*/
|
|
628
|
+
getUserByUsernameOrEmail(identifier: string): User | undefined;
|
|
506
629
|
/**
|
|
507
630
|
* Read all users
|
|
508
631
|
* @returns Array of all users
|
|
@@ -709,9 +832,19 @@ interface LLMOptions {
|
|
|
709
832
|
apiKey?: string;
|
|
710
833
|
partial?: (chunk: string) => void;
|
|
711
834
|
}
|
|
835
|
+
interface Tool {
|
|
836
|
+
name: string;
|
|
837
|
+
description: string;
|
|
838
|
+
input_schema: {
|
|
839
|
+
type: string;
|
|
840
|
+
properties: Record<string, any>;
|
|
841
|
+
required?: string[];
|
|
842
|
+
};
|
|
843
|
+
}
|
|
712
844
|
declare class LLM {
|
|
713
845
|
static text(messages: LLMMessages, options?: LLMOptions): Promise<string>;
|
|
714
846
|
static stream<T = string>(messages: LLMMessages, options?: LLMOptions, json?: boolean): Promise<T extends string ? string : any>;
|
|
847
|
+
static streamWithTools(messages: LLMMessages, tools: Tool[], toolHandler: (toolName: string, toolInput: any) => Promise<any>, options?: LLMOptions, maxIterations?: number): Promise<string>;
|
|
715
848
|
/**
|
|
716
849
|
* Parse model string to extract provider and model name
|
|
717
850
|
* @param modelString - Format: "provider/model-name" or just "model-name"
|
|
@@ -725,6 +858,7 @@ declare class LLM {
|
|
|
725
858
|
private static _parseModel;
|
|
726
859
|
private static _anthropicText;
|
|
727
860
|
private static _anthropicStream;
|
|
861
|
+
private static _anthropicStreamWithTools;
|
|
728
862
|
private static _groqText;
|
|
729
863
|
private static _groqStream;
|
|
730
864
|
/**
|
|
@@ -747,19 +881,26 @@ interface CapturedLog {
|
|
|
747
881
|
* UILogCollector captures logs during user prompt processing
|
|
748
882
|
* and sends them to runtime via ui_logs message with uiBlockId as the message id
|
|
749
883
|
* Logs are sent in real-time for streaming effect in the UI
|
|
884
|
+
* Respects the global log level configuration
|
|
750
885
|
*/
|
|
751
886
|
declare class UILogCollector {
|
|
752
887
|
private logs;
|
|
753
888
|
private uiBlockId;
|
|
754
889
|
private clientId;
|
|
755
890
|
private sendMessage;
|
|
891
|
+
private currentLogLevel;
|
|
756
892
|
constructor(clientId: string, sendMessage: (message: Message) => void, uiBlockId?: string);
|
|
757
893
|
/**
|
|
758
894
|
* Check if logging is enabled (uiBlockId is provided)
|
|
759
895
|
*/
|
|
760
896
|
isEnabled(): boolean;
|
|
897
|
+
/**
|
|
898
|
+
* Check if a message should be logged based on current log level
|
|
899
|
+
*/
|
|
900
|
+
private shouldLog;
|
|
761
901
|
/**
|
|
762
902
|
* Add a log entry with timestamp and immediately send to runtime
|
|
903
|
+
* Only logs that pass the log level filter are captured and sent
|
|
763
904
|
*/
|
|
764
905
|
private addLog;
|
|
765
906
|
/**
|
|
@@ -820,13 +961,14 @@ interface Action {
|
|
|
820
961
|
|
|
821
962
|
/**
|
|
822
963
|
* UIBlock represents a single user and assistant message block in a thread
|
|
823
|
-
* Contains user question, component metadata, component data, and available actions
|
|
964
|
+
* Contains user question, component metadata, component data, text response, and available actions
|
|
824
965
|
*/
|
|
825
966
|
declare class UIBlock {
|
|
826
967
|
private id;
|
|
827
968
|
private userQuestion;
|
|
828
969
|
private generatedComponentMetadata;
|
|
829
970
|
private componentData;
|
|
971
|
+
private textResponse;
|
|
830
972
|
private actions;
|
|
831
973
|
private createdAt;
|
|
832
974
|
/**
|
|
@@ -836,8 +978,9 @@ declare class UIBlock {
|
|
|
836
978
|
* @param generatedComponentMetadata - Optional metadata about the generated component
|
|
837
979
|
* @param actions - Optional array of available actions
|
|
838
980
|
* @param id - Optional custom ID, generates UUID if not provided
|
|
981
|
+
* @param textResponse - Optional text response from LLM
|
|
839
982
|
*/
|
|
840
|
-
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string);
|
|
983
|
+
constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string, textResponse?: string | null);
|
|
841
984
|
/**
|
|
842
985
|
* Get the UIBlock ID
|
|
843
986
|
*/
|
|
@@ -854,6 +997,7 @@ declare class UIBlock {
|
|
|
854
997
|
* Get component metadata
|
|
855
998
|
*/
|
|
856
999
|
getComponentMetadata(): Record<string, any>;
|
|
1000
|
+
getTextResponse(): string;
|
|
857
1001
|
/**
|
|
858
1002
|
* Set or update component metadata
|
|
859
1003
|
*/
|
|
@@ -882,6 +1026,10 @@ declare class UIBlock {
|
|
|
882
1026
|
* Set or update component data with size and row limits
|
|
883
1027
|
*/
|
|
884
1028
|
setComponentData(data: Record<string, any>): void;
|
|
1029
|
+
/**
|
|
1030
|
+
* Set or update text response
|
|
1031
|
+
*/
|
|
1032
|
+
setTextResponse(textResponse: string | null): void;
|
|
885
1033
|
/**
|
|
886
1034
|
* Get all actions (only if they are resolved, not if fetching)
|
|
887
1035
|
*/
|
|
@@ -1241,4 +1389,4 @@ declare class SuperatomSDK {
|
|
|
1241
1389
|
private storeComponents;
|
|
1242
1390
|
}
|
|
1243
1391
|
|
|
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 };
|
|
1392
|
+
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 };
|