ai-site-pilot 0.1.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.
- package/README.md +295 -0
- package/dist/api/index.d.mts +78 -0
- package/dist/api/index.d.ts +78 -0
- package/dist/api/index.js +142 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +137 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/hooks/index.d.mts +69 -0
- package/dist/hooks/index.d.ts +69 -0
- package/dist/hooks/index.js +240 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +237 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +56 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +611 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +597 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +238 -0
- package/dist/tools/index.d.mts +71 -0
- package/dist/tools/index.d.ts +71 -0
- package/dist/tools/index.js +124 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/index.mjs +119 -0
- package/dist/tools/index.mjs.map +1 -0
- package/dist/types--7jDyUM6.d.mts +32 -0
- package/dist/types--7jDyUM6.d.ts +32 -0
- package/dist/types-DAvVRuXd.d.mts +71 -0
- package/dist/types-DAvVRuXd.d.ts +71 -0
- package/package.json +81 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/hooks/useChat.ts
|
|
4
|
+
function useChat(options) {
|
|
5
|
+
const { apiEndpoint, initialMessages = [], onToolCall, onStreamStart, onStreamEnd } = options;
|
|
6
|
+
const [messages, setMessages] = useState(initialMessages);
|
|
7
|
+
const [input, setInput] = useState("");
|
|
8
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
9
|
+
const [streamingMessageId, setStreamingMessageId] = useState(null);
|
|
10
|
+
const abortControllerRef = useRef(null);
|
|
11
|
+
const addMessage = useCallback((message) => {
|
|
12
|
+
const newMessage = {
|
|
13
|
+
...message,
|
|
14
|
+
id: Date.now().toString(),
|
|
15
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
16
|
+
};
|
|
17
|
+
setMessages((prev) => [...prev, newMessage]);
|
|
18
|
+
return newMessage;
|
|
19
|
+
}, []);
|
|
20
|
+
const clearMessages = useCallback(() => {
|
|
21
|
+
setMessages(initialMessages);
|
|
22
|
+
}, [initialMessages]);
|
|
23
|
+
const sendMessage = useCallback(
|
|
24
|
+
async (content) => {
|
|
25
|
+
const messageContent = content || input;
|
|
26
|
+
if (!messageContent.trim() || isLoading) return;
|
|
27
|
+
if (abortControllerRef.current) {
|
|
28
|
+
abortControllerRef.current.abort();
|
|
29
|
+
}
|
|
30
|
+
abortControllerRef.current = new AbortController();
|
|
31
|
+
const userMessage = {
|
|
32
|
+
id: Date.now().toString(),
|
|
33
|
+
role: "user",
|
|
34
|
+
content: messageContent,
|
|
35
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
36
|
+
};
|
|
37
|
+
setMessages((prev) => [...prev, userMessage]);
|
|
38
|
+
setInput("");
|
|
39
|
+
setIsLoading(true);
|
|
40
|
+
onStreamStart?.();
|
|
41
|
+
const assistantMessageId = (Date.now() + 1).toString();
|
|
42
|
+
const assistantMessage = {
|
|
43
|
+
id: assistantMessageId,
|
|
44
|
+
role: "assistant",
|
|
45
|
+
content: "",
|
|
46
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
47
|
+
toolCalls: []
|
|
48
|
+
};
|
|
49
|
+
setMessages((prev) => [...prev, assistantMessage]);
|
|
50
|
+
setStreamingMessageId(assistantMessageId);
|
|
51
|
+
let fullText = "";
|
|
52
|
+
const toolCalls = [];
|
|
53
|
+
try {
|
|
54
|
+
const apiMessages = messages.concat(userMessage).map((m) => ({
|
|
55
|
+
role: m.role,
|
|
56
|
+
content: m.content
|
|
57
|
+
}));
|
|
58
|
+
const response = await fetch(apiEndpoint, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { "Content-Type": "application/json" },
|
|
61
|
+
body: JSON.stringify({ messages: apiMessages }),
|
|
62
|
+
signal: abortControllerRef.current.signal
|
|
63
|
+
});
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw new Error("Failed to get response");
|
|
66
|
+
}
|
|
67
|
+
const reader = response.body?.getReader();
|
|
68
|
+
if (!reader) throw new Error("No reader available");
|
|
69
|
+
const decoder = new TextDecoder();
|
|
70
|
+
while (true) {
|
|
71
|
+
const { done, value } = await reader.read();
|
|
72
|
+
if (done) break;
|
|
73
|
+
const text = decoder.decode(value);
|
|
74
|
+
const lines = text.split("\n");
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
if (line.startsWith("data: ")) {
|
|
77
|
+
try {
|
|
78
|
+
const data = JSON.parse(line.slice(6));
|
|
79
|
+
if (data.type === "text") {
|
|
80
|
+
fullText += data.content;
|
|
81
|
+
setMessages(
|
|
82
|
+
(prev) => prev.map(
|
|
83
|
+
(m) => m.id === assistantMessageId ? { ...m, content: fullText } : m
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
} else if (data.type === "tool") {
|
|
87
|
+
const toolCall = { name: data.name, args: data.args };
|
|
88
|
+
toolCalls.push(toolCall);
|
|
89
|
+
if (onToolCall) {
|
|
90
|
+
try {
|
|
91
|
+
await onToolCall(data.name, data.args);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.error("Tool execution error:", e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} else if (data.type === "done") {
|
|
97
|
+
if (toolCalls.length > 0) {
|
|
98
|
+
setMessages(
|
|
99
|
+
(prev) => prev.map(
|
|
100
|
+
(m) => m.id === assistantMessageId ? { ...m, toolCalls } : m
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (!fullText) {
|
|
105
|
+
setMessages(
|
|
106
|
+
(prev) => prev.map(
|
|
107
|
+
(m) => m.id === assistantMessageId ? { ...m, content: "I've made some changes. Take a look!" } : m
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
} else if (data.type === "error") {
|
|
112
|
+
throw new Error(data.message);
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
console.error("Chat error:", error);
|
|
124
|
+
setMessages(
|
|
125
|
+
(prev) => prev.map(
|
|
126
|
+
(m) => m.id === assistantMessageId ? { ...m, content: "Sorry, I encountered an error. Please try again." } : m
|
|
127
|
+
)
|
|
128
|
+
);
|
|
129
|
+
} finally {
|
|
130
|
+
setIsLoading(false);
|
|
131
|
+
setStreamingMessageId(null);
|
|
132
|
+
onStreamEnd?.();
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
[apiEndpoint, input, isLoading, messages, onToolCall, onStreamStart, onStreamEnd]
|
|
136
|
+
);
|
|
137
|
+
return {
|
|
138
|
+
messages,
|
|
139
|
+
input,
|
|
140
|
+
setInput,
|
|
141
|
+
isLoading,
|
|
142
|
+
streamingMessageId,
|
|
143
|
+
sendMessage,
|
|
144
|
+
clearMessages,
|
|
145
|
+
addMessage
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function useSpeech(options = {}) {
|
|
149
|
+
const { lang = "en-US", onResult } = options;
|
|
150
|
+
const [isSupported, setIsSupported] = useState(false);
|
|
151
|
+
const [isListening, setIsListening] = useState(false);
|
|
152
|
+
const [ttsEnabled, setTtsEnabled] = useState(false);
|
|
153
|
+
const recognitionRef = useRef(null);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (typeof window === "undefined") return;
|
|
156
|
+
const windowWithSpeech = window;
|
|
157
|
+
const SpeechRecognitionAPI = windowWithSpeech.SpeechRecognition || windowWithSpeech.webkitSpeechRecognition;
|
|
158
|
+
if (SpeechRecognitionAPI) {
|
|
159
|
+
setIsSupported(true);
|
|
160
|
+
recognitionRef.current = new SpeechRecognitionAPI();
|
|
161
|
+
recognitionRef.current.continuous = false;
|
|
162
|
+
recognitionRef.current.interimResults = true;
|
|
163
|
+
recognitionRef.current.lang = lang;
|
|
164
|
+
recognitionRef.current.onresult = (event) => {
|
|
165
|
+
const result = event.results[0];
|
|
166
|
+
const transcript = result[0].transcript;
|
|
167
|
+
onResult?.(transcript, result.isFinal);
|
|
168
|
+
if (result.isFinal) {
|
|
169
|
+
setIsListening(false);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
recognitionRef.current.onend = () => setIsListening(false);
|
|
173
|
+
recognitionRef.current.onerror = () => setIsListening(false);
|
|
174
|
+
}
|
|
175
|
+
}, [lang, onResult]);
|
|
176
|
+
const startListening = useCallback(() => {
|
|
177
|
+
if (!recognitionRef.current) return;
|
|
178
|
+
try {
|
|
179
|
+
recognitionRef.current.start();
|
|
180
|
+
setIsListening(true);
|
|
181
|
+
} catch (e) {
|
|
182
|
+
console.error("Speech recognition error:", e);
|
|
183
|
+
}
|
|
184
|
+
}, []);
|
|
185
|
+
const stopListening = useCallback(() => {
|
|
186
|
+
if (!recognitionRef.current) return;
|
|
187
|
+
recognitionRef.current.stop();
|
|
188
|
+
setIsListening(false);
|
|
189
|
+
}, []);
|
|
190
|
+
const toggleListening = useCallback(() => {
|
|
191
|
+
if (isListening) {
|
|
192
|
+
stopListening();
|
|
193
|
+
} else {
|
|
194
|
+
startListening();
|
|
195
|
+
}
|
|
196
|
+
}, [isListening, startListening, stopListening]);
|
|
197
|
+
const speak = useCallback(
|
|
198
|
+
(text) => {
|
|
199
|
+
if (!ttsEnabled || typeof window === "undefined" || !("speechSynthesis" in window)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
speechSynthesis.cancel();
|
|
203
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
|
204
|
+
utterance.rate = 1;
|
|
205
|
+
utterance.pitch = 1;
|
|
206
|
+
const voices = speechSynthesis.getVoices();
|
|
207
|
+
const preferredVoice = voices.find(
|
|
208
|
+
(v) => v.name.includes("Google") || v.name.includes("Samantha") || v.name.includes("Alex")
|
|
209
|
+
);
|
|
210
|
+
if (preferredVoice) {
|
|
211
|
+
utterance.voice = preferredVoice;
|
|
212
|
+
}
|
|
213
|
+
speechSynthesis.speak(utterance);
|
|
214
|
+
},
|
|
215
|
+
[ttsEnabled]
|
|
216
|
+
);
|
|
217
|
+
const cancelSpeech = useCallback(() => {
|
|
218
|
+
if (typeof window !== "undefined" && "speechSynthesis" in window) {
|
|
219
|
+
speechSynthesis.cancel();
|
|
220
|
+
}
|
|
221
|
+
}, []);
|
|
222
|
+
return {
|
|
223
|
+
isSupported,
|
|
224
|
+
isListening,
|
|
225
|
+
toggleListening,
|
|
226
|
+
startListening,
|
|
227
|
+
stopListening,
|
|
228
|
+
speak,
|
|
229
|
+
ttsEnabled,
|
|
230
|
+
setTtsEnabled,
|
|
231
|
+
cancelSpeech
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { useChat, useSpeech };
|
|
236
|
+
//# sourceMappingURL=index.mjs.map
|
|
237
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useChat.ts","../../src/hooks/useSpeech.ts"],"names":["useState","useRef","useCallback"],"mappings":";;;AAwCO,SAAS,QAAQ,OAAA,EAAwC;AAC9D,EAAA,MAAM,EAAE,aAAa,eAAA,GAAkB,IAAI,UAAA,EAAY,aAAA,EAAe,aAAY,GAAI,OAAA;AAEtF,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAwB,eAAe,CAAA;AACvE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,EAAE,CAAA;AACrC,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAA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,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO;AAAA,IACL,WAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,cAAA;AAAA,IACA,aAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.mjs","sourcesContent":["'use client';\n\nimport { useState, useCallback, useRef } from 'react';\nimport type { ChatMessage, ToolExecution, StreamEvent } from '../types';\n\nexport interface UseChatOptions {\n /** API endpoint for chat */\n apiEndpoint: string;\n /** Initial messages */\n initialMessages?: ChatMessage[];\n /** Callback when a tool is called */\n onToolCall?: (toolName: string, args: Record<string, unknown>) => void | Promise<void>;\n /** Callback when streaming starts */\n onStreamStart?: () => void;\n /** Callback when streaming ends */\n onStreamEnd?: () => void;\n}\n\nexport interface UseChatReturn {\n /** All messages in the conversation */\n messages: ChatMessage[];\n /** Current input value */\n input: string;\n /** Set the input value */\n setInput: (value: string) => void;\n /** Whether the assistant is currently responding */\n isLoading: boolean;\n /** ID of the currently streaming message */\n streamingMessageId: string | null;\n /** Send a message */\n sendMessage: (content?: string) => Promise<void>;\n /** Clear all messages */\n clearMessages: () => void;\n /** Add a message manually */\n addMessage: (message: Omit<ChatMessage, 'id' | 'timestamp'>) => void;\n}\n\n/**\n * Hook for managing chat state and streaming\n */\nexport function useChat(options: UseChatOptions): UseChatReturn {\n const { apiEndpoint, initialMessages = [], onToolCall, onStreamStart, onStreamEnd } = options;\n\n const [messages, setMessages] = useState<ChatMessage[]>(initialMessages);\n const [input, setInput] = useState('');\n const [isLoading, setIsLoading] = useState(false);\n const [streamingMessageId, setStreamingMessageId] = useState<string | null>(null);\n\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const addMessage = useCallback((message: Omit<ChatMessage, 'id' | 'timestamp'>) => {\n const newMessage: ChatMessage = {\n ...message,\n id: Date.now().toString(),\n timestamp: new Date(),\n };\n setMessages((prev) => [...prev, newMessage]);\n return newMessage;\n }, []);\n\n const clearMessages = useCallback(() => {\n setMessages(initialMessages);\n }, [initialMessages]);\n\n const sendMessage = useCallback(\n async (content?: string) => {\n const messageContent = content || input;\n if (!messageContent.trim() || isLoading) return;\n\n // Cancel any ongoing request\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n abortControllerRef.current = new AbortController();\n\n // Add user message\n const userMessage: ChatMessage = {\n id: Date.now().toString(),\n role: 'user',\n content: messageContent,\n timestamp: new Date(),\n };\n setMessages((prev) => [...prev, userMessage]);\n setInput('');\n setIsLoading(true);\n onStreamStart?.();\n\n // Add placeholder for assistant message\n const assistantMessageId = (Date.now() + 1).toString();\n const assistantMessage: ChatMessage = {\n id: assistantMessageId,\n role: 'assistant',\n content: '',\n timestamp: new Date(),\n toolCalls: [],\n };\n setMessages((prev) => [...prev, assistantMessage]);\n setStreamingMessageId(assistantMessageId);\n\n let fullText = '';\n const toolCalls: ToolExecution[] = [];\n\n try {\n // Prepare messages for API (convert to format expected by API)\n const apiMessages = messages.concat(userMessage).map((m) => ({\n role: m.role,\n content: m.content,\n }));\n\n const response = await fetch(apiEndpoint, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ messages: apiMessages }),\n signal: abortControllerRef.current.signal,\n });\n\n if (!response.ok) {\n throw new Error('Failed to get response');\n }\n\n const reader = response.body?.getReader();\n if (!reader) throw new Error('No reader available');\n\n const decoder = new TextDecoder();\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n const text = decoder.decode(value);\n const lines = text.split('\\n');\n\n for (const line of lines) {\n if (line.startsWith('data: ')) {\n try {\n const data = JSON.parse(line.slice(6)) as StreamEvent;\n\n if (data.type === 'text') {\n fullText += data.content;\n setMessages((prev) =>\n prev.map((m) =>\n m.id === assistantMessageId ? { ...m, content: fullText } : m\n )\n );\n } else if (data.type === 'tool') {\n const toolCall = { name: data.name, args: data.args };\n toolCalls.push(toolCall);\n\n // Execute tool call callback\n if (onToolCall) {\n try {\n await onToolCall(data.name, data.args);\n } catch (e) {\n console.error('Tool execution error:', e);\n }\n }\n } else if (data.type === 'done') {\n // Update message with tool calls\n if (toolCalls.length > 0) {\n setMessages((prev) =>\n prev.map((m) =>\n m.id === assistantMessageId ? { ...m, toolCalls } : m\n )\n );\n }\n\n // If no text, show default message\n if (!fullText) {\n setMessages((prev) =>\n prev.map((m) =>\n m.id === assistantMessageId\n ? { ...m, content: \"I've made some changes. Take a look!\" }\n : m\n )\n );\n }\n } else if (data.type === 'error') {\n throw new Error(data.message);\n }\n } catch {\n // Skip invalid JSON lines\n }\n }\n }\n }\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n // Request was cancelled, ignore\n return;\n }\n\n console.error('Chat error:', error);\n setMessages((prev) =>\n prev.map((m) =>\n m.id === assistantMessageId\n ? { ...m, content: 'Sorry, I encountered an error. Please try again.' }\n : m\n )\n );\n } finally {\n setIsLoading(false);\n setStreamingMessageId(null);\n onStreamEnd?.();\n }\n },\n [apiEndpoint, input, isLoading, messages, onToolCall, onStreamStart, onStreamEnd]\n );\n\n return {\n messages,\n input,\n setInput,\n isLoading,\n streamingMessageId,\n sendMessage,\n clearMessages,\n addMessage,\n };\n}\n","'use client';\n\nimport { useState, useRef, useEffect, useCallback } from 'react';\n\n// Web Speech API types\ninterface SpeechRecognitionEvent extends Event {\n results: SpeechRecognitionResultList;\n}\n\ninterface SpeechRecognitionInstance {\n continuous: boolean;\n interimResults: boolean;\n lang: string;\n start(): void;\n stop(): void;\n onresult: ((event: SpeechRecognitionEvent) => void) | null;\n onend: (() => void) | null;\n onerror: (() => void) | null;\n}\n\nexport interface UseSpeechOptions {\n /** Language for speech recognition */\n lang?: string;\n /** Callback when speech is recognized */\n onResult?: (transcript: string, isFinal: boolean) => void;\n}\n\nexport interface UseSpeechReturn {\n /** Whether speech recognition is supported */\n isSupported: boolean;\n /** Whether currently listening */\n isListening: boolean;\n /** Toggle listening on/off */\n toggleListening: () => void;\n /** Start listening */\n startListening: () => void;\n /** Stop listening */\n stopListening: () => void;\n /** Speak text using TTS */\n speak: (text: string) => void;\n /** Whether TTS is enabled */\n ttsEnabled: boolean;\n /** Toggle TTS on/off */\n setTtsEnabled: (enabled: boolean) => void;\n /** Cancel current speech */\n cancelSpeech: () => void;\n}\n\n/**\n * Hook for speech recognition and text-to-speech\n */\nexport function useSpeech(options: UseSpeechOptions = {}): UseSpeechReturn {\n const { lang = 'en-US', onResult } = options;\n\n const [isSupported, setIsSupported] = useState(false);\n const [isListening, setIsListening] = useState(false);\n const [ttsEnabled, setTtsEnabled] = useState(false);\n\n const recognitionRef = useRef<SpeechRecognitionInstance | null>(null);\n\n // Initialize speech recognition\n useEffect(() => {\n if (typeof window === 'undefined') return;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const windowWithSpeech = window as any;\n const SpeechRecognitionAPI =\n windowWithSpeech.SpeechRecognition || windowWithSpeech.webkitSpeechRecognition;\n\n if (SpeechRecognitionAPI) {\n setIsSupported(true);\n recognitionRef.current = new SpeechRecognitionAPI() as SpeechRecognitionInstance;\n recognitionRef.current.continuous = false;\n recognitionRef.current.interimResults = true;\n recognitionRef.current.lang = lang;\n\n recognitionRef.current.onresult = (event) => {\n const result = event.results[0];\n const transcript = result[0].transcript;\n onResult?.(transcript, result.isFinal);\n\n if (result.isFinal) {\n setIsListening(false);\n }\n };\n\n recognitionRef.current.onend = () => setIsListening(false);\n recognitionRef.current.onerror = () => setIsListening(false);\n }\n }, [lang, onResult]);\n\n const startListening = useCallback(() => {\n if (!recognitionRef.current) return;\n try {\n recognitionRef.current.start();\n setIsListening(true);\n } catch (e) {\n console.error('Speech recognition error:', e);\n }\n }, []);\n\n const stopListening = useCallback(() => {\n if (!recognitionRef.current) return;\n recognitionRef.current.stop();\n setIsListening(false);\n }, []);\n\n const toggleListening = useCallback(() => {\n if (isListening) {\n stopListening();\n } else {\n startListening();\n }\n }, [isListening, startListening, stopListening]);\n\n const speak = useCallback(\n (text: string) => {\n if (!ttsEnabled || typeof window === 'undefined' || !('speechSynthesis' in window)) {\n return;\n }\n\n speechSynthesis.cancel();\n const utterance = new SpeechSynthesisUtterance(text);\n utterance.rate = 1.0;\n utterance.pitch = 1.0;\n\n // Try to find a good voice\n const voices = speechSynthesis.getVoices();\n const preferredVoice = voices.find(\n (v) => v.name.includes('Google') || v.name.includes('Samantha') || v.name.includes('Alex')\n );\n if (preferredVoice) {\n utterance.voice = preferredVoice;\n }\n\n speechSynthesis.speak(utterance);\n },\n [ttsEnabled]\n );\n\n const cancelSpeech = useCallback(() => {\n if (typeof window !== 'undefined' && 'speechSynthesis' in window) {\n speechSynthesis.cancel();\n }\n }, []);\n\n return {\n isSupported,\n isListening,\n toggleListening,\n startListening,\n stopListening,\n speak,\n ttsEnabled,\n setTtsEnabled,\n cancelSpeech,\n };\n}\n"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { a as SitePilotProps, C as ChatMessage$1, b as Suggestion } from './types-DAvVRuXd.mjs';
|
|
3
|
+
export { d as SitePilotFeatures, c as SitePilotTheme, S as StreamEvent, T as ToolExecution } from './types-DAvVRuXd.mjs';
|
|
4
|
+
export { useChat, useSpeech } from './hooks/index.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SitePilot - AI chat widget that can control and navigate your website
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { SitePilot } from 'ai-site-pilot';
|
|
12
|
+
*
|
|
13
|
+
* <SitePilot
|
|
14
|
+
* apiEndpoint="/api/chat"
|
|
15
|
+
* suggestions={[
|
|
16
|
+
* { text: 'Show me products', icon: '🛍️' },
|
|
17
|
+
* { text: 'Help me find...', icon: '🔍' },
|
|
18
|
+
* ]}
|
|
19
|
+
* onToolCall={(name, args) => {
|
|
20
|
+
* // Handle tool execution
|
|
21
|
+
* }}
|
|
22
|
+
* />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function SitePilot({ apiEndpoint, theme, suggestions, features, onToolCall, defaultOpen, placeholder, welcomeMessage, className, }: SitePilotProps): react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
interface ChatMessageProps {
|
|
28
|
+
message: ChatMessage$1;
|
|
29
|
+
isStreaming?: boolean;
|
|
30
|
+
isFullscreen?: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare function ChatMessage({ message, isStreaming, isFullscreen }: ChatMessageProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
|
|
34
|
+
interface ChatInputProps {
|
|
35
|
+
value: string;
|
|
36
|
+
onChange: (value: string) => void;
|
|
37
|
+
onSubmit: () => void;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
isListening?: boolean;
|
|
41
|
+
onToggleListening?: () => void;
|
|
42
|
+
showMic?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare function ChatInput({ value, onChange, onSubmit, disabled, placeholder, isListening, onToggleListening, showMic, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
45
|
+
|
|
46
|
+
interface SuggestionsProps {
|
|
47
|
+
suggestions: Suggestion[];
|
|
48
|
+
onSelect: (text: string) => void;
|
|
49
|
+
isVisible?: boolean;
|
|
50
|
+
isFullscreen?: boolean;
|
|
51
|
+
suggestionsToShow?: number;
|
|
52
|
+
rotationInterval?: number;
|
|
53
|
+
}
|
|
54
|
+
declare function Suggestions({ suggestions, onSelect, isVisible, isFullscreen, suggestionsToShow, rotationInterval, }: SuggestionsProps): react_jsx_runtime.JSX.Element | null;
|
|
55
|
+
|
|
56
|
+
export { ChatInput, ChatMessage, ChatMessage$1 as ChatMessageType, SitePilot, SitePilotProps, Suggestion, Suggestions, SitePilot as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { a as SitePilotProps, C as ChatMessage$1, b as Suggestion } from './types-DAvVRuXd.js';
|
|
3
|
+
export { d as SitePilotFeatures, c as SitePilotTheme, S as StreamEvent, T as ToolExecution } from './types-DAvVRuXd.js';
|
|
4
|
+
export { useChat, useSpeech } from './hooks/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* SitePilot - AI chat widget that can control and navigate your website
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { SitePilot } from 'ai-site-pilot';
|
|
12
|
+
*
|
|
13
|
+
* <SitePilot
|
|
14
|
+
* apiEndpoint="/api/chat"
|
|
15
|
+
* suggestions={[
|
|
16
|
+
* { text: 'Show me products', icon: '🛍️' },
|
|
17
|
+
* { text: 'Help me find...', icon: '🔍' },
|
|
18
|
+
* ]}
|
|
19
|
+
* onToolCall={(name, args) => {
|
|
20
|
+
* // Handle tool execution
|
|
21
|
+
* }}
|
|
22
|
+
* />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function SitePilot({ apiEndpoint, theme, suggestions, features, onToolCall, defaultOpen, placeholder, welcomeMessage, className, }: SitePilotProps): react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
interface ChatMessageProps {
|
|
28
|
+
message: ChatMessage$1;
|
|
29
|
+
isStreaming?: boolean;
|
|
30
|
+
isFullscreen?: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare function ChatMessage({ message, isStreaming, isFullscreen }: ChatMessageProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
|
|
34
|
+
interface ChatInputProps {
|
|
35
|
+
value: string;
|
|
36
|
+
onChange: (value: string) => void;
|
|
37
|
+
onSubmit: () => void;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
placeholder?: string;
|
|
40
|
+
isListening?: boolean;
|
|
41
|
+
onToggleListening?: () => void;
|
|
42
|
+
showMic?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare function ChatInput({ value, onChange, onSubmit, disabled, placeholder, isListening, onToggleListening, showMic, }: ChatInputProps): react_jsx_runtime.JSX.Element;
|
|
45
|
+
|
|
46
|
+
interface SuggestionsProps {
|
|
47
|
+
suggestions: Suggestion[];
|
|
48
|
+
onSelect: (text: string) => void;
|
|
49
|
+
isVisible?: boolean;
|
|
50
|
+
isFullscreen?: boolean;
|
|
51
|
+
suggestionsToShow?: number;
|
|
52
|
+
rotationInterval?: number;
|
|
53
|
+
}
|
|
54
|
+
declare function Suggestions({ suggestions, onSelect, isVisible, isFullscreen, suggestionsToShow, rotationInterval, }: SuggestionsProps): react_jsx_runtime.JSX.Element | null;
|
|
55
|
+
|
|
56
|
+
export { ChatInput, ChatMessage, ChatMessage$1 as ChatMessageType, SitePilot, SitePilotProps, Suggestion, Suggestions, SitePilot as default };
|