@navsi.ai/sdk 1.0.0 → 1.0.1
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 +15 -15
- package/package.json +7 -5
- package/dist/chunk-427NHGTX.js +0 -3
- package/dist/chunk-427NHGTX.js.map +0 -1
- package/dist/chunk-6FUUG5WB.js +0 -77
- package/dist/chunk-6FUUG5WB.js.map +0 -1
- package/dist/chunk-EHZXIZIP.js +0 -3752
- package/dist/chunk-EHZXIZIP.js.map +0 -1
- package/dist/components/index.d.ts +0 -66
- package/dist/components/index.js +0 -4
- package/dist/components/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -104
- package/dist/hooks/index.js +0 -4
- package/dist/hooks/index.js.map +0 -1
- package/dist/index.d.ts +0 -286
- package/dist/index.js +0 -182
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @navsi/sdk - Navsi AI Chatbot SDK
|
|
1
|
+
# @navsi.ai/sdk - Navsi AI Chatbot SDK
|
|
2
2
|
|
|
3
3
|
AI-powered chatbot SDK for websites with Ask & Navigate modes.
|
|
4
4
|
|
|
@@ -7,11 +7,11 @@ AI-powered chatbot SDK for websites with Ask & Navigate modes.
|
|
|
7
7
|
## Installation (for external users)
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @navsi/sdk
|
|
10
|
+
npm install @navsi.ai/sdk
|
|
11
11
|
# or
|
|
12
|
-
yarn add @navsi/sdk
|
|
12
|
+
yarn add @navsi.ai/sdk
|
|
13
13
|
# or
|
|
14
|
-
pnpm add @navsi/sdk
|
|
14
|
+
pnpm add @navsi.ai/sdk
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
For **Next.js** projects, ensure `next` is installed (optional peer dependency):
|
|
@@ -20,7 +20,7 @@ For **Next.js** projects, ensure `next` is installed (optional peer dependency):
|
|
|
20
20
|
## Quick Start
|
|
21
21
|
|
|
22
22
|
```tsx
|
|
23
|
-
import { ChatbotProvider, ChatbotWidget } from '@navsi/sdk';
|
|
23
|
+
import { ChatbotProvider, ChatbotWidget } from '@navsi.ai/sdk';
|
|
24
24
|
|
|
25
25
|
function App() {
|
|
26
26
|
return (
|
|
@@ -41,8 +41,8 @@ For a complete setup with widget configuration from your server:
|
|
|
41
41
|
|
|
42
42
|
```tsx
|
|
43
43
|
import React, { useState, useEffect } from 'react';
|
|
44
|
-
import { ChatbotProvider, ChatbotWidget } from '@navsi/sdk';
|
|
45
|
-
import type { FlatWidgetConfig } from '@navsi/shared';
|
|
44
|
+
import { ChatbotProvider, ChatbotWidget } from '@navsi.ai/sdk';
|
|
45
|
+
import type { FlatWidgetConfig } from '@navsi.ai/shared';
|
|
46
46
|
|
|
47
47
|
function App() {
|
|
48
48
|
const [widgetConfig, setWidgetConfig] = useState<FlatWidgetConfig | null>(null);
|
|
@@ -97,7 +97,7 @@ function App() {
|
|
|
97
97
|
Use a **Client Component** to wrap your app with the chatbot and provide a Next.js navigation adapter so the AI can navigate between pages:
|
|
98
98
|
|
|
99
99
|
1. Create a client component (e.g. `app/ClientProviders.tsx`) with `'use client'` at the top.
|
|
100
|
-
2. Use `useRouter()` and `usePathname()` from `next/navigation`, and `useNextRouterAdapter(router, pathname)` from `@navsi/sdk`.
|
|
100
|
+
2. Use `useRouter()` and `usePathname()` from `next/navigation`, and `useNextRouterAdapter(router, pathname)` from `@navsi.ai/sdk`.
|
|
101
101
|
3. Wrap your app in `ChatbotProvider` (with `navigationAdapter`) and render `ChatbotWidget`.
|
|
102
102
|
4. Set `NEXT_PUBLIC_NAVSI_API_KEY` and `NEXT_PUBLIC_NAVSI_API_URL` in `.env.local` (WebSocket URL is derived from the API URL).
|
|
103
103
|
|
|
@@ -106,7 +106,7 @@ Use a **Client Component** to wrap your app with the chatbot and provide a Next.
|
|
|
106
106
|
'use client';
|
|
107
107
|
|
|
108
108
|
import { useRouter, usePathname } from 'next/navigation';
|
|
109
|
-
import { ChatbotProvider, ChatbotWidget, useNextRouterAdapter } from '@navsi/sdk';
|
|
109
|
+
import { ChatbotProvider, ChatbotWidget, useNextRouterAdapter } from '@navsi.ai/sdk';
|
|
110
110
|
|
|
111
111
|
function getWebSocketUrl(httpUrl: string): string {
|
|
112
112
|
const url = new URL(httpUrl);
|
|
@@ -250,7 +250,7 @@ const serverActions = [
|
|
|
250
250
|
Access chatbot state and controls:
|
|
251
251
|
|
|
252
252
|
```tsx
|
|
253
|
-
import { useChatbot } from '@navsi/sdk';
|
|
253
|
+
import { useChatbot } from '@navsi.ai/sdk';
|
|
254
254
|
|
|
255
255
|
function MyComponent() {
|
|
256
256
|
const {
|
|
@@ -268,7 +268,7 @@ function MyComponent() {
|
|
|
268
268
|
Access WebSocket connection state:
|
|
269
269
|
|
|
270
270
|
```tsx
|
|
271
|
-
import { useWebSocket } from '@navsi/sdk';
|
|
271
|
+
import { useWebSocket } from '@navsi.ai/sdk';
|
|
272
272
|
|
|
273
273
|
function ConnectionStatus() {
|
|
274
274
|
const { isConnected, isReconnecting } = useWebSocket();
|
|
@@ -282,7 +282,7 @@ function ConnectionStatus() {
|
|
|
282
282
|
Track action execution progress:
|
|
283
283
|
|
|
284
284
|
```tsx
|
|
285
|
-
import { useActionExecution } from '@navsi/sdk';
|
|
285
|
+
import { useActionExecution } from '@navsi.ai/sdk';
|
|
286
286
|
|
|
287
287
|
function ProgressBar() {
|
|
288
288
|
const { progress } = useActionExecution();
|
|
@@ -338,9 +338,9 @@ NEXT_PUBLIC_NAVSI_API_URL=https://api.example.com
|
|
|
338
338
|
|
|
339
339
|
```bash
|
|
340
340
|
# From monorepo root
|
|
341
|
-
pnpm --filter @navsi/sdk dev # Watch mode
|
|
342
|
-
pnpm --filter @navsi/sdk build # Build
|
|
343
|
-
pnpm --filter @navsi/sdk lint # Lint
|
|
341
|
+
pnpm --filter @navsi.ai/sdk dev # Watch mode
|
|
342
|
+
pnpm --filter @navsi.ai/sdk build # Build
|
|
343
|
+
pnpm --filter @navsi.ai/sdk lint # Lint
|
|
344
344
|
```
|
|
345
345
|
|
|
346
346
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navsi.ai/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "React SDK for Navsi AI chatbot - Ask and Navigate modes",
|
|
5
5
|
"author": "Kushagra Tiwari",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/Bolona-ai/
|
|
12
|
-
"directory": "
|
|
11
|
+
"url": "https://github.com/Bolona-ai/navsi-packages.git",
|
|
12
|
+
"directory": "sdk"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"navsi",
|
|
@@ -37,7 +37,9 @@
|
|
|
37
37
|
"import": "./dist/hooks/index.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"files": [
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
41
43
|
"scripts": {
|
|
42
44
|
"build": "tsup",
|
|
43
45
|
"dev": "tsup --watch",
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
"typecheck": "tsc --noEmit"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
|
-
"@navsi.ai/shared": "^1.0.
|
|
51
|
+
"@navsi.ai/shared": "^1.0.1"
|
|
50
52
|
},
|
|
51
53
|
"peerDependencies": {
|
|
52
54
|
"react": ">=18.0.0",
|
package/dist/chunk-427NHGTX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-427NHGTX.js"}
|
package/dist/chunk-6FUUG5WB.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
// src/context/chatbot-context.tsx
|
|
4
|
-
var ChatbotContext = createContext(null);
|
|
5
|
-
function useChatbotContext() {
|
|
6
|
-
const context = useContext(ChatbotContext);
|
|
7
|
-
if (!context) {
|
|
8
|
-
throw new Error("useChatbotContext must be used within a ChatbotProvider");
|
|
9
|
-
}
|
|
10
|
-
return context;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// src/hooks/useChatbot.ts
|
|
14
|
-
function useChatbot() {
|
|
15
|
-
const context = useChatbotContext();
|
|
16
|
-
return {
|
|
17
|
-
widgetConfig: context.widgetConfig,
|
|
18
|
-
voiceLanguage: context.voiceLanguage,
|
|
19
|
-
setVoiceLanguage: context.setVoiceLanguage,
|
|
20
|
-
// Messages
|
|
21
|
-
messages: context.messages,
|
|
22
|
-
sendMessage: context.sendMessage,
|
|
23
|
-
clearMessages: context.clearMessages,
|
|
24
|
-
// Mode
|
|
25
|
-
mode: context.mode,
|
|
26
|
-
setMode: context.setMode,
|
|
27
|
-
// Widget visibility
|
|
28
|
-
isWidgetOpen: context.isWidgetOpen,
|
|
29
|
-
setWidgetOpen: context.setWidgetOpen,
|
|
30
|
-
// Connection
|
|
31
|
-
isConnected: context.isConnected,
|
|
32
|
-
connect: context.connect,
|
|
33
|
-
disconnect: context.disconnect,
|
|
34
|
-
// Actions
|
|
35
|
-
executeAction: context.executeAction,
|
|
36
|
-
registerServerAction: context.registerServerAction,
|
|
37
|
-
stopExecution: context.stopExecution,
|
|
38
|
-
// State
|
|
39
|
-
isExecuting: context.isExecuting,
|
|
40
|
-
error: context.error,
|
|
41
|
-
clearError: context.clearError
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// src/hooks/useActionExecution.ts
|
|
46
|
-
function useActionExecution() {
|
|
47
|
-
const context = useChatbotContext();
|
|
48
|
-
const progress = context.executionState ? {
|
|
49
|
-
current: context.executionState.currentIndex,
|
|
50
|
-
total: context.executionState.totalCommands,
|
|
51
|
-
percentage: context.executionState.totalCommands > 0 ? Math.round(context.executionState.currentIndex / context.executionState.totalCommands * 100) : 0,
|
|
52
|
-
description: context.executionState.description
|
|
53
|
-
} : null;
|
|
54
|
-
return {
|
|
55
|
-
isExecuting: context.isExecuting,
|
|
56
|
-
executionState: context.executionState,
|
|
57
|
-
currentCommand: context.executionState?.currentCommand,
|
|
58
|
-
progress
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// src/hooks/useWebSocket.ts
|
|
63
|
-
function useWebSocket() {
|
|
64
|
-
const context = useChatbotContext();
|
|
65
|
-
return {
|
|
66
|
-
connectionState: context.connectionState,
|
|
67
|
-
isConnected: context.connectionState === "connected",
|
|
68
|
-
isConnecting: context.connectionState === "connecting",
|
|
69
|
-
isReconnecting: context.connectionState === "reconnecting",
|
|
70
|
-
connect: context.connect,
|
|
71
|
-
disconnect: context.disconnect
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { ChatbotContext, useActionExecution, useChatbot, useChatbotContext, useWebSocket };
|
|
76
|
-
//# sourceMappingURL=chunk-6FUUG5WB.js.map
|
|
77
|
-
//# sourceMappingURL=chunk-6FUUG5WB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context/chatbot-context.tsx","../src/hooks/useChatbot.ts","../src/hooks/useActionExecution.ts","../src/hooks/useWebSocket.ts"],"names":[],"mappings":";;;AA2DO,IAAM,cAAA,GAAiB,cAA0C,IAAI;AAUrE,SAAS,iBAAA,GAAyC;AACrD,EAAA,MAAM,OAAA,GAAU,WAAW,cAAc,CAAA;AAEzC,EAAA,IAAI,CAAC,OAAA,EAAS;AACV,IAAA,MAAM,IAAI,MAAM,yDAAyD,CAAA;AAAA,EAC7E;AAEA,EAAA,OAAO,OAAA;AACX;;;ACHO,SAAS,UAAA,GAA+B;AAC3C,EAAA,MAAM,UAAU,iBAAA,EAAkB;AAElC,EAAA,OAAO;AAAA,IACH,cAAc,OAAA,CAAQ,YAAA;AAAA,IACtB,eAAe,OAAA,CAAQ,aAAA;AAAA,IACvB,kBAAkB,OAAA,CAAQ,gBAAA;AAAA;AAAA,IAE1B,UAAU,OAAA,CAAQ,QAAA;AAAA,IAClB,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,eAAe,OAAA,CAAQ,aAAA;AAAA;AAAA,IAGvB,MAAM,OAAA,CAAQ,IAAA;AAAA,IACd,SAAS,OAAA,CAAQ,OAAA;AAAA;AAAA,IAGjB,cAAc,OAAA,CAAQ,YAAA;AAAA,IACtB,eAAe,OAAA,CAAQ,aAAA;AAAA;AAAA,IAGvB,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,SAAS,OAAA,CAAQ,OAAA;AAAA,IACjB,YAAY,OAAA,CAAQ,UAAA;AAAA;AAAA,IAGpB,eAAe,OAAA,CAAQ,aAAA;AAAA,IACvB,sBAAsB,OAAA,CAAQ,oBAAA;AAAA,IAC9B,eAAe,OAAA,CAAQ,aAAA;AAAA;AAAA,IAGvB,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,OAAO,OAAA,CAAQ,KAAA;AAAA,IACf,YAAY,OAAA,CAAQ;AAAA,GACxB;AACJ;;;ACpFO,SAAS,kBAAA,GAA+C;AAC3D,EAAA,MAAM,UAAU,iBAAA,EAAkB;AAElC,EAAA,MAAM,QAAA,GAAW,QAAQ,cAAA,GACnB;AAAA,IACE,OAAA,EAAS,QAAQ,cAAA,CAAe,YAAA;AAAA,IAChC,KAAA,EAAO,QAAQ,cAAA,CAAe,aAAA;AAAA,IAC9B,UAAA,EAAY,OAAA,CAAQ,cAAA,CAAe,aAAA,GAAgB,IAC7C,IAAA,CAAK,KAAA,CAAO,OAAA,CAAQ,cAAA,CAAe,YAAA,GAAe,OAAA,CAAQ,cAAA,CAAe,aAAA,GAAiB,GAAG,CAAA,GAC7F,CAAA;AAAA,IACN,WAAA,EAAa,QAAQ,cAAA,CAAe;AAAA,GACxC,GACE,IAAA;AAEN,EAAA,OAAO;AAAA,IACH,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,gBAAgB,OAAA,CAAQ,cAAA;AAAA,IACxB,cAAA,EAAgB,QAAQ,cAAA,EAAgB,cAAA;AAAA,IACxC;AAAA,GACJ;AACJ;;;ACxBO,SAAS,YAAA,GAAmC;AAC/C,EAAA,MAAM,UAAU,iBAAA,EAAkB;AAElC,EAAA,OAAO;AAAA,IACH,iBAAiB,OAAA,CAAQ,eAAA;AAAA,IACzB,WAAA,EAAa,QAAQ,eAAA,KAAoB,WAAA;AAAA,IACzC,YAAA,EAAc,QAAQ,eAAA,KAAoB,YAAA;AAAA,IAC1C,cAAA,EAAgB,QAAQ,eAAA,KAAoB,cAAA;AAAA,IAC5C,SAAS,OAAA,CAAQ,OAAA;AAAA,IACjB,YAAY,OAAA,CAAQ;AAAA,GACxB;AACJ","file":"chunk-6FUUG5WB.js","sourcesContent":["/**\n * Chatbot Context\n * \n * React context for chatbot state and functionality.\n */\n\nimport { createContext, useContext } from 'react';\nimport type {\n Message,\n ChatMode,\n ConnectionState,\n ServerAction,\n ExecutionState,\n WidgetConfig,\n} from '@navsi.ai/shared';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface ChatbotContextValue {\n /** Widget styling and copy (from admin / API). Applied by ChatbotWidget. */\n widgetConfig: Partial<WidgetConfig> | null;\n\n // State\n messages: Message[];\n mode: ChatMode;\n connectionState: ConnectionState;\n isExecuting: boolean;\n executionState: ExecutionState | null;\n error: Error | null;\n\n // Widget visibility (persists across navigation)\n isWidgetOpen: boolean;\n setWidgetOpen: (open: boolean) => void;\n\n /** User-selected voice/response language (e.g. 'en-US', 'hi-IN'). Overrides widgetConfig.voiceLanguage when set. */\n voiceLanguage: string | undefined;\n setVoiceLanguage: (lang: string | undefined) => void;\n\n // Actions\n sendMessage: (content: string) => void;\n setMode: (mode: ChatMode) => void;\n executeAction: (actionId: string, params?: Record<string, unknown>) => Promise<unknown>;\n registerServerAction: (action: ServerAction) => void;\n clearMessages: () => void;\n clearError: () => void;\n stopExecution: () => void;\n\n // Connection\n connect: () => void;\n disconnect: () => void;\n isConnected: boolean;\n}\n\n// ============================================================================\n// Context\n// ============================================================================\n\nexport const ChatbotContext = createContext<ChatbotContextValue | null>(null);\n\n// ============================================================================\n// Hook\n// ============================================================================\n\n/**\n * Hook to access chatbot context\n * Must be used within ChatbotProvider\n */\nexport function useChatbotContext(): ChatbotContextValue {\n const context = useContext(ChatbotContext);\n\n if (!context) {\n throw new Error('useChatbotContext must be used within a ChatbotProvider');\n }\n\n return context;\n}\n","/**\n * useChatbot Hook\n * \n * Main hook for accessing chatbot functionality.\n * Provides simplified API for common operations.\n */\n\nimport { useChatbotContext } from '../context/chatbot-context.js';\nimport type { ChatMode, ServerAction, Message, WidgetConfig } from '@navsi.ai/shared';\n\nexport interface UseChatbotReturn {\n /** Widget styling/copy from admin (or options). Use in ChatbotWidget. */\n widgetConfig: Partial<WidgetConfig> | null;\n\n /** Effective voice/response language (user-selected or config). Use for STT/TTS and locale. */\n voiceLanguage: string | undefined;\n setVoiceLanguage: (lang: string | undefined) => void;\n\n // Messages\n messages: Message[];\n sendMessage: (content: string) => void;\n clearMessages: () => void;\n\n // Mode\n mode: ChatMode;\n setMode: (mode: ChatMode) => void;\n\n // Widget visibility (persists across navigation)\n isWidgetOpen: boolean;\n setWidgetOpen: (open: boolean) => void;\n\n // Connection\n isConnected: boolean;\n connect: () => void;\n disconnect: () => void;\n\n // Actions\n executeAction: (actionId: string, params?: Record<string, unknown>) => Promise<unknown>;\n registerServerAction: (action: ServerAction) => void;\n stopExecution: () => void;\n\n // State\n isExecuting: boolean;\n error: Error | null;\n clearError: () => void;\n}\n\n/**\n * Main hook for chatbot functionality\n * \n * @example\n * ```tsx\n * function MyComponent() {\n * const { \n * messages, \n * sendMessage, \n * isConnected,\n * mode,\n * setMode,\n * } = useChatbot();\n * \n * return (\n * <div>\n * <button onClick={() => sendMessage('Hello!')}>\n * Send\n * </button>\n * <button onClick={() => startVoice()}>\n * Start Voice\n * </button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useChatbot(): UseChatbotReturn {\n const context = useChatbotContext();\n\n return {\n widgetConfig: context.widgetConfig,\n voiceLanguage: context.voiceLanguage,\n setVoiceLanguage: context.setVoiceLanguage,\n // Messages\n messages: context.messages,\n sendMessage: context.sendMessage,\n clearMessages: context.clearMessages,\n\n // Mode\n mode: context.mode,\n setMode: context.setMode,\n\n // Widget visibility\n isWidgetOpen: context.isWidgetOpen,\n setWidgetOpen: context.setWidgetOpen,\n\n // Connection\n isConnected: context.isConnected,\n connect: context.connect,\n disconnect: context.disconnect,\n\n // Actions\n executeAction: context.executeAction,\n registerServerAction: context.registerServerAction,\n stopExecution: context.stopExecution,\n\n // State\n isExecuting: context.isExecuting,\n error: context.error,\n clearError: context.clearError,\n };\n}\n","/**\n * useActionExecution Hook\n * \n * Hook for monitoring action execution state.\n */\n\nimport { useChatbotContext } from '../context/chatbot-context.js';\nimport type { ExecutionState } from '@navsi.ai/shared';\n\nexport interface UseActionExecutionReturn {\n isExecuting: boolean;\n executionState: ExecutionState | null;\n currentCommand: ExecutionState['currentCommand'] | undefined;\n progress: {\n current: number;\n total: number;\n percentage: number;\n /** Optional human-readable description of the current step */\n description?: string;\n } | null;\n}\n\n/**\n * Hook for monitoring action execution\n */\nexport function useActionExecution(): UseActionExecutionReturn {\n const context = useChatbotContext();\n\n const progress = context.executionState\n ? {\n current: context.executionState.currentIndex,\n total: context.executionState.totalCommands,\n percentage: context.executionState.totalCommands > 0\n ? Math.round((context.executionState.currentIndex / context.executionState.totalCommands) * 100)\n : 0,\n description: context.executionState.description,\n }\n : null;\n\n return {\n isExecuting: context.isExecuting,\n executionState: context.executionState,\n currentCommand: context.executionState?.currentCommand,\n progress,\n };\n}\n","/**\n * useWebSocket Hook\n * \n * Hook for managing WebSocket connection state.\n */\n\nimport { useChatbotContext } from '../context/chatbot-context.js';\nimport type { ConnectionState } from '@navsi.ai/shared';\n\nexport interface UseWebSocketReturn {\n connectionState: ConnectionState;\n isConnected: boolean;\n isConnecting: boolean;\n isReconnecting: boolean;\n connect: () => void;\n disconnect: () => void;\n}\n\n/**\n * Hook for WebSocket connection management\n */\nexport function useWebSocket(): UseWebSocketReturn {\n const context = useChatbotContext();\n\n return {\n connectionState: context.connectionState,\n isConnected: context.connectionState === 'connected',\n isConnecting: context.connectionState === 'connecting',\n isReconnecting: context.connectionState === 'reconnecting',\n connect: context.connect,\n disconnect: context.disconnect,\n };\n}\n"]}
|