@autoai-ui/autoui 0.1.8 → 0.1.9
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.d.ts +2 -0
- package/dist/lib/bin/index.d.ts +1 -0
- package/dist/lib/components/chat/context/chatContext.d.ts +3 -0
- package/dist/lib/components/chat/context/modalChatContext.d.ts +9 -0
- package/dist/lib/components/chat/hooks/useAutoUiChat.d.ts +4 -0
- package/dist/lib/components/chat/hooks/useChat.d.ts +3 -0
- package/dist/lib/components/chat/hooks/useChatState.d.ts +7 -0
- package/dist/lib/components/chat/hooks/useRendering.d.ts +7 -0
- package/dist/lib/components/chat/index.d.ts +2 -0
- package/dist/lib/components/chat/types/index.d.ts +107 -0
- package/dist/lib/components/chat/ui/Chat.d.ts +3 -0
- package/dist/lib/components/chat/ui/ChatHeader.d.ts +1 -0
- package/dist/lib/components/chat/ui/ChatInput.d.ts +4 -0
- package/dist/lib/components/chat/ui/ChatMessageList.d.ts +3 -0
- package/dist/lib/components/chat/ui/ChatMessageListItem.d.ts +6 -0
- package/dist/lib/components/chat/ui/ModalChat.d.ts +2 -0
- package/dist/lib/components/chat/ui/btnOpenChat/index.d.ts +3 -0
- package/dist/lib/components/index.d.ts +2 -0
- package/dist/lib/components/spinner/index.d.ts +1 -0
- package/dist/lib/components/spinner/ui/Spinner.d.ts +15 -0
- package/dist/lib/core/buildIntentPrompt.d.ts +2 -0
- package/dist/lib/core/index.d.ts +1 -0
- package/dist/lib/core/llmClient.d.ts +3 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/runtime/index.d.ts +1 -0
- package/dist/lib/runtime/rerenderChatFromHistory.d.ts +3 -0
- package/dist/lib/runtime/runtimeEngine.d.ts +9 -0
- package/dist/lib/runtime/stepExecutor.d.ts +7 -0
- package/dist/lib/types/index.d.ts +82 -0
- package/dist/lib/types/llmTypes.d.ts +20 -0
- package/dist/lib/utils/clsx.d.ts +1 -0
- package/dist/lib/utils/debounce.d.ts +11 -0
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/resolveProps.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ModalChatContext } from '../types';
|
|
3
|
+
import { AutoUIConfig } from '../../../types';
|
|
4
|
+
export interface ModalChatProviderProps {
|
|
5
|
+
config: AutoUIConfig;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const ModalChatProvider: ({ config, children }: ModalChatProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const useModalChatContext: () => ModalChatContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SerializedMessage, ChatMessage } from '../types';
|
|
2
|
+
import { AutoUIConfig } from '../../../types';
|
|
3
|
+
export declare function useChatState(storageKey: string, config: AutoUIConfig): {
|
|
4
|
+
messages: ChatMessage[];
|
|
5
|
+
serializedMessages: SerializedMessage[];
|
|
6
|
+
setSerializedMessages: import('react').Dispatch<import('react').SetStateAction<SerializedMessage[]>>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { default as React, ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { AutoUIConfig } from '../../../types';
|
|
3
|
+
export declare function useRendering(config: AutoUIConfig): {
|
|
4
|
+
setUIRenderer: (fn: (node: ReactNode | string | ComponentType<any>) => void) => void;
|
|
5
|
+
resolveComponent: (name: string, props: any) => ReactNode;
|
|
6
|
+
setUI: (ui: React.ReactNode | string) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { AutoUIConfig } from '../../../types';
|
|
2
|
+
import { ComponentType, ReactNode, default as React } from 'react';
|
|
3
|
+
export type BtnOpenChatProps = {
|
|
4
|
+
isOpen?: boolean;
|
|
5
|
+
onOpenChange?: () => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface ModalChatContextValue {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ModalChatContext {
|
|
12
|
+
value: ModalChatContextValue;
|
|
13
|
+
setValue: React.Dispatch<React.SetStateAction<ModalChatContextValue>>;
|
|
14
|
+
config: AutoUIConfig;
|
|
15
|
+
}
|
|
16
|
+
export interface ChatMessage {
|
|
17
|
+
id: string;
|
|
18
|
+
role: 'user' | 'assistant' | 'system';
|
|
19
|
+
content: string | ReactNode | ComponentType<any>;
|
|
20
|
+
}
|
|
21
|
+
interface ChatClassNames {
|
|
22
|
+
header?: string;
|
|
23
|
+
body?: string;
|
|
24
|
+
footer?: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
closeButton?: string;
|
|
27
|
+
base?: string;
|
|
28
|
+
inputWrapper?: string;
|
|
29
|
+
input?: string;
|
|
30
|
+
inputButton?: string;
|
|
31
|
+
messageList?: string;
|
|
32
|
+
message?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ChatProviderPropsType {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
value: ChatContextType;
|
|
37
|
+
config: AutoUIConfig;
|
|
38
|
+
}
|
|
39
|
+
export interface ChatContextType {
|
|
40
|
+
config: AutoUIConfig;
|
|
41
|
+
isOpen?: boolean;
|
|
42
|
+
title?: string;
|
|
43
|
+
classNames?: ChatClassNames;
|
|
44
|
+
messages: ChatMessage[] | undefined;
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
closeIcon?: any;
|
|
47
|
+
handleSend: (text: string) => Promise<void>;
|
|
48
|
+
handleClear: () => void;
|
|
49
|
+
getChatInputProps: () => {
|
|
50
|
+
onSend: (text: string) => Promise<void>;
|
|
51
|
+
disabled: boolean;
|
|
52
|
+
};
|
|
53
|
+
getChatHeaderProps: () => {
|
|
54
|
+
title: string;
|
|
55
|
+
onClose?: () => void;
|
|
56
|
+
};
|
|
57
|
+
getMessageListProps: () => {
|
|
58
|
+
messages: ChatMessage[] | undefined;
|
|
59
|
+
};
|
|
60
|
+
onClose?: () => void;
|
|
61
|
+
}
|
|
62
|
+
export interface ChatMessageListProps {
|
|
63
|
+
}
|
|
64
|
+
export interface ChatProps {
|
|
65
|
+
config: AutoUIConfig;
|
|
66
|
+
title?: string;
|
|
67
|
+
isOpen?: boolean;
|
|
68
|
+
storageKey?: string;
|
|
69
|
+
closeIcon?: any;
|
|
70
|
+
classNames?: ChatClassNames;
|
|
71
|
+
onError?: (err: Error) => void;
|
|
72
|
+
onClose?: () => void;
|
|
73
|
+
}
|
|
74
|
+
export type ModalChatProps = {
|
|
75
|
+
config: AutoUIConfig;
|
|
76
|
+
portalContainer?: HTMLElement;
|
|
77
|
+
} & ChatProps;
|
|
78
|
+
export type ActionRef = {
|
|
79
|
+
__action: string;
|
|
80
|
+
args?: Record<string, unknown>;
|
|
81
|
+
};
|
|
82
|
+
export type UiNode = {
|
|
83
|
+
t: 'text';
|
|
84
|
+
text: string;
|
|
85
|
+
} | {
|
|
86
|
+
t: 'component';
|
|
87
|
+
name: string;
|
|
88
|
+
props?: Record<string, unknown>;
|
|
89
|
+
children?: UiNode[];
|
|
90
|
+
} | {
|
|
91
|
+
t: 'fragment';
|
|
92
|
+
children?: UiNode[];
|
|
93
|
+
};
|
|
94
|
+
export type SerializedMessage = {
|
|
95
|
+
id: string;
|
|
96
|
+
role: 'assistant' | 'user';
|
|
97
|
+
kind: 'text';
|
|
98
|
+
text: string;
|
|
99
|
+
ts?: number;
|
|
100
|
+
} | {
|
|
101
|
+
id: string;
|
|
102
|
+
role: 'assistant';
|
|
103
|
+
kind: 'ui';
|
|
104
|
+
ui: UiNode;
|
|
105
|
+
ts?: number;
|
|
106
|
+
};
|
|
107
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ChatHeader: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Spinner } from './ui/Spinner';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface SpinnerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
variant?: 'default' | 'simple' | 'wave' | 'dots' | 'spinner';
|
|
4
|
+
label?: string;
|
|
5
|
+
classNames?: {
|
|
6
|
+
base?: string;
|
|
7
|
+
wrapper?: string;
|
|
8
|
+
dots?: string;
|
|
9
|
+
spinnerBars?: string;
|
|
10
|
+
circle1?: string;
|
|
11
|
+
circle2?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const Spinner: React.ForwardRefExoticComponent<SpinnerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Chat, ModalChat } from './components';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ChatMessage, SerializedMessage } from '../components/chat/types';
|
|
2
|
+
import { ResolveComponent, SetUI } from './stepExecutor';
|
|
3
|
+
export declare const rerenderChatFromHistory: (chatHistory: SerializedMessage[], resolveComponent: ResolveComponent, setUI: SetUI) => ChatMessage[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AutoUIConfig } from '../types';
|
|
2
|
+
import { InstructionPlan } from '../types/llmTypes';
|
|
3
|
+
import { ResolveComponent, SetUI } from './stepExecutor';
|
|
4
|
+
import { SerializedMessage } from '../components/chat/types';
|
|
5
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
6
|
+
export type RunOptions = {
|
|
7
|
+
validate?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function runInstructionPlan(plan: InstructionPlan, config: AutoUIConfig, resolveComponent: ResolveComponent, setUI: SetUI, setSerializedMessages: Dispatch<SetStateAction<SerializedMessage[]>>, opts?: RunOptions): Promise<Record<string, any>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InstructionPlan } from '../types/llmTypes';
|
|
2
|
+
import { AutoUIConfig } from '../types';
|
|
3
|
+
import { SerializedMessage } from '../components/chat/types';
|
|
4
|
+
import { Dispatch, SetStateAction, default as React } from 'react';
|
|
5
|
+
export type ResolveComponent = (name: string, props: any) => React.ReactNode;
|
|
6
|
+
export type SetUI = (ui: React.ReactNode | string) => void;
|
|
7
|
+
export declare function executePlanSteps(plan: InstructionPlan, config: AutoUIConfig, resolveComponent: ResolveComponent, setUI: SetUI, setSerializedMessages: Dispatch<SetStateAction<SerializedMessage[]>>): Promise<Record<string, any>>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
export interface AutoUIConfig {
|
|
3
|
+
llm: LLMConfig;
|
|
4
|
+
runtime: RuntimeConfig;
|
|
5
|
+
functions: Record<string, AutoUIFunction>;
|
|
6
|
+
components: Record<string, AutoUIComponent>;
|
|
7
|
+
metadata?: AutoUIMetadata;
|
|
8
|
+
}
|
|
9
|
+
export interface LLMConfig {
|
|
10
|
+
/** Provider name (e.g., openai, openrouter, anthropic, azure) */
|
|
11
|
+
provider: string;
|
|
12
|
+
/** Direct API key (client-side) */
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/** Backend proxy endpoint (safer for production) */
|
|
16
|
+
apiProxyUrl?: string;
|
|
17
|
+
/** Model identifier (e.g., openai/gpt-5-chat) */
|
|
18
|
+
model: string;
|
|
19
|
+
/** Sampling temperature */
|
|
20
|
+
temperature?: number;
|
|
21
|
+
/** Max tokens per request */
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
/** App description for context (“this app is about…”) */
|
|
24
|
+
appDescriptionPrompt?: string;
|
|
25
|
+
/** Optional request headers (forwarded to provider) */
|
|
26
|
+
requestHeaders?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface RuntimeConfig {
|
|
29
|
+
/** Whether to validate LLM JSON output */
|
|
30
|
+
validateLLMOutput?: boolean;
|
|
31
|
+
/** Whether to store chat history to localStorage */
|
|
32
|
+
storeChatToLocalStorage?: boolean;
|
|
33
|
+
/** Key used for saving chat history */
|
|
34
|
+
localStorageKey?: string;
|
|
35
|
+
/** Enable internal debug logging */
|
|
36
|
+
enableDebugLogs?: boolean;
|
|
37
|
+
/** Maximum instruction steps allowed */
|
|
38
|
+
maxSteps?: number;
|
|
39
|
+
/** Error-handling policy */
|
|
40
|
+
errorHandling?: {
|
|
41
|
+
showToUser?: boolean;
|
|
42
|
+
retryOnFail?: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface AutoUIFunction {
|
|
46
|
+
/** Prompt used by the LLM to decide when/how to call this function */
|
|
47
|
+
prompt: string;
|
|
48
|
+
/** Descriptive list of parameters (for documentation & LLM guidance) */
|
|
49
|
+
params?: Record<string, string>;
|
|
50
|
+
/** Description of the expected return type */
|
|
51
|
+
returns?: string;
|
|
52
|
+
/** The actual callable implementation (may be mocked) */
|
|
53
|
+
callFunc: Function;
|
|
54
|
+
/** Optional example usage or notes for LLM context */
|
|
55
|
+
exampleUsage?: string;
|
|
56
|
+
/** Optional tags for organization */
|
|
57
|
+
tags?: string[];
|
|
58
|
+
}
|
|
59
|
+
export interface AutoUIComponent {
|
|
60
|
+
/** Prompt describing what the component does (for LLM) */
|
|
61
|
+
prompt: string;
|
|
62
|
+
/** Human-readable parameter descriptions */
|
|
63
|
+
props?: Record<string, string>;
|
|
64
|
+
/** Actual React component reference */
|
|
65
|
+
callComponent: ComponentType<any>;
|
|
66
|
+
/** Default prop values for runtime or mock previews */
|
|
67
|
+
defaults?: Record<string, any>;
|
|
68
|
+
/** Example JSX usage (string literal for docs) */
|
|
69
|
+
exampleUsage?: string;
|
|
70
|
+
/** Optional category (product-display, checkout, etc.) */
|
|
71
|
+
category?: string;
|
|
72
|
+
/** Optional tags for search or grouping */
|
|
73
|
+
tags?: string[];
|
|
74
|
+
}
|
|
75
|
+
export interface AutoUIMetadata {
|
|
76
|
+
appName: string;
|
|
77
|
+
appVersion?: string;
|
|
78
|
+
author?: string;
|
|
79
|
+
createdAt?: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
tags?: string[];
|
|
82
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type FunctionStep = {
|
|
2
|
+
type: 'function';
|
|
3
|
+
name: string;
|
|
4
|
+
params?: Record<string, any>;
|
|
5
|
+
assign?: string;
|
|
6
|
+
};
|
|
7
|
+
export type ComponentStep = {
|
|
8
|
+
type: 'component';
|
|
9
|
+
name: string;
|
|
10
|
+
props?: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
export type TextStep = {
|
|
13
|
+
type: 'text';
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
export type InstructionStep = FunctionStep | ComponentStep | TextStep;
|
|
17
|
+
export type InstructionPlan = {
|
|
18
|
+
type: 'sequence';
|
|
19
|
+
steps: InstructionStep[];
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clsx(...classes: any[]): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface DebounceOptions {
|
|
2
|
+
leading?: boolean;
|
|
3
|
+
maxWait?: number;
|
|
4
|
+
trailing?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface DebouncedFunc<T extends (...args: any[]) => any> {
|
|
7
|
+
(...args: Parameters<T>): ReturnType<T> | undefined;
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
flush: () => ReturnType<T> | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait?: number, options?: DebounceOptions): DebouncedFunc<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|