App surfaces
app.surfaces[] and app.module — widgets, docks and cards, the renderer-by-trust matrix, the asset contract, and the Skill launcher.
Every UI contribution a package makes lives under neuralis.app.surfaces[]
in the manifest. A surface declares kind: "widget" | "card" | "dock" plus a
renderer, and validation enforces a strict renderer-by-trust matrix at load
time — what a surface is allowed to execute follows from who shipped the
package, never from what the manifest claims.
Renderer × trust matrix
| Renderer | Native | Trusted | Untrusted | Notes |
|---|---|---|---|---|
direct | yes | no | no | Compiled React mounted via the host component registry — native builtins only, attached at runtime from the package's prebuilt UI module |
iframe | yes | yes | relative-only | Every sandboxed render path. Absolute URLs require trusted/native; untrusted packages must point at a relative asset under their own app/ |
mcp | imported | imported | no | Imported/hosted external surfaces (widgets only) |
Two real render paths exist: direct and iframe (mcp marks imported
external surfaces, never a native authoring target). The removed inline-html
and wasm-ui values are rejected with a migration error; a leftover fallback
key is inert and warned about. The default shape is one self-contained HTML page
under its surface root, declared as an iframe
with a relative url; a multi-file build uses
assetMode: "bundle".
Passing validation is not the same as being drawn
A widget renders when it is direct with a resolvable registry component, or
iframe with a url; a direct import the registry cannot resolve falls
through to a placeholder reading "This widget cannot be rendered by this
host." ("Loading…" while a runtime module is still attaching, or until the
workspace has heard which modules exist; a module whose download failed is
tried again on the next listing). Cards follow
the same rule. A project package uses iframe with a relative url under its
own surface root — the only path available to it. With the default
self-contained asset mode, a surface whose stylesheet or script is a separate
file loads blank; declare assetMode: "bundle" and those files are served.
Trust upgrades do not unlock direct for project packages: the React lane is
reserved for host-assigned native builtins, and its components reach the
workspace only through the package's
runtime UI module.
The workspace host must be named
The workspace takes a package's surfaces only when the package targets it:
meta.hosts (see Manifest) omits the key, is empty,
or lists neuralis-workspace. A meta.hosts list without it means the workspace
serves none of the package's surfaces — widgets, docks and cards alike — and
nothing warns at load.
The surface asset contract
An iframe surface with a relative url is asset-backed: the package
ships an HTML entry and the host serves it. Two rules govern it, and both
fail quietly if you ignore them.
1. The entry lives in its own canonical root
app/surfaces/{kind}/{surfaceId}/…{kind} is the surface kind (widget or card) and {surfaceId} is the
surface's exact declared identity — a widget's type, a card's id —
used verbatim as a single path segment. An entry at the app/ root, in
another surface's directory, in an ancestor directory, or reachable through a
.. segment is a load-time validation error, and a contribution-validation
error fails the whole package, not just the surface.
The optional app/shared/ directory is package-public: any visible surface of
the package may read it, so nothing feature-private belongs there. A surface
entry may never live under it.
2. The entry has an asset mode
The entry is navigated as a sandboxed document with an opaque origin
(allow-scripts allow-forms, deliberately no allow-same-origin), so it
cannot reach host DOM, cookies, or storage — and every subresource request it
makes carries no session cookie. One optional field on the render block,
assetMode, decides what follows.
self-contained — the default
Inline your CSS and JavaScript; ship images and fonts as data: URIs. The
platform does not serve the entry's subresource requests, and nothing warns at
runtime: a linked stylesheet never arrives and the surface renders unstyled.
app/shared/ is unreachable from such an entry. This mode works on every
deployment and in every trust tier.
bundle — one document plus its own files
"component": {
"renderer": "iframe",
"url": "./app/surfaces/widget/my_workspace/index.html",
"assetMode": "bundle"
}The platform injects a <base href> into the entry response, pointing at a
short-lived session-free lane, and serves the entry's sibling files from there:
separate stylesheets, code-split chunks, dynamic import(), a runtime
fetch('./data.json'), real font and image files, source maps, and
app/shared/. A bundler's dist/ built with a relative base works as-is.
- The declaration is a request, not a switch. It is honoured only for a
relative
iframeentry that is an HTML document (.html/.htm); anything else is served self-contained, with a validator and pre-flight warning. - References resolve against the entry's own directory.
app/shared/is../shared/…from an entry at the first level of its surface root. A reference that resolves outside the surface root orapp/shared/is a pre-flight error, and the lane enforces the same bound at request time on the real path — a symlink whose target lives outside is refused, not followed. - One document, not one site. The lane never serves HTML, so multi-file works and multi-page does not.
- Budgets: 64 files and 8 MiB per surface, refetched on every render
(
no-store); the pre-flight warns past 1 MiB. The per-file 2 MiB cap applies in both modes. - Still no remote origins. The CSP names none, so a CDN script or a hosted font is refused before the request leaves the browser.
Load-time validation sees the declaration, never the files, so whether a document obeys its mode is checked by the packaging pre-flight shipped with the package-creation skill — and, in bundle mode, again by the lane at request time.
The served URL carries no identity
The host mints a short-lived, refcounted asset scope and navigates an opaque URL containing no package, project or agent id, no token and no query string. Every request for the entry re-checks the caller's full, live visibility, so a role, feature, trust, disable or uninstall change revokes the scope at once. A bundle surface's subresource lane carries no session, so it re-verifies the package on every request; a caller-side loss is caught by the entry lane or the frame's 60-second heartbeat, and both lanes stop together.
Entry responses are Cache-Control: private, no-store,
Referrer-Policy: no-referrer, capped at 2 MiB apiece, restricted to a
static-asset extension allowlist (TypeScript/JSX source is never served), and
carry a strict CSP: default-src 'none', script-src/style-src 'self' 'unsafe-inline', img-src 'self' data: blob:, font-src 'self' data:,
connect-src 'self', form-action 'none', base-uri 'self',
frame-ancestors 'self' and sandbox allow-scripts allow-forms — so the
document is forced into an opaque origin even if it is opened outside the
workspace frame. The bundle subresource lane serves the same allowlist minus
HTML, under its own CSP that denies script to anything navigated to it directly
(which is what disarms a served .svg).
What reaches the frame
| Surface | Sandbox / origin | Data it receives |
|---|---|---|
| Widget (any trust) | allow-scripts allow-forms, serialized origin null | nothing — there is no host→widget message channel |
Widget, native, absolute https: URL on a different origin than the host's (no credentials in the URL) | allow-same-origin (plus popups and downloads) added, so the external application runs on its own origin; never top navigation | nothing — the host shares no identity with it; the admin dashboard lists every such origin |
| Card, host-served or same-origin | same opaque sandbox | the bounded one-way card-data feed; the privileged bridge is refused fail-closed |
| Card, trusted absolute remote, no bridge opt-in | same opaque sandbox | the bounded one-way card-data feed |
| Card, trusted absolute remote, explicit bridge opt-in | allow-same-origin added, only for an HTTPS origin that differs from the host's | the feed plus the minimal window.neuralis bridge |
A widget that waits on an incoming message renders forever-empty. The host's
theme variables do not cascade into any frame — ship your own light/dark
styling. The privileged window.neuralis bridge is opt-in via
bridge.enabled, restricted to trusted/native packages, re-validated at
runtime against the exact frame origin, and offers submitApproval and
requestData only.
Direct renderer binding (builtin-class)
A direct surface's React code reaches the workspace through ONE lane,
reserved for host-assigned native builtins: a runtime UI module. The package
exports an install…HostComponents({ registry, port }) function that registers
each component.import string in the host component registry (one module may
register several surfaces).
The package declares app.module (see Manifest)
and ships one prebuilt browser module, built with
neuralis-build ui from app/host.tsx into
dist/app/. The host serves it from a content-hashed, same-origin URL to
signed-in members, imports it when the workspace loads and calls its install
exports — no host rebuild, no host code change.
- React and the platform client library are read from the host's own instances
(a build that would bundle a copy fails), so the workspace never runs two
Reacts. A package can publish modules to other native UI modules
(
app.module.provides) so two packages share one instance. - Utility classes come from ONE stylesheet the host compiles across every
native package's
app/sources — keep all UI sources (and anyclassName-bearing code) underapp/. - A module loads once per page; a new build is picked up after the package is reloaded, on the next page load. The host refuses a module built for a different host API version or React major (or a React-reading build that recorded none), and the surface shows the placeholder — rebuild the module after a platform upgrade.
The port argument (WorkspaceHostPort) carries shared workspace state plus
host-owned component slots (port.components — e.g. UserAvatar), so install
entries need no host-specific parameters. Its optional onClientStateReset
subscription lets a package that keeps its own client store drop a scope's
state when the user presses the dock's clean (broom) control, without the host
naming the package. Of its two refresh verbs, reload() rebuilds the whole
workspace and discards every project's arranged layouts, while
reloadAgents() re-reads only the active project's agent list and keeps them —
a package that created or removed an agent wants the second one.
useProjectMembers(), a required member of the port, returns the active
project's members by user id (name and role, never an e-mail) for pickers that
show a person by name and store the id. It reads the roster the workspace
already holds and makes no request; it is empty outside a project, and a route
judges every id it receives again.
Widgets
{
"kind": "widget",
"id": "my-pkg.widget",
"type": "my_workspace",
"title": "My Workspace",
"icon": "layout-dashboard",
"component": {
"renderer": "iframe",
"url": "./app/surfaces/widget/my_workspace/index.html"
},
"requires": { "features": ["my-pkg.read"] },
"layout": { "defaultWidth": 480, "defaultHeight": 640, "minWidth": 320, "minHeight": 240 },
"chrome": { "mode": "frameless" },
"open": { "singleton": true, "defaultTitle": "My Workspace" }
}| Field group | What it controls |
|---|---|
component | renderer plus url (iframe) or import (direct registry key) |
requires | features (visibility gate — see Features) and tools the widget depends on |
layout | Default and minimum dimensions |
chrome.mode | toolbar (host title bar), frameless (edge-to-edge, hover-revealed controls — recommended for iframe widgets that draw their own chrome), floating (always-on overlay controls) |
chrome.transparent | Baseline transparency the widget mounts at; without it, the user's workspace default widget transparency. The level changes the panel's CSS containment, so a position: fixed overlay inside a widget must createPortal(…, document.body) to anchor the same way at every level (position: absolute needs no portal) |
chrome.userTransparency | false locks the baseline and hides the user-facing transparency cycle; the host also force-locks it for untrusted packages |
chrome.sortKey | Workspace tile ordering |
defaultOpen | Opens the widget automatically once the agent runtime is ready |
open.singleton | true: at most one window per agent. Otherwise the user may open more windows (New window), also for the same agent, so keep view state per window — the component receives its window id (widgetId) and the agent the window is bound to |
All three chrome modes render the same compact control strip — they differ only in placement and visibility.
The strip's close (X) button minimizes the widget into its dock item; it
does not destroy it — instance, layout slot and component state are preserved,
also across a page refresh. One exception: an iframe widget is detached from
the document while minimized (or when the user switches stage mode), so on
restore it reloads from its URL and state held only inside the frame is lost —
persist it server-side or in the frame's own storage. Permanently closing a
widget is the dock item's clean (broom) control, which resets the widget's
client-side state (and the package's own store, via onClientStateReset);
server-side data is untouched. Cleaning ONE window sends a reset scope with
level: "instance" and that window's instanceId; the window stays open.
openWidget({ agentId, type, title, target }) picks the window: by default the
most recently used window of that type for that agent (a new one only when none
exists), "new" for another window where the widget allows it, or
{ instanceId } for a specific one. In a workspace Group several agents'
windows share one layout, and a window keeps the agent it was opened for — use
the agentId you are given, never the workspace's currently selected agent.
Dock entries
The dock is built only from kind: "dock" surfaces. A widget's own dock
block (show, label, icon, position) is metadata: dock: { show: true }
on a widget is ignored, and a widget without a dock companion entry has no dock
icon to open it from. Ship both entries for every docked widget:
{
"kind": "dock",
"id": "my-pkg.open",
"label": "My Pkg",
"icon": "layout-dashboard",
"position": 30,
"section": "top",
"action": { "type": "open-widget", "widget": "my_workspace", "title": "My Workspace" }
}Actions are either open-widget or a named action. Lower position sorts
higher; requires.features gates visibility the same way as widgets.
A dock entry may declare an image shown in place of the glyph in the dock, the
Apps launcher and the Inbox, e.g. "image": "app/shared/my-icon.png": a
package-relative path under app/shared/ ending in .png, .jpg, .jpeg or
.webp (no SVG), a real PNG, JPEG or WebP of at most 256 KiB, and the package
must ship its app/ folder. The host serves only that declared file, only to
users who can see the entry; the icon glyph stays the fallback.
Every icon — on a widget, dock entry or card, a team member's
appearance.icon, a workflow template — names an entry of ONE platform icon
library (about 270 curated lucide icons, ICON_LIBRARY from
@neuralis/package-system/icons), in PascalCase (LayoutDashboard) or
lucide-kebab form (layout-dashboard). An unknown name loads with a warning
and renders a fallback glyph. Native agent surfaces resolve agent appearance
with resolveAgentIcon and resolveAgentColor from
@neuralis/package-system/client (configured values win, an icon outside the
library falls back to Bot); human profile images belong to UserAvatar.
Cards
Cards render inline in chat, matched to tool results via match.tools[]
(paired with the tool's x-neuralis.ui.cardType — see
Tools). Cards reject the mcp renderer and add a
match.state discriminator for user-blocking situations:
interaction-required— the model is waiting on a user answer. The card body may render its own input controls; the final submission routes through the host's persisted interaction-response API.approval-required— a permission-style approval. The card body is preview-only: the host wraps it with approve/deny chrome, the runtime bridge filters embedded approve/deny buttons, and the validator warns when an approval card declares its own rendered URL.
{
"kind": "card",
"id": "my-result.card",
"type": "my_result",
"match": { "tools": ["my_query"] },
"render": {
"renderer": "iframe",
"url": "./app/surfaces/card/my-result.card/index.html"
}
}While a tool call is still streaming, a native direct card receives its input
as a partial JSON string. Never re-parse that growing buffer on every delta:
use the chat package's streaming helpers — previewInput,
extractStreamingField and parseSettledObject. Sandboxed iframe cards need
none of this; the card-data channel below delivers the bounded input. Keep a
card body still while it runs: a CSS keyframe on transform, opacity,
filter, background-color or clip-path inside the virtualized timeline
makes rows slide against each other on a fast scroll.
Row height — what the timeline reserves before your card renders
The virtualized chat timeline reserves a height for every unmeasured row; a wrong reservation makes the list jump when the card appears.
- A native card may register an
estimateHeightmodel (payload, status, expand state, width factor → the card's own height without the row gap). Keep it a module-level, pure, memoized function, round up, model the expanded height too, and scale per-line constants by the width factor with the exported helper; a model that throws or returns an out-of-range value is discarded. - An
iframecard declares"height": { "compact": 192, "expanded": 432 }(expandeddefaults tocompact) as shell numbers. An invalidheightis a load error, on adirectcard it is ignored with a warning, and every estimate is clamped. - Declaring nothing is valid: the generic default, or an estimate from the fallback card's content. A card that sizes itself at runtime is usually better off declaring nothing.
Composer aggregation (Changes & Actions)
Above the chat composer sits the Changes & Actions panel — Changes (one row
per changed file with +N/−M stats), Todos, Actions and Delegates tabs, plus a
post-stream summary chip of the files a turn touched. Which tab a card's
activity lands on is declared by the card itself; nothing in the host
hardcodes a card type.
- Native direct cards pass a module-level
composercontract besideestimateHeight:tab(a builtin id or a custom{ id, label, icon?, color? }shown after the builtins), an optionalbadge?(tool)chip, andchanges?(tool), the changed paths (plus an optional line diff) for the Changes tab and the summary. Extractors are fail-soft; a contract-less card lands on Actions with a generic chip. - Manifest-declared
iframecards get a declarative subset:"composer": { "tab": "changes", "badgeField": "label", "pathField": "uri" }.tabtargets existing builtin tabs only;badgeFieldnames a top-levelstructuredContentstring used as the chip label,pathFielda top-level string or string array of changed paths. No dot-paths, no diff field.
An invalid composer block is a load error; a composer on a direct card is
ignored with a warning (its contract lives in the install registration).
The one-way card-data channel
A sandboxed iframe card — and only a card — receives its tool's data over a
strictly one-way host→frame message:
- The entry announces itself with a
card-readymessage from an inline script. The host accepts it only from the exact frame window and the exact expected origin. - The host answers with one full snapshot per document generation, then monotonic-revision updates, only when the payload changed.
- The payload carries the tool's
name,input,status,resultandstructuredContent— and nothing else: no conversation, user, project, agent or tool-call id, no pending interaction, token, credential or action capability. The frame's origin is opaque, so the host must broadcast, which is why the payload carries no identity. - It is bounded: 131,072 bytes serialized in total and 16,384 characters per string, with an explicit truncation marker wherever a cap cut real data.
- The frame cannot answer with data and cannot request a host operation on this path.
The status the frame receives is derived: a finished call whose payload
carries no explicit status still settles, while a payload declaring
pending: true or status: "pending" keeps the card running — any other
bespoke shape ({ "done": false }) reads as completed. The channel is
owner-gated: only a card bound to its own package's tool receives the real
input and result; a card matching a foreign package's tool receives a generic
placeholder. Stream pacing, retention and the single realtime hub are
host-owned — a card does not open its own event stream or scheduler.
Skill launcher
The Skill launcher is the one reusable control for "this is a skill — let
the agent do it for you." Clicking it prefills the chat composer with the
skill — and optionally its scripts, the file it should act on and a one-line
hint — exactly as if the user had picked the skill from the / slash menu, then
focuses chat. It does not start a stream, call a route, or send the
message: the user reviews the draft and presses Send. It is exported from
@neuralis/package-system/client, so any package can use it.
import { SkillLauncher } from '@neuralis/package-system/client';
// variant: "icon" (toolbars) · "label" (empty states) · "row" (skill menus)
<SkillLauncher variant="label" skill="manage-workflows" packageId="@neuralis/agent-core"
label="Schedule a workflow" icon="calendar" />| Prop | Meaning |
|---|---|
skill | The skill activation id (frontmatter name, or its directory name) — what execute({ action: 'skill' }) resolves. Never a display title. |
packageId | The owning package's registry id (@neuralis/brain-core, its manifest neuralis.id) — not the directory name. Matched as an exact pair with skill. |
scripts? | Skill-bundle-relative paths (e.g. scripts/build.mjs) the agent should run through the skill's directory after activation — intent references, not attachments. |
attachments? | Real, addressable URIs the skill operates on, attached as ordinary read references. |
agentId? | Target agent; defaults to the active agent. |
hint? | One short line of plain text naming the job, appended after the chips; ≤200 characters, sanitized and clamped by the chat surface, never a chip of its own. |
label | Visible text (label variant) and the tooltip / accessible name. |
icon? | A library icon name; defaults to a wand glyph. |
alsoRequires? | Extra features required by the route behind the skill when it is gated more tightly than the skill. Narrow-only: it can hide the launcher, never reveal one. |
visible? | An explicit visibility answer from a surface that already holds a stronger per-caller projection. |
variant (icon | label | row) · size · attached (left | right, flush against an adjacent control in an inline-flex gap-0.5 wrapper) · accent | Presentation. |
port? | An explicit workspace host port, only where no provider is above the button. |
className? | Extra classes for spacing and placement. |
The handoff rides the workspace's cross-widget navigation seam: the skill becomes a skill chip, each script a file chip telling the agent to run it from the activated skill's directory, each attachment a file-read chip, and the hint plain text after them.
Visibility is derived, not declared. There is no feature prop: the launcher
renders only if the exact (packageId, skill) pair comes back in the skill
catalog the host resolves for the current caller, so an unresolved, denied or
still-loading catalog renders no button, never one that should not be there.
Activation ids are not globally unique, which is why the match is the exact
pair with the registry id. Visibility is still not authorization: sending
the message re-evaluates the caller's granted features server-side and fails
closed, and any attached URI is checked against the
URI policy before it is read.
Placing it well. Add it where it genuinely helps — a widget toolbar, an
empty state, a context-menu row — beside a surface's existing actions, matched
to a skill that fits the surface. To wire the same handoff into a control you
already have, call useSkillHandoff() and invoke composeSkill(...) — you then
own the visibility question yourself. The launcher resolves the host port from a
provider its package mounts once in its host install entry; without that
provider every launcher under it renders nothing, with no error. Sandboxed
(iframe) surfaces cannot host one. The chat surface also lists every in-scope
package's skills (and scripts) as variant="row" launchers in its searchable
skill menu, filled from the access-filtered package overview.
What validation rejects
validateContribution runs at package load, and a failing surface fails the
package. Besides the renderer × trust matrix, the asset root rules and the card
blocks above, it rejects: iframe without a url; a surface id that is not a
safe path segment, a %-escaped path, or two roots that collide after
case-folding; two surfaces declaring one card type with different composer
blocks; missing identity fields (id, widget type, dock id); and a
duplicate widget type, dock id or card id within one package.
Uniqueness is not checked across packages — the same widget type in two
packages loads and one shadows the other — so namespace your type with your
package id. A package that omits access.trust is treated as untrusted, with a
warning.
The rest of the manifest's validation is in
Testing and validation; the worked example of all
three kinds is in the contract examples —
example-builtin carries all three, including a second widget that
demonstrates assetMode: "bundle".