@leanmcp/ui 0.3.5 → 0.3.7-alpha.6.6dae082
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 +59 -52
- package/dist/{chunk-57VDL5UC.js → chunk-55345F7G.js} +2 -2
- package/dist/chunk-55345F7G.js.map +1 -0
- package/dist/{chunk-5RGEQPF3.mjs → chunk-XLPJFQ74.mjs} +2 -2
- package/dist/chunk-XLPJFQ74.mjs.map +1 -0
- package/dist/index.d.mts +28 -28
- package/dist/index.d.ts +28 -28
- package/dist/index.js +193 -193
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/server.js +13 -13
- package/dist/server.mjs +1 -1
- package/package.json +106 -106
- package/dist/chunk-57VDL5UC.js.map +0 -1
- package/dist/chunk-5RGEQPF3.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
<a href="https://x.com/LeanMcp">
|
|
28
28
|
<img src="https://img.shields.io/badge/@LeanMCP-f5f5f5?logo=x&logoColor=000000" />
|
|
29
29
|
</a>
|
|
30
|
+
<a href="https://leanmcp.com/">
|
|
31
|
+
<img src="https://img.shields.io/badge/Website-leanmcp-0A66C2?" />
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://deepwiki.com/LeanMCP/leanmcp-sdk"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
|
|
30
34
|
</p>
|
|
31
35
|
|
|
32
36
|
## Features
|
|
@@ -65,57 +69,57 @@ function MyApp() {
|
|
|
65
69
|
|
|
66
70
|
### MCP-Native Components
|
|
67
71
|
|
|
68
|
-
| Component
|
|
69
|
-
|
|
70
|
-
| `ToolButton`
|
|
71
|
-
| `ToolSelect`
|
|
72
|
-
| `ToolInput`
|
|
73
|
-
| `ToolForm`
|
|
74
|
-
| `ToolDataGrid`
|
|
75
|
-
| `ResourceView`
|
|
76
|
-
| `StreamingContent` | Render streaming/partial tool data
|
|
72
|
+
| Component | Description |
|
|
73
|
+
| ------------------ | --------------------------------------------------------------- |
|
|
74
|
+
| `ToolButton` | Button with tool execution, confirmation, result display |
|
|
75
|
+
| `ToolSelect` | Select with tool-based options and selection callbacks |
|
|
76
|
+
| `ToolInput` | Input with debounced search and autocomplete |
|
|
77
|
+
| `ToolForm` | Form with multiple field types (text, select, checkbox, slider) |
|
|
78
|
+
| `ToolDataGrid` | Table with server-side pagination, sorting, row actions |
|
|
79
|
+
| `ResourceView` | Display MCP server resources with auto-refresh |
|
|
80
|
+
| `StreamingContent` | Render streaming/partial tool data |
|
|
77
81
|
|
|
78
82
|
### Utility Components
|
|
79
83
|
|
|
80
|
-
| Component
|
|
81
|
-
|
|
82
|
-
| `RequireConnection` | Guard wrapper for MCP connection state
|
|
84
|
+
| Component | Description |
|
|
85
|
+
| ------------------- | ----------------------------------------- |
|
|
86
|
+
| `RequireConnection` | Guard wrapper for MCP connection state |
|
|
83
87
|
| `ToolErrorBoundary` | Error boundary with retry for tool errors |
|
|
84
|
-
| `ToolProvider`
|
|
88
|
+
| `ToolProvider` | Scoped configuration context |
|
|
85
89
|
|
|
86
90
|
## Hooks
|
|
87
91
|
|
|
88
|
-
| Hook
|
|
89
|
-
|
|
90
|
-
| `useTool`
|
|
91
|
-
| `useToolStream`
|
|
92
|
-
| `useResource`
|
|
93
|
-
| `useMessage`
|
|
94
|
-
| `useHostContext` | Access host theme and viewport
|
|
92
|
+
| Hook | Description |
|
|
93
|
+
| ---------------- | -------------------------------------------- |
|
|
94
|
+
| `useTool` | Call tools with retry, abort, transformation |
|
|
95
|
+
| `useToolStream` | Handle streaming tool input |
|
|
96
|
+
| `useResource` | Read MCP resources with auto-refresh |
|
|
97
|
+
| `useMessage` | Send messages to host chat |
|
|
98
|
+
| `useHostContext` | Access host theme and viewport |
|
|
95
99
|
|
|
96
100
|
### GPT Apps SDK Hooks
|
|
97
101
|
|
|
98
102
|
These hooks provide access to the ChatGPT Apps SDK globals (compatible with OpenAI's `window.openai` API):
|
|
99
103
|
|
|
100
|
-
| Hook
|
|
101
|
-
|
|
102
|
-
| `useToolOutput`
|
|
103
|
-
| `useToolInput`
|
|
104
|
-
| `useWidgetState`
|
|
105
|
-
| `useToolResponseMetadata` | Access `_meta` from the tool response
|
|
106
|
-
| `useOpenAiGlobal`
|
|
104
|
+
| Hook | Description |
|
|
105
|
+
| ------------------------- | ----------------------------------------------------------- |
|
|
106
|
+
| `useToolOutput` | Access `structuredContent` from the tool response |
|
|
107
|
+
| `useToolInput` | Access input arguments passed to the tool |
|
|
108
|
+
| `useWidgetState` | Read/write persistent widget state across sessions |
|
|
109
|
+
| `useToolResponseMetadata` | Access `_meta` from the tool response |
|
|
110
|
+
| `useOpenAiGlobal` | Low-level hook to subscribe to any `window.openai` property |
|
|
107
111
|
|
|
108
112
|
## Examples
|
|
109
113
|
|
|
110
114
|
### ToolButton with Confirmation
|
|
111
115
|
|
|
112
116
|
```tsx
|
|
113
|
-
<ToolButton
|
|
114
|
-
tool="delete-item"
|
|
117
|
+
<ToolButton
|
|
118
|
+
tool="delete-item"
|
|
115
119
|
args={{ id: item.id }}
|
|
116
|
-
confirm={{
|
|
120
|
+
confirm={{
|
|
117
121
|
title: 'Delete Item?',
|
|
118
|
-
description: 'This cannot be undone.'
|
|
122
|
+
description: 'This cannot be undone.',
|
|
119
123
|
}}
|
|
120
124
|
variant="destructive"
|
|
121
125
|
>
|
|
@@ -128,10 +132,12 @@ These hooks provide access to the ChatGPT Apps SDK globals (compatible with Open
|
|
|
128
132
|
```tsx
|
|
129
133
|
<ToolSelect
|
|
130
134
|
optionsTool="list-categories"
|
|
131
|
-
transformOptions={(r) =>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
transformOptions={(r) =>
|
|
136
|
+
r.categories.map((c) => ({
|
|
137
|
+
value: c.id,
|
|
138
|
+
label: c.name,
|
|
139
|
+
}))
|
|
140
|
+
}
|
|
135
141
|
onSelectTool="set-category"
|
|
136
142
|
argName="categoryId"
|
|
137
143
|
/>
|
|
@@ -145,12 +151,10 @@ These hooks provide access to the ChatGPT Apps SDK globals (compatible with Open
|
|
|
145
151
|
columns={[
|
|
146
152
|
{ key: 'name', header: 'Name', sortable: true },
|
|
147
153
|
{ key: 'email', header: 'Email' },
|
|
148
|
-
{ key: 'status', header: 'Status' }
|
|
154
|
+
{ key: 'status', header: 'Status' },
|
|
149
155
|
]}
|
|
150
156
|
transformData={(r) => ({ rows: r.users, total: r.total })}
|
|
151
|
-
rowActions={[
|
|
152
|
-
{ label: 'Edit', tool: 'edit-user' }
|
|
153
|
-
]}
|
|
157
|
+
rowActions={[{ label: 'Edit', tool: 'edit-user' }]}
|
|
154
158
|
pagination
|
|
155
159
|
/>
|
|
156
160
|
```
|
|
@@ -162,13 +166,16 @@ These hooks provide access to the ChatGPT Apps SDK globals (compatible with Open
|
|
|
162
166
|
toolName="create-item"
|
|
163
167
|
fields={[
|
|
164
168
|
{ name: 'title', label: 'Title', required: true },
|
|
165
|
-
{
|
|
169
|
+
{
|
|
170
|
+
name: 'priority',
|
|
171
|
+
label: 'Priority',
|
|
172
|
+
type: 'select',
|
|
166
173
|
options: [
|
|
167
174
|
{ value: 'low', label: 'Low' },
|
|
168
|
-
{ value: 'high', label: 'High' }
|
|
169
|
-
]
|
|
175
|
+
{ value: 'high', label: 'High' },
|
|
176
|
+
],
|
|
170
177
|
},
|
|
171
|
-
{ name: 'notify', label: 'Send notifications', type: 'switch' }
|
|
178
|
+
{ name: 'notify', label: 'Send notifications', type: 'switch' },
|
|
172
179
|
]}
|
|
173
180
|
showSuccessToast
|
|
174
181
|
/>
|
|
@@ -186,9 +193,9 @@ import { UIApp } from '@leanmcp/core';
|
|
|
186
193
|
|
|
187
194
|
export class DashboardService {
|
|
188
195
|
@UIApp({
|
|
189
|
-
component: './Dashboard',
|
|
196
|
+
component: './Dashboard', // Path relative to this file
|
|
190
197
|
name: 'dashboard',
|
|
191
|
-
title: 'Analytics Dashboard'
|
|
198
|
+
title: 'Analytics Dashboard',
|
|
192
199
|
})
|
|
193
200
|
dashboard() {}
|
|
194
201
|
}
|
|
@@ -203,8 +210,8 @@ import { GPTApp } from '@leanmcp/ui';
|
|
|
203
210
|
|
|
204
211
|
export class SlackService {
|
|
205
212
|
@GPTApp({
|
|
206
|
-
component: './SlackApp',
|
|
207
|
-
name: 'slack-composer'
|
|
213
|
+
component: './SlackApp', // Path relative to this file
|
|
214
|
+
name: 'slack-composer',
|
|
208
215
|
})
|
|
209
216
|
slackComposer() {}
|
|
210
217
|
}
|
|
@@ -220,15 +227,15 @@ import { useToolOutput, useWidgetState } from '@leanmcp/ui';
|
|
|
220
227
|
function ChannelsView() {
|
|
221
228
|
// Access the structured data from the tool response
|
|
222
229
|
const toolOutput = useToolOutput<{ channels: Channel[] }>();
|
|
223
|
-
|
|
230
|
+
|
|
224
231
|
// Persist state across the session
|
|
225
232
|
const [state, setState] = useWidgetState({ selectedChannel: null });
|
|
226
|
-
|
|
233
|
+
|
|
227
234
|
if (!toolOutput?.channels) return <div>Loading...</div>;
|
|
228
|
-
|
|
235
|
+
|
|
229
236
|
return (
|
|
230
237
|
<ul>
|
|
231
|
-
{toolOutput.channels.map(ch => (
|
|
238
|
+
{toolOutput.channels.map((ch) => (
|
|
232
239
|
<li key={ch.id} onClick={() => setState({ selectedChannel: ch.id })}>
|
|
233
240
|
{ch.name}
|
|
234
241
|
</li>
|
|
@@ -257,7 +264,7 @@ import { MockAppProvider } from '@leanmcp/ui/testing';
|
|
|
257
264
|
|
|
258
265
|
test('renders tool result', () => {
|
|
259
266
|
render(
|
|
260
|
-
<MockAppProvider
|
|
267
|
+
<MockAppProvider
|
|
261
268
|
toolResult={{ data: 'test' }}
|
|
262
269
|
callTool={async () => ({ content: [{ type: 'text', text: '{}' }] })}
|
|
263
270
|
>
|
|
@@ -134,5 +134,5 @@ exports.getGPTAppMetadata = getGPTAppMetadata;
|
|
|
134
134
|
exports.getGPTAppUri = getGPTAppUri;
|
|
135
135
|
exports.getUIAppMetadata = getUIAppMetadata;
|
|
136
136
|
exports.getUIAppUri = getUIAppUri;
|
|
137
|
-
//# sourceMappingURL=chunk-
|
|
138
|
-
//# sourceMappingURL=chunk-
|
|
137
|
+
//# sourceMappingURL=chunk-55345F7G.js.map
|
|
138
|
+
//# sourceMappingURL=chunk-55345F7G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/decorator/UIApp.ts","../src/decorator/GPTApp.ts"],"names":["UI_APP_COMPONENT_KEY","UI_APP_URI_KEY","UI_APP_OPTIONS_KEY","UIApp","options","target","propertyKey","descriptor","methodName","String","className","name","toLowerCase","replace","uri","Reflect","defineMetadata","component","value","existingMeta","getMetadata","ui","resourceUri","getUIAppMetadata","undefined","getUIAppUri","GPT_APP_COMPONENT_KEY","GPT_APP_URI_KEY","GPT_APP_OPTIONS_KEY","GPTApp","uiMeta","visibility","openAiMeta","widgetAccessible","prefersBorder","widgetDomain","widgetDescription","csp","fileParams","invocation","invoking","invoked","getGPTAppMetadata","getGPTAppUri"],"mappings":";;;;;;AAcO,IAAMA,oBAAAA,GAAuB;AAC7B,IAAMC,cAAAA,GAAiB;AACvB,IAAMC,kBAAAA,GAAqB;AAyC3B,SAASC,MAAMC,OAAAA,EAAqB;AACzC,EAAA,OAAO,CAACC,MAAAA,EAAgBC,WAAAA,EAA8BC,UAAAA,KAAAA;AACpD,IAAA,MAAMC,UAAAA,GAAaC,OAAOH,WAAAA,CAAAA;AAE1B,IAAA,MAAMI,SAAAA,GAAYL,OAAO,WAAA,CAAYM,IAAAA,CAAKC,aAAW,CAAGC,OAAAA,CAAQ,WAAW,EAAA,CAAA;AAG3E,IAAA,MAAMC,MAAMV,OAAAA,CAAQU,GAAAA,IAAO,CAAA,KAAA,EAAQJ,SAAAA,IAAaF,UAAAA,CAAAA,CAAAA;AAGhDO,IAAAA,OAAAA,CAAQC,cAAAA,CAAehB,oBAAAA,EAAsBI,OAAAA,CAAQa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A1B,IAAAA,OAAAA,CAAQC,eACN,WAAA,EACA;MACE,GAAGG,YAAAA;MACH,GAAGa;AACL,KAAA,EACAzB,WAAWW,KAAK,CAAA;AAGlB,IAAA,OAAOX,UAAAA;AACT,EAAA,CAAA;AACF;AAjFgBsB,MAAAA,CAAAA,MAAAA,EAAAA,QAAAA,CAAAA;AAsFT,SAASa,kBAAkBrC,MAAAA,EAAgB;AAChD,EAAA,MAAMY,SAAAA,GAAYF,OAAAA,CAAQK,WAAAA,CAAYM,qBAAAA,EAAuBrB,MAAAA,CAAAA;AAC7D,EAAA,IAAI,CAACY,WAAW,OAAOO,MAAAA;AAEvB,EAAA,OAAO;AACLP,IAAAA,SAAAA;IACAH,GAAAA,EAAKC,OAAAA,CAAQK,WAAAA,CAAYO,eAAAA,EAAiBtB,MAAAA,CAAAA;IAC1C,GAAGU,OAAAA,CAAQK,WAAAA,CAAYQ,mBAAAA,EAAqBvB,MAAAA;AAC9C,GAAA;AACF;AATgBqC,MAAAA,CAAAA,iBAAAA,EAAAA,mBAAAA,CAAAA;AAcT,SAASC,aAAatC,MAAAA,EAAgB;AAC3C,EAAA,OAAOU,OAAAA,CAAQK,WAAAA,CAAYO,eAAAA,EAAiBtB,MAAAA,CAAAA;AAC9C;AAFgBsC,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"chunk-55345F7G.js","sourcesContent":["/**\n * @UIApp Decorator\n *\n * Links an MCP tool to a React UI component.\n * When applied to a tool method, it:\n * 1. Adds _meta.ui/resourceUri to the tool definition\n * 2. Auto-registers a resource that renders the component to HTML\n *\n * This decorator is designed to work with @leanmcp/core decorators.\n */\nimport 'reflect-metadata';\nimport type React from 'react';\n\n// Metadata keys\nexport const UI_APP_COMPONENT_KEY = 'ui:app:component';\nexport const UI_APP_URI_KEY = 'ui:app:uri';\nexport const UI_APP_OPTIONS_KEY = 'ui:app:options';\n\n/**\n * Options for @UIApp decorator\n */\nexport interface UIAppOptions {\n /**\n * React component or path to component file (relative to service file).\n * - Use path string (e.g., './WeatherCard') for CLI build - avoids importing browser code in server\n * - Use component reference for direct SSR rendering\n */\n component: React.ComponentType<any> | string;\n /** Custom resource URI (auto-generated if not provided) */\n uri?: string;\n /** HTML document title */\n title?: string;\n /** Additional CSS styles */\n styles?: string;\n}\n\n/**\n * Decorator that links a tool to a UI component.\n *\n * When the tool is called, the host will fetch the UI resource\n * which returns the component rendered as HTML.\n *\n * @example\n * ```typescript\n * import { Tool } from '@leanmcp/core';\n * import { UIApp } from '@leanmcp/ui';\n * import { WeatherCard } from './WeatherCard';\n *\n * class WeatherService {\n * @Tool({ description: 'Get weather for a city' })\n * @UIApp({ component: WeatherCard })\n * async getWeather(args: { city: string }) {\n * return { city: args.city, temp: 22 };\n * }\n * }\n * ```\n */\nexport function UIApp(options: UIAppOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const methodName = String(propertyKey);\n // Use same pattern as @Resource in @leanmcp/core: className without 'service' suffix\n const className = target.constructor.name.toLowerCase().replace('service', '');\n\n // Generate URI using ui:// scheme (required by ext-apps hosts)\n const uri = options.uri ?? `ui://${className}/${methodName}`;\n\n // Store metadata on the method\n Reflect.defineMetadata(UI_APP_COMPONENT_KEY, options.component, descriptor.value!);\n Reflect.defineMetadata(UI_APP_URI_KEY, uri, descriptor.value!);\n Reflect.defineMetadata(UI_APP_OPTIONS_KEY, options, descriptor.value!);\n\n // Also store the resource URI for the @Tool decorator to pick up\n // The @Tool decorator in @leanmcp/core should check for this\n const existingMeta = Reflect.getMetadata('tool:meta', descriptor.value) || {};\n Reflect.defineMetadata(\n 'tool:meta',\n {\n ...existingMeta,\n // New nested format (preferred by ext-apps 0.2.2)\n ui: {\n resourceUri: uri,\n },\n // Legacy flat format (for backwards compatibility)\n 'ui/resourceUri': uri,\n },\n descriptor.value!\n );\n\n return descriptor;\n };\n}\n\n/**\n * Helper to get UIApp metadata from a method\n */\nexport function getUIAppMetadata(target: Function): UIAppOptions | undefined {\n const component = Reflect.getMetadata(UI_APP_COMPONENT_KEY, target);\n if (!component) return undefined;\n\n return {\n component,\n uri: Reflect.getMetadata(UI_APP_URI_KEY, target),\n ...Reflect.getMetadata(UI_APP_OPTIONS_KEY, target),\n };\n}\n\n/**\n * Helper to get the resource URI from a method\n */\nexport function getUIAppUri(target: Function): string | undefined {\n return Reflect.getMetadata(UI_APP_URI_KEY, target);\n}\n","/**\n * @GPTApp Decorator\n *\n * Links an MCP tool to a React UI component compliant with ChatGPT Apps SDK.\n *\n * When applied to a tool method, it:\n * 1. Adds _meta.ui/resourceUri to the tool definition\n * 2. Adds OpenAI-specific metadata (widgetAccessible, outputTemplate, etc.)\n * 3. Auto-registers a resource that renders the component to HTML with 'text/html+skybridge' mimeType\n */\nimport 'reflect-metadata';\nimport type React from 'react';\n\n// Metadata keys\nexport const GPT_APP_COMPONENT_KEY = 'gptapp:component';\nexport const GPT_APP_URI_KEY = 'gptapp:uri';\nexport const GPT_APP_OPTIONS_KEY = 'gptapp:options';\n\n/**\n * Options for @GPTApp decorator\n */\nexport interface GPTAppOptions {\n /**\n * React component or path to component file (relative to service file).\n * - Use path string (e.g., './WeatherCard') for CLI build - avoids importing browser code in server\n * - Use component reference for direct SSR rendering\n */\n component: React.ComponentType<any> | string;\n\n /** Custom resource URI (auto-generated ui://... if not provided) */\n uri?: string;\n\n /** HTML document title */\n title?: string;\n\n /** Additional CSS styles */\n styles?: string;\n\n // ========== GPT-specific options ==========\n\n /**\n * Allow widget to call tools via window.openai.callTool.\n * Maps to _meta[\"openai/widgetAccessible\"]\n */\n widgetAccessible?: boolean;\n\n /**\n * Tool visibility: 'public' (default) or 'private'.\n * 'private' hides the tool from the model but keeps it callable by the widget.\n * Maps to _meta[\"openai/visibility\"]\n */\n visibility?: 'public' | 'private';\n\n /**\n * Widget prefers border around iframe.\n * Maps to _meta[\"openai/widgetPrefersBorder\"]\n */\n prefersBorder?: boolean;\n\n /**\n * Widget domain for API allowlists.\n * Maps to _meta[\"openai/widgetDomain\"]\n */\n widgetDomain?: string;\n\n /**\n * Widget description for the model.\n * Maps to _meta[\"openai/widgetDescription\"]\n */\n widgetDescription?: string;\n\n /**\n * Content Security Policy configuration.\n * Maps to _meta[\"openai/widgetCSP\"]\n */\n csp?: {\n connect_domains?: string[];\n resource_domains?: string[];\n redirect_domains?: string[];\n frame_domains?: string[];\n };\n\n /**\n * File parameters (fields treated as file uploads).\n * Maps to _meta[\"openai/fileParams\"]\n */\n fileParams?: string[];\n\n /**\n * Invocation messages shown during tool call.\n * Maps to _meta[\"openai/toolInvocation\"]\n */\n invocation?: {\n invoking?: string; // e.g., \"Preparing the board…\"\n invoked?: string; // e.g., \"Board ready.\"\n };\n}\n\n/**\n * Decorator that links a tool to a UI component for ChatGPT Apps.\n *\n * When the tool is called, the host will fetch the UI resource\n * which returns the component rendered as HTML with 'text/html+skybridge'.\n *\n * @example\n * ```typescript\n * import { Tool } from '@leanmcp/core';\n * import { GPTApp } from '@leanmcp/ui';\n * import { KanbanBoard } from './KanbanBoard';\n *\n * class KanbanService {\n * @Tool({ description: 'Show Kanban Board' })\n * @GPTApp({\n * component: KanbanBoard,\n * widgetAccessible: true,\n * invocation: { invoking: 'Loading board...' }\n * })\n * async showBoard() { ... }\n * }\n * ```\n */\nexport function GPTApp(options: GPTAppOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const methodName = String(propertyKey);\n // Use same pattern as @Resource in @leanmcp/core: className without 'service' suffix\n const className = target.constructor.name.toLowerCase().replace('service', '');\n\n // Generate URI using ui:// scheme (required by ext-apps hosts)\n const uri = options.uri ?? `ui://${className}/${methodName}`;\n\n // Store metadata on the method\n Reflect.defineMetadata(GPT_APP_COMPONENT_KEY, options.component, descriptor.value!);\n Reflect.defineMetadata(GPT_APP_URI_KEY, uri, descriptor.value!);\n Reflect.defineMetadata(GPT_APP_OPTIONS_KEY, options, descriptor.value!);\n\n // Also store the resource URI and OpenAI-specific metadata for the @Tool decorator to pick up\n const existingMeta = Reflect.getMetadata('tool:meta', descriptor.value) || {};\n\n // Build nested ui metadata (preferred by ext-apps 0.2.2)\n const uiMeta: Record<string, any> = {\n resourceUri: uri,\n };\n\n // Map visibility to ext-apps format\n if (options.visibility) {\n uiMeta.visibility = options.visibility === 'private' ? ['app'] : ['model', 'app'];\n }\n\n const openAiMeta: Record<string, any> = {\n // New nested format (preferred by ext-apps 0.2.2)\n ui: uiMeta,\n // Legacy flat format (for backwards compatibility)\n 'ui/resourceUri': uri,\n 'openai/outputTemplate': uri,\n };\n\n if (options.widgetAccessible !== undefined) {\n openAiMeta['openai/widgetAccessible'] = options.widgetAccessible;\n }\n\n if (options.visibility) {\n openAiMeta['openai/visibility'] = options.visibility;\n }\n\n if (options.prefersBorder !== undefined) {\n openAiMeta['openai/widgetPrefersBorder'] = options.prefersBorder;\n }\n\n if (options.widgetDomain) {\n openAiMeta['openai/widgetDomain'] = options.widgetDomain;\n }\n\n if (options.widgetDescription) {\n openAiMeta['openai/widgetDescription'] = options.widgetDescription;\n }\n\n if (options.csp) {\n openAiMeta['openai/widgetCSP'] = options.csp;\n }\n\n if (options.fileParams) {\n openAiMeta['openai/fileParams'] = options.fileParams;\n }\n\n if (options.invocation) {\n if (options.invocation.invoking)\n openAiMeta['openai/toolInvocation/invoking'] = options.invocation.invoking;\n if (options.invocation.invoked)\n openAiMeta['openai/toolInvocation/invoked'] = options.invocation.invoked;\n }\n\n Reflect.defineMetadata(\n 'tool:meta',\n {\n ...existingMeta,\n ...openAiMeta,\n },\n descriptor.value!\n );\n\n return descriptor;\n };\n}\n\n/**\n * Helper to get GPTApp metadata from a method\n */\nexport function getGPTAppMetadata(target: Function): GPTAppOptions | undefined {\n const component = Reflect.getMetadata(GPT_APP_COMPONENT_KEY, target);\n if (!component) return undefined;\n\n return {\n component,\n uri: Reflect.getMetadata(GPT_APP_URI_KEY, target),\n ...Reflect.getMetadata(GPT_APP_OPTIONS_KEY, target),\n };\n}\n\n/**\n * Helper to get the resource URI from a method\n */\nexport function getGPTAppUri(target: Function): string | undefined {\n return Reflect.getMetadata(GPT_APP_URI_KEY, target);\n}\n"]}
|
|
@@ -120,5 +120,5 @@ function getGPTAppUri(target) {
|
|
|
120
120
|
__name(getGPTAppUri, "getGPTAppUri");
|
|
121
121
|
|
|
122
122
|
export { GPTApp, GPT_APP_COMPONENT_KEY, GPT_APP_OPTIONS_KEY, GPT_APP_URI_KEY, UIApp, UI_APP_COMPONENT_KEY, UI_APP_OPTIONS_KEY, UI_APP_URI_KEY, __name, getGPTAppMetadata, getGPTAppUri, getUIAppMetadata, getUIAppUri };
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
123
|
+
//# sourceMappingURL=chunk-XLPJFQ74.mjs.map
|
|
124
|
+
//# sourceMappingURL=chunk-XLPJFQ74.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/decorator/UIApp.ts","../src/decorator/GPTApp.ts"],"names":["UI_APP_COMPONENT_KEY","UI_APP_URI_KEY","UI_APP_OPTIONS_KEY","UIApp","options","target","propertyKey","descriptor","methodName","String","className","name","toLowerCase","replace","uri","Reflect","defineMetadata","component","value","existingMeta","getMetadata","ui","resourceUri","getUIAppMetadata","undefined","getUIAppUri","GPT_APP_COMPONENT_KEY","GPT_APP_URI_KEY","GPT_APP_OPTIONS_KEY","GPTApp","uiMeta","visibility","openAiMeta","widgetAccessible","prefersBorder","widgetDomain","widgetDescription","csp","fileParams","invocation","invoking","invoked","getGPTAppMetadata","getGPTAppUri"],"mappings":";;;;AAcO,IAAMA,oBAAAA,GAAuB;AAC7B,IAAMC,cAAAA,GAAiB;AACvB,IAAMC,kBAAAA,GAAqB;AAyC3B,SAASC,MAAMC,OAAAA,EAAqB;AACzC,EAAA,OAAO,CAACC,MAAAA,EAAgBC,WAAAA,EAA8BC,UAAAA,KAAAA;AACpD,IAAA,MAAMC,UAAAA,GAAaC,OAAOH,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ool method, it:\n * 1. Adds _meta.ui/resourceUri to the tool definition\n * 2. Auto-registers a resource that renders the component to HTML\n *\n * This decorator is designed to work with @leanmcp/core decorators.\n */\nimport 'reflect-metadata';\nimport type React from 'react';\n\n// Metadata keys\nexport const UI_APP_COMPONENT_KEY = 'ui:app:component';\nexport const UI_APP_URI_KEY = 'ui:app:uri';\nexport const UI_APP_OPTIONS_KEY = 'ui:app:options';\n\n/**\n * Options for @UIApp decorator\n */\nexport interface UIAppOptions {\n /**\n * React component or path to component file (relative to service file).\n * - Use path string (e.g., './WeatherCard') for CLI build - avoids importing browser code in server\n * - Use component reference for direct SSR rendering\n */\n component: React.ComponentType<any> | string;\n /** Custom resource URI (auto-generated if not provided) */\n uri?: string;\n /** HTML document title */\n title?: string;\n /** Additional CSS styles */\n styles?: string;\n}\n\n/**\n * Decorator that links a tool to a UI component.\n *\n * When the tool is called, the host will fetch the UI resource\n * which returns the component rendered as HTML.\n *\n * @example\n * ```typescript\n * import { Tool } from '@leanmcp/core';\n * import { UIApp } from '@leanmcp/ui';\n * import { WeatherCard } from './WeatherCard';\n *\n * class WeatherService {\n * @Tool({ description: 'Get weather for a city' })\n * @UIApp({ component: WeatherCard })\n * async getWeather(args: { city: string }) {\n * return { city: args.city, temp: 22 };\n * }\n * }\n * ```\n */\nexport function UIApp(options: UIAppOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const methodName = String(propertyKey);\n // Use same pattern as @Resource in @leanmcp/core: className without 'service' suffix\n const className = target.constructor.name.toLowerCase().replace('service', '');\n\n // Generate URI using ui:// scheme (required by ext-apps hosts)\n const uri = options.uri ?? `ui://${className}/${methodName}`;\n\n // Store metadata on the method\n Reflect.defineMetadata(UI_APP_COMPONENT_KEY, options.component, descriptor.value!);\n Reflect.defineMetadata(UI_APP_URI_KEY, uri, descriptor.value!);\n Reflect.defineMetadata(UI_APP_OPTIONS_KEY, options, descriptor.value!);\n\n // Also store the resource URI for the @Tool decorator to pick up\n // The @Tool decorator in @leanmcp/core should check for this\n const existingMeta = Reflect.getMetadata('tool:meta', descriptor.value) || {};\n Reflect.defineMetadata(\n 'tool:meta',\n {\n ...existingMeta,\n // New nested format (preferred by ext-apps 0.2.2)\n ui: {\n resourceUri: uri,\n },\n // Legacy flat format (for backwards compatibility)\n 'ui/resourceUri': uri,\n },\n descriptor.value!\n );\n\n return descriptor;\n };\n}\n\n/**\n * Helper to get UIApp metadata from a method\n */\nexport function getUIAppMetadata(target: Function): UIAppOptions | undefined {\n const component = Reflect.getMetadata(UI_APP_COMPONENT_KEY, target);\n if (!component) return undefined;\n\n return {\n component,\n uri: Reflect.getMetadata(UI_APP_URI_KEY, target),\n ...Reflect.getMetadata(UI_APP_OPTIONS_KEY, target),\n };\n}\n\n/**\n * Helper to get the resource URI from a method\n */\nexport function getUIAppUri(target: Function): string | undefined {\n return Reflect.getMetadata(UI_APP_URI_KEY, target);\n}\n","/**\n * @GPTApp Decorator\n *\n * Links an MCP tool to a React UI component compliant with ChatGPT Apps SDK.\n *\n * When applied to a tool method, it:\n * 1. Adds _meta.ui/resourceUri to the tool definition\n * 2. Adds OpenAI-specific metadata (widgetAccessible, outputTemplate, etc.)\n * 3. Auto-registers a resource that renders the component to HTML with 'text/html+skybridge' mimeType\n */\nimport 'reflect-metadata';\nimport type React from 'react';\n\n// Metadata keys\nexport const GPT_APP_COMPONENT_KEY = 'gptapp:component';\nexport const GPT_APP_URI_KEY = 'gptapp:uri';\nexport const GPT_APP_OPTIONS_KEY = 'gptapp:options';\n\n/**\n * Options for @GPTApp decorator\n */\nexport interface GPTAppOptions {\n /**\n * React component or path to component file (relative to service file).\n * - Use path string (e.g., './WeatherCard') for CLI build - avoids importing browser code in server\n * - Use component reference for direct SSR rendering\n */\n component: React.ComponentType<any> | string;\n\n /** Custom resource URI (auto-generated ui://... if not provided) */\n uri?: string;\n\n /** HTML document title */\n title?: string;\n\n /** Additional CSS styles */\n styles?: string;\n\n // ========== GPT-specific options ==========\n\n /**\n * Allow widget to call tools via window.openai.callTool.\n * Maps to _meta[\"openai/widgetAccessible\"]\n */\n widgetAccessible?: boolean;\n\n /**\n * Tool visibility: 'public' (default) or 'private'.\n * 'private' hides the tool from the model but keeps it callable by the widget.\n * Maps to _meta[\"openai/visibility\"]\n */\n visibility?: 'public' | 'private';\n\n /**\n * Widget prefers border around iframe.\n * Maps to _meta[\"openai/widgetPrefersBorder\"]\n */\n prefersBorder?: boolean;\n\n /**\n * Widget domain for API allowlists.\n * Maps to _meta[\"openai/widgetDomain\"]\n */\n widgetDomain?: string;\n\n /**\n * Widget description for the model.\n * Maps to _meta[\"openai/widgetDescription\"]\n */\n widgetDescription?: string;\n\n /**\n * Content Security Policy configuration.\n * Maps to _meta[\"openai/widgetCSP\"]\n */\n csp?: {\n connect_domains?: string[];\n resource_domains?: string[];\n redirect_domains?: string[];\n frame_domains?: string[];\n };\n\n /**\n * File parameters (fields treated as file uploads).\n * Maps to _meta[\"openai/fileParams\"]\n */\n fileParams?: string[];\n\n /**\n * Invocation messages shown during tool call.\n * Maps to _meta[\"openai/toolInvocation\"]\n */\n invocation?: {\n invoking?: string; // e.g., \"Preparing the board…\"\n invoked?: string; // e.g., \"Board ready.\"\n };\n}\n\n/**\n * Decorator that links a tool to a UI component for ChatGPT Apps.\n *\n * When the tool is called, the host will fetch the UI resource\n * which returns the component rendered as HTML with 'text/html+skybridge'.\n *\n * @example\n * ```typescript\n * import { Tool } from '@leanmcp/core';\n * import { GPTApp } from '@leanmcp/ui';\n * import { KanbanBoard } from './KanbanBoard';\n *\n * class KanbanService {\n * @Tool({ description: 'Show Kanban Board' })\n * @GPTApp({\n * component: KanbanBoard,\n * widgetAccessible: true,\n * invocation: { invoking: 'Loading board...' }\n * })\n * async showBoard() { ... }\n * }\n * ```\n */\nexport function GPTApp(options: GPTAppOptions): MethodDecorator {\n return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const methodName = String(propertyKey);\n // Use same pattern as @Resource in @leanmcp/core: className without 'service' suffix\n const className = target.constructor.name.toLowerCase().replace('service', '');\n\n // Generate URI using ui:// scheme (required by ext-apps hosts)\n const uri = options.uri ?? `ui://${className}/${methodName}`;\n\n // Store metadata on the method\n Reflect.defineMetadata(GPT_APP_COMPONENT_KEY, options.component, descriptor.value!);\n Reflect.defineMetadata(GPT_APP_URI_KEY, uri, descriptor.value!);\n Reflect.defineMetadata(GPT_APP_OPTIONS_KEY, options, descriptor.value!);\n\n // Also store the resource URI and OpenAI-specific metadata for the @Tool decorator to pick up\n const existingMeta = Reflect.getMetadata('tool:meta', descriptor.value) || {};\n\n // Build nested ui metadata (preferred by ext-apps 0.2.2)\n const uiMeta: Record<string, any> = {\n resourceUri: uri,\n };\n\n // Map visibility to ext-apps format\n if (options.visibility) {\n uiMeta.visibility = options.visibility === 'private' ? ['app'] : ['model', 'app'];\n }\n\n const openAiMeta: Record<string, any> = {\n // New nested format (preferred by ext-apps 0.2.2)\n ui: uiMeta,\n // Legacy flat format (for backwards compatibility)\n 'ui/resourceUri': uri,\n 'openai/outputTemplate': uri,\n };\n\n if (options.widgetAccessible !== undefined) {\n openAiMeta['openai/widgetAccessible'] = options.widgetAccessible;\n }\n\n if (options.visibility) {\n openAiMeta['openai/visibility'] = options.visibility;\n }\n\n if (options.prefersBorder !== undefined) {\n openAiMeta['openai/widgetPrefersBorder'] = options.prefersBorder;\n }\n\n if (options.widgetDomain) {\n openAiMeta['openai/widgetDomain'] = options.widgetDomain;\n }\n\n if (options.widgetDescription) {\n openAiMeta['openai/widgetDescription'] = options.widgetDescription;\n }\n\n if (options.csp) {\n openAiMeta['openai/widgetCSP'] = options.csp;\n }\n\n if (options.fileParams) {\n openAiMeta['openai/fileParams'] = options.fileParams;\n }\n\n if (options.invocation) {\n if (options.invocation.invoking)\n openAiMeta['openai/toolInvocation/invoking'] = options.invocation.invoking;\n if (options.invocation.invoked)\n openAiMeta['openai/toolInvocation/invoked'] = options.invocation.invoked;\n }\n\n Reflect.defineMetadata(\n 'tool:meta',\n {\n ...existingMeta,\n ...openAiMeta,\n },\n descriptor.value!\n );\n\n return descriptor;\n };\n}\n\n/**\n * Helper to get GPTApp metadata from a method\n */\nexport function getGPTAppMetadata(target: Function): GPTAppOptions | undefined {\n const component = Reflect.getMetadata(GPT_APP_COMPONENT_KEY, target);\n if (!component) return undefined;\n\n return {\n component,\n uri: Reflect.getMetadata(GPT_APP_URI_KEY, target),\n ...Reflect.getMetadata(GPT_APP_OPTIONS_KEY, target),\n };\n}\n\n/**\n * Helper to get the resource URI from a method\n */\nexport function getGPTAppUri(target: Function): string | undefined {\n return Reflect.getMetadata(GPT_APP_URI_KEY, target);\n}\n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -115,7 +115,7 @@ interface AppProviderProps {
|
|
|
115
115
|
* }
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
|
-
declare function AppProvider({ appInfo, capabilities, options, onTeardown, children }: AppProviderProps): react_jsx_runtime.JSX.Element;
|
|
118
|
+
declare function AppProvider({ appInfo, capabilities, options, onTeardown, children, }: AppProviderProps): react_jsx_runtime.JSX.Element;
|
|
119
119
|
/**
|
|
120
120
|
* Hook to access the MCP App context
|
|
121
121
|
* Returns SSR-safe defaults when no provider is available (during server rendering)
|
|
@@ -507,7 +507,7 @@ interface ToolProviderProps {
|
|
|
507
507
|
/**
|
|
508
508
|
* ToolProvider component
|
|
509
509
|
*/
|
|
510
|
-
declare function ToolProvider({ defaults, children
|
|
510
|
+
declare function ToolProvider({ defaults, children }: ToolProviderProps): react_jsx_runtime.JSX.Element;
|
|
511
511
|
/**
|
|
512
512
|
* Hook to access tool context
|
|
513
513
|
*/
|
|
@@ -1363,18 +1363,18 @@ declare function useToolInput<T = any>(): T | undefined;
|
|
|
1363
1363
|
*/
|
|
1364
1364
|
declare function useWidgetState<T extends Record<string, unknown>>(initialState: T | (() => T)): [T, (newState: T | ((prev: T) => T)) => void];
|
|
1365
1365
|
|
|
1366
|
-
declare function CardTitle({ className, ...props }: React.ComponentProps<
|
|
1367
|
-
declare function CardDescription({ className, ...props }: React.ComponentProps<
|
|
1366
|
+
declare function CardTitle({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1367
|
+
declare function CardDescription({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1368
1368
|
|
|
1369
1369
|
declare function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1370
1370
|
|
|
1371
|
-
declare function Textarea({ className, ...props }: React.ComponentProps<
|
|
1371
|
+
declare function Textarea({ className, ...props }: React.ComponentProps<'textarea'>): react_jsx_runtime.JSX.Element;
|
|
1372
1372
|
|
|
1373
1373
|
declare function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1374
1374
|
declare function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>): react_jsx_runtime.JSX.Element;
|
|
1375
1375
|
declare function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>): react_jsx_runtime.JSX.Element;
|
|
1376
1376
|
declare function SelectTrigger({ className, size, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
1377
|
-
size?:
|
|
1377
|
+
size?: 'sm' | 'default';
|
|
1378
1378
|
}): react_jsx_runtime.JSX.Element;
|
|
1379
1379
|
declare function SelectContent({ className, children, position, align, ...props }: React.ComponentProps<typeof SelectPrimitive.Content>): react_jsx_runtime.JSX.Element;
|
|
1380
1380
|
declare function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>): react_jsx_runtime.JSX.Element;
|
|
@@ -1403,29 +1403,29 @@ declare const useFormField: () => {
|
|
|
1403
1403
|
formDescriptionId: string;
|
|
1404
1404
|
formMessageId: string;
|
|
1405
1405
|
};
|
|
1406
|
-
declare function FormItem({ className, ...props }: React.ComponentProps<
|
|
1406
|
+
declare function FormItem({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1407
1407
|
declare function FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1408
1408
|
declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): react_jsx_runtime.JSX.Element;
|
|
1409
|
-
declare function FormDescription({ className, ...props }: React.ComponentProps<
|
|
1410
|
-
declare function FormMessage({ className, ...props }: React.ComponentProps<
|
|
1409
|
+
declare function FormDescription({ className, ...props }: React.ComponentProps<'p'>): react_jsx_runtime.JSX.Element;
|
|
1410
|
+
declare function FormMessage({ className, ...props }: React.ComponentProps<'p'>): react_jsx_runtime.JSX.Element | null;
|
|
1411
1411
|
|
|
1412
1412
|
declare const alertVariants: (props?: ({
|
|
1413
1413
|
variant?: "default" | "destructive" | null | undefined;
|
|
1414
1414
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
1415
|
-
declare function Alert({ className, variant, ...props }: React.ComponentProps<
|
|
1416
|
-
declare function AlertTitle({ className, ...props }: React.ComponentProps<
|
|
1417
|
-
declare function AlertDescription({ className, ...props }: React.ComponentProps<
|
|
1415
|
+
declare function Alert({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>): react_jsx_runtime.JSX.Element;
|
|
1416
|
+
declare function AlertTitle({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1417
|
+
declare function AlertDescription({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1418
1418
|
|
|
1419
1419
|
declare const badgeVariants: (props?: ({
|
|
1420
1420
|
variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
|
|
1421
1421
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
1422
|
-
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<
|
|
1422
|
+
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & {
|
|
1423
1423
|
asChild?: boolean;
|
|
1424
1424
|
}): react_jsx_runtime.JSX.Element;
|
|
1425
1425
|
|
|
1426
1426
|
declare function Progress({ className, value, ...props }: React.ComponentProps<typeof ProgressPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1427
1427
|
|
|
1428
|
-
declare function Skeleton({ className, ...props }: React__default.ComponentProps<
|
|
1428
|
+
declare function Skeleton({ className, ...props }: React__default.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1429
1429
|
|
|
1430
1430
|
declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1431
1431
|
declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
|
|
@@ -1435,8 +1435,8 @@ declare function DialogOverlay({ className, ...props }: React.ComponentProps<typ
|
|
|
1435
1435
|
declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
1436
1436
|
showCloseButton?: boolean;
|
|
1437
1437
|
}): react_jsx_runtime.JSX.Element;
|
|
1438
|
-
declare function DialogHeader({ className, ...props }: React.ComponentProps<
|
|
1439
|
-
declare function DialogFooter({ className, ...props }: React.ComponentProps<
|
|
1438
|
+
declare function DialogHeader({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1439
|
+
declare function DialogFooter({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1440
1440
|
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
|
|
1441
1441
|
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
|
|
1442
1442
|
|
|
@@ -1461,7 +1461,7 @@ declare function DropdownMenuContent({ className, sideOffset, ...props }: React.
|
|
|
1461
1461
|
declare function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>): react_jsx_runtime.JSX.Element;
|
|
1462
1462
|
declare function DropdownMenuItem({ className, inset, variant, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
1463
1463
|
inset?: boolean;
|
|
1464
|
-
variant?:
|
|
1464
|
+
variant?: 'default' | 'destructive';
|
|
1465
1465
|
}): react_jsx_runtime.JSX.Element;
|
|
1466
1466
|
declare function DropdownMenuCheckboxItem({ className, children, checked, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>): react_jsx_runtime.JSX.Element;
|
|
1467
1467
|
declare function DropdownMenuRadioGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>): react_jsx_runtime.JSX.Element;
|
|
@@ -1470,7 +1470,7 @@ declare function DropdownMenuLabel({ className, inset, ...props }: React.Compone
|
|
|
1470
1470
|
inset?: boolean;
|
|
1471
1471
|
}): react_jsx_runtime.JSX.Element;
|
|
1472
1472
|
declare function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>): react_jsx_runtime.JSX.Element;
|
|
1473
|
-
declare function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<
|
|
1473
|
+
declare function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<'span'>): react_jsx_runtime.JSX.Element;
|
|
1474
1474
|
declare function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>): react_jsx_runtime.JSX.Element;
|
|
1475
1475
|
declare function DropdownMenuSubTrigger({ className, inset, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
1476
1476
|
inset?: boolean;
|
|
@@ -1490,16 +1490,16 @@ declare function CommandEmpty({ ...props }: React.ComponentProps<typeof Command$
|
|
|
1490
1490
|
declare function CommandGroup({ className, ...props }: React.ComponentProps<typeof Command$1.Group>): react_jsx_runtime.JSX.Element;
|
|
1491
1491
|
declare function CommandSeparator({ className, ...props }: React.ComponentProps<typeof Command$1.Separator>): react_jsx_runtime.JSX.Element;
|
|
1492
1492
|
declare function CommandItem({ className, ...props }: React.ComponentProps<typeof Command$1.Item>): react_jsx_runtime.JSX.Element;
|
|
1493
|
-
declare function CommandShortcut({ className, ...props }: React.ComponentProps<
|
|
1493
|
+
declare function CommandShortcut({ className, ...props }: React.ComponentProps<'span'>): react_jsx_runtime.JSX.Element;
|
|
1494
1494
|
|
|
1495
|
-
declare function Table({ className, ...props }: React.ComponentProps<
|
|
1496
|
-
declare function TableHeader({ className, ...props }: React.ComponentProps<
|
|
1497
|
-
declare function TableBody({ className, ...props }: React.ComponentProps<
|
|
1498
|
-
declare function TableFooter({ className, ...props }: React.ComponentProps<
|
|
1499
|
-
declare function TableRow({ className, ...props }: React.ComponentProps<
|
|
1500
|
-
declare function TableHead({ className, ...props }: React.ComponentProps<
|
|
1501
|
-
declare function TableCell({ className, ...props }: React.ComponentProps<
|
|
1502
|
-
declare function TableCaption({ className, ...props }: React.ComponentProps<
|
|
1495
|
+
declare function Table({ className, ...props }: React.ComponentProps<'table'>): react_jsx_runtime.JSX.Element;
|
|
1496
|
+
declare function TableHeader({ className, ...props }: React.ComponentProps<'thead'>): react_jsx_runtime.JSX.Element;
|
|
1497
|
+
declare function TableBody({ className, ...props }: React.ComponentProps<'tbody'>): react_jsx_runtime.JSX.Element;
|
|
1498
|
+
declare function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>): react_jsx_runtime.JSX.Element;
|
|
1499
|
+
declare function TableRow({ className, ...props }: React.ComponentProps<'tr'>): react_jsx_runtime.JSX.Element;
|
|
1500
|
+
declare function TableHead({ className, ...props }: React.ComponentProps<'th'>): react_jsx_runtime.JSX.Element;
|
|
1501
|
+
declare function TableCell({ className, ...props }: React.ComponentProps<'td'>): react_jsx_runtime.JSX.Element;
|
|
1502
|
+
declare function TableCaption({ className, ...props }: React.ComponentProps<'caption'>): react_jsx_runtime.JSX.Element;
|
|
1503
1503
|
|
|
1504
1504
|
declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): react_jsx_runtime.JSX.Element;
|
|
1505
1505
|
declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
@@ -1662,7 +1662,7 @@ interface TabContentProps {
|
|
|
1662
1662
|
/** Additional class name */
|
|
1663
1663
|
className?: string;
|
|
1664
1664
|
}
|
|
1665
|
-
declare function Tabs({ tabs, defaultValue, value, onValueChange, children, className
|
|
1665
|
+
declare function Tabs({ tabs, defaultValue, value, onValueChange, children, className }: TabsProps): react_jsx_runtime.JSX.Element;
|
|
1666
1666
|
declare function TabContent({ value, children, className }: TabContentProps): react_jsx_runtime.JSX.Element;
|
|
1667
1667
|
|
|
1668
1668
|
interface ModalProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ interface AppProviderProps {
|
|
|
115
115
|
* }
|
|
116
116
|
* ```
|
|
117
117
|
*/
|
|
118
|
-
declare function AppProvider({ appInfo, capabilities, options, onTeardown, children }: AppProviderProps): react_jsx_runtime.JSX.Element;
|
|
118
|
+
declare function AppProvider({ appInfo, capabilities, options, onTeardown, children, }: AppProviderProps): react_jsx_runtime.JSX.Element;
|
|
119
119
|
/**
|
|
120
120
|
* Hook to access the MCP App context
|
|
121
121
|
* Returns SSR-safe defaults when no provider is available (during server rendering)
|
|
@@ -507,7 +507,7 @@ interface ToolProviderProps {
|
|
|
507
507
|
/**
|
|
508
508
|
* ToolProvider component
|
|
509
509
|
*/
|
|
510
|
-
declare function ToolProvider({ defaults, children
|
|
510
|
+
declare function ToolProvider({ defaults, children }: ToolProviderProps): react_jsx_runtime.JSX.Element;
|
|
511
511
|
/**
|
|
512
512
|
* Hook to access tool context
|
|
513
513
|
*/
|
|
@@ -1363,18 +1363,18 @@ declare function useToolInput<T = any>(): T | undefined;
|
|
|
1363
1363
|
*/
|
|
1364
1364
|
declare function useWidgetState<T extends Record<string, unknown>>(initialState: T | (() => T)): [T, (newState: T | ((prev: T) => T)) => void];
|
|
1365
1365
|
|
|
1366
|
-
declare function CardTitle({ className, ...props }: React.ComponentProps<
|
|
1367
|
-
declare function CardDescription({ className, ...props }: React.ComponentProps<
|
|
1366
|
+
declare function CardTitle({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1367
|
+
declare function CardDescription({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1368
1368
|
|
|
1369
1369
|
declare function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1370
1370
|
|
|
1371
|
-
declare function Textarea({ className, ...props }: React.ComponentProps<
|
|
1371
|
+
declare function Textarea({ className, ...props }: React.ComponentProps<'textarea'>): react_jsx_runtime.JSX.Element;
|
|
1372
1372
|
|
|
1373
1373
|
declare function Select({ ...props }: React.ComponentProps<typeof SelectPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1374
1374
|
declare function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>): react_jsx_runtime.JSX.Element;
|
|
1375
1375
|
declare function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>): react_jsx_runtime.JSX.Element;
|
|
1376
1376
|
declare function SelectTrigger({ className, size, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
|
1377
|
-
size?:
|
|
1377
|
+
size?: 'sm' | 'default';
|
|
1378
1378
|
}): react_jsx_runtime.JSX.Element;
|
|
1379
1379
|
declare function SelectContent({ className, children, position, align, ...props }: React.ComponentProps<typeof SelectPrimitive.Content>): react_jsx_runtime.JSX.Element;
|
|
1380
1380
|
declare function SelectLabel({ className, ...props }: React.ComponentProps<typeof SelectPrimitive.Label>): react_jsx_runtime.JSX.Element;
|
|
@@ -1403,29 +1403,29 @@ declare const useFormField: () => {
|
|
|
1403
1403
|
formDescriptionId: string;
|
|
1404
1404
|
formMessageId: string;
|
|
1405
1405
|
};
|
|
1406
|
-
declare function FormItem({ className, ...props }: React.ComponentProps<
|
|
1406
|
+
declare function FormItem({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1407
1407
|
declare function FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1408
1408
|
declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): react_jsx_runtime.JSX.Element;
|
|
1409
|
-
declare function FormDescription({ className, ...props }: React.ComponentProps<
|
|
1410
|
-
declare function FormMessage({ className, ...props }: React.ComponentProps<
|
|
1409
|
+
declare function FormDescription({ className, ...props }: React.ComponentProps<'p'>): react_jsx_runtime.JSX.Element;
|
|
1410
|
+
declare function FormMessage({ className, ...props }: React.ComponentProps<'p'>): react_jsx_runtime.JSX.Element | null;
|
|
1411
1411
|
|
|
1412
1412
|
declare const alertVariants: (props?: ({
|
|
1413
1413
|
variant?: "default" | "destructive" | null | undefined;
|
|
1414
1414
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
1415
|
-
declare function Alert({ className, variant, ...props }: React.ComponentProps<
|
|
1416
|
-
declare function AlertTitle({ className, ...props }: React.ComponentProps<
|
|
1417
|
-
declare function AlertDescription({ className, ...props }: React.ComponentProps<
|
|
1415
|
+
declare function Alert({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>): react_jsx_runtime.JSX.Element;
|
|
1416
|
+
declare function AlertTitle({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1417
|
+
declare function AlertDescription({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1418
1418
|
|
|
1419
1419
|
declare const badgeVariants: (props?: ({
|
|
1420
1420
|
variant?: "default" | "destructive" | "outline" | "secondary" | null | undefined;
|
|
1421
1421
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
1422
|
-
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<
|
|
1422
|
+
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & {
|
|
1423
1423
|
asChild?: boolean;
|
|
1424
1424
|
}): react_jsx_runtime.JSX.Element;
|
|
1425
1425
|
|
|
1426
1426
|
declare function Progress({ className, value, ...props }: React.ComponentProps<typeof ProgressPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1427
1427
|
|
|
1428
|
-
declare function Skeleton({ className, ...props }: React__default.ComponentProps<
|
|
1428
|
+
declare function Skeleton({ className, ...props }: React__default.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1429
1429
|
|
|
1430
1430
|
declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
1431
1431
|
declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
|
|
@@ -1435,8 +1435,8 @@ declare function DialogOverlay({ className, ...props }: React.ComponentProps<typ
|
|
|
1435
1435
|
declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
1436
1436
|
showCloseButton?: boolean;
|
|
1437
1437
|
}): react_jsx_runtime.JSX.Element;
|
|
1438
|
-
declare function DialogHeader({ className, ...props }: React.ComponentProps<
|
|
1439
|
-
declare function DialogFooter({ className, ...props }: React.ComponentProps<
|
|
1438
|
+
declare function DialogHeader({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1439
|
+
declare function DialogFooter({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
1440
1440
|
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
|
|
1441
1441
|
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
|
|
1442
1442
|
|
|
@@ -1461,7 +1461,7 @@ declare function DropdownMenuContent({ className, sideOffset, ...props }: React.
|
|
|
1461
1461
|
declare function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>): react_jsx_runtime.JSX.Element;
|
|
1462
1462
|
declare function DropdownMenuItem({ className, inset, variant, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
|
1463
1463
|
inset?: boolean;
|
|
1464
|
-
variant?:
|
|
1464
|
+
variant?: 'default' | 'destructive';
|
|
1465
1465
|
}): react_jsx_runtime.JSX.Element;
|
|
1466
1466
|
declare function DropdownMenuCheckboxItem({ className, children, checked, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>): react_jsx_runtime.JSX.Element;
|
|
1467
1467
|
declare function DropdownMenuRadioGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>): react_jsx_runtime.JSX.Element;
|
|
@@ -1470,7 +1470,7 @@ declare function DropdownMenuLabel({ className, inset, ...props }: React.Compone
|
|
|
1470
1470
|
inset?: boolean;
|
|
1471
1471
|
}): react_jsx_runtime.JSX.Element;
|
|
1472
1472
|
declare function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>): react_jsx_runtime.JSX.Element;
|
|
1473
|
-
declare function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<
|
|
1473
|
+
declare function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<'span'>): react_jsx_runtime.JSX.Element;
|
|
1474
1474
|
declare function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>): react_jsx_runtime.JSX.Element;
|
|
1475
1475
|
declare function DropdownMenuSubTrigger({ className, inset, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
1476
1476
|
inset?: boolean;
|
|
@@ -1490,16 +1490,16 @@ declare function CommandEmpty({ ...props }: React.ComponentProps<typeof Command$
|
|
|
1490
1490
|
declare function CommandGroup({ className, ...props }: React.ComponentProps<typeof Command$1.Group>): react_jsx_runtime.JSX.Element;
|
|
1491
1491
|
declare function CommandSeparator({ className, ...props }: React.ComponentProps<typeof Command$1.Separator>): react_jsx_runtime.JSX.Element;
|
|
1492
1492
|
declare function CommandItem({ className, ...props }: React.ComponentProps<typeof Command$1.Item>): react_jsx_runtime.JSX.Element;
|
|
1493
|
-
declare function CommandShortcut({ className, ...props }: React.ComponentProps<
|
|
1493
|
+
declare function CommandShortcut({ className, ...props }: React.ComponentProps<'span'>): react_jsx_runtime.JSX.Element;
|
|
1494
1494
|
|
|
1495
|
-
declare function Table({ className, ...props }: React.ComponentProps<
|
|
1496
|
-
declare function TableHeader({ className, ...props }: React.ComponentProps<
|
|
1497
|
-
declare function TableBody({ className, ...props }: React.ComponentProps<
|
|
1498
|
-
declare function TableFooter({ className, ...props }: React.ComponentProps<
|
|
1499
|
-
declare function TableRow({ className, ...props }: React.ComponentProps<
|
|
1500
|
-
declare function TableHead({ className, ...props }: React.ComponentProps<
|
|
1501
|
-
declare function TableCell({ className, ...props }: React.ComponentProps<
|
|
1502
|
-
declare function TableCaption({ className, ...props }: React.ComponentProps<
|
|
1495
|
+
declare function Table({ className, ...props }: React.ComponentProps<'table'>): react_jsx_runtime.JSX.Element;
|
|
1496
|
+
declare function TableHeader({ className, ...props }: React.ComponentProps<'thead'>): react_jsx_runtime.JSX.Element;
|
|
1497
|
+
declare function TableBody({ className, ...props }: React.ComponentProps<'tbody'>): react_jsx_runtime.JSX.Element;
|
|
1498
|
+
declare function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>): react_jsx_runtime.JSX.Element;
|
|
1499
|
+
declare function TableRow({ className, ...props }: React.ComponentProps<'tr'>): react_jsx_runtime.JSX.Element;
|
|
1500
|
+
declare function TableHead({ className, ...props }: React.ComponentProps<'th'>): react_jsx_runtime.JSX.Element;
|
|
1501
|
+
declare function TableCell({ className, ...props }: React.ComponentProps<'td'>): react_jsx_runtime.JSX.Element;
|
|
1502
|
+
declare function TableCaption({ className, ...props }: React.ComponentProps<'caption'>): react_jsx_runtime.JSX.Element;
|
|
1503
1503
|
|
|
1504
1504
|
declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): react_jsx_runtime.JSX.Element;
|
|
1505
1505
|
declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
@@ -1662,7 +1662,7 @@ interface TabContentProps {
|
|
|
1662
1662
|
/** Additional class name */
|
|
1663
1663
|
className?: string;
|
|
1664
1664
|
}
|
|
1665
|
-
declare function Tabs({ tabs, defaultValue, value, onValueChange, children, className
|
|
1665
|
+
declare function Tabs({ tabs, defaultValue, value, onValueChange, children, className }: TabsProps): react_jsx_runtime.JSX.Element;
|
|
1666
1666
|
declare function TabContent({ value, children, className }: TabContentProps): react_jsx_runtime.JSX.Element;
|
|
1667
1667
|
|
|
1668
1668
|
interface ModalProps {
|