@creature-ai/sdk 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +299 -72
- package/dist/core/index.js +235 -267
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.d.ts +47 -51
- package/dist/react/index.js +249 -311
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.d.ts +187 -218
- package/dist/server/index.js +567 -521
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/types-JBEuUzEi.d.ts +0 -186
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { T as ToolResult, W as WidgetState, E as Environment, D as DisplayMode, H as HostClient, a as AppSessionState } from '../types-JBEuUzEi.js';
|
|
4
|
-
export { b as AppSessionListener, A as AppSessionOptions, d as HostClientConfig, f as HostClientEvents, e as HostClientState, c as HostContext, L as LogLevel, S as StructuredWidgetState } from '../types-JBEuUzEi.js';
|
|
1
|
+
import { ToolResult, WidgetState, Environment, DisplayMode, WebSocketStatus } from '../core/index.js';
|
|
2
|
+
export { ChatGptAppHostClient, HostClient, HostClientConfig, HostClientEvents, HostClientState, HostContext, LogLevel, McpAppHostClient, StructuredWidgetState, WebSocketClient, WebSocketClientConfig, createHost, createWebSocket, detectEnvironment } from '../core/index.js';
|
|
5
3
|
import * as react from 'react';
|
|
6
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
5
|
export { applyDocumentTheme, applyHostFonts, applyHostStyleVariables, getDocumentTheme } from '@modelcontextprotocol/ext-apps';
|
|
@@ -85,6 +83,45 @@ interface UseHostReturn {
|
|
|
85
83
|
*/
|
|
86
84
|
log: Logger;
|
|
87
85
|
}
|
|
86
|
+
interface UseToolResultReturn<T> {
|
|
87
|
+
/** Structured data from tool result */
|
|
88
|
+
data: T | null;
|
|
89
|
+
/** Instance ID for this widget */
|
|
90
|
+
instanceId: string | null;
|
|
91
|
+
/** Title for PIP tab */
|
|
92
|
+
title: string | null;
|
|
93
|
+
/** Whether this is an error result */
|
|
94
|
+
isError: boolean;
|
|
95
|
+
/** Text content for AI context */
|
|
96
|
+
text: string | null;
|
|
97
|
+
/** Callback to handle tool result */
|
|
98
|
+
onToolResult: (result: ToolResult) => void;
|
|
99
|
+
/** Reset all state */
|
|
100
|
+
reset: () => void;
|
|
101
|
+
}
|
|
102
|
+
interface UseWebSocketConfig<TReceive = unknown> {
|
|
103
|
+
onMessage?: (message: TReceive) => void;
|
|
104
|
+
enabled?: boolean;
|
|
105
|
+
}
|
|
106
|
+
interface UseWebSocketReturn<TSend = unknown> {
|
|
107
|
+
status: WebSocketStatus;
|
|
108
|
+
error: string | undefined;
|
|
109
|
+
send: (message: TSend) => void;
|
|
110
|
+
}
|
|
111
|
+
interface CreatureIconProps {
|
|
112
|
+
/** Whether the app is in dark mode */
|
|
113
|
+
isDarkMode: boolean;
|
|
114
|
+
/** Whether to show the eyes (default: true) */
|
|
115
|
+
showEyes?: boolean;
|
|
116
|
+
/** Whether to enable eye blinking animation (default: false) */
|
|
117
|
+
enableBlink?: boolean;
|
|
118
|
+
/** Width of the icon in pixels */
|
|
119
|
+
width?: number;
|
|
120
|
+
/** Height of the icon in pixels */
|
|
121
|
+
height?: number;
|
|
122
|
+
/** Optional className for additional styling */
|
|
123
|
+
className?: string;
|
|
124
|
+
}
|
|
88
125
|
|
|
89
126
|
/**
|
|
90
127
|
* React hook for connecting to an MCP Apps host.
|
|
@@ -112,14 +149,10 @@ interface UseHostReturn {
|
|
|
112
149
|
*/
|
|
113
150
|
declare function useHost(config: UseHostConfig): UseHostReturn;
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
text: string | null;
|
|
120
|
-
onToolResult: (result: ToolResult) => void;
|
|
121
|
-
reset: () => void;
|
|
122
|
-
}
|
|
152
|
+
/**
|
|
153
|
+
* Hook to access tool result data.
|
|
154
|
+
* Extracts data, instanceId, title, and error state from tool results.
|
|
155
|
+
*/
|
|
123
156
|
declare function useToolResult<T = Record<string, unknown>>(): UseToolResultReturn<T>;
|
|
124
157
|
|
|
125
158
|
type SetStateAction<T> = T | ((prev: T) => T);
|
|
@@ -130,30 +163,7 @@ interface WidgetStateContextValue {
|
|
|
130
163
|
declare const WidgetStateContext: react.Context<WidgetStateContextValue | null>;
|
|
131
164
|
declare function useWidgetState<T extends WidgetState>(initialState?: T | (() => T | null) | null): readonly [T | null, (state: SetStateAction<T | null>) => void];
|
|
132
165
|
|
|
133
|
-
|
|
134
|
-
onMessage?: (message: TReceive) => void;
|
|
135
|
-
enabled?: boolean;
|
|
136
|
-
}
|
|
137
|
-
interface UseChannelReturn<TSend = unknown> {
|
|
138
|
-
status: ChannelStatus;
|
|
139
|
-
error: string | undefined;
|
|
140
|
-
send: (message: TSend) => void;
|
|
141
|
-
}
|
|
142
|
-
declare function useChannel<TSend = unknown, TReceive = unknown>(url: string | undefined, config?: UseChannelConfig<TReceive>): UseChannelReturn<TSend>;
|
|
143
|
-
|
|
144
|
-
interface UseAppSessionConfig<TInternal extends Record<string, unknown> = Record<string, unknown>, TBackend extends Record<string, unknown> = Record<string, unknown>, TUi extends WidgetState | null = WidgetState | null> {
|
|
145
|
-
hostClient?: HostClient;
|
|
146
|
-
initialState?: Partial<AppSessionState<TInternal, TBackend, TUi>>;
|
|
147
|
-
id?: string;
|
|
148
|
-
}
|
|
149
|
-
interface UseAppSessionReturn<TInternal extends Record<string, unknown> = Record<string, unknown>, TBackend extends Record<string, unknown> = Record<string, unknown>, TUi extends WidgetState | null = WidgetState | null> {
|
|
150
|
-
session: AppSession<TInternal, TBackend, TUi>;
|
|
151
|
-
state: AppSessionState<TInternal, TBackend, TUi>;
|
|
152
|
-
ui: TUi;
|
|
153
|
-
setUi: (ui: TUi) => void;
|
|
154
|
-
updateUi: (partial: TUi extends null ? never : Partial<NonNullable<TUi>>) => void;
|
|
155
|
-
}
|
|
156
|
-
declare function useAppSession<TInternal extends Record<string, unknown> = Record<string, unknown>, TBackend extends Record<string, unknown> = Record<string, unknown>, TUi extends WidgetState | null = WidgetState | null>(config?: UseAppSessionConfig<TInternal, TBackend, TUi>): UseAppSessionReturn<TInternal, TBackend, TUi>;
|
|
166
|
+
declare function useWebSocket<TSend = unknown, TReceive = unknown>(url: string | undefined, config?: UseWebSocketConfig<TReceive>): UseWebSocketReturn<TSend>;
|
|
157
167
|
|
|
158
168
|
/**
|
|
159
169
|
* CreatureIcon Component
|
|
@@ -162,20 +172,6 @@ declare function useAppSession<TInternal extends Record<string, unknown> = Recor
|
|
|
162
172
|
* Uses the main creature shape with optional eyes, adapting colors for dark/light mode.
|
|
163
173
|
* Supports optional eye blinking animation at random intervals.
|
|
164
174
|
*/
|
|
165
|
-
interface CreatureIconProps {
|
|
166
|
-
/** Whether the app is in dark mode */
|
|
167
|
-
isDarkMode: boolean;
|
|
168
|
-
/** Whether to show the eyes (default: true) */
|
|
169
|
-
showEyes?: boolean;
|
|
170
|
-
/** Whether to enable eye blinking animation (default: false) */
|
|
171
|
-
enableBlink?: boolean;
|
|
172
|
-
/** Width of the icon in pixels */
|
|
173
|
-
width?: number;
|
|
174
|
-
/** Height of the icon in pixels */
|
|
175
|
-
height?: number;
|
|
176
|
-
/** Optional className for additional styling */
|
|
177
|
-
className?: string;
|
|
178
|
-
}
|
|
179
175
|
declare function CreatureIcon({ isDarkMode, showEyes, enableBlink, width, height, className, }: CreatureIconProps): react_jsx_runtime.JSX.Element;
|
|
180
176
|
|
|
181
|
-
export {
|
|
177
|
+
export { CreatureIcon, type CreatureIconProps, DisplayMode, Environment, type Logger, ToolResult, type UseHostConfig, type UseHostReturn, type UseToolResultReturn, type UseWebSocketConfig, type UseWebSocketReturn, WebSocketStatus, WidgetState, WidgetStateContext, useHost, useToolResult, useWebSocket, useWidgetState };
|