@creature-ai/sdk 0.1.1 → 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 +314 -72
- package/dist/core/index.js +250 -267
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.d.ts +61 -36
- package/dist/react/index.js +356 -305
- 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-DcoqlK46.d.ts +0 -163
package/dist/react/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { T as ToolResult, W as WidgetState, E as Environment, H as HostClient, a as AppSessionState } from '../types-DcoqlK46.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-DcoqlK46.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';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
5
|
export { applyDocumentTheme, applyHostFonts, applyHostStyleVariables, getDocumentTheme } from '@modelcontextprotocol/ext-apps';
|
|
7
6
|
|
|
8
7
|
interface UseHostConfig {
|
|
@@ -56,6 +55,11 @@ interface UseHostReturn {
|
|
|
56
55
|
environment: Environment;
|
|
57
56
|
widgetState: WidgetState | null;
|
|
58
57
|
setWidgetState: (state: WidgetState | null) => void;
|
|
58
|
+
requestDisplayMode: (params: {
|
|
59
|
+
mode: DisplayMode;
|
|
60
|
+
}) => Promise<{
|
|
61
|
+
mode: DisplayMode;
|
|
62
|
+
}>;
|
|
59
63
|
/**
|
|
60
64
|
* Logger for sending messages to the host's DevConsole.
|
|
61
65
|
*
|
|
@@ -79,6 +83,45 @@ interface UseHostReturn {
|
|
|
79
83
|
*/
|
|
80
84
|
log: Logger;
|
|
81
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
|
+
}
|
|
82
125
|
|
|
83
126
|
/**
|
|
84
127
|
* React hook for connecting to an MCP Apps host.
|
|
@@ -106,14 +149,10 @@ interface UseHostReturn {
|
|
|
106
149
|
*/
|
|
107
150
|
declare function useHost(config: UseHostConfig): UseHostReturn;
|
|
108
151
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
text: string | null;
|
|
114
|
-
onToolResult: (result: ToolResult) => void;
|
|
115
|
-
reset: () => void;
|
|
116
|
-
}
|
|
152
|
+
/**
|
|
153
|
+
* Hook to access tool result data.
|
|
154
|
+
* Extracts data, instanceId, title, and error state from tool results.
|
|
155
|
+
*/
|
|
117
156
|
declare function useToolResult<T = Record<string, unknown>>(): UseToolResultReturn<T>;
|
|
118
157
|
|
|
119
158
|
type SetStateAction<T> = T | ((prev: T) => T);
|
|
@@ -124,29 +163,15 @@ interface WidgetStateContextValue {
|
|
|
124
163
|
declare const WidgetStateContext: react.Context<WidgetStateContextValue | null>;
|
|
125
164
|
declare function useWidgetState<T extends WidgetState>(initialState?: T | (() => T | null) | null): readonly [T | null, (state: SetStateAction<T | null>) => void];
|
|
126
165
|
|
|
127
|
-
|
|
128
|
-
onMessage?: (message: TReceive) => void;
|
|
129
|
-
enabled?: boolean;
|
|
130
|
-
}
|
|
131
|
-
interface UseChannelReturn<TSend = unknown> {
|
|
132
|
-
status: ChannelStatus;
|
|
133
|
-
error: string | undefined;
|
|
134
|
-
send: (message: TSend) => void;
|
|
135
|
-
}
|
|
136
|
-
declare function useChannel<TSend = unknown, TReceive = unknown>(url: string | undefined, config?: UseChannelConfig<TReceive>): UseChannelReturn<TSend>;
|
|
166
|
+
declare function useWebSocket<TSend = unknown, TReceive = unknown>(url: string | undefined, config?: UseWebSocketConfig<TReceive>): UseWebSocketReturn<TSend>;
|
|
137
167
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
ui: TUi;
|
|
147
|
-
setUi: (ui: TUi) => void;
|
|
148
|
-
updateUi: (partial: TUi extends null ? never : Partial<NonNullable<TUi>>) => void;
|
|
149
|
-
}
|
|
150
|
-
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>;
|
|
168
|
+
/**
|
|
169
|
+
* CreatureIcon Component
|
|
170
|
+
*
|
|
171
|
+
* The Creature mascot icon with theme-aware colors.
|
|
172
|
+
* Uses the main creature shape with optional eyes, adapting colors for dark/light mode.
|
|
173
|
+
* Supports optional eye blinking animation at random intervals.
|
|
174
|
+
*/
|
|
175
|
+
declare function CreatureIcon({ isDarkMode, showEyes, enableBlink, width, height, className, }: CreatureIconProps): react_jsx_runtime.JSX.Element;
|
|
151
176
|
|
|
152
|
-
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 };
|