/** * Versioned envelope shared by every postMessage between a UI plugin * (iframe-mounted or in-process) and its host shell. * * Both sides import these types from this module — there is no other * source of truth for the wire format. Bumping the envelope is a * deliberate breaking-change event; the major version embedded in * `ENVELOPE_VERSION` rides independently of the package's CalVer. */ export declare const ENVELOPE_VERSION: 1; export type EnvelopeVersion = typeof ENVELOPE_VERSION; /** Operations the host sends to the plugin. */ export type HostOp = 'host:init' | 'host:theme-change' | 'host:locale-change' | 'host:feature-flag' | 'host:context-change' | 'host:event' | 'host:rpc-response' | 'host:rpc-progress' | 'host:dispose'; /** Operations the plugin sends to the host. */ export type PluginOp = 'plugin:ready' | 'plugin:rpc-request' | 'plugin:event-emit' | 'plugin:set-badge' | 'plugin:set-title' | 'plugin:resize-request' | 'plugin:error'; export interface HostEnvelope

{ v: EnvelopeVersion; source: 'host'; kind: HostOp; /** Set when this envelope answers (or progresses) a prior plugin RPC. */ requestId?: string; payload: P; } export interface PluginEnvelope

{ v: EnvelopeVersion; source: 'plugin'; kind: PluginOp; /** Set on rpc-request / set on plugin:error when caused by a specific RPC. */ requestId?: string; payload: P; } export type Envelope

= HostEnvelope

| PluginEnvelope

; /** * Type guard that an unknown postMessage payload looks like a valid v1 * envelope. Origin and `event.source` checks are *not* performed here — * the caller must do those *before* trusting the payload, because a * well-formed envelope from a hostile origin is still hostile. */ export declare function isEnvelope(value: unknown): value is Envelope; /** Convenience: narrow to a HostEnvelope (caller already trusts the origin). */ export declare function isHostEnvelope(value: unknown): value is HostEnvelope; /** Convenience: narrow to a PluginEnvelope (caller already trusts the origin). */ export declare function isPluginEnvelope(value: unknown): value is PluginEnvelope; /** Sent in reply to `plugin:ready`. The plugin blocks render until it arrives. */ export interface HostInitPayload { /** Scoped iframe token. Bounded by manifest capabilities. */ iframeToken: string; tunnelUrl: string; mountPoint: string; context: Record; agentId: string; profile: string; theme: { colorMode: 'light' | 'dark'; tokens: Record; }; locale: string; capabilities: { restPaths: string[]; wsTopics: string[]; rpcMethods: string[]; }; featureFlags: Record; sdkVersion: string; hostVersion: string; } export interface HostThemeChangePayload { colorMode: 'light' | 'dark'; tokens: Record; } export interface HostLocaleChangePayload { locale: string; } export interface HostFeatureFlagPayload { flag: string; value: boolean; } export interface HostContextChangePayload { context: Record; } export interface HostEventPayload { name: string; data: T; } export interface HostRpcResponsePayload { ok: boolean; result?: T; error?: { code: string; message: string; data?: unknown; }; } export interface HostRpcProgressPayload { progress: T; } export type HostDisposePayload = Record; export interface PluginReadyPayload { pluginId: string; pluginVersion: string; sdkVersion: string; declaredCapabilities: { restPaths: string[]; wsTopics: string[]; rpcMethods: string[]; }; } export interface PluginRpcRequestPayload { method: string; args: unknown; /** Caller hint that the RPC may stream progress before terminal response. */ streaming?: boolean; } export interface PluginEventEmitPayload { name: string; data: T; } export interface PluginSetBadgePayload { value: string | number | null; } export interface PluginSetTitlePayload { value: string; } export interface PluginResizeRequestPayload { /** Suggested iframe height in pixels. Host may ignore. */ height?: number; width?: number; } export interface PluginErrorPayload { code: string; message: string; stack?: string; /** Optional reference to a specific in-flight requestId. */ requestId?: string; } //# sourceMappingURL=envelope.d.ts.map