@supernal/interface-nextjs 0.1.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/dist/index.d.mts +299 -0
- package/dist/index.d.ts +299 -0
- package/dist/index.js +932 -0
- package/dist/index.mjs +892 -0
- package/package.json +61 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { NavigationGraph, NavigationPath, NavigationContext, ToolMetadata } from '@supernal/interface/browser';
|
|
4
|
+
import { AIInterface } from '@supernal/interface';
|
|
5
|
+
export { AICommand, AIResponse } from '@supernal/interface';
|
|
6
|
+
|
|
7
|
+
interface SupernalProviderProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
10
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
11
|
+
mode?: 'fuzzy' | 'ai';
|
|
12
|
+
apiKey?: string;
|
|
13
|
+
welcomeMessage?: string;
|
|
14
|
+
routes?: Record<string, string>;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onNavigate?: (context: string) => void;
|
|
17
|
+
onToolExecute?: (tool: string, result: any) => void;
|
|
18
|
+
}
|
|
19
|
+
declare function SupernalProvider({ children, theme, position, mode, apiKey, welcomeMessage, routes, disabled, onNavigate, onToolExecute, }: SupernalProviderProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
interface ChatInputContextType {
|
|
22
|
+
/**
|
|
23
|
+
* Insert text into the chat input (and optionally submit it)
|
|
24
|
+
*/
|
|
25
|
+
insertText: (text: string, submit?: boolean) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Register the chat input element (called by ChatBubble)
|
|
28
|
+
*/
|
|
29
|
+
registerInput: (callback: (text: string, submit?: boolean) => void) => void;
|
|
30
|
+
}
|
|
31
|
+
declare function useChatInput(): ChatInputContextType;
|
|
32
|
+
declare function ChatInputProvider({ children }: {
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
}): react_jsx_runtime.JSX.Element;
|
|
35
|
+
|
|
36
|
+
declare function NavigationContextProvider({ value, children }: {
|
|
37
|
+
value: string;
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
}): react_jsx_runtime.JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* Hook to access the NavigationGraph singleton
|
|
42
|
+
*/
|
|
43
|
+
declare function useNavigationGraph(): NavigationGraph;
|
|
44
|
+
/**
|
|
45
|
+
* Hook to get the current navigation context
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const currentContext = useCurrentContext();
|
|
49
|
+
* console.log(currentContext); // 'dashboard.security'
|
|
50
|
+
*/
|
|
51
|
+
declare function useCurrentContext(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Hook to register a tool in a navigation context
|
|
54
|
+
*
|
|
55
|
+
* @param toolId - Unique tool identifier
|
|
56
|
+
* @param contextId - Optional: explicit context ID (otherwise uses current context)
|
|
57
|
+
* @param metadata - Optional: metadata for auto-detection
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Auto-registers in current context
|
|
61
|
+
* useRegisterTool('enable-2fa');
|
|
62
|
+
*
|
|
63
|
+
* // Or explicit context
|
|
64
|
+
* useRegisterTool('enable-2fa', 'dashboard.security');
|
|
65
|
+
*
|
|
66
|
+
* // Or with auto-detection metadata
|
|
67
|
+
* useRegisterTool('enable-2fa', undefined, {
|
|
68
|
+
* filePath: 'src/pages/dashboard/SecurityTab.tsx'
|
|
69
|
+
* });
|
|
70
|
+
*/
|
|
71
|
+
declare function useRegisterTool(toolId: string, contextId?: string, metadata?: {
|
|
72
|
+
filePath?: string;
|
|
73
|
+
componentName?: string;
|
|
74
|
+
element?: Element;
|
|
75
|
+
}): void;
|
|
76
|
+
/**
|
|
77
|
+
* Hook to compute navigation path from current context to target
|
|
78
|
+
*
|
|
79
|
+
* @param targetContextOrToolId - Target context ID or tool ID
|
|
80
|
+
* @param isToolId - Whether the target is a tool ID (will lookup context)
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* const { path, loading, error } = useNavigationPath('dashboard.security');
|
|
84
|
+
*
|
|
85
|
+
* if (loading) return <Spinner />;
|
|
86
|
+
* if (error) return <Error message={error} />;
|
|
87
|
+
* if (!path) return <div>Cannot navigate</div>;
|
|
88
|
+
*
|
|
89
|
+
* return (
|
|
90
|
+
* <div>
|
|
91
|
+
* Path: {path.steps.map(s => s.navigationTool).join(' → ')}
|
|
92
|
+
* </div>
|
|
93
|
+
* );
|
|
94
|
+
*/
|
|
95
|
+
declare function useNavigationPath(targetContextOrToolId: string, isToolId?: boolean): {
|
|
96
|
+
path: NavigationPath | null;
|
|
97
|
+
loading: boolean;
|
|
98
|
+
error: string | undefined;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Hook to execute navigation to a target context
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* const { navigateTo, navigating, error } = useNavigate();
|
|
105
|
+
*
|
|
106
|
+
* const handleClick = async () => {
|
|
107
|
+
* const success = await navigateTo('dashboard.security');
|
|
108
|
+
* if (success) {
|
|
109
|
+
* console.log('Navigation complete!');
|
|
110
|
+
* }
|
|
111
|
+
* };
|
|
112
|
+
*/
|
|
113
|
+
declare function useNavigate(): {
|
|
114
|
+
navigateTo: (targetContextOrToolId: string, isToolId?: boolean, executeNavigation?: (toolId: string) => Promise<void>) => Promise<boolean>;
|
|
115
|
+
navigating: boolean;
|
|
116
|
+
error: string | undefined;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Hook to get all navigation contexts (for debugging/admin UI)
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* const contexts = useAllContexts();
|
|
123
|
+
*
|
|
124
|
+
* return (
|
|
125
|
+
* <ul>
|
|
126
|
+
* {contexts.map(ctx => (
|
|
127
|
+
* <li key={ctx.id}>
|
|
128
|
+
* {ctx.name} - {ctx.tools.length} tools
|
|
129
|
+
* </li>
|
|
130
|
+
* ))}
|
|
131
|
+
* </ul>
|
|
132
|
+
* );
|
|
133
|
+
*/
|
|
134
|
+
declare function useAllContexts(): NavigationContext[];
|
|
135
|
+
|
|
136
|
+
interface Message {
|
|
137
|
+
id: string;
|
|
138
|
+
text: string;
|
|
139
|
+
type: 'user' | 'ai' | 'system';
|
|
140
|
+
timestamp: string;
|
|
141
|
+
}
|
|
142
|
+
interface ChatContextType {
|
|
143
|
+
messages: Message[];
|
|
144
|
+
sendMessage: (text: string) => Promise<void>;
|
|
145
|
+
clearMessages: () => void;
|
|
146
|
+
isLoading: boolean;
|
|
147
|
+
}
|
|
148
|
+
declare function useChatContext(): ChatContextType;
|
|
149
|
+
declare function ChatProvider({ children, mode, apiKey, onToolExecute, }: {
|
|
150
|
+
children: React.ReactNode;
|
|
151
|
+
mode?: 'fuzzy' | 'ai';
|
|
152
|
+
apiKey?: string;
|
|
153
|
+
onToolExecute?: (tool: string, result: any) => void;
|
|
154
|
+
}): react_jsx_runtime.JSX.Element;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Persistent Chat Bubble Component
|
|
158
|
+
*
|
|
159
|
+
* Fixed position chat bubble in lower right corner that:
|
|
160
|
+
* - Appears on every page
|
|
161
|
+
* - Expands/collapses without blocking content
|
|
162
|
+
* - Provides AI interface for tool execution
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
interface ChatBubbleProps {
|
|
166
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
167
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
168
|
+
welcomeMessage?: string;
|
|
169
|
+
}
|
|
170
|
+
declare const ChatBubble: React.FC<ChatBubbleProps>;
|
|
171
|
+
|
|
172
|
+
interface AutoNavigationContextProps {
|
|
173
|
+
children: React.ReactNode;
|
|
174
|
+
routes?: Record<string, string>;
|
|
175
|
+
onNavigate?: (context: string) => void;
|
|
176
|
+
}
|
|
177
|
+
declare function AutoNavigationContext({ children, routes, onNavigate, }: AutoNavigationContextProps): react_jsx_runtime.JSX.Element;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Tool Manager - Centralized system for tool execution and feedback
|
|
181
|
+
*
|
|
182
|
+
* Tools auto-report execution → ToolManager listens → Updates UI
|
|
183
|
+
*/
|
|
184
|
+
interface ToolExecutionResult {
|
|
185
|
+
toolName: string;
|
|
186
|
+
elementId?: string;
|
|
187
|
+
actionType?: string;
|
|
188
|
+
success: boolean;
|
|
189
|
+
message: string;
|
|
190
|
+
data?: unknown;
|
|
191
|
+
error?: Error;
|
|
192
|
+
timestamp: string;
|
|
193
|
+
}
|
|
194
|
+
type ToolExecutionListener = (result: ToolExecutionResult) => void;
|
|
195
|
+
declare class ToolManagerClass {
|
|
196
|
+
private listeners;
|
|
197
|
+
private lastReport;
|
|
198
|
+
constructor();
|
|
199
|
+
/**
|
|
200
|
+
* Subscribe to tool execution results
|
|
201
|
+
*/
|
|
202
|
+
subscribe(listener: ToolExecutionListener): () => void;
|
|
203
|
+
/**
|
|
204
|
+
* Tools call this to report execution results (auto-called by HOCs)
|
|
205
|
+
*/
|
|
206
|
+
reportExecution(result: Omit<ToolExecutionResult, 'timestamp'> | ToolExecutionResult): void;
|
|
207
|
+
/**
|
|
208
|
+
* Get the last reported tool execution (for AIInterface)
|
|
209
|
+
*/
|
|
210
|
+
getLastReport(): ToolExecutionResult | null;
|
|
211
|
+
/**
|
|
212
|
+
* Clear the last report
|
|
213
|
+
*/
|
|
214
|
+
clearLastReport(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Helper to create a success result (for custom messages)
|
|
217
|
+
*/
|
|
218
|
+
success(toolName: string, message: string, data?: unknown): ToolExecutionResult;
|
|
219
|
+
/**
|
|
220
|
+
* Helper to create a failure result (for custom messages)
|
|
221
|
+
*/
|
|
222
|
+
failure(toolName: string, message: string, data?: unknown): ToolExecutionResult;
|
|
223
|
+
}
|
|
224
|
+
declare const ToolManager: ToolManagerClass;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Demo AI Interface - uses open-source AIInterface
|
|
228
|
+
*
|
|
229
|
+
* This is a thin wrapper that:
|
|
230
|
+
* 1. Imports the generic AIInterface from @supernal/interface
|
|
231
|
+
* 2. Hooks into app-specific ToolManager for UI notifications
|
|
232
|
+
* 3. Provides backward-compatible interface for existing code
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
interface CommandResult {
|
|
236
|
+
success: boolean;
|
|
237
|
+
message: string;
|
|
238
|
+
tool?: any;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Demo-specific AIInterface with ToolManager integration
|
|
242
|
+
*/
|
|
243
|
+
declare class DemoAIInterface extends AIInterface {
|
|
244
|
+
private toolExecutionListeners;
|
|
245
|
+
constructor();
|
|
246
|
+
/**
|
|
247
|
+
* Subscribe to tool execution results (for chat UI)
|
|
248
|
+
*/
|
|
249
|
+
onToolExecution(callback: (result: ToolExecutionResult) => void): () => void;
|
|
250
|
+
/**
|
|
251
|
+
* Notify all listeners about tool execution
|
|
252
|
+
*/
|
|
253
|
+
private notifyToolExecutionListeners;
|
|
254
|
+
/**
|
|
255
|
+
* Find and execute command - backward compatible wrapper
|
|
256
|
+
*
|
|
257
|
+
* Convenience method that combines findToolsForCommand and executeCommand
|
|
258
|
+
*/
|
|
259
|
+
findAndExecuteCommand(query: string, _currentContainer?: string): Promise<CommandResult>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Fuzzy Matching Utility
|
|
264
|
+
* Finds items that best match a search query
|
|
265
|
+
*/
|
|
266
|
+
declare class FuzzyMatcher {
|
|
267
|
+
/**
|
|
268
|
+
* Find item that best matches the query
|
|
269
|
+
*/
|
|
270
|
+
static findBest<T>(items: T[], query: string, getSearchableText: (item: T) => string[]): T | null;
|
|
271
|
+
/**
|
|
272
|
+
* Find all items that match the query (ranked by relevance)
|
|
273
|
+
*/
|
|
274
|
+
static findAll<T>(items: T[], query: string, getSearchableText: (item: T) => string[]): T[];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Fuzzy Matching Utilities
|
|
279
|
+
*
|
|
280
|
+
* Shared fuzzy matching logic used by both:
|
|
281
|
+
* - DemoAIInterface (client-side tool matching)
|
|
282
|
+
* - CopilotKit mock endpoint (server-side fallback)
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
interface FuzzyMatchResult {
|
|
286
|
+
tool: ToolMetadata | undefined;
|
|
287
|
+
score: number;
|
|
288
|
+
confidence: number;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Score how well a query matches a tool's examples, description, and method name
|
|
292
|
+
*/
|
|
293
|
+
declare function scoreToolMatch(query: string, tool: ToolMetadata): number;
|
|
294
|
+
/**
|
|
295
|
+
* Find the best matching tool from a list
|
|
296
|
+
*/
|
|
297
|
+
declare function findBestMatch(query: string, tools: ToolMetadata[]): FuzzyMatchResult;
|
|
298
|
+
|
|
299
|
+
export { AutoNavigationContext, ChatBubble, ChatInputProvider, ChatProvider, type CommandResult, DemoAIInterface, type FuzzyMatchResult, FuzzyMatcher, NavigationContextProvider, SupernalProvider, type SupernalProviderProps, type ToolExecutionResult, ToolManager, findBestMatch, scoreToolMatch, useAllContexts, useChatContext, useChatInput, useCurrentContext, useNavigate, useNavigationGraph, useNavigationPath, useRegisterTool };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { NavigationGraph, NavigationPath, NavigationContext, ToolMetadata } from '@supernal/interface/browser';
|
|
4
|
+
import { AIInterface } from '@supernal/interface';
|
|
5
|
+
export { AICommand, AIResponse } from '@supernal/interface';
|
|
6
|
+
|
|
7
|
+
interface SupernalProviderProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
10
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
11
|
+
mode?: 'fuzzy' | 'ai';
|
|
12
|
+
apiKey?: string;
|
|
13
|
+
welcomeMessage?: string;
|
|
14
|
+
routes?: Record<string, string>;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onNavigate?: (context: string) => void;
|
|
17
|
+
onToolExecute?: (tool: string, result: any) => void;
|
|
18
|
+
}
|
|
19
|
+
declare function SupernalProvider({ children, theme, position, mode, apiKey, welcomeMessage, routes, disabled, onNavigate, onToolExecute, }: SupernalProviderProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
interface ChatInputContextType {
|
|
22
|
+
/**
|
|
23
|
+
* Insert text into the chat input (and optionally submit it)
|
|
24
|
+
*/
|
|
25
|
+
insertText: (text: string, submit?: boolean) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Register the chat input element (called by ChatBubble)
|
|
28
|
+
*/
|
|
29
|
+
registerInput: (callback: (text: string, submit?: boolean) => void) => void;
|
|
30
|
+
}
|
|
31
|
+
declare function useChatInput(): ChatInputContextType;
|
|
32
|
+
declare function ChatInputProvider({ children }: {
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
}): react_jsx_runtime.JSX.Element;
|
|
35
|
+
|
|
36
|
+
declare function NavigationContextProvider({ value, children }: {
|
|
37
|
+
value: string;
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
}): react_jsx_runtime.JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* Hook to access the NavigationGraph singleton
|
|
42
|
+
*/
|
|
43
|
+
declare function useNavigationGraph(): NavigationGraph;
|
|
44
|
+
/**
|
|
45
|
+
* Hook to get the current navigation context
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const currentContext = useCurrentContext();
|
|
49
|
+
* console.log(currentContext); // 'dashboard.security'
|
|
50
|
+
*/
|
|
51
|
+
declare function useCurrentContext(): string;
|
|
52
|
+
/**
|
|
53
|
+
* Hook to register a tool in a navigation context
|
|
54
|
+
*
|
|
55
|
+
* @param toolId - Unique tool identifier
|
|
56
|
+
* @param contextId - Optional: explicit context ID (otherwise uses current context)
|
|
57
|
+
* @param metadata - Optional: metadata for auto-detection
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Auto-registers in current context
|
|
61
|
+
* useRegisterTool('enable-2fa');
|
|
62
|
+
*
|
|
63
|
+
* // Or explicit context
|
|
64
|
+
* useRegisterTool('enable-2fa', 'dashboard.security');
|
|
65
|
+
*
|
|
66
|
+
* // Or with auto-detection metadata
|
|
67
|
+
* useRegisterTool('enable-2fa', undefined, {
|
|
68
|
+
* filePath: 'src/pages/dashboard/SecurityTab.tsx'
|
|
69
|
+
* });
|
|
70
|
+
*/
|
|
71
|
+
declare function useRegisterTool(toolId: string, contextId?: string, metadata?: {
|
|
72
|
+
filePath?: string;
|
|
73
|
+
componentName?: string;
|
|
74
|
+
element?: Element;
|
|
75
|
+
}): void;
|
|
76
|
+
/**
|
|
77
|
+
* Hook to compute navigation path from current context to target
|
|
78
|
+
*
|
|
79
|
+
* @param targetContextOrToolId - Target context ID or tool ID
|
|
80
|
+
* @param isToolId - Whether the target is a tool ID (will lookup context)
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* const { path, loading, error } = useNavigationPath('dashboard.security');
|
|
84
|
+
*
|
|
85
|
+
* if (loading) return <Spinner />;
|
|
86
|
+
* if (error) return <Error message={error} />;
|
|
87
|
+
* if (!path) return <div>Cannot navigate</div>;
|
|
88
|
+
*
|
|
89
|
+
* return (
|
|
90
|
+
* <div>
|
|
91
|
+
* Path: {path.steps.map(s => s.navigationTool).join(' → ')}
|
|
92
|
+
* </div>
|
|
93
|
+
* );
|
|
94
|
+
*/
|
|
95
|
+
declare function useNavigationPath(targetContextOrToolId: string, isToolId?: boolean): {
|
|
96
|
+
path: NavigationPath | null;
|
|
97
|
+
loading: boolean;
|
|
98
|
+
error: string | undefined;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Hook to execute navigation to a target context
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* const { navigateTo, navigating, error } = useNavigate();
|
|
105
|
+
*
|
|
106
|
+
* const handleClick = async () => {
|
|
107
|
+
* const success = await navigateTo('dashboard.security');
|
|
108
|
+
* if (success) {
|
|
109
|
+
* console.log('Navigation complete!');
|
|
110
|
+
* }
|
|
111
|
+
* };
|
|
112
|
+
*/
|
|
113
|
+
declare function useNavigate(): {
|
|
114
|
+
navigateTo: (targetContextOrToolId: string, isToolId?: boolean, executeNavigation?: (toolId: string) => Promise<void>) => Promise<boolean>;
|
|
115
|
+
navigating: boolean;
|
|
116
|
+
error: string | undefined;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Hook to get all navigation contexts (for debugging/admin UI)
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* const contexts = useAllContexts();
|
|
123
|
+
*
|
|
124
|
+
* return (
|
|
125
|
+
* <ul>
|
|
126
|
+
* {contexts.map(ctx => (
|
|
127
|
+
* <li key={ctx.id}>
|
|
128
|
+
* {ctx.name} - {ctx.tools.length} tools
|
|
129
|
+
* </li>
|
|
130
|
+
* ))}
|
|
131
|
+
* </ul>
|
|
132
|
+
* );
|
|
133
|
+
*/
|
|
134
|
+
declare function useAllContexts(): NavigationContext[];
|
|
135
|
+
|
|
136
|
+
interface Message {
|
|
137
|
+
id: string;
|
|
138
|
+
text: string;
|
|
139
|
+
type: 'user' | 'ai' | 'system';
|
|
140
|
+
timestamp: string;
|
|
141
|
+
}
|
|
142
|
+
interface ChatContextType {
|
|
143
|
+
messages: Message[];
|
|
144
|
+
sendMessage: (text: string) => Promise<void>;
|
|
145
|
+
clearMessages: () => void;
|
|
146
|
+
isLoading: boolean;
|
|
147
|
+
}
|
|
148
|
+
declare function useChatContext(): ChatContextType;
|
|
149
|
+
declare function ChatProvider({ children, mode, apiKey, onToolExecute, }: {
|
|
150
|
+
children: React.ReactNode;
|
|
151
|
+
mode?: 'fuzzy' | 'ai';
|
|
152
|
+
apiKey?: string;
|
|
153
|
+
onToolExecute?: (tool: string, result: any) => void;
|
|
154
|
+
}): react_jsx_runtime.JSX.Element;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Persistent Chat Bubble Component
|
|
158
|
+
*
|
|
159
|
+
* Fixed position chat bubble in lower right corner that:
|
|
160
|
+
* - Appears on every page
|
|
161
|
+
* - Expands/collapses without blocking content
|
|
162
|
+
* - Provides AI interface for tool execution
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
interface ChatBubbleProps {
|
|
166
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
167
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
168
|
+
welcomeMessage?: string;
|
|
169
|
+
}
|
|
170
|
+
declare const ChatBubble: React.FC<ChatBubbleProps>;
|
|
171
|
+
|
|
172
|
+
interface AutoNavigationContextProps {
|
|
173
|
+
children: React.ReactNode;
|
|
174
|
+
routes?: Record<string, string>;
|
|
175
|
+
onNavigate?: (context: string) => void;
|
|
176
|
+
}
|
|
177
|
+
declare function AutoNavigationContext({ children, routes, onNavigate, }: AutoNavigationContextProps): react_jsx_runtime.JSX.Element;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Tool Manager - Centralized system for tool execution and feedback
|
|
181
|
+
*
|
|
182
|
+
* Tools auto-report execution → ToolManager listens → Updates UI
|
|
183
|
+
*/
|
|
184
|
+
interface ToolExecutionResult {
|
|
185
|
+
toolName: string;
|
|
186
|
+
elementId?: string;
|
|
187
|
+
actionType?: string;
|
|
188
|
+
success: boolean;
|
|
189
|
+
message: string;
|
|
190
|
+
data?: unknown;
|
|
191
|
+
error?: Error;
|
|
192
|
+
timestamp: string;
|
|
193
|
+
}
|
|
194
|
+
type ToolExecutionListener = (result: ToolExecutionResult) => void;
|
|
195
|
+
declare class ToolManagerClass {
|
|
196
|
+
private listeners;
|
|
197
|
+
private lastReport;
|
|
198
|
+
constructor();
|
|
199
|
+
/**
|
|
200
|
+
* Subscribe to tool execution results
|
|
201
|
+
*/
|
|
202
|
+
subscribe(listener: ToolExecutionListener): () => void;
|
|
203
|
+
/**
|
|
204
|
+
* Tools call this to report execution results (auto-called by HOCs)
|
|
205
|
+
*/
|
|
206
|
+
reportExecution(result: Omit<ToolExecutionResult, 'timestamp'> | ToolExecutionResult): void;
|
|
207
|
+
/**
|
|
208
|
+
* Get the last reported tool execution (for AIInterface)
|
|
209
|
+
*/
|
|
210
|
+
getLastReport(): ToolExecutionResult | null;
|
|
211
|
+
/**
|
|
212
|
+
* Clear the last report
|
|
213
|
+
*/
|
|
214
|
+
clearLastReport(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Helper to create a success result (for custom messages)
|
|
217
|
+
*/
|
|
218
|
+
success(toolName: string, message: string, data?: unknown): ToolExecutionResult;
|
|
219
|
+
/**
|
|
220
|
+
* Helper to create a failure result (for custom messages)
|
|
221
|
+
*/
|
|
222
|
+
failure(toolName: string, message: string, data?: unknown): ToolExecutionResult;
|
|
223
|
+
}
|
|
224
|
+
declare const ToolManager: ToolManagerClass;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Demo AI Interface - uses open-source AIInterface
|
|
228
|
+
*
|
|
229
|
+
* This is a thin wrapper that:
|
|
230
|
+
* 1. Imports the generic AIInterface from @supernal/interface
|
|
231
|
+
* 2. Hooks into app-specific ToolManager for UI notifications
|
|
232
|
+
* 3. Provides backward-compatible interface for existing code
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
interface CommandResult {
|
|
236
|
+
success: boolean;
|
|
237
|
+
message: string;
|
|
238
|
+
tool?: any;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Demo-specific AIInterface with ToolManager integration
|
|
242
|
+
*/
|
|
243
|
+
declare class DemoAIInterface extends AIInterface {
|
|
244
|
+
private toolExecutionListeners;
|
|
245
|
+
constructor();
|
|
246
|
+
/**
|
|
247
|
+
* Subscribe to tool execution results (for chat UI)
|
|
248
|
+
*/
|
|
249
|
+
onToolExecution(callback: (result: ToolExecutionResult) => void): () => void;
|
|
250
|
+
/**
|
|
251
|
+
* Notify all listeners about tool execution
|
|
252
|
+
*/
|
|
253
|
+
private notifyToolExecutionListeners;
|
|
254
|
+
/**
|
|
255
|
+
* Find and execute command - backward compatible wrapper
|
|
256
|
+
*
|
|
257
|
+
* Convenience method that combines findToolsForCommand and executeCommand
|
|
258
|
+
*/
|
|
259
|
+
findAndExecuteCommand(query: string, _currentContainer?: string): Promise<CommandResult>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Fuzzy Matching Utility
|
|
264
|
+
* Finds items that best match a search query
|
|
265
|
+
*/
|
|
266
|
+
declare class FuzzyMatcher {
|
|
267
|
+
/**
|
|
268
|
+
* Find item that best matches the query
|
|
269
|
+
*/
|
|
270
|
+
static findBest<T>(items: T[], query: string, getSearchableText: (item: T) => string[]): T | null;
|
|
271
|
+
/**
|
|
272
|
+
* Find all items that match the query (ranked by relevance)
|
|
273
|
+
*/
|
|
274
|
+
static findAll<T>(items: T[], query: string, getSearchableText: (item: T) => string[]): T[];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Fuzzy Matching Utilities
|
|
279
|
+
*
|
|
280
|
+
* Shared fuzzy matching logic used by both:
|
|
281
|
+
* - DemoAIInterface (client-side tool matching)
|
|
282
|
+
* - CopilotKit mock endpoint (server-side fallback)
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
interface FuzzyMatchResult {
|
|
286
|
+
tool: ToolMetadata | undefined;
|
|
287
|
+
score: number;
|
|
288
|
+
confidence: number;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Score how well a query matches a tool's examples, description, and method name
|
|
292
|
+
*/
|
|
293
|
+
declare function scoreToolMatch(query: string, tool: ToolMetadata): number;
|
|
294
|
+
/**
|
|
295
|
+
* Find the best matching tool from a list
|
|
296
|
+
*/
|
|
297
|
+
declare function findBestMatch(query: string, tools: ToolMetadata[]): FuzzyMatchResult;
|
|
298
|
+
|
|
299
|
+
export { AutoNavigationContext, ChatBubble, ChatInputProvider, ChatProvider, type CommandResult, DemoAIInterface, type FuzzyMatchResult, FuzzyMatcher, NavigationContextProvider, SupernalProvider, type SupernalProviderProps, type ToolExecutionResult, ToolManager, findBestMatch, scoreToolMatch, useAllContexts, useChatContext, useChatInput, useCurrentContext, useNavigate, useNavigationGraph, useNavigationPath, useRegisterTool };
|