@tempad-dev/mcp 0.9.0 → 0.11.0

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 CHANGED
@@ -31,7 +31,7 @@ Supported tools/resources:
31
31
  available font families and exact native styles without reading file resources. `scope: "pages"`
32
32
  lists page IDs without scanning components; a resource call with `pageId` scans only that page's
33
33
  components while retaining file-wide variable, style, and shader definitions.
34
- - `begin_design`, `resume_design`, `set_design_anchor`, and `end_design`: Bind canvas writes to
34
+ - `manage_design_task` (`begin`, `resume`, `complete`, `cancel`) and `set_design_anchor`: Bind canvas writes to
35
35
  a design task, resume a paused task, place its status controls, and finish or cancel the task.
36
36
  Stop permanently fences the old task across reconnects. Native Codex App comments support Queue
37
37
  and Steer; confirmed admission clears submitted drafts before execution finishes. See the
@@ -43,17 +43,33 @@ Supported tools/resources:
43
43
  resolves, validates, diffs, applies, and structurally verifies the result.
44
44
  - `upload_asset`: A bounded Hub-only bridge from a programmatically composed generated PNG/JPEG/GIF
45
45
  data URL to a content-addressed `assetHash` for `apply_canvas`; encoded bytes are never returned.
46
- - `get_screenshot`: A bounded rendered PNG for selective visual validation.
47
- - `get_structure`: Hierarchy/geometry outline for an exact node, page, or current selection, including stable authoring keys on
46
+ - `get_screenshot`: A bounded rendered PNG per requested node for selective visual validation.
47
+ - `get_structure`: Hierarchy/geometry outline for an exact node, page, or one or more visible selected nodes, including stable authoring keys on
48
48
  TemPad-managed nodes and optional native mask, IMAGE paint, layout-grid, and frame-guide read-back.
49
49
 
50
50
  Notes:
51
51
 
52
+ - `get_code`, `get_structure`, and `get_screenshot` accept `nodeIds` or the current multi-selection.
53
+ Single `nodeId` calls retain their existing result shape. Code and screenshots return independent
54
+ `{ nodeId, result }` or `{ nodeId, error }` entries for batches; continue `remainingNodeIds` with
55
+ exact `nodeIds` and unchanged options. Structure retains exact roots, reports failed roots in
56
+ `errors`, and supports `options.depth: 0` for roots only. Node-set reads require matching Hub and
57
+ extension builds using bridge protocol 15; older peers cannot silently ignore the new selectors.
58
+ - `get_code.resolveTokens` controls code only. Both settings return token definitions with all
59
+ modes and aliases. Enabled resolution uses each actual consumer's effective Figma modes;
60
+ unresolved references remain in code with `token-resolution` warnings. Missing or ambiguous
61
+ definitions produce `token-definition` warnings. Warnings are bounded per node result.
62
+ This replaces older responses that flattened `tokens` when resolution was enabled; legacy
63
+ extensions must upgrade to use `resolveTokens: true`.
52
64
  - Tool responses use a shared `64 KiB` inline budget measured on the `CallToolResult` body. When a selection is too large for the `get_code` budget, TemPad Dev may return a shell response instead of failing. The shell keeps the current node wrapper and lists omitted direct child ids in an inline code comment so agents can request them one by one. The accompanying warning stays lightweight and only points agents to that comment.
53
65
  - `apply_canvas` is available whenever MCP access is enabled and the current Figma Design file is
54
66
  editable. Dev Mode and view-only files remain read-only.
55
- - MCP **0.9.0** pairs with extension **0.22.0** and Agent Plugin **0.2.1**. Update the extension
56
- and installed skills, replace any alpha-pinned MCP configuration with `@tempad-dev/mcp@latest`,
67
+ - MCP **0.11.0** pairs with extension **0.23.0** and Agent Plugin **0.4.0**.
68
+ The node-set and token-definition semantics above require matching protocol 15 Hub and extension
69
+ builds. Extension 0.22.0 remains supported through protocol 13 for existing reads, sessions,
70
+ tasks, and canvas writes. New read options prompt an upgrade, and responses identify older
71
+ selection/token semantics. Update the extension and reload Figma for the new capabilities, update
72
+ the plugin or installed skills, replace any alpha-pinned MCP configuration with `@tempad-dev/mcp@latest`,
57
73
  then reconnect the MCP client and start a new task. See the
58
74
  [upgrade guide](https://github.com/ecomfe/tempad-dev/tree/main/agent-plugin/src#upgrading).
59
75
  - Assets are ephemeral and tool-linked. Local stdio clients receive `asset.localPath` when the Hub
package/README.zh-Hans.md CHANGED
@@ -28,7 +28,7 @@ TemPad Dev 的 MCP server 将 coding agent 连接到浏览器中打开的 Figma
28
28
  有界定义。使用 `scope: "fonts"` 可查询当前可用字体家族和精确原生样式,不读取文件资源。
29
29
  `scope: "pages"` 无需扫描组件即可列出页面 ID;资源读取传入 `pageId` 时只扫描该页组件,
30
30
  变量、样式和 shader 定义仍按文件范围读取。
31
- - `begin_design`、`resume_design`、`set_design_anchor`、`end_design`:将画布写入绑定到设计任务,
31
+ - `manage_design_task`(`begin`、`resume`、`complete`、`cancel`)和 `set_design_anchor`:将画布写入绑定到设计任务,
32
32
  恢复暂停的任务、设置状态栏锚点,以及结束或取消任务。Stop 会永久禁止旧任务写入,重新连接也不会恢复。
33
33
  兼容 Codex App 的原生评论支持 Queue 和 Steer;确认接收后清空已提交草稿,无需等待执行完成。
34
34
  详细行为与宿主验证范围见[评论指南](https://github.com/ecomfe/tempad-dev/blob/main/agent-plugin/src/README.zh-Hans.md#使用)。
@@ -38,16 +38,29 @@ TemPad Dev 的 MCP server 将 coding agent 连接到浏览器中打开的 Figma
38
38
  扩展会在本地解析、验证、计算与实时画布的差异、应用修改并校验结构。
39
39
  - `upload_asset`:Hub 内的受限桥梁,把程序化串联生成的 PNG/JPEG/GIF data URL 存成供
40
40
  `apply_canvas` 使用的 content-addressed `assetHash`,且不会返回编码后的图片字节。
41
- - `get_screenshot`:返回一张有大小限制的渲染 PNG,用于按需视觉验证。
42
- - `get_structure`:精确节点、页面或当前选中节点的层级/几何结构信息,并返回 TemPad 已管理节点的稳定 authoring key;
41
+ - `get_screenshot`:为每个请求的节点返回有大小限制的渲染 PNG,用于按需视觉验证。
42
+ - `get_structure`:精确节点、页面或当前选中的一个或多个可见节点的层级/几何结构信息,并返回 TemPad 已管理节点的稳定 authoring key;
43
43
  还可按需读回原生遮罩、IMAGE paint、布局网格与画框参考线。
44
44
 
45
45
  说明:
46
46
 
47
+ - `get_code`、`get_structure` 和 `get_screenshot` 接受 `nodeIds` 或当前多选,单个 `nodeId`
48
+ 调用保留原有返回格式。代码和截图批量返回 `{ nodeId, result }` 或 `{ nodeId, error }`,
49
+ 使用返回的 `remainingNodeIds` 作为 `nodeIds`,并保留原参数,即可继续读取。结构读取保留
50
+ 真实根节点,在 `errors` 中报告失败节点;`options.depth: 0` 只读取根节点。多节点读取要求
51
+ Hub 和扩展使用匹配的 bridge protocol 15 构建,旧版不会静默忽略新的节点选择参数。
52
+ - `get_code.resolveTokens` 只控制代码;无论是否启用,`tokens` 都保留定义、全部模式和 alias。
53
+ 启用后按每个实际消费节点的 Figma 有效模式解析;无法解析的引用保留在代码中,并返回
54
+ `token-resolution` warning。定义缺失或名称有歧义时返回 `token-definition` warning;
55
+ warning 按节点独立去重并限制大小。旧版启用该选项时会把 `tokens` 展开为字面量,
56
+ 旧扩展需要升级才能使用 `resolveTokens: true`。
47
57
  - 工具响应共用 `64 KiB` 的 inline budget,按 `CallToolResult` 整体响应体积计算。若选区过大而超出 `get_code` 的预算,TemPad Dev 可能返回 shell response 而不是直接失败。shell 会保留当前节点的包裹结构,并在内联代码注释中列出被省略的直接子节点 id,方便 agent 逐个继续拉取;配套 warning 只保留最小化的提示信息,用来指向这条注释。
48
58
  - 启用 MCP access 且当前 Figma Design 文件可编辑时,`apply_canvas` 即可使用;Dev Mode 和
49
59
  只读文件仍不可写。
50
- - MCP **0.9.0** 应配套使用扩展 **0.22.0** 和 Agent Plugin **0.2.1**。请更新扩展和已安装的 skill,
60
+ - MCP **0.11.0** 配套扩展 **0.23.0** 和 Agent Plugin **0.4.0**。
61
+ 上述多节点读取与 token 定义语义要求 Hub 和扩展均使用匹配的 protocol 15 构建。
62
+ 扩展 0.22.0 仍通过 protocol 13 支持既有读取、会话、任务和画布写入。新版读取选项会提示升级,响应会标注旧版选区和 token 语义。
63
+ 请更新扩展并重新加载 Figma 以启用新版能力,再更新 plugin 或已安装的 skill,
51
64
  将固定 alpha 版本的 MCP 配置改为 `@tempad-dev/mcp@latest`,然后重新连接 MCP client 并新建任务。
52
65
  详见[升级指南](https://github.com/ecomfe/tempad-dev/blob/main/agent-plugin/src/README.zh-Hans.md#升级)。
53
66
  - 资源是临时且与工具调用关联的。本地 stdio client 在 Hub 持有字节时会收到
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { _ as runtimeIdentity, c as RUNTIME_DIR, l as SOCK_PATH, o as LOCK_PATH, p as log, s as PACKAGE_VERSION, u as ensureDir } from "./shared-8rz2qWXn.mjs";
2
+ import { _ as runtimeIdentity, c as RUNTIME_DIR, l as SOCK_PATH, o as LOCK_PATH, p as log, s as PACKAGE_VERSION, u as ensureDir } from "./shared-FHsVNIOk.mjs";
3
3
  import { spawn } from "node:child_process";
4
4
  import { connect } from "node:net";
5
5
  import { join } from "node:path";
package/dist/hub.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as SetDesignAnchorParametersSchema, A as GetDesignSystemParametersSchema, B as MCP_AUTO_ACTIVATE_GRACE_MS, C as DesignTaskIdSchema, D as GetAssetsParametersSchema, E as FigmaSessionSchema, F as LegacyMessageFromExtensionSchema, G as MCP_MAX_ASSET_STORE_BYTES, H as MCP_GET_CODE_TIMEOUT_MS, I as LegacyToolCallPayloadSchema, J as MCP_TOOL_INLINE_BUDGET_BYTES, K as MCP_MAX_PAYLOAD_BYTES, M as GetScreenshotParametersSchema, N as GetStructureParametersSchema, O as GetAssetsResultSchema, P as GetTokenDefsParametersSchema, Q as ResumeDesignParametersSchema, R as MCP_APPLY_CANVAS_TIMEOUT_MS, S as DesignAnchorSchema, T as EndDesignParametersSchema, U as MCP_GET_DESIGN_SYSTEM_TIMEOUT_MS, W as MCP_MAX_ASSET_BYTES, X as MessageFromExtensionSchema, Y as MCP_TOOL_TIMEOUT_MS, Z as RESUMABLE_DESIGN_TASK_STATUSES, a as HUB_RUNTIME_IDENTITY_PATH, at as buildApplyCanvasToolResult, b as ApplyCanvasResultSchema, c as RUNTIME_DIR, ct as buildGetDesignSystemToolResult, d as ensureFile, dt as buildGetTokenDefsToolResult, et as TEMPAD_MCP_BRIDGE_SUBPROTOCOL, f as getRecordProperty, ft as buildUploadAssetToolResult, g as clientDescriptor, h as bindRequestMetadata, ht as utf8Bytes, i as HUB_LOCK_UPDATE_MS, it as UploadAssetResultSchema, j as GetDesignSystemResultSchema, k as GetCodeParametersSchema, l as SOCK_PATH, lt as buildGetScreenshotToolResult, m as ClientEventSchema, mt as measureCallToolResultBytes, n as HUB_LOCK_PATH, nt as TEMPAD_MCP_ERROR_CODES, ot as buildGetAssetsToolResult, p as log, pt as formatDesignFeedback, q as MCP_PORT_CANDIDATES, r as HUB_LOCK_STALE_MS, rt as UploadAssetParametersSchema, s as PACKAGE_VERSION, st as buildGetCodeToolResult, t as ASSET_DIR, tt as TEMPAD_MCP_BRIDGE_SUPPORTED_PROTOCOL_VERSIONS, u as ensureDir, ut as buildGetStructureToolResult, v as AGENT_CLIENTS, w as DesignTaskSchema, x as BeginDesignParametersSchema, y as ApplyCanvasParametersSchema, z as MCP_ASSET_TTL_MS } from "./shared-8rz2qWXn.mjs";
1
+ import { $ as TEMPAD_MCP_BRIDGE_SUBPROTOCOL, A as GetScreenshotParametersSchema, B as MCP_GET_CODE_TIMEOUT_MS, C as DesignTaskSchema, D as GetCodeParametersSchema, E as GetAssetsResultSchema, G as MCP_NODE_READ_BATCH_WORK_BUDGET_MS, H as MCP_MAX_ASSET_BYTES, I as MCP_APPLY_CANVAS_TIMEOUT_MS, J as MCP_TOOL_TIMEOUT_MS, K as MCP_PORT_CANDIDATES, L as MCP_ASSET_TTL_MS, M as GetTokenDefsParametersSchema, N as LegacyMessageFromExtensionSchema, O as GetDesignSystemParametersSchema, P as LegacyToolCallPayloadSchema, Q as SetDesignAnchorParametersSchema, R as MCP_AUTO_ACTIVATE_GRACE_MS, S as DesignTaskIdSchema, T as GetAssetsParametersSchema, U as MCP_MAX_ASSET_STORE_BYTES, V as MCP_GET_DESIGN_SYSTEM_TIMEOUT_MS, W as MCP_MAX_PAYLOAD_BYTES, X as MessageFromExtensionSchema, Y as ManageDesignTaskParametersSchema, Z as RESUMABLE_DESIGN_TASK_STATUSES, a as HUB_RUNTIME_IDENTITY_PATH, at as buildGetAssetsToolResult, b as ApplyCanvasResultSchema, c as RUNTIME_DIR, ct as buildGetScreenshotToolResult, d as ensureFile, dt as buildUploadAssetToolResult, et as TEMPAD_MCP_BRIDGE_SUPPORTED_PROTOCOL_VERSIONS, f as getRecordProperty, ft as formatDesignFeedback, g as clientDescriptor, h as bindRequestMetadata, i as HUB_LOCK_UPDATE_MS, it as buildApplyCanvasToolResult, j as GetStructureParametersSchema, k as GetDesignSystemResultSchema, l as SOCK_PATH, lt as buildGetStructureToolResult, m as ClientEventSchema, mt as utf8Bytes, n as HUB_LOCK_PATH, nt as UploadAssetParametersSchema, ot as buildGetCodeToolResult, p as log, pt as measureCallToolResultBytes, q as MCP_TOOL_INLINE_BUDGET_BYTES, r as HUB_LOCK_STALE_MS, rt as UploadAssetResultSchema, s as PACKAGE_VERSION, st as buildGetDesignSystemToolResult, t as ASSET_DIR, tt as TEMPAD_MCP_ERROR_CODES, u as ensureDir, ut as buildGetTokenDefsToolResult, v as AGENT_CLIENTS, w as FigmaSessionSchema, x as DesignAnchorSchema, y as ApplyCanvasParametersSchema } from "./shared-FHsVNIOk.mjs";
2
2
  import { execFile, spawn } from "node:child_process";
3
3
  import { connect, createServer } from "node:net";
4
4
  import { dirname, join, resolve } from "node:path";
@@ -240,7 +240,7 @@ async function codexQueueExecutable() {
240
240
  "-o",
241
241
  "comm="
242
242
  ], { timeout: 3e3 });
243
- const paths = [...new Set(stdout.split(/\r?\n/).map((path) => path.trim()))].filter((path) => /[/\\]resources[/\\]codex(?:\.exe)?$/i.test(path));
243
+ const paths = [...new Set(stdout.split(/\r?\n/).map((path) => path.trim()))].filter((path) => /[/\\]resources[/\\](?:codex-cli[/\\]CodexCLI\.app[/\\]Contents[/\\]MacOS[/\\])?codex(?:\.exe)?$/i.test(path));
244
244
  if (paths.length !== 1) throw new Error("The running Codex desktop executable could not be identified.");
245
245
  return paths[0];
246
246
  }
@@ -2479,7 +2479,7 @@ var DesignTaskStore = class {
2479
2479
  //#endregion
2480
2480
  //#region src/legacy-extension.ts
2481
2481
  function extensionUpgradeRequired() {
2482
- return Object.assign(/* @__PURE__ */ new Error("This operation requires TemPad Dev extension 0.21.0 or later. Update the extension in Chrome, then reload the Figma tab and reconnect Agent integration. Until then, get_code, get_screenshot, and node-based get_structure remain available without a design task."), { code: TEMPAD_MCP_ERROR_CODES.EXTENSION_UPGRADE_REQUIRED });
2482
+ return Object.assign(/* @__PURE__ */ new Error("This operation requires a current TemPad Dev extension compatible with this Hub. Update the extension in Chrome, then reload the Figma tab and reconnect Agent integration. Until then, get_code, get_screenshot, and node-based get_structure remain available without a design task."), { code: TEMPAD_MCP_ERROR_CODES.EXTENSION_UPGRADE_REQUIRED });
2483
2483
  }
2484
2484
  function legacyToolPayload(name, args) {
2485
2485
  const result = LegacyToolCallPayloadSchema.safeParse({
@@ -2487,6 +2487,7 @@ function legacyToolPayload(name, args) {
2487
2487
  args
2488
2488
  });
2489
2489
  if (!result.success) throw extensionUpgradeRequired();
2490
+ if (result.data.name === "get_code" && result.data.args?.resolveTokens) throw Object.assign(/* @__PURE__ */ new Error("resolveTokens requires matching current Hub and extension builds. Update the extension, then reload the Figma tab and reconnect Agent integration. Older extensions flatten token definitions and cannot return consumer-aware code with preserved aliases."), { code: TEMPAD_MCP_ERROR_CODES.EXTENSION_UPGRADE_REQUIRED });
2490
2491
  return result.data;
2491
2492
  }
2492
2493
  //#endregion
@@ -2588,7 +2589,7 @@ var DesignTasks = class {
2588
2589
  if (!record) fail("DESIGN_TASK_INACTIVE", "Unknown or expired task. Begin a new design task and reread its target.");
2589
2590
  if (record.ownerId !== ownerId) fail("DESIGN_TASK_OWNER_MISMATCH", "This task belongs to another MCP caller. Begin your own task.");
2590
2591
  if (active && record.task.reviewClosed) fail("DESIGN_TASK_INACTIVE", "This review is closed. Begin a new task before writing.");
2591
- if (active && record.task.status !== "active") fail("DESIGN_TASK_INACTIVE", `Design task is ${record.task.status}. ${record.task.status === "cancelled" ? "Begin a new task with a fresh requestId before writing." : "Resume this task with resume_design and reread the target before writing; do not replay an old write."}`);
2592
+ if (active && record.task.status !== "active") fail("DESIGN_TASK_INACTIVE", `Design task is ${record.task.status}. ${record.task.status === "cancelled" ? "Begin a new task with a fresh requestId before writing." : "Use manage_design_task with action \"resume\" and reread the target before writing; do not replay an old write."}`);
2592
2593
  return record;
2593
2594
  }
2594
2595
  /** Runtime identity may reconnect the same conversation, never a focused/last caller. */
@@ -2606,7 +2607,7 @@ var DesignTasks = class {
2606
2607
  }
2607
2608
  assertEpoch(taskId, ownerId, epoch) {
2608
2609
  const record = this.owned(taskId, ownerId);
2609
- if ((epoch ?? 0) !== (record.task.epoch ?? 0)) fail("DESIGN_TASK_INACTIVE", "Stale task lease. Read get_design_task for the current epoch, resume_design if inactive, and reread the canvas before writing.");
2610
+ if ((epoch ?? 0) !== (record.task.epoch ?? 0)) fail("DESIGN_TASK_INACTIVE", "Stale task lease. Read get_design_task for the current epoch, use manage_design_task with action \"resume\" if inactive, and reread the canvas before writing.");
2610
2611
  return record;
2611
2612
  }
2612
2613
  resume(taskId, ownerId, epoch, session) {
@@ -3013,7 +3014,7 @@ function attachExtensionSocket(ws, options) {
3013
3014
  options.onConnected?.(extension.id);
3014
3015
  const registered = {
3015
3016
  id: extension.id,
3016
- protocolVersion: 13,
3017
+ protocolVersion: 15,
3017
3018
  supportedProtocolVersions: [...TEMPAD_MCP_BRIDGE_SUPPORTED_PROTOCOL_VERSIONS],
3018
3019
  type: "registered"
3019
3020
  };
@@ -3074,20 +3075,29 @@ function attachExtensionSocket(ws, options) {
3074
3075
  if (message.error !== void 0) options.onToolError(message.id, extension.id, message.error);
3075
3076
  else options.onToolResult(message.id, extension.id, message.payload);
3076
3077
  break;
3077
- case "runtimeHello":
3078
- if (extension.runtime && (extension.runtime.version !== message.extensionVersion || extension.runtime.fingerprint !== message.extensionRuntimeFingerprint)) {
3078
+ case "runtimeHello": {
3079
+ const protocolVersion = message.protocolVersion ?? 13;
3080
+ if (!TEMPAD_MCP_BRIDGE_SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
3081
+ ws.close(1008, "Unsupported extension bridge protocol.");
3082
+ break;
3083
+ }
3084
+ if (extension.runtime && (extension.runtime.version !== message.extensionVersion || extension.runtime.fingerprint !== message.extensionRuntimeFingerprint || extension.runtime.protocolVersion !== protocolVersion)) {
3079
3085
  options.onProtocolWarning?.({
3080
3086
  error: /* @__PURE__ */ new Error("Extension changed runtime identity on an open connection."),
3081
3087
  extensionId: extension.id,
3082
3088
  kind: "schema"
3083
3089
  });
3090
+ ws.close(1008, "Extension changed runtime identity.");
3084
3091
  break;
3085
3092
  }
3086
3093
  extension.runtime = {
3094
+ protocolVersion,
3087
3095
  version: message.extensionVersion,
3088
3096
  fingerprint: message.extensionRuntimeFingerprint
3089
3097
  };
3090
3098
  options.onRuntimeHello?.(extension);
3099
+ break;
3100
+ }
3091
3101
  }
3092
3102
  });
3093
3103
  ws.on("error", (error) => {
@@ -3116,7 +3126,7 @@ function rawDataToBuffer(raw) {
3116
3126
  }
3117
3127
  //#endregion
3118
3128
  //#region src/instructions.md?raw
3119
- var instructions_default = "You are connected to Figma through TemPad Dev. An active MCP badge selects the default file;\nbrowser focus does not. When the target is unclear, call `list_design_sessions` and pass the exact\n`sessionId` to `begin_design` or an independent read. Task targets never follow browser focus;\ntask-bound reads stay on their task's session. Independent reads need no task. Run calls against\nthe same file sequentially, including reads.\n\nFor new design work, call `begin_design` before research or writing, then carry its `taskId`.\nChoose a known Frame with `set_design_anchor` once the region is clear; otherwise the first new\ntop-level Frame anchors automatically. Reads, selections, and later writes never change the anchor\nunless `set_design_anchor` does. Task identity survives turns. A pause or idle lease expiry releases\ncanvas ownership without cancelling the task;\nresume the same task with `resume_design`, carry its returned `epoch` as `taskEpoch`, and reread the\nbound canvas with `get_structure` or `get_code` before writing. Use `get_design_task` for recovery,\nnot routine polling. Never replay a stale write or queue a write against an occupied file.\n`end_design` is for a verified completed pass or explicit cancellation, not a wait for input.\nCompletion releases ownership but keeps the review and same task open for comments until the user\nclicks Done; resume that task for follow-up comments. Cancelled, closed, or replaced tasks cannot\nresume. The Figma Stop control permanently cancels the current task after its running operation\nsettles; do not resume or automatically replace it. If further work is necessary or requested,\nbegin a fresh task with a new requestId; no separate\nFigma unlock or user turn is required. No progress or heartbeat calls are needed.\n\nFeedback drafts contain individually numbered elements captured when saved. Reread each exact node\nbefore acting; do not substitute the current selection. Supported hosts deliver submitted feedback\nthrough native conversation messages. Do not poll, launch helpers, or configure a control endpoint.\n\nTreat tool outputs as file-scoped facts. Never invent node IDs, resource refs, library keys, token\norigins, or design-system intent. Tool descriptions give mechanical affordances; the applicable host\nskill governs workflow, representation, and design judgment. For Figma-to-code, use `get_code` as\nvisible implementation evidence. Use `get_structure` only for hierarchy, geometry, managed-key\nuncertainty, or targeted mask, IMAGE paint, layout-grid, and frame-guide read-back via\n`options.native`.\n\nFor canvas authoring, choose the native representation through the skill, then describe one desired\nresult with `apply_canvas`. Canvas HTML serializes ordinary layers; typed fields carry selected\nnative state, resources, and bindings. Never send raw Plugin API operations or arbitrary JavaScript.\n`get_design_system` is optional when existing-resource reuse is relevant and permitted; new local\nresources do not require it. `scope: \"fonts\"` independently reads environment availability.\nFor large files, `scope: \"pages\"` finds a relevant component page before `pageId`-scoped discovery;\nvariables, styles, and shaders remain file-wide. Use catalog CSS names or a call-scoped `theme` for\nvariable utilities and native text-style classes. Load skill references only after choosing a\nnative concept.\n\nWhen design evidence is limited to the current page or an independent system without reuse, stay\non the Direct path: do not discover resource catalogs, inspect other pages, or use catalog refs.\n`scope: \"fonts\"` remains available. Local variables and styles remain file-wide Figma resources,\nand the extension may still check file-wide identities internally for safe reconciliation.\n\nCreates add and automatically place one root. Updates use exact node identity: omission preserves\nlive state; explicit removal removes managed content. Read structural verification and resolve\nwarnings before claiming completion. Use `get_screenshot` when pixels affect a decision and open\nits image before claiming visual verification. Use `asset.localPath` when present, otherwise\n`asset.url`; native media hashes identify assets within one Figma file, not preview bytes. Never\nship `data-hint-*` attributes from read-tool output.\n";
3129
+ var instructions_default = "You are connected to Figma through TemPad Dev. An active MCP badge selects the default file;\nbrowser focus does not. When the target is unclear, call `list_design_sessions` and pass the exact\n`sessionId` to `manage_design_task` with action `begin` or an independent read. Task targets never follow browser focus;\ntask-bound reads stay on their task's session. Independent reads need no task. Run calls against\nthe same file sequentially, including reads.\n\nFor new design work, call `manage_design_task` with action `begin` before research or writing,\nthen carry its `taskId`.\nChoose a known Frame with `set_design_anchor` once the region is clear; otherwise the first new\ntop-level Frame anchors automatically. Reads, selections, and later writes never change the anchor\nunless `set_design_anchor` does. Task identity survives turns. A pause or idle lease expiry releases\ncanvas ownership without cancelling the task;\nuse action `resume` with the current `epoch`, carry its returned `epoch` as `taskEpoch`, and reread the\nbound canvas with `get_structure` or `get_code` before writing. Use `get_design_task` for recovery,\nnot routine polling. Never replay a stale write or queue a write against an occupied file.\nActions `complete` and `cancel` require the current `epoch` and end a verified pass or explicitly\nabandon it; they are not for a wait for input.\nCompletion releases ownership but keeps the review and same task open for comments until the user\nclicks Done; resume that task for follow-up comments. Cancelled, closed, or replaced tasks cannot\nresume. The Figma Stop control permanently cancels the current task after its running operation\nsettles; do not resume or automatically replace it. If further work is necessary or requested,\nuse action `begin` with a fresh requestId; no separate\nFigma unlock or user turn is required. No progress or heartbeat calls are needed.\n\nFeedback drafts contain individually numbered elements captured when saved. Reread each exact node\nbefore acting; do not substitute the current selection. Supported hosts deliver submitted feedback\nthrough native conversation messages. Do not poll, launch helpers, or configure a control endpoint.\n\nTreat tool outputs as file-scoped facts. Never invent node IDs, resource refs, library keys, token\norigins, or design-system intent. Tool descriptions give mechanical affordances; the applicable host\nskill governs workflow, representation, and design judgment. For Figma-to-code, use `get_code` as\nvisible implementation evidence. Use `get_structure` only for hierarchy, geometry, managed-key\nuncertainty, or targeted mask, IMAGE paint, layout-grid, and frame-guide read-back via\n`options.native`.\n\nFor canvas authoring, choose the native representation through the skill, then describe one desired\nresult with `apply_canvas`. Canvas HTML serializes ordinary layers; typed fields carry selected\nnative state, resources, and bindings. Never send raw Plugin API operations or arbitrary JavaScript.\n`get_design_system` is optional when existing-resource reuse is relevant and permitted; new local\nresources do not require it. `scope: \"fonts\"` independently reads environment availability.\nFor large files, `scope: \"pages\"` finds a relevant component page before `pageId`-scoped discovery;\nvariables, styles, and shaders remain file-wide. Use catalog CSS names or a call-scoped `theme` for\nvariable utilities and native text-style classes. Load skill references only after choosing a\nnative concept.\n\nWhen design evidence is limited to the current page or an independent system without reuse, stay\non the Direct path: do not discover resource catalogs, inspect other pages, or use catalog refs.\n`scope: \"fonts\"` remains available. Local variables and styles remain file-wide Figma resources,\nand the extension may still check file-wide identities internally for safe reconciliation.\n\nCreates add and automatically place one root. Updates use exact node identity: omission preserves\nlive state; explicit removal removes managed content. Read structural verification and resolve\nwarnings before claiming completion. Use `get_screenshot` when pixels affect a decision and open\nits image before claiming visual verification. Use `asset.localPath` when present, otherwise\n`asset.url`; native media hashes identify assets within one Figma file, not preview bytes. Never\nship `data-hint-*` attributes from read-tool output.\n";
3120
3130
  //#endregion
3121
3131
  //#region src/request.ts
3122
3132
  const pendingCalls = /* @__PURE__ */ new Map();
@@ -3294,7 +3304,7 @@ const CONNECTIVITY_TROUBLESHOOTING_LINES = [
3294
3304
  "- Badge-default reads require the intended tab's active MCP badge. Exact sessionId reads require that session in list_design_sessions; browser focus does not select a default.",
3295
3305
  "- If the connection is missing or reports a protocol mismatch, rebuild the affected runtime layers, reload the installed TemPad Dev browser extension, reload the same Figma tab, and start a fresh task."
3296
3306
  ];
3297
- const SELECTION_TROUBLESHOOTING_LINE = "Tip: Select exactly one visible node, or pass nodeId.";
3307
+ const MULTI_SELECTION_TROUBLESHOOTING_LINE = "Tip: Select one or more visible nodes, or pass nodeIds (nodeId for a single node).";
3298
3308
  const VERIFICATION_TROUBLESHOOTING_LINE = "Tip: TemPad rolls verification failures back. Correct the reported desired-state mismatch and retry the affected root while preserving unrelated design intent.";
3299
3309
  function isRecord(value) {
3300
3310
  return !!value && typeof value === "object" && !Array.isArray(value);
@@ -3323,26 +3333,10 @@ const TOOL_DEFS = [
3323
3333
  outputSchema: z.object({ sessions: z.array(FigmaSessionSchema) })
3324
3334
  }),
3325
3335
  hubTool({
3326
- name: "resume_design",
3327
- description: "Continue the current design task after pause, expiry, interruption, or completion awaiting review. Keep the same taskId and design region for follow-up comments until the user clicks Done. Cancelled, closed, or replaced tasks cannot resume. The original browser tab automatically rebinds after a page refresh; get_design_task returns its current epoch. Pass that epoch to resume. Pass the returned epoch as taskEpoch on subsequent calls, and read the bound canvas with get_structure or get_code before writing. Never replay an old write.",
3328
- annotations: ASSET_WRITE_ANNOTATIONS,
3329
- parameters: ResumeDesignParametersSchema,
3330
- target: "hub",
3331
- outputSchema: DesignTaskSchema
3332
- }),
3333
- hubTool({
3334
- name: "begin_design",
3335
- description: "Begin a new design task in the active Figma session before design research or writing. Returns a taskId bound to that file and session; pass it on subsequent task calls. No coordinates or progress reports are needed. Idle ownership expires after five minutes. Reuse requestId only when retrying this same begin. Stop a busy task in TemPad Dev before another task takes over. For follow-up comments on an open review, use resume_design on the same task, including after completion. Beginning a new task replaces the previous task for that file.",
3336
+ name: "manage_design_task",
3337
+ description: "Manage one design task. begin requires title and a fresh UUID requestId, optionally sessionId; reserve the file before research or writing, and reuse requestId only for the same begin retry. Beginning replaces the previous task for that file; idle ownership expires after five minutes. Other actions require taskId and current epoch. resume continues the same open review after pause, expiry, interruption, or completion; pass its returned epoch as taskEpoch on subsequent work and reread the bound canvas before writing. Cancelled, closed, or replaced tasks cannot resume. complete releases ownership after the outcome and verification, keeping the review open until the user clicks Done. cancel permanently abandons the task after any running operation settles; applied changes remain. summary is optional for complete/cancel. Waiting for input is a pause, not completion. No progress or heartbeat calls are needed.",
3336
3338
  annotations: ASSET_WRITE_ANNOTATIONS,
3337
- parameters: BeginDesignParametersSchema,
3338
- target: "hub",
3339
- outputSchema: DesignTaskSchema
3340
- }),
3341
- hubTool({
3342
- name: "end_design",
3343
- description: "Mark this design pass complete after the requested outcome and its verification. Releases file ownership and keeps the same task, design region, and review open for comments. Follow-up comments resume this task; only the user’s Done closes the review. Waiting for input before the outcome is ready or stopping a turn is a pause. Cancel when abandoning a task; already completed writes remain. Retrying within the same epoch is safe. Cancellation waits for a running operation to finish before handing over the file.",
3344
- annotations: ASSET_WRITE_ANNOTATIONS,
3345
- parameters: EndDesignParametersSchema,
3339
+ parameters: ManageDesignTaskParametersSchema,
3346
3340
  target: "hub",
3347
3341
  outputSchema: DesignTaskSchema
3348
3342
  }),
@@ -3357,7 +3351,7 @@ const TOOL_DEFS = [
3357
3351
  }),
3358
3352
  extTool({
3359
3353
  name: "get_code",
3360
- description: "Read implementation evidence for an existing Figma node or the current single selection as JSX/Vue markup, classes, tokens, assets, codegen facts, and bounded warnings.",
3354
+ description: "Read implementation evidence for exact nodeId/nodeIds or the current selection as JSX/Vue markup, classes, tokens, assets, codegen facts, and bounded warnings. Multi-selection and explicit nodeIds return independent results keyed by nodeId, including per-node errors. Continue remainingNodeIds with nodeIds and the same options. Single-node calls retain the flat result.",
3361
3355
  annotations: READ_ONLY_ANNOTATIONS,
3362
3356
  parameters: GetCodeParametersSchema,
3363
3357
  target: "extension",
@@ -3381,7 +3375,7 @@ const TOOL_DEFS = [
3381
3375
  }),
3382
3376
  extTool({
3383
3377
  name: "get_token_defs",
3384
- description: "Resolve canonical token names to literal values (optionally including all modes) for tokens referenced by get_code.",
3378
+ description: "Read definitions for canonical token names referenced by get_code, preserving aliases and optionally all modes. Consumer-specific literal values belong to get_code with resolveTokens enabled.",
3385
3379
  annotations: READ_ONLY_ANNOTATIONS,
3386
3380
  parameters: GetTokenDefsParametersSchema,
3387
3381
  target: "extension",
@@ -3390,7 +3384,7 @@ const TOOL_DEFS = [
3390
3384
  }),
3391
3385
  extTool({
3392
3386
  name: "get_screenshot",
3393
- description: "Capture one bounded rendered PNG asset for an exact node or the current single selection.",
3387
+ description: "Capture a bounded rendered PNG per exact nodeId/nodeIds or selected node. Multi-selection and explicit nodeIds return independent results keyed by nodeId, including per-node errors. Continue remainingNodeIds with nodeIds. Single-node calls retain the flat result. Open each returned PNG to visually verify it.",
3394
3388
  annotations: READ_ONLY_ANNOTATIONS,
3395
3389
  parameters: GetScreenshotParametersSchema,
3396
3390
  target: "extension",
@@ -3398,7 +3392,7 @@ const TOOL_DEFS = [
3398
3392
  }),
3399
3393
  extTool({
3400
3394
  name: "get_structure",
3401
- description: "Read a compact hierarchy and geometry outline for an exact node, exact page id/key, or the current single selection. Every x/y is relative to the node's actual Figma parent; page-query roots are page-relative. The outline includes stable keys on TemPad-managed nodes and exact page context when page identity is supplied. Set options.native for selected native read-back; it does not provide rendered pixels or general appearance.",
3395
+ description: "Read a compact hierarchy and geometry outline for exact nodeId/nodeIds, exact page id/key, or the current selection. Exact roots are preserved before descendants consume the budget; options.depth: 0 returns roots only. Inspect errors and continue remainingNodeIds with nodeIds. Every x/y is relative to the node's actual Figma parent; page-query roots are page-relative. Includes stable keys on TemPad-managed nodes and exact page context for page queries. Set options.native for selected native read-back; this does not provide rendered pixels or general appearance.",
3402
3396
  annotations: READ_ONLY_ANNOTATIONS,
3403
3397
  parameters: GetStructureParametersSchema,
3404
3398
  target: "extension",
@@ -3454,7 +3448,7 @@ function createToolErrorResponse(toolName, error) {
3454
3448
  function buildTroubleshootingText(code, message) {
3455
3449
  const help = [];
3456
3450
  if (isConnectivityToolError(code, message)) help.push(...CONNECTIVITY_TROUBLESHOOTING_LINES);
3457
- if (isSelectionToolError(code, message)) help.push(SELECTION_TROUBLESHOOTING_LINE);
3451
+ if (isSelectionToolError(code, message)) help.push(MULTI_SELECTION_TROUBLESHOOTING_LINE);
3458
3452
  if (code === TEMPAD_MCP_ERROR_CODES.INVALID_CANVAS_SPEC && /verification failed/i.test(message)) help.push(VERIFICATION_TROUBLESHOOTING_LINE);
3459
3453
  return help.length ? `\n\n${help.join("\n")}` : "";
3460
3454
  }
@@ -3462,10 +3456,10 @@ function isConnectivityToolError(code, message) {
3462
3456
  return (code ? CONNECTIVITY_ERROR_CODES.has(code) : false) || /no active tempad dev extension/i.test(message) || /asset server url is not configured/i.test(message) || /\bwebsocket (?:connection )?(?:closed|disconnected|failed|unavailable|error)\b/i.test(message);
3463
3457
  }
3464
3458
  function isSelectionToolError(code, message) {
3465
- return (code ? SELECTION_ERROR_CODES.has(code) : false) || /select exactly one visible node/i.test(message) || /no visible node found/i.test(message);
3459
+ return (code ? SELECTION_ERROR_CODES.has(code) : false) || /select exactly one visible node/i.test(message) || /select one or more visible nodes/i.test(message) || /no visible node found/i.test(message);
3466
3460
  }
3467
3461
  function createCodeToolResponse(payload) {
3468
- return formatToolResult("get_code", payload, isCodeResult, buildGetCodeToolResult);
3462
+ return formatToolResult("get_code", payload, (value) => isCodeResult(value) || isNodeReadBatchResult(value, isCodeResult), buildGetCodeToolResult);
3469
3463
  }
3470
3464
  function createDesignSystemToolResponse(payload) {
3471
3465
  return formatToolResult("get_design_system", payload, isDesignSystemResult, buildGetDesignSystemToolResult);
@@ -3480,7 +3474,7 @@ function createTokenDefsToolResponse(payload) {
3480
3474
  return formatToolResult("get_token_defs", payload, isTokenDefsResult, buildGetTokenDefsToolResult);
3481
3475
  }
3482
3476
  function createScreenshotToolResponse(payload) {
3483
- return formatToolResult("get_screenshot", payload, isScreenshotResult, buildGetScreenshotToolResult);
3477
+ return formatToolResult("get_screenshot", payload, (value) => isScreenshotResult(value) || isNodeReadBatchResult(value, isScreenshotResult), buildGetScreenshotToolResult);
3484
3478
  }
3485
3479
  function formatToolResult(toolName, payload, isValid, build) {
3486
3480
  if (!isValid(payload)) throw new Error(`Invalid ${toolName} payload received from extension.`);
@@ -3498,6 +3492,9 @@ function isApplyCanvasResult(payload) {
3498
3492
  function isCodeResult(payload) {
3499
3493
  return isRecord(payload) && typeof payload.code === "string" && typeof payload.lang === "string" && (payload.assets === void 0 || Array.isArray(payload.assets));
3500
3494
  }
3495
+ function isNodeReadBatchResult(payload, isResult) {
3496
+ return isRecord(payload) && Array.isArray(payload.results) && (payload.remainingNodeIds === void 0 || Array.isArray(payload.remainingNodeIds) && payload.remainingNodeIds.every((id) => typeof id === "string" && id.length > 0)) && payload.results.every((entry) => isRecord(entry) && typeof entry.nodeId === "string" && entry.nodeId.length > 0 && (entry.error === void 0 ? isResult(entry.result) : entry.result === void 0 && isRecord(entry.error) && typeof entry.error.message === "string" && (entry.error.code === void 0 || isTempadMcpErrorCode(entry.error.code))));
3497
+ }
3501
3498
  function isStructureResult(payload) {
3502
3499
  return isRecord(payload) && Array.isArray(payload.roots);
3503
3500
  }
@@ -3556,9 +3553,7 @@ function getBudgetRetryGuidance(toolName) {
3556
3553
  switch (toolName) {
3557
3554
  case "get_design_task":
3558
3555
  case "list_design_sessions":
3559
- case "begin_design":
3560
- case "resume_design":
3561
- case "end_design":
3556
+ case "manage_design_task":
3562
3557
  case "set_design_anchor": return "Retry the same task lifecycle request without changing its identity.";
3563
3558
  case "apply_canvas": return "Submit a smaller desired subtree and retry.";
3564
3559
  case "get_code": return "Reduce selection size or request a smaller nodeId subtree and retry.";
@@ -3571,6 +3566,24 @@ function getBudgetRetryGuidance(toolName) {
3571
3566
  }
3572
3567
  }
3573
3568
  //#endregion
3569
+ //#region src/versioned-extension.ts
3570
+ const NODE_READS = /* @__PURE__ */ new Set([
3571
+ "get_code",
3572
+ "get_screenshot",
3573
+ "get_structure"
3574
+ ]);
3575
+ /** Preserve protocol 13's wire arguments; never silently strip a newer read option. */
3576
+ function assertVersionedToolSupport(protocolVersion, name, args) {
3577
+ if (protocolVersion !== 13) return;
3578
+ if (!(NODE_READS.has(name) && getRecordProperty(args, "nodeIds") !== void 0 || name === "get_structure" && getRecordProperty(getRecordProperty(args, "options"), "depth") === 0 || name === "get_code" && getRecordProperty(args, "resolveTokens") === true)) return;
3579
+ throw Object.assign(/* @__PURE__ */ new Error("This read option requires TemPad Dev extension 0.23.0 or later. Update the extension and reload the Figma tab. Until then, use individual nodeId reads, positive structure depths, and unresolved token references. Existing sessions, design tasks, and canvas writes remain available."), { code: TEMPAD_MCP_ERROR_CODES.EXTENSION_UPGRADE_REQUIRED });
3580
+ }
3581
+ function versionedReadNotice(protocolVersion, name) {
3582
+ if (protocolVersion !== 13) return void 0;
3583
+ if (name === "get_code" || name === "get_token_defs") return "Protocol 13 compatibility: token metadata uses the installed extension’s original semantics; complete modes and alias dependencies are not guaranteed. Use exact nodeId reads for code. Upgrade the extension and reload Figma for consumer-aware resolution and complete definitions.";
3584
+ if (name === "get_structure" || name === "get_screenshot") return "Protocol 13 compatibility: omitted nodeId uses the installed extension’s original selection behavior; structure may use a common ancestor. Use exact nodeId reads to preserve each requested root.";
3585
+ }
3586
+ //#endregion
3574
3587
  //#region src/websocket-server.ts
3575
3588
  async function startExtensionWebSocketServer({ maxPayloadBytes, maxConnections, originPolicy, portCandidates, onPortInUse, onConnectionLimit, onRejectedHandshake }) {
3576
3589
  for (const candidate of portCandidates) {
@@ -3766,17 +3779,9 @@ function enrichToolDefinition(tool) {
3766
3779
  };
3767
3780
  }
3768
3781
  };
3769
- case "resume_design": return {
3770
- ...tool,
3771
- handler: handleResumeDesign
3772
- };
3773
- case "begin_design": return {
3782
+ case "manage_design_task": return {
3774
3783
  ...tool,
3775
- handler: handleBeginDesign
3776
- };
3777
- case "end_design": return {
3778
- ...tool,
3779
- handler: handleEndDesign
3784
+ handler: handleManageDesignTask
3780
3785
  };
3781
3786
  case "get_assets": return {
3782
3787
  ...tool,
@@ -3891,6 +3896,26 @@ function publishDesignTask({ task }) {
3891
3896
  function resolveDesignRoute(ownerId, taskId, active = true, explicitSessionId) {
3892
3897
  return resolveDesignTarget(designTasks, extensionRegistry.list(), extensionRegistry.getActiveId(), ownerId, taskId, active, explicitSessionId);
3893
3898
  }
3899
+ async function handleManageDesignTask(args, ownerId) {
3900
+ switch (args.action) {
3901
+ case "begin": return handleBeginDesign({
3902
+ title: args.title,
3903
+ requestId: args.requestId,
3904
+ sessionId: args.sessionId
3905
+ }, ownerId);
3906
+ case "resume": return handleResumeDesign({
3907
+ taskId: args.taskId,
3908
+ epoch: args.epoch
3909
+ }, ownerId);
3910
+ case "complete":
3911
+ case "cancel": return handleEndDesign({
3912
+ taskId: args.taskId,
3913
+ taskEpoch: args.epoch,
3914
+ outcome: args.action === "complete" ? "completed" : "cancelled",
3915
+ summary: args.summary
3916
+ }, ownerId);
3917
+ }
3918
+ }
3894
3919
  async function handleBeginDesign(args, ownerId) {
3895
3920
  let record = designTasks.retry(ownerId, args.requestId);
3896
3921
  if (record) {
@@ -4002,6 +4027,7 @@ function registerProxiedTool(mcp, tool, ownerId) {
4002
4027
  else if (tool.name === "get_design_system" && getRecordProperty(parsedArgs, "scope") !== "fonts" && getRecordProperty(parsedArgs, "scope") !== "pages" && !getRecordProperty(parsedArgs, "catalogId")) timeoutMs = getDesignSystemTimeoutMs;
4003
4028
  else if (tool.name === "get_structure" && (getRecordProperty(parsedArgs, "pageId") || getRecordProperty(parsedArgs, "pageKey"))) timeoutMs = pageStructureTimeoutMs;
4004
4029
  else if (tool.name === "apply_canvas") timeoutMs = applyCanvasTimeoutMs;
4030
+ if ((tool.name === "get_code" || tool.name === "get_screenshot") && !getRecordProperty(parsedArgs, "nodeId")) timeoutMs += MCP_NODE_READ_BATCH_WORK_BUDGET_MS;
4005
4031
  const legacy = !taskId && !explicitSessionId ? extensionRegistry.getActive() : void 0;
4006
4032
  if (legacy?.legacy) {
4007
4033
  const payload = legacyToolPayload(tool.name, parsed);
@@ -4022,6 +4048,8 @@ function registerProxiedTool(mcp, tool, ownerId) {
4022
4048
  const runtimeIssues = getExtensionRuntimeIssues(activeExt.runtime);
4023
4049
  if (runtimeIssues.length) throw createCodedError(TEMPAD_MCP_ERROR_CODES.RUNTIME_IDENTITY_MISMATCH, `${runtimeIssues.join("; ")}. Rebuild/reload the extension and start a fresh agent task.`);
4024
4050
  const runtime = tool.name === "apply_canvas" ? buildAuthoringRuntimeEvidence(activeExt) : void 0;
4051
+ const protocolVersion = activeExt.runtime.protocolVersion;
4052
+ assertVersionedToolSupport(protocolVersion, tool.name, parsedArgs);
4025
4053
  if (runtime && utf8Bytes({ runtime }) > 2048) throw createCodedError(TEMPAD_MCP_ERROR_CODES.RUNTIME_IDENTITY_MISMATCH, "Runtime evidence exceeds the reserved response budget. No canvas write was dispatched.");
4026
4054
  designTasks.checkOperation(ownerId, session, taskId, tool.name === "apply_canvas");
4027
4055
  const registration = register(activeExt.id, timeoutMs, { waitForDefinitiveResult: tool.name === "apply_canvas" });
@@ -4066,7 +4094,10 @@ function registerProxiedTool(mcp, tool, ownerId) {
4066
4094
  if (typeof pageId === "string") designTasks.updatePage(taskId, pageId);
4067
4095
  }
4068
4096
  }
4069
- return createToolResponse(tool.name, payload, runtime);
4097
+ return createToolResponse(tool.name, payload, {
4098
+ runtime,
4099
+ compatibilityNotice: versionedReadNotice(protocolVersion, tool.name)
4100
+ });
4070
4101
  } catch (error) {
4071
4102
  const normalized = coerceToolError(error);
4072
4103
  log.error({
@@ -4100,11 +4131,7 @@ function registerLocalTool(mcp, tool, ownerId) {
4100
4131
  try {
4101
4132
  const parsed = schema.parse(args);
4102
4133
  const taskId = getRecordProperty(parsed, "taskId");
4103
- if (![
4104
- "end_design",
4105
- "resume_design",
4106
- "get_design_task"
4107
- ].includes(tool.name) && typeof taskId === "string") {
4134
+ if (!["manage_design_task", "get_design_task"].includes(tool.name) && typeof taskId === "string") {
4108
4135
  designTasks.assertEpoch(taskId, ownerId, getRecordProperty(parsed, "taskEpoch"));
4109
4136
  designTasks.touch(taskId, ownerId);
4110
4137
  }
@@ -4119,21 +4146,18 @@ function registerLocalTool(mcp, tool, ownerId) {
4119
4146
  };
4120
4147
  registerToolFn(tool.name, registrationOptions, registerHandler);
4121
4148
  }
4122
- function createToolResponse(toolName, payload, runtime, includeLocalAssetPaths = true) {
4149
+ function createToolResponse(toolName, payload, { runtime, includeLocalAssetPaths = true, compatibilityNotice } = {}) {
4123
4150
  const enrichedPayload = (() => {
4124
- if (toolName === "get_screenshot" && includeLocalAssetPaths) {
4125
- const screenshot = payload;
4126
- return {
4127
- ...screenshot,
4128
- asset: addLocalAssetPath(screenshot.asset)
4151
+ if (includeLocalAssetPaths && (toolName === "get_code" || toolName === "get_screenshot")) {
4152
+ const read = payload;
4153
+ if ("results" in read) return {
4154
+ ...read,
4155
+ results: read.results.map((entry) => entry.result ? {
4156
+ ...entry,
4157
+ result: addReadLocalAssetPaths(entry.result)
4158
+ } : entry)
4129
4159
  };
4130
- }
4131
- if (toolName === "get_code" && includeLocalAssetPaths) {
4132
- const code = payload;
4133
- return code.assets ? {
4134
- ...code,
4135
- assets: code.assets.map((asset) => addLocalAssetPath(asset))
4136
- } : code;
4160
+ return addReadLocalAssetPaths(read);
4137
4161
  }
4138
4162
  if (toolName === "apply_canvas" && runtime) return {
4139
4163
  ...payload,
@@ -4154,9 +4178,20 @@ function createToolResponse(toolName, payload, runtime, includeLocalAssetPaths =
4154
4178
  rawResult = coercePayloadToToolResponse(enrichedPayload);
4155
4179
  }
4156
4180
  else rawResult = coercePayloadToToolResponse(enrichedPayload);
4181
+ if (compatibilityNotice) rawResult = {
4182
+ ...rawResult,
4183
+ content: [{
4184
+ type: "text",
4185
+ text: compatibilityNotice
4186
+ }, ...rawResult.content]
4187
+ };
4157
4188
  const resultBytes = measureCallToolResultBytes(rawResult);
4158
4189
  if (resultBytes > 65536) {
4159
- if (includeLocalAssetPaths && (toolName === "get_code" || toolName === "get_screenshot")) return createToolResponse(toolName, payload, runtime, false);
4190
+ if (includeLocalAssetPaths && (toolName === "get_code" || toolName === "get_screenshot")) return createToolResponse(toolName, payload, {
4191
+ runtime,
4192
+ compatibilityNotice,
4193
+ includeLocalAssetPaths: false
4194
+ });
4160
4195
  log.warn({
4161
4196
  tool: toolName,
4162
4197
  resultBytes,
@@ -4171,7 +4206,7 @@ function buildAuthoringRuntimeEvidence(extension) {
4171
4206
  const issues = getExtensionRuntimeIssues(runtime);
4172
4207
  if (!hubRuntimeIdentity) issues.unshift("Hub runtime identity is unavailable");
4173
4208
  return {
4174
- protocolVersion: 13,
4209
+ protocolVersion: 15,
4175
4210
  locked: false,
4176
4211
  valid: issues.length === 0,
4177
4212
  issues,
@@ -4187,6 +4222,16 @@ function buildAuthoringRuntimeEvidence(extension) {
4187
4222
  }
4188
4223
  };
4189
4224
  }
4225
+ function addReadLocalAssetPaths(result) {
4226
+ if ("asset" in result) return {
4227
+ ...result,
4228
+ asset: addLocalAssetPath(result.asset)
4229
+ };
4230
+ return result.assets ? {
4231
+ ...result,
4232
+ assets: result.assets.map(addLocalAssetPath)
4233
+ } : result;
4234
+ }
4190
4235
  function addLocalAssetPath(asset) {
4191
4236
  const record = assetStore.get(asset.hash);
4192
4237
  return record && existsSync(record.filePath) ? {