@leanmcp/ui 0.3.1 → 0.3.2
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 +40 -0
- package/dist/index.d.mts +82 -3
- package/dist/index.d.ts +82 -3
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -93,6 +93,18 @@ function MyApp() {
|
|
|
93
93
|
| `useMessage` | Send messages to host chat |
|
|
94
94
|
| `useHostContext` | Access host theme and viewport |
|
|
95
95
|
|
|
96
|
+
### GPT Apps SDK Hooks
|
|
97
|
+
|
|
98
|
+
These hooks provide access to the ChatGPT Apps SDK globals (compatible with OpenAI's `window.openai` API):
|
|
99
|
+
|
|
100
|
+
| Hook | Description |
|
|
101
|
+
|------|-------------|
|
|
102
|
+
| `useToolOutput` | Access `structuredContent` from the tool response |
|
|
103
|
+
| `useToolInput` | Access input arguments passed to the tool |
|
|
104
|
+
| `useWidgetState` | Read/write persistent widget state across sessions |
|
|
105
|
+
| `useToolResponseMetadata` | Access `_meta` from the tool response |
|
|
106
|
+
| `useOpenAiGlobal` | Low-level hook to subscribe to any `window.openai` property |
|
|
107
|
+
|
|
96
108
|
## Examples
|
|
97
109
|
|
|
98
110
|
### ToolButton with Confirmation
|
|
@@ -198,6 +210,34 @@ export class SlackService {
|
|
|
198
210
|
}
|
|
199
211
|
```
|
|
200
212
|
|
|
213
|
+
### GPT Apps SDK Hooks Usage
|
|
214
|
+
|
|
215
|
+
Access tool output (structuredContent) without making additional API calls:
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
import { useToolOutput, useWidgetState } from '@leanmcp/ui';
|
|
219
|
+
|
|
220
|
+
function ChannelsView() {
|
|
221
|
+
// Access the structured data from the tool response
|
|
222
|
+
const toolOutput = useToolOutput<{ channels: Channel[] }>();
|
|
223
|
+
|
|
224
|
+
// Persist state across the session
|
|
225
|
+
const [state, setState] = useWidgetState({ selectedChannel: null });
|
|
226
|
+
|
|
227
|
+
if (!toolOutput?.channels) return <div>Loading...</div>;
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
<ul>
|
|
231
|
+
{toolOutput.channels.map(ch => (
|
|
232
|
+
<li key={ch.id} onClick={() => setState({ selectedChannel: ch.id })}>
|
|
233
|
+
{ch.name}
|
|
234
|
+
</li>
|
|
235
|
+
))}
|
|
236
|
+
</ul>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
201
241
|
## Theming
|
|
202
242
|
|
|
203
243
|
The SDK uses CSS variables compatible with MCP host theming. Import the styles:
|
package/dist/index.d.mts
CHANGED
|
@@ -124,11 +124,35 @@ declare function useMcpApp(): McpAppContextValue;
|
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* ChatGPT's window.openai interface
|
|
127
|
-
*
|
|
127
|
+
* Based on: https://developers.openai.com/apps-sdk/build/chatgpt-ui#understand-the-windowopenai-api
|
|
128
128
|
*/
|
|
129
129
|
interface OpenAISDK {
|
|
130
|
+
/** Input arguments for the tool */
|
|
131
|
+
toolInput?: Record<string, unknown>;
|
|
132
|
+
/** Structured content returned by the tool */
|
|
133
|
+
toolOutput?: any;
|
|
134
|
+
/** Metadata returned by the tool */
|
|
135
|
+
toolResponseMetadata?: Record<string, unknown>;
|
|
136
|
+
/** Persisted state for this widget instance */
|
|
137
|
+
widgetState?: Record<string, unknown>;
|
|
130
138
|
/** Call a server tool */
|
|
131
139
|
callTool: (name: string, args: Record<string, unknown>) => Promise<any>;
|
|
140
|
+
/** Send a follow-up message to chat */
|
|
141
|
+
sendFollowUpMessage?: (options: {
|
|
142
|
+
prompt: string;
|
|
143
|
+
}) => Promise<void>;
|
|
144
|
+
/** Upload a file */
|
|
145
|
+
uploadFile?: (file: File) => Promise<{
|
|
146
|
+
fileId: string;
|
|
147
|
+
}>;
|
|
148
|
+
/** Get download URL for a file */
|
|
149
|
+
getFileDownloadUrl?: (options: {
|
|
150
|
+
fileId: string;
|
|
151
|
+
}) => Promise<{
|
|
152
|
+
downloadUrl: string;
|
|
153
|
+
}>;
|
|
154
|
+
/** Persist widget state */
|
|
155
|
+
setWidgetState?: (state: Record<string, unknown>) => void;
|
|
132
156
|
/** Current theme */
|
|
133
157
|
theme?: 'light' | 'dark';
|
|
134
158
|
/** Current locale */
|
|
@@ -137,6 +161,15 @@ interface OpenAISDK {
|
|
|
137
161
|
displayMode?: 'inline' | 'modal' | 'fullscreen';
|
|
138
162
|
/** Maximum height for the widget */
|
|
139
163
|
maxHeight?: number;
|
|
164
|
+
/** Safe area insets */
|
|
165
|
+
safeArea?: {
|
|
166
|
+
top: number;
|
|
167
|
+
right: number;
|
|
168
|
+
bottom: number;
|
|
169
|
+
left: number;
|
|
170
|
+
};
|
|
171
|
+
/** View type */
|
|
172
|
+
view?: 'desktop' | 'mobile';
|
|
140
173
|
}
|
|
141
174
|
declare global {
|
|
142
175
|
interface Window {
|
|
@@ -1143,7 +1176,7 @@ interface UseToolInputReturn<T = Record<string, unknown>> {
|
|
|
1143
1176
|
* }
|
|
1144
1177
|
* ```
|
|
1145
1178
|
*/
|
|
1146
|
-
declare function useToolInput<T = Record<string, unknown>>(): UseToolInputReturn<T>;
|
|
1179
|
+
declare function useToolInput$1<T = Record<string, unknown>>(): UseToolInputReturn<T>;
|
|
1147
1180
|
|
|
1148
1181
|
interface UseToolInputPartialReturn {
|
|
1149
1182
|
/** Partial arguments currently available */
|
|
@@ -1216,6 +1249,52 @@ interface UseToolSubscriptionResult<T = unknown> {
|
|
|
1216
1249
|
*/
|
|
1217
1250
|
declare function useToolSubscription<T = unknown>(toolName: string, options?: UseToolSubscriptionOptions): UseToolSubscriptionResult<T>;
|
|
1218
1251
|
|
|
1252
|
+
interface OpenAiGlobals {
|
|
1253
|
+
toolInput: Record<string, unknown>;
|
|
1254
|
+
toolOutput: any;
|
|
1255
|
+
toolResponseMetadata: Record<string, unknown>;
|
|
1256
|
+
widgetState: Record<string, unknown>;
|
|
1257
|
+
theme: 'light' | 'dark';
|
|
1258
|
+
displayMode: 'inline' | 'modal' | 'fullscreen';
|
|
1259
|
+
maxHeight: number;
|
|
1260
|
+
safeArea: {
|
|
1261
|
+
top: number;
|
|
1262
|
+
right: number;
|
|
1263
|
+
bottom: number;
|
|
1264
|
+
left: number;
|
|
1265
|
+
};
|
|
1266
|
+
view: 'desktop' | 'mobile';
|
|
1267
|
+
locale: string;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* React hook to subscribe to window.openai global values.
|
|
1271
|
+
* Source: https://developers.openai.com/apps-sdk/build/chatgpt-ui#useopenaiglobal
|
|
1272
|
+
*/
|
|
1273
|
+
declare function useOpenAiGlobal<K extends keyof OpenAiGlobals>(key: K): OpenAiGlobals[K] | undefined;
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Access the structured content returned by the tool.
|
|
1277
|
+
* Maps to 'structuredContent' in the tool response.
|
|
1278
|
+
*/
|
|
1279
|
+
declare function useToolOutput<T = any>(): T | undefined;
|
|
1280
|
+
/**
|
|
1281
|
+
* Access metadata about the tool response.
|
|
1282
|
+
* Maps to '_meta' in the tool response.
|
|
1283
|
+
*/
|
|
1284
|
+
declare function useToolResponseMetadata<T = any>(): T | undefined;
|
|
1285
|
+
/**
|
|
1286
|
+
* Access the input arguments passed to the tool.
|
|
1287
|
+
*/
|
|
1288
|
+
declare function useToolInput<T = any>(): T | undefined;
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* Hook to read and write widget state.
|
|
1292
|
+
* Widget state persists across the session for this specific widget instance.
|
|
1293
|
+
*
|
|
1294
|
+
* @param initialState - Default state if none exists
|
|
1295
|
+
*/
|
|
1296
|
+
declare function useWidgetState<T extends Record<string, unknown>>(initialState: T | (() => T)): [T, (newState: T | ((prev: T) => T)) => void];
|
|
1297
|
+
|
|
1219
1298
|
declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
1220
1299
|
declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
1221
1300
|
|
|
@@ -1623,4 +1702,4 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'>
|
|
|
1623
1702
|
*/
|
|
1624
1703
|
declare const Input: React__default.ForwardRefExoticComponent<InputProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
1625
1704
|
|
|
1626
|
-
export { ActionButton, type ActionButtonProps, Alert, AlertDescription, AlertTitle, type AppInfo, type AppOptions, AppProvider, type AppProviderProps, AppShell, type AppShellProps, Badge, Button, type ButtonProps, Card, CardContent, type CardContentProps, CardDescription, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, Chart, type ChartProps, type ChartType, Checkbox, CodeBlock, type CodeBlockProps, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, type ConfirmConfig, DEFAULT_RESULT_CONFIG, DataGrid, type DataGridColumn, type DataGridProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GPTAppProvider, type GPTAppProviderProps, type GptAppContextValue, INITIAL_TOOL_STATE, Input, type InputProps, Label, type McpActionProps, type McpAppContextValue, Modal, type ModalProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RequireConnection, type RequireConnectionProps, type ResourceBinding, type ResourceMeta, ResourceView, type ResourceViewProps, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, Slider, StreamingContent, type StreamingContentProps, Switch, TabContent, type TabContentProps, type TabItem, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, Toaster, type ToolBinding, ToolButton, type ToolButtonProps, type ToolButtonState, type ToolCallState, type ToolContextValue, ToolDataGrid, type ToolDataGridColumn, type ToolDataGridProps, type ToolDataGridRowAction, ToolErrorBoundary, type ToolErrorBoundaryProps, ToolForm, type ToolFormField, type ToolFormProps, ToolInput, type ToolInputProps, type ToolInputSuggestion, ToolProvider, type ToolProviderProps, type ToolResultConfig, ToolSelect, type ToolSelectOption, type ToolSelectProps, type ToolState, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseHostContextReturn, type UseMessageReturn, type UseResourceOptions, type UseResourceReturn, type UseToolInputPartialReturn, type UseToolInputReturn, type UseToolOptions, type UseToolResultReturn, type UseToolReturn, type UseToolStreamOptions, type UseToolStreamReturn, badgeVariants, buttonVariants, cn, normalizeToolBinding, useFormField, useGptApp, useGptTool, useHostContext, useMcpApp, useMessage, useResource, useTool, useToolContext, useToolInput, useToolInputPartial, useToolResult, useToolStream, useToolSubscription };
|
|
1705
|
+
export { ActionButton, type ActionButtonProps, Alert, AlertDescription, AlertTitle, type AppInfo, type AppOptions, AppProvider, type AppProviderProps, AppShell, type AppShellProps, Badge, Button, type ButtonProps, Card, CardContent, type CardContentProps, CardDescription, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, Chart, type ChartProps, type ChartType, Checkbox, CodeBlock, type CodeBlockProps, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, type ConfirmConfig, DEFAULT_RESULT_CONFIG, DataGrid, type DataGridColumn, type DataGridProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GPTAppProvider, type GPTAppProviderProps, type GptAppContextValue, INITIAL_TOOL_STATE, Input, type InputProps, Label, type McpActionProps, type McpAppContextValue, Modal, type ModalProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RequireConnection, type RequireConnectionProps, type ResourceBinding, type ResourceMeta, ResourceView, type ResourceViewProps, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, Slider, StreamingContent, type StreamingContentProps, Switch, TabContent, type TabContentProps, type TabItem, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, Toaster, type ToolBinding, ToolButton, type ToolButtonProps, type ToolButtonState, type ToolCallState, type ToolContextValue, ToolDataGrid, type ToolDataGridColumn, type ToolDataGridProps, type ToolDataGridRowAction, ToolErrorBoundary, type ToolErrorBoundaryProps, ToolForm, type ToolFormField, type ToolFormProps, ToolInput, type ToolInputProps, type ToolInputSuggestion, ToolProvider, type ToolProviderProps, type ToolResultConfig, ToolSelect, type ToolSelectOption, type ToolSelectProps, type ToolState, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseHostContextReturn, type UseMessageReturn, type UseResourceOptions, type UseResourceReturn, type UseToolInputPartialReturn, type UseToolInputReturn, type UseToolOptions, type UseToolResultReturn, type UseToolReturn, type UseToolStreamOptions, type UseToolStreamReturn, badgeVariants, buttonVariants, cn, normalizeToolBinding, useFormField, useGptApp, useGptTool, useHostContext, useMcpApp, useMessage, useOpenAiGlobal, useResource, useTool, useToolContext, useToolInput$1 as useToolInput, useToolInputPartial, useToolInput as useToolInputSpec, useToolOutput, useToolResponseMetadata, useToolResult, useToolStream, useToolSubscription, useWidgetState };
|
package/dist/index.d.ts
CHANGED
|
@@ -124,11 +124,35 @@ declare function useMcpApp(): McpAppContextValue;
|
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* ChatGPT's window.openai interface
|
|
127
|
-
*
|
|
127
|
+
* Based on: https://developers.openai.com/apps-sdk/build/chatgpt-ui#understand-the-windowopenai-api
|
|
128
128
|
*/
|
|
129
129
|
interface OpenAISDK {
|
|
130
|
+
/** Input arguments for the tool */
|
|
131
|
+
toolInput?: Record<string, unknown>;
|
|
132
|
+
/** Structured content returned by the tool */
|
|
133
|
+
toolOutput?: any;
|
|
134
|
+
/** Metadata returned by the tool */
|
|
135
|
+
toolResponseMetadata?: Record<string, unknown>;
|
|
136
|
+
/** Persisted state for this widget instance */
|
|
137
|
+
widgetState?: Record<string, unknown>;
|
|
130
138
|
/** Call a server tool */
|
|
131
139
|
callTool: (name: string, args: Record<string, unknown>) => Promise<any>;
|
|
140
|
+
/** Send a follow-up message to chat */
|
|
141
|
+
sendFollowUpMessage?: (options: {
|
|
142
|
+
prompt: string;
|
|
143
|
+
}) => Promise<void>;
|
|
144
|
+
/** Upload a file */
|
|
145
|
+
uploadFile?: (file: File) => Promise<{
|
|
146
|
+
fileId: string;
|
|
147
|
+
}>;
|
|
148
|
+
/** Get download URL for a file */
|
|
149
|
+
getFileDownloadUrl?: (options: {
|
|
150
|
+
fileId: string;
|
|
151
|
+
}) => Promise<{
|
|
152
|
+
downloadUrl: string;
|
|
153
|
+
}>;
|
|
154
|
+
/** Persist widget state */
|
|
155
|
+
setWidgetState?: (state: Record<string, unknown>) => void;
|
|
132
156
|
/** Current theme */
|
|
133
157
|
theme?: 'light' | 'dark';
|
|
134
158
|
/** Current locale */
|
|
@@ -137,6 +161,15 @@ interface OpenAISDK {
|
|
|
137
161
|
displayMode?: 'inline' | 'modal' | 'fullscreen';
|
|
138
162
|
/** Maximum height for the widget */
|
|
139
163
|
maxHeight?: number;
|
|
164
|
+
/** Safe area insets */
|
|
165
|
+
safeArea?: {
|
|
166
|
+
top: number;
|
|
167
|
+
right: number;
|
|
168
|
+
bottom: number;
|
|
169
|
+
left: number;
|
|
170
|
+
};
|
|
171
|
+
/** View type */
|
|
172
|
+
view?: 'desktop' | 'mobile';
|
|
140
173
|
}
|
|
141
174
|
declare global {
|
|
142
175
|
interface Window {
|
|
@@ -1143,7 +1176,7 @@ interface UseToolInputReturn<T = Record<string, unknown>> {
|
|
|
1143
1176
|
* }
|
|
1144
1177
|
* ```
|
|
1145
1178
|
*/
|
|
1146
|
-
declare function useToolInput<T = Record<string, unknown>>(): UseToolInputReturn<T>;
|
|
1179
|
+
declare function useToolInput$1<T = Record<string, unknown>>(): UseToolInputReturn<T>;
|
|
1147
1180
|
|
|
1148
1181
|
interface UseToolInputPartialReturn {
|
|
1149
1182
|
/** Partial arguments currently available */
|
|
@@ -1216,6 +1249,52 @@ interface UseToolSubscriptionResult<T = unknown> {
|
|
|
1216
1249
|
*/
|
|
1217
1250
|
declare function useToolSubscription<T = unknown>(toolName: string, options?: UseToolSubscriptionOptions): UseToolSubscriptionResult<T>;
|
|
1218
1251
|
|
|
1252
|
+
interface OpenAiGlobals {
|
|
1253
|
+
toolInput: Record<string, unknown>;
|
|
1254
|
+
toolOutput: any;
|
|
1255
|
+
toolResponseMetadata: Record<string, unknown>;
|
|
1256
|
+
widgetState: Record<string, unknown>;
|
|
1257
|
+
theme: 'light' | 'dark';
|
|
1258
|
+
displayMode: 'inline' | 'modal' | 'fullscreen';
|
|
1259
|
+
maxHeight: number;
|
|
1260
|
+
safeArea: {
|
|
1261
|
+
top: number;
|
|
1262
|
+
right: number;
|
|
1263
|
+
bottom: number;
|
|
1264
|
+
left: number;
|
|
1265
|
+
};
|
|
1266
|
+
view: 'desktop' | 'mobile';
|
|
1267
|
+
locale: string;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* React hook to subscribe to window.openai global values.
|
|
1271
|
+
* Source: https://developers.openai.com/apps-sdk/build/chatgpt-ui#useopenaiglobal
|
|
1272
|
+
*/
|
|
1273
|
+
declare function useOpenAiGlobal<K extends keyof OpenAiGlobals>(key: K): OpenAiGlobals[K] | undefined;
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Access the structured content returned by the tool.
|
|
1277
|
+
* Maps to 'structuredContent' in the tool response.
|
|
1278
|
+
*/
|
|
1279
|
+
declare function useToolOutput<T = any>(): T | undefined;
|
|
1280
|
+
/**
|
|
1281
|
+
* Access metadata about the tool response.
|
|
1282
|
+
* Maps to '_meta' in the tool response.
|
|
1283
|
+
*/
|
|
1284
|
+
declare function useToolResponseMetadata<T = any>(): T | undefined;
|
|
1285
|
+
/**
|
|
1286
|
+
* Access the input arguments passed to the tool.
|
|
1287
|
+
*/
|
|
1288
|
+
declare function useToolInput<T = any>(): T | undefined;
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* Hook to read and write widget state.
|
|
1292
|
+
* Widget state persists across the session for this specific widget instance.
|
|
1293
|
+
*
|
|
1294
|
+
* @param initialState - Default state if none exists
|
|
1295
|
+
*/
|
|
1296
|
+
declare function useWidgetState<T extends Record<string, unknown>>(initialState: T | (() => T)): [T, (newState: T | ((prev: T) => T)) => void];
|
|
1297
|
+
|
|
1219
1298
|
declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
1220
1299
|
declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
1221
1300
|
|
|
@@ -1623,4 +1702,4 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'>
|
|
|
1623
1702
|
*/
|
|
1624
1703
|
declare const Input: React__default.ForwardRefExoticComponent<InputProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
1625
1704
|
|
|
1626
|
-
export { ActionButton, type ActionButtonProps, Alert, AlertDescription, AlertTitle, type AppInfo, type AppOptions, AppProvider, type AppProviderProps, AppShell, type AppShellProps, Badge, Button, type ButtonProps, Card, CardContent, type CardContentProps, CardDescription, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, Chart, type ChartProps, type ChartType, Checkbox, CodeBlock, type CodeBlockProps, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, type ConfirmConfig, DEFAULT_RESULT_CONFIG, DataGrid, type DataGridColumn, type DataGridProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GPTAppProvider, type GPTAppProviderProps, type GptAppContextValue, INITIAL_TOOL_STATE, Input, type InputProps, Label, type McpActionProps, type McpAppContextValue, Modal, type ModalProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RequireConnection, type RequireConnectionProps, type ResourceBinding, type ResourceMeta, ResourceView, type ResourceViewProps, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, Slider, StreamingContent, type StreamingContentProps, Switch, TabContent, type TabContentProps, type TabItem, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, Toaster, type ToolBinding, ToolButton, type ToolButtonProps, type ToolButtonState, type ToolCallState, type ToolContextValue, ToolDataGrid, type ToolDataGridColumn, type ToolDataGridProps, type ToolDataGridRowAction, ToolErrorBoundary, type ToolErrorBoundaryProps, ToolForm, type ToolFormField, type ToolFormProps, ToolInput, type ToolInputProps, type ToolInputSuggestion, ToolProvider, type ToolProviderProps, type ToolResultConfig, ToolSelect, type ToolSelectOption, type ToolSelectProps, type ToolState, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseHostContextReturn, type UseMessageReturn, type UseResourceOptions, type UseResourceReturn, type UseToolInputPartialReturn, type UseToolInputReturn, type UseToolOptions, type UseToolResultReturn, type UseToolReturn, type UseToolStreamOptions, type UseToolStreamReturn, badgeVariants, buttonVariants, cn, normalizeToolBinding, useFormField, useGptApp, useGptTool, useHostContext, useMcpApp, useMessage, useResource, useTool, useToolContext, useToolInput, useToolInputPartial, useToolResult, useToolStream, useToolSubscription };
|
|
1705
|
+
export { ActionButton, type ActionButtonProps, Alert, AlertDescription, AlertTitle, type AppInfo, type AppOptions, AppProvider, type AppProviderProps, AppShell, type AppShellProps, Badge, Button, type ButtonProps, Card, CardContent, type CardContentProps, CardDescription, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, Chart, type ChartProps, type ChartType, Checkbox, CodeBlock, type CodeBlockProps, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, type ConfirmConfig, DEFAULT_RESULT_CONFIG, DataGrid, type DataGridColumn, type DataGridProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, GPTAppProvider, type GPTAppProviderProps, type GptAppContextValue, INITIAL_TOOL_STATE, Input, type InputProps, Label, type McpActionProps, type McpAppContextValue, Modal, type ModalProps, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, RequireConnection, type RequireConnectionProps, type ResourceBinding, type ResourceMeta, ResourceView, type ResourceViewProps, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, Slider, StreamingContent, type StreamingContentProps, Switch, TabContent, type TabContentProps, type TabItem, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, type TabsProps, TabsTrigger, Textarea, Toaster, type ToolBinding, ToolButton, type ToolButtonProps, type ToolButtonState, type ToolCallState, type ToolContextValue, ToolDataGrid, type ToolDataGridColumn, type ToolDataGridProps, type ToolDataGridRowAction, ToolErrorBoundary, type ToolErrorBoundaryProps, ToolForm, type ToolFormField, type ToolFormProps, ToolInput, type ToolInputProps, type ToolInputSuggestion, ToolProvider, type ToolProviderProps, type ToolResultConfig, ToolSelect, type ToolSelectOption, type ToolSelectProps, type ToolState, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseHostContextReturn, type UseMessageReturn, type UseResourceOptions, type UseResourceReturn, type UseToolInputPartialReturn, type UseToolInputReturn, type UseToolOptions, type UseToolResultReturn, type UseToolReturn, type UseToolStreamOptions, type UseToolStreamReturn, badgeVariants, buttonVariants, cn, normalizeToolBinding, useFormField, useGptApp, useGptTool, useHostContext, useMcpApp, useMessage, useOpenAiGlobal, useResource, useTool, useToolContext, useToolInput$1 as useToolInput, useToolInputPartial, useToolInput as useToolInputSpec, useToolOutput, useToolResponseMetadata, useToolResult, useToolStream, useToolSubscription, useWidgetState };
|
package/dist/index.js
CHANGED
|
@@ -2666,6 +2666,59 @@ function useToolSubscription(toolName, options = {}) {
|
|
|
2666
2666
|
};
|
|
2667
2667
|
}
|
|
2668
2668
|
chunk2HRO6CFU_js.__name(useToolSubscription, "useToolSubscription");
|
|
2669
|
+
var SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
2670
|
+
function useOpenAiGlobal(key) {
|
|
2671
|
+
return React26.useSyncExternalStore((onChange) => {
|
|
2672
|
+
const handleSetGlobal = /* @__PURE__ */ chunk2HRO6CFU_js.__name((event) => {
|
|
2673
|
+
const customEvent = event;
|
|
2674
|
+
const value = customEvent.detail?.globals?.[key];
|
|
2675
|
+
if (value !== void 0) {
|
|
2676
|
+
onChange();
|
|
2677
|
+
}
|
|
2678
|
+
}, "handleSetGlobal");
|
|
2679
|
+
window.addEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal, {
|
|
2680
|
+
passive: true
|
|
2681
|
+
});
|
|
2682
|
+
return () => {
|
|
2683
|
+
window.removeEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal);
|
|
2684
|
+
};
|
|
2685
|
+
}, () => window.openai?.[key]);
|
|
2686
|
+
}
|
|
2687
|
+
chunk2HRO6CFU_js.__name(useOpenAiGlobal, "useOpenAiGlobal");
|
|
2688
|
+
|
|
2689
|
+
// src/mcp/useToolData.ts
|
|
2690
|
+
function useToolOutput() {
|
|
2691
|
+
return useOpenAiGlobal("toolOutput");
|
|
2692
|
+
}
|
|
2693
|
+
chunk2HRO6CFU_js.__name(useToolOutput, "useToolOutput");
|
|
2694
|
+
function useToolResponseMetadata() {
|
|
2695
|
+
return useOpenAiGlobal("toolResponseMetadata");
|
|
2696
|
+
}
|
|
2697
|
+
chunk2HRO6CFU_js.__name(useToolResponseMetadata, "useToolResponseMetadata");
|
|
2698
|
+
function useToolInput2() {
|
|
2699
|
+
return useOpenAiGlobal("toolInput");
|
|
2700
|
+
}
|
|
2701
|
+
chunk2HRO6CFU_js.__name(useToolInput2, "useToolInput");
|
|
2702
|
+
function useWidgetState(initialState) {
|
|
2703
|
+
const rawState = useOpenAiGlobal("widgetState");
|
|
2704
|
+
const resolvedInitial = rawState ?? (typeof initialState === "function" ? initialState() : initialState);
|
|
2705
|
+
const setWidgetState = React26.useCallback((newStateOrUpdater) => {
|
|
2706
|
+
if (!window.openai?.setWidgetState) {
|
|
2707
|
+
console.warn("window.openai.setWidgetState is not available");
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2710
|
+
const current = window.openai.widgetState ?? resolvedInitial;
|
|
2711
|
+
const next = typeof newStateOrUpdater === "function" ? newStateOrUpdater(current) : newStateOrUpdater;
|
|
2712
|
+
window.openai.setWidgetState(next);
|
|
2713
|
+
}, [
|
|
2714
|
+
resolvedInitial
|
|
2715
|
+
]);
|
|
2716
|
+
return [
|
|
2717
|
+
resolvedInitial,
|
|
2718
|
+
setWidgetState
|
|
2719
|
+
];
|
|
2720
|
+
}
|
|
2721
|
+
chunk2HRO6CFU_js.__name(useWidgetState, "useWidgetState");
|
|
2669
2722
|
|
|
2670
2723
|
// src/types/mcp-types.ts
|
|
2671
2724
|
function normalizeToolBinding(tool) {
|
|
@@ -3605,13 +3658,18 @@ exports.useGptTool = useGptTool;
|
|
|
3605
3658
|
exports.useHostContext = useHostContext;
|
|
3606
3659
|
exports.useMcpApp = useMcpApp;
|
|
3607
3660
|
exports.useMessage = useMessage;
|
|
3661
|
+
exports.useOpenAiGlobal = useOpenAiGlobal;
|
|
3608
3662
|
exports.useResource = useResource;
|
|
3609
3663
|
exports.useTool = useTool;
|
|
3610
3664
|
exports.useToolContext = useToolContext;
|
|
3611
3665
|
exports.useToolInput = useToolInput;
|
|
3612
3666
|
exports.useToolInputPartial = useToolInputPartial;
|
|
3667
|
+
exports.useToolInputSpec = useToolInput2;
|
|
3668
|
+
exports.useToolOutput = useToolOutput;
|
|
3669
|
+
exports.useToolResponseMetadata = useToolResponseMetadata;
|
|
3613
3670
|
exports.useToolResult = useToolResult;
|
|
3614
3671
|
exports.useToolStream = useToolStream;
|
|
3615
3672
|
exports.useToolSubscription = useToolSubscription;
|
|
3673
|
+
exports.useWidgetState = useWidgetState;
|
|
3616
3674
|
//# sourceMappingURL=index.js.map
|
|
3617
3675
|
//# sourceMappingURL=index.js.map
|