@superblocksteam/gateway 2.0.157-next.5 → 2.0.157
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/README.md +3 -30
- package/dist/capabilities/lifecycle.d.ts +1 -12
- package/dist/capabilities/lifecycle.js +51 -99
- package/dist/capabilities/lifecycle.js.map +1 -1
- package/dist/capabilities/types.d.ts +0 -5
- package/dist/capabilities/types.js.map +1 -1
- package/dist/deps.d.ts +0 -2
- package/dist/integrations/map.d.ts +0 -1
- package/dist/integrations/map.js +1 -1
- package/dist/integrations/map.js.map +1 -1
- package/dist/sabs/editor-client-methods.js +5 -4
- package/dist/sabs/editor-client-methods.js.map +1 -1
- package/dist/sabs/session-peer.d.ts +0 -4
- package/dist/sabs/websocket-session-peer.d.ts +1 -2
- package/dist/sabs/websocket-session-peer.js +11 -21
- package/dist/sabs/websocket-session-peer.js.map +1 -1
- package/dist/server/client.d.ts +4 -10
- package/dist/server/client.js +4 -13
- package/dist/server/client.js.map +1 -1
- package/dist/start.d.ts +0 -10
- package/dist/start.js +2 -5
- package/dist/start.js.map +1 -1
- package/dist/transports/mcp/admin-tools.d.ts +1 -3
- package/dist/transports/mcp/admin-tools.js +1 -12
- package/dist/transports/mcp/admin-tools.js.map +1 -1
- package/dist/transports/mcp/app-status-html.d.ts +2 -2
- package/dist/transports/mcp/app-status-html.js +8 -139
- package/dist/transports/mcp/app-status-html.js.map +1 -1
- package/dist/transports/mcp/mount.js +24 -89
- package/dist/transports/mcp/mount.js.map +1 -1
- package/package.json +4 -5
- package/dist/capabilities/integration-metadata.d.ts +0 -28
- package/dist/capabilities/integration-metadata.js +0 -174
- package/dist/capabilities/integration-metadata.js.map +0 -1
- package/dist/telemetry/mcp-client.d.ts +0 -22
- package/dist/telemetry/mcp-client.js +0 -129
- package/dist/telemetry/mcp-client.js.map +0 -1
- package/dist/telemetry/runtime.d.ts +0 -9
- package/dist/telemetry/runtime.js +0 -121
- package/dist/telemetry/runtime.js.map +0 -1
|
@@ -107,17 +107,6 @@ export function superblocksProductCopy(text) {
|
|
|
107
107
|
.replaceAll(/\bClark AI Apps\b/g, "Superblocks AI Apps")
|
|
108
108
|
.replaceAll(/\bClark\b/g, "Superblocks");
|
|
109
109
|
}
|
|
110
|
-
/** Completes MCP hints without overriding shared Admin definitions. */
|
|
111
|
-
export function completeToolAnnotations(annotations) {
|
|
112
|
-
const readOnlyHint = annotations?.readOnlyHint ?? false;
|
|
113
|
-
return {
|
|
114
|
-
...annotations,
|
|
115
|
-
destructiveHint: annotations?.destructiveHint ?? (readOnlyHint ? false : true),
|
|
116
|
-
idempotentHint: annotations?.idempotentHint ?? readOnlyHint,
|
|
117
|
-
openWorldHint: annotations?.openWorldHint ?? true,
|
|
118
|
-
readOnlyHint,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
110
|
/**
|
|
122
111
|
* Registers customer-profile Admin MCP tools on the same McpServer as Builder
|
|
123
112
|
* tools. Each call runs under `runWithAuthContext` with the Gateway's
|
|
@@ -133,7 +122,7 @@ export function registerAdminTools(server, options) {
|
|
|
133
122
|
}
|
|
134
123
|
const definition = toolDefinitions.find((d) => d.name === tool.name);
|
|
135
124
|
server.registerTool(tool.name, {
|
|
136
|
-
annotations:
|
|
125
|
+
annotations: tool.annotations,
|
|
137
126
|
description: superblocksProductCopy(tool.description ?? ""),
|
|
138
127
|
inputSchema: gatewayAdminInputShape(tool.inputSchema),
|
|
139
128
|
title: tool.title ?? definition?.title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-tools.js","sourceRoot":"","sources":["../../../src/transports/mcp/admin-tools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,eAAe,GAEhB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAA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AAkB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,CAC/D,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAC/C,CAAC;gBACF,YAAY,CAAC,qBAAqB,EAAE;oBAClC,aAAa,EAAE,SAAS;oBACxB,WAAW,EAAE,IAAI,CAAC,IAAI;iBACvB,CAAC,CAAC;gBACH,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,YAAY,CAAC,qBAAqB,EAAE;oBAClC,YAAY,EACV,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK;oBAChE,aAAa,EAAE,OAAO;oBACtB,WAAW,EAAE,IAAI,CAAC,IAAI;iBACvB,CAAC,CAAC;gBACH,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
* card (hosts cache UI resources; keep this file small and inline). Bump the
|
|
12
12
|
* resource URI when the HTML changes so Claude Desktop refreshes its cache.
|
|
13
13
|
*/
|
|
14
|
-
export declare const APP_STATUS_RESOURCE_URI = "ui://gateway/app-status-
|
|
15
|
-
export declare const APP_STATUS_HTML = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <title>Superblocks app</title>\n <style>\n :root {\n color-scheme: light dark;\n }\n body {\n margin: 0;\n font-family: var(--font-sans, system-ui, -apple-system, sans-serif);\n font-size: var(--font-text-sm-size, 13px);\n line-height: var(--font-text-sm-line-height, 1.45);\n color: var(--color-text-primary, #0f172a);\n background: transparent;\n }\n .card {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n border: var(--border-width-regular, 1px) solid\n var(--color-border-primary, #e2e8f0);\n border-radius: var(--border-radius-lg, 12px);\n background: var(--color-background-primary, #ffffff);\n }\n .head {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n h1 {\n flex: 1;\n margin: 0;\n font-size: var(--font-text-md-size, 14px);\n font-weight: var(--font-weight-semibold, 600);\n }\n .status {\n padding: 2px 8px;\n border-radius: var(--border-radius-full, 999px);\n background: var(--color-background-secondary, #f1f5f9);\n color: var(--color-text-secondary, #64748b);\n font-size: var(--font-text-xs-size, 12px);\n text-transform: lowercase;\n }\n .meta {\n color: var(--color-text-tertiary, #94a3b8);\n font-size: var(--font-text-xs-size, 12px);\n }\n .note {\n display: none;\n color: var(--color-text-warning, #b45309);\n font-size: var(--font-text-xs-size, 12px);\n }\n .note.shown {\n display: block;\n }\n .shot {\n display: none;\n width: 100%;\n border: var(--border-width-regular, 1px) solid\n var(--color-border-primary, #e2e8f0);\n border-radius: var(--border-radius-md, 8px);\n }\n .shot.shown {\n display: block;\n }\n .actions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n }\n button {\n appearance: none;\n border: var(--border-width-regular, 1px) solid\n var(--color-border-primary, #e2e8f0);\n border-radius: var(--border-radius-md, 8px);\n padding: 7px 12px;\n background: var(--color-background-secondary, #f8fafc);\n color: var(--color-text-primary, #0f172a);\n font: inherit;\n font-weight: var(--font-weight-medium, 500);\n cursor: pointer;\n }\n button:hover:not(:disabled) {\n background: var(--color-background-tertiary, #f1f5f9);\n }\n button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n }\n </style>\n</head>\n<body>\n <div class=\"card\">\n <div class=\"head\">\n <h1>Superblocks app</h1>\n <span id=\"status\" class=\"status\">loading</span>\n </div>\n <div id=\"appId\" class=\"meta\"></div>\n <img id=\"shot\" class=\"shot\" alt=\"Preview of the running app\" />\n <div id=\"note\" class=\"note\"></div>\n <div class=\"actions\">\n <button id=\"openEditor\" type=\"button\" disabled>Open editor</button>\n <button id=\"openPreview\" type=\"button\" disabled>Open preview</button>\n <button id=\"publishApp\" type=\"button\" disabled>Publish app</button>\n </div>\n </div>\n <script>\n (() => {\n const PROTOCOL_VERSION = \"2026-01-26\";\n // Statuses get_app reports when the app is still the empty starter\n // template. \"building\" is deliberately absent: the card only hears a\n // build finished if a new result arrives, so a stale badge would strand\n // the button.\n const UNBUILT_STATUSES = [\n \"cancelled\",\n \"live_edit_terminated\",\n \"needs_decision\",\n \"no_changes\",\n \"timeout\",\n ];\n const BLOCKED_ACTIONS = [\n \"answer_question\",\n \"approve_plan\",\n \"retry_build\",\n \"retry_import\",\n ];\n let nextId = 1;\n const pending = new Map();\n let applicationId = \"\";\n let appName = \"\";\n let commitId = \"\";\n let pendingAction = \"\";\n let editUrl = \"\";\n let previewUrl = \"\";\n let publishUrl = \"\";\n let canOpenLinks = false;\n let canCallTools = false;\n let publishing = false;\n let lastHeight = 0;\n let refreshInFlight = false;\n let refreshTimer = 0;\n let refreshGeneration = 0;\n let refreshAttempts = 0;\n let pollAfterMs = 2000;\n const MIN_POLL_MS = 2000;\n const MAX_REFRESH_ATTEMPTS = 40;\n\n function post(message) {\n window.parent.postMessage(message, \"*\");\n }\n\n function notify(method, params) {\n post({ jsonrpc: \"2.0\", method, params });\n }\n\n function request(method, params) {\n const id = nextId++;\n return new Promise((resolve, reject) => {\n pending.set(id, { resolve, reject });\n post({ jsonrpc: \"2.0\", id, method, params });\n });\n }\n\n function element(id) {\n return document.getElementById(id);\n }\n\n function show(id, on) {\n const node = element(id);\n if (node && node.classList) {\n node.classList.toggle(\"shown\", on);\n }\n }\n\n // Hosts size the card from this notification alone; without it the card\n // is laid out at zero height and never appears.\n function reportSize() {\n const height = Math.ceil(document.documentElement.scrollHeight || 0);\n if (height <= 0 || height === lastHeight) {\n return;\n }\n lastHeight = height;\n notify(\"ui/notifications/size-changed\", {\n height,\n width: Math.ceil(window.innerWidth || 0),\n });\n }\n\n function note(text) {\n element(\"note\").textContent = text;\n show(\"note\", Boolean(text));\n reportSize();\n }\n\n function isPlainHttp(url) {\n return url.slice(0, 5).toLowerCase() === \"http:\";\n }\n\n /** A UUID says nothing; the name the user asked Superblocks for does. */\n function renderIdentity() {\n element(\"appId\").textContent = appName || applicationId;\n }\n\n /**\n * Draws the screenshot the tool captured.\n *\n * Hosts that render an MCP App render it *instead of* the tool's content\n * blocks, so the image block get_app returns never reaches the user on\n * its own \u2014 the card has to take it out of the result and show it.\n */\n function showScreenshot(dataBase64, mimeType) {\n if (typeof dataBase64 !== \"string\" || !dataBase64) {\n return;\n }\n element(\"shot\").src =\n \"data:\" + (mimeType || \"image/jpeg\") + \";base64,\" + dataBase64;\n show(\"shot\", true);\n reportSize();\n }\n\n /** Applies every part of an MCP content array the card understands. */\n function applyContent(content) {\n for (const part of content || []) {\n if (!part) {\n continue;\n }\n if (part.type === \"text\" && typeof part.text === \"string\") {\n applyPayload(part.text);\n }\n if (part.type === \"image\") {\n showScreenshot(part.data, part.mimeType);\n }\n }\n }\n\n /**\n * True when publishing would deploy the empty starter template.\n * pendingAction is the server's own \"nothing to preview\" signal;\n * wait_for_build is the building exception. Status is only a fallback\n * when the payload omitted pendingAction. loading/waiting with no\n * preview fail closed so Publish is not clickable before get_app\n * returns.\n */\n function nothingToPublish() {\n if (previewUrl || publishUrl) {\n return false;\n }\n if (pendingAction === \"wait_for_build\") {\n return false;\n }\n if (BLOCKED_ACTIONS.indexOf(pendingAction) !== -1) {\n return true;\n }\n const badge = element(\"status\").textContent;\n if (!badge || badge === \"loading\" || badge === \"waiting\") {\n return true;\n }\n return UNBUILT_STATUSES.indexOf(badge) !== -1;\n }\n\n /**\n * Keep URLs in memory for openLink \u2014 never print them (preview JWTs are\n * huge and ugly in the card).\n */\n function renderActions() {\n element(\"openEditor\").disabled = !editUrl || !canOpenLinks;\n element(\"openPreview\").disabled = !previewUrl || !canOpenLinks;\n // Once the app is live, publishing again is not what anyone wants from\n // this button \u2014 going to the live app is.\n element(\"publishApp\").textContent = publishUrl\n ? \"Open published app\"\n : \"Publish app\";\n element(\"publishApp\").disabled = publishUrl\n ? !canOpenLinks\n : !applicationId ||\n !canCallTools ||\n publishing ||\n nothingToPublish();\n // Only warn about what is actually broken. Hosts that do open links\n // handle local http fine; if one refuses, refused() says so then.\n if (!canOpenLinks && (editUrl || previewUrl) && !publishUrl) {\n note(\"This host cannot open links for me \u2014 ask the model for an https preview URL.\");\n }\n reportSize();\n }\n\n /** Only ever ask the host to open a real web address. */\n function webUrl(candidate) {\n try {\n const parsed = new URL(candidate);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\"\n ? candidate\n : \"\";\n } catch {\n return \"\";\n }\n }\n\n /**\n * Merges whatever the host sent. Hosts replay tool input as well as tool\n * results, and the input carries no status or URLs \u2014 overwriting from a\n * partial payload is what showed the card as \"unknown\".\n *\n * Hosts also disagree on the shape: some pass the capability JSON, some\n * pass the MCP content/text envelope (Claude Desktop on initialize), and\n * some nest that under structuredContent.\n */\n function applyPayload(raw) {\n let data = raw;\n if (typeof raw === \"string\") {\n try {\n data = JSON.parse(raw);\n } catch {\n return;\n }\n }\n if (!data || typeof data !== \"object\") {\n return;\n }\n // MCP tool-result / initialize toolResult envelope.\n if (Array.isArray(data.content)) {\n applyContent(data.content);\n if (data.structuredContent) {\n applyPayload(data.structuredContent);\n }\n return;\n }\n if (data.result && typeof data.result === \"object\") {\n applyPayload(data.result);\n return;\n }\n const value = data.kind === \"ok\" ? data.value : data;\n if (!value || typeof value !== \"object\") {\n return;\n }\n if (typeof value.status === \"string\") {\n element(\"status\").textContent = value.status;\n }\n if (typeof value.applicationId === \"string\") {\n applicationId = value.applicationId;\n renderIdentity();\n }\n if (typeof value.name === \"string\" && value.name) {\n appName = value.name;\n renderIdentity();\n }\n if (typeof value.commitId === \"string\") {\n commitId = value.commitId;\n }\n if (typeof value.pendingAction === \"string\") {\n pendingAction = value.pendingAction;\n } else if (typeof value.status === \"string\") {\n pendingAction = \"\";\n }\n if (typeof value.screenshotBase64 === \"string\") {\n showScreenshot(value.screenshotBase64, \"image/jpeg\");\n }\n if (typeof value.editUrl === \"string\") {\n editUrl = webUrl(value.editUrl);\n }\n if (typeof value.previewUrl === \"string\") {\n previewUrl = webUrl(value.previewUrl);\n }\n if (typeof value.publishUrl === \"string\") {\n publishUrl = webUrl(value.publishUrl);\n }\n if (typeof value.nextPollAfterMs === \"number\") {\n pollAfterMs = value.nextPollAfterMs;\n }\n // Hosts that deliver URLs without a status left the badge on the HTML\n // default (\"loading\") even after the app was built.\n const badge = element(\"status\").textContent;\n if (\n !value.status &&\n editUrl &&\n (badge === \"\" || badge === \"loading\" || badge === \"waiting\")\n ) {\n element(\"status\").textContent = previewUrl ? \"ready\" : \"building\";\n }\n renderActions();\n }\n\n /**\n * Re-ask get_app when the host gave us no result, or while status is\n * still building. wait:false and ensurePreview:false so polls only\n * ask for status. Honor nextPollAfterMs; 0 means stop.\n */\n function clearRefreshTimer() {\n if (refreshTimer) {\n clearTimeout(refreshTimer);\n refreshTimer = 0;\n }\n }\n\n function retryDelay() {\n return Math.max(MIN_POLL_MS, pollAfterMs || MIN_POLL_MS);\n }\n\n function scheduleRefresh(delayMs) {\n clearRefreshTimer();\n if (refreshAttempts >= MAX_REFRESH_ATTEMPTS) {\n note(\"Stopped checking whether the app is still building.\");\n return;\n }\n refreshTimer = setTimeout(() => {\n refreshTimer = 0;\n refreshFromServer();\n }, delayMs);\n }\n\n function refreshFromServer() {\n clearRefreshTimer();\n if (!canCallTools || !applicationId || refreshInFlight) {\n return;\n }\n if (typeof document.hidden === \"boolean\" && document.hidden) {\n scheduleRefresh(retryDelay());\n return;\n }\n const badge = element(\"status\").textContent;\n if (editUrl && badge !== \"building\") {\n return;\n }\n if (refreshAttempts >= MAX_REFRESH_ATTEMPTS) {\n note(\"Stopped checking whether the app is still building.\");\n return;\n }\n refreshAttempts += 1;\n const generation = refreshGeneration;\n refreshInFlight = true;\n request(\"tools/call\", {\n name: \"get_app\",\n arguments: {\n applicationId,\n ensurePreview: false,\n wait: false,\n },\n })\n .then((result) => {\n refreshInFlight = false;\n if (generation !== refreshGeneration) {\n if (element(\"status\").textContent === \"building\") {\n scheduleRefresh(retryDelay());\n }\n return;\n }\n if (!result || result.isError) {\n scheduleRefresh(retryDelay());\n return;\n }\n applyPayload(result);\n if (result.structuredContent) {\n applyPayload(result.structuredContent);\n }\n if (element(\"status\").textContent !== \"building\") {\n return;\n }\n if (pollAfterMs === 0) {\n return;\n }\n scheduleRefresh(retryDelay());\n })\n .catch(() => {\n refreshInFlight = false;\n if (generation !== refreshGeneration) {\n return;\n }\n scheduleRefresh(retryDelay());\n });\n }\n\n function applyHostContext(context) {\n if (!context || typeof context !== \"object\") {\n return;\n }\n const variables = context.styles && context.styles.variables;\n const style = document.documentElement.style;\n if (variables && style && typeof style.setProperty === \"function\") {\n for (const name of Object.keys(variables)) {\n const value = variables[name];\n if (typeof value === \"string\") {\n style.setProperty(name, value);\n }\n }\n }\n reportSize();\n }\n\n function refused(url) {\n note(\n isPlainHttp(url)\n ? \"This host only opens https links, and this app is served over http \u2014 ask for an https preview URL.\"\n : \"The host could not open the link \u2014 try again or ask the model for another URL.\",\n );\n }\n\n function openLink(url) {\n if (!url || !canOpenLinks) {\n return;\n }\n request(\"ui/open-link\", { url })\n .then((result) => {\n if (result && result.isError) {\n refused(url);\n return;\n }\n note(\"\");\n })\n .catch(() => refused(url));\n }\n\n /**\n * Asks the host to proxy publish_app back to this MCP server. The prompt\n * is the commit message createCommit needs; the card supplies a fixed one\n * so the user does not have to type through the model.\n */\n function publish() {\n if (!applicationId || !canCallTools || publishing) {\n return;\n }\n if (nothingToPublish()) {\n note(\"Nothing to publish yet: this turn did not build the app.\");\n return;\n }\n publishing = true;\n renderActions();\n note(\"Publishing\u2026\");\n const args = {\n applicationId,\n idempotencyKey:\n \"mcp-app-publish:\" + applicationId + \":\" + Date.now(),\n prompt: \"Published from Gateway status card\",\n };\n if (commitId) {\n args.commitId = commitId;\n }\n request(\"tools/call\", { name: \"publish_app\", arguments: args })\n .then((result) => {\n publishing = false;\n if (!result || result.isError) {\n const text =\n result &&\n Array.isArray(result.content) &&\n result.content[0] &&\n result.content[0].text\n ? String(result.content[0].text)\n : \"Publish failed.\";\n note(text.slice(0, 280));\n renderActions();\n return;\n }\n applyContent(result.content || []);\n if (result.structuredContent) {\n applyPayload(result.structuredContent);\n }\n note(\n publishUrl\n ? \"Published \u2014 open the live app with Open published app.\"\n : \"Published \u2014 the app is live.\",\n );\n renderActions();\n })\n .catch((error) => {\n publishing = false;\n note(\n (error && error.message) ||\n \"The host could not call publish_app.\",\n );\n renderActions();\n });\n }\n\n function handleHostMessage(event) {\n // App documents are opaque-origin, so the host window is the only\n // identity available to authenticate a message against.\n if (event.source !== window.parent) {\n return;\n }\n const data = event.data;\n if (!data || typeof data !== \"object\") {\n return;\n }\n if (data.method === \"ping\") {\n post({ jsonrpc: \"2.0\", id: data.id, result: {} });\n return;\n }\n if (data.id != null && pending.has(data.id)) {\n const waiter = pending.get(data.id);\n pending.delete(data.id);\n if (data.error) {\n waiter.reject(data.error);\n } else {\n waiter.resolve(data.result);\n }\n return;\n }\n const method = data.method;\n const params = data.params || {};\n if (\n method === \"ui/notifications/tool-result\" ||\n method === \"ui/tool-result\" ||\n method === \"tools/call\"\n ) {\n applyContent(params.content || params.result?.content || []);\n if (params.structuredContent) {\n applyPayload(params.structuredContent);\n }\n refreshGeneration += 1;\n if (element(\"status\").textContent === \"building\") {\n refreshFromServer();\n }\n }\n if (method === \"ui/notifications/tool-input\" && params.arguments) {\n applyPayload(params.arguments);\n refreshFromServer();\n }\n if (method === \"ui/notifications/host-context-changed\") {\n applyHostContext(params);\n }\n }\n\n window.addEventListener(\"message\", handleHostMessage);\n\n element(\"openEditor\").addEventListener(\"click\", () => openLink(editUrl));\n element(\"openPreview\").addEventListener(\"click\", () =>\n openLink(previewUrl),\n );\n element(\"publishApp\").addEventListener(\"click\", () => {\n if (publishUrl) {\n openLink(publishUrl);\n return;\n }\n publish();\n });\n\n if (typeof ResizeObserver === \"function\") {\n new ResizeObserver(reportSize).observe(document.documentElement);\n }\n\n void request(\"ui/initialize\", {\n appCapabilities: {\n availableDisplayModes: [\"inline\"],\n },\n appInfo: { name: \"gateway-app-status\", version: \"0.0.6\" },\n protocolVersion: PROTOCOL_VERSION,\n })\n .then((result) => {\n // Hosts hold back tool results until the app confirms it is ready.\n notify(\"ui/notifications/initialized\", {});\n // Buttons that cannot work are worse than no buttons: hosts without\n // openLinks silently drop ui/open-link.\n canOpenLinks = Boolean(\n result && result.hostCapabilities && result.hostCapabilities.openLinks,\n );\n canCallTools = Boolean(\n result &&\n result.hostCapabilities &&\n result.hostCapabilities.serverTools,\n );\n applyHostContext(result && result.hostContext);\n renderActions();\n if (result && result.toolResult) {\n applyPayload(result.toolResult);\n }\n refreshFromServer();\n })\n .catch(() => {\n // Hosts that push tool results via notification still work.\n })\n .finally(reportSize);\n })();\n </script>\n</body>\n</html>\n";
|
|
14
|
+
export declare const APP_STATUS_RESOURCE_URI = "ui://gateway/app-status-v6.html";
|
|
15
|
+
export declare const APP_STATUS_HTML = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <title>Superblocks app</title>\n <style>\n :root {\n color-scheme: light dark;\n }\n body {\n margin: 0;\n font-family: var(--font-sans, system-ui, -apple-system, sans-serif);\n font-size: var(--font-text-sm-size, 13px);\n line-height: var(--font-text-sm-line-height, 1.45);\n color: var(--color-text-primary, #0f172a);\n background: transparent;\n }\n .card {\n display: flex;\n flex-direction: column;\n gap: 10px;\n padding: 14px;\n border: var(--border-width-regular, 1px) solid\n var(--color-border-primary, #e2e8f0);\n border-radius: var(--border-radius-lg, 12px);\n background: var(--color-background-primary, #ffffff);\n }\n .head {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n h1 {\n flex: 1;\n margin: 0;\n font-size: var(--font-text-md-size, 14px);\n font-weight: var(--font-weight-semibold, 600);\n }\n .status {\n padding: 2px 8px;\n border-radius: var(--border-radius-full, 999px);\n background: var(--color-background-secondary, #f1f5f9);\n color: var(--color-text-secondary, #64748b);\n font-size: var(--font-text-xs-size, 12px);\n text-transform: lowercase;\n }\n .meta {\n color: var(--color-text-tertiary, #94a3b8);\n font-size: var(--font-text-xs-size, 12px);\n }\n .note {\n display: none;\n color: var(--color-text-warning, #b45309);\n font-size: var(--font-text-xs-size, 12px);\n }\n .note.shown {\n display: block;\n }\n .shot {\n display: none;\n width: 100%;\n border: var(--border-width-regular, 1px) solid\n var(--color-border-primary, #e2e8f0);\n border-radius: var(--border-radius-md, 8px);\n }\n .shot.shown {\n display: block;\n }\n .actions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n }\n button {\n appearance: none;\n border: var(--border-width-regular, 1px) solid\n var(--color-border-primary, #e2e8f0);\n border-radius: var(--border-radius-md, 8px);\n padding: 7px 12px;\n background: var(--color-background-secondary, #f8fafc);\n color: var(--color-text-primary, #0f172a);\n font: inherit;\n font-weight: var(--font-weight-medium, 500);\n cursor: pointer;\n }\n button:hover:not(:disabled) {\n background: var(--color-background-tertiary, #f1f5f9);\n }\n button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n }\n </style>\n</head>\n<body>\n <div class=\"card\">\n <div class=\"head\">\n <h1>Superblocks app</h1>\n <span id=\"status\" class=\"status\">loading</span>\n </div>\n <div id=\"appId\" class=\"meta\"></div>\n <img id=\"shot\" class=\"shot\" alt=\"Preview of the running app\" />\n <div id=\"note\" class=\"note\"></div>\n <div class=\"actions\">\n <button id=\"openEditor\" type=\"button\" disabled>Open editor</button>\n <button id=\"openPreview\" type=\"button\" disabled>Open preview</button>\n <button id=\"publishApp\" type=\"button\" disabled>Publish app</button>\n </div>\n </div>\n <script>\n (() => {\n const PROTOCOL_VERSION = \"2026-01-26\";\n let nextId = 1;\n const pending = new Map();\n let applicationId = \"\";\n let appName = \"\";\n let commitId = \"\";\n let editUrl = \"\";\n let previewUrl = \"\";\n let publishUrl = \"\";\n let canOpenLinks = false;\n let canCallTools = false;\n let publishing = false;\n let lastHeight = 0;\n\n function post(message) {\n window.parent.postMessage(message, \"*\");\n }\n\n function notify(method, params) {\n post({ jsonrpc: \"2.0\", method, params });\n }\n\n function request(method, params) {\n const id = nextId++;\n return new Promise((resolve, reject) => {\n pending.set(id, { resolve, reject });\n post({ jsonrpc: \"2.0\", id, method, params });\n });\n }\n\n function element(id) {\n return document.getElementById(id);\n }\n\n function show(id, on) {\n const node = element(id);\n if (node && node.classList) {\n node.classList.toggle(\"shown\", on);\n }\n }\n\n // Hosts size the card from this notification alone; without it the card\n // is laid out at zero height and never appears.\n function reportSize() {\n const height = Math.ceil(document.documentElement.scrollHeight || 0);\n if (height <= 0 || height === lastHeight) {\n return;\n }\n lastHeight = height;\n notify(\"ui/notifications/size-changed\", {\n height,\n width: Math.ceil(window.innerWidth || 0),\n });\n }\n\n function note(text) {\n element(\"note\").textContent = text;\n show(\"note\", Boolean(text));\n reportSize();\n }\n\n function isPlainHttp(url) {\n return url.slice(0, 5).toLowerCase() === \"http:\";\n }\n\n /** A UUID says nothing; the name the user asked Superblocks for does. */\n function renderIdentity() {\n element(\"appId\").textContent = appName || applicationId;\n }\n\n /**\n * Draws the screenshot the tool captured.\n *\n * Hosts that render an MCP App render it *instead of* the tool's content\n * blocks, so the image block get_app returns never reaches the user on\n * its own \u2014 the card has to take it out of the result and show it.\n */\n function showScreenshot(dataBase64, mimeType) {\n if (typeof dataBase64 !== \"string\" || !dataBase64) {\n return;\n }\n element(\"shot\").src =\n \"data:\" + (mimeType || \"image/jpeg\") + \";base64,\" + dataBase64;\n show(\"shot\", true);\n reportSize();\n }\n\n /** Applies every part of an MCP content array the card understands. */\n function applyContent(content) {\n for (const part of content || []) {\n if (!part) {\n continue;\n }\n if (part.type === \"text\" && typeof part.text === \"string\") {\n applyPayload(part.text);\n }\n if (part.type === \"image\") {\n showScreenshot(part.data, part.mimeType);\n }\n }\n }\n\n /**\n * Keep URLs in memory for openLink \u2014 never print them (preview JWTs are\n * huge and ugly in the card).\n */\n function renderActions() {\n element(\"openEditor\").disabled = !editUrl || !canOpenLinks;\n element(\"openPreview\").disabled = !previewUrl || !canOpenLinks;\n // Once the app is live, publishing again is not what anyone wants from\n // this button \u2014 going to the live app is.\n element(\"publishApp\").textContent = publishUrl\n ? \"Open published app\"\n : \"Publish app\";\n element(\"publishApp\").disabled = publishUrl\n ? !canOpenLinks\n : !applicationId || !canCallTools || publishing;\n // Only warn about what is actually broken. Hosts that do open links\n // handle local http fine; if one refuses, refused() says so then.\n if (!canOpenLinks && (editUrl || previewUrl) && !publishUrl) {\n note(\"This host cannot open links for me \u2014 ask the model for an https preview URL.\");\n }\n reportSize();\n }\n\n /** Only ever ask the host to open a real web address. */\n function webUrl(candidate) {\n try {\n const parsed = new URL(candidate);\n return parsed.protocol === \"http:\" || parsed.protocol === \"https:\"\n ? candidate\n : \"\";\n } catch {\n return \"\";\n }\n }\n\n /**\n * Merges whatever the host sent. Hosts replay tool input as well as tool\n * results, and the input carries no status or URLs \u2014 overwriting from a\n * partial payload is what showed the card as \"unknown\".\n *\n * Hosts also disagree on the shape: some pass the capability JSON, some\n * pass the MCP content/text envelope (Claude Desktop on initialize), and\n * some nest that under structuredContent.\n */\n function applyPayload(raw) {\n let data = raw;\n if (typeof raw === \"string\") {\n try {\n data = JSON.parse(raw);\n } catch {\n return;\n }\n }\n if (!data || typeof data !== \"object\") {\n return;\n }\n // MCP tool-result / initialize toolResult envelope.\n if (Array.isArray(data.content)) {\n applyContent(data.content);\n if (data.structuredContent) {\n applyPayload(data.structuredContent);\n }\n return;\n }\n if (data.result && typeof data.result === \"object\") {\n applyPayload(data.result);\n return;\n }\n const value = data.kind === \"ok\" ? data.value : data;\n if (!value || typeof value !== \"object\") {\n return;\n }\n if (typeof value.status === \"string\") {\n element(\"status\").textContent = value.status;\n }\n if (typeof value.applicationId === \"string\") {\n applicationId = value.applicationId;\n renderIdentity();\n }\n if (typeof value.name === \"string\" && value.name) {\n appName = value.name;\n renderIdentity();\n }\n if (typeof value.commitId === \"string\") {\n commitId = value.commitId;\n }\n if (typeof value.screenshotBase64 === \"string\") {\n showScreenshot(value.screenshotBase64, \"image/jpeg\");\n }\n if (typeof value.editUrl === \"string\") {\n editUrl = webUrl(value.editUrl);\n }\n if (typeof value.previewUrl === \"string\") {\n previewUrl = webUrl(value.previewUrl);\n }\n if (typeof value.publishUrl === \"string\") {\n publishUrl = webUrl(value.publishUrl);\n }\n // Hosts that deliver URLs without a status left the badge on the HTML\n // default (\"loading\") even after the app was built.\n const badge = element(\"status\").textContent;\n if (\n !value.status &&\n editUrl &&\n (badge === \"\" || badge === \"loading\" || badge === \"waiting\")\n ) {\n element(\"status\").textContent = previewUrl ? \"ready\" : \"building\";\n }\n renderActions();\n }\n\n /**\n * When the host opened the card with tool input (applicationId) but never\n * pushed a tool result, refresh ourselves so the badge is not stuck on\n * \"loading\" after the build finished.\n */\n function refreshFromServer() {\n if (!canCallTools || !applicationId || editUrl) {\n return;\n }\n request(\"tools/call\", {\n name: \"get_app\",\n arguments: { applicationId },\n })\n .then((result) => {\n if (!result || result.isError) {\n return;\n }\n applyPayload(result);\n if (result.structuredContent) {\n applyPayload(result.structuredContent);\n }\n })\n .catch(() => {\n // Host declined; stay on whatever we have.\n });\n }\n\n function applyHostContext(context) {\n if (!context || typeof context !== \"object\") {\n return;\n }\n const variables = context.styles && context.styles.variables;\n const style = document.documentElement.style;\n if (variables && style && typeof style.setProperty === \"function\") {\n for (const name of Object.keys(variables)) {\n const value = variables[name];\n if (typeof value === \"string\") {\n style.setProperty(name, value);\n }\n }\n }\n reportSize();\n }\n\n function refused(url) {\n note(\n isPlainHttp(url)\n ? \"This host only opens https links, and this app is served over http \u2014 ask for an https preview URL.\"\n : \"The host could not open the link \u2014 try again or ask the model for another URL.\",\n );\n }\n\n function openLink(url) {\n if (!url || !canOpenLinks) {\n return;\n }\n request(\"ui/open-link\", { url })\n .then((result) => {\n if (result && result.isError) {\n refused(url);\n return;\n }\n note(\"\");\n })\n .catch(() => refused(url));\n }\n\n /**\n * Asks the host to proxy publish_app back to this MCP server. The prompt\n * is the commit message createCommit needs; the card supplies a fixed one\n * so the user does not have to type through the model.\n */\n function publish() {\n if (!applicationId || !canCallTools || publishing) {\n return;\n }\n publishing = true;\n renderActions();\n note(\"Publishing\u2026\");\n const args = {\n applicationId,\n idempotencyKey:\n \"mcp-app-publish:\" + applicationId + \":\" + Date.now(),\n prompt: \"Published from Gateway status card\",\n };\n if (commitId) {\n args.commitId = commitId;\n }\n request(\"tools/call\", { name: \"publish_app\", arguments: args })\n .then((result) => {\n publishing = false;\n if (!result || result.isError) {\n const text =\n result &&\n Array.isArray(result.content) &&\n result.content[0] &&\n result.content[0].text\n ? String(result.content[0].text)\n : \"Publish failed.\";\n note(text.slice(0, 280));\n renderActions();\n return;\n }\n applyContent(result.content || []);\n if (result.structuredContent) {\n applyPayload(result.structuredContent);\n }\n note(\n publishUrl\n ? \"Published \u2014 open the live app with Open published app.\"\n : \"Published \u2014 the app is live.\",\n );\n renderActions();\n })\n .catch((error) => {\n publishing = false;\n note(\n (error && error.message) ||\n \"The host could not call publish_app.\",\n );\n renderActions();\n });\n }\n\n function handleHostMessage(event) {\n // App documents are opaque-origin, so the host window is the only\n // identity available to authenticate a message against.\n if (event.source !== window.parent) {\n return;\n }\n const data = event.data;\n if (!data || typeof data !== \"object\") {\n return;\n }\n if (data.method === \"ping\") {\n post({ jsonrpc: \"2.0\", id: data.id, result: {} });\n return;\n }\n if (data.id != null && pending.has(data.id)) {\n const waiter = pending.get(data.id);\n pending.delete(data.id);\n if (data.error) {\n waiter.reject(data.error);\n } else {\n waiter.resolve(data.result);\n }\n return;\n }\n const method = data.method;\n const params = data.params || {};\n if (\n method === \"ui/notifications/tool-result\" ||\n method === \"ui/tool-result\" ||\n method === \"tools/call\"\n ) {\n applyContent(params.content || params.result?.content || []);\n if (params.structuredContent) {\n applyPayload(params.structuredContent);\n }\n }\n if (method === \"ui/notifications/tool-input\" && params.arguments) {\n applyPayload(params.arguments);\n refreshFromServer();\n }\n if (method === \"ui/notifications/host-context-changed\") {\n applyHostContext(params);\n }\n }\n\n window.addEventListener(\"message\", handleHostMessage);\n\n element(\"openEditor\").addEventListener(\"click\", () => openLink(editUrl));\n element(\"openPreview\").addEventListener(\"click\", () =>\n openLink(previewUrl),\n );\n element(\"publishApp\").addEventListener(\"click\", () => {\n if (publishUrl) {\n openLink(publishUrl);\n return;\n }\n publish();\n });\n\n if (typeof ResizeObserver === \"function\") {\n new ResizeObserver(reportSize).observe(document.documentElement);\n }\n\n void request(\"ui/initialize\", {\n appCapabilities: {\n availableDisplayModes: [\"inline\"],\n },\n appInfo: { name: \"gateway-app-status\", version: \"0.0.6\" },\n protocolVersion: PROTOCOL_VERSION,\n })\n .then((result) => {\n // Hosts hold back tool results until the app confirms it is ready.\n notify(\"ui/notifications/initialized\", {});\n // Buttons that cannot work are worse than no buttons: hosts without\n // openLinks silently drop ui/open-link.\n canOpenLinks = Boolean(\n result && result.hostCapabilities && result.hostCapabilities.openLinks,\n );\n canCallTools = Boolean(\n result &&\n result.hostCapabilities &&\n result.hostCapabilities.serverTools,\n );\n applyHostContext(result && result.hostContext);\n renderActions();\n if (result && result.toolResult) {\n applyPayload(result.toolResult);\n }\n refreshFromServer();\n })\n .catch(() => {\n // Hosts that push tool results via notification still work.\n })\n .finally(reportSize);\n })();\n </script>\n</body>\n</html>\n";
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* card (hosts cache UI resources; keep this file small and inline). Bump the
|
|
12
12
|
* resource URI when the HTML changes so Claude Desktop refreshes its cache.
|
|
13
13
|
*/
|
|
14
|
-
export const APP_STATUS_RESOURCE_URI = "ui://gateway/app-status-
|
|
14
|
+
export const APP_STATUS_RESOURCE_URI = "ui://gateway/app-status-v6.html";
|
|
15
15
|
export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
16
16
|
<html lang="en">
|
|
17
17
|
<head>
|
|
@@ -125,29 +125,11 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
125
125
|
<script>
|
|
126
126
|
(() => {
|
|
127
127
|
const PROTOCOL_VERSION = "2026-01-26";
|
|
128
|
-
// Statuses get_app reports when the app is still the empty starter
|
|
129
|
-
// template. "building" is deliberately absent: the card only hears a
|
|
130
|
-
// build finished if a new result arrives, so a stale badge would strand
|
|
131
|
-
// the button.
|
|
132
|
-
const UNBUILT_STATUSES = [
|
|
133
|
-
"cancelled",
|
|
134
|
-
"live_edit_terminated",
|
|
135
|
-
"needs_decision",
|
|
136
|
-
"no_changes",
|
|
137
|
-
"timeout",
|
|
138
|
-
];
|
|
139
|
-
const BLOCKED_ACTIONS = [
|
|
140
|
-
"answer_question",
|
|
141
|
-
"approve_plan",
|
|
142
|
-
"retry_build",
|
|
143
|
-
"retry_import",
|
|
144
|
-
];
|
|
145
128
|
let nextId = 1;
|
|
146
129
|
const pending = new Map();
|
|
147
130
|
let applicationId = "";
|
|
148
131
|
let appName = "";
|
|
149
132
|
let commitId = "";
|
|
150
|
-
let pendingAction = "";
|
|
151
133
|
let editUrl = "";
|
|
152
134
|
let previewUrl = "";
|
|
153
135
|
let publishUrl = "";
|
|
@@ -155,13 +137,6 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
155
137
|
let canCallTools = false;
|
|
156
138
|
let publishing = false;
|
|
157
139
|
let lastHeight = 0;
|
|
158
|
-
let refreshInFlight = false;
|
|
159
|
-
let refreshTimer = 0;
|
|
160
|
-
let refreshGeneration = 0;
|
|
161
|
-
let refreshAttempts = 0;
|
|
162
|
-
let pollAfterMs = 2000;
|
|
163
|
-
const MIN_POLL_MS = 2000;
|
|
164
|
-
const MAX_REFRESH_ATTEMPTS = 40;
|
|
165
140
|
|
|
166
141
|
function post(message) {
|
|
167
142
|
window.parent.postMessage(message, "*");
|
|
@@ -251,31 +226,6 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
251
226
|
}
|
|
252
227
|
}
|
|
253
228
|
|
|
254
|
-
/**
|
|
255
|
-
* True when publishing would deploy the empty starter template.
|
|
256
|
-
* pendingAction is the server's own "nothing to preview" signal;
|
|
257
|
-
* wait_for_build is the building exception. Status is only a fallback
|
|
258
|
-
* when the payload omitted pendingAction. loading/waiting with no
|
|
259
|
-
* preview fail closed so Publish is not clickable before get_app
|
|
260
|
-
* returns.
|
|
261
|
-
*/
|
|
262
|
-
function nothingToPublish() {
|
|
263
|
-
if (previewUrl || publishUrl) {
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
if (pendingAction === "wait_for_build") {
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
if (BLOCKED_ACTIONS.indexOf(pendingAction) !== -1) {
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
const badge = element("status").textContent;
|
|
273
|
-
if (!badge || badge === "loading" || badge === "waiting") {
|
|
274
|
-
return true;
|
|
275
|
-
}
|
|
276
|
-
return UNBUILT_STATUSES.indexOf(badge) !== -1;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
229
|
/**
|
|
280
230
|
* Keep URLs in memory for openLink — never print them (preview JWTs are
|
|
281
231
|
* huge and ugly in the card).
|
|
@@ -290,10 +240,7 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
290
240
|
: "Publish app";
|
|
291
241
|
element("publishApp").disabled = publishUrl
|
|
292
242
|
? !canOpenLinks
|
|
293
|
-
: !applicationId ||
|
|
294
|
-
!canCallTools ||
|
|
295
|
-
publishing ||
|
|
296
|
-
nothingToPublish();
|
|
243
|
+
: !applicationId || !canCallTools || publishing;
|
|
297
244
|
// Only warn about what is actually broken. Hosts that do open links
|
|
298
245
|
// handle local http fine; if one refuses, refused() says so then.
|
|
299
246
|
if (!canOpenLinks && (editUrl || previewUrl) && !publishUrl) {
|
|
@@ -365,11 +312,6 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
365
312
|
if (typeof value.commitId === "string") {
|
|
366
313
|
commitId = value.commitId;
|
|
367
314
|
}
|
|
368
|
-
if (typeof value.pendingAction === "string") {
|
|
369
|
-
pendingAction = value.pendingAction;
|
|
370
|
-
} else if (typeof value.status === "string") {
|
|
371
|
-
pendingAction = "";
|
|
372
|
-
}
|
|
373
315
|
if (typeof value.screenshotBase64 === "string") {
|
|
374
316
|
showScreenshot(value.screenshotBase64, "image/jpeg");
|
|
375
317
|
}
|
|
@@ -382,9 +324,6 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
382
324
|
if (typeof value.publishUrl === "string") {
|
|
383
325
|
publishUrl = webUrl(value.publishUrl);
|
|
384
326
|
}
|
|
385
|
-
if (typeof value.nextPollAfterMs === "number") {
|
|
386
|
-
pollAfterMs = value.nextPollAfterMs;
|
|
387
|
-
}
|
|
388
327
|
// Hosts that deliver URLs without a status left the badge on the HTML
|
|
389
328
|
// default ("loading") even after the app was built.
|
|
390
329
|
const badge = element("status").textContent;
|
|
@@ -399,91 +338,29 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
399
338
|
}
|
|
400
339
|
|
|
401
340
|
/**
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
341
|
+
* When the host opened the card with tool input (applicationId) but never
|
|
342
|
+
* pushed a tool result, refresh ourselves so the badge is not stuck on
|
|
343
|
+
* "loading" after the build finished.
|
|
405
344
|
*/
|
|
406
|
-
function clearRefreshTimer() {
|
|
407
|
-
if (refreshTimer) {
|
|
408
|
-
clearTimeout(refreshTimer);
|
|
409
|
-
refreshTimer = 0;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
function retryDelay() {
|
|
414
|
-
return Math.max(MIN_POLL_MS, pollAfterMs || MIN_POLL_MS);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
function scheduleRefresh(delayMs) {
|
|
418
|
-
clearRefreshTimer();
|
|
419
|
-
if (refreshAttempts >= MAX_REFRESH_ATTEMPTS) {
|
|
420
|
-
note("Stopped checking whether the app is still building.");
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
refreshTimer = setTimeout(() => {
|
|
424
|
-
refreshTimer = 0;
|
|
425
|
-
refreshFromServer();
|
|
426
|
-
}, delayMs);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
345
|
function refreshFromServer() {
|
|
430
|
-
|
|
431
|
-
if (!canCallTools || !applicationId || refreshInFlight) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (typeof document.hidden === "boolean" && document.hidden) {
|
|
435
|
-
scheduleRefresh(retryDelay());
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
const badge = element("status").textContent;
|
|
439
|
-
if (editUrl && badge !== "building") {
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
if (refreshAttempts >= MAX_REFRESH_ATTEMPTS) {
|
|
443
|
-
note("Stopped checking whether the app is still building.");
|
|
346
|
+
if (!canCallTools || !applicationId || editUrl) {
|
|
444
347
|
return;
|
|
445
348
|
}
|
|
446
|
-
refreshAttempts += 1;
|
|
447
|
-
const generation = refreshGeneration;
|
|
448
|
-
refreshInFlight = true;
|
|
449
349
|
request("tools/call", {
|
|
450
350
|
name: "get_app",
|
|
451
|
-
arguments: {
|
|
452
|
-
applicationId,
|
|
453
|
-
ensurePreview: false,
|
|
454
|
-
wait: false,
|
|
455
|
-
},
|
|
351
|
+
arguments: { applicationId },
|
|
456
352
|
})
|
|
457
353
|
.then((result) => {
|
|
458
|
-
refreshInFlight = false;
|
|
459
|
-
if (generation !== refreshGeneration) {
|
|
460
|
-
if (element("status").textContent === "building") {
|
|
461
|
-
scheduleRefresh(retryDelay());
|
|
462
|
-
}
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
354
|
if (!result || result.isError) {
|
|
466
|
-
scheduleRefresh(retryDelay());
|
|
467
355
|
return;
|
|
468
356
|
}
|
|
469
357
|
applyPayload(result);
|
|
470
358
|
if (result.structuredContent) {
|
|
471
359
|
applyPayload(result.structuredContent);
|
|
472
360
|
}
|
|
473
|
-
if (element("status").textContent !== "building") {
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
if (pollAfterMs === 0) {
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
scheduleRefresh(retryDelay());
|
|
480
361
|
})
|
|
481
362
|
.catch(() => {
|
|
482
|
-
|
|
483
|
-
if (generation !== refreshGeneration) {
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
scheduleRefresh(retryDelay());
|
|
363
|
+
// Host declined; stay on whatever we have.
|
|
487
364
|
});
|
|
488
365
|
}
|
|
489
366
|
|
|
@@ -536,10 +413,6 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
536
413
|
if (!applicationId || !canCallTools || publishing) {
|
|
537
414
|
return;
|
|
538
415
|
}
|
|
539
|
-
if (nothingToPublish()) {
|
|
540
|
-
note("Nothing to publish yet: this turn did not build the app.");
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
416
|
publishing = true;
|
|
544
417
|
renderActions();
|
|
545
418
|
note("Publishing…");
|
|
@@ -623,10 +496,6 @@ export const APP_STATUS_HTML = `<!DOCTYPE html>
|
|
|
623
496
|
if (params.structuredContent) {
|
|
624
497
|
applyPayload(params.structuredContent);
|
|
625
498
|
}
|
|
626
|
-
refreshGeneration += 1;
|
|
627
|
-
if (element("status").textContent === "building") {
|
|
628
|
-
refreshFromServer();
|
|
629
|
-
}
|
|
630
499
|
}
|
|
631
500
|
if (method === "ui/notifications/tool-input" && params.arguments) {
|
|
632
501
|
applyPayload(params.arguments);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-status-html.js","sourceRoot":"","sources":["../../../src/transports/mcp/app-status-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,iCAAiC,CAAC;AAEzE,MAAM,CAAC,MAAM,eAAe,GAAG
|
|
1
|
+
{"version":3,"file":"app-status-html.js","sourceRoot":"","sources":["../../../src/transports/mcp/app-status-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,iCAAiC,CAAC;AAEzE,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmiB9B,CAAC"}
|