@pancake-apps/web 0.0.0-snapshot-20260125200133
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 +333 -0
- package/dist/adaptor-interface-BYbH9PpT.d.ts +370 -0
- package/dist/apps-sdk/index.d.ts +1 -0
- package/dist/apps-sdk/index.js +4 -0
- package/dist/apps-sdk/index.js.map +1 -0
- package/dist/chunk-5NYJ2IVD.js +406 -0
- package/dist/chunk-5NYJ2IVD.js.map +1 -0
- package/dist/chunk-7HJ5PKKT.js +146 -0
- package/dist/chunk-7HJ5PKKT.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-TLBYYZHP.js +715 -0
- package/dist/chunk-TLBYYZHP.js.map +1 -0
- package/dist/chunk-YGGRUIUG.js +977 -0
- package/dist/chunk-YGGRUIUG.js.map +1 -0
- package/dist/chunk-ZYBPDIEG.js +674 -0
- package/dist/chunk-ZYBPDIEG.js.map +1 -0
- package/dist/core/index.d.ts +169 -0
- package/dist/core/index.js +195 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index-BBfZZJWn.d.ts +671 -0
- package/dist/index-CpXDfXKD.d.ts +395 -0
- package/dist/index-DtukOUjY.d.ts +738 -0
- package/dist/index.d.ts +741 -0
- package/dist/index.js +685 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-apps/index.d.ts +2 -0
- package/dist/mcp-apps/index.js +4 -0
- package/dist/mcp-apps/index.js.map +1 -0
- package/dist/notify-size-changed-Ck2BGfUk.d.ts +270 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +7 -0
- package/dist/react/index.js.map +1 -0
- package/dist/types-B_O3kZYh.d.ts +253 -0
- package/package.json +90 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChatGPT Apps SDK Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* These types match the window.openai runtime interface as specified
|
|
5
|
+
* in the ChatGPT Apps SDK documentation.
|
|
6
|
+
*/
|
|
7
|
+
type Theme = 'light' | 'dark';
|
|
8
|
+
type DisplayMode = 'inline' | 'pip' | 'fullscreen';
|
|
9
|
+
interface SafeAreaInsets {
|
|
10
|
+
top: number;
|
|
11
|
+
right: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
left: number;
|
|
14
|
+
}
|
|
15
|
+
interface ContentBlock {
|
|
16
|
+
type: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
interface CallToolResult<TOutput = unknown> {
|
|
21
|
+
content: ContentBlock[];
|
|
22
|
+
structuredContent?: TOutput;
|
|
23
|
+
isError?: boolean;
|
|
24
|
+
_meta?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read-only properties available on window.openai
|
|
28
|
+
*/
|
|
29
|
+
interface OpenAiGlobals {
|
|
30
|
+
theme: Theme;
|
|
31
|
+
locale: string;
|
|
32
|
+
displayMode: DisplayMode;
|
|
33
|
+
maxHeight: number;
|
|
34
|
+
safeArea: SafeAreaInsets;
|
|
35
|
+
view: string;
|
|
36
|
+
userAgent: string;
|
|
37
|
+
toolInput: Record<string, unknown> | undefined;
|
|
38
|
+
toolOutput: unknown | undefined;
|
|
39
|
+
toolResponseMetadata: Record<string, unknown> | undefined;
|
|
40
|
+
widgetState: unknown | undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Methods available on window.openai
|
|
44
|
+
*/
|
|
45
|
+
interface OpenAiMethods {
|
|
46
|
+
callTool(name: string, args?: Record<string, unknown>): Promise<CallToolResult>;
|
|
47
|
+
sendFollowUpMessage(options: {
|
|
48
|
+
prompt: string;
|
|
49
|
+
}): void;
|
|
50
|
+
uploadFile(file: File): Promise<{
|
|
51
|
+
fileId: string;
|
|
52
|
+
}>;
|
|
53
|
+
getFileDownloadUrl(options: {
|
|
54
|
+
fileId: string;
|
|
55
|
+
}): Promise<{
|
|
56
|
+
url: string;
|
|
57
|
+
}>;
|
|
58
|
+
requestDisplayMode(mode: DisplayMode): void;
|
|
59
|
+
requestModal(options: ModalOptions): Promise<void>;
|
|
60
|
+
notifyIntrinsicHeight(options: {
|
|
61
|
+
height: number;
|
|
62
|
+
}): void;
|
|
63
|
+
requestClose(): void;
|
|
64
|
+
openExternal(options: {
|
|
65
|
+
href: string;
|
|
66
|
+
}): void;
|
|
67
|
+
setOpenInAppUrl(options: {
|
|
68
|
+
href: string;
|
|
69
|
+
}): void;
|
|
70
|
+
setWidgetState(state: unknown): void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Complete window.openai interface
|
|
74
|
+
*/
|
|
75
|
+
interface OpenAiRuntime extends OpenAiGlobals, OpenAiMethods {
|
|
76
|
+
}
|
|
77
|
+
declare const SET_GLOBALS_EVENT_TYPE: "openai:set_globals";
|
|
78
|
+
interface SetGlobalsEventDetail {
|
|
79
|
+
globals: OpenAiGlobals;
|
|
80
|
+
changes: Partial<OpenAiGlobals>;
|
|
81
|
+
}
|
|
82
|
+
interface SetGlobalsEvent extends CustomEvent<SetGlobalsEventDetail> {
|
|
83
|
+
type: typeof SET_GLOBALS_EVENT_TYPE;
|
|
84
|
+
}
|
|
85
|
+
interface ModalOptions {
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
}
|
|
88
|
+
declare global {
|
|
89
|
+
interface Window {
|
|
90
|
+
openai?: OpenAiRuntime;
|
|
91
|
+
}
|
|
92
|
+
interface WindowEventMap {
|
|
93
|
+
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* AppsSdkBridge
|
|
99
|
+
*
|
|
100
|
+
* Singleton bridge that wraps window.openai, providing:
|
|
101
|
+
* - Runtime availability checking
|
|
102
|
+
* - Method wrappers with proper typing
|
|
103
|
+
* - Error handling for missing runtime
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
declare class AppsSdkBridge {
|
|
107
|
+
private static instance;
|
|
108
|
+
/**
|
|
109
|
+
* Get the singleton bridge instance
|
|
110
|
+
* @throws Error if window.openai is not available
|
|
111
|
+
*/
|
|
112
|
+
static getInstance(): AppsSdkBridge;
|
|
113
|
+
/**
|
|
114
|
+
* Check if the Apps SDK runtime is available
|
|
115
|
+
*/
|
|
116
|
+
static isAvailable(): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Reset the singleton (for testing)
|
|
119
|
+
*/
|
|
120
|
+
static reset(): void;
|
|
121
|
+
private constructor();
|
|
122
|
+
/**
|
|
123
|
+
* Get the raw window.openai runtime
|
|
124
|
+
*/
|
|
125
|
+
private get runtime();
|
|
126
|
+
/**
|
|
127
|
+
* Call an MCP tool
|
|
128
|
+
*/
|
|
129
|
+
callTool<TInput = Record<string, unknown>, TOutput = unknown>(name: string, args?: TInput): Promise<CallToolResult<TOutput>>;
|
|
130
|
+
/**
|
|
131
|
+
* Send a follow-up message to the conversation
|
|
132
|
+
*/
|
|
133
|
+
sendFollowUpMessage(prompt: string): void;
|
|
134
|
+
/**
|
|
135
|
+
* Upload a file and get its ID
|
|
136
|
+
*/
|
|
137
|
+
uploadFile(file: File): Promise<{
|
|
138
|
+
fileId: string;
|
|
139
|
+
}>;
|
|
140
|
+
/**
|
|
141
|
+
* Get a temporary download URL for a file
|
|
142
|
+
*/
|
|
143
|
+
getFileDownloadUrl(fileId: string): Promise<{
|
|
144
|
+
url: string;
|
|
145
|
+
}>;
|
|
146
|
+
/**
|
|
147
|
+
* Request a change in display mode
|
|
148
|
+
*/
|
|
149
|
+
requestDisplayMode(mode: DisplayMode): void;
|
|
150
|
+
/**
|
|
151
|
+
* Request to show a modal dialog
|
|
152
|
+
*/
|
|
153
|
+
requestModal(options: ModalOptions): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Notify the host of the widget's intrinsic height
|
|
156
|
+
*/
|
|
157
|
+
notifyIntrinsicHeight(height: number): void;
|
|
158
|
+
/**
|
|
159
|
+
* Request to close/hide the widget
|
|
160
|
+
*/
|
|
161
|
+
requestClose(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Open an external URL in the user's browser
|
|
164
|
+
*/
|
|
165
|
+
openExternal(href: string): void;
|
|
166
|
+
/**
|
|
167
|
+
* Set the "Open in App" URL for fullscreen mode
|
|
168
|
+
*/
|
|
169
|
+
setOpenInAppUrl(href: string): void;
|
|
170
|
+
/**
|
|
171
|
+
* Set the widget state (persisted by host)
|
|
172
|
+
*/
|
|
173
|
+
setWidgetState<T>(state: T): void;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get the bridge instance (convenience function)
|
|
177
|
+
*/
|
|
178
|
+
declare function getBridge(): AppsSdkBridge;
|
|
179
|
+
/**
|
|
180
|
+
* Check if Apps SDK is available (convenience function)
|
|
181
|
+
*/
|
|
182
|
+
declare function isAppsSdkAvailable(): boolean;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* AppsSdkStore
|
|
186
|
+
*
|
|
187
|
+
* External store implementation for React 18's useSyncExternalStore.
|
|
188
|
+
* Listens to openai:set_globals events for reactive updates.
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
type Subscriber = () => void;
|
|
192
|
+
type Unsubscribe = () => void;
|
|
193
|
+
declare class AppsSdkStore {
|
|
194
|
+
private static instance;
|
|
195
|
+
private subscribers;
|
|
196
|
+
private globalSubscribers;
|
|
197
|
+
static getInstance(): AppsSdkStore;
|
|
198
|
+
static reset(): void;
|
|
199
|
+
private constructor();
|
|
200
|
+
private setupEventListener;
|
|
201
|
+
private cleanup;
|
|
202
|
+
private handleSetGlobals;
|
|
203
|
+
/**
|
|
204
|
+
* Subscribe to changes for specific keys
|
|
205
|
+
*/
|
|
206
|
+
subscribe(keys: keyof OpenAiGlobals | (keyof OpenAiGlobals)[], callback: Subscriber): Unsubscribe;
|
|
207
|
+
/**
|
|
208
|
+
* Subscribe to any change
|
|
209
|
+
*/
|
|
210
|
+
subscribeAll(callback: Subscriber): Unsubscribe;
|
|
211
|
+
/**
|
|
212
|
+
* Get current value of a global property
|
|
213
|
+
*/
|
|
214
|
+
getSnapshot<K extends keyof OpenAiGlobals>(key: K): OpenAiGlobals[K] | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* Get server snapshot (for SSR, returns undefined)
|
|
217
|
+
*/
|
|
218
|
+
getServerSnapshot<K extends keyof OpenAiGlobals>(_key: K): undefined;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Get the store instance (convenience function)
|
|
223
|
+
*/
|
|
224
|
+
declare function getStore(): AppsSdkStore;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Base hook factory for creating reactive hooks for window.openai properties
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Create a hook that subscribes to a specific window.openai property
|
|
232
|
+
*/
|
|
233
|
+
declare function createOpenAiGlobalHook<K extends keyof OpenAiGlobals>(key: K): () => OpenAiGlobals[K] | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* Generic hook to access any window.openai property
|
|
236
|
+
*/
|
|
237
|
+
declare function useOpenAiGlobal<K extends keyof OpenAiGlobals>(key: K): OpenAiGlobals[K] | undefined;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Get the current theme (light or dark)
|
|
241
|
+
*
|
|
242
|
+
* @returns Current theme, defaults to 'light' if not available
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```tsx
|
|
246
|
+
* function MyWidget() {
|
|
247
|
+
* const theme = useTheme();
|
|
248
|
+
* return <div className={theme === 'dark' ? 'dark' : 'light'}>...</div>;
|
|
249
|
+
* }
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
declare function useTheme(): Theme;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Get the user's locale setting
|
|
256
|
+
*
|
|
257
|
+
* @returns BCP 47 language tag (e.g., 'en-US', 'ja-JP')
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```tsx
|
|
261
|
+
* function MyWidget() {
|
|
262
|
+
* const locale = useLocale();
|
|
263
|
+
* const formatter = new Intl.DateTimeFormat(locale);
|
|
264
|
+
* return <span>{formatter.format(new Date())}</span>;
|
|
265
|
+
* }
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
declare function useLocale(): string;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Get the current widget display mode
|
|
272
|
+
*
|
|
273
|
+
* @returns Current display mode: 'inline', 'pip', or 'fullscreen'
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```tsx
|
|
277
|
+
* function MyWidget() {
|
|
278
|
+
* const mode = useDisplayMode();
|
|
279
|
+
* if (mode === 'fullscreen') {
|
|
280
|
+
* return <FullscreenLayout />;
|
|
281
|
+
* }
|
|
282
|
+
* return <CompactLayout />;
|
|
283
|
+
* }
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
declare function useDisplayMode(): DisplayMode;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Get the maximum allowed height for the widget
|
|
290
|
+
*
|
|
291
|
+
* @returns Maximum height in pixels
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```tsx
|
|
295
|
+
* function MyWidget() {
|
|
296
|
+
* const maxHeight = useMaxHeight();
|
|
297
|
+
* return <div style={{ maxHeight }}>...</div>;
|
|
298
|
+
* }
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
declare function useMaxHeight(): number;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Get safe area insets for devices with notches/rounded corners
|
|
305
|
+
*
|
|
306
|
+
* @returns Safe area insets object
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```tsx
|
|
310
|
+
* function MyWidget() {
|
|
311
|
+
* const safeArea = useSafeArea();
|
|
312
|
+
* return (
|
|
313
|
+
* <div style={{ paddingTop: safeArea.top, paddingBottom: safeArea.bottom }}>
|
|
314
|
+
* ...
|
|
315
|
+
* </div>
|
|
316
|
+
* );
|
|
317
|
+
* }
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
declare function useSafeArea(): SafeAreaInsets;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Get the view context identifier
|
|
324
|
+
*
|
|
325
|
+
* @returns View identifier string or undefined
|
|
326
|
+
*/
|
|
327
|
+
declare function useView(): string | undefined;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Get the user agent string
|
|
331
|
+
*
|
|
332
|
+
* Note: Do not rely on this for security decisions.
|
|
333
|
+
*
|
|
334
|
+
* @returns User agent string or undefined
|
|
335
|
+
*/
|
|
336
|
+
declare function useUserAgent(): string | undefined;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Get the tool input arguments
|
|
340
|
+
*
|
|
341
|
+
* @returns Tool input arguments or undefined if not yet available
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```tsx
|
|
345
|
+
* interface SearchInput {
|
|
346
|
+
* query: string;
|
|
347
|
+
* limit?: number;
|
|
348
|
+
* }
|
|
349
|
+
*
|
|
350
|
+
* function SearchWidget() {
|
|
351
|
+
* const input = useToolInput<SearchInput>();
|
|
352
|
+
*
|
|
353
|
+
* if (!input) {
|
|
354
|
+
* return <Loading />;
|
|
355
|
+
* }
|
|
356
|
+
*
|
|
357
|
+
* return <div>Searching for: {input.query}</div>;
|
|
358
|
+
* }
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare function useToolInput<T = Record<string, unknown>>(): T | undefined;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Get the tool output (structuredContent from tool response)
|
|
365
|
+
*
|
|
366
|
+
* This is the concise JSON that both widget and model can access.
|
|
367
|
+
*
|
|
368
|
+
* @returns Tool output or undefined if not yet available
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```tsx
|
|
372
|
+
* interface SearchOutput {
|
|
373
|
+
* results: Array<{ id: string; title: string }>;
|
|
374
|
+
* total: number;
|
|
375
|
+
* }
|
|
376
|
+
*
|
|
377
|
+
* function SearchWidget() {
|
|
378
|
+
* const output = useToolOutput<SearchOutput>();
|
|
379
|
+
*
|
|
380
|
+
* if (!output) {
|
|
381
|
+
* return <Loading />;
|
|
382
|
+
* }
|
|
383
|
+
*
|
|
384
|
+
* return (
|
|
385
|
+
* <ul>
|
|
386
|
+
* {output.results.map(r => <li key={r.id}>{r.title}</li>)}
|
|
387
|
+
* </ul>
|
|
388
|
+
* );
|
|
389
|
+
* }
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
declare function useToolOutput<T = unknown>(): T | undefined;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Get the tool response metadata (_meta from tool response)
|
|
396
|
+
*
|
|
397
|
+
* This data is only visible to the widget, never sent to the model.
|
|
398
|
+
* Use for large datasets, sensitive info, or data not needed for model reasoning.
|
|
399
|
+
*
|
|
400
|
+
* @returns Tool response metadata or undefined
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```tsx
|
|
404
|
+
* interface SearchMetadata {
|
|
405
|
+
* fullResultData: Array<FullResult>;
|
|
406
|
+
* timing: number;
|
|
407
|
+
* }
|
|
408
|
+
*
|
|
409
|
+
* function SearchWidget() {
|
|
410
|
+
* const meta = useToolResponseMetadata<SearchMetadata>();
|
|
411
|
+
* // meta.fullResultData has the complete data
|
|
412
|
+
* // meta.timing shows how long the search took
|
|
413
|
+
* }
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
declare function useToolResponseMetadata<T = Record<string, unknown>>(): T | undefined;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Bidirectional sync with host-persisted widget state
|
|
420
|
+
*
|
|
421
|
+
* State is scoped to the specific widget instance on a single message.
|
|
422
|
+
* It persists across page refreshes and conversation reopening.
|
|
423
|
+
*
|
|
424
|
+
* @param defaultState - Optional default state if no persisted state exists
|
|
425
|
+
* @returns Tuple of [state, setState]
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* ```tsx
|
|
429
|
+
* interface EditorState {
|
|
430
|
+
* activeTab: string;
|
|
431
|
+
* scrollPosition: number;
|
|
432
|
+
* }
|
|
433
|
+
*
|
|
434
|
+
* function Editor() {
|
|
435
|
+
* const [state, setState] = useWidgetState<EditorState>({
|
|
436
|
+
* activeTab: 'general',
|
|
437
|
+
* scrollPosition: 0,
|
|
438
|
+
* });
|
|
439
|
+
*
|
|
440
|
+
* const handleTabChange = (tab: string) => {
|
|
441
|
+
* setState({ ...state!, activeTab: tab });
|
|
442
|
+
* };
|
|
443
|
+
*
|
|
444
|
+
* return <Tabs active={state?.activeTab} onChange={handleTabChange} />;
|
|
445
|
+
* }
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
declare function useWidgetState<T>(defaultState?: T): readonly [T | undefined, (newState: T) => void];
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Call an MCP tool from the widget
|
|
452
|
+
*
|
|
453
|
+
* The target tool must have `_meta["openai/widgetAccessible"]: true` set on the server.
|
|
454
|
+
*
|
|
455
|
+
* @param name - Tool name to call
|
|
456
|
+
* @param args - Optional arguments for the tool
|
|
457
|
+
* @returns Promise resolving to tool result
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```tsx
|
|
461
|
+
* const result = await callTool('get_product_details', { productId: '123' });
|
|
462
|
+
* if (result.isError) {
|
|
463
|
+
* console.error('Tool failed:', result.content[0]?.text);
|
|
464
|
+
* } else {
|
|
465
|
+
* console.log('Product:', result.structuredContent);
|
|
466
|
+
* }
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
declare function callTool<TInput = Record<string, unknown>, TOutput = unknown>(name: string, args?: TInput): Promise<CallToolResult<TOutput>>;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Send a follow-up message to the conversation
|
|
473
|
+
*
|
|
474
|
+
* This will post a message authored by the widget into the chat.
|
|
475
|
+
*
|
|
476
|
+
* @param prompt - The message text to send
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```tsx
|
|
480
|
+
* function ActionButton() {
|
|
481
|
+
* const handleClick = () => {
|
|
482
|
+
* sendFollowUpMessage('Show me more options like this one');
|
|
483
|
+
* };
|
|
484
|
+
* return <button onClick={handleClick}>Show more</button>;
|
|
485
|
+
* }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
declare function sendFollowUpMessage(prompt: string): void;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Upload a file and get its ID
|
|
492
|
+
*
|
|
493
|
+
* Supported formats: PNG, JPEG, WebP
|
|
494
|
+
*
|
|
495
|
+
* @param file - File object to upload
|
|
496
|
+
* @returns Promise resolving to object with fileId
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ```tsx
|
|
500
|
+
* const input = document.querySelector('input[type="file"]');
|
|
501
|
+
* const file = input.files[0];
|
|
502
|
+
* const { fileId } = await uploadFile(file);
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
declare function uploadFile(file: File): Promise<{
|
|
506
|
+
fileId: string;
|
|
507
|
+
}>;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Get a temporary download URL for a previously uploaded file
|
|
511
|
+
*
|
|
512
|
+
* The URL is temporary and will expire.
|
|
513
|
+
*
|
|
514
|
+
* @param fileId - ID of the uploaded file
|
|
515
|
+
* @returns Promise resolving to object with temporary URL
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```tsx
|
|
519
|
+
* const { url } = await getFileDownloadUrl('file-abc123');
|
|
520
|
+
* // Use url before it expires
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
declare function getFileDownloadUrl(fileId: string): Promise<{
|
|
524
|
+
url: string;
|
|
525
|
+
}>;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Request a change in widget display mode
|
|
529
|
+
*
|
|
530
|
+
* Note: The host may deny the request based on user preferences or device constraints.
|
|
531
|
+
*
|
|
532
|
+
* @param mode - Desired display mode: 'inline', 'pip', or 'fullscreen'
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```tsx
|
|
536
|
+
* function ExpandButton() {
|
|
537
|
+
* return (
|
|
538
|
+
* <button onClick={() => requestDisplayMode('fullscreen')}>
|
|
539
|
+
* Expand
|
|
540
|
+
* </button>
|
|
541
|
+
* );
|
|
542
|
+
* }
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
declare function requestDisplayMode(mode: DisplayMode): void;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Spawn a modal dialog owned by ChatGPT
|
|
549
|
+
*
|
|
550
|
+
* @param options - Modal configuration options
|
|
551
|
+
* @returns Promise that resolves when modal is closed
|
|
552
|
+
*/
|
|
553
|
+
declare function requestModal(options: ModalOptions): Promise<void>;
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Report the widget's intrinsic content height to the host
|
|
557
|
+
*
|
|
558
|
+
* Use this to avoid scroll clipping when content size changes dynamically.
|
|
559
|
+
*
|
|
560
|
+
* @param height - Content height in pixels
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```tsx
|
|
564
|
+
* function DynamicContent({ content }) {
|
|
565
|
+
* const ref = useRef<HTMLDivElement>(null);
|
|
566
|
+
*
|
|
567
|
+
* useEffect(() => {
|
|
568
|
+
* if (ref.current) {
|
|
569
|
+
* notifyIntrinsicHeight(ref.current.scrollHeight);
|
|
570
|
+
* }
|
|
571
|
+
* }, [content]);
|
|
572
|
+
*
|
|
573
|
+
* return <div ref={ref}>{content}</div>;
|
|
574
|
+
* }
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
declare function notifyIntrinsicHeight(height: number): void;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Programmatically hide/close the widget
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```tsx
|
|
584
|
+
* function CloseButton() {
|
|
585
|
+
* return <button onClick={requestClose}>Close</button>;
|
|
586
|
+
* }
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
589
|
+
declare function requestClose(): void;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Open an external URL in the user's browser
|
|
593
|
+
*
|
|
594
|
+
* The URL must be allowed by the widget's CSP `redirect_domains` configuration.
|
|
595
|
+
*
|
|
596
|
+
* @param href - URL to open
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```tsx
|
|
600
|
+
* function ProductLink({ url, children }) {
|
|
601
|
+
* const handleClick = (e) => {
|
|
602
|
+
* e.preventDefault();
|
|
603
|
+
* openExternal(url);
|
|
604
|
+
* };
|
|
605
|
+
* return <a href={url} onClick={handleClick}>{children}</a>;
|
|
606
|
+
* }
|
|
607
|
+
* ```
|
|
608
|
+
*/
|
|
609
|
+
declare function openExternal(href: string): void;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Set the destination URL for the fullscreen mode's "Open in App" button
|
|
613
|
+
*
|
|
614
|
+
* @param href - URL to set for the "Open in App" button
|
|
615
|
+
*/
|
|
616
|
+
declare function setOpenInAppUrl(href: string): void;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* @pancake-apps/web/apps-sdk
|
|
620
|
+
*
|
|
621
|
+
* Complete SDK for building widgets that run inside ChatGPT.
|
|
622
|
+
* Wraps the window.openai runtime with React hooks and typed actions.
|
|
623
|
+
*/
|
|
624
|
+
|
|
625
|
+
type appsSdk_AppsSdkBridge = AppsSdkBridge;
|
|
626
|
+
declare const appsSdk_AppsSdkBridge: typeof AppsSdkBridge;
|
|
627
|
+
type appsSdk_AppsSdkStore = AppsSdkStore;
|
|
628
|
+
declare const appsSdk_AppsSdkStore: typeof AppsSdkStore;
|
|
629
|
+
type appsSdk_CallToolResult<TOutput = unknown> = CallToolResult<TOutput>;
|
|
630
|
+
type appsSdk_ContentBlock = ContentBlock;
|
|
631
|
+
type appsSdk_DisplayMode = DisplayMode;
|
|
632
|
+
type appsSdk_ModalOptions = ModalOptions;
|
|
633
|
+
type appsSdk_OpenAiGlobals = OpenAiGlobals;
|
|
634
|
+
type appsSdk_OpenAiMethods = OpenAiMethods;
|
|
635
|
+
type appsSdk_OpenAiRuntime = OpenAiRuntime;
|
|
636
|
+
declare const appsSdk_SET_GLOBALS_EVENT_TYPE: typeof SET_GLOBALS_EVENT_TYPE;
|
|
637
|
+
type appsSdk_SafeAreaInsets = SafeAreaInsets;
|
|
638
|
+
type appsSdk_SetGlobalsEvent = SetGlobalsEvent;
|
|
639
|
+
type appsSdk_SetGlobalsEventDetail = SetGlobalsEventDetail;
|
|
640
|
+
type appsSdk_Theme = Theme;
|
|
641
|
+
declare const appsSdk_callTool: typeof callTool;
|
|
642
|
+
declare const appsSdk_createOpenAiGlobalHook: typeof createOpenAiGlobalHook;
|
|
643
|
+
declare const appsSdk_getBridge: typeof getBridge;
|
|
644
|
+
declare const appsSdk_getFileDownloadUrl: typeof getFileDownloadUrl;
|
|
645
|
+
declare const appsSdk_getStore: typeof getStore;
|
|
646
|
+
declare const appsSdk_isAppsSdkAvailable: typeof isAppsSdkAvailable;
|
|
647
|
+
declare const appsSdk_notifyIntrinsicHeight: typeof notifyIntrinsicHeight;
|
|
648
|
+
declare const appsSdk_openExternal: typeof openExternal;
|
|
649
|
+
declare const appsSdk_requestClose: typeof requestClose;
|
|
650
|
+
declare const appsSdk_requestDisplayMode: typeof requestDisplayMode;
|
|
651
|
+
declare const appsSdk_requestModal: typeof requestModal;
|
|
652
|
+
declare const appsSdk_sendFollowUpMessage: typeof sendFollowUpMessage;
|
|
653
|
+
declare const appsSdk_setOpenInAppUrl: typeof setOpenInAppUrl;
|
|
654
|
+
declare const appsSdk_uploadFile: typeof uploadFile;
|
|
655
|
+
declare const appsSdk_useDisplayMode: typeof useDisplayMode;
|
|
656
|
+
declare const appsSdk_useLocale: typeof useLocale;
|
|
657
|
+
declare const appsSdk_useMaxHeight: typeof useMaxHeight;
|
|
658
|
+
declare const appsSdk_useOpenAiGlobal: typeof useOpenAiGlobal;
|
|
659
|
+
declare const appsSdk_useSafeArea: typeof useSafeArea;
|
|
660
|
+
declare const appsSdk_useTheme: typeof useTheme;
|
|
661
|
+
declare const appsSdk_useToolInput: typeof useToolInput;
|
|
662
|
+
declare const appsSdk_useToolOutput: typeof useToolOutput;
|
|
663
|
+
declare const appsSdk_useToolResponseMetadata: typeof useToolResponseMetadata;
|
|
664
|
+
declare const appsSdk_useUserAgent: typeof useUserAgent;
|
|
665
|
+
declare const appsSdk_useView: typeof useView;
|
|
666
|
+
declare const appsSdk_useWidgetState: typeof useWidgetState;
|
|
667
|
+
declare namespace appsSdk {
|
|
668
|
+
export { appsSdk_AppsSdkBridge as AppsSdkBridge, appsSdk_AppsSdkStore as AppsSdkStore, type appsSdk_CallToolResult as CallToolResult, type appsSdk_ContentBlock as ContentBlock, type appsSdk_DisplayMode as DisplayMode, type appsSdk_ModalOptions as ModalOptions, type appsSdk_OpenAiGlobals as OpenAiGlobals, type appsSdk_OpenAiMethods as OpenAiMethods, type appsSdk_OpenAiRuntime as OpenAiRuntime, appsSdk_SET_GLOBALS_EVENT_TYPE as SET_GLOBALS_EVENT_TYPE, type appsSdk_SafeAreaInsets as SafeAreaInsets, type appsSdk_SetGlobalsEvent as SetGlobalsEvent, type appsSdk_SetGlobalsEventDetail as SetGlobalsEventDetail, type appsSdk_Theme as Theme, appsSdk_callTool as callTool, appsSdk_createOpenAiGlobalHook as createOpenAiGlobalHook, appsSdk_getBridge as getBridge, appsSdk_getFileDownloadUrl as getFileDownloadUrl, appsSdk_getStore as getStore, appsSdk_isAppsSdkAvailable as isAppsSdkAvailable, appsSdk_notifyIntrinsicHeight as notifyIntrinsicHeight, appsSdk_openExternal as openExternal, appsSdk_requestClose as requestClose, appsSdk_requestDisplayMode as requestDisplayMode, appsSdk_requestModal as requestModal, appsSdk_sendFollowUpMessage as sendFollowUpMessage, appsSdk_setOpenInAppUrl as setOpenInAppUrl, appsSdk_uploadFile as uploadFile, appsSdk_useDisplayMode as useDisplayMode, appsSdk_useLocale as useLocale, appsSdk_useMaxHeight as useMaxHeight, appsSdk_useOpenAiGlobal as useOpenAiGlobal, appsSdk_useSafeArea as useSafeArea, appsSdk_useTheme as useTheme, appsSdk_useToolInput as useToolInput, appsSdk_useToolOutput as useToolOutput, appsSdk_useToolResponseMetadata as useToolResponseMetadata, appsSdk_useUserAgent as useUserAgent, appsSdk_useView as useView, appsSdk_useWidgetState as useWidgetState };
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
export { AppsSdkBridge as A, uploadFile as B, type ContentBlock as C, type DisplayMode as D, getFileDownloadUrl as E, requestDisplayMode as F, requestModal as G, notifyIntrinsicHeight as H, requestClose as I, openExternal as J, setOpenInAppUrl as K, type ModalOptions as M, type OpenAiGlobals as O, type SafeAreaInsets as S, type Theme as T, appsSdk as a, type CallToolResult as b, type OpenAiMethods as c, type OpenAiRuntime as d, type SetGlobalsEventDetail as e, type SetGlobalsEvent as f, SET_GLOBALS_EVENT_TYPE as g, getBridge as h, isAppsSdkAvailable as i, AppsSdkStore as j, getStore as k, createOpenAiGlobalHook as l, useTheme as m, useLocale as n, useDisplayMode as o, useMaxHeight as p, useSafeArea as q, useView as r, useUserAgent as s, useToolInput as t, useOpenAiGlobal as u, useToolOutput as v, useToolResponseMetadata as w, useWidgetState as x, callTool as y, sendFollowUpMessage as z };
|