@agent-native/core 0.84.35 → 0.84.36

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 (187) hide show
  1. package/README.md +15 -51
  2. package/corpus/core/CHANGELOG.md +12 -0
  3. package/corpus/core/docs/content/actions.mdx +17 -24
  4. package/corpus/core/docs/content/agent-surfaces.mdx +59 -56
  5. package/corpus/core/docs/content/cloneable-saas.mdx +3 -3
  6. package/corpus/core/docs/content/faq.mdx +4 -4
  7. package/corpus/core/docs/content/getting-started.mdx +246 -204
  8. package/corpus/core/docs/content/key-concepts.mdx +9 -9
  9. package/corpus/core/docs/content/locales/ar-SA/cloneable-saas.mdx +3 -3
  10. package/corpus/core/docs/content/locales/ar-SA/faq.mdx +4 -4
  11. package/corpus/core/docs/content/locales/ar-SA/getting-started.mdx +148 -214
  12. package/corpus/core/docs/content/locales/ar-SA/pure-agent-apps.mdx +4 -9
  13. package/corpus/core/docs/content/locales/ar-SA/template-chat.mdx +2 -2
  14. package/corpus/core/docs/content/locales/ar-SA/using-your-agent.mdx +2 -2
  15. package/corpus/core/docs/content/locales/de-DE/cloneable-saas.mdx +3 -3
  16. package/corpus/core/docs/content/locales/de-DE/faq.mdx +4 -4
  17. package/corpus/core/docs/content/locales/de-DE/getting-started.mdx +145 -211
  18. package/corpus/core/docs/content/locales/de-DE/pure-agent-apps.mdx +4 -9
  19. package/corpus/core/docs/content/locales/de-DE/template-chat.mdx +2 -2
  20. package/corpus/core/docs/content/locales/de-DE/using-your-agent.mdx +2 -2
  21. package/corpus/core/docs/content/locales/es-ES/cloneable-saas.mdx +3 -3
  22. package/corpus/core/docs/content/locales/es-ES/faq.mdx +4 -4
  23. package/corpus/core/docs/content/locales/es-ES/getting-started.mdx +148 -214
  24. package/corpus/core/docs/content/locales/es-ES/pure-agent-apps.mdx +4 -9
  25. package/corpus/core/docs/content/locales/es-ES/template-chat.mdx +2 -2
  26. package/corpus/core/docs/content/locales/es-ES/using-your-agent.mdx +2 -2
  27. package/corpus/core/docs/content/locales/fr-FR/cloneable-saas.mdx +2 -2
  28. package/corpus/core/docs/content/locales/fr-FR/faq.mdx +4 -4
  29. package/corpus/core/docs/content/locales/fr-FR/getting-started.mdx +146 -212
  30. package/corpus/core/docs/content/locales/fr-FR/pure-agent-apps.mdx +4 -9
  31. package/corpus/core/docs/content/locales/fr-FR/template-chat.mdx +2 -2
  32. package/corpus/core/docs/content/locales/fr-FR/using-your-agent.mdx +2 -2
  33. package/corpus/core/docs/content/locales/hi-IN/cloneable-saas.mdx +3 -3
  34. package/corpus/core/docs/content/locales/hi-IN/faq.mdx +4 -4
  35. package/corpus/core/docs/content/locales/hi-IN/getting-started.mdx +149 -215
  36. package/corpus/core/docs/content/locales/hi-IN/pure-agent-apps.mdx +8 -13
  37. package/corpus/core/docs/content/locales/hi-IN/template-chat.mdx +2 -2
  38. package/corpus/core/docs/content/locales/hi-IN/using-your-agent.mdx +2 -2
  39. package/corpus/core/docs/content/locales/ja-JP/cloneable-saas.mdx +2 -2
  40. package/corpus/core/docs/content/locales/ja-JP/faq.mdx +4 -4
  41. package/corpus/core/docs/content/locales/ja-JP/getting-started.mdx +144 -210
  42. package/corpus/core/docs/content/locales/ja-JP/pure-agent-apps.mdx +8 -13
  43. package/corpus/core/docs/content/locales/ja-JP/template-chat.mdx +2 -2
  44. package/corpus/core/docs/content/locales/ja-JP/using-your-agent.mdx +2 -2
  45. package/corpus/core/docs/content/locales/ko-KR/cloneable-saas.mdx +3 -3
  46. package/corpus/core/docs/content/locales/ko-KR/faq.mdx +4 -4
  47. package/corpus/core/docs/content/locales/ko-KR/getting-started.mdx +146 -212
  48. package/corpus/core/docs/content/locales/ko-KR/pure-agent-apps.mdx +8 -13
  49. package/corpus/core/docs/content/locales/ko-KR/template-chat.mdx +2 -2
  50. package/corpus/core/docs/content/locales/ko-KR/using-your-agent.mdx +2 -2
  51. package/corpus/core/docs/content/locales/pt-BR/cloneable-saas.mdx +3 -3
  52. package/corpus/core/docs/content/locales/pt-BR/faq.mdx +4 -4
  53. package/corpus/core/docs/content/locales/pt-BR/getting-started.mdx +145 -211
  54. package/corpus/core/docs/content/locales/pt-BR/pure-agent-apps.mdx +4 -9
  55. package/corpus/core/docs/content/locales/pt-BR/template-chat.mdx +2 -2
  56. package/corpus/core/docs/content/locales/pt-BR/using-your-agent.mdx +2 -2
  57. package/corpus/core/docs/content/locales/zh-CN/cloneable-saas.mdx +3 -3
  58. package/corpus/core/docs/content/locales/zh-CN/faq.mdx +4 -4
  59. package/corpus/core/docs/content/locales/zh-CN/getting-started.mdx +158 -209
  60. package/corpus/core/docs/content/locales/zh-CN/pure-agent-apps.mdx +4 -9
  61. package/corpus/core/docs/content/locales/zh-CN/template-chat.mdx +2 -2
  62. package/corpus/core/docs/content/locales/zh-CN/using-your-agent.mdx +2 -2
  63. package/corpus/core/docs/content/locales/zh-TW/cloneable-saas.mdx +3 -3
  64. package/corpus/core/docs/content/locales/zh-TW/faq.mdx +4 -4
  65. package/corpus/core/docs/content/locales/zh-TW/getting-started.mdx +158 -212
  66. package/corpus/core/docs/content/locales/zh-TW/pure-agent-apps.mdx +4 -9
  67. package/corpus/core/docs/content/locales/zh-TW/template-chat.mdx +2 -2
  68. package/corpus/core/docs/content/locales/zh-TW/using-your-agent.mdx +2 -2
  69. package/corpus/core/docs/content/native-chat-ui.mdx +17 -32
  70. package/corpus/core/docs/content/pure-agent-apps.mdx +46 -26
  71. package/corpus/core/docs/content/template-chat.mdx +8 -8
  72. package/corpus/core/docs/content/using-your-agent.mdx +2 -2
  73. package/corpus/core/docs/content/what-is-agent-native.mdx +6 -6
  74. package/corpus/core/package.json +1 -1
  75. package/corpus/core/src/cli/skills.ts +7 -9
  76. package/corpus/core/src/client/MultiTabAssistantChat.tsx +2 -0
  77. package/corpus/core/src/client/RunStuckBanner.tsx +172 -18
  78. package/corpus/core/src/client/blocks/library/wireframe-kit.tsx +57 -9
  79. package/corpus/core/src/client/blocks/library/wireframe.tsx +3 -18
  80. package/corpus/core/src/client/chat/widgets/builtin-tool-renderers.tsx +28 -32
  81. package/corpus/core/src/db/schema.ts +5 -0
  82. package/corpus/core/src/styles/blocks.css +27 -6
  83. package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +1 -4
  84. package/corpus/templates/content/actions/list-trashed-content-databases.ts +1 -1
  85. package/corpus/templates/plan/.agents/skills/visual-plan/references/wireframe.md +7 -9
  86. package/corpus/templates/plan/.agents/skills/visual-recap/references/wireframe.md +7 -9
  87. package/dist/cli/skills.d.ts +1 -1
  88. package/dist/cli/skills.d.ts.map +1 -1
  89. package/dist/cli/skills.js +7 -9
  90. package/dist/cli/skills.js.map +1 -1
  91. package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
  92. package/dist/client/MultiTabAssistantChat.js +1 -1
  93. package/dist/client/MultiTabAssistantChat.js.map +1 -1
  94. package/dist/client/RunStuckBanner.d.ts +13 -1
  95. package/dist/client/RunStuckBanner.d.ts.map +1 -1
  96. package/dist/client/RunStuckBanner.js +123 -16
  97. package/dist/client/RunStuckBanner.js.map +1 -1
  98. package/dist/client/blocks/library/wireframe-kit.d.ts +6 -6
  99. package/dist/client/blocks/library/wireframe-kit.d.ts.map +1 -1
  100. package/dist/client/blocks/library/wireframe-kit.js +52 -5
  101. package/dist/client/blocks/library/wireframe-kit.js.map +1 -1
  102. package/dist/client/blocks/library/wireframe.d.ts.map +1 -1
  103. package/dist/client/blocks/library/wireframe.js +1 -11
  104. package/dist/client/blocks/library/wireframe.js.map +1 -1
  105. package/dist/client/chat/widgets/builtin-tool-renderers.d.ts.map +1 -1
  106. package/dist/client/chat/widgets/builtin-tool-renderers.js +27 -31
  107. package/dist/client/chat/widgets/builtin-tool-renderers.js.map +1 -1
  108. package/dist/collab/routes.d.ts +2 -2
  109. package/dist/db/schema.d.ts +2 -1
  110. package/dist/db/schema.d.ts.map +1 -1
  111. package/dist/db/schema.js +3 -2
  112. package/dist/db/schema.js.map +1 -1
  113. package/dist/resources/handlers.d.ts +3 -3
  114. package/dist/server/transcribe-voice.d.ts +1 -1
  115. package/dist/styles/blocks.css +27 -6
  116. package/docs/content/actions.mdx +17 -24
  117. package/docs/content/agent-surfaces.mdx +59 -56
  118. package/docs/content/cloneable-saas.mdx +3 -3
  119. package/docs/content/faq.mdx +4 -4
  120. package/docs/content/getting-started.mdx +246 -204
  121. package/docs/content/key-concepts.mdx +9 -9
  122. package/docs/content/locales/ar-SA/cloneable-saas.mdx +3 -3
  123. package/docs/content/locales/ar-SA/faq.mdx +4 -4
  124. package/docs/content/locales/ar-SA/getting-started.mdx +148 -214
  125. package/docs/content/locales/ar-SA/pure-agent-apps.mdx +4 -9
  126. package/docs/content/locales/ar-SA/template-chat.mdx +2 -2
  127. package/docs/content/locales/ar-SA/using-your-agent.mdx +2 -2
  128. package/docs/content/locales/de-DE/cloneable-saas.mdx +3 -3
  129. package/docs/content/locales/de-DE/faq.mdx +4 -4
  130. package/docs/content/locales/de-DE/getting-started.mdx +145 -211
  131. package/docs/content/locales/de-DE/pure-agent-apps.mdx +4 -9
  132. package/docs/content/locales/de-DE/template-chat.mdx +2 -2
  133. package/docs/content/locales/de-DE/using-your-agent.mdx +2 -2
  134. package/docs/content/locales/es-ES/cloneable-saas.mdx +3 -3
  135. package/docs/content/locales/es-ES/faq.mdx +4 -4
  136. package/docs/content/locales/es-ES/getting-started.mdx +148 -214
  137. package/docs/content/locales/es-ES/pure-agent-apps.mdx +4 -9
  138. package/docs/content/locales/es-ES/template-chat.mdx +2 -2
  139. package/docs/content/locales/es-ES/using-your-agent.mdx +2 -2
  140. package/docs/content/locales/fr-FR/cloneable-saas.mdx +2 -2
  141. package/docs/content/locales/fr-FR/faq.mdx +4 -4
  142. package/docs/content/locales/fr-FR/getting-started.mdx +146 -212
  143. package/docs/content/locales/fr-FR/pure-agent-apps.mdx +4 -9
  144. package/docs/content/locales/fr-FR/template-chat.mdx +2 -2
  145. package/docs/content/locales/fr-FR/using-your-agent.mdx +2 -2
  146. package/docs/content/locales/hi-IN/cloneable-saas.mdx +3 -3
  147. package/docs/content/locales/hi-IN/faq.mdx +4 -4
  148. package/docs/content/locales/hi-IN/getting-started.mdx +149 -215
  149. package/docs/content/locales/hi-IN/pure-agent-apps.mdx +8 -13
  150. package/docs/content/locales/hi-IN/template-chat.mdx +2 -2
  151. package/docs/content/locales/hi-IN/using-your-agent.mdx +2 -2
  152. package/docs/content/locales/ja-JP/cloneable-saas.mdx +2 -2
  153. package/docs/content/locales/ja-JP/faq.mdx +4 -4
  154. package/docs/content/locales/ja-JP/getting-started.mdx +144 -210
  155. package/docs/content/locales/ja-JP/pure-agent-apps.mdx +8 -13
  156. package/docs/content/locales/ja-JP/template-chat.mdx +2 -2
  157. package/docs/content/locales/ja-JP/using-your-agent.mdx +2 -2
  158. package/docs/content/locales/ko-KR/cloneable-saas.mdx +3 -3
  159. package/docs/content/locales/ko-KR/faq.mdx +4 -4
  160. package/docs/content/locales/ko-KR/getting-started.mdx +146 -212
  161. package/docs/content/locales/ko-KR/pure-agent-apps.mdx +8 -13
  162. package/docs/content/locales/ko-KR/template-chat.mdx +2 -2
  163. package/docs/content/locales/ko-KR/using-your-agent.mdx +2 -2
  164. package/docs/content/locales/pt-BR/cloneable-saas.mdx +3 -3
  165. package/docs/content/locales/pt-BR/faq.mdx +4 -4
  166. package/docs/content/locales/pt-BR/getting-started.mdx +145 -211
  167. package/docs/content/locales/pt-BR/pure-agent-apps.mdx +4 -9
  168. package/docs/content/locales/pt-BR/template-chat.mdx +2 -2
  169. package/docs/content/locales/pt-BR/using-your-agent.mdx +2 -2
  170. package/docs/content/locales/zh-CN/cloneable-saas.mdx +3 -3
  171. package/docs/content/locales/zh-CN/faq.mdx +4 -4
  172. package/docs/content/locales/zh-CN/getting-started.mdx +158 -209
  173. package/docs/content/locales/zh-CN/pure-agent-apps.mdx +4 -9
  174. package/docs/content/locales/zh-CN/template-chat.mdx +2 -2
  175. package/docs/content/locales/zh-CN/using-your-agent.mdx +2 -2
  176. package/docs/content/locales/zh-TW/cloneable-saas.mdx +3 -3
  177. package/docs/content/locales/zh-TW/faq.mdx +4 -4
  178. package/docs/content/locales/zh-TW/getting-started.mdx +158 -212
  179. package/docs/content/locales/zh-TW/pure-agent-apps.mdx +4 -9
  180. package/docs/content/locales/zh-TW/template-chat.mdx +2 -2
  181. package/docs/content/locales/zh-TW/using-your-agent.mdx +2 -2
  182. package/docs/content/native-chat-ui.mdx +17 -32
  183. package/docs/content/pure-agent-apps.mdx +46 -26
  184. package/docs/content/template-chat.mdx +8 -8
  185. package/docs/content/using-your-agent.mdx +2 -2
  186. package/docs/content/what-is-agent-native.mdx +6 -6
  187. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"wireframe.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/wireframe.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,MAAM,EACN,WAAW,EACX,oBAAoB,EACpB,SAAS,EACT,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,eAAe,EACf,YAAY,GAGb,MAAM,uBAAuB,CAAC;AA+C/B,MAAM,eAAe,GAA4C;IAC/D,6EAA6E;IAC7E,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,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H,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,EAAE,GAAG,EAAiC;IAC1E,OAAO,KAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AACxD,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAgB;IACvD,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,eAAe;IACvB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,eAAe;IACrB,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,WAAW;IAClB,WAAW,EACT,4JAA4J;IAC9J,8EAA8E;IAC9E,2EAA2E;IAC3E,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;CAClD,CAAC,CAAC","sourcesContent":["import { IconPencil } from \"@tabler/icons-react\";\nimport {\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\n\nimport { ltrCodeBlockProps } from \"../code-block-direction.js\";\nimport { defineBlock } from \"../types.js\";\nimport type {\n BlockReadProps,\n BlockEditProps,\n BlockRenderContext,\n} from \"../types.js\";\nimport { useBlockCopy } from \"./block-copy.js\";\nimport {\n sanitizeWireframeCss,\n sanitizeWireframeHtml,\n scopeDesignCss,\n} from \"./sanitize-html.js\";\nimport { renderWireframeIconHtml } from \"./wireframe-icons.js\";\nimport {\n HTML_ROUGH_SELECTOR,\n KitConfigContext,\n RoughOverlay,\n Screen,\n renderNodes,\n toggleWireframeStyle,\n useIsDark,\n useWireframeStyle,\n} from \"./wireframe-kit.js\";\nimport {\n wireframeSchema,\n wireframeMdx,\n type WireframeData,\n type WireframeSurface,\n} from \"./wireframe.config.js\";\n\n/**\n * Shared `wireframe` block — a hand-drawn low-fi mockup of one screen, rendered\n * from either a declarative kit tree (`data.screen`) or a self-contained HTML\n * mockup (`data.html`), inside a surface-locked frame (desktop/mobile/popover/\n * panel/browser) with a rough.js sketch overlay. Lives in core so any app can\n * register it (it originated in the plan template).\n *\n * DECOUPLING from the plan original:\n * - Theme: `useIsDark()` reads `document.documentElement.classList` instead of\n * `next-themes` (the MermaidBlock precedent), so core stays dependency-light.\n * - HTML sanitize: the HTML path runs `data.html`/`data.css` through the\n * app-injected `ctx.sanitizeHtml`. If no sanitizer is wired the HTML path is\n * skipped (kit tree or an empty frame renders) — core never injects unsanitized\n * author HTML.\n * - The plan-only prototype runtime, design-element selection, and legacy region\n * fallback are intentionally NOT ported; those are plan-canvas features, not\n * part of the document-block render. The kit element vocabulary, the `--wf-*`\n * token contract, and the `.plan-wf` / `[data-rough]` classes the overlay\n * measures are preserved exactly.\n *\n * The section carries the app-neutral `an-block` class plus the legacy\n * `plan-block` class so plan renders byte-identically while any other app gets\n * the theme-token treatment from core's `blocks.css`.\n *\n * The wireframe is canvas / agent-patch edited (node-addressable content patches\n * applied server-side), NOT schema-form edited in the browser — so `Edit` reuses\n * the same static render as `Read`, mirroring the plan `WireframeEditor`.\n */\n\ntype SurfacePreset = {\n width: number;\n /**\n * Floor height for the surface. The frame is AUTO-HEIGHT (content-driven): it\n * grows past this when content is tall and shrinks toward its content height\n * when content is short, but never collapses below this floor — so an empty or\n * near-empty frame still reads as that surface instead of a thin sliver. This\n * is a `min-height`, not a fixed `height`: it is the lower bound the old fixed\n * preset height used to also be the UPPER bound, which is what left a big empty\n * vertical band below short content (e.g. a header + one dropdown padded to a\n * tall fixed aspect).\n */\n minHeight: number;\n radius: number;\n};\n\nconst SURFACE_PRESETS: Record<WireframeSurface, SurfacePreset> = {\n // mobile keeps a tall floor: a phone frame reads as a phone even when short.\n mobile: { width: 300, minHeight: 360, radius: 30 },\n desktop: { width: 840, minHeight: 200, radius: 14 },\n browser: { width: 900, minHeight: 200, radius: 14 },\n popover: { width: 360, minHeight: 120, radius: 16 },\n panel: { width: 420, minHeight: 200, radius: 16 },\n};\n\nfunction isHtmlData(data: WireframeData): boolean {\n return typeof data.html === \"string\" && data.html.trim().length > 0;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Shared frame shell: surface-locked WIDTH + auto (content-driven) height + */\n/* theme + rough overlay. The frame keeps each surface's footprint and chrome */\n/* but fits its content height instead of padding to a fixed aspect, so short */\n/* content yields a short frame and tall content grows. Pass `canvasSize` to */\n/* opt a fixed-aspect canvas artboard back into a hard pixel height. */\n/* -------------------------------------------------------------------------- */\n\nfunction ArtboardFrame({\n surface,\n compact,\n canvasSize,\n canvasWidth,\n skeleton,\n renderMode,\n roughOverlay = true,\n selector,\n caption,\n render,\n}: {\n surface: WireframeSurface;\n compact?: boolean;\n /**\n * Force a FIXED pixel height instead of the auto-height (content-driven)\n * default. Reserved for fixed-aspect canvas artboards (pan/zoom). Document-flow\n * wireframes — what recaps render — leave this unset so the frame fits content.\n */\n canvasSize?: number;\n canvasWidth?: number;\n skeleton?: boolean;\n renderMode?: \"wireframe\" | \"design\";\n roughOverlay?: boolean;\n selector: string;\n caption?: string;\n render: (ctx: {\n theme: \"light\" | \"dark\";\n style: \"sketchy\" | \"clean\";\n }) => ReactNode;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n const fitRef = useRef<HTMLDivElement>(null);\n const isDark = useIsDark();\n const theme: \"light\" | \"dark\" = isDark ? \"dark\" : \"light\";\n const style = useWireframeStyle();\n const preset = SURFACE_PRESETS[surface] ?? SURFACE_PRESETS.desktop;\n const width = canvasWidth ?? preset.width;\n // AUTO-HEIGHT: with no explicit `canvasSize` the artboard height is driven by\n // its content (`height: auto`), floored at the surface's `minHeight` so a short\n // screen produces a short frame and a tall screen grows — instead of every\n // surface being padded to a fixed preset height that left a big empty band\n // below short content. A `canvasSize` (fixed-aspect canvas artboard) overrides\n // this with a hard pixel height.\n const fixedHeight = canvasSize;\n const minHeight = fixedHeight ?? preset.minHeight;\n const baseScale = compact ? Math.min(1, 320 / preset.width) : 1;\n const maxFrameWidth = compact ? preset.width * baseScale : width;\n const [fitScale, setFitScale] = useState(baseScale);\n // The scaled artboard is `transform: scale()`-ed, which does not change its\n // layout box, so the wrapper that reserves vertical space must track the\n // artboard's ACTUAL rendered height. With a fixed height that's known up front;\n // with auto-height we measure it.\n const [measuredHeight, setMeasuredHeight] = useState<number | null>(\n fixedHeight ?? null,\n );\n const designMode = renderMode === \"design\";\n const sketchy = !designMode && style === \"sketchy\" && !skeleton;\n const roughEnabled = sketchy && roughOverlay;\n const paper = designMode\n ? \"hsl(var(--background))\"\n : \"var(--plan-document, hsl(var(--background)))\";\n const frameBorder = skeleton\n ? \"var(--plan-placeholder-line, var(--plan-line, hsl(var(--border))))\"\n : \"var(--plan-line, hsl(var(--border)))\";\n\n useEffect(() => {\n const element = fitRef.current;\n if (!element) return;\n const measure = () => {\n const availableWidth = element.clientWidth;\n const nextScale =\n availableWidth > 0\n ? Math.min(baseScale, availableWidth / width)\n : baseScale;\n setFitScale((current) =>\n Math.abs(current - nextScale) < 0.001 ? current : nextScale,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [baseScale, width]);\n\n // Track the auto-height artboard's rendered height so the (un-transformed)\n // wrapper reserves exactly the scaled space the frame occupies. Skipped when a\n // fixed height is supplied — there's nothing to measure.\n useEffect(() => {\n if (fixedHeight != null) return;\n const element = ref.current;\n if (!element) return;\n const measure = () => {\n const next = element.offsetHeight;\n setMeasuredHeight((current) =>\n current != null && Math.abs(current - next) < 0.5 ? current : next,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [fixedHeight]);\n\n // Height the wrapper reserves: the measured (or fixed) artboard height scaled\n // by the fit factor. Falls back to the surface floor before the first measure\n // so SSR / first paint reserves a sensible box rather than collapsing.\n const reservedHeight = (measuredHeight ?? minHeight) * fitScale;\n const reserveScaledHeight = fixedHeight != null || fitScale !== 1;\n\n return (\n <div\n ref={fitRef}\n className=\"plan-kit-wireframe\"\n style={{\n width: \"100%\",\n maxWidth: maxFrameWidth,\n }}\n >\n <div\n className=\"group/wireframe-artboard relative\"\n style={{\n width: \"100%\",\n maxWidth: maxFrameWidth,\n ...(reserveScaledHeight ? { height: reservedHeight } : {}),\n marginInline: \"auto\",\n }}\n >\n <div\n ref={ref}\n className=\"plan-kit-artboard relative\"\n data-rough-scope=\"wireframe\"\n style={{\n width,\n // Auto-height by default (content-driven, floored at `minHeight`);\n // a fixed `canvasSize` locks the height for canvas artboards.\n ...(fixedHeight != null ? { height: fixedHeight } : { minHeight }),\n borderRadius: preset.radius,\n background: paper,\n ...(fitScale !== 1\n ? {\n transform: `scale(${fitScale})`,\n transformOrigin: \"top left\",\n }\n : {}),\n }}\n >\n {/* Content drives the artboard height in flow when auto-height; for a\n fixed height it's pinned to the box. Rounded corners clip overflow\n either way. */}\n <div\n className=\"overflow-hidden\"\n style={{\n borderRadius: preset.radius,\n ...(fixedHeight != null\n ? { position: \"absolute\", inset: 0 }\n : { minHeight }),\n }}\n >\n {render({ theme, style })}\n </div>\n {!roughEnabled && (\n <div\n className=\"pointer-events-none absolute inset-0\"\n style={{\n borderRadius: preset.radius,\n border: `1.5px solid ${frameBorder}`,\n }}\n />\n )}\n <RoughOverlay\n scopeRef={ref}\n enabled={roughEnabled}\n frameRadius={preset.radius}\n selector={selector}\n />\n </div>\n {!designMode && !skeleton && <WireframeStyleToggleButton />}\n </div>\n {caption && (\n <p className=\"mt-2 text-center text-xs text-plan-muted\">{caption}</p>\n )}\n </div>\n );\n}\n\nfunction WireframeStyleToggleButton() {\n const style = useWireframeStyle();\n const copy = useBlockCopy();\n const nextStyle = style === \"sketchy\" ? \"clean\" : \"sketchy\";\n const label = nextStyle === \"clean\" ? copy.clean : copy.sketchy;\n const description = copy.switchVisualStyle.replace(\n \"{{style}}\",\n label.toLocaleLowerCase(),\n );\n\n return (\n <button\n type=\"button\"\n data-plan-interactive\n data-rough=\"none\"\n data-wireframe-style-toggle\n aria-label={description}\n title={description}\n onClick={(event) => {\n event.stopPropagation();\n toggleWireframeStyle();\n }}\n className=\"absolute right-2 top-2 z-30 inline-flex h-7 items-center gap-1 rounded-md border border-border/60 bg-background px-2 text-xs font-medium text-muted-foreground opacity-0 shadow-sm transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/wireframe-artboard:opacity-100\"\n >\n <IconPencil className=\"size-3.5\" aria-hidden=\"true\" />\n <span>{label}</span>\n </button>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* HTML artboard — author HTML, themed + roughened by the renderer. */\n/* -------------------------------------------------------------------------- */\n\nfunction HtmlArtboard({\n data,\n ctx: _ctx,\n compact,\n}: {\n data: WireframeData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const renderMode = data.renderMode ?? \"wireframe\";\n const designMode = renderMode === \"design\";\n // Sanitize author HTML/CSS at the render point (defense-in-depth against stored\n // XSS). Self-contained in core via the shared block sanitizer (DOM-based in the\n // browser, regex fallback on the server) so the HTML mockup path renders in any\n // app without the host wiring a sanitizer hook.\n const safeHtml = useMemo(\n () =>\n renderWireframeIconHtml(\n sanitizeWireframeHtml(data.html, {\n preserveThemeClasses: designMode,\n }),\n ),\n [data.html, designMode],\n );\n const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const scopedCss = useMemo(() => {\n const safeCss = sanitizeWireframeCss(data.css);\n // Scope every author selector under this instance's artboard so global\n // selectors (body, *, .app-shell, :root) can't restyle/hide the host app.\n return safeCss\n ? scopeDesignCss(safeCss, `[data-plan-design-scope=\"${scopeId}\"]`)\n : \"\";\n }, [data.css, scopeId]);\n\n return (\n <ArtboardFrame\n surface={data.surface}\n compact={compact}\n skeleton={data.skeleton}\n renderMode={renderMode}\n selector={HTML_ROUGH_SELECTOR}\n caption={data.caption}\n render={({ theme, style }) => (\n <div\n className=\"plan-html-frame\"\n data-theme={theme}\n data-style={style}\n data-render-mode={renderMode}\n data-plan-design-scope={scopeId}\n data-skeleton={data.skeleton ? \"true\" : undefined}\n >\n {scopedCss && <style>{scopedCss}</style>}\n <div\n className=\"plan-html-frame-content\"\n dangerouslySetInnerHTML={{ __html: safeHtml }}\n />\n </div>\n )}\n />\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Kit artboard — declarative kit tree. */\n/* -------------------------------------------------------------------------- */\n\nfunction KitArtboard({\n data,\n compact,\n}: {\n data: WireframeData;\n compact?: boolean;\n}) {\n return (\n <ArtboardFrame\n surface={data.surface}\n compact={compact}\n skeleton={data.skeleton}\n selector=\"[data-rough]\"\n caption={data.caption}\n render={({ theme, style }) => (\n <KitConfigContext.Provider\n value={{ skeleton: data.skeleton, theme, style }}\n >\n {renderKitScreen(data.screen ?? [])}\n </KitConfigContext.Provider>\n )}\n />\n );\n}\n\nfunction renderKitScreen(\n nodes: NonNullable<WireframeData[\"screen\"]>,\n): ReactNode {\n if (nodes.length === 1 && nodes[0]?.el === \"screen\") {\n return renderNodes(nodes);\n }\n // `minHeight` (not `height`) so the screen fills the auto-height artboard floor\n // but grows past it when content is tall, instead of locking to a fixed box.\n return (\n <Screen pad=\"calc(var(--pad) * 1.35)\" style={{ minHeight: \"100%\" }}>\n {renderNodes(nodes)}\n </Screen>\n );\n}\n\n/**\n * The bare wireframe surface (no block section / title). Routes to the HTML\n * mockup when `data.html` is present and a sanitizer is wired; otherwise renders\n * the kit tree.\n */\nfunction WireframeSurfaceView({\n data,\n ctx,\n compact,\n}: {\n data: WireframeData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n if (isHtmlData(data)) {\n return <HtmlArtboard data={data} ctx={ctx} compact={compact} />;\n }\n return <KitArtboard data={data} compact={compact} />;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Block Read / Edit */\n/* -------------------------------------------------------------------------- */\n\n/** Read-only renderer for a `wireframe` block. */\nexport function WireframeBlock({\n data,\n blockId,\n title,\n summary,\n ctx,\n compactVisuals,\n}: BlockReadProps<WireframeData>) {\n return (\n <section\n {...ltrCodeBlockProps}\n className=\"an-block plan-block an-wireframe\"\n data-block-id={blockId}\n >\n {title && <div className=\"an-block-label plan-block-label\">{title}</div>}\n <WireframeSurfaceView data={data} ctx={ctx} compact={compactVisuals} />\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/**\n * Editor for the `wireframe` block. The wireframe is canvas / agent-patch edited\n * (it never calls `onChange`), so edit mode reuses the read surface — mirroring\n * the plan `WireframeEditor`. The host document editor already wraps the registry\n * edit path in a titled section, so this renders only the surface to avoid\n * double-nesting.\n */\nexport function WireframeEditor({ data, ctx }: BlockEditProps<WireframeData>) {\n return <WireframeSurfaceView data={data} ctx={ctx} />;\n}\n\n/** Full client spec for the shared `wireframe` block (schema + MDX + Read/Edit). */\nexport const wireframeBlock = defineBlock<WireframeData>({\n type: \"wireframe\",\n schema: wireframeSchema,\n mdx: wireframeMdx,\n Read: WireframeBlock,\n Edit: WireframeEditor,\n placement: [\"block\"],\n editSurface: \"inline\",\n label: \"Wireframe\",\n description:\n \"A sketch wireframe of one screen built from kit primitives (or an HTML mockup), rendered in a chosen surface frame (desktop/mobile/popover/panel/browser).\",\n // `surface` is the only required field; `screen` defaults to []. Start on the\n // desktop surface with an empty screen so the canvas/agent can fill it in.\n empty: () => ({ surface: \"desktop\", screen: [] }),\n});\n"]}
1
+ {"version":3,"file":"wireframe.js","sourceRoot":"","sources":["../../../../src/client/blocks/library/wireframe.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAM1C,OAAO,EAAE,YAAY,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,OAAO,IAAI,YAAG,SAAS,EAAC,sBAAsB,YAAE,OAAO,GAAK,IACrD,CACX,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,EAAE,GAAG,EAAiC;IAC1E,OAAO,KAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AACxD,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAgB;IACvD,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,eAAe;IACvB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,eAAe;IACrB,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE,WAAW;IAClB,WAAW,EACT,4JAA4J;IAC9J,8EAA8E;IAC9E,2EAA2E;IAC3E,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;CAClD,CAAC,CAAC","sourcesContent":["import { IconPencil } from \"@tabler/icons-react\";\nimport {\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\n\nimport { ltrCodeBlockProps } from \"../code-block-direction.js\";\nimport { defineBlock } from \"../types.js\";\nimport type {\n BlockReadProps,\n BlockEditProps,\n BlockRenderContext,\n} from \"../types.js\";\nimport { useBlockCopy } from \"./block-copy.js\";\nimport {\n sanitizeWireframeCss,\n sanitizeWireframeHtml,\n scopeDesignCss,\n} from \"./sanitize-html.js\";\nimport { renderWireframeIconHtml } from \"./wireframe-icons.js\";\nimport {\n HTML_ROUGH_SELECTOR,\n KitConfigContext,\n RoughOverlay,\n Screen,\n renderNodes,\n toggleWireframeStyle,\n useIsDark,\n useWireframeStyle,\n} from \"./wireframe-kit.js\";\nimport {\n wireframeSchema,\n wireframeMdx,\n type WireframeData,\n type WireframeSurface,\n} from \"./wireframe.config.js\";\n\n/**\n * Shared `wireframe` block — a hand-drawn low-fi mockup of one screen, rendered\n * from either a declarative kit tree (`data.screen`) or a self-contained HTML\n * mockup (`data.html`), inside a surface-locked frame (desktop/mobile/popover/\n * panel/browser) with a rough.js sketch overlay. Lives in core so any app can\n * register it (it originated in the plan template).\n *\n * DECOUPLING from the plan original:\n * - Theme: `useIsDark()` reads `document.documentElement.classList` instead of\n * `next-themes` (the MermaidBlock precedent), so core stays dependency-light.\n * - HTML sanitize: the HTML path runs `data.html`/`data.css` through the\n * app-injected `ctx.sanitizeHtml`. If no sanitizer is wired the HTML path is\n * skipped (kit tree or an empty frame renders) — core never injects unsanitized\n * author HTML.\n * - The plan-only prototype runtime, design-element selection, and legacy region\n * fallback are intentionally NOT ported; those are plan-canvas features, not\n * part of the document-block render. The kit element vocabulary, the `--wf-*`\n * token contract, and the `.plan-wf` / `.wf-*` / `[data-rough]` classes the\n * overlay measures are preserved exactly.\n *\n * The section carries the app-neutral `an-block` class plus the legacy\n * `plan-block` class so plan renders byte-identically while any other app gets\n * the theme-token treatment from core's `blocks.css`.\n *\n * The wireframe is canvas / agent-patch edited (node-addressable content patches\n * applied server-side), NOT schema-form edited in the browser — so `Edit` reuses\n * the same static render as `Read`, mirroring the plan `WireframeEditor`.\n */\n\ntype SurfacePreset = {\n width: number;\n /**\n * Floor height for the surface. The frame is AUTO-HEIGHT (content-driven): it\n * grows past this when content is tall and shrinks toward its content height\n * when content is short, but never collapses below this floor — so an empty or\n * near-empty frame still reads as that surface instead of a thin sliver. This\n * is a `min-height`, not a fixed `height`: it is the lower bound the old fixed\n * preset height used to also be the UPPER bound, which is what left a big empty\n * vertical band below short content (e.g. a header + one dropdown padded to a\n * tall fixed aspect).\n */\n minHeight: number;\n radius: number;\n};\n\nconst SURFACE_PRESETS: Record<WireframeSurface, SurfacePreset> = {\n // mobile keeps a tall floor: a phone frame reads as a phone even when short.\n mobile: { width: 300, minHeight: 360, radius: 30 },\n desktop: { width: 840, minHeight: 200, radius: 14 },\n browser: { width: 900, minHeight: 200, radius: 14 },\n popover: { width: 360, minHeight: 120, radius: 16 },\n panel: { width: 420, minHeight: 200, radius: 16 },\n};\n\nfunction isHtmlData(data: WireframeData): boolean {\n return typeof data.html === \"string\" && data.html.trim().length > 0;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Shared frame shell: surface-locked WIDTH + auto (content-driven) height + */\n/* theme + rough overlay. The frame keeps each surface's footprint and chrome */\n/* but fits its content height instead of padding to a fixed aspect, so short */\n/* content yields a short frame and tall content grows. Pass `canvasSize` to */\n/* opt a fixed-aspect canvas artboard back into a hard pixel height. */\n/* -------------------------------------------------------------------------- */\n\nfunction ArtboardFrame({\n surface,\n compact,\n canvasSize,\n canvasWidth,\n skeleton,\n renderMode,\n roughOverlay = true,\n selector,\n caption,\n render,\n}: {\n surface: WireframeSurface;\n compact?: boolean;\n /**\n * Force a FIXED pixel height instead of the auto-height (content-driven)\n * default. Reserved for fixed-aspect canvas artboards (pan/zoom). Document-flow\n * wireframes — what recaps render — leave this unset so the frame fits content.\n */\n canvasSize?: number;\n canvasWidth?: number;\n skeleton?: boolean;\n renderMode?: \"wireframe\" | \"design\";\n roughOverlay?: boolean;\n selector: string;\n caption?: string;\n render: (ctx: {\n theme: \"light\" | \"dark\";\n style: \"sketchy\" | \"clean\";\n }) => ReactNode;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n const fitRef = useRef<HTMLDivElement>(null);\n const isDark = useIsDark();\n const theme: \"light\" | \"dark\" = isDark ? \"dark\" : \"light\";\n const style = useWireframeStyle();\n const preset = SURFACE_PRESETS[surface] ?? SURFACE_PRESETS.desktop;\n const width = canvasWidth ?? preset.width;\n // AUTO-HEIGHT: with no explicit `canvasSize` the artboard height is driven by\n // its content (`height: auto`), floored at the surface's `minHeight` so a short\n // screen produces a short frame and a tall screen grows — instead of every\n // surface being padded to a fixed preset height that left a big empty band\n // below short content. A `canvasSize` (fixed-aspect canvas artboard) overrides\n // this with a hard pixel height.\n const fixedHeight = canvasSize;\n const minHeight = fixedHeight ?? preset.minHeight;\n const baseScale = compact ? Math.min(1, 320 / preset.width) : 1;\n const maxFrameWidth = compact ? preset.width * baseScale : width;\n const [fitScale, setFitScale] = useState(baseScale);\n // The scaled artboard is `transform: scale()`-ed, which does not change its\n // layout box, so the wrapper that reserves vertical space must track the\n // artboard's ACTUAL rendered height. With a fixed height that's known up front;\n // with auto-height we measure it.\n const [measuredHeight, setMeasuredHeight] = useState<number | null>(\n fixedHeight ?? null,\n );\n const designMode = renderMode === \"design\";\n const sketchy = !designMode && style === \"sketchy\" && !skeleton;\n const roughEnabled = sketchy && roughOverlay;\n\n useEffect(() => {\n const element = fitRef.current;\n if (!element) return;\n const measure = () => {\n const availableWidth = element.clientWidth;\n const nextScale =\n availableWidth > 0\n ? Math.min(baseScale, availableWidth / width)\n : baseScale;\n setFitScale((current) =>\n Math.abs(current - nextScale) < 0.001 ? current : nextScale,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [baseScale, width]);\n\n // Track the auto-height artboard's rendered height so the (un-transformed)\n // wrapper reserves exactly the scaled space the frame occupies. Skipped when a\n // fixed height is supplied — there's nothing to measure.\n useEffect(() => {\n if (fixedHeight != null) return;\n const element = ref.current;\n if (!element) return;\n const measure = () => {\n const next = element.offsetHeight;\n setMeasuredHeight((current) =>\n current != null && Math.abs(current - next) < 0.5 ? current : next,\n );\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [fixedHeight]);\n\n // Height the wrapper reserves: the measured (or fixed) artboard height scaled\n // by the fit factor. Falls back to the surface floor before the first measure\n // so SSR / first paint reserves a sensible box rather than collapsing.\n const reservedHeight = (measuredHeight ?? minHeight) * fitScale;\n const reserveScaledHeight = fixedHeight != null || fitScale !== 1;\n\n return (\n <div\n ref={fitRef}\n className=\"plan-kit-wireframe\"\n style={{\n width: \"100%\",\n maxWidth: maxFrameWidth,\n }}\n >\n <div\n className=\"group/wireframe-artboard relative\"\n style={{\n width: \"100%\",\n maxWidth: maxFrameWidth,\n ...(reserveScaledHeight ? { height: reservedHeight } : {}),\n marginInline: \"auto\",\n }}\n >\n <div\n ref={ref}\n className=\"plan-kit-artboard relative\"\n data-rough-scope=\"wireframe\"\n style={{\n width,\n // Auto-height by default (content-driven, floored at `minHeight`);\n // a fixed `canvasSize` locks the height for canvas artboards.\n ...(fixedHeight != null ? { height: fixedHeight } : { minHeight }),\n borderRadius: preset.radius,\n ...(fitScale !== 1\n ? {\n transform: `scale(${fitScale})`,\n transformOrigin: \"top left\",\n }\n : {}),\n }}\n >\n {/* Content drives the artboard height in flow when auto-height; for a\n fixed height it's pinned to the box. Rounded corners clip overflow\n either way. */}\n <div\n className=\"overflow-hidden\"\n style={{\n borderRadius: preset.radius,\n ...(fixedHeight != null\n ? { position: \"absolute\", inset: 0 }\n : { minHeight }),\n }}\n >\n {render({ theme, style })}\n </div>\n <RoughOverlay\n scopeRef={ref}\n enabled={roughEnabled}\n drawFrame={false}\n frameRadius={preset.radius}\n selector={selector}\n />\n </div>\n {!designMode && !skeleton && <WireframeStyleToggleButton />}\n </div>\n {caption && (\n <p className=\"mt-2 text-center text-xs text-plan-muted\">{caption}</p>\n )}\n </div>\n );\n}\n\nfunction WireframeStyleToggleButton() {\n const style = useWireframeStyle();\n const copy = useBlockCopy();\n const nextStyle = style === \"sketchy\" ? \"clean\" : \"sketchy\";\n const label = nextStyle === \"clean\" ? copy.clean : copy.sketchy;\n const description = copy.switchVisualStyle.replace(\n \"{{style}}\",\n label.toLocaleLowerCase(),\n );\n\n return (\n <button\n type=\"button\"\n data-plan-interactive\n data-rough=\"none\"\n data-wireframe-style-toggle\n aria-label={description}\n title={description}\n onClick={(event) => {\n event.stopPropagation();\n toggleWireframeStyle();\n }}\n className=\"absolute right-2 top-2 z-30 inline-flex h-7 items-center gap-1 rounded-md border border-border/60 bg-background px-2 text-xs font-medium text-muted-foreground opacity-0 shadow-sm transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring group-hover/wireframe-artboard:opacity-100\"\n >\n <IconPencil className=\"size-3.5\" aria-hidden=\"true\" />\n <span>{label}</span>\n </button>\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* HTML artboard — author HTML, themed + roughened by the renderer. */\n/* -------------------------------------------------------------------------- */\n\nfunction HtmlArtboard({\n data,\n ctx: _ctx,\n compact,\n}: {\n data: WireframeData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n const renderMode = data.renderMode ?? \"wireframe\";\n const designMode = renderMode === \"design\";\n // Sanitize author HTML/CSS at the render point (defense-in-depth against stored\n // XSS). Self-contained in core via the shared block sanitizer (DOM-based in the\n // browser, regex fallback on the server) so the HTML mockup path renders in any\n // app without the host wiring a sanitizer hook.\n const safeHtml = useMemo(\n () =>\n renderWireframeIconHtml(\n sanitizeWireframeHtml(data.html, {\n preserveThemeClasses: designMode,\n }),\n ),\n [data.html, designMode],\n );\n const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n const scopedCss = useMemo(() => {\n const safeCss = sanitizeWireframeCss(data.css);\n // Scope every author selector under this instance's artboard so global\n // selectors (body, *, .app-shell, :root) can't restyle/hide the host app.\n return safeCss\n ? scopeDesignCss(safeCss, `[data-plan-design-scope=\"${scopeId}\"]`)\n : \"\";\n }, [data.css, scopeId]);\n\n return (\n <ArtboardFrame\n surface={data.surface}\n compact={compact}\n skeleton={data.skeleton}\n renderMode={renderMode}\n selector={HTML_ROUGH_SELECTOR}\n caption={data.caption}\n render={({ theme, style }) => (\n <div\n className=\"plan-html-frame\"\n data-theme={theme}\n data-style={style}\n data-render-mode={renderMode}\n data-plan-design-scope={scopeId}\n data-skeleton={data.skeleton ? \"true\" : undefined}\n >\n {scopedCss && <style>{scopedCss}</style>}\n <div\n className=\"plan-html-frame-content\"\n dangerouslySetInnerHTML={{ __html: safeHtml }}\n />\n </div>\n )}\n />\n );\n}\n\n/* -------------------------------------------------------------------------- */\n/* Kit artboard — declarative kit tree. */\n/* -------------------------------------------------------------------------- */\n\nfunction KitArtboard({\n data,\n compact,\n}: {\n data: WireframeData;\n compact?: boolean;\n}) {\n return (\n <ArtboardFrame\n surface={data.surface}\n compact={compact}\n skeleton={data.skeleton}\n selector=\"[data-rough]\"\n caption={data.caption}\n render={({ theme, style }) => (\n <KitConfigContext.Provider\n value={{ skeleton: data.skeleton, theme, style }}\n >\n {renderKitScreen(data.screen ?? [])}\n </KitConfigContext.Provider>\n )}\n />\n );\n}\n\nfunction renderKitScreen(\n nodes: NonNullable<WireframeData[\"screen\"]>,\n): ReactNode {\n if (nodes.length === 1 && nodes[0]?.el === \"screen\") {\n return renderNodes(nodes);\n }\n // `minHeight` (not `height`) so the screen fills the auto-height artboard floor\n // but grows past it when content is tall, instead of locking to a fixed box.\n return (\n <Screen pad=\"calc(var(--pad) * 1.35)\" style={{ minHeight: \"100%\" }}>\n {renderNodes(nodes)}\n </Screen>\n );\n}\n\n/**\n * The bare wireframe surface (no block section / title). Routes to the HTML\n * mockup when `data.html` is present and a sanitizer is wired; otherwise renders\n * the kit tree.\n */\nfunction WireframeSurfaceView({\n data,\n ctx,\n compact,\n}: {\n data: WireframeData;\n ctx: BlockRenderContext;\n compact?: boolean;\n}) {\n if (isHtmlData(data)) {\n return <HtmlArtboard data={data} ctx={ctx} compact={compact} />;\n }\n return <KitArtboard data={data} compact={compact} />;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Block Read / Edit */\n/* -------------------------------------------------------------------------- */\n\n/** Read-only renderer for a `wireframe` block. */\nexport function WireframeBlock({\n data,\n blockId,\n title,\n summary,\n ctx,\n compactVisuals,\n}: BlockReadProps<WireframeData>) {\n return (\n <section\n {...ltrCodeBlockProps}\n className=\"an-block plan-block an-wireframe\"\n data-block-id={blockId}\n >\n {title && <div className=\"an-block-label plan-block-label\">{title}</div>}\n <WireframeSurfaceView data={data} ctx={ctx} compact={compactVisuals} />\n {summary && <p className=\"mt-5 text-plan-muted\">{summary}</p>}\n </section>\n );\n}\n\n/**\n * Editor for the `wireframe` block. The wireframe is canvas / agent-patch edited\n * (it never calls `onChange`), so edit mode reuses the read surface — mirroring\n * the plan `WireframeEditor`. The host document editor already wraps the registry\n * edit path in a titled section, so this renders only the surface to avoid\n * double-nesting.\n */\nexport function WireframeEditor({ data, ctx }: BlockEditProps<WireframeData>) {\n return <WireframeSurfaceView data={data} ctx={ctx} />;\n}\n\n/** Full client spec for the shared `wireframe` block (schema + MDX + Read/Edit). */\nexport const wireframeBlock = defineBlock<WireframeData>({\n type: \"wireframe\",\n schema: wireframeSchema,\n mdx: wireframeMdx,\n Read: WireframeBlock,\n Edit: WireframeEditor,\n placement: [\"block\"],\n editSurface: \"inline\",\n label: \"Wireframe\",\n description:\n \"A sketch wireframe of one screen built from kit primitives (or an HTML mockup), rendered in a chosen surface frame (desktop/mobile/popover/panel/browser).\",\n // `surface` is the only required field; `screen` defaults to []. Start on the\n // desktop surface with an empty screen so the canvas/agent can fill it in.\n empty: () => ({ surface: \"desktop\", screen: [] }),\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"builtin-tool-renderers.d.ts","sourceRoot":"","sources":["../../../../src/client/chat/widgets/builtin-tool-renderers.tsx"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC3B,MAAM,4BAA4B,CAAC;AAqGpC,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAQT;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,mBAAmB,GAC3B,qBAAqB,GAAG,IAAI,CAc9B;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mBAAmB,GAC3B,qBAAqB,GAAG,IAAI,CAU9B"}
1
+ {"version":3,"file":"builtin-tool-renderers.d.ts","sourceRoot":"","sources":["../../../../src/client/chat/widgets/builtin-tool-renderers.tsx"],"names":[],"mappings":"AAOA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC3B,MAAM,4BAA4B,CAAC;AAiGpC,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAQT;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,mBAAmB,GAC3B,qBAAqB,GAAG,IAAI,CAc9B;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mBAAmB,GAC3B,qBAAqB,GAAG,IAAI,CAU9B"}
@@ -10,46 +10,42 @@ function isRecord(value) {
10
10
  return !!value && typeof value === "object" && !Array.isArray(value);
11
11
  }
12
12
  function normalizeActionDataWidgetResult(context) {
13
+ const renderer = context.chatUI?.renderer;
14
+ if (isRecord(context.resultJson)) {
15
+ if (renderer === ACTION_CHAT_UI_DATA_TABLE_RENDERER) {
16
+ return normalizeDataWidgetResult({
17
+ ...context.resultJson,
18
+ widget: DATA_TABLE_WIDGET,
19
+ table: isRecord(context.resultJson.table)
20
+ ? context.resultJson.table
21
+ : context.resultJson,
22
+ });
23
+ }
24
+ if (renderer === ACTION_CHAT_UI_DATA_CHART_RENDERER) {
25
+ return normalizeDataWidgetResult({
26
+ ...context.resultJson,
27
+ widget: DATA_CHART_WIDGET,
28
+ chartSeries: isRecord(context.resultJson.chartSeries)
29
+ ? context.resultJson.chartSeries
30
+ : context.resultJson,
31
+ });
32
+ }
33
+ if (renderer === ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER) {
34
+ return normalizeDataWidgetResult({
35
+ ...context.resultJson,
36
+ widget: DATA_INSIGHTS_WIDGET,
37
+ });
38
+ }
39
+ }
13
40
  const result = normalizeDataWidgetResult(context.resultJson);
14
41
  if (result)
15
42
  return result;
16
- const renderer = context.chatUI?.renderer;
17
43
  if (renderer === ACTION_CHAT_UI_DATA_WIDGET_RENDERER ||
18
44
  context.toolName === "render-data-widget") {
19
45
  const argsResult = normalizeDataWidgetResult(context.args);
20
46
  if (argsResult)
21
47
  return argsResult;
22
48
  }
23
- if (!isRecord(context.resultJson))
24
- return null;
25
- if (renderer === ACTION_CHAT_UI_DATA_TABLE_RENDERER) {
26
- return normalizeDataWidgetResult({
27
- widget: DATA_TABLE_WIDGET,
28
- table: isRecord(context.resultJson.table)
29
- ? context.resultJson.table
30
- : context.resultJson,
31
- display: isRecord(context.resultJson.display)
32
- ? context.resultJson.display
33
- : undefined,
34
- });
35
- }
36
- if (renderer === ACTION_CHAT_UI_DATA_CHART_RENDERER) {
37
- return normalizeDataWidgetResult({
38
- widget: DATA_CHART_WIDGET,
39
- chartSeries: isRecord(context.resultJson.chartSeries)
40
- ? context.resultJson.chartSeries
41
- : context.resultJson,
42
- display: isRecord(context.resultJson.display)
43
- ? context.resultJson.display
44
- : undefined,
45
- });
46
- }
47
- if (renderer === ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER) {
48
- return normalizeDataWidgetResult({
49
- ...context.resultJson,
50
- widget: DATA_INSIGHTS_WIDGET,
51
- });
52
- }
53
49
  return null;
54
50
  }
55
51
  function renderDataWidget(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"builtin-tool-renderers.js","sourceRoot":"","sources":["../../../../src/client/chat/widgets/builtin-tool-renderers.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAClC,mCAAmC,EACnC,wCAAwC,GACzC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kCAAkC,EAClC,oCAAoC,GAGrC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAE1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe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C,yBAAyB;QAC3B,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,KAAK,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI;IAC3B,CAAC,iBAAiB,EAAE,kCAAkC,CAAC;IACvD,CAAC,iBAAiB,EAAE,kCAAkC,CAAC;IACvD,CAAC,oBAAoB,EAAE,qCAAqC,CAAC;IAC7D,CAAC,kBAAkB,EAAE,mCAAmC,CAAC;IACzD,CAAC,uBAAuB,EAAE,wCAAwC,CAAC;CAC3D,EAAE,CAAC;IACX,kCAAkC,CAAC;QACjC,EAAE;QACF,QAAQ;QACR,SAAS,EACP,QAAQ,KAAK,wCAAwC;YACnD,CAAC,CAAC,8BAA8B;YAChC,CAAC,CAAC,yBAAyB;KAChC,CAAC,CAAC;AACL,CAAC;AAED,oCAAoC,CAAC;IACnC,EAAE,EAAE,mBAAmB;IACvB,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,+BAA+B,CAAC,OAAO,CAAC,KAAK,IAAI;IACrE,SAAS,EAAE,yBAAyB;CACrC,CAAC,CAAC","sourcesContent":["import {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER,\n} from \"../../../action-ui.js\";\nimport {\n registerReservedActionChatRenderer,\n registerReservedFallbackToolRenderer,\n type ToolRendererContext,\n type ToolRendererComponent,\n} from \"../tool-render-registry.js\";\nimport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataWidgetResult,\n} from \"./data-widget-types.js\";\nimport { DataChartWidget } from \"./DataChartWidget.js\";\nimport { DataInsightsWidget } from \"./DataInsightsWidget.js\";\nimport { DataTableWidget } from \"./DataTableWidget.js\";\nimport {\n InlineExtensionWidget,\n normalizeInlineExtensionToolResult,\n} from \"./InlineExtensionWidget.js\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction normalizeActionDataWidgetResult(\n context: ToolRendererContext,\n): DataWidgetResult | null {\n const result = normalizeDataWidgetResult(context.resultJson);\n if (result) return result;\n\n const renderer = context.chatUI?.renderer;\n if (\n renderer === ACTION_CHAT_UI_DATA_WIDGET_RENDERER ||\n context.toolName === \"render-data-widget\"\n ) {\n const argsResult = normalizeDataWidgetResult(context.args);\n if (argsResult) return argsResult;\n }\n\n if (!isRecord(context.resultJson)) return null;\n\n if (renderer === ACTION_CHAT_UI_DATA_TABLE_RENDERER) {\n return normalizeDataWidgetResult({\n widget: DATA_TABLE_WIDGET,\n table: isRecord(context.resultJson.table)\n ? context.resultJson.table\n : context.resultJson,\n display: isRecord(context.resultJson.display)\n ? context.resultJson.display\n : undefined,\n });\n }\n if (renderer === ACTION_CHAT_UI_DATA_CHART_RENDERER) {\n return normalizeDataWidgetResult({\n widget: DATA_CHART_WIDGET,\n chartSeries: isRecord(context.resultJson.chartSeries)\n ? context.resultJson.chartSeries\n : context.resultJson,\n display: isRecord(context.resultJson.display)\n ? context.resultJson.display\n : undefined,\n });\n }\n if (renderer === ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER) {\n return normalizeDataWidgetResult({\n ...context.resultJson,\n widget: DATA_INSIGHTS_WIDGET,\n });\n }\n\n return null;\n}\n\nfunction renderDataWidget(context: ToolRendererContext) {\n const result =\n normalizeActionDataWidgetResult(context) ??\n normalizeDataWidgetResult(context.resultJson);\n if (!result) return null;\n const widget = normalizeDataWidgetKind(result.widget);\n if (widget === DATA_TABLE_WIDGET && result.table) {\n return (\n <DataTableWidget\n table={result.table}\n action={result.display?.primaryAction}\n />\n );\n }\n if (widget === DATA_CHART_WIDGET && result.chartSeries) {\n return <DataChartWidget chart={result.chartSeries} />;\n }\n if (widget === DATA_INSIGHTS_WIDGET) {\n return <DataInsightsWidget result={result} />;\n }\n return null;\n}\n\nconst BuiltinDataWidgetRenderer: ToolRendererComponent = ({ context }) =>\n renderDataWidget(context);\n\nconst BuiltinInlineExtensionRenderer: ToolRendererComponent = ({ context }) =>\n normalizeInlineExtensionToolResult(context) ? (\n <InlineExtensionWidget context={context} />\n ) : null;\n\nexport function isBuiltinDataWidgetActionRenderer(\n context: ToolRendererContext,\n): boolean {\n const renderer = context.chatUI?.renderer;\n return (\n renderer === ACTION_CHAT_UI_DATA_TABLE_RENDERER ||\n renderer === ACTION_CHAT_UI_DATA_CHART_RENDERER ||\n renderer === ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER ||\n renderer === ACTION_CHAT_UI_DATA_WIDGET_RENDERER\n );\n}\n\nexport function resolveBuiltinActionChatRenderer(\n context: ToolRendererContext,\n): ToolRendererComponent | null {\n if (\n context.chatUI?.renderer === ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER &&\n normalizeInlineExtensionToolResult(context)\n ) {\n return BuiltinInlineExtensionRenderer;\n }\n if (\n isBuiltinDataWidgetActionRenderer(context) &&\n normalizeActionDataWidgetResult(context)\n ) {\n return BuiltinDataWidgetRenderer;\n }\n return null;\n}\n\nexport function resolveBuiltinFallbackToolRenderer(\n context: ToolRendererContext,\n): ToolRendererComponent | null {\n if (\n context.chatUI?.renderer === ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER &&\n normalizeInlineExtensionToolResult(context)\n ) {\n return BuiltinInlineExtensionRenderer;\n }\n return normalizeActionDataWidgetResult(context) !== null\n ? BuiltinDataWidgetRenderer\n : null;\n}\n\nfor (const [id, renderer] of [\n [\"core.data-table\", ACTION_CHAT_UI_DATA_TABLE_RENDERER],\n [\"core.data-chart\", ACTION_CHAT_UI_DATA_CHART_RENDERER],\n [\"core.data-insights\", ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER],\n [\"core.data-widget\", ACTION_CHAT_UI_DATA_WIDGET_RENDERER],\n [\"core.inline-extension\", ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER],\n] as const) {\n registerReservedActionChatRenderer({\n id,\n renderer,\n Component:\n renderer === ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER\n ? BuiltinInlineExtensionRenderer\n : BuiltinDataWidgetRenderer,\n });\n}\n\nregisterReservedFallbackToolRenderer({\n id: \"core.data-widgets\",\n match: (context) => normalizeActionDataWidgetResult(context) !== null,\n Component: BuiltinDataWidgetRenderer,\n});\n"]}
1
+ {"version":3,"file":"builtin-tool-renderers.js","sourceRoot":"","sources":["../../../../src/client/chat/widgets/builtin-tool-renderers.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAClC,mCAAmC,EACnC,wCAAwC,GACzC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kCAAkC,EAClC,oCAAoC,GAGrC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAE1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,qBAAqB,EACrB,kCAAkC,GACnC,MAAM,4BAA4B,CAAC;AAEpC,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,+BAA+B,CACtC,OAA4B;IAE5B,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1C,IAAI,QAAQ,CAAC,OAAO,CAAC,UAAU,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,IAAI;IACrE,SAAS,EAAE,yBAAyB;CACrC,CAAC,CAAC","sourcesContent":["import {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER,\n} from \"../../../action-ui.js\";\nimport {\n registerReservedActionChatRenderer,\n registerReservedFallbackToolRenderer,\n type ToolRendererContext,\n type ToolRendererComponent,\n} from \"../tool-render-registry.js\";\nimport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataWidgetResult,\n} from \"./data-widget-types.js\";\nimport { DataChartWidget } from \"./DataChartWidget.js\";\nimport { DataInsightsWidget } from \"./DataInsightsWidget.js\";\nimport { DataTableWidget } from \"./DataTableWidget.js\";\nimport {\n InlineExtensionWidget,\n normalizeInlineExtensionToolResult,\n} from \"./InlineExtensionWidget.js\";\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction normalizeActionDataWidgetResult(\n context: ToolRendererContext,\n): DataWidgetResult | null {\n const renderer = context.chatUI?.renderer;\n if (isRecord(context.resultJson)) {\n if (renderer === ACTION_CHAT_UI_DATA_TABLE_RENDERER) {\n return normalizeDataWidgetResult({\n ...context.resultJson,\n widget: DATA_TABLE_WIDGET,\n table: isRecord(context.resultJson.table)\n ? context.resultJson.table\n : context.resultJson,\n });\n }\n if (renderer === ACTION_CHAT_UI_DATA_CHART_RENDERER) {\n return normalizeDataWidgetResult({\n ...context.resultJson,\n widget: DATA_CHART_WIDGET,\n chartSeries: isRecord(context.resultJson.chartSeries)\n ? context.resultJson.chartSeries\n : context.resultJson,\n });\n }\n if (renderer === ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER) {\n return normalizeDataWidgetResult({\n ...context.resultJson,\n widget: DATA_INSIGHTS_WIDGET,\n });\n }\n }\n\n const result = normalizeDataWidgetResult(context.resultJson);\n if (result) return result;\n\n if (\n renderer === ACTION_CHAT_UI_DATA_WIDGET_RENDERER ||\n context.toolName === \"render-data-widget\"\n ) {\n const argsResult = normalizeDataWidgetResult(context.args);\n if (argsResult) return argsResult;\n }\n\n return null;\n}\n\nfunction renderDataWidget(context: ToolRendererContext) {\n const result =\n normalizeActionDataWidgetResult(context) ??\n normalizeDataWidgetResult(context.resultJson);\n if (!result) return null;\n const widget = normalizeDataWidgetKind(result.widget);\n if (widget === DATA_TABLE_WIDGET && result.table) {\n return (\n <DataTableWidget\n table={result.table}\n action={result.display?.primaryAction}\n />\n );\n }\n if (widget === DATA_CHART_WIDGET && result.chartSeries) {\n return <DataChartWidget chart={result.chartSeries} />;\n }\n if (widget === DATA_INSIGHTS_WIDGET) {\n return <DataInsightsWidget result={result} />;\n }\n return null;\n}\n\nconst BuiltinDataWidgetRenderer: ToolRendererComponent = ({ context }) =>\n renderDataWidget(context);\n\nconst BuiltinInlineExtensionRenderer: ToolRendererComponent = ({ context }) =>\n normalizeInlineExtensionToolResult(context) ? (\n <InlineExtensionWidget context={context} />\n ) : null;\n\nexport function isBuiltinDataWidgetActionRenderer(\n context: ToolRendererContext,\n): boolean {\n const renderer = context.chatUI?.renderer;\n return (\n renderer === ACTION_CHAT_UI_DATA_TABLE_RENDERER ||\n renderer === ACTION_CHAT_UI_DATA_CHART_RENDERER ||\n renderer === ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER ||\n renderer === ACTION_CHAT_UI_DATA_WIDGET_RENDERER\n );\n}\n\nexport function resolveBuiltinActionChatRenderer(\n context: ToolRendererContext,\n): ToolRendererComponent | null {\n if (\n context.chatUI?.renderer === ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER &&\n normalizeInlineExtensionToolResult(context)\n ) {\n return BuiltinInlineExtensionRenderer;\n }\n if (\n isBuiltinDataWidgetActionRenderer(context) &&\n normalizeActionDataWidgetResult(context)\n ) {\n return BuiltinDataWidgetRenderer;\n }\n return null;\n}\n\nexport function resolveBuiltinFallbackToolRenderer(\n context: ToolRendererContext,\n): ToolRendererComponent | null {\n if (\n context.chatUI?.renderer === ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER &&\n normalizeInlineExtensionToolResult(context)\n ) {\n return BuiltinInlineExtensionRenderer;\n }\n return normalizeActionDataWidgetResult(context) !== null\n ? BuiltinDataWidgetRenderer\n : null;\n}\n\nfor (const [id, renderer] of [\n [\"core.data-table\", ACTION_CHAT_UI_DATA_TABLE_RENDERER],\n [\"core.data-chart\", ACTION_CHAT_UI_DATA_CHART_RENDERER],\n [\"core.data-insights\", ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER],\n [\"core.data-widget\", ACTION_CHAT_UI_DATA_WIDGET_RENDERER],\n [\"core.inline-extension\", ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER],\n] as const) {\n registerReservedActionChatRenderer({\n id,\n renderer,\n Component:\n renderer === ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER\n ? BuiltinInlineExtensionRenderer\n : BuiltinDataWidgetRenderer,\n });\n}\n\nregisterReservedFallbackToolRenderer({\n id: \"core.data-widgets\",\n match: (context) => normalizeActionDataWidgetResult(context) !== null,\n Component: BuiltinDataWidgetRenderer,\n});\n"]}
@@ -26,8 +26,8 @@ export declare const getCollabState: import("h3").EventHandlerWithFetch<import("
26
26
  * Body: { update: string (base64), requestSource?: string }
27
27
  */
28
28
  export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
29
- error: string;
30
29
  ok?: undefined;
30
+ error: string;
31
31
  } | {
32
32
  error?: undefined;
33
33
  ok: boolean;
@@ -42,8 +42,8 @@ export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import
42
42
  */
43
43
  export declare const postCollabText: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
44
44
  ok?: undefined;
45
- error: string;
46
45
  text?: undefined;
46
+ error: string;
47
47
  } | {
48
48
  error?: undefined;
49
49
  ok: boolean;
@@ -15,11 +15,12 @@
15
15
  * createdAt: text("created_at").notNull().default(now()),
16
16
  * });
17
17
  */
18
- import { sqliteTable, index as sqliteIndex, text as sqliteText, integer as sqliteInteger, real as sqliteReal, uniqueIndex as sqliteUniqueIndex } from "drizzle-orm/sqlite-core";
18
+ import { sqliteTable, alias as sqliteAlias, index as sqliteIndex, text as sqliteText, integer as sqliteInteger, real as sqliteReal, uniqueIndex as sqliteUniqueIndex } from "drizzle-orm/sqlite-core";
19
19
  /**
20
20
  * Define a table. Delegates to `pgTable` or `sqliteTable` based on dialect.
21
21
  */
22
22
  export declare const table: typeof sqliteTable;
23
+ export declare const alias: typeof sqliteAlias;
23
24
  export declare const index: typeof sqliteIndex;
24
25
  export declare const uniqueIndex: typeof sqliteUniqueIndex;
25
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAYH,OAAO,EACL,WAAW,EACX,KAAK,IAAI,WAAW,EACpB,IAAI,IAAI,UAAU,EAClB,OAAO,IAAI,aAAa,EACxB,IAAI,IAAI,UAAU,EAClB,WAAW,IAAI,iBAAiB,EACjC,MAAM,yBAAyB,CAAC;AAWjC;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,OAAO,WAC+C,CAAC;AAE3E,eAAO,MAAM,KAAK,EAAE,OAAO,WAC+C,CAAC;AAE3E,eAAO,MAAM,WAAW,EAAE,OAAO,iBAGgB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,OAAO,UAC8C,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,EAAE,OAAO,aAKpB,CAAC;AAEV;;;;;GAKG;AACH,eAAO,MAAM,IAAI,EAAE,OAAO,UAIjB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EACd,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC"}
package/dist/db/schema.js CHANGED
@@ -16,8 +16,8 @@
16
16
  * });
17
17
  */
18
18
  import { sql } from "drizzle-orm";
19
- import { pgTable, index as pgIndex, text as pgText, integer as pgInteger, boolean as pgBoolean, doublePrecision as pgDoublePrecision, uniqueIndex as pgUniqueIndex, } from "drizzle-orm/pg-core";
20
- import { sqliteTable, index as sqliteIndex, text as sqliteText, integer as sqliteInteger, real as sqliteReal, uniqueIndex as sqliteUniqueIndex, } from "drizzle-orm/sqlite-core";
19
+ import { pgTable, alias as pgAlias, index as pgIndex, text as pgText, integer as pgInteger, boolean as pgBoolean, doublePrecision as pgDoublePrecision, uniqueIndex as pgUniqueIndex, } from "drizzle-orm/pg-core";
20
+ import { sqliteTable, alias as sqliteAlias, index as sqliteIndex, text as sqliteText, integer as sqliteInteger, real as sqliteReal, uniqueIndex as sqliteUniqueIndex, } from "drizzle-orm/sqlite-core";
21
21
  import { getDialect } from "./client.js";
22
22
  // No caching — getDialect() handles its own caching once env is available.
23
23
  // On CF Workers, this runs at import time before env bindings are set, so
@@ -29,6 +29,7 @@ function pg() {
29
29
  * Define a table. Delegates to `pgTable` or `sqliteTable` based on dialect.
30
30
  */
31
31
  export const table = ((...args) => pg() ? pgTable(...args) : sqliteTable(...args));
32
+ export const alias = ((...args) => pg() ? pgAlias(...args) : sqliteAlias(...args));
32
33
  export const index = ((...args) => pg() ? pgIndex(...args) : sqliteIndex(...args));
33
34
  export const uniqueIndex = ((...args) => pg()
34
35
  ? pgUniqueIndex(...args)
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,OAAO,EACP,KAAK,IAAI,OAAO,EAChB,IAAI,IAAI,MAAM,EACd,OAAO,IAAI,SAAS,EAC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,UAAkB,CAAC,GAAG,IAAI,CAAC,CAAQ,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAyB,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;IAC/D,IAAI,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,SAAS,EAAE,CAAC;QACxC,OAAQ,SAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,EAAE,CAAC,CAAC,CAAE,SAAiB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAE,aAAqB,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9E,CAAC,CAAQ,CAAC;AAEV;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAsB,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;IACzD,OAAO,EAAE,EAAE;QACT,CAAC,CAAE,iBAAyB,CAAC,GAAG,IAAI,CAAC;QACrC,CAAC,CAAE,UAAkB,CAAC,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC,CAAQ,CAAC;AAEV;;;;;;GAMG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA,mBAAmB,CAAC;AACpD,CAAC;AAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEtE,+EAA+E;AAC/E,6EAA6E;AAC7E,iEAAiE;AACjE,OAAO,EACL,cAAc,EACd,iBAAiB,GAIlB,MAAM,sBAAsB,CAAC","sourcesContent":["/**\n * Dialect-agnostic Drizzle schema helpers.\n *\n * Templates import `table`, `text`, `integer`, and `now` from here instead of\n * importing directly from `drizzle-orm/sqlite-core` or `drizzle-orm/pg-core`.\n * The correct dialect is chosen at runtime based on `DATABASE_URL`.\n *\n * Usage:\n * import { table, text, integer, now } from \"@agent-native/core/db/schema\";\n *\n * export const users = table(\"users\", {\n * id: text(\"id\").primaryKey(),\n * name: text(\"name\").notNull(),\n * active: integer(\"active\", { mode: \"boolean\" }).notNull().default(true),\n * createdAt: text(\"created_at\").notNull().default(now()),\n * });\n */\n\nimport { sql } from \"drizzle-orm\";\nimport {\n pgTable,\n index as pgIndex,\n text as pgText,\n integer as pgInteger,\n boolean as pgBoolean,\n doublePrecision as pgDoublePrecision,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n sqliteTable,\n index as sqliteIndex,\n text as sqliteText,\n integer as sqliteInteger,\n real as sqliteReal,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport { getDialect } from \"./client.js\";\n\n// No caching — getDialect() handles its own caching once env is available.\n// On CF Workers, this runs at import time before env bindings are set, so\n// caching here would lock in the wrong dialect.\nfunction pg(): boolean {\n return getDialect() === \"postgres\";\n}\n\n/**\n * Define a table. Delegates to `pgTable` or `sqliteTable` based on dialect.\n */\nexport const table: typeof sqliteTable = ((...args: any[]) =>\n pg() ? (pgTable as any)(...args) : (sqliteTable as any)(...args)) as any;\n\nexport const index: typeof sqliteIndex = ((...args: any[]) =>\n pg() ? (pgIndex as any)(...args) : (sqliteIndex as any)(...args)) as any;\n\nexport const uniqueIndex: typeof sqliteUniqueIndex = ((...args: any[]) =>\n pg()\n ? (pgUniqueIndex as any)(...args)\n : (sqliteUniqueIndex as any)(...args)) as any;\n\n/**\n * Text column. Works identically in both dialects.\n * Supports `{ enum: [...] }` config in both.\n */\nexport const text: typeof sqliteText = ((...args: any[]) =>\n pg() ? (pgText as any)(...args) : (sqliteText as any)(...args)) as any;\n\n/**\n * Integer column.\n *\n * Handles `{ mode: \"boolean\" }` transparently — maps to Postgres `boolean`\n * type when running against Postgres, and SQLite `integer` with boolean\n * coercion when running against SQLite.\n */\nexport const integer: typeof sqliteInteger = ((...args: any[]) => {\n if (pg() && args[1]?.mode === \"boolean\") {\n return (pgBoolean as any)(args[0]);\n }\n return pg() ? (pgInteger as any)(...args) : (sqliteInteger as any)(...args);\n}) as any;\n\n/**\n * Real/float column.\n *\n * Maps to `real` on SQLite and `double precision` on Postgres.\n * Use for decimal values like weight, macros, etc.\n */\nexport const real: typeof sqliteReal = ((...args: any[]) => {\n return pg()\n ? (pgDoublePrecision as any)(...args)\n : (sqliteReal as any)(...args);\n}) as any;\n\n/**\n * Dialect-agnostic \"current timestamp\" SQL expression.\n * Use with `.default(now())` on text columns storing timestamps.\n *\n * - Postgres: `now()`\n * - SQLite: `(datetime('now'))`\n */\nexport function now() {\n return pg() ? sql`now()` : sql`(datetime('now'))`;\n}\n\nexport { and, desc, eq, inArray, isNull, or, sql } from \"drizzle-orm\";\n\n// Ownership / sharing primitives — templates opt a resource into the framework\n// sharing system by spreading ownableColumns() into the table and pairing it\n// with createSharesTable(). See .agents/skills/sharing/SKILL.md.\nexport {\n ownableColumns,\n createSharesTable,\n type Visibility,\n type ShareRole,\n type PrincipalType,\n} from \"../sharing/schema.js\";\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,OAAO,EACP,KAAK,IAAI,OAAO,EAChB,KAAK,IAAI,OAAO,EAChB,IAAI,IAAI,MAAM,EACd,OAAO,IAAI,SAAS,EACpB,OAAO,IAAI,SAAS,EACpB,eAAe,IAAI,iBAAiB,EACpC,WAAW,IAAI,aAAa,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,KAAK,IAAI,WAAW,EACpB,KAAK,IAAI,WAAW,EACpB,IAAI,IAAI,UAAU,EAClB,OAAO,IAAI,aAAa,EACxB,IAAI,IAAI,UAAU,EAClB,WAAW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,CAAC,CAAQ,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAyB,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;IAC/D,IAAI,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,SAAS,EAAE,CAAC;QACxC,OAAQ,SAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,EAAE,CAAC,CAAC,CAAE,SAAiB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAE,aAAqB,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9E,CAAC,CAAQ,CAAC;AAEV;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAsB,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE;IACzD,OAAO,EAAE,EAAE;QACT,CAAC,CAAE,iBAAyB,CAAC,GAAG,IAAI,CAAC;QACrC,CAAC,CAAE,UAAkB,CAAC,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC,CAAQ,CAAC;AAEV;;;;;;GAMG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA,mBAAmB,CAAC;AACpD,CAAC;AAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEtE,+EAA+E;AAC/E,6EAA6E;AAC7E,iEAAiE;AACjE,OAAO,EACL,cAAc,EACd,iBAAiB,GAIlB,MAAM,sBAAsB,CAAC","sourcesContent":["/**\n * Dialect-agnostic Drizzle schema helpers.\n *\n * Templates import `table`, `text`, `integer`, and `now` from here instead of\n * importing directly from `drizzle-orm/sqlite-core` or `drizzle-orm/pg-core`.\n * The correct dialect is chosen at runtime based on `DATABASE_URL`.\n *\n * Usage:\n * import { table, text, integer, now } from \"@agent-native/core/db/schema\";\n *\n * export const users = table(\"users\", {\n * id: text(\"id\").primaryKey(),\n * name: text(\"name\").notNull(),\n * active: integer(\"active\", { mode: \"boolean\" }).notNull().default(true),\n * createdAt: text(\"created_at\").notNull().default(now()),\n * });\n */\n\nimport { sql } from \"drizzle-orm\";\nimport {\n pgTable,\n alias as pgAlias,\n index as pgIndex,\n text as pgText,\n integer as pgInteger,\n boolean as pgBoolean,\n doublePrecision as pgDoublePrecision,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n sqliteTable,\n alias as sqliteAlias,\n index as sqliteIndex,\n text as sqliteText,\n integer as sqliteInteger,\n real as sqliteReal,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport { getDialect } from \"./client.js\";\n\n// No caching — getDialect() handles its own caching once env is available.\n// On CF Workers, this runs at import time before env bindings are set, so\n// caching here would lock in the wrong dialect.\nfunction pg(): boolean {\n return getDialect() === \"postgres\";\n}\n\n/**\n * Define a table. Delegates to `pgTable` or `sqliteTable` based on dialect.\n */\nexport const table: typeof sqliteTable = ((...args: any[]) =>\n pg() ? (pgTable as any)(...args) : (sqliteTable as any)(...args)) as any;\n\nexport const alias: typeof sqliteAlias = ((...args: any[]) =>\n pg() ? (pgAlias as any)(...args) : (sqliteAlias as any)(...args)) as any;\n\nexport const index: typeof sqliteIndex = ((...args: any[]) =>\n pg() ? (pgIndex as any)(...args) : (sqliteIndex as any)(...args)) as any;\n\nexport const uniqueIndex: typeof sqliteUniqueIndex = ((...args: any[]) =>\n pg()\n ? (pgUniqueIndex as any)(...args)\n : (sqliteUniqueIndex as any)(...args)) as any;\n\n/**\n * Text column. Works identically in both dialects.\n * Supports `{ enum: [...] }` config in both.\n */\nexport const text: typeof sqliteText = ((...args: any[]) =>\n pg() ? (pgText as any)(...args) : (sqliteText as any)(...args)) as any;\n\n/**\n * Integer column.\n *\n * Handles `{ mode: \"boolean\" }` transparently — maps to Postgres `boolean`\n * type when running against Postgres, and SQLite `integer` with boolean\n * coercion when running against SQLite.\n */\nexport const integer: typeof sqliteInteger = ((...args: any[]) => {\n if (pg() && args[1]?.mode === \"boolean\") {\n return (pgBoolean as any)(args[0]);\n }\n return pg() ? (pgInteger as any)(...args) : (sqliteInteger as any)(...args);\n}) as any;\n\n/**\n * Real/float column.\n *\n * Maps to `real` on SQLite and `double precision` on Postgres.\n * Use for decimal values like weight, macros, etc.\n */\nexport const real: typeof sqliteReal = ((...args: any[]) => {\n return pg()\n ? (pgDoublePrecision as any)(...args)\n : (sqliteReal as any)(...args);\n}) as any;\n\n/**\n * Dialect-agnostic \"current timestamp\" SQL expression.\n * Use with `.default(now())` on text columns storing timestamps.\n *\n * - Postgres: `now()`\n * - SQLite: `(datetime('now'))`\n */\nexport function now() {\n return pg() ? sql`now()` : sql`(datetime('now'))`;\n}\n\nexport { and, desc, eq, inArray, isNull, or, sql } from \"drizzle-orm\";\n\n// Ownership / sharing primitives — templates opt a resource into the framework\n// sharing system by spreading ownableColumns() into the table and pairing it\n// with createSharesTable(). See .agents/skills/sharing/SKILL.md.\nexport {\n ownableColumns,\n createSharesTable,\n type Visibility,\n type ShareRole,\n type PrincipalType,\n} from \"../sharing/schema.js\";\n"]}
@@ -49,11 +49,11 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
49
49
  }>;
50
50
  /** DELETE /_agent-native/resources/:id — delete a resource */
51
51
  export declare function handleDeleteResource(event: any): Promise<{
52
- error: string;
53
52
  ok?: undefined;
53
+ error: string;
54
54
  } | {
55
- ok: boolean;
56
55
  error?: undefined;
56
+ ok: boolean;
57
57
  }>;
58
58
  /** POST /_agent-native/resources/upload — upload a file as a resource */
59
59
  export declare function handleUploadResource(event: any): Promise<import("./store.js").Resource | {
@@ -73,9 +73,9 @@ export declare function handleUploadResource(event: any): Promise<import("./stor
73
73
  runId: string | null;
74
74
  expiresAt: number | null;
75
75
  metadata: string | null;
76
+ error?: undefined;
76
77
  url: string;
77
78
  provider: string;
78
- error?: undefined;
79
79
  }>;
80
80
  export {};
81
81
  //# sourceMappingURL=handlers.d.ts.map
@@ -20,7 +20,7 @@ export declare function createTranscribeVoiceHandler(): import("h3").EventHandle
20
20
  error: string;
21
21
  text?: undefined;
22
22
  } | {
23
- text: string;
24
23
  error?: undefined;
24
+ text: string;
25
25
  }>>;
26
26
  //# sourceMappingURL=transcribe-voice.d.ts.map
@@ -995,7 +995,7 @@
995
995
  min-height: 100%;
996
996
  overflow: hidden;
997
997
  box-sizing: border-box;
998
- background: var(--wf-paper);
998
+ background: transparent;
999
999
  color: var(--wf-ink);
1000
1000
  font-family: var(--wf-font);
1001
1001
  font-size: 14px;
@@ -1177,6 +1177,16 @@
1177
1177
  border-radius: var(--wf-radius);
1178
1178
  padding: 12px;
1179
1179
  }
1180
+ .plan-html-frame:not([data-render-mode="design"]) .wf-row {
1181
+ display: flex;
1182
+ align-items: center;
1183
+ justify-content: space-between;
1184
+ gap: 10px;
1185
+ }
1186
+ .plan-html-frame:not([data-render-mode="design"]) .wf-row > :last-child {
1187
+ margin-inline-start: auto;
1188
+ text-align: end;
1189
+ }
1180
1190
  .plan-html-frame[data-style="sketchy"]:not([data-render-mode="design"])
1181
1191
  :is(.wf-card, .wf-box) {
1182
1192
  border-color: color-mix(in srgb, var(--wf-line) 72%, transparent);
@@ -1197,9 +1207,9 @@
1197
1207
  background: var(--wf-accent-soft);
1198
1208
  }
1199
1209
 
1200
- /* Once rough has drawn, hide crisp borders only on elements rough.js actually
1201
- redraws. Broad helper containers keep theme-safe filled backgrounds and soft
1202
- borders so nested cards do not become a pile of overlapping sketch strokes. */
1210
+ /* Once rough has drawn, hide crisp borders on the standard wireframe primitives
1211
+ that rough.js redraws. Fills and text stay in CSS; only outlines switch to
1212
+ the hand-drawn overlay. */
1203
1213
  .plan-html-frame[data-rough-ready]
1204
1214
  :is(
1205
1215
  button,
@@ -1207,8 +1217,19 @@
1207
1217
  textarea,
1208
1218
  select,
1209
1219
  hr,
1210
- [data-rough]:not([data-rough="none"])
1211
- ) {
1220
+ .wf-btn,
1221
+ .wf-card,
1222
+ .wf-box,
1223
+ .wf-pill,
1224
+ .wf-chip,
1225
+ .wf-icon-fallback,
1226
+ [style*="border:"],
1227
+ [style*="border-top:"],
1228
+ [style*="border-right:"],
1229
+ [style*="border-bottom:"],
1230
+ [style*="border-left:"],
1231
+ [data-rough]
1232
+ ):not([data-rough="none"]) {
1212
1233
  border-color: transparent !important;
1213
1234
  }
1214
1235
 
@@ -16,8 +16,9 @@ Actions are the single source of truth for anything your app does. Define an act
16
16
  - **A CLI command** — `pnpm action <name>` for scripting and dev loops.
17
17
 
18
18
  One definition, seven consumers. This is rung 3 of the [ladder](/docs/what-is-agent-native#the-ladder).
19
- If you are deciding whether to expose an operation headlessly, in chat, in an
20
- embedded sidecar, or as a full app screen, see [Agent Surfaces](/docs/agent-surfaces).
19
+ In the default getting-started flow, the action first appears as an agent tool in
20
+ chat, then as a native inline result, then as the operation behind a durable app
21
+ page. For the full surface map, see [Agent Surfaces](/docs/agent-surfaces).
21
22
 
22
23
  <Diagram id="doc-block-xcp5x6" title="One definition, seven consumers" summary={"A single defineAction() fans out to every surface — agent, UI, HTTP, MCP, A2A, and CLI — with one validated schema and one run() body."}>
23
24
 
@@ -93,9 +94,8 @@ For App Operations](/docs/server#actions-first).
93
94
 
94
95
  ## Start with one action {#hello-action}
95
96
 
96
- The primitive-first on-ramp is one action, not a template. In a headless
97
- scaffold such as `agent-native create my-agent --headless`, this can be the
98
- whole first app:
97
+ The first operation in a chat-first app can be tiny. In the Chat template,
98
+ replace `actions/hello.ts` or add a new file beside it:
99
99
 
100
100
  ```ts
101
101
  // actions/hello.ts
@@ -477,19 +477,19 @@ and use [MCP Apps](/docs/mcp-apps) for inline UI in external MCP hosts.
477
477
 
478
478
  ```ts
479
479
  import { defineAction } from "@agent-native/core/action";
480
- import { ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER } from "@agent-native/core/action-ui";
480
+ import { ACTION_CHAT_UI_DATA_CHART_RENDERER } from "@agent-native/core/action-ui";
481
481
  import {
482
- createDataInsightsWidgetResult,
483
- dataInsightsWidgetResultSchema,
482
+ createDataChartWidgetResult,
483
+ dataChartWidgetResultSchema,
484
484
  } from "@agent-native/core/data-widgets";
485
485
 
486
486
  export default defineAction({
487
487
  description: "Summarize response trends.",
488
488
  readOnly: true,
489
- outputSchema: dataInsightsWidgetResultSchema,
490
- chatUI: { renderer: ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER },
489
+ outputSchema: dataChartWidgetResultSchema,
490
+ chatUI: { renderer: ACTION_CHAT_UI_DATA_CHART_RENDERER },
491
491
  run: async () =>
492
- createDataInsightsWidgetResult({
492
+ createDataChartWidgetResult({
493
493
  title: "Response trends",
494
494
  chartSeries: {
495
495
  type: "line",
@@ -500,26 +500,19 @@ export default defineAction({
500
500
  { day: "Tue", responses: 18 },
501
501
  ],
502
502
  },
503
- table: {
504
- columns: [
505
- { key: "day", label: "Day" },
506
- { key: "responses", label: "Responses", align: "right" },
507
- ],
508
- rows: [
509
- { day: "Mon", responses: 12 },
510
- { day: "Tue", responses: 18 },
511
- ],
512
- },
513
503
  }),
514
504
  });
515
505
  ```
516
506
 
517
507
  The built-in discriminants are `"data-table"`, `"data-chart"`, and
518
508
  `"data-insights"`, with server-safe builders and schemas in
519
- `@agent-native/core/data-widgets`. See [Native Chat UI](/docs/native-chat-ui)
520
- for the full result contract and BYO runtime guidance, or
509
+ `@agent-native/core/data-widgets`. Use `data-chart` for chart-only answers,
510
+ `data-table` for SQL/list results, and `data-insights` only when a combined
511
+ summary/chart/table card is the right output. See
512
+ [Native Chat UI](/docs/native-chat-ui) for the full result contract and BYO
513
+ runtime guidance, or
521
514
  [Agent Surfaces](/docs/agent-surfaces) for how the same action can stay
522
- headless, render in chat, or grow into a full screen.
515
+ automation-friendly, render in chat, or grow into a full screen.
523
516
 
524
517
  ## Calling it from the CLI {#cli}
525
518