You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 154a49a
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/tools/show-widget.md
+17-3Lines changed: 17 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,12 +15,12 @@ read_when:
15
15
16
16
When the agent calls `show_widget`, OpenClaw core wraps `widget_code` in a minimal HTML document, stores it as a Canvas document, and returns a preview handle. The Control UI renders that handle as a sandboxed iframe directly under the tool call, while native apps use an isolated web view. Both restore the widget after history reload.
17
17
18
-
In Control UI sessions, a Canvas widget can also be pinned to the session dashboard. Set `pin: true` in the tool call, or use **Pin to dashboard** on an existing transcript widget. Pinning reuses the exact hosted document; it does not fetch widget HTML through the browser.
18
+
In Control UI sessions, a Canvas widget can also be pinned to the session dashboard. Set `pin: true` in the tool call, or use **Pin to dashboard** on an existing transcript widget. Pinned HTML runs behind the same dedicated-origin, double-iframe sandbox host used by MCP Apps; the browser never resolves a widget data binding inside the untrusted frame.
19
19
20
20
For browser embedding, the wrapper document injects four small host bridges around the widget code:
21
21
22
22
- A size reporter posts the rendered content height to the embedding chat, which clamps it and fits the iframe (160 to 1200 pixels).
23
-
- A prompt bridge defines a global`sendPrompt(text)`function that widget scripts can call to submit a follow-up message into the chat. The bridge creates a private message channel and offers one endpoint to the chat before any widget code runs; the chat adopts only that first offer. See [Interactive widgets](#interactive-widgets).
23
+
- A host bridge defines the legacy`sendPrompt(text)`helper plus the structured `openclaw.prompt`, `openclaw.state`, `openclaw.data`, and `openclaw.cron` APIs. Inline chat prompts retain their private message channel; dashboard APIs use a view-ticket-bound request channel. See [Interactive widgets](#interactive-widgets) and [Dashboard capabilities](#dashboard-capabilities).
24
24
- A theme bridge listens for the Control UI's current design tokens and applies them as CSS variables, on load and again on every theme change.
25
25
- A snapshot bridge renders the current widget document as a PNG when the embedding chat requests an export.
26
26
@@ -96,6 +96,7 @@ The core Canvas tool accepts these optional dashboard placement fields:
96
96
-`tab`: destination tab slug.
97
97
-`size`: one of `sm`, `md`, `lg`, `xl`, or `full`.
98
98
-`after`: sibling widget name after which to place the widget.
99
+
-`capabilities`: access requested by a pinned widget. `netOrigins` contains exact HTTPS origins; `tools` contains `prompt`, an allowlisted read binding, or an exact `cron.trigger:<jobId>` action.
99
100
100
101
The core result includes a Canvas preview handle, so the Control UI and supported native apps render the widget directly from the tool call and restore it after history reload. Pinned results also retain the board widget name so the Control UI does not offer a duplicate pin after transcript reload. Discord returns the stored widget and posted-message identifiers.
101
102
@@ -120,14 +121,27 @@ Every prompt is validated on both sides of the frame boundary:
120
121
121
122
Accepted prompts appear in the transcript as regular user messages and start a normal agent turn in the session that owns the widget. There is no feedback channel into the widget: a dropped prompt fails silently, and the widget cannot read the agent's reply.
122
123
124
+
## Dashboard capabilities
125
+
126
+
Pinned widgets can use one ticket-bound host API after the operator reviews the declaration shown on the pending card:
127
+
128
+
-`openclaw.prompt.send(text)` requires transient user activation and posts a visible composer message. Declaring and receiving the `prompt` tool grant skips the extra per-click confirmation; validation, focus checks, and rate limits still apply.
129
+
-`openclaw.state.emit(payload)` adds a session notice. Payloads are capped at 8 KiB, and identical client emissions within five seconds are coalesced.
130
+
-`openclaw.data.read(bindingId, params?)` resolves only at the Gateway. Grantable bindings are `sessions.list`, `usage.status`, `usage.cost`, `cron.list`, `cron.status`, `agents.list`, and `health`.
131
+
-`openclaw.cron.trigger(jobId)` runs an existing job now only when the exact `cron.trigger:<jobId>` capability was granted.
132
+
133
+
Network access is separate from host tools. Put exact HTTPS origins in `capabilities.netOrigins`; after approval, only those origins enter the widget's `connect-src`. Wildcards, credentials, paths, query strings, and undeclared origins remain blocked. A literal port is allowed only when it is part of the declared origin.
134
+
123
135
## Security and storage
124
136
125
-
Widget documents use restrictive Content Security Policies. Inline style and script are allowed, while external fetches and resource loads are blocked. Keep all markup, styles, scripts, and image data inside `widget_code`.
137
+
Widget documents use restrictive Content Security Policies. Inline style and script are allowed, while external resource loads remain blocked. Inline transcript widgets cannot fetch the network. A pinned dashboard widget can fetch only exact HTTPS origins that the agent declared and the operator granted.
126
138
127
139
The Control UI iframe always omits `allow-same-origin`, even when the global embed mode is `trusted`, so widget scripts cannot read the parent application origin. Native clients use isolated, nonpersistent web views and block navigation away from the hosted widget. The core document host also serves widgets with a `Content-Security-Policy: sandbox allow-scripts` response header, so direct rendering still runs the widget in an opaque origin instead of an application origin. Only render widget code you are willing to execute in that isolated frame.
128
140
129
141
The iframe also follows [`gateway.controlUi.embedSandbox`](/web/control-ui#hosted-embeds). The default `scripts` tier supports interactive widgets while preserving origin isolation.
130
142
143
+
The accepted WebRTC data-channel egress residual is documented in [Dashboard Architecture](/web/dashboard-architecture#modeled-residual-webrtc-data-channels).
144
+
131
145
Canvas retains at most 32 widgets per session (or per agent when no session is available). Creating another widget removes the oldest document in that scope.
Copy file name to clipboardExpand all lines: docs/web/dashboard-architecture.md
+29-6Lines changed: 29 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,11 +155,26 @@ Shared infrastructure underneath (this is where the simplification lands):
155
155
one-tap **Allow**/**Reject**. Grants are per widget name; for `html` widgets
156
156
they are byte-frozen (sha256), and changed bytes keep the grant only if the
157
157
declaration shrank.
158
-
-**Authoring shim.** The document wrapper injects
159
-
`window.openclaw.sendPrompt/emitState/read/call` as the stable author API;
160
-
whether the transport underneath is our channel or the AppBridge is an
161
-
internal detail the widget author never sees. Size reporting and theme
162
-
tokens ride the same bridge.
158
+
-**Authoring shim.** The document wrapper injects `window.openclaw.prompt`,
159
+
`window.openclaw.state`, `window.openclaw.data`, and `window.openclaw.cron`
160
+
as the stable author API. Dashboard calls share one view-ticket-bound
161
+
request channel; size reporting and theme tokens remain separate host
162
+
notifications.
163
+
164
+
### Modeled residual: WebRTC data channels
165
+
166
+
The sandbox CSP emits the proposed `webrtc 'block'` directive, but
167
+
[Chromium's current CSP directive set](https://chromium.googlesource.com/chromium/src/+/main/services/network/public/mojom/content_security_policy.mojom#95)
168
+
does not implement it. Scriptable widgets can therefore use WebRTC data
169
+
channels for egress in current Chromium. The same residual already ships for
170
+
inline chat widgets and the MCP Apps host on `main`.
171
+
172
+
**Accepted tradeoff:** OpenClaw does not gate scriptable widgets on this
173
+
residual. Widget content gains access to sensitive OpenClaw data only through
174
+
an operator-granted, byte-frozen `data:read` capability, and the sandbox
175
+
Permissions Policy blocks camera and microphone access. A DOM API guard is
176
+
best-effort defense-in-depth, not a security boundary, and belongs in
0 commit comments