@aceshooting/lyra-ui 30.2.0 → 30.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/dist/ai/adapters/a2ui.d.ts +10 -4
- package/dist/ai/adapters/a2ui.js +1 -1
- package/dist/ai/adapters/ag-ui.d.ts +17 -4
- package/dist/ai/adapters/ag-ui.js +1 -1
- package/dist/ai/adapters/ai-sdk.js +1 -1
- package/dist/ai/runtime.js +1 -1
- package/dist/components/agent-tools/mcp-app/mcp-app-protocol.d.ts +15 -0
- package/dist/components/agent-tools/mcp-app/mcp-app-protocol.js +36 -0
- package/dist/components/agent-tools/mcp-app/mcp-app.class.d.ts +31 -4
- package/dist/components/agent-tools/mcp-app/mcp-app.class.js +4 -4
- package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +2 -2
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
- package/dist/components/conversation/message-parts/message-parts.class.d.ts +13 -4
- package/dist/components/conversation/message-parts/message-parts.class.js +12 -10
- package/dist/components/conversation/message-parts/message-parts.d.ts +1 -1
- package/dist/components/conversation/message-parts/message-parts.js +1 -1
- package/dist/components/forms/select/select.class.js +1 -1
- package/dist/components/media/file-input/file-input.styles.js +1 -1
- package/dist/components/media/map/map-control-chrome.js +1 -0
- package/dist/components/media/map/map-control-options.d.ts +6 -2
- package/dist/components/media/map/map-control-options.js +1 -1
- package/dist/components/media/map/map-controls-lifecycle.js +1 -1
- package/dist/components/media/map/map-controls-readiness.js +1 -0
- package/dist/components/media/map/map.class.d.ts +39 -2
- package/dist/components/media/map/map.class.js +13 -7
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/events.d.ts +10 -1
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/llms/components/lr-file-input.md +5 -0
- package/llms/components/lr-map.md +80 -8
- package/llms/components/lr-mcp-app.md +94 -4
- package/llms/components/lr-message-parts.md +18 -0
- package/llms/components/lr-select.md +3 -2
- package/llms/peers.md +1 -1
- package/llms/shared/ai-and-peers.md +77 -3
- package/llms/shared/events-and-types.md +25 -1
- package/llms/shared/localization-and-rtl.md +29 -0
- package/llms/shared.md +131 -4
- package/locales.json +1 -1
- package/package.json +8 -4
- package/registrations.json +1 -1
- package/skills/compose-lyra-interfaces/SKILL.md +5 -3
- package/skills/compose-lyra-interfaces/references/composition-patterns.md +8 -1
- package/skills/lyra-ui/SKILL.md +16 -8
- package/skills/lyra-ui/lyra-gen.md +86 -0
|
@@ -21,7 +21,94 @@ with a trusted CSP meta placed before every caller-controlled HTML token; commen
|
|
|
21
21
|
head decoys therefore cannot bypass the policy. Remote documents accept only relative or HTTP(S)
|
|
22
22
|
URLs and use a fixed `no-referrer` policy; active-document `data:` and `blob:` URLs are rejected.
|
|
23
23
|
The frame can only request tool calls, messages, navigation, logs, and clamped resizing through
|
|
24
|
-
typed events.
|
|
24
|
+
typed events. Browser API permissions are denied unless explicitly enabled in `resource.permissions`.
|
|
25
|
+
|
|
26
|
+
The default `protocol="legacy"` uses Lyra's existing nonce/port envelope. Set
|
|
27
|
+
`protocol="mcp-apps"` for the supported JSON-RPC host subset of the
|
|
28
|
+
[MCP Apps 2026-01-26 protocol](https://github.com/modelcontextprotocol/ext-apps/blob/v2.0.3/specification/2026-01-26/apps.mdx).
|
|
29
|
+
The wire contract is pinned against the public `@modelcontextprotocol/ext-apps` 2.0.3 types.
|
|
30
|
+
An SDK-built interoperability fixture exercises initialization, tools, resources, context, text messages,
|
|
31
|
+
links, inline display fallback, cancellation, error responses and teardown with `App` from the pinned
|
|
32
|
+
SDK. This is a bounded host implementation, not a claim of full MCP Apps conformance: server
|
|
33
|
+
connections and discovery execution belong to the embedding application; sampling, downloads,
|
|
34
|
+
fullscreen/PiP presentation and host calls into app-exposed tools are unsupported. Unsupported
|
|
35
|
+
optional host capabilities are omitted from the initialization result, even if untyped input offers
|
|
36
|
+
them; their incoming requests fail with method-not-found and do not dispatch host work. App-exposed
|
|
37
|
+
tools use the separate app capability direction: advertising them does not grant server-tool access,
|
|
38
|
+
and this host does not discover or invoke them.
|
|
39
|
+
|
|
40
|
+
**Official protocol mode:**
|
|
41
|
+
|
|
42
|
+
- `hostCapabilities: McpAppHostCapabilities = {}` (attribute: false) is a clone-owned grant snapshot.
|
|
43
|
+
Supported grants are `serverTools: {}`, `serverResources: {}`, `openLinks: {}`, `logging: {}`,
|
|
44
|
+
`message: { text: {} }`, and
|
|
45
|
+
`updateModelContext: { text?: {}, structuredContent?: {} }`. Unadvertised methods return JSON-RPC
|
|
46
|
+
method-not-found. Changing capabilities or protocol remounts the app and cancels pending work.
|
|
47
|
+
- The app sends `ui/initialize`; the host returns the pinned revision, host identity, supported
|
|
48
|
+
capabilities, locale and inline display context. The app's `ui/notifications/initialized`
|
|
49
|
+
notification emits `lr-mcp-initialized` with `{ uri, frameGeneration }`. Host notifications are
|
|
50
|
+
rejected before that point; `lr-mcp-ready` alone only reports frame load.
|
|
51
|
+
- `lr-mcp-request` carries `{ requestId, requestToken, method, params, frameGeneration, signal }` for `tools/call`,
|
|
52
|
+
`tools/list`, `resources/list`, `resources/templates/list`, `resources/read`, `ui/message`,
|
|
53
|
+
`ui/open-link`, and `ui/update-model-context`. IDs retain their string
|
|
54
|
+
or numeric type, including `0`. The host authorizes and executes each request. Links must be
|
|
55
|
+
absolute HTTP(S) or mailto; message content supports text blocks only. Resource methods delegate
|
|
56
|
+
authorization and actual server reads to the host listener; they never fetch on their own.
|
|
57
|
+
- `ui/request-display-mode` accepts the standard mode vocabulary and returns `{ mode: "inline" }`,
|
|
58
|
+
the only display mode advertised by this host, including when the app requests fullscreen or PiP.
|
|
59
|
+
- `postMcpResponse(requestId, options): boolean` requires `{ frameGeneration, requestToken, result }` or
|
|
60
|
+
`{ frameGeneration, requestToken, error: { code, message, data? } }`. Results are objects. Unknown, duplicate,
|
|
61
|
+
cancelled, timed-out and stale replies return `false`. Each event has a fresh opaque `requestToken`;
|
|
62
|
+
return it unchanged so a late reply cannot answer a newer request that reuses the same wire ID.
|
|
63
|
+
No external action is automatic.
|
|
64
|
+
- `postMcpNotification(method, params, frameGeneration): boolean` supports
|
|
65
|
+
`ui/notifications/tool-input`, `tool-input-partial`, `tool-result`, `tool-cancelled` and
|
|
66
|
+
`host-context-changed` under that same prefix. Keep the initialized event's generation for
|
|
67
|
+
asynchronous deliveries. `postHostContext()` sends a context-changed notification in this mode.
|
|
68
|
+
- `teardownApp(): Promise<boolean>` sends `ui/resource-teardown` and waits at most one second for
|
|
69
|
+
acknowledgement. Await it before removing the resource when graceful cleanup is needed. The
|
|
70
|
+
session closes regardless of acknowledgement. Abrupt removal closes immediately.
|
|
71
|
+
- Each pending request has a 30-second deadline; cancellation, timeout and teardown abort its
|
|
72
|
+
`signal`. There are at most 64 pending requests; messages are bounded to 10,000 values, 32 nesting
|
|
73
|
+
levels and 1,048,576 UTF-16 code units across keys and strings. This bounds processing and retained requests, not the
|
|
74
|
+
browser's initial structured-clone allocation. Optional undefined object members are omitted
|
|
75
|
+
during bounded JSON normalization; sparse/undefined arrays, cyclic values and accessors are rejected.
|
|
76
|
+
|
|
77
|
+
In official mode, inline resources can load external JavaScript and stylesheets only from the
|
|
78
|
+
HTTP(S) origins explicitly granted in `resource.csp.resourceDomains`. The embedding host must vet
|
|
79
|
+
those origins before assigning the resource; server-provided metadata is not itself authorization.
|
|
80
|
+
Empty, malformed and unmatched origins do not enable external assets. This adds no evaluation,
|
|
81
|
+
blob-script or wildcard allowances. Legacy mode keeps script and stylesheet execution inline-only,
|
|
82
|
+
even when its resource domains permit images, fonts or media. Remote `src` resources still follow
|
|
83
|
+
the remote server's own CSP rather than receiving an injected policy.
|
|
84
|
+
|
|
85
|
+
The official app runs in an inner opaque-origin iframe within a trusted outer sandbox proxy.
|
|
86
|
+
The trusted proxy enforces an ancestor CSP: inline app navigation is limited to the explicitly
|
|
87
|
+
approved `frameDomains` (none by default), including redirects. For remote `src`, the ancestor
|
|
88
|
+
permits only its initial HTTP(S) origin. This blocks unapproved destinations before a network
|
|
89
|
+
request is sent; the inner document cannot remove or relax the ancestor policy. Inline srcdoc
|
|
90
|
+
frames inherit the approved policy, including any approved nested-frame origins.
|
|
91
|
+
The app uses standard parent-window JSON-RPC messages; the proxy checks the app window and opaque
|
|
92
|
+
origin and relays through the host's document-bound message port. Loaded inner-frame navigation
|
|
93
|
+
closes that relay and remounts the sandbox. Treat all app documents and navigations as untrusted;
|
|
94
|
+
window transport does not authenticate a document during the interval before a permitted navigation
|
|
95
|
+
loads. The origin allowlist constrains that interval but does not prove document identity. Do not deliver credentials or secrets as host context or tool data.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
element.protocol = "mcp-apps";
|
|
99
|
+
element.hostCapabilities = { serverTools: {} };
|
|
100
|
+
element.addEventListener("lr-mcp-request", async event => {
|
|
101
|
+
const { requestId, requestToken, method, params, frameGeneration, signal } = event.detail;
|
|
102
|
+
if (method !== "tools/call") {
|
|
103
|
+
element.postMcpResponse(requestId, {
|
|
104
|
+
frameGeneration, requestToken, error: { code: -32601, message: "Unsupported method" }
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const result = await callAuthorizedTool(params, { signal });
|
|
109
|
+
element.postMcpResponse(requestId, { frameGeneration, requestToken, result });
|
|
110
|
+
});
|
|
111
|
+
```
|
|
25
112
|
|
|
26
113
|
**Properties:**
|
|
27
114
|
|
|
@@ -51,15 +138,18 @@ typed events. Capabilities are denied unless explicitly enabled in `resource.per
|
|
|
51
138
|
request with exactly one of `{ frameGeneration, result }` or `{ frameGeneration, error }`. Missing,
|
|
52
139
|
stale, or ambiguous correlation fails closed. Both methods are no-ops before a frame exists.
|
|
53
140
|
|
|
54
|
-
|
|
141
|
+
In legacy mode, the initial `host-context` message includes a document-bound nonce and transfers a `MessagePort` to
|
|
55
142
|
the executable document; that port is the only channel (window messages are ignored). A same-frame
|
|
56
143
|
navigation closes the port, invalidates the nonce and generation, and mounts a fresh sandbox before
|
|
57
144
|
host data can be delivered.
|
|
58
145
|
|
|
59
146
|
**Exported types:** `McpAppResource`, `McpAppCsp`, `McpAppPermissions`,
|
|
60
|
-
`McpAppToolCallDetail`, `McpAppToolResultOptions`,
|
|
147
|
+
`McpAppToolCallDetail`, `McpAppToolResultOptions`, `McpAppProtocol`, `McpAppHostCapabilities`,
|
|
148
|
+
`McpAppRequestId`, `McpAppRequestMethod`, `McpAppRequestDetail`, `McpAppResponseOptions`,
|
|
149
|
+
`McpAppNotificationMethod`, and `LyraMcpAppEventMap`.
|
|
61
150
|
|
|
62
|
-
**Events:** `lr-mcp-ready` (`{ uri }`), `lr-mcp-
|
|
151
|
+
**Events:** `lr-mcp-ready` (`{ uri }`), `lr-mcp-initialized` (`{ uri, frameGeneration }`),
|
|
152
|
+
`lr-mcp-request` (`{ requestId, requestToken, method, params, frameGeneration, signal }`), `lr-mcp-tool-call`
|
|
63
153
|
(`{ requestId?, name, args, frameGeneration }`), `lr-mcp-send-message` (`{ message }`),
|
|
64
154
|
`lr-mcp-open-link` (`{ href }`, an absolute http(s) or mailto URL), `lr-mcp-log`
|
|
65
155
|
(`{ level, value }`), and `lr-mcp-resize` (`{ height }`). These are host-authorized requests; the
|
|
@@ -22,6 +22,11 @@ Built-in text and reasoning Markdown receives each part's `state === 'streaming'
|
|
|
22
22
|
accumulated plain text without parsing or highlighting by default. The `streaming-render` property
|
|
23
23
|
can opt those parts into progressive Markdown. Replacing that same-id part with `state: 'complete'`
|
|
24
24
|
parses and renders the final content.
|
|
25
|
+
Built-in reasoning, tool, citation, attachment, JSON, widget and retry-button renderers register
|
|
26
|
+
on first use. A localized loading placeholder is visible while the import is pending; a failed
|
|
27
|
+
import shows a localized error and emits `lr-render-error`. Text-only messages do not load those
|
|
28
|
+
renderer implementations. Audio uses the browser's native audio element. A custom `renderPart`
|
|
29
|
+
that replaces a part does not load that part's built-in renderer.
|
|
25
30
|
Citation badge ranks are precomputed in one linear pass per render, rather than rescanning and
|
|
26
31
|
allocating every preceding part for each citation in a citation-heavy or growing message.
|
|
27
32
|
|
|
@@ -58,6 +63,19 @@ default — every instance carries `tool-display="chip"` until set, like `conten
|
|
|
58
63
|
`renderPart` is called exactly once per rendered part, in order, in both tool displays, and its
|
|
59
64
|
output is the host's own: it is never masked by `redactedFields`.
|
|
60
65
|
|
|
66
|
+
`widgetRegistry: LyraWidgetTypeRegistry = DEFAULT_WIDGET_TYPE_REGISTRY` (property only) forwards
|
|
67
|
+
an immutable registry created by `createWidgetTypeRegistry()` to every built-in widget part.
|
|
68
|
+
`widgetBindingState?: unknown` (property only) forwards explicit controlled state; `null` is a real
|
|
69
|
+
value. This state takes a bounded, clone-owned snapshot on assignment. Handle
|
|
70
|
+
`lr-widget-state-change` and reassign the next state yourself. Parts share this state, so their
|
|
71
|
+
JSON Pointer bindings must refer to the intended host-owned paths. Registry entries only describe
|
|
72
|
+
allowed types: applications must still register custom mapped components using granular imports.
|
|
73
|
+
Widget documents are cached by the unique part id and their bounded snapshot content. Unrelated
|
|
74
|
+
text writes preserve the existing widget document, while a changed widget root invalidates it.
|
|
75
|
+
Removing a part, windowing it out, or disconnecting releases its cached document. This cache does
|
|
76
|
+
not change widget-v2 validation, identity rejection, or controlled-state ownership.
|
|
77
|
+
|
|
78
|
+
|
|
61
79
|
Unsupported direct or `content-mode` attribute values normalize and reflect as `markdown`;
|
|
62
80
|
unsupported `tool-display` values normalize and reflect as `chip`.
|
|
63
81
|
|
|
@@ -545,8 +545,9 @@ purposes.
|
|
|
545
545
|
`defaultSelected`/attribute changes update that reset baseline without clobbering a dirty live
|
|
546
546
|
selection; user picks and direct `option.selected` writes remain live-only and never rewrite the
|
|
547
547
|
attribute/default.
|
|
548
|
-
- `aria-required` on the trigger reflects `required` immediately; `aria-invalid`
|
|
549
|
-
|
|
548
|
+
- `aria-required` on the trigger reflects `required` immediately; `aria-invalid` and `data-invalid`
|
|
549
|
+
reveal a constraint error after blur, `reportValidity()` or a native submission attempt.
|
|
550
|
+
A silent `checkValidity()` leaves a pristine control unchanged; `form.reset()` restores that state.
|
|
550
551
|
Blurring the trigger (Tab away) closes an open listbox, the same as a native `<select>`'s popup,
|
|
551
552
|
without restoring focus and undoing the browser's native Tab/Shift+Tab destination.
|
|
552
553
|
- The trigger's accessible name now checks a host-level `aria-label` attribute first, before falling
|
package/llms/peers.md
CHANGED
|
@@ -40,7 +40,7 @@ for the page.
|
|
|
40
40
|
| `@aceshooting/lyra-3d` | `^1.0.0` | `lr-chart-3d`, `lr-embedding-explorer`, `lr-graph`, `lr-image-viewer`, `lr-knowledge-graph-explorer`, `lr-model-viewer`, `lr-video` |
|
|
41
41
|
| `@aceshooting/lyra-flags` | `^2.3.1` | _(loaded by a shared internal module)_ |
|
|
42
42
|
| `@aceshooting/lyra-map` | `^1.3.0` | `lr-geojson-viewer`, `lr-map` |
|
|
43
|
-
| `@aceshooting/lyra-translations` | `^30.
|
|
43
|
+
| `@aceshooting/lyra-translations` | `^30.3.0` | _(not referenced by any component)_ |
|
|
44
44
|
| `@aiden0z/pptx-renderer` | `^1.4.0` | `lr-pptx-viewer` |
|
|
45
45
|
| `@sgratzl/chartjs-chart-boxplot` | `^4.0.0` | `lr-box-plot` |
|
|
46
46
|
| `chart.js` | `^4.0.1` | `lr-bar-chart`, `lr-box-plot`, `lr-bubble-chart`, `lr-chart`, `lr-doughnut-chart`, `lr-histogram`, `lr-line-chart`, `lr-pie-chart`, `lr-polar-area-chart`, `lr-radar-chart`, `lr-scatter-chart` |
|
|
@@ -29,9 +29,12 @@ import {
|
|
|
29
29
|
and strictly increasing `sequence`. A newer generation atomically retires the previous run, while
|
|
30
30
|
an older or replayed cursor is ignored. JSON Patch input is structurally validated and rejects
|
|
31
31
|
prototype-mutating paths.
|
|
32
|
-
- **
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
- **Structural adapters** — `adaptAiSdkMessage()` maps structural provider messages and
|
|
33
|
+
`AgUiStreamAdapter` maps events onto the neutral runtime without pulling vendor SDKs into the
|
|
34
|
+
package. Feed AG-UI events through `new AgUiStreamAdapter().push(event)`; the constructor accepts
|
|
35
|
+
`(limits?: Partial<AgUiAdapterLimits>, options?: AgUiAdapterOptions)`.
|
|
36
|
+
`adaptA2UiSurface()` is a limited A2UI-like graph helper, described below; it does not implement
|
|
37
|
+
the native A2UI protocol or its surface lifecycle.
|
|
35
38
|
Adapter inputs are treated as untrusted data, recursively snapshotted, and rejected without
|
|
36
39
|
throwing when malformed, non-serializable, or over their configured budgets.
|
|
37
40
|
`adaptAiSdkMessage()` maps AI SDK tool states structurally: `output-error` → `error`,
|
|
@@ -71,6 +74,77 @@ import {
|
|
|
71
74
|
These structural, provider-agnostic types correspond to the component inputs above; map a vendor
|
|
72
75
|
payload onto them at the edge.
|
|
73
76
|
|
|
77
|
+
### AG-UI reasoning, activity, and custom events
|
|
78
|
+
|
|
79
|
+
`AgUiLikeEvent` is the structural input shape; `push()` also accepts unknown input for guarded
|
|
80
|
+
admission. Visible `REASONING_MESSAGE_*` events become reasoning parts. `ACTIVITY_SNAPSHOT`
|
|
81
|
+
uses `messageId`, `activityType`, object `content`, and optional `replace`; `replace: false`
|
|
82
|
+
keeps an existing message. `ACTIVITY_DELTA` uses `patch` against a prior snapshot with the same
|
|
83
|
+
`messageId` and `activityType`. Activity content becomes a named data part and remains subject to
|
|
84
|
+
the adapter's snapshot and buffered-content budgets.
|
|
85
|
+
|
|
86
|
+
`CUSTOM` requires `name` and `value` plus explicit host routing. Set
|
|
87
|
+
`AgUiAdapterOptions.customEventTarget` to receive an `AgUiCustomEvent { name, value }` and return
|
|
88
|
+
an `AgUiCustomEventTarget { messageId, partId }`, or `null` to ignore it. Repeated targets replace
|
|
89
|
+
their data part. The callback owns those identities; the application registers named data renderers
|
|
90
|
+
and controls which event names it accepts. An omitted callback ignores custom events. Named data values remain data,
|
|
91
|
+
including values that resemble widgets or actions.
|
|
92
|
+
|
|
93
|
+
`AgUiAdapterLimits.maxBufferedMessages` bounds retained message identities, including activity
|
|
94
|
+
patch baselines; its default is 512. `maxBufferedTools`, `maxToolArgumentBytes`,
|
|
95
|
+
`maxTextDeltaCharacters`, and the inherited provider snapshot limits remain independently bounded.
|
|
96
|
+
Run boundaries and `reset()` clear retained buffers. Compact chunks require upstream expansion;
|
|
97
|
+
phase, encrypted, raw, step, subagent, deprecated thinking, and unknown events are ignored.
|
|
98
|
+
See the [AG-UI adapter guide](https://github.com/aceshooting/lyra-ui/blob/main/docs/ag-ui-adapter.md)
|
|
99
|
+
for event mappings, routing examples, error behavior, and the supported subset.
|
|
100
|
+
|
|
101
|
+
### Limited A2UI-like graph helper
|
|
102
|
+
|
|
103
|
+
`adaptA2UiSurface(surface, typeMap, limits?)` accepts one structural graph:
|
|
104
|
+
`{ rootId, components: [{ id, type, props?, text?, children?: string[], action?: { id, payload? } }], data? }`.
|
|
105
|
+
The host-owned `typeMap` maps those type names to allowlisted widget types. Unsupported native
|
|
106
|
+
A2UI lifecycle messages are not accepted as graphs; the helper does not maintain surfaces,
|
|
107
|
+
process native data-model updates, or provide native A2UI catalog compatibility.
|
|
108
|
+
|
|
109
|
+
The result is `A2UiAdapterResult | null`: a widget-compatible `{ version: '2', root }` plus
|
|
110
|
+
`bindingState` when `surface.data` is present. Assign `bindingState` separately; the widget-v2
|
|
111
|
+
document itself never supplies controlled state. Explicit `data: null` remains `bindingState: null`.
|
|
112
|
+
The original `state` field remains an equal compatibility alias in the helper result; renderers
|
|
113
|
+
do not read it. Input, props, action payloads and state are detached under the adapter budgets.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { adaptA2UiSurface } from "@aceshooting/lyra-ui/ai";
|
|
117
|
+
import "@aceshooting/lyra-ui/components/lr-message-parts.js";
|
|
118
|
+
import "@aceshooting/lyra-ui/components/lr-input.js";
|
|
119
|
+
import { createWidgetTypeRegistry } from "@aceshooting/lyra-ui/components/lr-widget-renderer.js";
|
|
120
|
+
|
|
121
|
+
const registry = createWidgetTypeRegistry([["field", {
|
|
122
|
+
tag: "lr-input", interaction: "control", props: { label: "string", value: "string" },
|
|
123
|
+
bindings: { value: { event: "lr-input" } },
|
|
124
|
+
}]]);
|
|
125
|
+
const adapted = adaptA2UiSurface({
|
|
126
|
+
rootId: "name-field",
|
|
127
|
+
components: [{ id: "name-field", type: "Field", props: {
|
|
128
|
+
label: "Name", value: { $bind: "/name" },
|
|
129
|
+
} }],
|
|
130
|
+
data: { name: "Ada" },
|
|
131
|
+
}, { Field: "field" });
|
|
132
|
+
const message = document.querySelector("lr-message-parts")!;
|
|
133
|
+
if (adapted) {
|
|
134
|
+
message.widgetRegistry = registry;
|
|
135
|
+
message.widgetBindingState = adapted.bindingState;
|
|
136
|
+
message.parts = [{ id: "name-form", type: "data", widget: adapted.root }];
|
|
137
|
+
}
|
|
138
|
+
message.addEventListener("lr-widget-state-change", (event) => {
|
|
139
|
+
if (event.detail.path === "/name") message.widgetBindingState = { name: event.detail.value };
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
For host-specific content, keep using `renderPart(part, index)`: return `undefined` to delegate
|
|
144
|
+
one part, or return a template to replace it and own its interaction. No extra part registry is
|
|
145
|
+
required. Widget type registries control the existing widget renderer's allowed component types,
|
|
146
|
+
separately from the message-part rendering hook.
|
|
147
|
+
|
|
74
148
|
### Interrupting and resuming a streamed run
|
|
75
149
|
|
|
76
150
|
`stream-interrupt` and `stream-resume` are reducer events for the host-owned transport lifecycle;
|
|
@@ -614,11 +614,18 @@ These named interfaces and helper signatures are available to typed integrations
|
|
|
614
614
|
components: A2UiLikeComponent[];
|
|
615
615
|
data?: unknown;
|
|
616
616
|
}`
|
|
617
|
-
`
|
|
617
|
+
`A2UiAdapterResult {
|
|
618
|
+
readonly version: '2';
|
|
619
|
+
readonly root: LyraWidgetNode;
|
|
620
|
+
readonly bindingState?: unknown;
|
|
621
|
+
readonly state?: unknown;
|
|
622
|
+
}`
|
|
623
|
+
`adaptA2UiSurface(surface: unknown, typeMap: unknown, limits: Partial<A2UiAdapterLimits> = {}): A2UiAdapterResult | null`
|
|
618
624
|
|
|
619
625
|
- **`ai-adapters-ag-ui-contracts`** — AI adapter and runtime contracts.
|
|
620
626
|
`AgUiAdapterLimits {
|
|
621
627
|
maxBufferedTools: number;
|
|
628
|
+
maxBufferedMessages: number;
|
|
622
629
|
maxToolArgumentBytes: number;
|
|
623
630
|
maxTextDeltaCharacters: number;
|
|
624
631
|
maxDepth: number;
|
|
@@ -640,6 +647,23 @@ These named interfaces and helper signatures are available to typed integrations
|
|
|
640
647
|
code?: string;
|
|
641
648
|
snapshot?: unknown;
|
|
642
649
|
messages?: unknown[];
|
|
650
|
+
name?: string;
|
|
651
|
+
value?: unknown;
|
|
652
|
+
activityType?: string;
|
|
653
|
+
content?: unknown;
|
|
654
|
+
replace?: boolean;
|
|
655
|
+
patch?: unknown[];
|
|
656
|
+
}`
|
|
657
|
+
`AgUiCustomEvent {
|
|
658
|
+
name: string;
|
|
659
|
+
value: unknown;
|
|
660
|
+
}`
|
|
661
|
+
`AgUiCustomEventTarget {
|
|
662
|
+
messageId: string;
|
|
663
|
+
partId: string;
|
|
664
|
+
}`
|
|
665
|
+
`AgUiAdapterOptions {
|
|
666
|
+
customEventTarget?: (event: AgUiCustomEvent) => AgUiCustomEventTarget | null;
|
|
643
667
|
}`
|
|
644
668
|
|
|
645
669
|
- **`ai-adapters-ai-sdk-contracts`** — AI adapter and runtime contracts.
|
|
@@ -313,6 +313,35 @@ Pluralized messages use one object-valued entry keyed by CLDR categories. A cata
|
|
|
313
313
|
singular and `<key>Plural` entries should fold them into `{ one: …, other: … }` under the singular
|
|
314
314
|
key's name; the plural key is not read.
|
|
315
315
|
|
|
316
|
+
### Generated views and embedded apps
|
|
317
|
+
|
|
318
|
+
`@aceshooting/lyra-gen` uses the same locale registry and inherited `lang`/`locale` as Lyra UI.
|
|
319
|
+
The seven `genView*` renderer messages ship in each locale's `conversation` slice, including
|
|
320
|
+
empty, invalid, loading, load-failure, field-value, unavailable-action and confirmation messages.
|
|
321
|
+
Import the full matching `@aceshooting/lyra-translations/<locale>.js` catalog, or the
|
|
322
|
+
`<locale>/conversation.js` slice plus the families and `shared.js` used by generated child controls.
|
|
323
|
+
The translations package matches the **Lyra UI** version; Gen is versioned independently.
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
import '@aceshooting/lyra-translations/fr/conversation.js';
|
|
327
|
+
import '@aceshooting/lyra-translations/fr/forms.js';
|
|
328
|
+
import '@aceshooting/lyra-translations/fr/shared.js';
|
|
329
|
+
import '@aceshooting/lyra-gen/gen-view.js';
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The renderer keeps its own small English defaults and does not load the complete English catalog.
|
|
333
|
+
Its `.strings` overrides affect its own messages; registered locale messages also reach nested
|
|
334
|
+
controls. Changing the inherited locale or registering a catalog after mounting refreshes the
|
|
335
|
+
renderer. Caller labels and model-generated prose remain caller content: the host chooses their
|
|
336
|
+
language separately. Numeric/date formatting follows the host locale without changing stored
|
|
337
|
+
JSON numbers or ISO dates. Host-created chat stream messages still require the host's localized
|
|
338
|
+
`strings` configuration.
|
|
339
|
+
|
|
340
|
+
A loaded `lr-mcp-app` publishes changed locale/direction context without reloading its frame.
|
|
341
|
+
Official MCP Apps sessions retain context updates during initialization and deliver the latest
|
|
342
|
+
context when the app becomes ready. Resource content remains responsible for rendering its own
|
|
343
|
+
translations and direction; the iframe does not inherit the parent document's CSS or `dir`.
|
|
344
|
+
|
|
316
345
|
## RTL and direction
|
|
317
346
|
|
|
318
347
|
Direction is inherited from the platform `dir` cascade; locale/`lang` selection does not change it,
|
package/llms/shared.md
CHANGED
|
@@ -2679,6 +2679,35 @@ Pluralized messages use one object-valued entry keyed by CLDR categories. A cata
|
|
|
2679
2679
|
singular and `<key>Plural` entries should fold them into `{ one: …, other: … }` under the singular
|
|
2680
2680
|
key's name; the plural key is not read.
|
|
2681
2681
|
|
|
2682
|
+
### Generated views and embedded apps
|
|
2683
|
+
|
|
2684
|
+
`@aceshooting/lyra-gen` uses the same locale registry and inherited `lang`/`locale` as Lyra UI.
|
|
2685
|
+
The seven `genView*` renderer messages ship in each locale's `conversation` slice, including
|
|
2686
|
+
empty, invalid, loading, load-failure, field-value, unavailable-action and confirmation messages.
|
|
2687
|
+
Import the full matching `@aceshooting/lyra-translations/<locale>.js` catalog, or the
|
|
2688
|
+
`<locale>/conversation.js` slice plus the families and `shared.js` used by generated child controls.
|
|
2689
|
+
The translations package matches the **Lyra UI** version; Gen is versioned independently.
|
|
2690
|
+
|
|
2691
|
+
```ts
|
|
2692
|
+
import '@aceshooting/lyra-translations/fr/conversation.js';
|
|
2693
|
+
import '@aceshooting/lyra-translations/fr/forms.js';
|
|
2694
|
+
import '@aceshooting/lyra-translations/fr/shared.js';
|
|
2695
|
+
import '@aceshooting/lyra-gen/gen-view.js';
|
|
2696
|
+
```
|
|
2697
|
+
|
|
2698
|
+
The renderer keeps its own small English defaults and does not load the complete English catalog.
|
|
2699
|
+
Its `.strings` overrides affect its own messages; registered locale messages also reach nested
|
|
2700
|
+
controls. Changing the inherited locale or registering a catalog after mounting refreshes the
|
|
2701
|
+
renderer. Caller labels and model-generated prose remain caller content: the host chooses their
|
|
2702
|
+
language separately. Numeric/date formatting follows the host locale without changing stored
|
|
2703
|
+
JSON numbers or ISO dates. Host-created chat stream messages still require the host's localized
|
|
2704
|
+
`strings` configuration.
|
|
2705
|
+
|
|
2706
|
+
A loaded `lr-mcp-app` publishes changed locale/direction context without reloading its frame.
|
|
2707
|
+
Official MCP Apps sessions retain context updates during initialization and deliver the latest
|
|
2708
|
+
context when the app becomes ready. Resource content remains responsible for rendering its own
|
|
2709
|
+
translations and direction; the iframe does not inherit the parent document's CSS or `dir`.
|
|
2710
|
+
|
|
2682
2711
|
## RTL and direction
|
|
2683
2712
|
|
|
2684
2713
|
Direction is inherited from the platform `dir` cascade; locale/`lang` selection does not change it,
|
|
@@ -2742,9 +2771,12 @@ import {
|
|
|
2742
2771
|
and strictly increasing `sequence`. A newer generation atomically retires the previous run, while
|
|
2743
2772
|
an older or replayed cursor is ignored. JSON Patch input is structurally validated and rejects
|
|
2744
2773
|
prototype-mutating paths.
|
|
2745
|
-
- **
|
|
2746
|
-
|
|
2747
|
-
|
|
2774
|
+
- **Structural adapters** — `adaptAiSdkMessage()` maps structural provider messages and
|
|
2775
|
+
`AgUiStreamAdapter` maps events onto the neutral runtime without pulling vendor SDKs into the
|
|
2776
|
+
package. Feed AG-UI events through `new AgUiStreamAdapter().push(event)`; the constructor accepts
|
|
2777
|
+
`(limits?: Partial<AgUiAdapterLimits>, options?: AgUiAdapterOptions)`.
|
|
2778
|
+
`adaptA2UiSurface()` is a limited A2UI-like graph helper, described below; it does not implement
|
|
2779
|
+
the native A2UI protocol or its surface lifecycle.
|
|
2748
2780
|
Adapter inputs are treated as untrusted data, recursively snapshotted, and rejected without
|
|
2749
2781
|
throwing when malformed, non-serializable, or over their configured budgets.
|
|
2750
2782
|
`adaptAiSdkMessage()` maps AI SDK tool states structurally: `output-error` → `error`,
|
|
@@ -2784,6 +2816,77 @@ import {
|
|
|
2784
2816
|
These structural, provider-agnostic types correspond to the component inputs above; map a vendor
|
|
2785
2817
|
payload onto them at the edge.
|
|
2786
2818
|
|
|
2819
|
+
### AG-UI reasoning, activity, and custom events
|
|
2820
|
+
|
|
2821
|
+
`AgUiLikeEvent` is the structural input shape; `push()` also accepts unknown input for guarded
|
|
2822
|
+
admission. Visible `REASONING_MESSAGE_*` events become reasoning parts. `ACTIVITY_SNAPSHOT`
|
|
2823
|
+
uses `messageId`, `activityType`, object `content`, and optional `replace`; `replace: false`
|
|
2824
|
+
keeps an existing message. `ACTIVITY_DELTA` uses `patch` against a prior snapshot with the same
|
|
2825
|
+
`messageId` and `activityType`. Activity content becomes a named data part and remains subject to
|
|
2826
|
+
the adapter's snapshot and buffered-content budgets.
|
|
2827
|
+
|
|
2828
|
+
`CUSTOM` requires `name` and `value` plus explicit host routing. Set
|
|
2829
|
+
`AgUiAdapterOptions.customEventTarget` to receive an `AgUiCustomEvent { name, value }` and return
|
|
2830
|
+
an `AgUiCustomEventTarget { messageId, partId }`, or `null` to ignore it. Repeated targets replace
|
|
2831
|
+
their data part. The callback owns those identities; the application registers named data renderers
|
|
2832
|
+
and controls which event names it accepts. An omitted callback ignores custom events. Named data values remain data,
|
|
2833
|
+
including values that resemble widgets or actions.
|
|
2834
|
+
|
|
2835
|
+
`AgUiAdapterLimits.maxBufferedMessages` bounds retained message identities, including activity
|
|
2836
|
+
patch baselines; its default is 512. `maxBufferedTools`, `maxToolArgumentBytes`,
|
|
2837
|
+
`maxTextDeltaCharacters`, and the inherited provider snapshot limits remain independently bounded.
|
|
2838
|
+
Run boundaries and `reset()` clear retained buffers. Compact chunks require upstream expansion;
|
|
2839
|
+
phase, encrypted, raw, step, subagent, deprecated thinking, and unknown events are ignored.
|
|
2840
|
+
See the [AG-UI adapter guide](https://github.com/aceshooting/lyra-ui/blob/main/docs/ag-ui-adapter.md)
|
|
2841
|
+
for event mappings, routing examples, error behavior, and the supported subset.
|
|
2842
|
+
|
|
2843
|
+
### Limited A2UI-like graph helper
|
|
2844
|
+
|
|
2845
|
+
`adaptA2UiSurface(surface, typeMap, limits?)` accepts one structural graph:
|
|
2846
|
+
`{ rootId, components: [{ id, type, props?, text?, children?: string[], action?: { id, payload? } }], data? }`.
|
|
2847
|
+
The host-owned `typeMap` maps those type names to allowlisted widget types. Unsupported native
|
|
2848
|
+
A2UI lifecycle messages are not accepted as graphs; the helper does not maintain surfaces,
|
|
2849
|
+
process native data-model updates, or provide native A2UI catalog compatibility.
|
|
2850
|
+
|
|
2851
|
+
The result is `A2UiAdapterResult | null`: a widget-compatible `{ version: '2', root }` plus
|
|
2852
|
+
`bindingState` when `surface.data` is present. Assign `bindingState` separately; the widget-v2
|
|
2853
|
+
document itself never supplies controlled state. Explicit `data: null` remains `bindingState: null`.
|
|
2854
|
+
The original `state` field remains an equal compatibility alias in the helper result; renderers
|
|
2855
|
+
do not read it. Input, props, action payloads and state are detached under the adapter budgets.
|
|
2856
|
+
|
|
2857
|
+
```ts
|
|
2858
|
+
import { adaptA2UiSurface } from "@aceshooting/lyra-ui/ai";
|
|
2859
|
+
import "@aceshooting/lyra-ui/components/lr-message-parts.js";
|
|
2860
|
+
import "@aceshooting/lyra-ui/components/lr-input.js";
|
|
2861
|
+
import { createWidgetTypeRegistry } from "@aceshooting/lyra-ui/components/lr-widget-renderer.js";
|
|
2862
|
+
|
|
2863
|
+
const registry = createWidgetTypeRegistry([["field", {
|
|
2864
|
+
tag: "lr-input", interaction: "control", props: { label: "string", value: "string" },
|
|
2865
|
+
bindings: { value: { event: "lr-input" } },
|
|
2866
|
+
}]]);
|
|
2867
|
+
const adapted = adaptA2UiSurface({
|
|
2868
|
+
rootId: "name-field",
|
|
2869
|
+
components: [{ id: "name-field", type: "Field", props: {
|
|
2870
|
+
label: "Name", value: { $bind: "/name" },
|
|
2871
|
+
} }],
|
|
2872
|
+
data: { name: "Ada" },
|
|
2873
|
+
}, { Field: "field" });
|
|
2874
|
+
const message = document.querySelector("lr-message-parts")!;
|
|
2875
|
+
if (adapted) {
|
|
2876
|
+
message.widgetRegistry = registry;
|
|
2877
|
+
message.widgetBindingState = adapted.bindingState;
|
|
2878
|
+
message.parts = [{ id: "name-form", type: "data", widget: adapted.root }];
|
|
2879
|
+
}
|
|
2880
|
+
message.addEventListener("lr-widget-state-change", (event) => {
|
|
2881
|
+
if (event.detail.path === "/name") message.widgetBindingState = { name: event.detail.value };
|
|
2882
|
+
});
|
|
2883
|
+
```
|
|
2884
|
+
|
|
2885
|
+
For host-specific content, keep using `renderPart(part, index)`: return `undefined` to delegate
|
|
2886
|
+
one part, or return a template to replace it and own its interaction. No extra part registry is
|
|
2887
|
+
required. Widget type registries control the existing widget renderer's allowed component types,
|
|
2888
|
+
separately from the message-part rendering hook.
|
|
2889
|
+
|
|
2787
2890
|
### Interrupting and resuming a streamed run
|
|
2788
2891
|
|
|
2789
2892
|
`stream-interrupt` and `stream-resume` are reducer events for the host-owned transport lifecycle;
|
|
@@ -4319,11 +4422,18 @@ These named interfaces and helper signatures are available to typed integrations
|
|
|
4319
4422
|
components: A2UiLikeComponent[];
|
|
4320
4423
|
data?: unknown;
|
|
4321
4424
|
}`
|
|
4322
|
-
`
|
|
4425
|
+
`A2UiAdapterResult {
|
|
4426
|
+
readonly version: '2';
|
|
4427
|
+
readonly root: LyraWidgetNode;
|
|
4428
|
+
readonly bindingState?: unknown;
|
|
4429
|
+
readonly state?: unknown;
|
|
4430
|
+
}`
|
|
4431
|
+
`adaptA2UiSurface(surface: unknown, typeMap: unknown, limits: Partial<A2UiAdapterLimits> = {}): A2UiAdapterResult | null`
|
|
4323
4432
|
|
|
4324
4433
|
- **`ai-adapters-ag-ui-contracts`** — AI adapter and runtime contracts.
|
|
4325
4434
|
`AgUiAdapterLimits {
|
|
4326
4435
|
maxBufferedTools: number;
|
|
4436
|
+
maxBufferedMessages: number;
|
|
4327
4437
|
maxToolArgumentBytes: number;
|
|
4328
4438
|
maxTextDeltaCharacters: number;
|
|
4329
4439
|
maxDepth: number;
|
|
@@ -4345,6 +4455,23 @@ These named interfaces and helper signatures are available to typed integrations
|
|
|
4345
4455
|
code?: string;
|
|
4346
4456
|
snapshot?: unknown;
|
|
4347
4457
|
messages?: unknown[];
|
|
4458
|
+
name?: string;
|
|
4459
|
+
value?: unknown;
|
|
4460
|
+
activityType?: string;
|
|
4461
|
+
content?: unknown;
|
|
4462
|
+
replace?: boolean;
|
|
4463
|
+
patch?: unknown[];
|
|
4464
|
+
}`
|
|
4465
|
+
`AgUiCustomEvent {
|
|
4466
|
+
name: string;
|
|
4467
|
+
value: unknown;
|
|
4468
|
+
}`
|
|
4469
|
+
`AgUiCustomEventTarget {
|
|
4470
|
+
messageId: string;
|
|
4471
|
+
partId: string;
|
|
4472
|
+
}`
|
|
4473
|
+
`AgUiAdapterOptions {
|
|
4474
|
+
customEventTarget?: (event: AgUiCustomEvent) => AgUiCustomEventTarget | null;
|
|
4348
4475
|
}`
|
|
4349
4476
|
|
|
4350
4477
|
- **`ai-adapters-ai-sdk-contracts`** — AI adapter and runtime contracts.
|