@frontmcp/ui 0.6.1 → 0.6.3
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/bridge/core/bridge-factory.d.ts +1 -0
- package/bridge/core/bridge-factory.d.ts.map +1 -1
- package/bridge/index.d.ts +1 -1
- package/bridge/index.d.ts.map +1 -1
- package/bridge/index.js +39 -881
- package/bundler/browser-components.d.ts +42 -0
- package/bundler/browser-components.d.ts.map +1 -0
- package/bundler/bundler.d.ts +78 -4
- package/bundler/bundler.d.ts.map +1 -1
- package/bundler/index.d.ts +8 -8
- package/bundler/index.d.ts.map +1 -1
- package/bundler/index.js +1315 -1854
- package/bundler/types.d.ts +188 -7
- package/bundler/types.d.ts.map +1 -1
- package/esm/bridge/{index.js → index.mjs} +40 -877
- package/esm/bundler/{index.js → index.mjs} +1391 -1895
- package/esm/{index.js → index.mjs} +215 -3091
- package/esm/layouts/{index.js → index.mjs} +3 -3
- package/esm/package.json +17 -18
- package/esm/react/index.mjs +1183 -0
- package/esm/renderers/index.mjs +611 -0
- package/esm/universal/{index.js → index.mjs} +266 -70
- package/index.d.ts +1 -4
- package/index.d.ts.map +1 -1
- package/index.js +208 -3113
- package/layouts/base.d.ts.map +1 -1
- package/layouts/index.js +3 -3
- package/layouts/presets.d.ts.map +1 -1
- package/package.json +9 -8
- package/react/Badge.d.ts.map +1 -1
- package/react/hooks/context.d.ts.map +1 -1
- package/react/index.d.ts +0 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +57 -2001
- package/react/types.d.ts.map +1 -1
- package/renderers/index.d.ts +9 -4
- package/renderers/index.d.ts.map +1 -1
- package/renderers/index.js +328 -88
- package/renderers/mdx.renderer.d.ts +99 -0
- package/renderers/mdx.renderer.d.ts.map +1 -0
- package/renderers/react.renderer.d.ts +22 -13
- package/renderers/react.renderer.d.ts.map +1 -1
- package/renderers/transpiler.d.ts +49 -0
- package/renderers/transpiler.d.ts.map +1 -0
- package/universal/cached-runtime.d.ts +25 -1
- package/universal/cached-runtime.d.ts.map +1 -1
- package/universal/index.js +266 -70
- package/universal/runtime-builder.d.ts.map +1 -1
- package/universal/types.d.ts.map +1 -1
- package/web-components/elements/fmcp-input.d.ts.map +1 -1
- package/web-components/elements/fmcp-select.d.ts.map +1 -1
- package/web-components/index.d.ts +0 -1
- package/web-components/index.d.ts.map +1 -1
- package/bundler/cache.d.ts +0 -173
- package/bundler/cache.d.ts.map +0 -1
- package/bundler/file-cache/component-builder.d.ts +0 -167
- package/bundler/file-cache/component-builder.d.ts.map +0 -1
- package/bundler/file-cache/hash-calculator.d.ts +0 -155
- package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
- package/bundler/file-cache/index.d.ts +0 -12
- package/bundler/file-cache/index.d.ts.map +0 -1
- package/bundler/file-cache/storage/filesystem.d.ts +0 -149
- package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
- package/bundler/file-cache/storage/index.d.ts +0 -11
- package/bundler/file-cache/storage/index.d.ts.map +0 -1
- package/bundler/file-cache/storage/interface.d.ts +0 -152
- package/bundler/file-cache/storage/interface.d.ts.map +0 -1
- package/bundler/file-cache/storage/redis.d.ts +0 -139
- package/bundler/file-cache/storage/redis.d.ts.map +0 -1
- package/bundler/sandbox/enclave-adapter.d.ts +0 -121
- package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
- package/bundler/sandbox/executor.d.ts +0 -14
- package/bundler/sandbox/executor.d.ts.map +0 -1
- package/bundler/sandbox/policy.d.ts +0 -62
- package/bundler/sandbox/policy.d.ts.map +0 -1
- package/esm/bridge/adapters/base-adapter.d.ts +0 -104
- package/esm/bridge/adapters/base-adapter.d.ts.map +0 -1
- package/esm/bridge/adapters/claude.adapter.d.ts +0 -67
- package/esm/bridge/adapters/claude.adapter.d.ts.map +0 -1
- package/esm/bridge/adapters/ext-apps.adapter.d.ts +0 -143
- package/esm/bridge/adapters/ext-apps.adapter.d.ts.map +0 -1
- package/esm/bridge/adapters/gemini.adapter.d.ts +0 -64
- package/esm/bridge/adapters/gemini.adapter.d.ts.map +0 -1
- package/esm/bridge/adapters/generic.adapter.d.ts +0 -56
- package/esm/bridge/adapters/generic.adapter.d.ts.map +0 -1
- package/esm/bridge/adapters/index.d.ts +0 -26
- package/esm/bridge/adapters/index.d.ts.map +0 -1
- package/esm/bridge/adapters/openai.adapter.d.ts +0 -65
- package/esm/bridge/adapters/openai.adapter.d.ts.map +0 -1
- package/esm/bridge/core/adapter-registry.d.ts +0 -122
- package/esm/bridge/core/adapter-registry.d.ts.map +0 -1
- package/esm/bridge/core/bridge-factory.d.ts +0 -199
- package/esm/bridge/core/bridge-factory.d.ts.map +0 -1
- package/esm/bridge/core/index.d.ts +0 -10
- package/esm/bridge/core/index.d.ts.map +0 -1
- package/esm/bridge/index.d.ts +0 -62
- package/esm/bridge/index.d.ts.map +0 -1
- package/esm/bridge/runtime/iife-generator.d.ts +0 -62
- package/esm/bridge/runtime/iife-generator.d.ts.map +0 -1
- package/esm/bridge/runtime/index.d.ts +0 -10
- package/esm/bridge/runtime/index.d.ts.map +0 -1
- package/esm/bridge/types.d.ts +0 -386
- package/esm/bridge/types.d.ts.map +0 -1
- package/esm/bundler/bundler.d.ts +0 -208
- package/esm/bundler/bundler.d.ts.map +0 -1
- package/esm/bundler/cache.d.ts +0 -173
- package/esm/bundler/cache.d.ts.map +0 -1
- package/esm/bundler/file-cache/component-builder.d.ts +0 -167
- package/esm/bundler/file-cache/component-builder.d.ts.map +0 -1
- package/esm/bundler/file-cache/hash-calculator.d.ts +0 -155
- package/esm/bundler/file-cache/hash-calculator.d.ts.map +0 -1
- package/esm/bundler/file-cache/index.d.ts +0 -12
- package/esm/bundler/file-cache/index.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/filesystem.d.ts +0 -149
- package/esm/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/index.d.ts +0 -11
- package/esm/bundler/file-cache/storage/index.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/interface.d.ts +0 -152
- package/esm/bundler/file-cache/storage/interface.d.ts.map +0 -1
- package/esm/bundler/file-cache/storage/redis.d.ts +0 -139
- package/esm/bundler/file-cache/storage/redis.d.ts.map +0 -1
- package/esm/bundler/index.d.ts +0 -43
- package/esm/bundler/index.d.ts.map +0 -1
- package/esm/bundler/sandbox/enclave-adapter.d.ts +0 -121
- package/esm/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
- package/esm/bundler/sandbox/executor.d.ts +0 -14
- package/esm/bundler/sandbox/executor.d.ts.map +0 -1
- package/esm/bundler/sandbox/policy.d.ts +0 -62
- package/esm/bundler/sandbox/policy.d.ts.map +0 -1
- package/esm/bundler/types.d.ts +0 -702
- package/esm/bundler/types.d.ts.map +0 -1
- package/esm/components/alert.d.ts +0 -66
- package/esm/components/alert.d.ts.map +0 -1
- package/esm/components/alert.schema.d.ts +0 -98
- package/esm/components/alert.schema.d.ts.map +0 -1
- package/esm/components/avatar.d.ts +0 -77
- package/esm/components/avatar.d.ts.map +0 -1
- package/esm/components/avatar.schema.d.ts +0 -170
- package/esm/components/avatar.schema.d.ts.map +0 -1
- package/esm/components/badge.d.ts +0 -64
- package/esm/components/badge.d.ts.map +0 -1
- package/esm/components/badge.schema.d.ts +0 -91
- package/esm/components/badge.schema.d.ts.map +0 -1
- package/esm/components/button.d.ts +0 -100
- package/esm/components/button.d.ts.map +0 -1
- package/esm/components/button.schema.d.ts +0 -120
- package/esm/components/button.schema.d.ts.map +0 -1
- package/esm/components/card.d.ts +0 -53
- package/esm/components/card.d.ts.map +0 -1
- package/esm/components/card.schema.d.ts +0 -93
- package/esm/components/card.schema.d.ts.map +0 -1
- package/esm/components/form.d.ts +0 -212
- package/esm/components/form.d.ts.map +0 -1
- package/esm/components/form.schema.d.ts +0 -365
- package/esm/components/form.schema.d.ts.map +0 -1
- package/esm/components/index.d.ts +0 -29
- package/esm/components/index.d.ts.map +0 -1
- package/esm/components/list.d.ts +0 -121
- package/esm/components/list.d.ts.map +0 -1
- package/esm/components/list.schema.d.ts +0 -129
- package/esm/components/list.schema.d.ts.map +0 -1
- package/esm/components/modal.d.ts +0 -100
- package/esm/components/modal.d.ts.map +0 -1
- package/esm/components/modal.schema.d.ts +0 -151
- package/esm/components/modal.schema.d.ts.map +0 -1
- package/esm/components/table.d.ts +0 -91
- package/esm/components/table.d.ts.map +0 -1
- package/esm/components/table.schema.d.ts +0 -123
- package/esm/components/table.schema.d.ts.map +0 -1
- package/esm/index.d.ts +0 -40
- package/esm/index.d.ts.map +0 -1
- package/esm/layouts/base.d.ts +0 -86
- package/esm/layouts/base.d.ts.map +0 -1
- package/esm/layouts/index.d.ts +0 -8
- package/esm/layouts/index.d.ts.map +0 -1
- package/esm/layouts/presets.d.ts +0 -134
- package/esm/layouts/presets.d.ts.map +0 -1
- package/esm/pages/consent.d.ts +0 -117
- package/esm/pages/consent.d.ts.map +0 -1
- package/esm/pages/error.d.ts +0 -101
- package/esm/pages/error.d.ts.map +0 -1
- package/esm/pages/index.d.ts +0 -9
- package/esm/pages/index.d.ts.map +0 -1
- package/esm/pages/index.js +0 -1036
- package/esm/react/Alert.d.ts +0 -101
- package/esm/react/Alert.d.ts.map +0 -1
- package/esm/react/Badge.d.ts +0 -100
- package/esm/react/Badge.d.ts.map +0 -1
- package/esm/react/Button.d.ts +0 -108
- package/esm/react/Button.d.ts.map +0 -1
- package/esm/react/Card.d.ts +0 -103
- package/esm/react/Card.d.ts.map +0 -1
- package/esm/react/hooks/context.d.ts +0 -179
- package/esm/react/hooks/context.d.ts.map +0 -1
- package/esm/react/hooks/index.d.ts +0 -42
- package/esm/react/hooks/index.d.ts.map +0 -1
- package/esm/react/hooks/tools.d.ts +0 -284
- package/esm/react/hooks/tools.d.ts.map +0 -1
- package/esm/react/index.d.ts +0 -80
- package/esm/react/index.d.ts.map +0 -1
- package/esm/react/index.js +0 -3124
- package/esm/react/types.d.ts +0 -105
- package/esm/react/types.d.ts.map +0 -1
- package/esm/react/utils.d.ts +0 -43
- package/esm/react/utils.d.ts.map +0 -1
- package/esm/render/index.d.ts +0 -8
- package/esm/render/index.d.ts.map +0 -1
- package/esm/render/prerender.d.ts +0 -57
- package/esm/render/prerender.d.ts.map +0 -1
- package/esm/renderers/index.d.ts +0 -21
- package/esm/renderers/index.d.ts.map +0 -1
- package/esm/renderers/index.js +0 -381
- package/esm/renderers/react.adapter.d.ts +0 -70
- package/esm/renderers/react.adapter.d.ts.map +0 -1
- package/esm/renderers/react.renderer.d.ts +0 -96
- package/esm/renderers/react.renderer.d.ts.map +0 -1
- package/esm/universal/UniversalApp.d.ts +0 -108
- package/esm/universal/UniversalApp.d.ts.map +0 -1
- package/esm/universal/cached-runtime.d.ts +0 -115
- package/esm/universal/cached-runtime.d.ts.map +0 -1
- package/esm/universal/context.d.ts +0 -122
- package/esm/universal/context.d.ts.map +0 -1
- package/esm/universal/index.d.ts +0 -57
- package/esm/universal/index.d.ts.map +0 -1
- package/esm/universal/renderers/html.renderer.d.ts +0 -37
- package/esm/universal/renderers/html.renderer.d.ts.map +0 -1
- package/esm/universal/renderers/index.d.ts +0 -112
- package/esm/universal/renderers/index.d.ts.map +0 -1
- package/esm/universal/renderers/markdown.renderer.d.ts +0 -33
- package/esm/universal/renderers/markdown.renderer.d.ts.map +0 -1
- package/esm/universal/renderers/mdx.renderer.d.ts +0 -38
- package/esm/universal/renderers/mdx.renderer.d.ts.map +0 -1
- package/esm/universal/renderers/react.renderer.d.ts +0 -46
- package/esm/universal/renderers/react.renderer.d.ts.map +0 -1
- package/esm/universal/runtime-builder.d.ts +0 -33
- package/esm/universal/runtime-builder.d.ts.map +0 -1
- package/esm/universal/store.d.ts +0 -135
- package/esm/universal/store.d.ts.map +0 -1
- package/esm/universal/types.d.ts +0 -199
- package/esm/universal/types.d.ts.map +0 -1
- package/esm/web-components/core/attribute-parser.d.ts +0 -82
- package/esm/web-components/core/attribute-parser.d.ts.map +0 -1
- package/esm/web-components/core/base-element.d.ts +0 -197
- package/esm/web-components/core/base-element.d.ts.map +0 -1
- package/esm/web-components/core/index.d.ts +0 -9
- package/esm/web-components/core/index.d.ts.map +0 -1
- package/esm/web-components/elements/fmcp-alert.d.ts +0 -46
- package/esm/web-components/elements/fmcp-alert.d.ts.map +0 -1
- package/esm/web-components/elements/fmcp-badge.d.ts +0 -47
- package/esm/web-components/elements/fmcp-badge.d.ts.map +0 -1
- package/esm/web-components/elements/fmcp-button.d.ts +0 -117
- package/esm/web-components/elements/fmcp-button.d.ts.map +0 -1
- package/esm/web-components/elements/fmcp-card.d.ts +0 -53
- package/esm/web-components/elements/fmcp-card.d.ts.map +0 -1
- package/esm/web-components/elements/fmcp-input.d.ts +0 -96
- package/esm/web-components/elements/fmcp-input.d.ts.map +0 -1
- package/esm/web-components/elements/fmcp-select.d.ts +0 -100
- package/esm/web-components/elements/fmcp-select.d.ts.map +0 -1
- package/esm/web-components/elements/index.d.ts +0 -13
- package/esm/web-components/elements/index.d.ts.map +0 -1
- package/esm/web-components/index.d.ts +0 -50
- package/esm/web-components/index.d.ts.map +0 -1
- package/esm/web-components/register.d.ts +0 -57
- package/esm/web-components/register.d.ts.map +0 -1
- package/esm/web-components/types.d.ts +0 -122
- package/esm/web-components/types.d.ts.map +0 -1
- package/esm/widgets/index.d.ts +0 -8
- package/esm/widgets/index.d.ts.map +0 -1
- package/esm/widgets/index.js +0 -883
- package/esm/widgets/progress.d.ts +0 -133
- package/esm/widgets/progress.d.ts.map +0 -1
- package/esm/widgets/resource.d.ts +0 -163
- package/esm/widgets/resource.d.ts.map +0 -1
- package/pages/consent.d.ts +0 -117
- package/pages/consent.d.ts.map +0 -1
- package/pages/error.d.ts +0 -101
- package/pages/error.d.ts.map +0 -1
- package/pages/index.d.ts +0 -9
- package/pages/index.d.ts.map +0 -1
- package/pages/index.js +0 -1065
- package/react/utils.d.ts +0 -43
- package/react/utils.d.ts.map +0 -1
- package/widgets/index.d.ts +0 -8
- package/widgets/index.d.ts.map +0 -1
- package/widgets/index.js +0 -910
- package/widgets/progress.d.ts +0 -133
- package/widgets/progress.d.ts.map +0 -1
- package/widgets/resource.d.ts +0 -163
- package/widgets/resource.d.ts.map +0 -1
- /package/esm/components/{index.js → index.mjs} +0 -0
- /package/esm/render/{index.js → index.mjs} +0 -0
- /package/esm/web-components/{index.js → index.mjs} +0 -0
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file tools.tsx
|
|
3
|
-
* @description React hooks for MCP tool interactions.
|
|
4
|
-
*
|
|
5
|
-
* Provides hooks for calling tools, accessing tool input/output,
|
|
6
|
-
* and managing tool execution state.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* import { useCallTool, useToolInput, useToolOutput } from '@frontmcp/ui/react';
|
|
11
|
-
*
|
|
12
|
-
* function WeatherWidget() {
|
|
13
|
-
* const input = useToolInput<{ location: string }>();
|
|
14
|
-
* const output = useToolOutput<WeatherData>();
|
|
15
|
-
* const [callWeather, { data, loading, error }] = useCallTool<WeatherData>('get_weather');
|
|
16
|
-
*
|
|
17
|
-
* return (
|
|
18
|
-
* <div>
|
|
19
|
-
* <p>Location: {input?.location}</p>
|
|
20
|
-
* <button onClick={() => callWeather({ location: 'NYC' })}>
|
|
21
|
-
* Get Weather
|
|
22
|
-
* </button>
|
|
23
|
-
* {loading && <p>Loading...</p>}
|
|
24
|
-
* {data && <p>Temperature: {data.temperature}</p>}
|
|
25
|
-
* </div>
|
|
26
|
-
* );
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @module @frontmcp/ui/react/hooks
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* State for tool execution.
|
|
34
|
-
*/
|
|
35
|
-
export interface ToolState<T = unknown> {
|
|
36
|
-
/** Tool result data */
|
|
37
|
-
data: T | null;
|
|
38
|
-
/** Whether the tool is currently executing */
|
|
39
|
-
loading: boolean;
|
|
40
|
-
/** Execution error, if any */
|
|
41
|
-
error: Error | null;
|
|
42
|
-
/** Whether the tool has been called at least once */
|
|
43
|
-
called: boolean;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Options for useCallTool hook.
|
|
47
|
-
*/
|
|
48
|
-
export interface UseCallToolOptions {
|
|
49
|
-
/** Automatically reset state when tool name changes */
|
|
50
|
-
resetOnToolChange?: boolean;
|
|
51
|
-
/** Callback when tool execution succeeds */
|
|
52
|
-
onSuccess?: (data: unknown) => void;
|
|
53
|
-
/** Callback when tool execution fails */
|
|
54
|
-
onError?: (error: Error) => void;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Return type for useCallTool hook.
|
|
58
|
-
*/
|
|
59
|
-
export type UseCallToolReturn<TInput extends object, TOutput> = [
|
|
60
|
-
/** Function to call the tool */
|
|
61
|
-
(args: TInput) => Promise<TOutput | null>,
|
|
62
|
-
/** Current tool state */
|
|
63
|
-
ToolState<TOutput>,
|
|
64
|
-
/** Reset state to initial values */
|
|
65
|
-
() => void
|
|
66
|
-
];
|
|
67
|
-
/**
|
|
68
|
-
* Hook to get the current tool input arguments.
|
|
69
|
-
* Returns the arguments passed to the tool when it was invoked.
|
|
70
|
-
*
|
|
71
|
-
* @typeParam T - Expected shape of the tool input
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```tsx
|
|
75
|
-
* interface WeatherInput {
|
|
76
|
-
* location: string;
|
|
77
|
-
* units?: 'celsius' | 'fahrenheit';
|
|
78
|
-
* }
|
|
79
|
-
*
|
|
80
|
-
* function WeatherWidget() {
|
|
81
|
-
* const input = useToolInput<WeatherInput>();
|
|
82
|
-
*
|
|
83
|
-
* return (
|
|
84
|
-
* <div>
|
|
85
|
-
* <h1>Weather for {input?.location}</h1>
|
|
86
|
-
* <p>Units: {input?.units ?? 'celsius'}</p>
|
|
87
|
-
* </div>
|
|
88
|
-
* );
|
|
89
|
-
* }
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export declare function useToolInput<T extends object = Record<string, unknown>>(): T | null;
|
|
93
|
-
/**
|
|
94
|
-
* Hook to get the current tool output/result.
|
|
95
|
-
* Returns the result data from the tool execution.
|
|
96
|
-
*
|
|
97
|
-
* @typeParam T - Expected shape of the tool output
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```tsx
|
|
101
|
-
* interface WeatherOutput {
|
|
102
|
-
* temperature: number;
|
|
103
|
-
* condition: string;
|
|
104
|
-
* humidity: number;
|
|
105
|
-
* }
|
|
106
|
-
*
|
|
107
|
-
* function WeatherDisplay() {
|
|
108
|
-
* const output = useToolOutput<WeatherOutput>();
|
|
109
|
-
*
|
|
110
|
-
* if (!output) return <div>No data</div>;
|
|
111
|
-
*
|
|
112
|
-
* return (
|
|
113
|
-
* <div>
|
|
114
|
-
* <p>Temperature: {output.temperature}°</p>
|
|
115
|
-
* <p>Condition: {output.condition}</p>
|
|
116
|
-
* </div>
|
|
117
|
-
* );
|
|
118
|
-
* }
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
export declare function useToolOutput<T = unknown>(): T | null;
|
|
122
|
-
/**
|
|
123
|
-
* Hook to get the structured content from the tool output.
|
|
124
|
-
* This is the parsed/structured version of the tool result.
|
|
125
|
-
*
|
|
126
|
-
* @typeParam T - Expected shape of the structured content
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```tsx
|
|
130
|
-
* interface WeatherData {
|
|
131
|
-
* forecast: Array<{ day: string; temp: number }>;
|
|
132
|
-
* }
|
|
133
|
-
*
|
|
134
|
-
* function ForecastDisplay() {
|
|
135
|
-
* const content = useStructuredContent<WeatherData>();
|
|
136
|
-
*
|
|
137
|
-
* return (
|
|
138
|
-
* <ul>
|
|
139
|
-
* {content?.forecast.map(day => (
|
|
140
|
-
* <li key={day.day}>{day.day}: {day.temp}°</li>
|
|
141
|
-
* ))}
|
|
142
|
-
* </ul>
|
|
143
|
-
* );
|
|
144
|
-
* }
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
export declare function useStructuredContent<T = unknown>(): T | null;
|
|
148
|
-
/**
|
|
149
|
-
* Hook to call an MCP tool with loading and error state management.
|
|
150
|
-
*
|
|
151
|
-
* Returns a tuple with:
|
|
152
|
-
* 1. The call function
|
|
153
|
-
* 2. State object (data, loading, error, called)
|
|
154
|
-
* 3. Reset function
|
|
155
|
-
*
|
|
156
|
-
* @typeParam TInput - Shape of the tool input arguments
|
|
157
|
-
* @typeParam TOutput - Expected shape of the tool output
|
|
158
|
-
*
|
|
159
|
-
* @example Basic usage
|
|
160
|
-
* ```tsx
|
|
161
|
-
* function WeatherButton() {
|
|
162
|
-
* const [getWeather, { data, loading, error }] = useCallTool<
|
|
163
|
-
* { location: string },
|
|
164
|
-
* { temperature: number; condition: string }
|
|
165
|
-
* >('get_weather');
|
|
166
|
-
*
|
|
167
|
-
* return (
|
|
168
|
-
* <div>
|
|
169
|
-
* <button
|
|
170
|
-
* onClick={() => getWeather({ location: 'San Francisco' })}
|
|
171
|
-
* disabled={loading}
|
|
172
|
-
* >
|
|
173
|
-
* {loading ? 'Loading...' : 'Get Weather'}
|
|
174
|
-
* </button>
|
|
175
|
-
* {error && <p className="error">{error.message}</p>}
|
|
176
|
-
* {data && <p>{data.temperature}° - {data.condition}</p>}
|
|
177
|
-
* </div>
|
|
178
|
-
* );
|
|
179
|
-
* }
|
|
180
|
-
* ```
|
|
181
|
-
*
|
|
182
|
-
* @example With callbacks
|
|
183
|
-
* ```tsx
|
|
184
|
-
* function WeatherWidget() {
|
|
185
|
-
* const [getWeather, state, reset] = useCallTool('get_weather', {
|
|
186
|
-
* onSuccess: (data) => console.log('Got weather:', data),
|
|
187
|
-
* onError: (err) => console.error('Failed:', err),
|
|
188
|
-
* });
|
|
189
|
-
*
|
|
190
|
-
* return (
|
|
191
|
-
* <div>
|
|
192
|
-
* <button onClick={() => getWeather({ location: 'NYC' })}>
|
|
193
|
-
* Get Weather
|
|
194
|
-
* </button>
|
|
195
|
-
* <button onClick={reset}>Reset</button>
|
|
196
|
-
* </div>
|
|
197
|
-
* );
|
|
198
|
-
* }
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
export declare function useCallTool<TInput extends object = Record<string, unknown>, TOutput = unknown>(toolName: string, options?: UseCallToolOptions): UseCallToolReturn<TInput, TOutput>;
|
|
202
|
-
/**
|
|
203
|
-
* Hook to manage multiple tool calls.
|
|
204
|
-
* Useful when you need to track state for multiple tools.
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```tsx
|
|
208
|
-
* function MultiToolWidget() {
|
|
209
|
-
* const tools = useToolCalls({
|
|
210
|
-
* weather: 'get_weather',
|
|
211
|
-
* news: 'get_news',
|
|
212
|
-
* stocks: 'get_stocks',
|
|
213
|
-
* });
|
|
214
|
-
*
|
|
215
|
-
* return (
|
|
216
|
-
* <div>
|
|
217
|
-
* <button onClick={() => tools.weather.call({ location: 'NYC' })}>
|
|
218
|
-
* Get Weather
|
|
219
|
-
* </button>
|
|
220
|
-
* <button onClick={() => tools.news.call({ topic: 'tech' })}>
|
|
221
|
-
* Get News
|
|
222
|
-
* </button>
|
|
223
|
-
* {tools.weather.loading && <p>Loading weather...</p>}
|
|
224
|
-
* {tools.news.data && <p>News: {tools.news.data.headline}</p>}
|
|
225
|
-
* </div>
|
|
226
|
-
* );
|
|
227
|
-
* }
|
|
228
|
-
* ```
|
|
229
|
-
*/
|
|
230
|
-
export declare function useToolCalls<T extends Record<string, string>>(toolMap: T): {
|
|
231
|
-
[K in keyof T]: {
|
|
232
|
-
call: (args: Record<string, unknown>) => Promise<unknown>;
|
|
233
|
-
data: unknown;
|
|
234
|
-
loading: boolean;
|
|
235
|
-
error: Error | null;
|
|
236
|
-
reset: () => void;
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
/**
|
|
240
|
-
* Hook to send a message to the conversation.
|
|
241
|
-
* Returns a function and state for sending messages.
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* ```tsx
|
|
245
|
-
* function ChatWidget() {
|
|
246
|
-
* const [sendMessage, { loading, error, sent }] = useSendMessage();
|
|
247
|
-
*
|
|
248
|
-
* return (
|
|
249
|
-
* <button
|
|
250
|
-
* onClick={() => sendMessage('Here is the weather update!')}
|
|
251
|
-
* disabled={loading}
|
|
252
|
-
* >
|
|
253
|
-
* {loading ? 'Sending...' : 'Send Update'}
|
|
254
|
-
* </button>
|
|
255
|
-
* );
|
|
256
|
-
* }
|
|
257
|
-
* ```
|
|
258
|
-
*/
|
|
259
|
-
export declare function useSendMessage(): [
|
|
260
|
-
(content: string) => Promise<void>,
|
|
261
|
-
{
|
|
262
|
-
loading: boolean;
|
|
263
|
-
error: Error | null;
|
|
264
|
-
sent: boolean;
|
|
265
|
-
}
|
|
266
|
-
];
|
|
267
|
-
/**
|
|
268
|
-
* Hook to open external links via the bridge.
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* ```tsx
|
|
272
|
-
* function LinkButton() {
|
|
273
|
-
* const openLink = useOpenLink();
|
|
274
|
-
*
|
|
275
|
-
* return (
|
|
276
|
-
* <button onClick={() => openLink('https://example.com')}>
|
|
277
|
-
* Open Website
|
|
278
|
-
* </button>
|
|
279
|
-
* );
|
|
280
|
-
* }
|
|
281
|
-
* ```
|
|
282
|
-
*/
|
|
283
|
-
export declare function useOpenLink(): (url: string) => Promise<void>;
|
|
284
|
-
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/tools.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AASH;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACpC,uBAAuB;IACvB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,qDAAqD;IACrD,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4CAA4C;IAC5C,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,MAAM,EAAE,OAAO,IAAI;IAC9D,gCAAgC;IAChC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IACzC,yBAAyB;IACzB,SAAS,CAAC,OAAO,CAAC;IAClB,oCAAoC;IACpC,MAAM,IAAI;CACX,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAYnF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,GAAG,IAAI,CA0BrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,GAAG,IAAI,CAgB5D;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,EAC5F,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAgFpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3D,OAAO,EAAE,CAAC,GACT;KACA,CAAC,IAAI,MAAM,CAAC,GAAG;QACd,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,EAAE,OAAO,CAAC;QACd,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QACpB,KAAK,EAAE,MAAM,IAAI,CAAC;KACnB;CACF,CAuFA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,IAAI;IAChC,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;IAClC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE;CACzD,CA6BA;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,IAAI,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAc5D"}
|
package/esm/react/index.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file index.ts
|
|
3
|
-
* @description React components and hooks for FrontMCP UI.
|
|
4
|
-
*
|
|
5
|
-
* These are pure React components that can be used:
|
|
6
|
-
* 1. As regular React components in your app
|
|
7
|
-
* 2. To generate static HTML via render functions
|
|
8
|
-
* 3. With hooks to access the MCP bridge
|
|
9
|
-
*
|
|
10
|
-
* @example React usage
|
|
11
|
-
* ```tsx
|
|
12
|
-
* import { Card, Badge, Button, Alert } from '@frontmcp/ui/react';
|
|
13
|
-
*
|
|
14
|
-
* function App() {
|
|
15
|
-
* return (
|
|
16
|
-
* <Card title="Welcome" variant="elevated">
|
|
17
|
-
* <Badge variant="success">New</Badge>
|
|
18
|
-
* <p>Card content here</p>
|
|
19
|
-
* <Button variant="primary">Click Me</Button>
|
|
20
|
-
* </Card>
|
|
21
|
-
* );
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @example Static HTML generation
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import { renderCard, renderBadge } from '@frontmcp/ui/react';
|
|
28
|
-
*
|
|
29
|
-
* const cardHtml = await renderCard({
|
|
30
|
-
* title: 'Welcome',
|
|
31
|
-
* variant: 'elevated',
|
|
32
|
-
* children: '<p>Content</p>',
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @example Using hooks with the MCP bridge
|
|
37
|
-
* ```tsx
|
|
38
|
-
* import {
|
|
39
|
-
* McpBridgeProvider,
|
|
40
|
-
* useMcpBridge,
|
|
41
|
-
* useToolInput,
|
|
42
|
-
* useCallTool,
|
|
43
|
-
* useTheme,
|
|
44
|
-
* } from '@frontmcp/ui/react';
|
|
45
|
-
*
|
|
46
|
-
* function App() {
|
|
47
|
-
* return (
|
|
48
|
-
* <McpBridgeProvider>
|
|
49
|
-
* <WeatherWidget />
|
|
50
|
-
* </McpBridgeProvider>
|
|
51
|
-
* );
|
|
52
|
-
* }
|
|
53
|
-
*
|
|
54
|
-
* function WeatherWidget() {
|
|
55
|
-
* const input = useToolInput<{ location: string }>();
|
|
56
|
-
* const theme = useTheme();
|
|
57
|
-
* const [getWeather, { data, loading }] = useCallTool('get_weather');
|
|
58
|
-
*
|
|
59
|
-
* return (
|
|
60
|
-
* <Card title={`Weather for ${input?.location}`} variant={theme === 'dark' ? 'elevated' : 'default'}>
|
|
61
|
-
* {loading ? 'Loading...' : data?.temperature}
|
|
62
|
-
* </Card>
|
|
63
|
-
* );
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @module @frontmcp/ui/react
|
|
68
|
-
*/
|
|
69
|
-
export { Card, renderCard, renderCardSync } from './Card';
|
|
70
|
-
export { Badge, renderBadge, renderBadgeSync } from './Badge';
|
|
71
|
-
export { Button, renderButton, renderButtonSync } from './Button';
|
|
72
|
-
export { Alert, renderAlert, renderAlertSync } from './Alert';
|
|
73
|
-
export { McpBridgeProvider, useMcpBridgeContext, useMcpBridge, useTheme, useDisplayMode, useHostContext, useCapability, useToolInput, useToolOutput, useStructuredContent, useCallTool, useToolCalls, useSendMessage, useOpenLink, type McpBridgeContextValue, type McpBridgeProviderProps, type ToolState, type UseCallToolOptions, type UseCallToolReturn, } from './hooks';
|
|
74
|
-
export type { CardProps, CardRenderProps } from './Card';
|
|
75
|
-
export type { BadgeProps, BadgeRenderProps } from './Badge';
|
|
76
|
-
export type { ButtonProps, ButtonRenderProps } from './Button';
|
|
77
|
-
export type { AlertProps, AlertRenderProps } from './Alert';
|
|
78
|
-
export type { FmcpCard, FmcpBadge, FmcpButton, FmcpAlert, FmcpInput, FmcpSelect } from './types';
|
|
79
|
-
export { renderChildrenToString, isBrowser, isServer } from './utils';
|
|
80
|
-
//# sourceMappingURL=index.d.ts.map
|
package/esm/react/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAGH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG9D,OAAO,EAEL,iBAAiB,EAEjB,mBAAmB,EACnB,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,cAAc,EACd,aAAa,EAEb,YAAY,EACZ,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,WAAW,EAEX,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzD,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC5D,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC/D,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAM5D,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGjG,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
|