@runsnative/mcp-server 0.7.0 → 0.7.1
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/tools/render-surface.js +12 -1
- package/package.json +1 -1
|
@@ -22,8 +22,15 @@ import { getLinkedPairId } from '../bridge-client.js';
|
|
|
22
22
|
import { componentsBundle, iframeRuntime } from '../surface/assets.js';
|
|
23
23
|
import { AGENT_SURFACE_URI, buildAgentSurfaceHtml } from '../surface/agent-surface.js';
|
|
24
24
|
import { SURFACE_MIME_TYPE } from '../surface/package-surface.js';
|
|
25
|
-
import { SurfaceHostSession, SurfaceHostStateError, } from '../../../surface-protocol/surface-host-client.js';
|
|
26
25
|
import { engineGatewayTransport } from '../surface/engine-gateway-transport.js';
|
|
26
|
+
let _surfaceHostClientModule;
|
|
27
|
+
/** Lazy, memoized load of the surface-host-client runtime classes. */
|
|
28
|
+
async function loadSurfaceHostClient() {
|
|
29
|
+
if (!_surfaceHostClientModule) {
|
|
30
|
+
_surfaceHostClientModule = await import('../surface/surface-host-client.js');
|
|
31
|
+
}
|
|
32
|
+
return _surfaceHostClientModule;
|
|
33
|
+
}
|
|
27
34
|
// ---------------------------------------------------------------------------
|
|
28
35
|
// Module-level state — one active surface per MCP server process, and an
|
|
29
36
|
// injectable transport (default: the engine gateway over HTTP).
|
|
@@ -110,6 +117,7 @@ export async function handleRenderSurface(args) {
|
|
|
110
117
|
if (!route) {
|
|
111
118
|
throw new McpError(ErrorCode.InvalidParams, 'render_surface requires a non-empty "route".');
|
|
112
119
|
}
|
|
120
|
+
const { SurfaceHostSession } = await loadSurfaceHostClient();
|
|
113
121
|
const session = new SurfaceHostSession({
|
|
114
122
|
transport: _transport,
|
|
115
123
|
agentSessionId: currentAgentSessionId(),
|
|
@@ -152,6 +160,9 @@ export async function handleSurfaceEvent(args) {
|
|
|
152
160
|
outcome = await _session.submit(eventType, payload);
|
|
153
161
|
}
|
|
154
162
|
catch (e) {
|
|
163
|
+
// Already loaded — reaching here requires an active _session, which only
|
|
164
|
+
// handleRenderSurface (which loads the module first) can have set.
|
|
165
|
+
const { SurfaceHostStateError } = await loadSurfaceHostClient();
|
|
155
166
|
if (e instanceof SurfaceHostStateError) {
|
|
156
167
|
// Non-resumable (session-less) surface, or ordering violation — a clean
|
|
157
168
|
// host-side signal, not a crash.
|