@artooi/ag-ui-web-component 0.43.0 → 0.44.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 CHANGED
@@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.44.0] — 2026-10-20
11
+
12
+ ### Fixed
13
+
14
+ - **`ag-ui-feedback` now says which message was rated.** Its detail carried only
15
+ the message's text and the rating, so a host could not tell two answers that
16
+ read the same apart, and could not find a rated message again after a reload.
17
+ The detail now also carries `messageId`, the AG-UI id of the rated assistant
18
+ message (the id it streamed under, or the stored message's `id` when it was
19
+ restored from history, including the turns a Retry keeps); `threadId`, the
20
+ conversation it belongs to; and `runId`, the run whose `RUN_STARTED` streamed
21
+ it. `runId` is present only on a message that arrived live: a stored AG-UI
22
+ message carries no run id, so the key is absent on a restored one rather than
23
+ guessed; text a sub-agent streams through the parent run carries the
24
+ parent's `runId`. A restored answer whose store returned no id keeps its Copy
25
+ but offers no rating pair, since a rating has to name a message. A restored
26
+ message is named by the id its store returns: the
27
+ built-in browser store keeps the streamed ids, and with `data-threads-url` or
28
+ a host's own store a rating made after a reload names the same message as one
29
+ made live only where the server persists the ids it streamed. Additive: `content` and
30
+ `rating` are unchanged. **A host has to opt in to use it**: the rating pair is
31
+ still off unless `data-message-actions` lists `feedback`, and a host already
32
+ listening reads the new fields from the same event. `AgUiClientHandlers.onTextEnd`
33
+ gains a second argument, `AgUiMessageIds`, naming the completed message; a
34
+ handler that ignores it is unaffected, and code that calls a handler table's
35
+ `onTextEnd` itself has to pass it.
36
+ - **The `data-message-actions` row of the README's attribute table said all
37
+ three actions are on by default.** Absent means copy and retry; the rating
38
+ pair has been opt-in since it was found latching with no listener. The row now
39
+ says so.
40
+
10
41
  ## [0.43.0] — 2026-10-10
11
42
 
12
43
  ### Fixed
@@ -4551,7 +4582,8 @@ hosts that both arrange the page the way it expects.
4551
4582
  ### Notes
4552
4583
  - First release — exercising the automated npm OIDC publish pipeline end-to-end.
4553
4584
 
4554
- [Unreleased]: https://github.com/Artui/ag-ui-web-component/compare/v0.43.0...HEAD
4585
+ [Unreleased]: https://github.com/Artui/ag-ui-web-component/compare/v0.44.0...HEAD
4586
+ [0.44.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.43.0...v0.44.0
4555
4587
  [0.43.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.42.0...v0.43.0
4556
4588
  [0.42.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.41.3...v0.42.0
4557
4589
  [0.41.3]: https://github.com/Artui/ag-ui-web-component/compare/v0.41.2...v0.41.3
package/README.md CHANGED
@@ -199,7 +199,7 @@ another origin, add `credentials="include"` too; see
199
199
  | `data-unread-badge` | — | **On by default.** `="false"` hides the launcher's unread badge; the count and the `ag-ui-unread` event keep running. See [Collapsing to the launcher](#collapsing-to-the-launcher). |
200
200
  | `data-launcher-drag` | — | **On by default.** `="false"` leaves the widget wherever your CSS puts it. Otherwise the collapsed launcher can be dragged anywhere on screen (the panel opens into the clearest space) and the open panel can be dragged by its header. See [Moving the launcher](#moving-the-launcher) and [Moving the panel](#moving-the-panel). |
201
201
  | `data-quote-selection` | — | **On by default.** `="false"` stops the transcript offering to quote a selection. `quote()` keeps working either way. See [Quoting a selection](#quoting-a-selection). |
202
- | `data-message-actions` | — | **All on by default.** A comma list of the actions a finished answer keeps: `copy` / `retry` / `feedback` (e.g. `"copy,retry"`). `="false"` removes the row entirely. See [Message actions](#message-actions-copy-retry-feedback). |
202
+ | `data-message-actions` | — | **Copy and retry by default; feedback is opt-in.** A comma list of the actions a finished answer keeps: `copy` / `retry` / `feedback` (e.g. `"copy,retry,feedback"` to add the rating pair, which needs an `ag-ui-feedback` listener). `="false"` removes the row entirely. See [Message actions](#message-actions-copy-retry-feedback). |
203
203
  | `data-max-tool-rounds` | — | Upper bound on frontend tool-call → re-run rounds within one send (default 10; a value below 1 is ignored). Raise it for a page-driving agent whose turn takes many small steps. See [The run loop](#the-run-loop-and-the-ag-ui-client). |
204
204
  | `data-page-actions` | — | Opt-in built-in page-action tools: a comma list of `scroll` / `drag` / `chat` (e.g. `"scroll,drag"`). See [Page-action tools](#page-action-tools). |
205
205
  | `data-side` | — | CSS-only, for `placement="sidebar"`: which edge it docks to — `right` (default) / `left`. |
@@ -1912,13 +1912,46 @@ still takes its margin and still announces itself as a group of actions.
1912
1912
  `retryLastTurn()` is public, for a host driving its own message UI.
1913
1913
 
1914
1914
  ```js
1915
+ await chat.retryLastTurn(); // false when there is nothing to ask again, a run is in flight, or a restore is loading
1916
+ ```
1917
+
1918
+ ### Storing a rating
1919
+
1920
+ `ag-ui-feedback` names the message that was rated, so a host can file the
1921
+ rating against it rather than against its text — two answers can read the same,
1922
+ and nothing about the text survives a reload:
1923
+
1924
+ | Field | Type | What it is |
1925
+ | --- | --- | --- |
1926
+ | `messageId` | `string` | The AG-UI id of the rated assistant message: the id it streamed under (`TEXT_MESSAGE_START` / `TEXT_MESSAGE_END`), or the stored message's `id` when it was restored from history. A restored answer whose store returned no id offers no rating pair, since a rating has to name a message. |
1927
+ | `threadId` | `string` | The conversation it belongs to: the element's thread when the message was drawn. |
1928
+ | `runId` | `string`, optional | The run that streamed it, as that run's `RUN_STARTED` named it. Text a sub-agent streams through the parent run carries the parent's `runId`. **Absent on a restored message** — an AG-UI message carries no run id, so there is none to give and the key is left out rather than guessed. |
1929
+ | `content` | `string` | The message's text, as rendered. |
1930
+ | `rating` | `"up"` \| `"down"` | Which button. |
1931
+
1932
+ ```js
1933
+ chat.setAttribute("data-message-actions", "copy,retry,feedback");
1915
1934
  chat.addEventListener("ag-ui-feedback", (e) => {
1916
- analytics.track("assistant_rating", e.detail); // { content, rating }
1935
+ const { messageId, threadId, runId, rating } = e.detail;
1936
+ // Keyed by message: rating the same answer again replaces the earlier rating.
1937
+ fetch(`/api/threads/${threadId}/ratings/${messageId}/`, {
1938
+ method: "PUT",
1939
+ headers: { "Content-Type": "application/json" },
1940
+ body: JSON.stringify({ rating, ...(runId === undefined ? {} : { runId }) }),
1941
+ });
1917
1942
  });
1918
-
1919
- await chat.retryLastTurn(); // false when there is nothing to ask again, a run is in flight, or a restore is loading
1920
1943
  ```
1921
1944
 
1945
+ > [!NOTE]
1946
+ > **A restored message is named by whatever `id` the conversation store returns
1947
+ > for it.** The built-in browser store saves the conversation as it streamed, so
1948
+ > there a message keeps its id across a reload. With `data-threads-url` or a
1949
+ > `conversationStore` of your own, the conversation comes back from your server,
1950
+ > and a message keeps its id only if the server persists the ids it streamed:
1951
+ > one that stores the conversation under fresh ids makes a rating made live and a
1952
+ > rating made after a reload name the same answer by two different ids. Live,
1953
+ > the id is always the one on the wire.
1954
+
1922
1955
  ## Quoting a selection
1923
1956
 
1924
1957
  Select any text in the transcript and a small **Quote** offer floats beside it.
@@ -2655,6 +2688,7 @@ re-export point. Internal modules import from leaf paths.
2655
2688
  | `AgUiClient` | class | Orchestration layer over an AG-UI `AbstractAgent`. |
2656
2689
  | `AgUiClientConfig` / `AgUiClientHandlers` / `AgUiRunInputs` | type | Client config, lifecycle handlers, per-run input providers. |
2657
2690
  | `AgUiToolCall` / `ToolExecution` / `ExecuteTool` | type | Tool-call shape, execution result, executor signature. |
2691
+ | `AgUiMessageIds` | type | Which message `AgUiClientHandlers.onTextEnd` completed: its `messageId`, and the `runId` its `RUN_STARTED` named. |
2658
2692
  | `ToolOutcome` | type | The `TOOL_OUTCOME` values as a union. |
2659
2693
  | `toolStatusFromOutcome` | function | Map a wire outcome to the card status it settles into; anything absent or unrecognised is a success. |
2660
2694
  | `ConnectionLostError` | class | Raised (→ `onError`) when a run's stream closes with no terminal AG-UI event. |
@@ -2700,7 +2734,7 @@ re-export point. Internal modules import from leaf paths.
2700
2734
  | `RunFinishedDetail` / `ToolRun` | type | `ag-ui-run-finished` detail: the tools an interaction ran, and which side ran them. |
2701
2735
  | `CustomAgentDetail` | type | `ag-ui-custom` detail: an AG-UI `CUSTOM` event's `name` and `value`, verbatim. |
2702
2736
  | `InvalidateDetail` | type | `ag-ui-invalidate` detail: the resource `keys` that moved, and the `reason`. |
2703
- | `FeedbackDetail` | type | `ag-ui-feedback` detail: the rated message's `content` and the `rating`. |
2737
+ | `FeedbackDetail` | type | `ag-ui-feedback` detail: the rated message's `messageId`, its `threadId`, the `runId` that streamed it (live only), its `content` and the `rating`. See [Storing a rating](#storing-a-rating). |
2704
2738
  | `relativeTime` | function | The built-in locale-neutral timestamp formatter (`"5m ago"`), for a host building on it. |
2705
2739
  | `RelativeTimeFormatter` | type | What `formatRelativeTime` takes: an epoch-ms timestamp in, row text out. |
2706
2740
  | `renderSuggestionChips` | function | Draw a `suggestions` activity as chips that send themselves; `null` when nothing survives. |