Skip to content

Self-improving AI Employees for everyone

feat(plugins): let meta.json point at a library icon

trohitg1f5d1b9ae4eb
diff --git a/client/src/assets/icons/index.test.ts b/client/src/assets/icons/index.test.ts
index 74004b8f..aa4fc11f 100644
--- a/client/src/assets/icons/index.test.ts
+++ b/client/src/assets/icons/index.test.ts
@@ -10,9 +10,24 @@
* - asset:* / data: / http: / emoji passthrough still behaves
*/
+import { readFileSync, readdirSync, statSync } from 'node:fs';
+import { join } from 'node:path';
+
import { describe, it, expect } from 'vitest';
import { resolveLibraryIcon, resolveIcon } from './index';
+/** Every `meta.json` under server/nodes, found without a glob dependency. */
+const pluginMetaFiles = (dir: string): string[] => {
+ const found: string[] = [];
+ for (const entry of readdirSync(dir)) {
+ if (entry === '__pycache__' || entry === 'node_modules') continue;
+ const path = join(dir, entry);
+ if (statSync(path).isDirectory()) found.push(...pluginMetaFiles(path));
+ else if (entry === 'meta.json') found.push(path);
+ }
+ return found;
+};
+
describe('resolveLibraryIcon', () => {
it('resolves a lucide icon to a forwardRef React component', () => {
const Icon = resolveLibraryIcon('lucide:Battery');
@@ -38,6 +53,39 @@ describe('resolveLibraryIcon', () => {
expect(Icon).not.toBeNull();
});
+ /**
+ * Cross-language contract. The backend lets a plugin point at a library
+ * glyph from its own meta.json instead of vendoring an SVG, and nothing
+ * on the Python side can tell whether the name actually exists here.
+ *
+ * The specific trap: lucide's lookup index is keyed on lowercased
+ * *export* names, so `lucide:CheckCheck` resolves and the kebab-case
+ * file name `lucide:check-check` does not. That failure is silent -- the
+ * node renders no icon rather than erroring -- so it is asserted here.
+ */
+ it('resolves every library icon declared in a plugin meta.json', () => {
+ const nodesDir = join(__dirname, '..', '..', '..', '..', 'server', 'nodes');
+ const declared: Array<[string, string]> = [];
+
+ for (const file of pluginMetaFiles(nodesDir)) {
+ const meta = JSON.parse(readFileSync(file, 'utf-8')) as {
+ icon?: string;
+ icons?: Record<string, string>;
+ };
+ const refs = [meta.icon, ...Object.values(meta.icons ?? {})];
+ for (const ref of refs) {
+ if (ref && ref.includes(':')) declared.push([file, ref]);
+ }
+ }
+
+ // Guards the guard: if the discovery ever breaks, the loop below would
+ // vacuously pass.
+ expect(declared.length).toBeGreaterThan(0);
+
+ const unresolved = declared.filter(([, ref]) => resolveLibraryIcon(ref) === null);
+ expect(unresolved).toEqual([]);
+ });
+
it('returns null for unknown library prefixes', () => {
expect(resolveLibraryIcon('madeup:Battery')).toBeNull();
});
diff --git a/docs-internal/node_creation.md b/docs-internal/node_creation.md
index adee801a..593e092c 100644
--- a/docs-internal/node_creation.md
+++ b/docs-internal/node_creation.md
@@ -225,13 +225,14 @@ walker does on startup), these registrations happen automatically:
| Credentials | `CREDENTIAL_REGISTRY` | `Credential.__init_subclass__` when `_credentials.py` is imported |
| Trigger registry + filter builders | `event_waiter.TRIGGER_REGISTRY`, `FILTER_BUILDERS` | back-fill from `TriggerNode` subclasses on first lookup |
| Temporal activity wrapper | `cls.as_activity()` | first call; pooled into the worker queue declared by `task_queue` |
-| Palette icon | `<plugin_folder>/icon.svg` (or `icon_<nodeType>.svg` for multi-node folders); served via `GET /api/schemas/nodes/<type>/icon`. `visuals.json` is the fallback for emoji or `lobehub:<brand>` icons. |
+| Palette icon | `<plugin_folder>/meta.json` → `"icons": {"<nodeType>": "lucide:Send"}` (preferred — no artwork to vendor), or `icon.svg` / `icon_<nodeType>.svg` served via `GET /api/schemas/nodes/<type>/icon` when a brand mark is needed. Resolution: SVG file → plugin `meta.json` ref → `visuals.json`. |
| Palette color | `<plugin_folder>/meta.json` (`{"color": "#xxx"}`); `visuals.json` is the fallback for legacy entries (post-F2 it has zero color fields). |
What you **do** still write:
-- Drop `icon.svg` (or `icon_<nodeType>.svg` for multi-node folders) and `meta.json` (`{"color": "#xxx"}`) inside the plugin folder. The class-attribute icon/color override was removed in F1 — declaring `icon` or `color` as class attrs has no effect.
-- An entry in `server/nodes/visuals.json` ONLY if you want an emoji or `lobehub:<brand>` icon (no folder SVG). Post-F1/F7 visuals.json carries zero `asset:<key>` values.
+- A `meta.json` inside the plugin folder carrying `{"color": "#xxx"}` and, preferably, the icon as a library reference: `"icons": {"<nodeType>": "lucide:Send"}` per node type, or `"icon"` for one glyph across the folder. Use the library's **export** name (`lucide:CheckCheck`), not its kebab-case file name — the lookup is against package exports, and a miss renders nothing rather than erroring. Locked by `client/src/assets/icons/index.test.ts`.
+- `icon.svg` (or `icon_<nodeType>.svg` for multi-node folders) only when the node needs artwork no library has — typically a brand mark. A file beats a `meta.json` ref, so shipping both makes the ref dead. The class-attribute icon/color override was removed in F1 — declaring `icon` or `color` as class attrs has no effect.
+- An entry in `server/nodes/visuals.json` is the legacy central fallback, for plugins with neither of the above. Post-F1/F7 it carries zero `asset:<key>` values.
- A **lowercase alias entry in `visuals.json` keyed by the LLM `tool_name`** whenever you set `tool_name` to something other than `<snake_case_of_node_type>` AND ship a paired skill. The skill icon resolver maps the SKILL.md `allowed-tools` token (= the tool name) through snake→camel into `visuals.json`; a custom tool name misses the node-type key and the Master Skill row renders a blank icon. The alias carries the same icon plus the plugin's `meta.json` color — precedent: `"github": {"icon": "lobehub:Github", "color": "#8250df"}`, `"vercel": {"icon": "lobehub:Vercel", "color": "#666666"}`. Locked by `server/tests/test_skill_icon_resolution.py`.
- An entry in `server/nodes/groups.py` if you introduce a new palette group.
diff --git a/docs-internal/plugin_system.md b/docs-internal/plugin_system.md
index 49780c0b..e30fb84e 100644
--- a/docs-internal/plugin_system.md
+++ b/docs-internal/plugin_system.md
@@ -66,7 +66,7 @@ class SpecializedAgentBase(ActionNode, abstract=True):
| `type` | Node type string. Matches workflow JSON + registry key. |
| `version` | Int, bumped on breaking changes. Activity name includes it. |
| `display_name` / `subtitle` / `description` | Palette + panel header. |
-| *(icon / color)* | **Not class attributes** (removed in F1 — declaring them has no effect). Icon: co-located `icon.svg` (or a `visuals.json` entry for emoji / `lobehub:<brand>`); color: co-located `meta.json` `{"color": "#..."}`. Wire format on the NodeSpec stays `asset:<key>` / `<lib>:<brand>` / URL / emoji. |
+| *(icon / color)* | **Not class attributes** (removed in F1 — declaring them has no effect). Icon resolves co-located `icon.svg` / `icon_<nodeType>.svg` → the plugin's own `meta.json` (`"icons": {"<nodeType>": "lucide:Send"}`, or folder-wide `"icon"`) → `visuals.json`. Prefer the `meta.json` ref: it reuses a library the frontend already bundles, so there is no artwork to vendor. Color: co-located `meta.json` `{"color": "#..."}`. Wire format on the NodeSpec stays `asset:<key>` / `<lib>:<brand>` / URL / emoji. |
| `group` | Tuple of palette groupings (first is primary). |
| `component_kind` | Frontend dispatch: `square` / `trigger` / `agent` / `tool` / `model` / `start` / `generic`. |
| `handles` | React Flow handle topology (`input-main`, `output-main`, …). |
diff --git a/server/nodes/README.md b/server/nodes/README.md
index c0fcc178..17df18b3 100644
--- a/server/nodes/README.md
+++ b/server/nodes/README.md
@@ -44,12 +44,16 @@ class AcmeOutput(BaseModel):
# 4. The node. (Icon + color are NOT declared on the class.
-# Icon: drop `icon.svg` into THIS plugin folder. For per-node-type
-# icons in multi-node folders (telegram / whatsapp / stripe),
-# use `icon_<nodeType>.svg`. The resolver picks per-node first,
-# falling back to shared `icon.svg`. Emoji / `lobehub:<brand>`
-# entries live in `server/nodes/visuals.json` for plugins
-# without a co-located SVG.
+# Icon: prefer a library glyph over vendored artwork — add
+# `"icons": {"<nodeType>": "lucide:Send"}` to THIS folder's
+# meta.json (or `"icon"` for one glyph across the folder).
+# Use `lucide:<ExportName>` (`CheckCheck`, NOT `check-check` —
+# lookup is on the package's exports) or `lobehub:<brand>`.
+# Ship `icon.svg` only for artwork no library has, typically a
+# brand mark; `icon_<nodeType>.svg` for per-node artwork in
+# multi-node folders. A file always beats a meta.json ref, so
+# don't ship both. `server/nodes/visuals.json` is the legacy
+# central registry for plugins with neither.
# Color: create `meta.json` with `{"color": "#abcdef"}` in this folder.
# BaseNode._metadata_dict resolves both at registration time via the
# central handler at server/nodes/_visuals.py.)
diff --git a/server/nodes/_visuals.py b/server/nodes/_visuals.py
index db9c72a7..3243fd08 100644
--- a/server/nodes/_visuals.py
+++ b/server/nodes/_visuals.py
@@ -7,18 +7,28 @@ Two icon sources co-exist by design (per RFC §6.5):
:func:`get_plugin_icon_path`. Preferred for new plugins; served
by ``GET /api/schemas/nodes/{type}/icon`` (see ``routers/schemas.py``).
-2. **``visuals.json``** for emoji entries and library-icon
- (``lobehub:<brand>``) entries that don't map to a file. Resolved
- via :func:`get_icon` / :func:`get_color`.
-
-``BaseNode._metadata_dict`` checks the per-folder path first and
-falls back to ``visuals.json``. The frontend resolver dispatches by
-the wire-format prefix (URL paths route to ``<img>``; ``asset:``,
-``lobehub:``, emoji each have their own branch).
-
-Adding a new node:
-- Drop ``icon.svg`` into the plugin folder, OR
-- Add an entry to ``visuals.json`` (emoji or ``lobehub:<brand>``).
+2. **Per-plugin ``meta.json``** for library references that need no
+ artwork at all — ``{"icons": {"<node_type>": "lucide:Send"}}``.
+ Resolved via :func:`get_plugin_icon_ref`. Keeps a plugin's visual
+ surface inside its own folder, the same way ``color`` already lives
+ there, while reusing an icon set the frontend already bundles.
+
+3. **``visuals.json``** for emoji and library entries belonging to
+ plugins that predate per-folder ``meta.json``. Resolved via
+ :func:`get_icon` / :func:`get_color`.
+
+``BaseNode._metadata_dict`` tries the co-located SVG, then the plugin's
+own ``meta.json``, then ``visuals.json``. The frontend resolver
+dispatches by the wire-format prefix (URL paths route to ``<img>``;
+``lucide:``, ``lobehub:``, ``asset:`` and emoji each have their own
+branch).
+
+Adding a new node, in order of preference:
+- Declare ``icons`` / ``icon`` in the plugin's ``meta.json`` pointing at
+ a library glyph (nothing to draw, nothing to maintain), OR
+- Drop ``icon.svg`` into the plugin folder when the node needs artwork
+ a library does not have — typically a brand mark, OR
+- Add an entry to ``visuals.json`` (legacy central registry).
Node files do NOT declare ``icon`` or ``color`` themselves.
"""
@@ -81,6 +91,44 @@ def get_color(node_type: str) -> str:
return str(entry.get("color", ""))
+def get_plugin_icon_ref(node_type: str) -> str:
+ """Return a library/emoji icon reference from the plugin's ``meta.json``.
+
+ The file-based chain (:func:`get_plugin_icon_path`) only answers with an
+ SVG on disk. This is its no-file counterpart, so a plugin can point at
+ an icon that already exists in a library instead of vendoring artwork:
+
+ {"color": "#128C7E",
+ "icons": {"whatsappBusinessSend": "lucide:Send"}}
+
+ Two levels, mirroring the ``icon_<node_type>.svg`` / ``icon.svg`` pair:
+
+ 1. ``icons[<node_type>]`` — per-node-type, for folders that serve
+ several node types from one plugin directory.
+ 2. ``icon`` — one reference for every node type in the folder.
+
+ Values use the same wire format the frontend's resolver understands
+ (``lucide:<Name>``, ``lobehub:<brand>``, emoji). ``lucide`` names are
+ matched case-insensitively against the package's own exports, so they
+ are the export identifier (``CheckCheck``), not the kebab-case file
+ name (``check-check``), which would not resolve.
+
+ Returns ``""`` when nothing is declared, so callers can fall through to
+ :func:`get_icon`. Note a folder that also ships ``icon.svg`` never
+ reaches here: the file wins. A plugin choosing library references
+ should not vendor an SVG as well.
+ """
+ meta = get_plugin_meta(node_type)
+ if not isinstance(meta, dict):
+ return ""
+ per_type = meta.get("icons")
+ if isinstance(per_type, dict):
+ value = per_type.get(node_type)
+ if value:
+ return str(value)
+ return str(meta.get("icon") or "")
+
+
def get_plugin_meta(node_type: str, key: Optional[str] = None) -> Optional[dict | str]:
"""Read the plugin's co-located ``meta.json`` file.
diff --git a/server/services/plugin/base.py b/server/services/plugin/base.py
index 1ed52e20..5e20cadd 100644
--- a/server/services/plugin/base.py
+++ b/server/services/plugin/base.py
@@ -286,13 +286,18 @@ class BaseNode:
get_icon,
get_color,
get_plugin_icon_path,
+ get_plugin_icon_ref,
get_plugin_meta,
)
+ # Co-located SVG, then the plugin's own meta.json (library
+ # reference), then the central visuals.json. Same shape as the
+ # color lookup below: plugin folder first, central registry as the
+ # legacy fallback.
if get_plugin_icon_path(cls.type) is not None:
icon = f"/api/schemas/nodes/{cls.type}/icon"
else:
- icon = get_icon(cls.type)
+ icon = get_plugin_icon_ref(cls.type) or get_icon(cls.type)
color = get_plugin_meta(cls.type, "color") or get_color(cls.type)
meta: Dict[str, Any] = {
"displayName": cls.display_name or cls.type,
diff --git a/server/tests/test_node_spec.py b/server/tests/test_node_spec.py
index 97ee5ec5..68b84004 100644
--- a/server/tests/test_node_spec.py
+++ b/server/tests/test_node_spec.py
@@ -1160,6 +1160,55 @@ class TestWave10GContractInvariants:
assert code_field, f"{t}: `code` field missing from input schema"
assert code_field.get("editor") == "code", f"{t}.code: expected `editor: 'code'`, got {code_field.get('editor')!r}"
+ def test_plugin_meta_icon_refs_are_wellformed(self):
+ """A plugin may point at a library glyph from its own ``meta.json``
+ instead of vendoring an SVG. Two ways that goes silently wrong:
+
+ * A key in ``icons`` that is not a real node type never matches, so
+ the node keeps whatever fallback it had and the author sees no
+ error.
+ * A library prefix the frontend does not register resolves to null,
+ rendering nothing.
+
+ Whether a *name* exists inside the library is checked on the
+ frontend, in ``client/src/assets/icons/index.test.ts`` -- Python
+ cannot see lucide's exports.
+ """
+ import json
+ from pathlib import Path
+
+ from models.node_metadata import NODE_METADATA
+
+ # Kept in step with ICON_LIBRARIES in client/src/assets/icons/index.ts.
+ known_libraries = {"lucide", "lobehub", "asset"}
+ nodes_dir = Path(__file__).resolve().parents[1] / "nodes"
+
+ problems: list[str] = []
+ for meta_path in nodes_dir.rglob("meta.json"):
+ try:
+ data = json.loads(meta_path.read_text(encoding="utf-8"))
+ except (OSError, json.JSONDecodeError) as exc:
+ problems.append(f"{meta_path}: unreadable ({exc})")
+ continue
+ if not isinstance(data, dict):
+ continue
+
+ refs = list((data.get("icons") or {}).items())
+ for node_type, _ref in refs:
+ if node_type not in NODE_METADATA:
+ problems.append(
+ f"{meta_path}: icons key {node_type!r} is not a registered node type"
+ )
+
+ for ref in [data.get("icon"), *[r for _, r in refs]]:
+ if not ref or ":" not in str(ref):
+ continue # emoji or absent — nothing to validate
+ library = str(ref).split(":", 1)[0]
+ if library not in known_libraries:
+ problems.append(f"{meta_path}: unknown icon library {library!r} in {ref!r}")
+
+ assert not problems, "malformed plugin meta.json icon refs:\n " + "\n ".join(problems)
+
def test_every_asset_icon_has_matching_svg(self):
"""Wave 10.B: every ``asset:<key>`` string emitted by a plugin
must resolve to a real SVG file under