@8wave/ai-elements 0.119.0-beta.59 → 0.119.0-beta.60

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/README.md CHANGED
@@ -85,6 +85,8 @@ The `external-token` attribute is **reactive** and acts as the source of truth f
85
85
 
86
86
  Widget sessions created from an external token have a limited duration (default 8 hours, configurable per integration in the backoffice). When the session expires the widget silently re-authenticates with the active token, or emits `external-auth-expired` if that token is no longer valid.
87
87
 
88
+ An agent can use MCP servers that receive the user's token (authentication type "External authentication token per user"). They need a valid token on every message, and your token usually expires long before the widget session does. A minute before it expires (halfway through, for a token that lives two minutes or less) the widget emits `external-token-expiring`: answer with a fresh token of the same user, through the `external-token` attribute or `signIn(token)`, and the session takes it in place, without signing in again. A token of another user still switches the session. Without a fresh token those MCP servers are left out of the conversation until one arrives, and the agent tells the user.
89
+
88
90
  If the token is not available at mount time, add the `await-external-token` attribute to prevent the widget from creating an anonymous session:
89
91
 
90
92
  ```html
@@ -211,6 +213,7 @@ Both elements dispatch standard `CustomEvent`s that bubble and cross shadow DOM
211
213
  | `signed-in` | `{ userId: string, isAnonymous: boolean }` | A session was established or the user changed (any flow: anonymous, external token, email, social). |
212
214
  | `signed-out` | `null` | The session ended without an immediate replacement. |
213
215
  | `external-auth-expired` | `null` | An external token sign-in failed (expired token, invalid signature or disabled config). Listen for it and call `signIn(freshToken)` with a newly generated JWT. |
216
+ | `external-token-expiring` | `null` | The external token of the session expires in a minute (or is halfway through, when it lives two minutes or less), while the session goes on. Call `signIn(freshToken)` with a new JWT of the same user: the session keeps going with it. |
214
217
 
215
218
  ### Example: open widget and send a message
216
219