@mcpjam/widget-react 0.1.14 → 0.1.15
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/index.d.ts +188 -14
- package/dist/index.js +779 -307
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { ComponentType, ReactNode, ContextType } from 'react';
|
|
3
|
+
import * as _mcpjam_sdk_widget_runtime from '@mcpjam/sdk/widget-runtime';
|
|
3
4
|
import { ToolResultPolicy, BrowserStoragePolicy, AppToolInvocationUpdate } from '@mcpjam/sdk/widget-runtime';
|
|
4
5
|
export { getToolVisibility, isVisibleToAppOnly, isVisibleToModelOnly } from '@mcpjam/sdk/widget-runtime';
|
|
5
6
|
import { McpUiResourceCsp, McpUiResourcePermissions, McpUiHostCapabilities, McpUiStyles, McpUiHostContext, AppBridge } from '@modelcontextprotocol/ext-apps/app-bridge';
|
|
6
7
|
import { SandboxCspPolicy, SandboxPermissionsPolicy, MCPPrompt, MCPResourceTemplate } from '@mcpjam/sdk/browser';
|
|
7
8
|
import * as zustand from 'zustand';
|
|
9
|
+
import { StoreApi } from 'zustand';
|
|
8
10
|
import { CallToolResult, ContentBlock } from '@modelcontextprotocol/client';
|
|
9
11
|
|
|
10
12
|
/** Sandbox CSP-mode selection. Mirrors the inspector ui-playground-store. */
|
|
@@ -166,6 +168,14 @@ interface WidgetSurfaceInfo {
|
|
|
166
168
|
* input because `minimalMode` is per-instance).
|
|
167
169
|
*/
|
|
168
170
|
playgroundCspMode: CspMode;
|
|
171
|
+
/**
|
|
172
|
+
* The one display mode the host presents this App in, chosen by the host
|
|
173
|
+
* rather than negotiated: a plugin extension entrypoint opens `fullscreen`,
|
|
174
|
+
* the way ChatGPT presents every entrypoint. A resource's or App's
|
|
175
|
+
* display-mode declaration cannot select another mode here, so it never
|
|
176
|
+
* refuses the App either. Absent: modes are negotiated as usual.
|
|
177
|
+
*/
|
|
178
|
+
fixedDisplayMode?: DisplayMode;
|
|
169
179
|
}
|
|
170
180
|
interface WidgetMount {
|
|
171
181
|
index: number;
|
|
@@ -206,7 +216,7 @@ interface CspViolation {
|
|
|
206
216
|
subtype?: CspSubtype;
|
|
207
217
|
}
|
|
208
218
|
interface WidgetLifecycleEvent {
|
|
209
|
-
kind: "sandbox-proxy-ready" | "widget-content-requested" | "widget-content-ready" | "widget-content-error" | "widget-content-invalid-mimetype" | "bridge-connect-start" | "bridge-connect-ready" | "bridge-connect-error" | "bridge-connect-skipped" | "app-initialized" | "view-mounted";
|
|
219
|
+
kind: "sandbox-proxy-ready" | "widget-content-requested" | "widget-content-ready" | "widget-content-error" | "widget-content-invalid-mimetype" | "bridge-connect-start" | "bridge-connect-ready" | "bridge-connect-error" | "bridge-connect-skipped" | "app-initialized" | "view-mounted" | "view-channel-closed";
|
|
210
220
|
status: "ok" | "error" | "pending";
|
|
211
221
|
message?: string;
|
|
212
222
|
timestamp: number;
|
|
@@ -235,9 +245,11 @@ interface WidgetSandboxApplied {
|
|
|
235
245
|
* How the proxy mounted the view. `"url"` means it was written into a blank
|
|
236
246
|
* same-origin frame and runs at the proxy's URL; the srcdoc values mean it
|
|
237
247
|
* has no URL of its own (`"srcdoc"` was asked for, `"srcdoc-fallback"` was
|
|
238
|
-
* forced because the frame's document was unreachable).
|
|
248
|
+
* forced because the frame's document was unreachable). `"opaque"` is the
|
|
249
|
+
* intended srcdoc mount of a client whose app iframe is not same-origin
|
|
250
|
+
* (e.g. Claude's no-`stable-origin` mode): no URL and an opaque origin, by design.
|
|
239
251
|
*/
|
|
240
|
-
viewMode?: "url" | "srcdoc" | "srcdoc-fallback";
|
|
252
|
+
viewMode?: "url" | "srcdoc" | "srcdoc-fallback" | "opaque";
|
|
241
253
|
/** Id of the currently displayed inner iframe mount. */
|
|
242
254
|
mountId?: CspMountId;
|
|
243
255
|
/** The view's document URL as reported by the proxy. */
|
|
@@ -460,6 +472,12 @@ interface WidgetHostProfileSandbox {
|
|
|
460
472
|
* field missing here silently disappears before reaching the renderer.
|
|
461
473
|
*/
|
|
462
474
|
browserStorage?: BrowserStoragePolicy;
|
|
475
|
+
/**
|
|
476
|
+
* Probe-measured: whether the app iframe shares the sandbox page's origin.
|
|
477
|
+
* `false` makes the proxy mount the view in an opaque origin (srcdoc, no
|
|
478
|
+
* `allow-same-origin`), `ui.domain` or not. Absent or `true` = same-origin.
|
|
479
|
+
*/
|
|
480
|
+
sameOriginAppIframe?: boolean;
|
|
463
481
|
}
|
|
464
482
|
/**
|
|
465
483
|
* Raw ambient ENV inputs the renderer reads (Phase 1b). The inspector's
|
|
@@ -544,6 +562,7 @@ interface FetchWidgetContentRequest {
|
|
|
544
562
|
forceWebEndpoint?: boolean;
|
|
545
563
|
}
|
|
546
564
|
interface FetchWidgetContentResponse {
|
|
565
|
+
resourceDisplayHints?: _mcpjam_sdk_widget_runtime.ResourceDisplayHints;
|
|
547
566
|
html: string;
|
|
548
567
|
csp?: McpUiResourceCsp;
|
|
549
568
|
permissions?: McpUiResourcePermissions;
|
|
@@ -583,10 +602,20 @@ type ListResourcesResult = {
|
|
|
583
602
|
* HOSTED_MODE / web-managed guard before calling the raw api.
|
|
584
603
|
*/
|
|
585
604
|
interface WidgetHostServices {
|
|
605
|
+
/** Host-admitted plugin navigation, never arbitrary external navigation. */
|
|
606
|
+
openAppLink?: (url: string) => Promise<void>;
|
|
607
|
+
sendMessage?: (params: unknown) => Promise<Record<string, unknown>>;
|
|
608
|
+
updateModelContext?: (params: unknown) => Promise<{
|
|
609
|
+
_meta?: Record<string, unknown>;
|
|
610
|
+
}>;
|
|
586
611
|
fetchWidgetContent: (req: FetchWidgetContentRequest) => Promise<FetchWidgetContentResponse>;
|
|
587
612
|
readResource: (serverId: string, uri: string, opts?: {
|
|
588
613
|
forceHosted?: boolean;
|
|
589
614
|
}) => Promise<any>;
|
|
615
|
+
/** Complete instance-bound resource callback; legacy services remain compatible. */
|
|
616
|
+
readResourceV2?: _mcpjam_sdk_widget_runtime.HostBridgeCallbacks["onReadResourceV2"];
|
|
617
|
+
/** Trusted fixed-lifetime extensions, installed before connect and released on close. */
|
|
618
|
+
configureAppBridge?: (bridge: AppBridge, capabilities: ConstructorParameters<typeof AppBridge>[2]) => void | (() => void);
|
|
590
619
|
listResources: (serverId: string, cursor?: string, opts?: {
|
|
591
620
|
forceHosted?: boolean;
|
|
592
621
|
}) => Promise<ListResourcesResult>;
|
|
@@ -741,6 +770,8 @@ interface AppToolsRegistryState {
|
|
|
741
770
|
*/
|
|
742
771
|
pendingControllers: Map<BridgeId, Set<AbortController>>;
|
|
743
772
|
registerInstance: (inst: AppInstance) => Promise<void>;
|
|
773
|
+
dispose: () => void;
|
|
774
|
+
setEnabled: (enabled: boolean) => void;
|
|
744
775
|
unregisterInstance: (bridgeId: BridgeId) => void;
|
|
745
776
|
pushActive: (parentToolCallId: string, bridgeId: BridgeId, chatSessionId?: string) => void;
|
|
746
777
|
popActive: (parentToolCallId: string, bridgeId: BridgeId, chatSessionId?: string) => void;
|
|
@@ -774,7 +805,19 @@ interface AppToolsRegistryState {
|
|
|
774
805
|
*/
|
|
775
806
|
declare function generateAlias(chatSessionId: string | undefined, serverId: string, parentToolCallId: string, surface: AppInstance["surface"], rawName: string, salt?: number): Promise<string>;
|
|
776
807
|
declare function isReadOnly(tool: AppToolDescriptor): boolean;
|
|
777
|
-
declare
|
|
808
|
+
declare function createAppToolsRegistry(options?: {
|
|
809
|
+
/** Most LIVE app instances at once (closed ones free their slot). */
|
|
810
|
+
maxInstances?: number;
|
|
811
|
+
/** Most registrations hashing at once. */
|
|
812
|
+
maxIdentities?: number;
|
|
813
|
+
}): zustand.UseBoundStore<StoreApi<AppToolsRegistryState>>;
|
|
814
|
+
type AppToolsRegistry = ReturnType<typeof createAppToolsRegistry>;
|
|
815
|
+
declare function useAppToolsRegistryApi(): AppToolsRegistry;
|
|
816
|
+
/** Static methods address the legacy registry; scoped callbacks use the API hook. */
|
|
817
|
+
declare const useAppToolsRegistry: (<T = AppToolsRegistryState>(selector?: (state: AppToolsRegistryState) => T) => T) & {
|
|
818
|
+
(): AppToolsRegistryState;
|
|
819
|
+
<U>(selector: (state: AppToolsRegistryState) => U): U;
|
|
820
|
+
} & StoreApi<AppToolsRegistryState>;
|
|
778
821
|
/**
|
|
779
822
|
* Side-channel log of every app-tool invocation for debugging and future UI.
|
|
780
823
|
* Mirrors the widget-html debug store pattern. The full untouched
|
|
@@ -797,9 +840,17 @@ interface AppToolInvocationLogState {
|
|
|
797
840
|
records: AppToolInvocationRecord[];
|
|
798
841
|
append: (r: AppToolInvocationRecord) => void;
|
|
799
842
|
clear: () => void;
|
|
843
|
+
setEnabled: (enabled: boolean) => void;
|
|
844
|
+
dispose: () => void;
|
|
800
845
|
}
|
|
801
|
-
declare
|
|
802
|
-
|
|
846
|
+
declare function createAppToolInvocationLog(): zustand.UseBoundStore<StoreApi<AppToolInvocationLogState>>;
|
|
847
|
+
type AppToolInvocationLog = ReturnType<typeof createAppToolInvocationLog>;
|
|
848
|
+
declare function useAppToolInvocationLogApi(): AppToolInvocationLog;
|
|
849
|
+
declare const useAppToolInvocationLog: (<T = AppToolInvocationLogState>(selector?: (state: AppToolInvocationLogState) => T) => T) & {
|
|
850
|
+
(): AppToolInvocationLogState;
|
|
851
|
+
<U>(selector: (state: AppToolInvocationLogState) => U): U;
|
|
852
|
+
} & StoreApi<AppToolInvocationLogState>;
|
|
853
|
+
declare function recordAppToolInvocation(args: Omit<AppToolInvocationRecord, "invokedAtMs">, addTrafficLog?: AddTrafficLog, invocationLog?: AppToolInvocationLog): void;
|
|
803
854
|
declare function useAppToolAttributionResolver(chatSessionId?: string): (label: string) => AppToolAttribution | null;
|
|
804
855
|
declare function useAppToolAttribution(label: string, chatSessionId?: string): AppToolAttribution | null;
|
|
805
856
|
declare const __internal: {
|
|
@@ -975,9 +1026,11 @@ interface SandboxedIframeProps {
|
|
|
975
1026
|
* restores the legacy `iframe.srcdoc` mount, where the view has no URL of
|
|
976
1027
|
* its own. Supplied by the host (`host.surface.viewMountMode`); build-time
|
|
977
1028
|
* only, so it exists to exercise the srcdoc branch rather than to switch
|
|
978
|
-
* behaviour at runtime.
|
|
1029
|
+
* behaviour at runtime. `"opaque"` is per client: a srcdoc mount without
|
|
1030
|
+
* `allow-same-origin`, so the view runs in an opaque origin
|
|
1031
|
+
* (the renderer picks it from the client's `sameOriginAppIframe: false`).
|
|
979
1032
|
*/
|
|
980
|
-
mountMode?: "write" | "srcdoc";
|
|
1033
|
+
mountMode?: "write" | "srcdoc" | "opaque";
|
|
981
1034
|
/**
|
|
982
1035
|
* Per-server label for a dedicated view origin, and whether this deploy
|
|
983
1036
|
* serves one. Supplied by the host; without both the view renders on the
|
|
@@ -985,6 +1038,13 @@ interface SandboxedIframeProps {
|
|
|
985
1038
|
*/
|
|
986
1039
|
viewOriginLabel?: string;
|
|
987
1040
|
viewSubdomainsEnabled?: boolean;
|
|
1041
|
+
/**
|
|
1042
|
+
* Changing this reloads the guest document (the resource is sent to the
|
|
1043
|
+
* proxy again) even when the payload is unchanged. The renderer bumps it
|
|
1044
|
+
* for every new AppBridge: a guest initializes once per document, so a
|
|
1045
|
+
* bridge that replaced another one never hears `ui/initialize` otherwise.
|
|
1046
|
+
*/
|
|
1047
|
+
reloadKey?: number | string;
|
|
988
1048
|
}
|
|
989
1049
|
/**
|
|
990
1050
|
* SandboxedIframe provides a secure double-iframe architecture per SEP-1865.
|
|
@@ -1024,6 +1084,8 @@ interface MCPAppsRendererProps {
|
|
|
1024
1084
|
onCallTool?: (toolName: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
1025
1085
|
onAppToolInvocationChange?: (invocation: AppToolInvocationUpdate) => void;
|
|
1026
1086
|
onWidgetStateChange?: (toolCallId: string, state: unknown) => void;
|
|
1087
|
+
/** Fixed initial-render outcome, without guest content or error text. */
|
|
1088
|
+
onInitialRenderOutcome?: (outcome: "ready" | "error") => void;
|
|
1027
1089
|
/**
|
|
1028
1090
|
* Tier 2 recorder. When `recordMode` is on, the sandbox proxy injects a
|
|
1029
1091
|
* recorder shim into the guest; `onRecorderStep` fires for each captured
|
|
@@ -1132,6 +1194,8 @@ interface MCPAppsRendererProps {
|
|
|
1132
1194
|
* way).
|
|
1133
1195
|
*/
|
|
1134
1196
|
initialWidgetState?: unknown;
|
|
1197
|
+
/** The workspace owns the rectangle and toolbar, independent of protocol display mode. */
|
|
1198
|
+
hostManagedPresentation?: boolean;
|
|
1135
1199
|
/** Minimal mode hides diagnostics and metadata surfaces */
|
|
1136
1200
|
minimalMode?: boolean;
|
|
1137
1201
|
/**
|
|
@@ -1148,7 +1212,7 @@ interface MCPAppsRendererProps {
|
|
|
1148
1212
|
persistentSurfaceInitialToolCallId?: string;
|
|
1149
1213
|
}
|
|
1150
1214
|
declare function MCPAppsRenderer(props: MCPAppsRendererProps): react.JSX.Element;
|
|
1151
|
-
declare function MCPAppsRendererSurface({ chatSessionId, serverId, serverName, toolCallId, toolName, toolState, toolInput, toolOutput, toolResponseMetadata, toolErrorText, resourceUri, toolMetadata, toolsMetadata, onSendFollowUp, onCallTool, onAppToolInvocationChange, onWidgetStateChange, recordMode, onRecorderStep, onRecorderReady, onReplayControllerReady, pipWidgetId, fullscreenWidgetId, onRequestPip, onExitPip, displayMode: displayModeProp, onDisplayModeChange, onRequestFullscreen, onExitFullscreen, onModelContextUpdate, onAppSupportedDisplayModesChange, onRequestTeardown, onConfirmDownload, isOffline, cachedWidgetHtmlUrl, liveFetchPreferred, widgetCsp: initialWidgetCsp, widgetPermissions: initialWidgetPermissions, widgetPermissive: initialWidgetPermissive, prefersBorder: initialPrefersBorder, injectedOpenAiCompat: initialInjectedOpenAiCompat, injectedOpenAiCompatCapabilities: initialInjectedOpenAiCompatCapabilities, initialWidgetState, minimalMode, persistentSurfaceId, persistentSurfaceInitialToolCallId, }: MCPAppsRendererProps): react.JSX.Element | null;
|
|
1215
|
+
declare function MCPAppsRendererSurface({ chatSessionId, serverId, serverName, toolCallId, toolName, toolState, toolInput, toolOutput, toolResponseMetadata, toolErrorText, resourceUri, toolMetadata, toolsMetadata, onSendFollowUp, onCallTool, onAppToolInvocationChange, onWidgetStateChange, onInitialRenderOutcome, recordMode, onRecorderStep, onRecorderReady, onReplayControllerReady, pipWidgetId, fullscreenWidgetId, onRequestPip, onExitPip, displayMode: displayModeProp, onDisplayModeChange, onRequestFullscreen, onExitFullscreen, onModelContextUpdate, onAppSupportedDisplayModesChange, onRequestTeardown, onConfirmDownload, isOffline, cachedWidgetHtmlUrl, liveFetchPreferred, widgetCsp: initialWidgetCsp, widgetPermissions: initialWidgetPermissions, widgetPermissive: initialWidgetPermissive, prefersBorder: initialPrefersBorder, injectedOpenAiCompat: initialInjectedOpenAiCompat, injectedOpenAiCompatCapabilities: initialInjectedOpenAiCompatCapabilities, initialWidgetState, minimalMode, hostManagedPresentation, persistentSurfaceId, persistentSurfaceInitialToolCallId, }: MCPAppsRendererProps): react.JSX.Element | null;
|
|
1152
1216
|
|
|
1153
1217
|
declare function WidgetSurfaceHostProvider({ children, }: {
|
|
1154
1218
|
children: ReactNode;
|
|
@@ -1157,7 +1221,7 @@ declare function usePersistentWidgetSurfaceHost(): boolean;
|
|
|
1157
1221
|
|
|
1158
1222
|
declare function WidgetSurfaceHost({ chatSessionId, }: {
|
|
1159
1223
|
chatSessionId?: string;
|
|
1160
|
-
}): react.JSX.Element;
|
|
1224
|
+
}): react.JSX.Element | null;
|
|
1161
1225
|
|
|
1162
1226
|
type WidgetSurfaceId = string;
|
|
1163
1227
|
interface WidgetSurfaceRegistration {
|
|
@@ -1168,25 +1232,135 @@ interface WidgetSurfaceRegistration {
|
|
|
1168
1232
|
}
|
|
1169
1233
|
interface WidgetSurfaceRecord {
|
|
1170
1234
|
surfaceId: WidgetSurfaceId;
|
|
1235
|
+
/** Chosen before the first render; moving a live iframe resets its context. */
|
|
1236
|
+
presentation?: "panel" | "modal";
|
|
1171
1237
|
chatSessionId?: string;
|
|
1172
1238
|
initialToolCallId: string;
|
|
1173
1239
|
latestToolCallId: string;
|
|
1174
1240
|
registrations: Map<string, WidgetSurfaceRegistration>;
|
|
1241
|
+
/** Instance-owned render input survives removal of presentation rows. */
|
|
1242
|
+
retainedProps: MCPAppsRendererProps;
|
|
1243
|
+
/** Live adapter only; never include services in a recording projection. */
|
|
1244
|
+
host?: WidgetHost;
|
|
1245
|
+
}
|
|
1246
|
+
/** Why a workspace refused to open an App surface. */
|
|
1247
|
+
interface WidgetSurfaceAdmissionError {
|
|
1248
|
+
code: "WIDGET_INSTANCE_LIMIT";
|
|
1249
|
+
/** Plain-English description, safe to show as-is. */
|
|
1250
|
+
message: string;
|
|
1251
|
+
limit: number;
|
|
1175
1252
|
}
|
|
1176
1253
|
interface WidgetSurfaceStoreState {
|
|
1177
1254
|
surfaces: Map<WidgetSurfaceId, WidgetSurfaceRecord>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Surfaces a retaining workspace refused because it already holds its
|
|
1257
|
+
* maximum number of live Apps. Cleared when the surface is admitted later
|
|
1258
|
+
* or destroyed. Refusing (instead of throwing from a layout effect) keeps
|
|
1259
|
+
* the rest of the workspace rendering.
|
|
1260
|
+
*/
|
|
1261
|
+
refused: Map<WidgetSurfaceId, WidgetSurfaceAdmissionError>;
|
|
1178
1262
|
nextOrder: number;
|
|
1179
|
-
upsertRegistration: (surfaceId: WidgetSurfaceId, toolCallId: string, props: MCPAppsRendererProps) => void;
|
|
1263
|
+
upsertRegistration: (surfaceId: WidgetSurfaceId, toolCallId: string, props: MCPAppsRendererProps, host?: WidgetHost, presentation?: WidgetSurfaceRecord["presentation"]) => void;
|
|
1180
1264
|
setAnchor: (surfaceId: WidgetSurfaceId, toolCallId: string, anchorElement: HTMLDivElement | null) => void;
|
|
1181
1265
|
releaseRegistration: (surfaceId: WidgetSurfaceId, toolCallId: string) => void;
|
|
1182
1266
|
clearChatSession: (chatSessionId?: string) => void;
|
|
1267
|
+
destroySurface: (surfaceId: WidgetSurfaceId) => void;
|
|
1268
|
+
dispose: () => void;
|
|
1269
|
+
setEnabled: (enabled: boolean) => void;
|
|
1183
1270
|
}
|
|
1184
|
-
declare
|
|
1271
|
+
declare function createWidgetSurfaceStore(options?: {
|
|
1272
|
+
retainInstances?: boolean;
|
|
1273
|
+
maxInstances?: number;
|
|
1274
|
+
}): zustand.UseBoundStore<zustand.StoreApi<WidgetSurfaceStoreState>>;
|
|
1275
|
+
type WidgetSurfaceStore = ReturnType<typeof createWidgetSurfaceStore>;
|
|
1276
|
+
/** Why the current workspace refused `surfaceId`, or null. */
|
|
1277
|
+
declare function useWidgetSurfaceAdmissionError(surfaceId: WidgetSurfaceId | null | undefined): WidgetSurfaceAdmissionError | null;
|
|
1278
|
+
declare function useWidgetSurfaceStoreApi(): WidgetSurfaceStore;
|
|
1279
|
+
/** Static methods retain legacy compatibility; workspace callbacks use the API hook. */
|
|
1280
|
+
declare const useWidgetSurfaceStore: (<T = WidgetSurfaceStoreState>(selector?: (state: WidgetSurfaceStoreState) => T) => T) & {
|
|
1281
|
+
(): WidgetSurfaceStoreState;
|
|
1282
|
+
<U>(selector: (state: WidgetSurfaceStoreState) => U): U;
|
|
1283
|
+
} & zustand.StoreApi<WidgetSurfaceStoreState>;
|
|
1185
1284
|
declare function getRenderableSurfaceEntries(surfaces: Map<WidgetSurfaceId, WidgetSurfaceRecord>, chatSessionId?: string): {
|
|
1186
1285
|
surfaceId: WidgetSurfaceId;
|
|
1187
1286
|
anchorElement: HTMLDivElement | null;
|
|
1188
1287
|
initialToolCallId: string;
|
|
1189
1288
|
props: MCPAppsRendererProps;
|
|
1289
|
+
host?: WidgetHost;
|
|
1190
1290
|
}[];
|
|
1191
1291
|
|
|
1192
|
-
|
|
1292
|
+
/** Per-workspace stores; Host Compare mounts one provider per lane. */
|
|
1293
|
+
declare const WidgetWorkspaceContext: react.Context<{
|
|
1294
|
+
workspaceId: string;
|
|
1295
|
+
surfaces: WidgetSurfaceStore;
|
|
1296
|
+
registry: AppToolsRegistry;
|
|
1297
|
+
invocations: AppToolInvocationLog;
|
|
1298
|
+
} | null>;
|
|
1299
|
+
|
|
1300
|
+
/** One owner per workspace/lane. Key this provider when its binding changes. */
|
|
1301
|
+
declare function WidgetWorkspaceProvider({ workspaceId, children, }: {
|
|
1302
|
+
workspaceId: string;
|
|
1303
|
+
children: ReactNode;
|
|
1304
|
+
}): react.JSX.Element;
|
|
1305
|
+
declare function useOptionalWidgetWorkspace(): {
|
|
1306
|
+
workspaceId: string;
|
|
1307
|
+
surfaces: WidgetSurfaceStore;
|
|
1308
|
+
registry: AppToolsRegistry;
|
|
1309
|
+
invocations: AppToolInvocationLog;
|
|
1310
|
+
} | null;
|
|
1311
|
+
declare function useWidgetWorkspace(): {
|
|
1312
|
+
workspaceId: string;
|
|
1313
|
+
surfaces: WidgetSurfaceStore;
|
|
1314
|
+
registry: AppToolsRegistry;
|
|
1315
|
+
invocations: AppToolInvocationLog;
|
|
1316
|
+
};
|
|
1317
|
+
/** Explicit destruction owns registry cancellation; row cleanup never calls it. */
|
|
1318
|
+
declare function closeWorkspaceSurface(workspace: NonNullable<ContextType<typeof WidgetWorkspaceContext>>, surfaceId: string): void;
|
|
1319
|
+
/**
|
|
1320
|
+
* Every app's DOM parent is permanent. Selection only toggles presentation;
|
|
1321
|
+
* nothing is portaled/reparented into a transcript row or a different panel.
|
|
1322
|
+
*/
|
|
1323
|
+
declare function WidgetWorkspaceSurfaceHost({ activeSurfaceId, renderSurface, renderContainer, }: {
|
|
1324
|
+
activeSurfaceId: string | null;
|
|
1325
|
+
renderSurface?: (props: MCPAppsRendererProps) => ReactNode;
|
|
1326
|
+
/** Chrome is chosen by the immutable presentation slot, never by selection. */
|
|
1327
|
+
renderContainer?: (input: {
|
|
1328
|
+
surface: WidgetSurfaceRecord;
|
|
1329
|
+
active: boolean;
|
|
1330
|
+
children: ReactNode;
|
|
1331
|
+
}) => ReactNode;
|
|
1332
|
+
}): react.JSX.Element;
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* Where a chat App draws itself when it goes fullscreen. Without a placement
|
|
1336
|
+
* it covers the window (today's chat fullscreen). With one, the host gives a
|
|
1337
|
+
* viewport rectangle instead — the Playground's right-rail App area for
|
|
1338
|
+
* clients whose Apps move into a side panel tab — and the App's DOM parent
|
|
1339
|
+
* never changes, so it doesn't reload. A placed App stacks above the panel
|
|
1340
|
+
* that holds its rectangle, even when that panel is itself layered over the
|
|
1341
|
+
* chat (a narrow window's side panel).
|
|
1342
|
+
*/
|
|
1343
|
+
interface WidgetFullscreenPlacement {
|
|
1344
|
+
rect: {
|
|
1345
|
+
top: number;
|
|
1346
|
+
left: number;
|
|
1347
|
+
width: number;
|
|
1348
|
+
height: number;
|
|
1349
|
+
} | null;
|
|
1350
|
+
/** Text for the exit control (e.g. "Exit full screen"); an X when absent. */
|
|
1351
|
+
exitLabel?: string;
|
|
1352
|
+
/** The placed App announces itself: its label and how to leave fullscreen. */
|
|
1353
|
+
onEnter?: (app: {
|
|
1354
|
+
label: string;
|
|
1355
|
+
exit: () => void;
|
|
1356
|
+
}) => void;
|
|
1357
|
+
onLeave?: () => void;
|
|
1358
|
+
/**
|
|
1359
|
+
* The person left fullscreen with the placed App's own exit control, as
|
|
1360
|
+
* opposed to the host ending it (another tab chosen, the panel hidden).
|
|
1361
|
+
*/
|
|
1362
|
+
onExit?: () => void;
|
|
1363
|
+
}
|
|
1364
|
+
declare const WidgetFullscreenPlacementContext: react.Context<WidgetFullscreenPlacement | null>;
|
|
1365
|
+
|
|
1366
|
+
export { type AddTrafficLog, type AppInstance, type AppToolAlias, type AppToolAttribution, type AppToolDescriptor, type AppToolInvocationLog, type AppToolInvocationLogState, type AppToolInvocationRecord, type AppToolSnapshotEntry, type AppToolsRegistry, type AppToolsRegistryState, type BridgeId, type CspApplicationIntent, type CspClientContext, type CspMode, type CspMountId, type CspSubtypePolicy, type CspViolation, type DeviceCapabilities, type DeviceType, type DisplayMode, type EffectiveCompatRuntime, type FetchWidgetContentRequest, type FetchWidgetContentResponse, type ListResourcesResult, MCPAppsRenderer, type MCPAppsRendererProps, MCPAppsRendererSurface, type OpenAiAppsCapabilities, PARTIAL_INPUT_THROTTLE_MS, type ProjectHostContextDraft, type ResolvedHostCapabilities, type ResolvedHostInfo, type ResolvedHostStyle, type ResolvedMcpAppsCapabilities, type ResolvedOpenAiAppsCapabilities, SIGNATURE_MAX_ARRAY_ITEMS, SIGNATURE_MAX_DEPTH, SIGNATURE_MAX_OBJECT_KEYS, SIGNATURE_STRING_EDGE_LENGTH, STREAMING_REVEAL_FALLBACK_MS, type SafeAreaInsets, type SandboxProxyLocation, SandboxedIframe, type SandboxedIframeHandle, type ScenarioHostStyle, type ThemeMode, type ToolLike, type ToolState, UIType, type UiLogEvent, type UiProtocol, type UseToolInputStreamingParams, type UseToolInputStreamingReturn, type WidgetCheckoutProps, type WidgetDebugInfo, type WidgetDebugSink, type WidgetFullscreenPlacement, WidgetFullscreenPlacementContext, type WidgetGlobals, type WidgetHost, type WidgetHostComponents, type WidgetHostEnvironment, type WidgetHostEnvironmentInputs, WidgetHostProvider, type WidgetHostProviderProps, type WidgetHostResolvers, type WidgetHostServices, type WidgetLifecycleEvent, type WidgetModalProps, type WidgetMount, type WidgetSandboxApplied, type WidgetSandboxInfo, type WidgetSurfaceAdmissionError, WidgetSurfaceHost, WidgetSurfaceHostProvider, type WidgetSurfaceId, type WidgetSurfaceInfo, type WidgetSurfaceKind, type WidgetSurfaceRecord, type WidgetSurfaceStore, WidgetWorkspaceProvider, WidgetWorkspaceSurfaceHost, __internal, closeWorkspaceSurface, createAppToolInvocationLog, createAppToolsRegistry, createWidgetSurfaceStore, detectUIType, detectUiTypeFromTool, getRenderableSurfaceEntries, getToolInputSignature, getUIResourceUri, readToolResultMeta, readToolResultObject, readToolResultServerId, recordAppToolInvocation, resolveSandboxProxyUrl, useAppToolAttribution, useAppToolAttributionResolver, useAppToolInvocationLog, useAppToolInvocationLogApi, useAppToolsRegistry, useAppToolsRegistryApi, useOptionalWidgetWorkspace, usePersistentWidgetSurfaceHost, useToolInputStreaming, useWidgetHost, useWidgetSurfaceAdmissionError, useWidgetSurfaceStore, useWidgetSurfaceStoreApi, useWidgetWorkspace };
|