Remote Component Host Bridge
The host bridge connects a Remote Component iframe, the Workbench host, and the plugin View Provider. It is not a generic RPC tunnel: every capability requires a manifest declaration, a host message handler, and the corresponding server implementation.Three contract layers
The host must reject a capability when any layer is missing.
Message envelope
All messages use a fixed channel and protocol version:- The iframe sends
readyafter loading. - The host returns
initwith theinstanceId, manifest, initial query, locale, theme, and debug configuration. - Later messages must carry the matching
instanceId. - Requests and responses share one
requestId. - The iframe accepts messages only from
window.parent; the host accepts messages only from the current iframecontentWindow.
Supported messages
Host to iframe:
Iframe to host:
Capability mapping
TypeScript bridge client
Keep the bridge inbridge.ts; business components should not construct wire messages directly.
requestData(), executeAction(), and invokeClientCommand() on top of this boundary. Return stable error codes from the bridge and translate them at the UI boundary.
Query data
XpertViewQuery.parameters accepts only scalar values or scalar arrays. Serialize a complex filter into one explicit JSON string parameter and parse it safely in the provider.
Use server-side pagination for large tables. Do not load every record into the iframe.
Execute actions
Use JSON actions for normal business mutations:actionKey must exist in manifest.actions, and its transport must match. The provider still validates the target, current user, and tenant/organization scope.
Use executeFileAction for uploads; do not put binary or Base64 content in JSON actions. Use requestFileAccess for previews and downloads so the host can issue a time-bounded grant.
Client commands
Client commands perform host-local UI behavior without calling the plugin provider. Examples include sending an Assistant message, setting Assistant context, opening a file, or navigating to another Workbench view. They form a closed three-party contract:- The source manifest allowlists the command key in
clientCommands. - The current host registers a handler for the same key.
- The Remote Component invokes it through
invokeClientCommandand handles a structured failure result.
Host events
A Remote Component can subscribe to normalized host events, such as a completed Agent middleware tool:refresh. Prefer forward for Remote Components so they can refresh only the affected data. If local edits are dirty, do not silently replace them with remote state.
Initialization, theme, and locale
Treatinit.locale as authoritative and normalize it once to a BCP 47 tag such as en-US, zh-Hans, or zh-Hant. Do not select copy with locale branches inside business components.
After applying init.theme.tokens, call installShadcnThemeVars() to install semantic theme variables. Gate debug logging with init.debug.enabled; do not infer development mode from URLs, hostnames, or platform identity.
Do not rely on localStorage or sessionStorage. Keep ephemeral state in React and persist durable state through the host bridge.
Security checklist
- Do not pass access tokens, API URLs, Assistant IDs, tenant IDs, or organization IDs into the iframe.
- Do not let the iframe select
hostTypeorhostId. - Reject actions, file capabilities, and client commands that are absent from the manifest.
- Do not log tokens, file contents, complete business snapshots, or personally sensitive data.
- Re-run authorization and tenant/organization isolation for every provider read and mutation.
- Test the message source, protocol version, instance ID, and request ID boundaries.