@djangocfg/layouts 2.1.15 → 2.1.17
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/layouts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.17",
|
|
4
4
|
"description": "Simple, straightforward layout components for Next.js - import and use with props",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"layouts",
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
"check": "tsc --noEmit"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@djangocfg/api": "^2.1.
|
|
96
|
-
"@djangocfg/centrifugo": "^2.1.
|
|
97
|
-
"@djangocfg/ui-nextjs": "^2.1.
|
|
95
|
+
"@djangocfg/api": "^2.1.17",
|
|
96
|
+
"@djangocfg/centrifugo": "^2.1.17",
|
|
97
|
+
"@djangocfg/ui-nextjs": "^2.1.17",
|
|
98
98
|
"@hookform/resolvers": "^5.2.0",
|
|
99
99
|
"consola": "^3.4.2",
|
|
100
100
|
"lucide-react": "^0.545.0",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"uuid": "^11.1.0"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
117
|
+
"@djangocfg/typescript-config": "^2.1.17",
|
|
118
118
|
"@types/node": "^24.7.2",
|
|
119
119
|
"@types/react": "^19.1.0",
|
|
120
120
|
"@types/react-dom": "^19.1.0",
|
|
@@ -7,7 +7,7 @@ import { ChatPanel } from './ChatPanel';
|
|
|
7
7
|
import { ChatSidebar } from './ChatSidebar';
|
|
8
8
|
import { useAIChatContext, useAIChatContextOptional, AIChatProvider } from '../context/AIChatContext';
|
|
9
9
|
import { useChatLayout } from '../hooks/useChatLayout';
|
|
10
|
-
import {
|
|
10
|
+
import { getMcpEndpoints, type ChatWidgetConfig } from '../types';
|
|
11
11
|
|
|
12
12
|
// CSS for mysterious rotating border animation with multi-color ethereal effects
|
|
13
13
|
const fabAnimationStyles = `
|
|
@@ -210,8 +210,11 @@ AIChatWidgetInternal.displayName = 'AIChatWidgetInternal';
|
|
|
210
210
|
*
|
|
211
211
|
* @example
|
|
212
212
|
* ```tsx
|
|
213
|
-
* // Standalone usage
|
|
214
|
-
* <AIChatWidget
|
|
213
|
+
* // Standalone usage (always uses production API)
|
|
214
|
+
* <AIChatWidget />
|
|
215
|
+
*
|
|
216
|
+
* // Auto-detect environment (dev/prod)
|
|
217
|
+
* <AIChatWidget autoDetectEnvironment={true} />
|
|
215
218
|
*
|
|
216
219
|
* // With provider for custom control
|
|
217
220
|
* <AIChatProvider apiEndpoint="/api/ai/chat">
|
|
@@ -221,7 +224,7 @@ AIChatWidgetInternal.displayName = 'AIChatWidgetInternal';
|
|
|
221
224
|
* ```
|
|
222
225
|
*/
|
|
223
226
|
export const AIChatWidget: React.FC<AIChatWidgetProps> = ({
|
|
224
|
-
apiEndpoint
|
|
227
|
+
apiEndpoint,
|
|
225
228
|
title = 'DjangoCFG AI Assistant',
|
|
226
229
|
placeholder = 'Ask about DjangoCFG...',
|
|
227
230
|
greeting = "Hi! I'm your DjangoCFG AI assistant powered by GPT. Ask me anything about configuration, features, or how to use the library.",
|
|
@@ -229,6 +232,7 @@ export const AIChatWidget: React.FC<AIChatWidgetProps> = ({
|
|
|
229
232
|
variant = 'default',
|
|
230
233
|
className,
|
|
231
234
|
enableStreaming = true,
|
|
235
|
+
autoDetectEnvironment = false,
|
|
232
236
|
}) => {
|
|
233
237
|
// Check if we're inside an AIChatProvider
|
|
234
238
|
const existingContext = useAIChatContextOptional();
|
|
@@ -238,11 +242,14 @@ export const AIChatWidget: React.FC<AIChatWidgetProps> = ({
|
|
|
238
242
|
return <AIChatWidgetInternal className={className} />;
|
|
239
243
|
}
|
|
240
244
|
|
|
245
|
+
// Determine API endpoint: use provided, or get from config based on autoDetect
|
|
246
|
+
const finalApiEndpoint = apiEndpoint || getMcpEndpoints(autoDetectEnvironment).chat;
|
|
247
|
+
|
|
241
248
|
// Otherwise, wrap in provider
|
|
242
249
|
return (
|
|
243
250
|
<AIChatProvider
|
|
244
|
-
apiEndpoint={
|
|
245
|
-
config={{ title, placeholder, greeting, position, variant }}
|
|
251
|
+
apiEndpoint={finalApiEndpoint}
|
|
252
|
+
config={{ title, placeholder, greeting, position, variant, autoDetectEnvironment }}
|
|
246
253
|
enableStreaming={enableStreaming}
|
|
247
254
|
>
|
|
248
255
|
<AIChatWidgetInternal className={className} />
|
|
@@ -7,28 +7,45 @@
|
|
|
7
7
|
const PROD_HOST = 'https://mcp.djangocfg.com';
|
|
8
8
|
const DEV_HOST = 'http://localhost:3002';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Get host based on auto-detect flag
|
|
12
|
+
* @param autoDetect - If true, auto-detect based on NODE_ENV. If false, always use PROD_HOST
|
|
13
|
+
*/
|
|
14
|
+
function getHost(autoDetect: boolean = false): string {
|
|
15
|
+
if (autoDetect && process.env.NODE_ENV === 'development') {
|
|
16
|
+
return DEV_HOST;
|
|
17
|
+
}
|
|
18
|
+
return PROD_HOST;
|
|
19
|
+
}
|
|
12
20
|
|
|
13
21
|
/**
|
|
14
|
-
* MCP Server endpoints
|
|
22
|
+
* Get MCP Server endpoints
|
|
23
|
+
* @param autoDetect - If true, auto-detect environment. If false (default), always use production
|
|
15
24
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
export function getMcpEndpoints(autoDetect: boolean = false) {
|
|
26
|
+
const HOST = getHost(autoDetect);
|
|
27
|
+
return {
|
|
28
|
+
/** Base URL */
|
|
29
|
+
baseUrl: HOST,
|
|
30
|
+
/** Chat API endpoint */
|
|
31
|
+
chat: `${HOST}/api/chat`,
|
|
32
|
+
/** Search API endpoint */
|
|
33
|
+
search: `${HOST}/api/search`,
|
|
34
|
+
/** Conversations API endpoint */
|
|
35
|
+
conversations: `${HOST}/api/conversations`,
|
|
36
|
+
/** Health check endpoint */
|
|
37
|
+
health: `${HOST}/health`,
|
|
38
|
+
/** MCP protocol endpoint (Streamable HTTP) */
|
|
39
|
+
mcp: `${HOST}/mcp`,
|
|
40
|
+
/** SSE endpoint for legacy clients */
|
|
41
|
+
sse: `${HOST}/mcp/sse`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* MCP Server endpoints (always production by default)
|
|
47
|
+
*/
|
|
48
|
+
export const mcpEndpoints = getMcpEndpoints(false);
|
|
32
49
|
|
|
33
50
|
// Export defaults for backwards compatibility
|
|
34
51
|
export const DEFAULT_CHAT_API_ENDPOINT = PROD_HOST + '/api/chat';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
// Re-export config constants for backwards compatibility
|
|
6
|
-
export { DEFAULT_CHAT_API_ENDPOINT, mcpEndpoints } from './config';
|
|
6
|
+
export { DEFAULT_CHAT_API_ENDPOINT, mcpEndpoints, getMcpEndpoints } from './config';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* AI Chat message role
|
|
@@ -79,6 +79,8 @@ export interface ChatWidgetConfig {
|
|
|
79
79
|
position?: 'bottom-right' | 'bottom-left';
|
|
80
80
|
/** Theme variant */
|
|
81
81
|
variant?: 'default' | 'minimal';
|
|
82
|
+
/** Auto-detect environment (dev/prod) for API endpoint. If false (default), always uses production */
|
|
83
|
+
autoDetectEnvironment?: boolean;
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
// =============================================================================
|