@mcpjam/widget-react 0.1.14 → 0.1.16
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 +197 -14
- package/dist/index.js +796 -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,23 @@ 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;
|
|
179
|
+
/**
|
|
180
|
+
* Apply OpenAI's display-mode rules (ChatGPT and Codex with the Display
|
|
181
|
+
* modes extension on): omitted resource modes mean every host mode, a
|
|
182
|
+
* preference picks the starting mode without narrowing, a resource that
|
|
183
|
+
* declares both inline and fullscreen starts fullscreen, and a fixed mode
|
|
184
|
+
* the initialized App says it cannot show refuses the App. Absent: modes are
|
|
185
|
+
* negotiated as before.
|
|
186
|
+
*/
|
|
187
|
+
openAIDisplayModes?: boolean;
|
|
169
188
|
}
|
|
170
189
|
interface WidgetMount {
|
|
171
190
|
index: number;
|
|
@@ -206,7 +225,7 @@ interface CspViolation {
|
|
|
206
225
|
subtype?: CspSubtype;
|
|
207
226
|
}
|
|
208
227
|
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";
|
|
228
|
+
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
229
|
status: "ok" | "error" | "pending";
|
|
211
230
|
message?: string;
|
|
212
231
|
timestamp: number;
|
|
@@ -235,9 +254,11 @@ interface WidgetSandboxApplied {
|
|
|
235
254
|
* How the proxy mounted the view. `"url"` means it was written into a blank
|
|
236
255
|
* same-origin frame and runs at the proxy's URL; the srcdoc values mean it
|
|
237
256
|
* has no URL of its own (`"srcdoc"` was asked for, `"srcdoc-fallback"` was
|
|
238
|
-
* forced because the frame's document was unreachable).
|
|
257
|
+
* forced because the frame's document was unreachable). `"opaque"` is the
|
|
258
|
+
* intended srcdoc mount of a client whose app iframe is not same-origin
|
|
259
|
+
* (e.g. Claude's no-`stable-origin` mode): no URL and an opaque origin, by design.
|
|
239
260
|
*/
|
|
240
|
-
viewMode?: "url" | "srcdoc" | "srcdoc-fallback";
|
|
261
|
+
viewMode?: "url" | "srcdoc" | "srcdoc-fallback" | "opaque";
|
|
241
262
|
/** Id of the currently displayed inner iframe mount. */
|
|
242
263
|
mountId?: CspMountId;
|
|
243
264
|
/** The view's document URL as reported by the proxy. */
|
|
@@ -460,6 +481,12 @@ interface WidgetHostProfileSandbox {
|
|
|
460
481
|
* field missing here silently disappears before reaching the renderer.
|
|
461
482
|
*/
|
|
462
483
|
browserStorage?: BrowserStoragePolicy;
|
|
484
|
+
/**
|
|
485
|
+
* Probe-measured: whether the app iframe shares the sandbox page's origin.
|
|
486
|
+
* `false` makes the proxy mount the view in an opaque origin (srcdoc, no
|
|
487
|
+
* `allow-same-origin`), `ui.domain` or not. Absent or `true` = same-origin.
|
|
488
|
+
*/
|
|
489
|
+
sameOriginAppIframe?: boolean;
|
|
463
490
|
}
|
|
464
491
|
/**
|
|
465
492
|
* Raw ambient ENV inputs the renderer reads (Phase 1b). The inspector's
|
|
@@ -544,6 +571,7 @@ interface FetchWidgetContentRequest {
|
|
|
544
571
|
forceWebEndpoint?: boolean;
|
|
545
572
|
}
|
|
546
573
|
interface FetchWidgetContentResponse {
|
|
574
|
+
resourceDisplayHints?: _mcpjam_sdk_widget_runtime.ResourceDisplayHints;
|
|
547
575
|
html: string;
|
|
548
576
|
csp?: McpUiResourceCsp;
|
|
549
577
|
permissions?: McpUiResourcePermissions;
|
|
@@ -583,10 +611,20 @@ type ListResourcesResult = {
|
|
|
583
611
|
* HOSTED_MODE / web-managed guard before calling the raw api.
|
|
584
612
|
*/
|
|
585
613
|
interface WidgetHostServices {
|
|
614
|
+
/** Host-admitted plugin navigation, never arbitrary external navigation. */
|
|
615
|
+
openAppLink?: (url: string) => Promise<void>;
|
|
616
|
+
sendMessage?: (params: unknown) => Promise<Record<string, unknown>>;
|
|
617
|
+
updateModelContext?: (params: unknown) => Promise<{
|
|
618
|
+
_meta?: Record<string, unknown>;
|
|
619
|
+
}>;
|
|
586
620
|
fetchWidgetContent: (req: FetchWidgetContentRequest) => Promise<FetchWidgetContentResponse>;
|
|
587
621
|
readResource: (serverId: string, uri: string, opts?: {
|
|
588
622
|
forceHosted?: boolean;
|
|
589
623
|
}) => Promise<any>;
|
|
624
|
+
/** Complete instance-bound resource callback; legacy services remain compatible. */
|
|
625
|
+
readResourceV2?: _mcpjam_sdk_widget_runtime.HostBridgeCallbacks["onReadResourceV2"];
|
|
626
|
+
/** Trusted fixed-lifetime extensions, installed before connect and released on close. */
|
|
627
|
+
configureAppBridge?: (bridge: AppBridge, capabilities: ConstructorParameters<typeof AppBridge>[2]) => void | (() => void);
|
|
590
628
|
listResources: (serverId: string, cursor?: string, opts?: {
|
|
591
629
|
forceHosted?: boolean;
|
|
592
630
|
}) => Promise<ListResourcesResult>;
|
|
@@ -741,6 +779,8 @@ interface AppToolsRegistryState {
|
|
|
741
779
|
*/
|
|
742
780
|
pendingControllers: Map<BridgeId, Set<AbortController>>;
|
|
743
781
|
registerInstance: (inst: AppInstance) => Promise<void>;
|
|
782
|
+
dispose: () => void;
|
|
783
|
+
setEnabled: (enabled: boolean) => void;
|
|
744
784
|
unregisterInstance: (bridgeId: BridgeId) => void;
|
|
745
785
|
pushActive: (parentToolCallId: string, bridgeId: BridgeId, chatSessionId?: string) => void;
|
|
746
786
|
popActive: (parentToolCallId: string, bridgeId: BridgeId, chatSessionId?: string) => void;
|
|
@@ -774,7 +814,19 @@ interface AppToolsRegistryState {
|
|
|
774
814
|
*/
|
|
775
815
|
declare function generateAlias(chatSessionId: string | undefined, serverId: string, parentToolCallId: string, surface: AppInstance["surface"], rawName: string, salt?: number): Promise<string>;
|
|
776
816
|
declare function isReadOnly(tool: AppToolDescriptor): boolean;
|
|
777
|
-
declare
|
|
817
|
+
declare function createAppToolsRegistry(options?: {
|
|
818
|
+
/** Most LIVE app instances at once (closed ones free their slot). */
|
|
819
|
+
maxInstances?: number;
|
|
820
|
+
/** Most registrations hashing at once. */
|
|
821
|
+
maxIdentities?: number;
|
|
822
|
+
}): zustand.UseBoundStore<StoreApi<AppToolsRegistryState>>;
|
|
823
|
+
type AppToolsRegistry = ReturnType<typeof createAppToolsRegistry>;
|
|
824
|
+
declare function useAppToolsRegistryApi(): AppToolsRegistry;
|
|
825
|
+
/** Static methods address the legacy registry; scoped callbacks use the API hook. */
|
|
826
|
+
declare const useAppToolsRegistry: (<T = AppToolsRegistryState>(selector?: (state: AppToolsRegistryState) => T) => T) & {
|
|
827
|
+
(): AppToolsRegistryState;
|
|
828
|
+
<U>(selector: (state: AppToolsRegistryState) => U): U;
|
|
829
|
+
} & StoreApi<AppToolsRegistryState>;
|
|
778
830
|
/**
|
|
779
831
|
* Side-channel log of every app-tool invocation for debugging and future UI.
|
|
780
832
|
* Mirrors the widget-html debug store pattern. The full untouched
|
|
@@ -797,9 +849,17 @@ interface AppToolInvocationLogState {
|
|
|
797
849
|
records: AppToolInvocationRecord[];
|
|
798
850
|
append: (r: AppToolInvocationRecord) => void;
|
|
799
851
|
clear: () => void;
|
|
852
|
+
setEnabled: (enabled: boolean) => void;
|
|
853
|
+
dispose: () => void;
|
|
800
854
|
}
|
|
801
|
-
declare
|
|
802
|
-
|
|
855
|
+
declare function createAppToolInvocationLog(): zustand.UseBoundStore<StoreApi<AppToolInvocationLogState>>;
|
|
856
|
+
type AppToolInvocationLog = ReturnType<typeof createAppToolInvocationLog>;
|
|
857
|
+
declare function useAppToolInvocationLogApi(): AppToolInvocationLog;
|
|
858
|
+
declare const useAppToolInvocationLog: (<T = AppToolInvocationLogState>(selector?: (state: AppToolInvocationLogState) => T) => T) & {
|
|
859
|
+
(): AppToolInvocationLogState;
|
|
860
|
+
<U>(selector: (state: AppToolInvocationLogState) => U): U;
|
|
861
|
+
} & StoreApi<AppToolInvocationLogState>;
|
|
862
|
+
declare function recordAppToolInvocation(args: Omit<AppToolInvocationRecord, "invokedAtMs">, addTrafficLog?: AddTrafficLog, invocationLog?: AppToolInvocationLog): void;
|
|
803
863
|
declare function useAppToolAttributionResolver(chatSessionId?: string): (label: string) => AppToolAttribution | null;
|
|
804
864
|
declare function useAppToolAttribution(label: string, chatSessionId?: string): AppToolAttribution | null;
|
|
805
865
|
declare const __internal: {
|
|
@@ -975,9 +1035,11 @@ interface SandboxedIframeProps {
|
|
|
975
1035
|
* restores the legacy `iframe.srcdoc` mount, where the view has no URL of
|
|
976
1036
|
* its own. Supplied by the host (`host.surface.viewMountMode`); build-time
|
|
977
1037
|
* only, so it exists to exercise the srcdoc branch rather than to switch
|
|
978
|
-
* behaviour at runtime.
|
|
1038
|
+
* behaviour at runtime. `"opaque"` is per client: a srcdoc mount without
|
|
1039
|
+
* `allow-same-origin`, so the view runs in an opaque origin
|
|
1040
|
+
* (the renderer picks it from the client's `sameOriginAppIframe: false`).
|
|
979
1041
|
*/
|
|
980
|
-
mountMode?: "write" | "srcdoc";
|
|
1042
|
+
mountMode?: "write" | "srcdoc" | "opaque";
|
|
981
1043
|
/**
|
|
982
1044
|
* Per-server label for a dedicated view origin, and whether this deploy
|
|
983
1045
|
* serves one. Supplied by the host; without both the view renders on the
|
|
@@ -985,6 +1047,13 @@ interface SandboxedIframeProps {
|
|
|
985
1047
|
*/
|
|
986
1048
|
viewOriginLabel?: string;
|
|
987
1049
|
viewSubdomainsEnabled?: boolean;
|
|
1050
|
+
/**
|
|
1051
|
+
* Changing this reloads the guest document (the resource is sent to the
|
|
1052
|
+
* proxy again) even when the payload is unchanged. The renderer bumps it
|
|
1053
|
+
* for every new AppBridge: a guest initializes once per document, so a
|
|
1054
|
+
* bridge that replaced another one never hears `ui/initialize` otherwise.
|
|
1055
|
+
*/
|
|
1056
|
+
reloadKey?: number | string;
|
|
988
1057
|
}
|
|
989
1058
|
/**
|
|
990
1059
|
* SandboxedIframe provides a secure double-iframe architecture per SEP-1865.
|
|
@@ -1024,6 +1093,8 @@ interface MCPAppsRendererProps {
|
|
|
1024
1093
|
onCallTool?: (toolName: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
1025
1094
|
onAppToolInvocationChange?: (invocation: AppToolInvocationUpdate) => void;
|
|
1026
1095
|
onWidgetStateChange?: (toolCallId: string, state: unknown) => void;
|
|
1096
|
+
/** Fixed initial-render outcome, without guest content or error text. */
|
|
1097
|
+
onInitialRenderOutcome?: (outcome: "ready" | "error") => void;
|
|
1027
1098
|
/**
|
|
1028
1099
|
* Tier 2 recorder. When `recordMode` is on, the sandbox proxy injects a
|
|
1029
1100
|
* recorder shim into the guest; `onRecorderStep` fires for each captured
|
|
@@ -1132,6 +1203,8 @@ interface MCPAppsRendererProps {
|
|
|
1132
1203
|
* way).
|
|
1133
1204
|
*/
|
|
1134
1205
|
initialWidgetState?: unknown;
|
|
1206
|
+
/** The workspace owns the rectangle and toolbar, independent of protocol display mode. */
|
|
1207
|
+
hostManagedPresentation?: boolean;
|
|
1135
1208
|
/** Minimal mode hides diagnostics and metadata surfaces */
|
|
1136
1209
|
minimalMode?: boolean;
|
|
1137
1210
|
/**
|
|
@@ -1148,7 +1221,7 @@ interface MCPAppsRendererProps {
|
|
|
1148
1221
|
persistentSurfaceInitialToolCallId?: string;
|
|
1149
1222
|
}
|
|
1150
1223
|
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;
|
|
1224
|
+
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
1225
|
|
|
1153
1226
|
declare function WidgetSurfaceHostProvider({ children, }: {
|
|
1154
1227
|
children: ReactNode;
|
|
@@ -1157,7 +1230,7 @@ declare function usePersistentWidgetSurfaceHost(): boolean;
|
|
|
1157
1230
|
|
|
1158
1231
|
declare function WidgetSurfaceHost({ chatSessionId, }: {
|
|
1159
1232
|
chatSessionId?: string;
|
|
1160
|
-
}): react.JSX.Element;
|
|
1233
|
+
}): react.JSX.Element | null;
|
|
1161
1234
|
|
|
1162
1235
|
type WidgetSurfaceId = string;
|
|
1163
1236
|
interface WidgetSurfaceRegistration {
|
|
@@ -1168,25 +1241,135 @@ interface WidgetSurfaceRegistration {
|
|
|
1168
1241
|
}
|
|
1169
1242
|
interface WidgetSurfaceRecord {
|
|
1170
1243
|
surfaceId: WidgetSurfaceId;
|
|
1244
|
+
/** Chosen before the first render; moving a live iframe resets its context. */
|
|
1245
|
+
presentation?: "panel" | "modal";
|
|
1171
1246
|
chatSessionId?: string;
|
|
1172
1247
|
initialToolCallId: string;
|
|
1173
1248
|
latestToolCallId: string;
|
|
1174
1249
|
registrations: Map<string, WidgetSurfaceRegistration>;
|
|
1250
|
+
/** Instance-owned render input survives removal of presentation rows. */
|
|
1251
|
+
retainedProps: MCPAppsRendererProps;
|
|
1252
|
+
/** Live adapter only; never include services in a recording projection. */
|
|
1253
|
+
host?: WidgetHost;
|
|
1254
|
+
}
|
|
1255
|
+
/** Why a workspace refused to open an App surface. */
|
|
1256
|
+
interface WidgetSurfaceAdmissionError {
|
|
1257
|
+
code: "WIDGET_INSTANCE_LIMIT";
|
|
1258
|
+
/** Plain-English description, safe to show as-is. */
|
|
1259
|
+
message: string;
|
|
1260
|
+
limit: number;
|
|
1175
1261
|
}
|
|
1176
1262
|
interface WidgetSurfaceStoreState {
|
|
1177
1263
|
surfaces: Map<WidgetSurfaceId, WidgetSurfaceRecord>;
|
|
1264
|
+
/**
|
|
1265
|
+
* Surfaces a retaining workspace refused because it already holds its
|
|
1266
|
+
* maximum number of live Apps. Cleared when the surface is admitted later
|
|
1267
|
+
* or destroyed. Refusing (instead of throwing from a layout effect) keeps
|
|
1268
|
+
* the rest of the workspace rendering.
|
|
1269
|
+
*/
|
|
1270
|
+
refused: Map<WidgetSurfaceId, WidgetSurfaceAdmissionError>;
|
|
1178
1271
|
nextOrder: number;
|
|
1179
|
-
upsertRegistration: (surfaceId: WidgetSurfaceId, toolCallId: string, props: MCPAppsRendererProps) => void;
|
|
1272
|
+
upsertRegistration: (surfaceId: WidgetSurfaceId, toolCallId: string, props: MCPAppsRendererProps, host?: WidgetHost, presentation?: WidgetSurfaceRecord["presentation"]) => void;
|
|
1180
1273
|
setAnchor: (surfaceId: WidgetSurfaceId, toolCallId: string, anchorElement: HTMLDivElement | null) => void;
|
|
1181
1274
|
releaseRegistration: (surfaceId: WidgetSurfaceId, toolCallId: string) => void;
|
|
1182
1275
|
clearChatSession: (chatSessionId?: string) => void;
|
|
1276
|
+
destroySurface: (surfaceId: WidgetSurfaceId) => void;
|
|
1277
|
+
dispose: () => void;
|
|
1278
|
+
setEnabled: (enabled: boolean) => void;
|
|
1183
1279
|
}
|
|
1184
|
-
declare
|
|
1280
|
+
declare function createWidgetSurfaceStore(options?: {
|
|
1281
|
+
retainInstances?: boolean;
|
|
1282
|
+
maxInstances?: number;
|
|
1283
|
+
}): zustand.UseBoundStore<zustand.StoreApi<WidgetSurfaceStoreState>>;
|
|
1284
|
+
type WidgetSurfaceStore = ReturnType<typeof createWidgetSurfaceStore>;
|
|
1285
|
+
/** Why the current workspace refused `surfaceId`, or null. */
|
|
1286
|
+
declare function useWidgetSurfaceAdmissionError(surfaceId: WidgetSurfaceId | null | undefined): WidgetSurfaceAdmissionError | null;
|
|
1287
|
+
declare function useWidgetSurfaceStoreApi(): WidgetSurfaceStore;
|
|
1288
|
+
/** Static methods retain legacy compatibility; workspace callbacks use the API hook. */
|
|
1289
|
+
declare const useWidgetSurfaceStore: (<T = WidgetSurfaceStoreState>(selector?: (state: WidgetSurfaceStoreState) => T) => T) & {
|
|
1290
|
+
(): WidgetSurfaceStoreState;
|
|
1291
|
+
<U>(selector: (state: WidgetSurfaceStoreState) => U): U;
|
|
1292
|
+
} & zustand.StoreApi<WidgetSurfaceStoreState>;
|
|
1185
1293
|
declare function getRenderableSurfaceEntries(surfaces: Map<WidgetSurfaceId, WidgetSurfaceRecord>, chatSessionId?: string): {
|
|
1186
1294
|
surfaceId: WidgetSurfaceId;
|
|
1187
1295
|
anchorElement: HTMLDivElement | null;
|
|
1188
1296
|
initialToolCallId: string;
|
|
1189
1297
|
props: MCPAppsRendererProps;
|
|
1298
|
+
host?: WidgetHost;
|
|
1190
1299
|
}[];
|
|
1191
1300
|
|
|
1192
|
-
|
|
1301
|
+
/** Per-workspace stores; Host Compare mounts one provider per lane. */
|
|
1302
|
+
declare const WidgetWorkspaceContext: react.Context<{
|
|
1303
|
+
workspaceId: string;
|
|
1304
|
+
surfaces: WidgetSurfaceStore;
|
|
1305
|
+
registry: AppToolsRegistry;
|
|
1306
|
+
invocations: AppToolInvocationLog;
|
|
1307
|
+
} | null>;
|
|
1308
|
+
|
|
1309
|
+
/** One owner per workspace/lane. Key this provider when its binding changes. */
|
|
1310
|
+
declare function WidgetWorkspaceProvider({ workspaceId, children, }: {
|
|
1311
|
+
workspaceId: string;
|
|
1312
|
+
children: ReactNode;
|
|
1313
|
+
}): react.JSX.Element;
|
|
1314
|
+
declare function useOptionalWidgetWorkspace(): {
|
|
1315
|
+
workspaceId: string;
|
|
1316
|
+
surfaces: WidgetSurfaceStore;
|
|
1317
|
+
registry: AppToolsRegistry;
|
|
1318
|
+
invocations: AppToolInvocationLog;
|
|
1319
|
+
} | null;
|
|
1320
|
+
declare function useWidgetWorkspace(): {
|
|
1321
|
+
workspaceId: string;
|
|
1322
|
+
surfaces: WidgetSurfaceStore;
|
|
1323
|
+
registry: AppToolsRegistry;
|
|
1324
|
+
invocations: AppToolInvocationLog;
|
|
1325
|
+
};
|
|
1326
|
+
/** Explicit destruction owns registry cancellation; row cleanup never calls it. */
|
|
1327
|
+
declare function closeWorkspaceSurface(workspace: NonNullable<ContextType<typeof WidgetWorkspaceContext>>, surfaceId: string): void;
|
|
1328
|
+
/**
|
|
1329
|
+
* Every app's DOM parent is permanent. Selection only toggles presentation;
|
|
1330
|
+
* nothing is portaled/reparented into a transcript row or a different panel.
|
|
1331
|
+
*/
|
|
1332
|
+
declare function WidgetWorkspaceSurfaceHost({ activeSurfaceId, renderSurface, renderContainer, }: {
|
|
1333
|
+
activeSurfaceId: string | null;
|
|
1334
|
+
renderSurface?: (props: MCPAppsRendererProps) => ReactNode;
|
|
1335
|
+
/** Chrome is chosen by the immutable presentation slot, never by selection. */
|
|
1336
|
+
renderContainer?: (input: {
|
|
1337
|
+
surface: WidgetSurfaceRecord;
|
|
1338
|
+
active: boolean;
|
|
1339
|
+
children: ReactNode;
|
|
1340
|
+
}) => ReactNode;
|
|
1341
|
+
}): react.JSX.Element;
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* Where a chat App draws itself when it goes fullscreen. Without a placement
|
|
1345
|
+
* it covers the window (today's chat fullscreen). With one, the host gives a
|
|
1346
|
+
* viewport rectangle instead — the Playground's right-rail App area for
|
|
1347
|
+
* clients whose Apps move into a side panel tab — and the App's DOM parent
|
|
1348
|
+
* never changes, so it doesn't reload. A placed App stacks above the panel
|
|
1349
|
+
* that holds its rectangle, even when that panel is itself layered over the
|
|
1350
|
+
* chat (a narrow window's side panel).
|
|
1351
|
+
*/
|
|
1352
|
+
interface WidgetFullscreenPlacement {
|
|
1353
|
+
rect: {
|
|
1354
|
+
top: number;
|
|
1355
|
+
left: number;
|
|
1356
|
+
width: number;
|
|
1357
|
+
height: number;
|
|
1358
|
+
} | null;
|
|
1359
|
+
/** Text for the exit control (e.g. "Exit full screen"); an X when absent. */
|
|
1360
|
+
exitLabel?: string;
|
|
1361
|
+
/** The placed App announces itself: its label and how to leave fullscreen. */
|
|
1362
|
+
onEnter?: (app: {
|
|
1363
|
+
label: string;
|
|
1364
|
+
exit: () => void;
|
|
1365
|
+
}) => void;
|
|
1366
|
+
onLeave?: () => void;
|
|
1367
|
+
/**
|
|
1368
|
+
* The person left fullscreen with the placed App's own exit control, as
|
|
1369
|
+
* opposed to the host ending it (another tab chosen, the panel hidden).
|
|
1370
|
+
*/
|
|
1371
|
+
onExit?: () => void;
|
|
1372
|
+
}
|
|
1373
|
+
declare const WidgetFullscreenPlacementContext: react.Context<WidgetFullscreenPlacement | null>;
|
|
1374
|
+
|
|
1375
|
+
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 };
|