@hanzo/react 0.1.2 → 1.0.0

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.
Files changed (52) hide show
  1. package/README.md +317 -53
  2. package/dist/index.d.mts +255 -0
  3. package/dist/index.d.ts +255 -0
  4. package/dist/index.js +548 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +539 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +84 -91
  9. package/src/components/HanzoProvider.test.tsx +346 -0
  10. package/src/components/HanzoProvider.tsx +508 -0
  11. package/src/hooks/index.ts +39 -0
  12. package/src/hooks/types.ts +162 -0
  13. package/src/hooks/useAuth.ts +0 -0
  14. package/src/hooks/useComponent.ts +0 -0
  15. package/src/hooks/useGenerativeUI.ts +0 -0
  16. package/src/hooks/useMCP.ts +0 -0
  17. package/src/hooks/useMessage.ts +105 -0
  18. package/src/hooks/useModelConfig.ts +0 -0
  19. package/src/hooks/useStreaming.ts +161 -0
  20. package/src/hooks/useSuggestions.ts +0 -0
  21. package/src/hooks/useThread.ts +0 -0
  22. package/src/hooks/useTool.ts +0 -0
  23. package/src/index.ts +40 -0
  24. package/src/types/index.ts +25 -0
  25. package/src/utils/cn.ts +6 -0
  26. package/src/utils/id.ts +6 -0
  27. package/src/utils/stream.ts +33 -0
  28. package/LICENSE +0 -21
  29. package/dist/index.cjs.js +0 -15755
  30. package/dist/index.cjs.js.map +0 -1
  31. package/dist/index.css +0 -789
  32. package/dist/index.esm.js +0 -15736
  33. package/dist/index.esm.js.map +0 -1
  34. package/dist/index.umd.js +0 -15756
  35. package/dist/index.umd.js.map +0 -1
  36. package/src/controls/.DS_Store +0 -0
  37. package/src/controls/MUICheckbox.js +0 -108
  38. package/src/controls/MUIKeyboardDatePicker.js +0 -90
  39. package/src/controls/MUIPhone.js +0 -33
  40. package/src/controls/MUISwitch.js +0 -107
  41. package/src/controls/MUIText.js +0 -298
  42. package/src/controls/NumericFormats.js +0 -57
  43. package/src/controls/control.js +0 -148
  44. package/src/controls/index.js +0 -7
  45. package/src/controls/material-ui-phone-number/components/Item.js +0 -66
  46. package/src/controls/material-ui-phone-number/components/flags.css +0 -789
  47. package/src/controls/material-ui-phone-number/components/index.js +0 -884
  48. package/src/controls/material-ui-phone-number/components/polyfills.js +0 -82
  49. package/src/controls/material-ui-phone-number/country_data.js +0 -1536
  50. package/src/controls/material-ui-phone-number/index.js +0 -3
  51. package/src/index.js +0 -1
  52. /package/src/{core/index.js → hooks/useAttachments.ts} +0 -0
@@ -0,0 +1,255 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React$1 from 'react';
3
+ import { z } from 'zod';
4
+ import { ClassValue } from 'clsx';
5
+
6
+ interface HanzoComponent {
7
+ name: string;
8
+ component: React$1.ComponentType<any>;
9
+ description?: string;
10
+ parameters?: z.ZodType<any>;
11
+ generateUI?: (params: any) => React$1.ReactElement;
12
+ }
13
+ interface HanzoTool {
14
+ name: string;
15
+ description: string;
16
+ parameters: z.ZodType<any>;
17
+ execute: (params: any) => Promise<any>;
18
+ }
19
+ interface Message {
20
+ id: string;
21
+ role: 'user' | 'assistant' | 'system' | 'tool';
22
+ content: string | React$1.ReactElement;
23
+ timestamp: Date;
24
+ threadId: string;
25
+ toolCalls?: ToolCall[];
26
+ metadata?: Record<string, any>;
27
+ }
28
+ interface ToolCall {
29
+ id: string;
30
+ name: string;
31
+ arguments: any;
32
+ result?: any;
33
+ status: 'pending' | 'running' | 'completed' | 'failed';
34
+ }
35
+ interface Thread {
36
+ id: string;
37
+ messages: Message[];
38
+ createdAt: Date;
39
+ updatedAt: Date;
40
+ metadata?: Record<string, any>;
41
+ }
42
+ interface HanzoContextValue {
43
+ apiKey?: string;
44
+ apiUrl?: string;
45
+ model?: string;
46
+ components: Map<string, HanzoComponent>;
47
+ tools: Map<string, HanzoTool>;
48
+ threads: Map<string, Thread>;
49
+ activeThreadId?: string;
50
+ sendMessage: (content: string, threadId?: string) => Promise<Message>;
51
+ streamMessage: (content: string, threadId?: string) => AsyncGenerator<Message>;
52
+ createThread: (metadata?: Record<string, any>) => Thread;
53
+ switchThread: (threadId: string) => void;
54
+ deleteThread: (threadId: string) => void;
55
+ registerComponent: (component: HanzoComponent) => void;
56
+ unregisterComponent: (name: string) => void;
57
+ renderComponent: (name: string, props: any) => React$1.ReactElement | null;
58
+ registerTool: (tool: HanzoTool) => void;
59
+ unregisterTool: (name: string) => void;
60
+ executeTool: (name: string, params: any) => Promise<any>;
61
+ isStreaming: boolean;
62
+ responseStage?: 'thinking' | 'generating' | 'tool-calling' | 'completed';
63
+ error?: Error;
64
+ }
65
+ interface HanzoProviderProps {
66
+ children: React$1.ReactNode;
67
+ apiKey?: string;
68
+ apiUrl?: string;
69
+ model?: string;
70
+ components?: HanzoComponent[];
71
+ tools?: HanzoTool[];
72
+ initialMessages?: Message[];
73
+ onMessage?: (message: Message) => void;
74
+ onError?: (error: Error) => void;
75
+ enableStreaming?: boolean;
76
+ enableMCP?: boolean;
77
+ mcpServers?: string[];
78
+ }
79
+ declare function HanzoProvider({ children, apiKey, apiUrl, model, components: initialComponents, tools: initialTools, initialMessages, onMessage, onError, enableStreaming, enableMCP, // eslint-disable-line @typescript-eslint/no-unused-vars
80
+ mcpServers }: HanzoProviderProps): react_jsx_runtime.JSX.Element;
81
+ declare function useHanzo(): HanzoContextValue;
82
+
83
+ interface UseMessageOptions {
84
+ threadId?: string;
85
+ onSuccess?: (message: Message) => void;
86
+ onError?: (error: Error) => void;
87
+ autoRetry?: boolean;
88
+ maxRetries?: number;
89
+ retryDelay?: number;
90
+ }
91
+ interface UseMessageReturn {
92
+ sendMessage: (content: string) => Promise<Message>;
93
+ sendMessageWithAttachments: (content: string, attachments: File[]) => Promise<Message>;
94
+ isLoading: boolean;
95
+ error: Error | null;
96
+ lastMessage: Message | null;
97
+ clearError: () => void;
98
+ retry: () => Promise<void>;
99
+ }
100
+ declare function useMessage(options?: UseMessageOptions): UseMessageReturn;
101
+
102
+ interface UseStreamingOptions {
103
+ threadId?: string;
104
+ onChunk?: (chunk: string) => void;
105
+ onComplete?: (message: Message) => void;
106
+ onError?: (error: Error) => void;
107
+ bufferSize?: number;
108
+ throttleMs?: number;
109
+ }
110
+ interface UseStreamingReturn {
111
+ streamMessage: (content: string) => Promise<void>;
112
+ isStreaming: boolean;
113
+ currentMessage: string;
114
+ error: Error | null;
115
+ stopStreaming: () => void;
116
+ clearMessage: () => void;
117
+ progress: number;
118
+ }
119
+ declare function useStreaming(options?: UseStreamingOptions): UseStreamingReturn;
120
+
121
+ declare function cn(...inputs: ClassValue[]): string;
122
+
123
+ declare function generateId(prefix?: string): string;
124
+
125
+ declare function parseStream(stream: ReadableStream<Uint8Array>): Promise<string>;
126
+
127
+ interface UseThreadOptions {
128
+ maxThreads?: number;
129
+ autoArchive?: boolean;
130
+ }
131
+ interface UseThreadReturn {
132
+ threads: Map<string, any>;
133
+ activeThread: any | undefined;
134
+ createThread: (metadata?: Record<string, any>) => any;
135
+ switchThread: (threadId: string) => void;
136
+ deleteThread: (threadId: string) => void;
137
+ updateThreadMetadata: (threadId: string, metadata: Record<string, any>) => void;
138
+ getThreadMessages: (threadId: string) => any[];
139
+ clearThread: (threadId: string) => void;
140
+ }
141
+ interface UseComponentOptions {
142
+ lazy?: boolean;
143
+ }
144
+ interface UseComponentReturn {
145
+ registerComponent: (component: any) => void;
146
+ unregisterComponent: (name: string) => void;
147
+ renderComponent: (name: string, props: any) => React.ReactElement | null;
148
+ getComponent: (name: string) => any | undefined;
149
+ hasComponent: (name: string) => boolean;
150
+ listComponents: () => string[];
151
+ }
152
+ interface UseToolOptions {
153
+ timeout?: number;
154
+ }
155
+ interface UseToolReturn {
156
+ executeTool: (name: string, params: any) => Promise<any>;
157
+ registerTool: (tool: any) => void;
158
+ unregisterTool: (name: string) => void;
159
+ isExecuting: boolean;
160
+ lastResult: any | null;
161
+ error: Error | null;
162
+ }
163
+ interface UseSuggestionsOptions {
164
+ maxSuggestions?: number;
165
+ autoRefresh?: boolean;
166
+ refreshInterval?: number;
167
+ }
168
+ interface UseSuggestionsReturn {
169
+ suggestions: any[];
170
+ getSuggestions: (options?: any) => Promise<void>;
171
+ acceptSuggestion: (suggestion: any) => void;
172
+ dismissSuggestion: (id: string) => void;
173
+ isLoading: boolean;
174
+ }
175
+ interface UseModelConfigOptions {
176
+ defaultModel?: string;
177
+ }
178
+ interface UseModelConfigReturn {
179
+ currentModel: string;
180
+ availableModels: any[];
181
+ switchModel: (modelId: string) => void;
182
+ updateParameters: (params: any) => void;
183
+ resetToDefaults: () => void;
184
+ }
185
+ interface UseMCPOptions {
186
+ autoConnect?: boolean;
187
+ }
188
+ interface UseMCPReturn {
189
+ connectServer: (config: any) => Promise<void>;
190
+ disconnectServer: (id: string) => void;
191
+ connectedServers: any[];
192
+ executeServerTool: (serverId: string, tool: string, params: any) => Promise<any>;
193
+ getServerResources: (serverId: string) => any[];
194
+ isConnected: (serverId: string) => boolean;
195
+ }
196
+ interface UseGenerativeUIOptions {
197
+ cacheResults?: boolean;
198
+ }
199
+ interface UseGenerativeUIReturn {
200
+ generateUI: (options: any) => Promise<React.ReactElement>;
201
+ isGenerating: boolean;
202
+ generatedComponents: React.ReactElement[];
203
+ clearComponents: () => void;
204
+ saveComponent: (name: string, component: React.ReactElement) => void;
205
+ }
206
+ interface UseAuthOptions {
207
+ provider?: string;
208
+ }
209
+ interface UseAuthReturn {
210
+ user: any | null;
211
+ isAuthenticated: boolean;
212
+ isLoading: boolean;
213
+ signIn: (options?: any) => Promise<void>;
214
+ signOut: () => Promise<void>;
215
+ getToken: () => Promise<string | null>;
216
+ refreshToken: () => Promise<void>;
217
+ }
218
+ interface UseAttachmentsOptions {
219
+ maxSize?: number;
220
+ allowedTypes?: string[];
221
+ autoUpload?: boolean;
222
+ }
223
+ interface UseAttachmentsReturn {
224
+ attachments: any[];
225
+ addAttachment: (file: File) => Promise<any>;
226
+ removeAttachment: (id: string) => void;
227
+ clearAttachments: () => void;
228
+ uploadAttachment: (attachment: any) => Promise<void>;
229
+ isUploading: boolean;
230
+ uploadProgress: number;
231
+ }
232
+
233
+ interface Suggestion {
234
+ id: string;
235
+ text: string;
236
+ metadata?: Record<string, any>;
237
+ }
238
+ interface Model {
239
+ id: string;
240
+ name: string;
241
+ description: string;
242
+ parameters?: Record<string, any>;
243
+ }
244
+ interface Attachment {
245
+ id: string;
246
+ name: string;
247
+ size: number;
248
+ type: string;
249
+ url?: string;
250
+ file?: File;
251
+ }
252
+
253
+ declare const VERSION = "1.0.0";
254
+
255
+ export { type Attachment, type HanzoComponent, type HanzoContextValue, HanzoProvider, type HanzoProviderProps, type HanzoTool, type Message, type Model, type Suggestion, type Thread, type ToolCall, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseAuthOptions, type UseAuthReturn, type UseComponentOptions, type UseComponentReturn, type UseGenerativeUIOptions, type UseGenerativeUIReturn, type UseMCPOptions, type UseMCPReturn, type UseMessageOptions, type UseMessageReturn, type UseModelConfigOptions, type UseModelConfigReturn, type UseStreamingOptions, type UseStreamingReturn, type UseSuggestionsOptions, type UseSuggestionsReturn, type UseThreadOptions, type UseThreadReturn, type UseToolOptions, type UseToolReturn, VERSION, cn, generateId, parseStream, useHanzo, useMessage, useStreaming };