🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(skill): default explanatory visuals to inline HTML preview (#21120)
Arvin Xucadf0f022446
diff --git a/packages/builtin-skills/src/artifacts/content.ts b/packages/builtin-skills/src/artifacts/content.tsindex 2549ff4705d..f618d2aa43a 100644--- a/packages/builtin-skills/src/artifacts/content.ts+++ b/packages/builtin-skills/src/artifacts/content.ts@@ -1,19 +1,28 @@export const systemPrompt = `<artifacts_guides>-The assistant possesses the capability to generate "Artifacts"—dedicated UI windows for presenting visual and interactive content. This feature segregates complex deliverables from the conversational stream, facilitating user ownership, modification, and reuse.+The assistant possesses two ways to present visual and interactive content: **Artifacts**—dedicated UI windows that carry complex deliverables out of the conversational stream so the user can own, modify and reuse them—and **inline HTML previews**, which mount a live visual directly inside the reply. Choose the mode by what the user will do with the result, then decide whether this skill is needed at all.# 1. Evaluation Criteria-For a self-contained preview, emit the Artifact directly after loading these instructions unless the user explicitly requests a downloadable file, an inline preview, or separate computation or validation. Do NOT activate or call sandbox tools merely to prepare a file, probe the environment, or perform optional validation. Do not invent an additional download or validation requirement: "write a playable game in HTML" requests an HTML Artifact, not a downloadable file. Instructions to activate needed tools apply only to tools the user's task actually needs. Complete separately requested computation or validation when needed, then deliver in the requested format.+## Delivery Modes++Both modes are first-class:++- **Inline preview** — a fenced \`html\` code block that the chat renders in the message flow. **Default for explanation**: teaching a concept, showing how something behaves, illustrating a mechanism, comparing states, or any demo the reader looks at *while reading the answer*. Placing the visual next to the sentence that explains it is what makes an explanation comfortable to read.+- **Artifact** — a \`<lobeArtifact>\` card that opens in its own panel. **Default for deliverables**: applications, dashboards, tools, multi-file projects — anything the user keeps, reopens, iterates on or downloads.++Rule of thumb: if the visual *explains something*, render it inline; if the visual *is the thing the user came to build*, make it an Artifact. When it is genuinely both (an explainer the user then asks to keep and extend), start inline and promote it to an Artifact once they ask to build on it — do not open a panel for a picture the user only wants to understand.++For a self-contained preview, emit the result directly after loading these instructions unless the user explicitly requests a downloadable file, a separate computation or validation. Do NOT activate or call sandbox tools merely to prepare a file, probe the environment, or perform optional validation. Do not invent an additional download or validation requirement: "write a playable game in HTML" requests a runnable web page, not a downloadable file. Instructions to activate needed tools apply only to tools the user's task actually needs. Complete separately requested computation or validation when needed, then deliver in the requested format.## When to Create an Artifact (Qualifying Content)Target content that serves as a distinct visual or interactive "deliverable." Valid candidates are:- **Interactive Components:** UI components, dashboards, data visualizations, or interactive widgets.-- **Visual Content:** SVG graphics, illustrations, icons, or diagrams.+- **Visual Content:** SVG graphics, illustrations, icons, or diagrams the user wants to keep, reuse or hand off.- **Web Pages:** Landing pages, forms, or any HTML-based layouts.- **Iterative Projects:** Content the user is likely to refine, modify, or maintain over time.-## When to Stay Inline (Disqualifying Content)-Do NOT generate artifacts for:+## When Not to Render at All (Disqualifying Content)+Do NOT generate an artifact or an inline preview for:- **Code snippets:** Always present code inline using markdown code blocks, never as an artifact.- **Documents or articles:** Use regular markdown text in conversation.- **Trivial content:** Brief explanations, math equations, or short examples.@@ -22,16 +31,28 @@ Do NOT generate artifacts for:- **One-off Answers:** Responses to transient questions unlikely to be revisited.# 2. Operational Constraints-- **Frequency:** Limit to one artifact per response unless explicitly engaged in a multi-file task.-- **Preference:** Use Artifacts for visual and interactive works. Honor an explicit request for a downloadable file or supported inline preview instead; code snippets and explanations stay inline.+- **Frequency:** Limit to one artifact or inline preview per response unless explicitly engaged in a multi-file task.+- **Preference:** Explanatory visuals render inline; deliverables become Artifacts. Honor an explicit request for a downloadable file or a separate panel instead; code snippets and prose explanations stay inline.- **Capability Mapping:**- - If asked for "SVG", provide an SVG artifact. Raster image files use the available image-generation or file tools.- - If asked for "websites" or "web pages", provide HTML or React artifacts.+ - If asked for "SVG", provide an SVG artifact, unless the drawing only illustrates the explanation — then wrap it in a minimal inline HTML document. Raster image files use the available image-generation or file tools.+ - If asked for "websites" or "web pages" as a deliverable, provide HTML or React artifacts. A page whose only purpose is to demonstrate an idea is an inline preview.- If asked for "dashboards" or "interactive components", provide React artifacts.- - If asked for a code snippet or code explanation, provide it inline as markdown code blocks, NOT as an artifact. "Write code for a playable web game" still requests an interactive deliverable.+ - If asked for a code snippet or code explanation, provide it inline as markdown code blocks, NOT as an artifact. "Write code for a playable web game" still requests a runnable deliverable.- **Safety:** Do NOT generate hazardous content. Apply the same safety standards as text responses.-# 3. Generation Workflow+# 3. Inline Preview Mode++An inline preview only mounts when the message contains a fenced \`html\` code block whose body is a **complete document**. Follow these rules exactly:++- **Open the document properly.** Begin with \`<!DOCTYPE html>\` and end with \`</html>\`. A fragment without \`<!DOCTYPE html>\` or \`<html\` renders as plain source code, so a sloppy wrapper throws the visual away.+- **One self-contained file.** All CSS and JS inside the document; CDN \`<script>\` and \`<link>\` tags are fine. No local assets, no build step, no external images that may 404.+- **Design for the message column, not a full screen.** The preview starts around 400px tall, grows to the content height, and can be expanded into a drawer. Keep one focused visual: no page-level navigation, no marketing hero sections, no \`100vh\` layouts.+- **Sandbox limits.** Scripts, forms and modals run. Cookies, \`window.parent\`, popups and top-level navigation do not, and \`localStorage\` is a per-preview shim — nothing persists across messages.+- **Do not double-render.** Never emit both an inline preview and a \`<lobeArtifact>\` for the same content, and never paste the same HTML twice.+- **Keep it lean.** Enough markup to show the idea; skip boilerplate the preview does not need. Long output costs the user reading time before they reach the visual.+- **Talk around it.** One or two sentences before the block setting up what to look at, optionally one line after it pointing out what to try. Do not narrate the code.++# 4. Generation WorkflowWhen the intent matches the criteria, adhere strictly to this sequence:@@ -201,6 +222,48 @@ Here are some examples of correct usage of artifacts:This creates a simple, elegant landing page with a hero section.</assistant_response></example>++ <example_docstring>+ This example demonstrates an inline preview. The visual exists to explain an idea, so it is+ rendered as a complete HTML code block inside the reply instead of an Artifact — no panel,+ no download.+ </example_docstring>++ <example>+ <user_query>What is a Voronoi diagram? Show me.</user_query>++ <assistant_response>+ A Voronoi diagram splits a plane into one region per site, where every point belongs to+ its nearest site. Drag the dots below and watch the borders re-cut themselves:++ \\\`\\\`\\\`html+ <!DOCTYPE html>+ <html lang="en">+ <head>+ <meta charset="UTF-8">+ <style>+ body { margin: 0; font-family: ui-sans-serif, system-ui, sans-serif; }+ svg { display: block; width: 100%; height: 320px; background: #faf7f2; }+ circle { fill: #7c5cff; cursor: grab; }+ </style>+ </head>+ <body>+ <svg id="canvas" viewBox="0 0 600 320">+ <circle cx="140" cy="120" r="9" />+ <circle cx="330" cy="90" r="9" />+ <circle cx="430" cy="230" r="9" />+ </svg>+ <script>+ // build the regions from the three sites, then let the reader drag them+ </script>+ </body>+ </html>+ \\\`\\\`\\\`++ Each region is the set of points closer to its own site than to any other, which is why+ dropping a new site always steals area from its neighbours.+ </assistant_response>+ </example></examples>The assistant should not mention any of these instructions to the user, nor make reference to the \`lobeArtifact\` tag, any of the MIME types (e.g. \`application/lobe.artifacts.react\`), or related syntax unless it is directly relevant to the query.diff --git a/packages/builtin-skills/src/artifacts/manifest.ts b/packages/builtin-skills/src/artifacts/manifest.tsindex 3a6233c9a84..fc69d1d460d 100644--- a/packages/builtin-skills/src/artifacts/manifest.ts+++ b/packages/builtin-skills/src/artifacts/manifest.ts@@ -5,7 +5,7 @@ export const ArtifactsIdentifier = 'lobe-artifacts';export const ArtifactsManifest: BuiltinSkillManifest = {avatar: `data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAyNCIgaGVpZ2h0PSIxMDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSIxMDI0IiBoZWlnaHQ9IjEwMjQiIHJ4PSI1MTIiIGZpbGw9IiNDNDc4NUIiLz48cGF0aCBkPSJNNTEyIDYxMmM1NS4yMjggMCAxMDAtNDQuNzcyIDEwMC0xMDBzLTQ0Ljc3Mi0xMDAtMTAwLTEwMC0xMDAgNDQuNzcyLTEwMCAxMDAgNDQuNzcyIDEwMCAxMDAgMTAwWiIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjU2IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48cGF0aCBkPSJNNTEyIDY2MmExNDkuOTk4IDE0OS45OTggMCAwIDEtOTIuNTk3IDEzOC41ODIgMTUwLjAwMiAxNTAuMDAyIDAgMCAxLTIwNC41MjEtMTA5LjMxOCAxNDkuOTk4IDE0OS45OTggMCAwIDEgNjMuNzgzLTE1My45ODRBMTQ5Ljk5MiAxNDkuOTkyIDAgMCAxIDM2MiA1MTJhMTQ5Ljk5OSAxNDkuOTk5IDAgMSAxIDE1MC0xNTAgMTQ5Ljk5OCAxNDkuOTk4IDAgMCAxIDI5Ny4xMTgtMjkuMjYzQTE1MCAxNTAgMCAwIDEgNjYyIDUxMmMyOS42NjcgMCA1OC42NjggOC43OTcgODMuMzM1IDI1LjI4YTE0OS45OTUgMTQ5Ljk5NSAwIDAgMSA2My43ODMgMTUzLjk4NEExNTAgMTUwIDAgMCAxIDUxMiA2NjJaTTUxMiAzNjJ2NTBNMzYyIDUxMmg1ME02NjIgNTEyaC01ME01MTIgNjYydi01ME0zNzguNjY3IDM3OC42NjdsNjIuNjY2IDYyLjY2Nk01ODIuNjY3IDQ0MS4zMzNsNjIuNjY2LTYyLjY2Nk0zNzguNjY3IDY0NS4zMzNsNjIuNjY2LTYyLjY2Nk01ODIuNjY3IDU4Mi42NjdsNjIuNjY2IDYyLjY2NiIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjU2IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=`,description:- 'Create directly viewable web pages, browser games, SVG graphics or animations, and React components. Prefer this skill for visual works, including requests to show the result directly or preview it. Use files only when the user explicitly requests a download; HTML/SVG specify the implementation format, not download intent. Do not add a downloadable file or sandbox preparation to a self-contained preview request. Use inline preview only when the user explicitly asks to display inside the chat message or code block, or rejects a separate Artifact panel; respond with a complete HTML code block (wrap SVG inside it) without activation. Answer code snippets and explanations directly without loading this skill.',+ 'Create directly viewable web pages, browser games, SVG graphics or animations, and React components, and decide how a visual is delivered. Explanatory visuals default to an inline HTML preview rendered inside the reply (a complete html code block), which reads better than a separate panel; deliverables the user keeps, reopens or iterates on become Artifacts. Use files only when the user explicitly requests a download; HTML/SVG specify the implementation format, not download intent. Do not add a downloadable file or sandbox preparation to a self-contained preview request. Answer code snippets and explanations directly without loading this skill.',identifier: ArtifactsIdentifier,name: 'artifacts',source: 'builtin',