pmx-canvas 0.7.2 → 0.8.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.
Files changed (251) hide show
  1. package/.github/extensions/pmx-canvas/THIRD_PARTY_LICENSES.txt +331 -0
  2. package/.github/extensions/pmx-canvas/extension.mjs +25 -172
  3. package/.github/extensions/pmx-canvas/mcp-bootstrap.ts +198 -0
  4. package/.github/extensions/pmx-canvas/runtime.d.mts +41 -0
  5. package/.github/extensions/pmx-canvas/runtime.json +3 -0
  6. package/.github/extensions/pmx-canvas/runtime.mjs +194 -0
  7. package/.github/extensions/pmx-canvas/start-mcp.mjs +51 -0
  8. package/.github/extensions/pmx-canvas/tools.json +2560 -0
  9. package/CHANGELOG.md +60 -0
  10. package/Readme.md +44 -16
  11. package/dist/canvas/fonts/OFL.txt +93 -0
  12. package/dist/canvas/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  13. package/dist/canvas/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  14. package/dist/canvas/fonts/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
  15. package/dist/canvas/fonts/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
  16. package/dist/canvas/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  17. package/dist/canvas/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  18. package/dist/canvas/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  19. package/dist/canvas/fonts/ibm-plex-sans-latin-ext-400-normal.woff2 +0 -0
  20. package/dist/canvas/fonts/ibm-plex-sans-latin-ext-500-normal.woff2 +0 -0
  21. package/dist/canvas/fonts/ibm-plex-sans-latin-ext-600-normal.woff2 +0 -0
  22. package/dist/canvas/global.css +844 -710
  23. package/dist/canvas/index.js +92 -90
  24. package/dist/canvas/mcp-app.html +7878 -0
  25. package/dist/canvas/mermaid-entry.js +1 -1
  26. package/dist/canvas/surface-theme.css +151 -46
  27. package/dist/json-render/index.css +1 -1
  28. package/dist/json-render/index.js +55 -55
  29. package/dist/types/cli/commands/record.d.ts +1 -1
  30. package/dist/types/client/canvas/ChoiceMenu.d.ts +13 -0
  31. package/dist/types/client/canvas/NodeContextMark.d.ts +24 -0
  32. package/dist/types/client/canvas/SessionReceipt.d.ts +3 -1
  33. package/dist/types/client/icons.d.ts +1 -2
  34. package/dist/types/client/mcp-app/index.d.ts +1 -0
  35. package/dist/types/client/nodes/McpAppNode.d.ts +2 -1
  36. package/dist/types/client/nodes/ax-node-actions.d.ts +2 -2
  37. package/dist/types/client/nodes/markdown-sanitize.d.ts +2 -0
  38. package/dist/types/client/nodes/use-workbench-asset.d.ts +2 -0
  39. package/dist/types/client/nodes/viewer-runtime-state.d.ts +1 -0
  40. package/dist/types/client/state/attention-store.d.ts +0 -5
  41. package/dist/types/client/state/canvas-store.d.ts +2 -0
  42. package/dist/types/client/state/context-status-store.d.ts +53 -0
  43. package/dist/types/client/state/intent-bridge.d.ts +4 -1
  44. package/dist/types/client/state/near-pin-store.d.ts +16 -0
  45. package/dist/types/client/state/presence-store.d.ts +5 -0
  46. package/dist/types/client/state/session-store.d.ts +33 -3
  47. package/dist/types/client/state/workbench-transport.d.ts +16 -0
  48. package/dist/types/client/theme/tokens.d.ts +1 -3
  49. package/dist/types/client/types.d.ts +9 -0
  50. package/dist/types/json-render/renderer/index.d.ts +2 -1
  51. package/dist/types/json-render/server.d.ts +3 -1
  52. package/dist/types/mcp/app-server.d.ts +3 -0
  53. package/dist/types/mcp/canvas-access.d.ts +1 -1
  54. package/dist/types/mcp/canvas-app.d.ts +4 -0
  55. package/dist/types/mcp/workbench-app.d.ts +4 -0
  56. package/dist/types/server/agent-presence.d.ts +1 -1
  57. package/dist/types/server/ax-state.d.ts +1 -1
  58. package/dist/types/server/canvas-db.d.ts +8 -0
  59. package/dist/types/server/canvas-geometry.d.ts +25 -0
  60. package/dist/types/server/canvas-operations.d.ts +1 -11
  61. package/dist/types/server/canvas-state.d.ts +25 -3
  62. package/dist/types/server/context-brief.d.ts +8 -1
  63. package/dist/types/server/context-reads.d.ts +30 -7
  64. package/dist/types/server/index.d.ts +6 -1
  65. package/dist/types/server/mcp-app-runtime.d.ts +1 -0
  66. package/dist/types/server/operations/http.d.ts +2 -0
  67. package/dist/types/server/operations/invoker.d.ts +4 -2
  68. package/dist/types/server/operations/ops/nodes.d.ts +0 -6
  69. package/dist/types/server/server.d.ts +1 -0
  70. package/dist/types/server/spatial-analysis.d.ts +2 -0
  71. package/dist/types/shared/agent-context.d.ts +22 -0
  72. package/dist/types/shared/agent-presence.d.ts +3 -10
  73. package/dist/types/shared/ax-surface-protocol.d.ts +2 -0
  74. package/dist/types/shared/canvas-app.d.ts +54 -0
  75. package/dist/types/shared/themes.d.ts +1 -1
  76. package/docs/RELEASE.md +7 -3
  77. package/docs/agent-plugin.md +123 -0
  78. package/docs/ax-host-adapter-contract.md +13 -2
  79. package/docs/ax-state-contract.md +40 -0
  80. package/docs/cli.md +7 -2
  81. package/docs/design/AgentContext.dc.html +186 -0
  82. package/docs/design/Before.dc.html +208 -0
  83. package/docs/design/BoardPins.dc.html +151 -0
  84. package/docs/design/Chrome.dc.html +208 -0
  85. package/docs/design/Context.dc.html +239 -0
  86. package/docs/design/Flows.dc.html +181 -0
  87. package/docs/design/Home.dc.html +209 -0
  88. package/docs/design/HomeGraph.dc.html +211 -0
  89. package/docs/design/HomeMap.dc.html +117 -0
  90. package/docs/design/HomeTeam.dc.html +176 -0
  91. package/docs/design/Light.dc.html +28 -0
  92. package/docs/design/Main.dc.html +280 -0
  93. package/docs/design/NearPin.dc.html +260 -0
  94. package/docs/design/Pane600.dc.html +120 -0
  95. package/docs/design/Relations.dc.html +297 -0
  96. package/docs/design/Themes.dc.html +121 -0
  97. package/docs/design/TokenSystem.dc.html +136 -0
  98. package/docs/design/Tokens.dc.html +163 -0
  99. package/docs/design/Types1.dc.html +177 -0
  100. package/docs/design/Types2.dc.html +226 -0
  101. package/docs/design/Types3.dc.html +195 -0
  102. package/docs/design/Uses.dc.html +152 -0
  103. package/docs/design/Vision.dc.html +116 -0
  104. package/docs/design/Zoom.dc.html +82 -0
  105. package/docs/design/canvas.json +274 -0
  106. package/docs/design.md +214 -0
  107. package/docs/environment.md +1 -1
  108. package/docs/http-api.md +80 -15
  109. package/docs/mcp.md +198 -3
  110. package/docs/node-types.md +34 -10
  111. package/docs/plans/plan-009-tech-debt-backlog.md +1 -1
  112. package/docs/plans/plan-015-design-foundation-wave-0.md +177 -0
  113. package/docs/plans/plan-016-context-made-visible-wave-1.md +148 -0
  114. package/docs/product-vision-2026-09.md +47 -7
  115. package/docs/screenshot.png +0 -0
  116. package/docs/sdk.md +1 -0
  117. package/package.json +10 -4
  118. package/plugins/pmx-canvas/LICENSE +21 -0
  119. package/plugins/pmx-canvas/THIRD_PARTY_LICENSES.txt +331 -0
  120. package/plugins/pmx-canvas/assets/preview.png +0 -0
  121. package/plugins/pmx-canvas/com.github.copilot/extensions/pmx-canvas/extension.mjs +930 -0
  122. package/plugins/pmx-canvas/com.github.copilot/extensions/pmx-canvas/runtime.json +3 -0
  123. package/plugins/pmx-canvas/com.github.copilot/extensions/pmx-canvas/runtime.mjs +194 -0
  124. package/plugins/pmx-canvas/com.github.copilot/extensions/pmx-canvas/steering-delivery.mjs +79 -0
  125. package/plugins/pmx-canvas/mcp.json +12 -0
  126. package/plugins/pmx-canvas/plugin.json +24 -0
  127. package/plugins/pmx-canvas/runtime.json +3 -0
  128. package/plugins/pmx-canvas/runtime.mjs +194 -0
  129. package/plugins/pmx-canvas/start-mcp.mjs +51 -0
  130. package/plugins/pmx-canvas/tools.json +2560 -0
  131. package/skills/pmx-canvas/SKILL.md +31 -16
  132. package/skills/pmx-canvas/evals/evals.json +69 -0
  133. package/skills/pmx-canvas/references/full-reference.md +14 -10
  134. package/skills/pmx-canvas/references/github-copilot-app-adapter.md +20 -8
  135. package/skills/pmx-canvas/references/installing-pmx-canvas.md +76 -4
  136. package/skills/pmx-canvas-testing/SKILL.md +54 -4
  137. package/src/cli/commands/copilot.ts +5 -0
  138. package/src/cli/commands/view.ts +1 -1
  139. package/src/cli/index.ts +8 -3
  140. package/src/client/App.tsx +6 -1
  141. package/src/client/canvas/AgentPresenceLayer.tsx +3 -3
  142. package/src/client/canvas/AnnotationLayer.tsx +1 -1
  143. package/src/client/canvas/CanvasNode.tsx +208 -220
  144. package/src/client/canvas/CanvasViewport.tsx +6 -2
  145. package/src/client/canvas/ChoiceMenu.tsx +122 -0
  146. package/src/client/canvas/CommandBar.tsx +25 -23
  147. package/src/client/canvas/CommandPalette.tsx +3 -2
  148. package/src/client/canvas/ContextMenu.tsx +11 -0
  149. package/src/client/canvas/EdgeLayer.tsx +1 -1
  150. package/src/client/canvas/ExportDialog.tsx +33 -6
  151. package/src/client/canvas/FeedbackDialog.tsx +10 -8
  152. package/src/client/canvas/IntentLayer.tsx +2 -2
  153. package/src/client/canvas/Minimap.tsx +12 -7
  154. package/src/client/canvas/NodeContextMark.tsx +156 -0
  155. package/src/client/canvas/SessionPanel.tsx +4 -7
  156. package/src/client/canvas/SessionReceipt.tsx +114 -17
  157. package/src/client/canvas/ShortcutOverlay.tsx +6 -1
  158. package/src/client/canvas/SnapshotPanel.tsx +11 -2
  159. package/src/client/canvas/ToolRail.tsx +58 -108
  160. package/src/client/canvas/TopBar.tsx +16 -11
  161. package/src/client/icons.tsx +2 -12
  162. package/src/client/mcp-app/index.tsx +137 -0
  163. package/src/client/mcp-app/style.css +10 -0
  164. package/src/client/nodes/AttachmentNode.tsx +8 -1
  165. package/src/client/nodes/AxStepControls.tsx +1 -1
  166. package/src/client/nodes/ContextNode.tsx +9 -9
  167. package/src/client/nodes/ExtAppFrame.tsx +13 -8
  168. package/src/client/nodes/FileNode.tsx +8 -5
  169. package/src/client/nodes/ImageNode.tsx +4 -2
  170. package/src/client/nodes/InlineMarkdownEditor.tsx +2 -1
  171. package/src/client/nodes/LedgerNode.tsx +2 -2
  172. package/src/client/nodes/MarkdownNode.tsx +44 -9
  173. package/src/client/nodes/McpAppNode.tsx +22 -4
  174. package/src/client/nodes/PromptNode.tsx +5 -17
  175. package/src/client/nodes/ResponseNode.tsx +3 -15
  176. package/src/client/nodes/StatusNode.tsx +2 -2
  177. package/src/client/nodes/StatusSummary.tsx +3 -1
  178. package/src/client/nodes/TraceNode.tsx +6 -4
  179. package/src/client/nodes/WebpageNode.tsx +1 -1
  180. package/src/client/nodes/ax-node-actions.ts +2 -2
  181. package/src/client/nodes/iframe-document-url.ts +3 -2
  182. package/src/client/nodes/markdown-sanitize.ts +10 -0
  183. package/src/client/nodes/surface-url.ts +10 -0
  184. package/src/client/nodes/use-ax-surface-bridge.ts +4 -2
  185. package/src/client/nodes/use-surface-frame.ts +3 -1
  186. package/src/client/nodes/use-workbench-asset.ts +26 -0
  187. package/src/client/nodes/viewer-runtime-state.ts +78 -0
  188. package/src/client/state/attention-bridge.ts +0 -8
  189. package/src/client/state/attention-store.ts +0 -17
  190. package/src/client/state/canvas-store.ts +7 -2
  191. package/src/client/state/context-status-store.ts +66 -0
  192. package/src/client/state/human-store.ts +2 -0
  193. package/src/client/state/iframe-mode.ts +5 -0
  194. package/src/client/state/intent-bridge.ts +24 -6
  195. package/src/client/state/near-pin-store.ts +53 -0
  196. package/src/client/state/presence-store.ts +5 -10
  197. package/src/client/state/session-store.ts +106 -9
  198. package/src/client/state/sse-bridge.ts +26 -7
  199. package/src/client/state/theme-override.ts +1 -1
  200. package/src/client/state/workbench-transport.ts +36 -0
  201. package/src/client/theme/global.css +844 -710
  202. package/src/client/theme/surface-theme.css +151 -46
  203. package/src/client/theme/tokens.ts +7 -11
  204. package/src/client/types.ts +10 -0
  205. package/src/json-render/renderer/index.tsx +58 -38
  206. package/src/json-render/server.ts +79 -15
  207. package/src/mcp/app-server.ts +64 -0
  208. package/src/mcp/canvas-access.ts +14 -11
  209. package/src/mcp/canvas-app.ts +318 -0
  210. package/src/mcp/server.ts +1 -1
  211. package/src/mcp/workbench-app.ts +211 -0
  212. package/src/server/agent-presence.ts +45 -6
  213. package/src/server/ax-context.ts +1 -1
  214. package/src/server/ax-state.ts +1 -1
  215. package/src/server/board-export.ts +5 -2
  216. package/src/server/canvas-db.ts +46 -12
  217. package/src/server/canvas-geometry.ts +64 -0
  218. package/src/server/canvas-operations.ts +6 -24
  219. package/src/server/canvas-state.ts +105 -15
  220. package/src/server/canvas-validation.ts +19 -4
  221. package/src/server/context-brief.ts +39 -2
  222. package/src/server/context-reads.ts +86 -15
  223. package/src/server/demo-state.json +31 -31
  224. package/src/server/html-surface.ts +4 -5
  225. package/src/server/index.ts +19 -3
  226. package/src/server/mcp-app-runtime.ts +11 -0
  227. package/src/server/operations/composites.ts +4 -3
  228. package/src/server/operations/http.ts +4 -4
  229. package/src/server/operations/invoker.ts +13 -4
  230. package/src/server/operations/ops/ax-read.ts +1 -1
  231. package/src/server/operations/ops/ax-timeline.ts +37 -0
  232. package/src/server/operations/ops/boards.ts +1 -1
  233. package/src/server/operations/ops/canvas-wire.ts +3 -6
  234. package/src/server/operations/ops/intent.ts +31 -2
  235. package/src/server/operations/ops/json-render.ts +1 -1
  236. package/src/server/operations/ops/nodes.ts +8 -76
  237. package/src/server/operations/ops/query.ts +8 -2
  238. package/src/server/operations/ops/snapshots.ts +4 -1
  239. package/src/server/operations/ops/viewport.ts +29 -5
  240. package/src/server/operations/registry.ts +38 -4
  241. package/src/server/scope-fence.ts +55 -10
  242. package/src/server/server.ts +86 -6
  243. package/src/server/spatial-analysis.ts +2 -2
  244. package/src/server/workboard.ts +6 -1
  245. package/src/{server → shared}/agent-context.ts +2 -2
  246. package/src/shared/agent-presence.ts +3 -15
  247. package/src/shared/ax-surface-protocol.ts +3 -0
  248. package/src/shared/canvas-app.ts +62 -0
  249. package/src/shared/themes.ts +5 -5
  250. package/src/client/canvas/FocusFieldLayer.tsx +0 -116
  251. package/src/client/canvas/kind-colors.ts +0 -23
@@ -3134,7 +3134,7 @@
3134
3134
  "actor": "agent",
3135
3135
  "source": "api"
3136
3136
  },
3137
- "contentRevision": 41,
3137
+ "contentRevision": 46,
3138
3138
  "kind": "markdown",
3139
3139
  "title": "Sprint 41 — canvas polish",
3140
3140
  "content": "Three nodes, one frame. Moving the frame moves the children; ungrouping leaves them exactly where they are.\n\n- Group children keep their own positions by default\n- `childLayout` opts into auto-packing\n- The frame is stored as `data.children` on the group",
@@ -3174,7 +3174,7 @@
3174
3174
  "actor": "agent",
3175
3175
  "source": "api"
3176
3176
  },
3177
- "contentRevision": 42,
3177
+ "contentRevision": 47,
3178
3178
  "kind": "status",
3179
3179
  "title": "Sprint state",
3180
3180
  "content": null,
@@ -3215,7 +3215,7 @@
3215
3215
  "actor": "agent",
3216
3216
  "source": "api"
3217
3217
  },
3218
- "contentRevision": 43,
3218
+ "contentRevision": 48,
3219
3219
  "kind": "trace",
3220
3220
  "title": "canvas_group",
3221
3221
  "content": null,
@@ -3256,7 +3256,7 @@
3256
3256
  "actor": "agent",
3257
3257
  "source": "api"
3258
3258
  },
3259
- "contentRevision": 44,
3259
+ "contentRevision": 45,
3260
3260
  "kind": "group",
3261
3261
  "title": "Sprint 41",
3262
3262
  "content": null,
@@ -3292,7 +3292,7 @@
3292
3292
  "actor": "agent",
3293
3293
  "source": "api"
3294
3294
  },
3295
- "contentRevision": 45,
3295
+ "contentRevision": 49,
3296
3296
  "kind": "markdown",
3297
3297
  "title": "⑦ HTML primitives",
3298
3298
  "content": "All 21 generated communication surfaces — self-contained sandboxed documents, no build step.",
@@ -3377,7 +3377,7 @@
3377
3377
  "actor": "agent",
3378
3378
  "source": "api"
3379
3379
  },
3380
- "contentRevision": 46,
3380
+ "contentRevision": 50,
3381
3381
  "kind": "html",
3382
3382
  "title": "How should the demo board be generated?",
3383
3383
  "content": "Side-by-side options with tradeoffs, pros, cons, and code or evidence snippets.",
@@ -3487,7 +3487,7 @@
3487
3487
  "actor": "agent",
3488
3488
  "source": "api"
3489
3489
  },
3490
- "contentRevision": 47,
3490
+ "contentRevision": 51,
3491
3491
  "kind": "html",
3492
3492
  "title": "Demo board rebuild",
3493
3493
  "content": "Implementation plan with milestones, data flow, code checkpoints, and risks.",
@@ -3566,7 +3566,7 @@
3566
3566
  "actor": "agent",
3567
3567
  "source": "api"
3568
3568
  },
3569
- "contentRevision": 48,
3569
+ "contentRevision": 52,
3570
3570
  "kind": "html",
3571
3571
  "title": "Review — auto-fit floor",
3572
3572
  "content": "Annotated PR/code review sheet with severity-colored findings and diff excerpts.",
@@ -3654,7 +3654,7 @@
3654
3654
  "actor": "agent",
3655
3655
  "source": "api"
3656
3656
  },
3657
- "contentRevision": 49,
3657
+ "contentRevision": 53,
3658
3658
  "kind": "html",
3659
3659
  "title": "PR — replace the demo board",
3660
3660
  "content": "Reviewer-ready PR narrative with motivation, before/after, file tour, test plan, and rollout notes.",
@@ -3766,7 +3766,7 @@
3766
3766
  "actor": "agent",
3767
3767
  "source": "api"
3768
3768
  },
3769
- "contentRevision": 50,
3769
+ "contentRevision": 54,
3770
3770
  "kind": "html",
3771
3771
  "title": "Canvas server map",
3772
3772
  "content": "Module or architecture map with boxes, relationships, entry points, and hot paths.",
@@ -3895,7 +3895,7 @@
3895
3895
  "actor": "agent",
3896
3896
  "source": "api"
3897
3897
  },
3898
- "contentRevision": 51,
3898
+ "contentRevision": 55,
3899
3899
  "kind": "html",
3900
3900
  "title": "Walkthrough — creating a node",
3901
3901
  "content": "Guided code-path map with modules, ordered file steps, snippets, key files, and gotchas.",
@@ -3998,7 +3998,7 @@
3998
3998
  "actor": "agent",
3999
3999
  "source": "api"
4000
4000
  },
4001
- "contentRevision": 52,
4001
+ "contentRevision": 56,
4002
4002
  "kind": "html",
4003
4003
  "title": "Board typography directions",
4004
4004
  "content": "Visual design directions, tokens, swatches, type samples, and rationale.",
@@ -4081,7 +4081,7 @@
4081
4081
  "actor": "agent",
4082
4082
  "source": "api"
4083
4083
  },
4084
- "contentRevision": 53,
4084
+ "contentRevision": 57,
4085
4085
  "kind": "html",
4086
4086
  "title": "Node titlebar states",
4087
4087
  "content": "Contact sheet for component variants, states, sizes, and accessibility notes.",
@@ -4179,7 +4179,7 @@
4179
4179
  "actor": "agent",
4180
4180
  "source": "api"
4181
4181
  },
4182
- "contentRevision": 54,
4182
+ "contentRevision": 58,
4183
4183
  "kind": "html",
4184
4184
  "title": "Node expand transition",
4185
4185
  "content": "Throwaway interaction or motion sandbox with a live stage, controls, annotations, and copyable config.",
@@ -4265,7 +4265,7 @@
4265
4265
  "actor": "agent",
4266
4266
  "source": "api"
4267
4267
  },
4268
- "contentRevision": 55,
4268
+ "contentRevision": 59,
4269
4269
  "kind": "html",
4270
4270
  "title": "Release pipeline",
4271
4271
  "content": "Clickable flowchart for pipelines, user journeys, process diagrams, and failure paths.",
@@ -4360,7 +4360,7 @@
4360
4360
  "actor": "agent",
4361
4361
  "source": "api"
4362
4362
  },
4363
- "contentRevision": 56,
4363
+ "contentRevision": 60,
4364
4364
  "kind": "html",
4365
4365
  "title": "Why a spatial canvas",
4366
4366
  "content": "Arrow-key HTML deck with sections, speaker notes, and copyable JSON payload. Slides: Chat is a queue, work is a graph, The canvas is the agent’s working memory, Pinning is the steering wheel.",
@@ -4478,7 +4478,7 @@
4478
4478
  "actor": "agent",
4479
4479
  "source": "api"
4480
4480
  },
4481
- "contentRevision": 57,
4481
+ "contentRevision": 61,
4482
4482
  "kind": "html",
4483
4483
  "title": "PMX Canvas 0.4.7 briefing",
4484
4484
  "content": "PowerPoint-style fullscreen-ready HTML presentation with slide navigation, progress, speaker notes, and presentation metadata. Slides: Where we are, What changed in 0.4.7, Next.",
@@ -4643,7 +4643,7 @@
4643
4643
  "actor": "agent",
4644
4644
  "source": "api"
4645
4645
  },
4646
- "contentRevision": 58,
4646
+ "contentRevision": 62,
4647
4647
  "kind": "html",
4648
4648
  "title": "Figures — the collaboration loop",
4649
4649
  "content": "Inline SVG figure sheet with captions and per-figure SVG copy/export controls.",
@@ -4749,7 +4749,7 @@
4749
4749
  "actor": "agent",
4750
4750
  "source": "api"
4751
4751
  },
4752
- "contentRevision": 59,
4752
+ "contentRevision": 63,
4753
4753
  "kind": "html",
4754
4754
  "title": "How context pins work",
4755
4755
  "content": "Readable explainer with TLDR, collapsible steps, annotated snippets, FAQ, and glossary.",
@@ -4870,7 +4870,7 @@
4870
4870
  "actor": "agent",
4871
4871
  "source": "api"
4872
4872
  },
4873
- "contentRevision": 60,
4873
+ "contentRevision": 64,
4874
4874
  "kind": "html",
4875
4875
  "title": "Blank ext-app tiles on WebKit",
4876
4876
  "content": "Post-incident report with impact metrics, minute-by-minute timeline, root cause, log excerpts, and action checklist.",
@@ -4956,7 +4956,7 @@
4956
4956
  "actor": "agent",
4957
4957
  "source": "api"
4958
4958
  },
4959
- "contentRevision": 61,
4959
+ "contentRevision": 65,
4960
4960
  "kind": "html",
4961
4961
  "title": "Weekly canvas status",
4962
4962
  "content": "Skimmable report with metrics, shipped/slipped lists, blockers, and next actions.",
@@ -5042,7 +5042,7 @@
5042
5042
  "actor": "agent",
5043
5043
  "source": "api"
5044
5044
  },
5045
- "contentRevision": 62,
5045
+ "contentRevision": 66,
5046
5046
  "kind": "html",
5047
5047
  "title": "Post-0.4.7 triage",
5048
5048
  "content": "Draggable Now/Next/Later/Cut board with copy-as-markdown export.",
@@ -5134,7 +5134,7 @@
5134
5134
  "actor": "agent",
5135
5135
  "source": "api"
5136
5136
  },
5137
- "contentRevision": 63,
5137
+ "contentRevision": 67,
5138
5138
  "kind": "html",
5139
5139
  "title": "Canvas feature flags",
5140
5140
  "content": "Form-like editor for flags or structured config with dependency warnings and copy-diff export.",
@@ -5203,7 +5203,7 @@
5203
5203
  "actor": "agent",
5204
5204
  "source": "api"
5205
5205
  },
5206
- "contentRevision": 64,
5206
+ "contentRevision": 68,
5207
5207
  "kind": "html",
5208
5208
  "title": "Board summary prompt",
5209
5209
  "content": "Side-by-side prompt/template editor with live variable previews and copy export.",
@@ -5256,7 +5256,7 @@
5256
5256
  "actor": "agent",
5257
5257
  "source": "api"
5258
5258
  },
5259
- "contentRevision": 65,
5259
+ "contentRevision": 69,
5260
5260
  "kind": "html",
5261
5261
  "title": "Agent board",
5262
5262
  "content": "Live agent work board: hand the agent tasks, watch status, steer, and run bounded task loops.",
@@ -5337,7 +5337,7 @@
5337
5337
  "actor": "agent",
5338
5338
  "source": "api"
5339
5339
  },
5340
- "contentRevision": 77,
5340
+ "contentRevision": 85,
5341
5341
  "kind": "html",
5342
5342
  "title": "Release flow",
5343
5343
  "content": "HTML primitive: ax-flow\nLive task-flow control panel: a step diagram with an explicit loop-back, per-step status, and a one-click materialize onto the board.\nRelease flow PMX HTML primitive / ax-flow Release flow Live task-flow control panel: a step diagram with an explicit loop-back, per-step status, and a one-click materialize onto the board. Copy JSON Copy prompt AX bridge unavailable This flow is not running as an AX-enabled canvas node, so its controls are inert. Release flow Each step is a canvas AX work item. Materialize drops the same flow onto the board as real nodes. loops back to step 1 · max 3 runs Run the flow Queue every step A step is queued once — after that its status control advances it (todo → in-progress → done). or run the whole flow as a bounded loop: max runs Start loop Steer Queue steering message Queued for the agent's next turn — steering is recorded on the timeline, it does not wake a running agent. Loop run 0 of 0 Each run is its own work item. When you mark the current run done , the surface opens the next run...",
@@ -5373,7 +5373,7 @@
5373
5373
  "actor": "agent",
5374
5374
  "source": "api"
5375
5375
  },
5376
- "contentRevision": 67,
5376
+ "contentRevision": 71,
5377
5377
  "kind": "markdown",
5378
5378
  "title": "⑧ Agent at work",
5379
5379
  "content": "A task caught mid-flight: one work item per step, status chips on the nodes, controls that steer the agent.",
@@ -5454,7 +5454,7 @@
5454
5454
  "actor": "agent",
5455
5455
  "source": "api"
5456
5456
  },
5457
- "contentRevision": 78,
5457
+ "contentRevision": 86,
5458
5458
  "kind": "markdown",
5459
5459
  "title": "1. Reproduce",
5460
5460
  "content": "Ran the publish gate 20× in a loop. Fails 3 in 20, always on the registry probe.",
@@ -5500,7 +5500,7 @@
5500
5500
  "actor": "agent",
5501
5501
  "source": "api"
5502
5502
  },
5503
- "contentRevision": 79,
5503
+ "contentRevision": 87,
5504
5504
  "kind": "markdown",
5505
5505
  "title": "2. Fix",
5506
5506
  "content": "Retry the probe with backoff instead of failing the gate on the first timeout.",
@@ -5592,7 +5592,7 @@
5592
5592
  "actor": "agent",
5593
5593
  "source": "api"
5594
5594
  },
5595
- "contentRevision": 81,
5595
+ "contentRevision": 83,
5596
5596
  "kind": "markdown",
5597
5597
  "title": "4. Ship",
5598
5598
  "content": "Land the patch, then watch the next three releases.",
@@ -5628,7 +5628,7 @@
5628
5628
  "actor": "agent",
5629
5629
  "source": "api"
5630
5630
  },
5631
- "contentRevision": 82,
5631
+ "contentRevision": 88,
5632
5632
  "kind": "markdown",
5633
5633
  "title": "How to read this band",
5634
5634
  "content": "Each step is a real **AX work item**, so the chip on a step node is the\nagent’s live status — it moves as the agent works.\n\nThe buttons in each step footer steer it: **Start**, **Done** and\n**Blocked** write that step’s work item, which the agent reads back from\n`canvas://ax-work`.\n\nStep 2 is pinned, so `canvas://pinned-context` hands the agent the\nstep it is actually on.",
@@ -226,12 +226,11 @@ export function buildMermaidSurfaceHtml(
226
226
  ): string {
227
227
  // srcdoc-rendered surfaces in hosts that block sub-frame subresources (the
228
228
  // Claude Code desktop browser blocks the script request too, not just the
229
- // frame document) get the renderer embedded as a data: URL — no network
230
- // request for the host to block, and base64 has no `<` for the HTML script
231
- // parser to trip on (a 3.5MB bundle inlined as literal script text hits the
232
- // `<!--` script-data-escaped states and renders as page text).
229
+ // frame document) get an inline bootstrap. Assigning decoded script text
230
+ // avoids HTML parser escaped states (`<!--`, `</script>`) in the bundle,
231
+ // without requiring data: script URLs that MCP App hosts may prohibit.
233
232
  const entry = inlineEntry
234
- ? `<script src="data:text/javascript;charset=utf-8;base64,${Buffer.from(inlineEntry, 'utf-8').toString('base64')}"></script>`
233
+ ? `<script>(()=>{const s=document.createElement('script');s.textContent=new TextDecoder().decode(Uint8Array.from(atob('${Buffer.from(inlineEntry, 'utf-8').toString('base64')}'),c=>c.charCodeAt(0)));document.head.appendChild(s)})()</script>`
235
234
  : '<script src="/canvas/mermaid-entry.js"></script>';
236
235
  return `<pre class="mermaid-source" data-fit="${fit}" data-frame-token="${sanitizeFrameToken(frameToken)}" style="display:none">${escapeSurfaceHtml(source)}</pre>${entry}`;
237
236
  }
@@ -218,6 +218,8 @@ export class PmxCanvas extends EventEmitter {
218
218
  async start(options?: {
219
219
  open?: boolean;
220
220
  automationWebView?: boolean | CanvasAutomationWebViewOptions;
221
+ /** Embedded startup must not launch external MCP backends from saved nodes. */
222
+ allowExternalMcp?: boolean;
221
223
  /**
222
224
  * Bind a nearby free port when the preferred one is taken instead of
223
225
  * failing. Default false (an explicit SDK port is honored exactly); the
@@ -225,7 +227,11 @@ export class PmxCanvas extends EventEmitter {
225
227
  */
226
228
  allowPortFallback?: boolean;
227
229
  }): Promise<void> {
228
- const base = startCanvasServer({ port: this._port, allowPortFallback: options?.allowPortFallback ?? false });
230
+ const base = startCanvasServer({
231
+ port: this._port,
232
+ allowPortFallback: options?.allowPortFallback ?? false,
233
+ allowExternalMcp: options?.allowExternalMcp,
234
+ });
229
235
  if (!base) {
230
236
  throw new Error(`Failed to start canvas server on port ${this._port}`);
231
237
  }
@@ -900,6 +906,11 @@ export class PmxCanvas extends EventEmitter {
900
906
  return canvasState.getContextReads(limit);
901
907
  }
902
908
 
909
+ /** Per node on a board: when an agent last read its content, who, and the content revision it read. */
910
+ getNodeReadStatus(board?: string): ReturnType<typeof canvasState.getNodeReadStatus> {
911
+ return canvasState.getNodeReadStatus(board ?? canvasState.activeBoardId);
912
+ }
913
+
903
914
  listWorkItems(): PmxAxWorkItem[] {
904
915
  return canvasState.getWorkItems();
905
916
  }
@@ -1298,8 +1309,13 @@ export class PmxCanvas extends EventEmitter {
1298
1309
  return applyCanvasNodeUpdates(updates);
1299
1310
  }
1300
1311
 
1301
- setContextPins(nodeIds: string[], mode: 'set' | 'add' | 'remove' = 'set'): { count: number; nodeIds: string[] } {
1302
- const result = setCanvasContextPins(nodeIds, mode);
1312
+ /** `reason` is kept with newly pinned nodes and shown to the human on hover. */
1313
+ setContextPins(
1314
+ nodeIds: string[],
1315
+ mode: 'set' | 'add' | 'remove' = 'set',
1316
+ reason?: string,
1317
+ ): { count: number; nodeIds: string[] } {
1318
+ const result = setCanvasContextPins(nodeIds, mode, reason);
1303
1319
  emitPrimaryWorkbenchEvent('context-pins-changed', { count: result.count, nodeIds: result.nodeIds });
1304
1320
  return result;
1305
1321
  }
@@ -1,3 +1,4 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
1
2
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
3
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
3
4
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
@@ -18,6 +19,13 @@ import type { McpUiClientCapabilities, McpUiResourceCsp, McpUiResourceMeta } fro
18
19
  import { getToolUiResourceUri } from '@modelcontextprotocol/ext-apps/app-bridge';
19
20
  import { normalizeExtAppToolResult } from './ext-app-tool-result.js';
20
21
 
22
+ // A restriction follows async rehydration spawned by an embedded operation,
23
+ // without disabling independent requests from the local workbench.
24
+ const externalMcpDisabled = new AsyncLocalStorage<boolean>();
25
+ export function withoutExternalMcp<T>(run: () => T): T {
26
+ return externalMcpDisabled.run(true, run);
27
+ }
28
+
21
29
  export interface ExternalMcpHttpTransportConfig {
22
30
  type: 'http';
23
31
  url: string;
@@ -210,6 +218,9 @@ async function createSession(
210
218
  serverName?: string,
211
219
  timeoutMs?: number,
212
220
  ): Promise<McpAppSession> {
221
+ if (externalMcpDisabled.getStore()) {
222
+ throw new Error('Open external MCP apps from the local PMX workbench; embedded actions cannot launch them.');
223
+ }
213
224
  const transport = buildTransport(transportConfig);
214
225
  const client = new Client({ name: 'pmx-canvas-app-host', version: '0.1.0' }, { capabilities: clientCapabilities });
215
226
  await client.connect(transport, requestOptions(timeoutMs));
@@ -323,14 +323,15 @@ export const compositeToolDefinitions: CompositeToolDefinition[] = [
323
323
  {
324
324
  toolName: 'canvas_ax_timeline',
325
325
  description:
326
- 'Read or write the bounded PMX AX timeline. Action "read" returns recent agent-events, evidence, and steering messages plus counts (limit); "record-event" records a normalized agent-event (kind prompt|assistant-message|tool-start|tool-result|failure|approval|steering, summary, detail, data); "add-evidence" records an evidence item (kind logs|tool-result|screenshot|file|diff|test-output, title, body, ref); "send-steering" records a steering message (message); "reads" returns the context read log — which canvas context each agent read and which pinned nodes reached it — with a per-consumer summary (limit). Timeline rows persist for diagnostics/continuity but are not restored by snapshots; exposed via canvas://ax-timeline.',
327
- actionSummary: 'read | record-event | add-evidence | send-steering | reads',
326
+ 'Read or write the bounded PMX AX timeline. Action "read" returns recent agent-events, evidence, and steering messages plus counts (limit); "record-event" records a normalized agent-event (kind prompt|assistant-message|tool-start|tool-result|failure|approval|steering, summary, detail, data); "add-evidence" records an evidence item (kind logs|tool-result|screenshot|file|diff|test-output, title, body, ref); "send-steering" records a steering message (message); "reads" returns the context read log — which canvas context each agent read and which pinned nodes reached it — with a per-consumer summary (limit); "read-status" returns, per node on a board, when an agent last read its content, who, and the content revision it read (board). Timeline rows persist for diagnostics/continuity but are not restored by snapshots; exposed via canvas://ax-timeline.',
327
+ actionSummary: 'read | record-event | add-evidence | send-steering | reads | read-status',
328
328
  actions: {
329
329
  read: 'ax.timeline.get',
330
330
  'record-event': 'ax.event.record',
331
331
  'add-evidence': 'ax.evidence.add',
332
332
  'send-steering': 'ax.steer',
333
333
  reads: 'ax.reads.list',
334
+ 'read-status': 'ax.reads.status',
334
335
  },
335
336
  },
336
337
  {
@@ -346,7 +347,7 @@ export const compositeToolDefinitions: CompositeToolDefinition[] = [
346
347
  {
347
348
  toolName: 'canvas_intent',
348
349
  description:
349
- 'Ghost Cursor of Intent — announce the spatial move you are ABOUT to make so the canvas paints a faint pre-commit placeholder (legibility: the human sees the next move forming, and can veto it). Action "signal" registers an intent (kind create|move|connect|remove|edit; pass position for create/move, nodeId for move/edit/remove, edge for connect; optional label, reason, confidence 0..1, seq, ttlMs, and a stable id); "update" patches a live intent by id; "clear" abandons/dissolves it. To make veto authoritative, pass the returned id as intentId on the real canvas_node/canvas_edge/canvas_group/canvas_render mutation: vetoed or expired intents are rejected, and a successful linked mutation settles the ghost automatically. Intents are ephemeral presence: never persisted, never snapshotted, auto-expire (~8s).',
350
+ 'Ghost Cursor of Intent — announce the spatial move you are ABOUT to make so the canvas paints a faint pre-commit placeholder (legibility: the human sees the next move forming, and can veto it). Action "signal" registers an intent (kind create|move|connect|remove|edit; pass position for move — omit it for create to ghost where the canvas will place the node, and the linked create lands there — nodeId for move/edit/remove, edge for connect; optional label, reason, confidence 0..1, seq, ttlMs, and a stable id); "update" patches a live intent by id; "clear" abandons/dissolves it. To make veto authoritative, pass the returned id as intentId on the real canvas_node/canvas_edge/canvas_group/canvas_render mutation: vetoed or expired intents are rejected, and a successful linked mutation settles the ghost automatically. Intents are ephemeral presence: never persisted, never snapshotted, auto-expire (~8s).',
350
351
  actionSummary: 'signal | update | clear',
351
352
  actions: {
352
353
  signal: 'intent.signal',
@@ -20,7 +20,7 @@ function responseJson(data: unknown, status = 200): Response {
20
20
  });
21
21
  }
22
22
 
23
- function matchPath(template: string, pathname: string): Record<string, string> | null {
23
+ export function matchOperationPath(template: string, pathname: string): Record<string, string> | null {
24
24
  const templateSegments = template.split('/');
25
25
  const pathSegments = pathname.split('/');
26
26
  if (templateSegments.length !== pathSegments.length) return null;
@@ -58,7 +58,7 @@ export async function readJsonValue(req: Request): Promise<unknown> {
58
58
  }
59
59
  }
60
60
 
61
- async function defaultReadInput(
61
+ export async function readOperationInput(
62
62
  req: Request,
63
63
  params: Record<string, string>,
64
64
  url: URL,
@@ -80,12 +80,12 @@ export async function dispatchOperationRoute(req: Request, url: URL): Promise<Re
80
80
  for (const op of listOperations()) {
81
81
  const route = op.http;
82
82
  if (!route || route.method !== req.method) continue;
83
- const params = matchPath(route.path, url.pathname);
83
+ const params = matchOperationPath(route.path, url.pathname);
84
84
  if (!params) continue;
85
85
  try {
86
86
  const input = route.readInput
87
87
  ? await route.readInput(req, params, url)
88
- : await defaultReadInput(req, params, url);
88
+ : await readOperationInput(req, params, url);
89
89
  // The workbench marks its own HTTP calls: a human dragging/editing in
90
90
  // the browser is not agent activity, so it never synthesizes an
91
91
  // auto-ghost. Everything else (CLI, scripts, adapters) counts as agent.
@@ -32,13 +32,17 @@ export class LocalOperationInvoker implements OperationInvoker {
32
32
  private readonly proxiedRead: boolean;
33
33
 
34
34
  /** `source` labels this caller's agent presence ('mcp', 'sdk', …). */
35
- constructor(source = 'api') {
35
+ constructor(
36
+ source = 'api',
37
+ private readonly allowExternalMcp = true,
38
+ ) {
36
39
  this.source = agentSourceLabel(source);
37
40
  this.proxiedRead = source === 'mcp';
38
41
  }
39
42
 
40
43
  async invoke(name: string, input: Record<string, unknown>): Promise<unknown> {
41
- return await executeOperation(name, defaultPresenceSource(name, input, this.source), {
44
+ const args = this.allowExternalMcp ? input : { ...input, allowExternalMcp: false };
45
+ return await executeOperation(name, defaultPresenceSource(name, args, this.source), {
42
46
  source: this.source,
43
47
  proxiedRead: this.proxiedRead,
44
48
  });
@@ -56,14 +60,19 @@ export class HttpOperationInvoker implements OperationInvoker {
56
60
  private readonly proxiedRead: boolean;
57
61
 
58
62
  /** `source` labels this caller's agent presence on the server ('cli', 'mcp', …). */
59
- constructor(baseUrl: string, source = 'api') {
63
+ constructor(
64
+ baseUrl: string,
65
+ source = 'api',
66
+ private readonly allowExternalMcp = true,
67
+ ) {
60
68
  this.baseUrl = baseUrl.replace(/\/$/, '');
61
69
  this.source = agentSourceLabel(source);
62
70
  this.proxiedRead = source === 'mcp';
63
71
  }
64
72
 
65
73
  async invoke(name: string, rawInput: Record<string, unknown>): Promise<unknown> {
66
- const input = defaultPresenceSource(name, rawInput, this.source);
74
+ const args = this.allowExternalMcp ? rawInput : { ...rawInput, allowExternalMcp: false };
75
+ const input = defaultPresenceSource(name, args, this.source);
67
76
  const op = getOperation(name);
68
77
  const route = op.http;
69
78
  if (!route) throw new OperationError(`Operation "${name}" has no HTTP route.`, 400);
@@ -13,7 +13,7 @@
13
13
  */
14
14
  import { agentPresence } from '../../agent-presence.js';
15
15
  import { z } from 'zod';
16
- import { buildAgentContextPreamble, serializeNodeForAgentContext } from '../../agent-context.js';
16
+ import { buildAgentContextPreamble, serializeNodeForAgentContext } from '../../../shared/agent-context.js';
17
17
  import { buildCanvasAxContext, buildCanvasAxSurfaceSnapshot } from '../../ax-context.js';
18
18
  import { applyAxInteraction } from '../../ax-interaction.js';
19
19
  import {
@@ -502,6 +502,10 @@ const axReadsRecordShape = {
502
502
  source: z.string().optional().describe('Transport label (default "api").'),
503
503
  pinnedNodeIds: z.array(z.string()).optional().describe('Pins at read time; defaults to the current pins.'),
504
504
  deliveredNodeIds: z.array(z.string()).describe('Pinned ids present in what the agent received.'),
505
+ readNodeIds: z
506
+ .array(z.string())
507
+ .optional()
508
+ .describe('Ids of every serialized node in what the agent received; defaults to deliveredNodeIds.'),
505
509
  bytes: z.number().int().nonnegative().describe('Size of what the agent received.'),
506
510
  boardId: z.string().nullable().optional().describe('Board that was read, captured before delivery.'),
507
511
  };
@@ -527,6 +531,7 @@ const axReadsRecordOperation = defineOperation<z.infer<typeof axReadsRecordSchem
527
531
  agentId: input.agentId ?? null,
528
532
  pinnedNodeIds: input.pinnedNodeIds ?? [...canvasState.contextPinnedNodeIds],
529
533
  deliveredNodeIds: input.deliveredNodeIds,
534
+ ...(input.readNodeIds ? { readNodeIds: input.readNodeIds } : {}),
530
535
  bytes: input.bytes,
531
536
  },
532
537
  input.boardId === undefined ? canvasState.activeBoardId : input.boardId,
@@ -535,6 +540,37 @@ const axReadsRecordOperation = defineOperation<z.infer<typeof axReadsRecordSchem
535
540
  },
536
541
  });
537
542
 
543
+ const axReadsStatusShape = {
544
+ board: z.string().optional().describe('Board id; defaults to the open board.'),
545
+ };
546
+ const axReadsStatusSchema = z.looseObject(axReadsStatusShape);
547
+
548
+ /**
549
+ * Per node: when an agent last read its content, who, and at which revision
550
+ * (vs the node's revision now); and per pin: who pinned it, when and why.
551
+ */
552
+ const axReadsStatusOperation = defineOperation<z.infer<typeof axReadsStatusSchema>, Record<string, unknown>>({
553
+ name: 'ax.reads.status',
554
+ mutates: false,
555
+ input: axReadsStatusSchema,
556
+ inputShape: axReadsStatusShape,
557
+ http: {
558
+ method: 'GET',
559
+ path: '/api/canvas/ax/context-status',
560
+ },
561
+ handler: (input) => {
562
+ const boardId =
563
+ typeof input.board === 'string' && input.board.trim() ? input.board.trim() : canvasState.activeBoardId;
564
+ const pins =
565
+ boardId === canvasState.activeBoardId
566
+ ? canvasState.getContextPinMeta()
567
+ : boardId
568
+ ? (canvasState.readBoard(boardId, false)?.state.contextPinMeta ?? {})
569
+ : {};
570
+ return { ok: true, boardId, nodes: canvasState.getNodeReadStatus(boardId), pins };
571
+ },
572
+ });
573
+
538
574
  export const axTimelineOperations: Operation[] = [
539
575
  axEventRecordOperation,
540
576
  axEvidenceAddOperation,
@@ -545,4 +581,5 @@ export const axTimelineOperations: Operation[] = [
545
581
  axCommandInvokeOperation,
546
582
  axReadsListOperation,
547
583
  axReadsRecordOperation,
584
+ axReadsStatusOperation,
548
585
  ];
@@ -15,7 +15,7 @@ import { z } from 'zod';
15
15
  import { normalizeBoardCategory } from '../../../shared/boards.js';
16
16
  import { canvasState, type CanvasLayout } from '../../canvas-state.js';
17
17
  import { openCanvasBoard } from '../../canvas-operations.js';
18
- import { summarizeNodeForAgentContext } from '../../agent-context.js';
18
+ import { summarizeNodeForAgentContext } from '../../../shared/agent-context.js';
19
19
  import { defineOperation, OperationError, type Operation, type OperationContext } from '../types.js';
20
20
 
21
21
  export function boardsPayload(): Record<string, unknown> {
@@ -70,15 +70,15 @@ const applyUpdatesSchema = z.looseObject(applyUpdatesShape);
70
70
 
71
71
  const applyUpdatesOperation = defineOperation<z.infer<typeof applyUpdatesSchema>, Record<string, unknown>>({
72
72
  name: 'canvas.apply-updates',
73
- mutates: false,
73
+ mutates: true,
74
74
  input: applyUpdatesSchema,
75
75
  inputShape: applyUpdatesShape,
76
76
  http: {
77
77
  method: 'POST',
78
78
  path: '/api/canvas/update',
79
79
  },
80
- // Legacy wire: one layout update only when something actually applied.
81
- handler: (input, ctx) => {
80
+ // The registry emits the layout update, as for other mutating operations.
81
+ handler: (input) => {
82
82
  const body: Record<string, unknown> = input;
83
83
  const updates = Array.isArray(body.updates) ? body.updates : [];
84
84
  const result =
@@ -94,9 +94,6 @@ const applyUpdatesOperation = defineOperation<z.infer<typeof applyUpdatesSchema>
94
94
  return suppressedResult;
95
95
  })()
96
96
  : applyCanvasNodeUpdates(updates);
97
- if (result.applied > 0) {
98
- ctx.emit('canvas-layout-update', { layout: canvasState.getLayout() });
99
- }
100
97
  return { ok: true, ...result };
101
98
  },
102
99
  });
@@ -15,9 +15,12 @@
15
15
  */
16
16
  import { z } from 'zod';
17
17
  import { INTENT_EDGE_TYPES, INTENT_KINDS } from '../../../shared/ax-intent.js';
18
+ import { canvasState } from '../../canvas-state.js';
18
19
  import { intentRegistry } from '../../intent-registry.js';
20
+ import { findOpenCanvasPosition } from '../../placement.js';
19
21
  import { readJsonValue } from '../http.js';
20
22
  import { defineOperation, OperationError, type Operation } from '../types.js';
23
+ import { defaultNodeSize } from './nodes.js';
21
24
 
22
25
  const positionShape = z.object({ x: z.number(), y: z.number() });
23
26
 
@@ -28,7 +31,11 @@ const intentSignalShape = {
28
31
  .enum(INTENT_KINDS)
29
32
  .optional()
30
33
  .describe('create | move | connect | remove | edit — the move about to be made.'),
31
- position: positionShape.optional().describe('World coords: where a create forms, or the destination of a move.'),
34
+ position: positionShape
35
+ .optional()
36
+ .describe(
37
+ 'World coords: the destination of a move, or where a create forms. Omit it for a create to ghost where the canvas will place the node.',
38
+ ),
32
39
  nodeId: z.string().optional().describe('The existing node a move/edit/remove targets.'),
33
40
  edge: z
34
41
  .object({ from: z.string(), to: z.string(), type: z.enum(INTENT_EDGE_TYPES) })
@@ -46,6 +53,24 @@ const intentSignalShape = {
46
53
 
47
54
  const intentSignalSchema = z.looseObject(intentSignalShape);
48
55
 
56
+ /**
57
+ * Where a create without a position will land: the same auto-placement the
58
+ * create ops use, with live create ghosts as obstacles so staged ghosts do not
59
+ * stack. An agent announcing work before it knows the layout must not have to
60
+ * guess a position (a guessed 0,0 put every first ghost in the top-left corner).
61
+ */
62
+ function openPositionForCreate(nodeType: unknown): { x: number; y: number } {
63
+ const size = defaultNodeSize(typeof nodeType === 'string' ? nodeType : 'markdown');
64
+ const ghosts = intentRegistry
65
+ .list()
66
+ .flatMap((intent) =>
67
+ intent.kind === 'create' && intent.position
68
+ ? [{ position: intent.position, size: defaultNodeSize(intent.nodeType ?? 'markdown') }]
69
+ : [],
70
+ );
71
+ return findOpenCanvasPosition([...canvasState.getLayout().nodes, ...ghosts], size.width, size.height);
72
+ }
73
+
49
74
  const intentSignalOperation = defineOperation<z.infer<typeof intentSignalSchema>, Record<string, unknown>>({
50
75
  name: 'intent.signal',
51
76
  mutates: false,
@@ -53,7 +78,11 @@ const intentSignalOperation = defineOperation<z.infer<typeof intentSignalSchema>
53
78
  inputShape: intentSignalShape,
54
79
  http: { method: 'POST', path: '/api/canvas/ax/intent' },
55
80
  handler: (input) => {
56
- const intent = intentRegistry.signal(input);
81
+ const placed =
82
+ input.kind === 'create' && !input.position
83
+ ? { ...input, position: openPositionForCreate(input.nodeType) }
84
+ : input;
85
+ const intent = intentRegistry.signal(placed);
57
86
  return { ok: true, intent } as unknown as Record<string, unknown>;
58
87
  },
59
88
  });