Skip to content

Commit 2090e58

Browse files
committed
docs: add TypeScript support section for ChatGPT Apps SDK types
Added comprehensive documentation for the TypeScript type definitions that are already exported by @ainativekit/ui for the ChatGPT Apps SDK. Changes: - Added "TypeScript Support" section to both root and package READMEs - Documented zero-boilerplate usage of window.openai types - Listed all exported types (OpenAiGlobals, OpenAiApi, Theme, etc.) - Included examples showing autocomplete and type safety This resolves the developer pain point where users didn't know that window.openai type definitions are automatically available when they import @ainativekit/ui. Resolves: #3
1 parent ad37780 commit 2090e58

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,57 @@ function MyChatGPTWidget() {
197197
}
198198
```
199199

200+
## 📘 TypeScript Support
201+
202+
AINativeKit UI exports comprehensive TypeScript definitions for the ChatGPT Apps SDK, giving you **full autocomplete and type safety** for `window.openai`.
203+
204+
### Zero Boilerplate - Types Just Work
205+
206+
```tsx
207+
// Simply import the package
208+
import '@ainativekit/ui';
209+
210+
// window.openai is now fully typed! ✨
211+
const theme = window.openai?.theme; // 'light' | 'dark' | undefined
212+
const toolOutput = window.openai?.toolOutput; // string | undefined
213+
const displayMode = window.openai?.displayMode; // 'inline' | 'pip' | 'fullscreen' | undefined
214+
215+
// Full autocomplete for all methods
216+
window.openai?.sendFollowUpMessage({ prompt: 'Show more' });
217+
const result = await window.openai?.callTool('get_weather', { location: 'SF' });
218+
```
219+
220+
### Available Types
221+
222+
All ChatGPT Apps SDK types are exported:
223+
224+
```tsx
225+
import type {
226+
OpenAiGlobals,
227+
OpenAiApi,
228+
Theme,
229+
DisplayMode,
230+
UserAgent,
231+
SafeArea
232+
} from '@ainativekit/ui';
233+
234+
// Use in your own type definitions
235+
type MyWidgetProps = {
236+
theme: Theme;
237+
displayMode: DisplayMode;
238+
};
239+
```
240+
241+
**Exported Types:**
242+
- `OpenAiGlobals` - Complete `window.openai` globals interface
243+
- `OpenAiApi` - API methods (`callTool`, `sendFollowUpMessage`, etc.)
244+
- `Theme` - `'light' | 'dark'`
245+
- `DisplayMode` - `'inline' | 'pip' | 'fullscreen'`
246+
- `UserAgent` - Device type and capabilities
247+
- `SafeArea` - Safe area insets for mobile layouts
248+
- `CallTool` - Type-safe tool calling signature
249+
- And more... (see [types.ts](packages/ui/src/hooks/openai/types.ts))
250+
200251
## 🧰 Development
201252

202253
```bash

packages/ui/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,57 @@ function MyChatGPTWidget() {
198198
}
199199
```
200200

201+
## 📘 TypeScript Support
202+
203+
AINativeKit UI exports comprehensive TypeScript definitions for the ChatGPT Apps SDK, giving you **full autocomplete and type safety** for `window.openai`.
204+
205+
### Zero Boilerplate - Types Just Work
206+
207+
```tsx
208+
// Simply import the package
209+
import '@ainativekit/ui';
210+
211+
// window.openai is now fully typed! ✨
212+
const theme = window.openai?.theme; // 'light' | 'dark' | undefined
213+
const toolOutput = window.openai?.toolOutput; // string | undefined
214+
const displayMode = window.openai?.displayMode; // 'inline' | 'pip' | 'fullscreen' | undefined
215+
216+
// Full autocomplete for all methods
217+
window.openai?.sendFollowUpMessage({ prompt: 'Show more' });
218+
const result = await window.openai?.callTool('get_weather', { location: 'SF' });
219+
```
220+
221+
### Available Types
222+
223+
All ChatGPT Apps SDK types are exported:
224+
225+
```tsx
226+
import type {
227+
OpenAiGlobals,
228+
OpenAiApi,
229+
Theme,
230+
DisplayMode,
231+
UserAgent,
232+
SafeArea
233+
} from '@ainativekit/ui';
234+
235+
// Use in your own type definitions
236+
type MyWidgetProps = {
237+
theme: Theme;
238+
displayMode: DisplayMode;
239+
};
240+
```
241+
242+
**Exported Types:**
243+
- `OpenAiGlobals` - Complete `window.openai` globals interface
244+
- `OpenAiApi` - API methods (`callTool`, `sendFollowUpMessage`, etc.)
245+
- `Theme` - `'light' | 'dark'`
246+
- `DisplayMode` - `'inline' | 'pip' | 'fullscreen'`
247+
- `UserAgent` - Device type and capabilities
248+
- `SafeArea` - Safe area insets for mobile layouts
249+
- `CallTool` - Type-safe tool calling signature
250+
- And more... (see [types.ts](packages/ui/src/hooks/openai/types.ts))
251+
201252
## 🤖 AI Tool Integration
202253

203254
AINativeKit UI is optimized for AI coding assistants through Context7 and runtime utilities.

0 commit comments

Comments
 (0)