@sentropic/h2a 0.98.7 → 0.98.8-rc.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.
Files changed (147) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +56 -15
  5. package/dist/cli.js.map +1 -1
  6. package/dist/hosts/native-artifacts.d.ts +2 -0
  7. package/dist/hosts/native-artifacts.d.ts.map +1 -1
  8. package/dist/hosts/native-artifacts.js +19 -5
  9. package/dist/hosts/native-artifacts.js.map +1 -1
  10. package/dist/hosts/native-convergence.d.ts +1 -0
  11. package/dist/hosts/native-convergence.d.ts.map +1 -1
  12. package/dist/hosts/native-convergence.js +1 -1
  13. package/dist/hosts/native-convergence.js.map +1 -1
  14. package/dist/hosts/native-skills.d.ts +6 -0
  15. package/dist/hosts/native-skills.d.ts.map +1 -1
  16. package/dist/hosts/native-skills.js +9 -4
  17. package/dist/hosts/native-skills.js.map +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/runtime/identity/live.d.ts.map +1 -1
  23. package/dist/runtime/identity/live.js +27 -4
  24. package/dist/runtime/identity/live.js.map +1 -1
  25. package/dist/runtime/identity/worker.js +21 -2
  26. package/dist/runtime/identity/worker.js.map +1 -1
  27. package/dist/runtime/local-files/identity-fence.d.ts +1 -0
  28. package/dist/runtime/local-files/identity-fence.d.ts.map +1 -1
  29. package/dist/runtime/local-files/identity-fence.js +14 -3
  30. package/dist/runtime/local-files/identity-fence.js.map +1 -1
  31. package/dist/runtime/local-files/locks.d.ts +16 -9
  32. package/dist/runtime/local-files/locks.d.ts.map +1 -1
  33. package/dist/runtime/local-files/locks.js +238 -42
  34. package/dist/runtime/local-files/locks.js.map +1 -1
  35. package/dist/runtime/local-files/succession-lock.d.ts.map +1 -1
  36. package/dist/runtime/local-files/succession-lock.js +7 -6
  37. package/dist/runtime/local-files/succession-lock.js.map +1 -1
  38. package/dist/runtime/mcp/identity-state.d.ts +2 -0
  39. package/dist/runtime/mcp/identity-state.d.ts.map +1 -1
  40. package/dist/runtime/mcp/identity-state.js +39 -1
  41. package/dist/runtime/mcp/identity-state.js.map +1 -1
  42. package/dist/runtime/mcp/index.d.ts +11 -1
  43. package/dist/runtime/mcp/index.d.ts.map +1 -1
  44. package/dist/runtime/mcp/index.js +10 -0
  45. package/dist/runtime/mcp/index.js.map +1 -1
  46. package/dist/runtime/mcp/server.d.ts +23 -1
  47. package/dist/runtime/mcp/server.d.ts.map +1 -1
  48. package/dist/runtime/mcp/server.js +18 -2
  49. package/dist/runtime/mcp/server.js.map +1 -1
  50. package/dist/runtime/mcp/stdio.d.ts.map +1 -1
  51. package/dist/runtime/mcp/stdio.js +60 -4
  52. package/dist/runtime/mcp/stdio.js.map +1 -1
  53. package/dist/runtime/mcp/tools.d.ts +22 -0
  54. package/dist/runtime/mcp/tools.d.ts.map +1 -1
  55. package/dist/runtime/mcp/tools.js.map +1 -1
  56. package/dist/runtime/mcp/ui-render/a2ui-common-types.d.ts +32 -0
  57. package/dist/runtime/mcp/ui-render/a2ui-common-types.d.ts.map +1 -0
  58. package/dist/runtime/mcp/ui-render/a2ui-common-types.js +374 -0
  59. package/dist/runtime/mcp/ui-render/a2ui-common-types.js.map +1 -0
  60. package/dist/runtime/mcp/ui-render/assets.d.ts +104 -0
  61. package/dist/runtime/mcp/ui-render/assets.d.ts.map +1 -0
  62. package/dist/runtime/mcp/ui-render/assets.js +217 -0
  63. package/dist/runtime/mcp/ui-render/assets.js.map +1 -0
  64. package/dist/runtime/mcp/ui-render/bpmn-port.d.ts +3 -0
  65. package/dist/runtime/mcp/ui-render/bpmn-port.d.ts.map +1 -0
  66. package/dist/runtime/mcp/ui-render/bpmn-port.js +621 -0
  67. package/dist/runtime/mcp/ui-render/bpmn-port.js.map +1 -0
  68. package/dist/runtime/mcp/ui-render/fallback.d.ts +35 -0
  69. package/dist/runtime/mcp/ui-render/fallback.d.ts.map +1 -0
  70. package/dist/runtime/mcp/ui-render/fallback.js +245 -0
  71. package/dist/runtime/mcp/ui-render/fallback.js.map +1 -0
  72. package/dist/runtime/mcp/ui-render/index.d.ts +51 -0
  73. package/dist/runtime/mcp/ui-render/index.d.ts.map +1 -0
  74. package/dist/runtime/mcp/ui-render/index.js +38 -0
  75. package/dist/runtime/mcp/ui-render/index.js.map +1 -0
  76. package/dist/runtime/mcp/ui-render/inline.d.ts +3 -0
  77. package/dist/runtime/mcp/ui-render/inline.d.ts.map +1 -0
  78. package/dist/runtime/mcp/ui-render/inline.js +21 -0
  79. package/dist/runtime/mcp/ui-render/inline.js.map +1 -0
  80. package/dist/runtime/mcp/ui-render/negotiation.d.ts +23 -0
  81. package/dist/runtime/mcp/ui-render/negotiation.d.ts.map +1 -0
  82. package/dist/runtime/mcp/ui-render/negotiation.js +45 -0
  83. package/dist/runtime/mcp/ui-render/negotiation.js.map +1 -0
  84. package/dist/runtime/mcp/ui-render/registry-entry.d.ts +74 -0
  85. package/dist/runtime/mcp/ui-render/registry-entry.d.ts.map +1 -0
  86. package/dist/runtime/mcp/ui-render/registry-entry.js +207 -0
  87. package/dist/runtime/mcp/ui-render/registry-entry.js.map +1 -0
  88. package/dist/runtime/mcp/ui-render/resources.d.ts +35 -0
  89. package/dist/runtime/mcp/ui-render/resources.d.ts.map +1 -0
  90. package/dist/runtime/mcp/ui-render/resources.js +342 -0
  91. package/dist/runtime/mcp/ui-render/resources.js.map +1 -0
  92. package/dist/runtime/mcp/ui-render/tools.d.ts +42 -0
  93. package/dist/runtime/mcp/ui-render/tools.d.ts.map +1 -0
  94. package/dist/runtime/mcp/ui-render/tools.js +367 -0
  95. package/dist/runtime/mcp/ui-render/tools.js.map +1 -0
  96. package/dist/runtime/mcp/ui-render/types.d.ts +96 -0
  97. package/dist/runtime/mcp/ui-render/types.d.ts.map +1 -0
  98. package/dist/runtime/mcp/ui-render/types.js +22 -0
  99. package/dist/runtime/mcp/ui-render/types.js.map +1 -0
  100. package/dist/runtime/mcp/ui-render/validation.d.ts +151 -0
  101. package/dist/runtime/mcp/ui-render/validation.d.ts.map +1 -0
  102. package/dist/runtime/mcp/ui-render/validation.js +460 -0
  103. package/dist/runtime/mcp/ui-render/validation.js.map +1 -0
  104. package/dist/runtime/mcp/ui-render/watermark.d.ts +38 -0
  105. package/dist/runtime/mcp/ui-render/watermark.d.ts.map +1 -0
  106. package/dist/runtime/mcp/ui-render/watermark.js +52 -0
  107. package/dist/runtime/mcp/ui-render/watermark.js.map +1 -0
  108. package/dist/runtime/mcp-central.d.ts.map +1 -1
  109. package/dist/runtime/mcp-central.js +55 -6
  110. package/dist/runtime/mcp-central.js.map +1 -1
  111. package/fixtures/ui-render-ac-l3/offline-measurement.v1.json +105 -0
  112. package/package.json +8 -5
  113. package/vendor/design-system-elements/catalog.json +1234 -0
  114. package/vendor/design-system-elements/dist/browser/assets/bpmn-CZlEAdL6.ttf +0 -0
  115. package/vendor/design-system-elements/dist/browser/assets/bpmn-DaGVGZ7K.woff +0 -0
  116. package/vendor/design-system-elements/dist/browser/assets/bpmn-DaJ2be00.woff2 +0 -0
  117. package/vendor/design-system-elements/dist/browser/chunks/BpmnRenderUtil-WMCgqGDs.js +1 -0
  118. package/vendor/design-system-elements/dist/browser/chunks/BpmnUpdater-C-UNbzXl.js +1 -0
  119. package/vendor/design-system-elements/dist/browser/chunks/LabelUtil-7QpE43Ed.js +1 -0
  120. package/vendor/design-system-elements/dist/browser/chunks/LayoutUtil-hAMJmJFU.js +1 -0
  121. package/vendor/design-system-elements/dist/browser/chunks/ModelUtil-CMh7LuN4.js +1 -0
  122. package/vendor/design-system-elements/dist/browser/chunks/Modeler-BfAmwsmK.js +389 -0
  123. package/vendor/design-system-elements/dist/browser/chunks/Viewer-eYLzc3fD.js +4 -0
  124. package/vendor/design-system-elements/dist/browser/chunks/bpmn-canvas-DeAWdJFy.js +2207 -0
  125. package/vendor/design-system-elements/dist/browser/chunks/colored-CSIQaGsQ.js +1 -0
  126. package/vendor/design-system-elements/dist/browser/chunks/dist-Co2MgHWm.js +1 -0
  127. package/vendor/design-system-elements/dist/browser/chunks/dist-O6_2ByYB.js +1 -0
  128. package/vendor/design-system-elements/dist/browser/chunks/dist-kvAYI1vo.js +1 -0
  129. package/vendor/design-system-elements/dist/browser/chunks/entropic-CM5BHERN.js +2173 -0
  130. package/vendor/design-system-elements/dist/browser/chunks/focus-renderer-C4z8aS9F.js +8 -0
  131. package/vendor/design-system-elements/dist/browser/chunks/forge-B8hrW4lA.js +2173 -0
  132. package/vendor/design-system-elements/dist/browser/chunks/layout-q0TR9-aY.js +1 -0
  133. package/vendor/design-system-elements/dist/browser/chunks/legend-CXdfCBh6.js +1 -0
  134. package/vendor/design-system-elements/dist/browser/chunks/textMetrics-BrMS6-sA.js +2 -0
  135. package/vendor/design-system-elements/dist/browser/chunks/tokens-DFPpCvf1.js +1 -0
  136. package/vendor/design-system-elements/dist/browser/elements.js +2221 -0
  137. package/vendor/design-system-elements/dist/browser/sri.json +166 -0
  138. package/vendor/design-system-elements/envelope.json +43 -0
  139. package/vendor/design-system-elements/manifest.json +101 -0
  140. package/vendor/design-system-elements/schemas/BarChart.v1.json +556 -0
  141. package/vendor/design-system-elements/schemas/BpmnCanvas.v1.json +139 -0
  142. package/vendor/design-system-elements/schemas/DecisionDossier.v1.json +635 -0
  143. package/vendor/ui-render-inline/BarChart.js +1 -0
  144. package/vendor/ui-render-inline/BpmnCanvas.js +1 -0
  145. package/vendor/ui-render-inline/DecisionDossier.js +1 -0
  146. package/vendor/ui-render-inline/manifest.json +80 -0
  147. package/vendor/ui-render-inline/render.js +1 -0
@@ -0,0 +1,342 @@
1
+ /**
2
+ * The ui:// resource surface (h2a spec §3): the five pinned resource
3
+ * descriptors (`resources/list`) and the exact-URI `resources/read`
4
+ * handler. The pilot MCP App shell is assembled server-side from the
5
+ * vendored build — the core runtime (and, for per-component resources, the
6
+ * requested component's transitive engine/theme closure) is inlined together
7
+ * with `#st-host-config`, and the SEP-1865 postMessage bridge script
8
+ * (h2a spec §3.3) implements `ui/initialize`, `ui/notifications/tool-input`
9
+ * / `tool-result` / `host-context-changed`, the §4.4 contract check, the
10
+ * `st-intent` whitelist and the `submit_intent` bridge.
11
+ */
12
+ import { readInlineModule } from "./inline.js";
13
+ import { buildResourceHostConfig, serializeHostConfigScript } from "./watermark.js";
14
+ import { CATALOG_MIME_TYPE, PILOT_RESOURCE_DOMAIN, UI_MIME_TYPE, UnknownResourceError } from "./types.js";
15
+ /** The primary MCP App renderer resource (h2a spec §3.1). */
16
+ export const UI_RENDER_RESOURCE_URI = "ui://sentropic/render/v1";
17
+ /** The A2UI / JSON Schema catalogue resource (h2a spec §3.2). */
18
+ export const A2UI_CATALOG_RESOURCE_URI = "a2ui://sentropic/catalog/v1";
19
+ /** The pilot CSP declaration every ui:// resource carries (DS §6.4 U-12). */
20
+ const PILOT_CSP = { resourceDomains: [PILOT_RESOURCE_DOMAIN], connectDomains: [] };
21
+ /** The custom element tag of one component (st- + kebab-case name). */
22
+ function componentTag(component) {
23
+ return `st-${component.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase()}`;
24
+ }
25
+ /** The x-sentropic metadata block of one catalogue entry. */
26
+ function sentropicOf(entry) {
27
+ return entry?.["x-sentropic"];
28
+ }
29
+ /** The derived per-component metadata the shell script embeds (§3.3). */
30
+ function shellComponentMeta(assets) {
31
+ const events = {};
32
+ const contracts = {};
33
+ const engines = {};
34
+ const tags = {};
35
+ for (const [name, entry] of Object.entries(assets.catalog.components)) {
36
+ const sentropic = sentropicOf(entry);
37
+ events[name] = Array.isArray(sentropic?.events)
38
+ ? sentropic.events.filter((event) => typeof event === "string")
39
+ : [];
40
+ contracts[name] = typeof sentropic?.contract === "string" ? sentropic.contract : "";
41
+ engines[name] = typeof sentropic?.engine === "string" ? sentropic.engine : "";
42
+ tags[name] = componentTag(name);
43
+ }
44
+ return JSON.stringify({ events, contracts, engines, tags });
45
+ }
46
+ /**
47
+ * The SEP-1865 shell protocol script (h2a spec §3.3). Plain classic script:
48
+ * no imports, no eval, no template literals — it only bridges postMessage
49
+ * traffic and mounts the custom element the vendored core defines.
50
+ */
51
+ function shellScript(metaJson) {
52
+ return `
53
+ (function () {
54
+ "use strict";
55
+ var META = ${metaJson};
56
+ var configElement = document.getElementById("st-host-config");
57
+ var hostConfig = {};
58
+ try { hostConfig = JSON.parse(configElement ? configElement.textContent : "{}") || {}; } catch (error) { hostConfig = {}; }
59
+ var root = document.getElementById("st-root");
60
+ var envelope = null;
61
+ var toolInputEnvelope = null;
62
+ var mountedElement = null;
63
+ var resultRevision = 0;
64
+ var diagnostics = [];
65
+ var requestCounter = 0;
66
+
67
+ function postToHost(message) {
68
+ try { window.parent.postMessage(message, "*"); } catch (error) { /* the bridge is best-effort */ }
69
+ }
70
+ function nextRequestId() { requestCounter += 1; return "st-shell-" + requestCounter; }
71
+
72
+ function applyHostContext(context) {
73
+ if (!context || typeof context !== "object") return;
74
+ if (context.colorScheme === "dark" || context.colorScheme === "light") {
75
+ document.documentElement.setAttribute("data-st-color-scheme", context.colorScheme);
76
+ hostConfig = Object.assign({}, hostConfig, { colorScheme: context.colorScheme });
77
+ }
78
+ if (typeof context.locale === "string" && context.locale.trim()) {
79
+ hostConfig = Object.assign({}, hostConfig, { locale: context.locale });
80
+ }
81
+ if (mountedElement) mountedElement.hostConfig = hostConfig;
82
+ var variables = context.cssVariables || context.variables;
83
+ if (variables && typeof variables === "object") {
84
+ for (var name in variables) {
85
+ if (Object.prototype.hasOwnProperty.call(variables, name) && name.indexOf("--") === 0) {
86
+ document.documentElement.style.setProperty(name, String(variables[name]));
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ function hasErrorDiagnostics() {
93
+ for (var index = 0; index < diagnostics.length; index += 1) {
94
+ if (diagnostics[index] && diagnostics[index].severity === "error") return true;
95
+ }
96
+ return false;
97
+ }
98
+
99
+ function showDiagnostics() {
100
+ mountedElement = null;
101
+ var panel = document.createElement("div");
102
+ panel.setAttribute("role", "alert");
103
+ panel.setAttribute("data-st-diagnostics", String(diagnostics.length));
104
+ var title = document.createElement("p");
105
+ title.textContent = "The envelope was refused by the renderer:";
106
+ panel.appendChild(title);
107
+ for (var index = 0; index < diagnostics.length; index += 1) {
108
+ var item = diagnostics[index];
109
+ if (!item) continue;
110
+ var line = document.createElement("p");
111
+ line.textContent = String(item.code || "schema-violation") + " " + String(item.path || "") + " " + String(item.message || "");
112
+ panel.appendChild(line);
113
+ }
114
+ while (root.firstChild) root.removeChild(root.firstChild);
115
+ root.appendChild(panel);
116
+ }
117
+
118
+ function parseContract(value) {
119
+ var parts = String(value || "").split(".");
120
+ if (parts.length !== 2) return null;
121
+ var major = Number(parts[0]);
122
+ var minor = Number(parts[1]);
123
+ if (!Number.isInteger(major) || !Number.isInteger(minor)) return null;
124
+ return { major: major, minor: minor };
125
+ }
126
+
127
+ function contractAccepted(entryContract) {
128
+ var parsedEntry = parseContract(entryContract);
129
+ var parsedEnvelope = envelope ? parseContract(envelope.contract) : null;
130
+ return Boolean(parsedEntry && parsedEnvelope &&
131
+ parsedEnvelope.major === parsedEntry.major &&
132
+ parsedEnvelope.minor <= parsedEntry.minor);
133
+ }
134
+
135
+ function mount() {
136
+ if (hasErrorDiagnostics()) { showDiagnostics(); return; }
137
+ if (!envelope || typeof envelope !== "object") return;
138
+ var target = envelope.root || {};
139
+ var component = typeof target.component === "string" ? target.component : "";
140
+ if (!Object.prototype.hasOwnProperty.call(META.tags, component) ||
141
+ !contractAccepted(META.contracts[component])) {
142
+ diagnostics = [{ code: "unknown-component", path: "/root/component", message: "the shell cannot mount " + component, severity: "error", source: "catalog" }];
143
+ showDiagnostics();
144
+ return;
145
+ }
146
+ var element = document.createElement(META.tags[component]);
147
+ element.hostConfig = hostConfig;
148
+ element.envelope = envelope;
149
+ element.addEventListener("st-intent", onIntent);
150
+ while (root.firstChild) root.removeChild(root.firstChild);
151
+ mountedElement = element;
152
+ root.appendChild(element);
153
+ }
154
+
155
+ function onIntent(event) {
156
+ var detail = event && event.detail;
157
+ if (!detail || typeof detail !== "object") return;
158
+ var name = typeof detail.name === "string" ? detail.name : "";
159
+ var component = envelope && envelope.root && typeof envelope.root.component === "string" ? envelope.root.component : "";
160
+ var allowed = META.events[component] || [];
161
+ if (allowed.indexOf(name) === -1) return; // unlisted intents are dropped (§3.3.3)
162
+ var intent = {
163
+ event: "intent",
164
+ name: name,
165
+ target: typeof detail.target === "string" ? detail.target : "",
166
+ context: Object.assign({ component: component }, detail.context && typeof detail.context === "object" ? detail.context : {})
167
+ };
168
+ postToHost({ jsonrpc: "2.0", id: nextRequestId(), method: "tools/call", params: { name: "submit_intent", arguments: intent } });
169
+ if (name === "select" || name === "choose-option" || name === "open") {
170
+ postToHost({ jsonrpc: "2.0", method: "ui/update-model-context", params: { context: intent } });
171
+ }
172
+ if (name === "comment") {
173
+ postToHost({ jsonrpc: "2.0", method: "ui/message", params: { message: JSON.stringify(intent) } });
174
+ }
175
+ }
176
+
177
+ async function verifyInputDigest(expected, input) {
178
+ function failure(code, message) {
179
+ return { code: code, path: "", message: message, severity: "error", source: "host" };
180
+ }
181
+ if (!input || typeof input !== "object") {
182
+ return failure("schema-violation", "SHA-256 verification requires a retained tool-input envelope");
183
+ }
184
+ if (typeof crypto === "undefined" || !crypto || !crypto.subtle || typeof TextEncoder === "undefined") {
185
+ return failure("host-capability-missing", "SHA-256 verification requires Web Crypto and TextEncoder");
186
+ }
187
+ try {
188
+ var hash = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(input))));
189
+ var actual = "";
190
+ for (var index = 0; index < hash.length; index += 1) actual += hash[index].toString(16).padStart(2, "0");
191
+ if (actual !== expected) return failure("schema-violation", "SHA-256 does not match the retained tool-input envelope");
192
+ } catch (error) {
193
+ return failure("host-capability-missing", "SHA-256 verification failed in the host");
194
+ }
195
+ return null;
196
+ }
197
+
198
+ window.addEventListener("message", async function (event) {
199
+ var message = event.data;
200
+ if (!message || typeof message !== "object") return;
201
+ if (typeof message.method === "string" && message.method.indexOf("ui/notifications/") === 0) {
202
+ var params = message.params && typeof message.params === "object" ? message.params : {};
203
+ if (message.method === "ui/notifications/tool-input") {
204
+ resultRevision += 1;
205
+ toolInputEnvelope = params.arguments;
206
+ envelope = toolInputEnvelope; // retained in memory (DS §8.2)
207
+ diagnostics = [];
208
+ mount();
209
+ } else if (message.method === "ui/notifications/tool-result") {
210
+ var revision = ++resultRevision;
211
+ var structured = params.structuredContent;
212
+ if (structured && typeof structured === "object") {
213
+ var nextDiagnostics = Array.isArray(structured.diagnostics) ? structured.diagnostics : [];
214
+ if (structured.envelope && typeof structured.envelope === "object") {
215
+ envelope = structured.envelope;
216
+ } else if (typeof structured.envelopeSha256 === "string") {
217
+ var retained = toolInputEnvelope;
218
+ var failure = await verifyInputDigest(structured.envelopeSha256, retained);
219
+ if (revision !== resultRevision) return; // a newer input/result owns the surface
220
+ if (failure) nextDiagnostics = nextDiagnostics.concat([failure]);
221
+ else envelope = retained;
222
+ }
223
+ diagnostics = nextDiagnostics;
224
+ }
225
+ mount();
226
+ } else if (message.method === "ui/notifications/host-context-changed") {
227
+ applyHostContext(params);
228
+ }
229
+ return;
230
+ }
231
+ if (typeof message.id === "string" && message.id.indexOf("st-shell-") === 0) {
232
+ applyHostContext(message.result); // the ui/initialize result carries the host context
233
+ }
234
+ });
235
+
236
+ postToHost({ jsonrpc: "2.0", id: nextRequestId(), method: "ui/initialize", params: {} });
237
+ })();
238
+ `;
239
+ }
240
+ /** Assembles the pilot MCP App shell HTML for the full or per-component resource. */
241
+ export function buildShellHtml(assets, hostConfigScript, component) {
242
+ const core = readInlineModule(assets, component);
243
+ const html = `<!DOCTYPE html>
244
+ <html lang="fr">
245
+ <head>
246
+ <meta charset="utf-8">
247
+ <title>Sentropic Design-System JSON Renderer (v1)</title>
248
+ <style>
249
+ html, body { margin: 0; padding: 0; background: #ffffff; color: #111111;
250
+ font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
251
+ #st-root { min-height: 100vh; }
252
+ [data-st-diagnostics] { padding: 16px; }
253
+ [data-st-diagnostics] p { margin: 4px 0; }
254
+ </style>
255
+ </head>
256
+ <body>
257
+ <div id="st-root"></div>
258
+ ${hostConfigScript}
259
+ <script type="module">
260
+ ${core}
261
+ </script>
262
+ <script>
263
+ ${shellScript(shellComponentMeta(assets))}
264
+ </script>
265
+ </body>
266
+ </html>
267
+ `;
268
+ return html;
269
+ }
270
+ /** The `resources/read` contents entry for one ui:// shell resource. */
271
+ function shellContents(uri, html) {
272
+ const bytes = Buffer.byteLength(html);
273
+ if (bytes > 960 * 1024) {
274
+ const fallback = uri === UI_RENDER_RESOURCE_URI
275
+ ? "Use render_BarChart, render_DecisionDossier or render_BpmnCanvas (per-component resources, DS §8.3)."
276
+ : "The complete BPMN module also exceeds the frame budget. Use the non-UI text fallback.";
277
+ const hostConfigScript = html.match(/<script type="application\/json" id="st-host-config">[\s\S]*?<\/script>/)?.[0] ?? "";
278
+ html = `<!DOCTYPE html><html lang="en"><body><div role="alert" data-st-resource-degraded="true">Complete resource: ${bytes} bytes; limit: 983040 bytes. ${fallback}</div>${hostConfigScript}<script>window.parent.postMessage({jsonrpc:"2.0",id:"st-degraded",method:"ui/initialize",params:{}},"*");</script></body></html>`;
279
+ }
280
+ return { uri, mimeType: UI_MIME_TYPE, text: html, _meta: { ui: { csp: PILOT_CSP } } };
281
+ }
282
+ export function createUiRenderResources(options) {
283
+ const assets = options.assets;
284
+ const env = options.env ?? process.env;
285
+ const components = Object.keys(assets.catalog.components);
286
+ function perComponentUri(component) {
287
+ return `ui://sentropic/${component}/v1`;
288
+ }
289
+ function listResources(_context) {
290
+ const resources = [
291
+ {
292
+ uri: UI_RENDER_RESOURCE_URI,
293
+ name: "Sentropic Design-System JSON Renderer (v1)",
294
+ description: `Sandboxed SEP-1865 MCP App shell hosting @sentropic/design-system-elements (${components
295
+ .map(componentTag)
296
+ .map((tag) => `<${tag}>`)
297
+ .join(", ")}).`,
298
+ mimeType: UI_MIME_TYPE,
299
+ _meta: { ui: { csp: PILOT_CSP } }
300
+ },
301
+ {
302
+ uri: A2UI_CATALOG_RESOURCE_URI,
303
+ name: "Sentropic Design-System Elements Catalogue (v1)",
304
+ description: `Machine-readable JSON Schema 2020-12 component catalogue ($id: ${assets.catalog.catalogId}).`,
305
+ mimeType: CATALOG_MIME_TYPE
306
+ }
307
+ ];
308
+ for (const component of components) {
309
+ resources.push({
310
+ uri: perComponentUri(component),
311
+ name: `Sentropic Design-System ${component} Renderer (v1)`,
312
+ description: `Single-component MCP App shell inlining the core runtime, the ${component} engine chunk and #st-host-config.`,
313
+ mimeType: UI_MIME_TYPE,
314
+ _meta: { ui: { csp: PILOT_CSP } }
315
+ });
316
+ }
317
+ return { resources };
318
+ }
319
+ function readResource(uri, _context) {
320
+ if (uri === UI_RENDER_RESOURCE_URI) {
321
+ return {
322
+ contents: [shellContents(uri, buildShellHtml(assets, serializeHostConfigScript(buildResourceHostConfig(env))))]
323
+ };
324
+ }
325
+ if (uri === A2UI_CATALOG_RESOURCE_URI) {
326
+ return { contents: [{ uri, mimeType: CATALOG_MIME_TYPE, text: assets.catalogText }] };
327
+ }
328
+ for (const component of components) {
329
+ if (uri === perComponentUri(component)) {
330
+ return {
331
+ contents: [
332
+ shellContents(uri, buildShellHtml(assets, serializeHostConfigScript(buildResourceHostConfig(env)), component))
333
+ ]
334
+ };
335
+ }
336
+ }
337
+ // No filesystem path traversal or arbitrary URI scheme is ever read.
338
+ throw new UnknownResourceError(uri);
339
+ }
340
+ return { listResources, readResource };
341
+ }
342
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../../src/runtime/mcp/ui-render/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MA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OAAO;oBACL,QAAQ,EAAE;wBACR,aAAa,CACX,GAAG,EACH,cAAc,CAAC,MAAM,EAAE,yBAAyB,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAC3F;qBACF;iBACF,CAAC;YACJ,CAAC;QACH,CAAC;QACD,qEAAqE;QACrE,MAAM,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The ui:// render tool surface (h2a spec §4; DS spec §8.2, §8.3):
3
+ * `list_components`, `get_schema`, `render`, the per-component fallback
4
+ * `render_<id>` tools, and `submit_intent`. Every result is a transport-
5
+ * shaped `{ content, structuredContent?, isError? }` — `structuredContent`
6
+ * carries the machine view (envelope echo + diagnostics) while `content`
7
+ * stays within the DS §8.2 byte caps so the model-visible surface is always
8
+ * bounded.
9
+ */
10
+ import type { UiRenderAssets } from "./assets.js";
11
+ import type { UiRenderValidator } from "./validation.js";
12
+ import { type IntentEvent, type UiRenderCallContext } from "./types.js";
13
+ import type { McpToolDescriptor } from "../tools.js";
14
+ import type { McpTransportResult } from "../server.js";
15
+ /** Every tool name the module owns (h2a spec §4.1). */
16
+ export declare const UI_RENDER_TOOL_NAMES: readonly ["list_components", "get_schema", "render", "render_BarChart", "render_BpmnCanvas", "render_DecisionDossier", "submit_intent"];
17
+ /** The consumer invoked by submit_intent (the future decision-inject seam). */
18
+ export type UiRenderIntentConsumer = (intent: IntentEvent, context?: UiRenderCallContext) => void;
19
+ /** Options of `createUiRenderTools`. */
20
+ export interface CreateUiRenderToolsOptions {
21
+ readonly assets: UiRenderAssets;
22
+ readonly validator: UiRenderValidator;
23
+ /** Optional server-configured intent consumer (DS §8.2 & §11.2 criterion 4). */
24
+ readonly onIntent?: UiRenderIntentConsumer;
25
+ /**
26
+ * The envelope-echo threshold: above it `structuredContent` carries
27
+ * `envelopeSha256` instead of the envelope. Defaults to the h2a frame
28
+ * ceiling minus 16 KiB (never triggering `boundCallToolResult`). The
29
+ * L3.5 offline measurement (fixtures/ui-render-ac-l3) kept this
30
+ * default: every pilot resource fits the 1 MiB frame with the echo;
31
+ * fixing the value from real-host caps (U-1) stays open.
32
+ */
33
+ readonly inlineLimitBytes?: number;
34
+ }
35
+ /** The tools handlers for one module. */
36
+ export interface UiRenderTools {
37
+ listTools(): McpToolDescriptor[];
38
+ /** Returns undefined when `name` is not a ui-render tool. */
39
+ callTool(name: string, args: Record<string, unknown> | undefined, context?: UiRenderCallContext): McpTransportResult | undefined;
40
+ }
41
+ export declare function createUiRenderTools(options: CreateUiRenderToolsOptions): UiRenderTools;
42
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../src/runtime/mcp/ui-render/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AAExE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,mBAAmB,EAEzB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,uDAAuD;AACvD,eAAO,MAAM,oBAAoB,yIAQvB,CAAC;AAmCX,+EAA+E;AAC/E,MAAM,MAAM,sBAAsB,GAAG,CACnC,MAAM,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE,mBAAmB,KAC1B,IAAI,CAAC;AAEV,wCAAwC;AACxC,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,gFAAg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