Kaynağa Gözat

docs(visualizer): require self-contained widget sources

ZiyaZhang 4 hafta önce
ebeveyn
işleme
b80e22ec2d

+ 2 - 2
docs/tool-catalog.i18n.yaml

@@ -2,5 +2,5 @@
 # side as of the last confirmed-consistent state. Both languages carry equal authority;
 # after editing either side, bring the other along and re-record with:
 #   pnpm run verify-translation-pairing --write docs/tool-catalog.md
-tool-catalog.md: ac1b84c279247990f22728995684f8d4ca6e5254
-tool-catalog.zh.md: 42071bbbf65fb0fb1ace66e8b1858a834a4b5e12
+tool-catalog.md: 731d7b0c45d2e2834848fbb2e27440e5ac8a7401
+tool-catalog.zh.md: b976a15113cb2272f2e51c8a688abcb34131be68

+ 1 - 1
docs/tool-catalog.md

@@ -2097,7 +2097,7 @@ Render one temporary inline graphic or interactive widget from conversation cont
     },
     "widget_code": {
       "type": "string",
-      "description": "For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. External resources are blocked; inline everything."
+      "description": "For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. Keep the widget self-contained: include all required styles, scripts, data, and assets in the source."
     }
   },
   "required": [

+ 1 - 1
docs/tool-catalog.zh.md

@@ -2104,7 +2104,7 @@ todo_write 是会话所有的状态;UI 将最新的 todo/write 事件渲染为
     },
     "widget_code": {
       "type": "string",
-      "description": "For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. External resources are blocked; inline everything."
+      "description": "For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. Keep the widget self-contained: include all required styles, scripts, data, and assets in the source."
     }
   },
   "required": [

+ 1 - 1
packages/visualizer/tool-visualizer/src/tools.ts

@@ -49,7 +49,7 @@ export function registerVisualizerTools(
   ctx: Context,
   limits: { readonly maxTitleBytes: number; readonly maxWidgetBytes: number },
 ): void {
-  const sourceDescription = 'For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. External resources are blocked; inline everything.'
+  const sourceDescription = 'For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. Keep the widget self-contained: include all required styles, scripts, data, and assets in the source.'
 
   ctx.tools.register(defineTool({
     name: 'widget_guidelines',

+ 1 - 1
packages/visualizer/tool-visualizer/tests/__snapshots__/model-surface.spec.ts.snap

@@ -87,7 +87,7 @@ exports[`Visualizer model surface > ships one neutral SVG and HTML model surface
             "type": "string",
           },
           "widget_code": {
-            "description": "For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. External resources are blocked; inline everything.",
+            "description": "For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. Keep the widget self-contained: include all required styles, scripts, data, and assets in the source.",
             "type": "string",
           },
         },

+ 3 - 1
packages/visualizer/tool-visualizer/tests/model-surface.spec.ts

@@ -171,7 +171,9 @@ describe('Visualizer model surface', () => {
     expect(sourceDescription).toContain('<canvas> using 2D or WebGL')
     expect(sourceDescription).toContain('inline <script>')
     expect(sourceDescription).toContain('For SVG: raw SVG')
-    expect(sourceDescription).toContain('External resources are blocked; inline everything')
+    expect(sourceDescription).toContain(
+      'Keep the widget self-contained: include all required styles, scripts, data, and assets in the source',
+    )
     expect(sourceDescription).not.toContain('load and follow the interactive widget_guidelines module')
     expect(sourceDescription).not.toContain('window.dshWidget')
   })

+ 1 - 1
snapshots/web/visualizer-host/tool-schemas.expected.json

@@ -416,7 +416,7 @@
           },
           "widget_code": {
             "type": "string",
-            "description": "For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. External resources are blocked; inline everything."
+            "description": "For HTML: one fragment. Put any inline <style> first, content next (semantic HTML, inline <svg>, <canvas> using 2D or WebGL, or native controls), and any inline <script> last. For SVG: raw SVG beginning with <svg>, with a viewBox that declares its aspect ratio. Keep the widget self-contained: include all required styles, scripts, data, and assets in the source."
           }
         },
         "required": [