Novior.MentorAgent.Abstractions
1.5.0
Prefix Reserved
dotnet add package Novior.MentorAgent.Abstractions --version 1.5.0
NuGet\Install-Package Novior.MentorAgent.Abstractions -Version 1.5.0
<PackageReference Include="Novior.MentorAgent.Abstractions" Version="1.5.0" />
<PackageVersion Include="Novior.MentorAgent.Abstractions" Version="1.5.0" />
<PackageReference Include="Novior.MentorAgent.Abstractions" />
paket add Novior.MentorAgent.Abstractions --version 1.5.0
#r "nuget: Novior.MentorAgent.Abstractions, 1.5.0"
#:package Novior.MentorAgent.Abstractions@1.5.0
#addin nuget:?package=Novior.MentorAgent.Abstractions&version=1.5.0
#tool nuget:?package=Novior.MentorAgent.Abstractions&version=1.5.0
Novior.MentorAgent.Abstractions
New package IDs. From 1.0.0 the packages, their namespaces and their assemblies are
Novior.MentorAgent.*; up to 1.0.0-rc.15 they wereMentorAgent.*. See Migrating from the MentorAgent.* packages in the Novior.MentorAgent README.
You do not need to install this package directly. It is included automatically as a transitive dependency of
Novior.MentorAgentandNovior.MentorAgent.Blazor.
This package is the shared foundation of the MentorAgent family. It contains all the contracts, models, and UI components shared between the server-side and client-side packages — with no AI or ASP.NET Core server dependencies, making it fully compatible with Blazor WebAssembly.
Table of Contents
- Package Family
- What's included
- Component parameter reference
- Static assets — CSS and JS
- When you actually touch this package
- Why a separate package?
- Requirements
- Related Packages
- License
Package Family
| Package | Install when |
|---|---|
| Novior.MentorAgent | Blazor Server app |
| Novior.MentorAgent.Server | Web API / headless backend, or Blazor Auto server-side project |
| Novior.MentorAgent.Blazor | Blazor WASM / Blazor Auto client project |
| Novior.MentorAgent.Abstractions ← you are here | Never directly — it arrives with any of the above |
| Novior.MentorAgent.Declarative | Optional — define Level-2 specialist agents in YAML instead of C# |
What's included
Interfaces
| Interface | Description |
|---|---|
IMentorOrchestrator |
AI orchestrator contract — implemented by MentorOrchestrator (server) and WasmMentorOrchestrator (WASM) |
IMentorStateService |
Thread-safe event bus between the AI layer and the UI layer |
IMentorPageContext |
Page context and UI actions registry |
IMentorAgent |
Marker interface for Level 2 specialized agents |
IMentorTeam |
Marker interface for Level 3 collaborative teams |
IMentorStructured |
Typed generation — GenerateAsync<T>(input, instructions) returns a deserialized T, with the JSON schema derived from your type |
IMentorMetrics |
Read-side of the token/cost counters — GetSnapshot() feeds MentorDashboard |
IMentorTour |
Supplies the onboarding tour steps. The default implementation generates them from the app's own pages and tools; register your own to script the tour by hand |
IMentorMetricsStore |
Optional persistence/aggregation for those metrics. Implement it to survive restarts or to read an external aggregate (Prometheus, Azure Monitor) instead of the in-RAM snapshot |
Models
| Type | Description |
|---|---|
ConfirmationRequest |
HITL confirmation request shown in ConfirmationBanner |
MentorRagResult |
A single RAG search result with content, URL, title, and score, plus optional Metadata the model is shown with it |
MentorWidgetOptions |
UI-only options for ChatWidget (theme, position, language, etc.) |
UIActionRegistration |
Handler registration for a page-level UI action |
PageContextSnapshot |
Serializable page context sent from WASM client to server hub |
UIActionInfo |
UI action descriptor in a PageContextSnapshot |
AgentDisplayInfo |
Remote agent display info for the A2A detail badge |
MentorAttachment |
One image on a user turn — DataBase64 (upload/paste) or Url (remote), mapped to the Agent Framework's DataContent / UriContent |
MentorUserMessage |
A user turn as text + attachments; an image-only turn (empty text) is valid |
MentorTourStep |
One step of the onboarding tour — title, body, the screen it describes and a ready-made question the user can send with one tap |
MentorCard |
A generative-UI card a tool returns instead of prose — kind, title, subtitle, fields, actions, image, accent |
MentorCardField / MentorCardAction |
One label/value row, and one button (SendMessage / Navigate / UIAction) |
MentorMetricsSnapshot |
Point-in-time totals, per-model breakdown, hourly series, top actions and cost — the payload of GET /mentor/admin/metrics |
MentorModelUsage |
One model's slice of that snapshot (tokens, calls, latency, cost) |
ModelPrice |
record ModelPrice(decimal InputPer1M, decimal OutputPer1M) — you supply prices; the library ships no price table, because they change and a stale one lies |
Enums
| Enum | Values |
|---|---|
MentorLanguage |
English, Italian, French, German, Spanish, Portuguese, Dutch, Polish, Japanese, Chinese |
MentorTheme |
Default, Dark, Minimal, Custom, Auto |
ChatPosition |
BottomRight, BottomLeft, TopRight, TopLeft, SideRight, SideLeft |
MentorshipLevel |
Minimal, Standard, Proactive |
MentorHostedTools |
[Flags] — None, WebSearch, CodeInterpreter, FileSearch, ImageGeneration, HostedMcp. The set the model provider may run on its own infrastructure; also what the server publishes on connect so a client badge never drifts from the server |
MentorModelKind |
Cheap, Strong, Embedding, Other — how a model's usage is attributed in the metrics snapshot. Other is any model id that is none of the three configured ones, e.g. a ClassifierChatClient on its own deployment |
MentorCardActionKind |
SendMessage, Navigate, UIAction — what a card button does |
MentorCardAccent |
Default, Success, Warning, Danger, Info — the card's colour accent |
UI Components (Razor)
All MentorAgent UI components live here so they work identically in both Blazor Server and Blazor WASM:
| Component | Description |
|---|---|
ChatWidget |
Main floating chat widget — injects CSS/JS automatically |
MessageBubble |
A chat message: Markdown rendering (links to http/https addresses included), citation chips and any images the message carries. XSS-safe by construction — every piece of model text is HTML-encoded before a tag is emitted, so the model supplies data, never markup |
ChatInput |
Text input with voice recognition and the image composer (upload, paste, drag & drop, remote URL) |
MentorDashboard |
Admin token & cost dashboard — per-model breakdown, temporal SVG charts, cost table. Presentational: hand it a MentorMetricsSnapshot, from DI in Blazor Server or from GET /mentor/admin/metrics in WASM. Never rendered by ChatWidget — keep it off end-user pages |
ConfirmationBanner |
HITL approval dialog |
OnboardingTour |
Guided first-run tour. Presentational — it is handed the steps and raises callbacks, which is what lets the same component serve Blazor Server (steps from DI) and WASM (steps over HTTP) |
MentorCardView |
Built-in renderer for a MentorCard. XSS-safe by construction — every value goes through Razor interpolation and no MarkupString is used, because a card carries data and never markup |
WelcomePanel |
Empty-state welcome screen with suggestion chips |
TypingIndicator |
Animated typing dots while AI processes |
RagSourcePanel |
Citation chips below AI responses |
McpStatusBadge / McpDetailBar |
MCP server connection status |
A2AStatusBadge / A2ADetailBar |
A2A remote agent status |
Core
| Type | Description |
|---|---|
MentorLocalizer |
In-memory i18n for 10 languages — no .resx files, no external dependencies. Registered by AddMentorAgent() / AddMentorAgentBlazor(); inject it as MentorLocalizer and call L.Get("key") if you build UI that must match the widget's language. L.Language is the language it uses: the application's, read on every use |
MentorLanguageExtensions |
MentorLanguage.Italian.ToIsoCode() → "it" (ISO 639-1; an unknown value gives "en"), and ToFullName() → "Italian". ToIsoCode() is what the components hand the JS layer, which expands it to the BCP-47 tag the browser Speech APIs expect ("it" → "it-IT"). A custom voice control that talks to SpeechRecognition / speechSynthesis directly has to do that expansion itself to speak the same language as the widget |
TourProgress |
(internal) Where the onboarding tour resumes. Not API — documented only because its edge cases are user-visible |
Component parameter reference
Every component is presentational in the sense that matters: it takes its data through parameters and raises callbacks out, never calling the AI itself. That is what lets the identical component serve Blazor Server (data from DI) and WebAssembly (data over HTTP), and it is what lets you compose the parts on your own pages instead of taking the whole widget.
ChatWidget is the exception — it is the assembled widget and resolves IMentorOrchestrator,
IMentorStateService and navigation for itself.
They still need DI. Every component except
MentorDashboardandMentorCardViewinjectsIOptions<MentorWidgetOptions>,MentorLocalizeror both, soAddMentorAgent()/AddMentorAgentBlazor()must have run in that host. RenderingMessageBubbleon a page of an app that never registered MentorAgent throws at build-render time, not at first interaction.
Namespaces and injections. The components live in
Novior.MentorAgent.Abstractions.Components, the models and enums inNovior.MentorAgent.Abstractions.Models, the interfaces inNovior.MentorAgent.Abstractions.InterfacesandMentorLocalizerinNovior.MentorAgent.Abstractions.Core.ChatMessage/ChatRolecome fromMicrosoft.Extensions.AI. The examples below assume these in your_Imports.razor, plus the services they call injected on the page:@using Novior.MentorAgent.Abstractions.Components @using Novior.MentorAgent.Abstractions.Models @using Novior.MentorAgent.Abstractions.Interfaces @using Novior.MentorAgent.Abstractions.Core @using Microsoft.Extensions.AI @inject IMentorOrchestrator Orchestrator @inject IMentorStateService State @inject NavigationManager Nav @inject IMentorTour Tour
ChatWidget
| Parameter | Type | Description |
|---|---|---|
CardTemplate |
RenderFragment<MentorCard>? |
Optional custom renderer for generative-UI cards. Not supplied → MentorCardView is used. Match on card.Kind and fall back to the built-in renderer for kinds you do not handle |
Language |
MentorLanguage? |
This widget's language: its texts, voice and onboarding tour, and the language of every turn it sends. Not supplied → the application's Language, through the MentorLocalizer from DI. See A language per page in the MentorAgent README |
@* A MentorCardView inside the template needs no OnAction: ChatWidget cascades its own
dispatcher around the cards, so these buttons send / navigate / run the UI action. *@
<ChatWidget>
<CardTemplate Context="card">
@if (card.Kind == "order") { <OrderCard Card="card" /> }
else { <MentorCardView Card="card" /> }
</CardTemplate>
</ChatWidget>
The template replaces the widget's card rendering for every card, but not its button handling:
a <MentorCardView Card="card" /> rendered inside the template without OnAction uses the widget's
dispatcher, so its SendMessage, Navigate and UIAction buttons work as they do on an untemplated
card. An OnAction you set explicitly still wins. Buttons your template draws itself (inside
OrderCard above) do not get the dispatcher: handle them yourself, or render MentorCardView for
the cards whose buttons should just work.
Everything else about the widget comes from MentorWidgetOptions in DI, not from parameters — see
the option tables in the Novior.MentorAgent or
Novior.MentorAgent.Blazor README, depending on which
host you use.
MentorDashboard
| Parameter | Type | Default | Description |
|---|---|---|---|
Snapshot |
MentorMetricsSnapshot? |
null |
An override, not the only source. Pass it in WASM/headless. In Blazor Server leave it null and the component resolves the data itself |
OnRefresh |
EventCallback |
— | Fired after the Refresh button re-resolves. Handle it in WASM to re-fetch; in Blazor Server you can ignore it |
Currency |
string |
"$" |
Symbol prefixed to every cost figure. The library never converts — supply ModelPricing already in the currency you want shown |
Language |
MentorLanguage? |
null |
null → the MentorLocalizer from DI, which follows the Language option on both hosts (AddMentorAgent() and AddMentorAgentBlazor() both register it). Pass it only to override that language, or in an app that registered neither; there the dashboard falls back to English |
The Refresh button is part of the populated view; OnRefresh only decides whether anything of yours
runs when it is pressed. With no data at all the component renders its empty state rather than
throwing, and that state has no Refresh button. In WASM, a first fetch that failed cannot be
retried from the dashboard: retry it yourself (a button of your own, or a timer) and pass the new
Snapshot.
Its resolution order when Snapshot is null is: an external IMentorMetricsStore.QueryAsync()
first (so a Prometheus/Azure Monitor aggregate wins), then the live in-RAM IMentorMetrics snapshot.
@* Blazor Server — no parameters needed *@
<MentorDashboard />
@* WASM — you own the fetch *@
<MentorDashboard Snapshot="_snapshot"
OnRefresh="Reload"
Currency="€"
Language="MentorLanguage.Italian" />
MentorCardView
| Parameter | Type | Description |
|---|---|---|
Card |
MentorCard |
Required. The card to render |
OnAction |
EventCallback<MentorCardAction> |
Raised when a button is pressed. Left unset inside ChatWidget (including in a CardTemplate), the widget's own dispatcher sends / navigates / runs the UI action; an explicit OnAction wins. Wire it yourself when you render cards outside the widget |
<MentorCardView Card="_card" OnAction="RunCardAction" />
@code {
private readonly MentorCard _card = new("order")
{
Title = "Ordine #1002",
Subtitle = "Laura Bianchi",
Accent = MentorCardAccent.Info,
Fields = [new("Stato", "Shipped"), new("Totale", "1.249,98 €")],
Actions =
[
new("Apri", MentorCardActionKind.Navigate, "/orders/1002"),
new("Dettagli", MentorCardActionKind.SendMessage, "Dammi i dettagli dell'ordine 1002"),
],
};
// @inject IMentorOrchestrator Orchestrator, NavigationManager Nav, IMentorPageContext PageContext
private async Task RunCardAction(MentorCardAction action)
{
switch (action.Kind)
{
case MentorCardActionKind.SendMessage:
await Orchestrator.SendMessageAsync(action.Value);
break;
case MentorCardActionKind.Navigate:
Nav.NavigateTo(action.Value);
break;
// Resolved at click time, as ChatWidget does: the page that registered the action
// may have changed since the card was rendered.
case MentorCardActionKind.UIAction
when PageContext.UIActions.TryGetValue(action.Value, out var reg):
if (reg.HandlerAsync is not null) await reg.HandlerAsync(null);
else reg.Handler(null);
break;
}
}
}
The buttons are written by the tool that produced the card, never by the model's prose — which is why a card can safely carry actions. Inside
ChatWidgetthe buttons are handled for you, in aCardTemplatetoo as long as the card is rendered byMentorCardView; wireOnActionyourself only when you render cards outside the widget.
MessageBubble
| Parameter | Type | Description |
|---|---|---|
Message |
ChatMessage |
Required. The MEAI message. Role decides the side and styling |
IsStreaming |
bool |
Renders the trailing caret while text is still arriving |
SentAt |
DateTime? |
Timestamp under the bubble; omitted when null |
Sources |
IReadOnlyList<MentorRagResult>? |
RAG citation chips below the message, rendered through RagSourcePanel, so only on an assistant message and only when MentorWidgetOptions.ShowRagSources is on |
@foreach (var m in _messages)
{
<MessageBubble Message="m.Message" SentAt="m.At" Sources="m.Sources" />
}
@* the one still arriving — the caret is the only difference *@
@if (_streaming is not null)
{
<MessageBubble Message="_streaming" IsStreaming="true" />
}
Message is MEAI's own ChatMessage, so the role decides the side and the styling. Model text is
HTML-encoded before any Markdown tag is emitted, so a reply containing <script> renders as text.
Only an absolute http or https address becomes a link: javascript:, data: and relative ones stay
text.
ChatInput
| Parameter | Type | Description |
|---|---|---|
OnSend |
EventCallback<MentorUserMessage> |
Required. Raised with text and attachments — an image-only turn (empty text) is valid |
Disabled |
bool |
Blocks input while a turn is in flight |
Placeholder |
string? |
Overrides the localised default. MentorWidgetOptions.InputPlaceholder is not read here: ChatWidget passes it in, so pass it yourself on your own surface |
The rest comes from MentorWidgetOptions. The microphone appears only with EnableVoiceInput (and a
browser that supports speech recognition). The image composer appears only with EnableImageInput,
limited by MaxImageBytes, MaxImagesPerMessage and AllowedImageTypes. MaxMessageLength sets
the textarea's maxlength.
<ChatInput OnSend="Send" Disabled="_busy" Placeholder="Chiedi qualcosa sugli ordini…" />
@code {
private bool _busy;
private async Task Send(MentorUserMessage message)
{
_busy = true;
try
{
// Text AND attachments. An image-only turn — empty Text, one attachment — is valid.
await Orchestrator.SendMessageAsync(message.Text, message.Attachments);
}
finally { _busy = false; }
}
}
OnboardingTour
| Parameter | Type | Description |
|---|---|---|
Steps |
IReadOnlyList<MentorTourStep> |
Required. From IMentorTour in Blazor Server, or GET /mentor/tour in WASM |
StartIndex |
int |
Where to open. Clamped into range, so a stale stored index cannot throw |
OnIndexChanged |
EventCallback<int> |
Fired on every step change — this is what the host persists to resume later |
OnNavigate |
EventCallback<string> |
The step's URL, when the user chooses to go there |
OnAsk |
EventCallback<string> |
The step's ready-made question, when the user taps it |
OnClose |
EventCallback |
Skip or finish |
OnNavigate and OnAsk are engagement, not dismissal: the host is expected to suspend the tour
and resume at the next step, not mark it seen. ChatWidget already does this.
@if (_tourOpen)
{
<OnboardingTour Steps="_steps"
StartIndex="_resumeAt"
OnIndexChanged="Persist"
OnNavigate="GoThere"
OnAsk="AskThat"
OnClose="Finish" />
}
@code {
private IReadOnlyList<MentorTourStep> _steps = [];
private bool _tourOpen;
private int _resumeAt;
protected override async Task OnInitializedAsync()
{
// IMentorTour from DI on both hosts: generated in-process on Blazor Server,
// fetched from GET /mentor/tour by Novior.MentorAgent.Blazor on WebAssembly.
_steps = await Tour.GetStepsAsync();
_resumeAt = await LoadSavedIndex(); // your storage; clamped for you
// At or past the end: the user already acted on the last step, so there is nothing to resume.
_tourOpen = _steps.Count > 0 && _resumeAt < _steps.Count;
}
// Track where the user IS, not where the tour opened: the component moves on its own and
// OnIndexChanged is the only way you learn it.
private Task Persist(int index) { _resumeAt = index; return SaveIndex(index); }
// Engagement, not dismissal: suspend and resume at the NEXT step rather than marking it seen.
private async Task GoThere(string url) { _tourOpen = false; await SaveIndex(_resumeAt + 1); Nav.NavigateTo(url); }
private async Task AskThat(string q) { _tourOpen = false; await SaveIndex(_resumeAt + 1); await Orchestrator.SendMessageAsync(q); }
private Task Finish() { _tourOpen = false; return MarkSeen(); }
}
ConfirmationBanner
| Parameter | Type | Description |
|---|---|---|
Request |
ConfirmationRequest |
Required. What is being approved |
OnConfirm |
EventCallback |
Required. Approve |
OnCancel |
EventCallback |
Required. Reject |
@if (_pending is not null)
{
<ConfirmationBanner Request="_pending" OnConfirm="Approve" OnCancel="Reject" />
}
@code {
private ConfirmationRequest? _pending;
protected override void OnInitialized() =>
State.OnConfirmationRequired += r => { _pending = r; InvokeAsync(StateHasChanged); };
private async Task Approve() { var r = _pending!; _pending = null; await State.ConfirmAsync(r.ActionId); }
private Task Reject() { var r = _pending!; _pending = null; State.Cancel(r.ActionId); return Task.CompletedTask; }
}
On WebAssembly the snippet above already answers over HTTP:
State.ConfirmAsync/State.Cancelpost toPOST /mentor/approve?actionId=…&approved=true|falserather than calling a hub method, because SignalR dispatches one invocation at a time per connection, so a hub call would queue behind the very turn it is meant to release. The request goes to the hub's origin whenMentorAgentBlazorOptions.HubUrlis an absolutehttp(s)URL (relative to the hostHttpClient'sBaseAddresswhen it is relative, i.e. same-origin hosting) and carriesAuthorization: Bearer <token>fromMentorAgentBlazorOptions.AccessTokenProviderwhen one is set, the same credential the hub uses, so a signed-in user's answer is not refused with 401. Stop takes the same route (POST /mentor/cancel). The host must still register anHttpClient, as the WASM template does. Call the endpoints yourself only from a client that has noIMentorStateService(JavaScript, React), and send the same bearer token there.
WelcomePanel
| Parameter | Type | Default | Description |
|---|---|---|---|
BotName |
string |
"Mentor AI" |
Shown in the empty state heading and as the avatar's alt text |
WelcomeMessage |
string? |
null |
null or blank → the localised default. Rendered as HTML, not encoded: pass only text you wrote, never user or model input |
EnableSuggestions |
bool |
true |
Whether to render the three built-in, localised suggestion chips. They also need OnChipClick; with no handler they are not rendered |
OnChipClick |
EventCallback<string> |
— | The chip's text, to be sent as a user turn |
@if (_messages.Count == 0)
{
<WelcomePanel BotName="Assistente ShopFlow"
WelcomeMessage="Ciao! Posso aiutarti con ordini e prodotti."
EnableSuggestions="true"
OnChipClick="Send" />
}
The chip's text arrives as an ordinary user turn — there is nothing special about it, which is why
OnChipClick and the input's OnSend can share one handler.
RagSourcePanel
| Parameter | Type | Description |
|---|---|---|
Sources |
IReadOnlyList<MentorRagResult>? |
Citation chips: the first three, then a "+N more" chip that expands the rest. Renders nothing when null, empty, or when MentorWidgetOptions.ShowRagSources is off, which is the default: set options.ShowRagSources = true on either host |
<RagSourcePanel Sources="_sources" />
@code {
// null or empty renders nothing at all, so there is no need to guard the element.
private IReadOnlyList<MentorRagResult>? _sources;
protected override void OnInitialized() =>
State.OnRagSourcesReady += s => { _sources = s; InvokeAsync(StateHasChanged); };
}
Status badges
| Component | Parameters |
|---|---|
McpStatusBadge |
ServerStatus (IReadOnlyDictionary<string, bool?>? — name → connected/failed/unknown), OnToggle |
McpDetailBar |
Visible (bool), ServerStatus, OnClose |
A2AStatusBadge |
OnToggle — the agent list comes from MentorWidgetOptions.RemoteAgentDisplays |
A2ADetailBar |
Visible (bool), OnClose |
bool? in ServerStatus is three-valued on purpose: true connected, false failed,
null not yet probed. Rendering null as "failed" would show a red badge during startup.
The badges are also gated by MentorWidgetOptions, so on a page of your own they render nothing until
the matching options are set. McpStatusBadge needs ShowMcpStatus and HasMcpServers, plus at
least one entry in ServerStatus. McpDetailBar needs HasMcpServers and a non-empty ServerStatus.
A2AStatusBadge needs ShowA2AStatus and HasRemoteAgents. A2ADetailBar needs a non-empty
RemoteAgentDisplays. On Blazor Server, AddMentorAgent() fills HasMcpServers, HasRemoteAgents,
RemoteAgentDisplays and McpServerNames from your MCP and A2A configuration. On WebAssembly you set
them on MentorAgentBlazorOptions, because the client cannot see the server's configuration.
<McpStatusBadge ServerStatus="_mcp" OnToggle="() => _mcpOpen = !_mcpOpen" />
<McpDetailBar Visible="_mcpOpen" ServerStatus="_mcp" OnClose="() => _mcpOpen = false" />
<A2AStatusBadge OnToggle="() => _a2aOpen = !_a2aOpen" />
<A2ADetailBar Visible="_a2aOpen" OnClose="() => _a2aOpen = false" />
@code {
private bool _mcpOpen, _a2aOpen;
// name → connected. Seed every configured server as null ("connecting") rather than false:
// nothing has been probed yet. An EMPTY dictionary hides the badge until the first status
// event, which with lazily-connected MCP servers is the first message.
// (@inject IOptions<MentorWidgetOptions> Options)
private readonly Dictionary<string, bool?> _mcp = new(StringComparer.OrdinalIgnoreCase);
protected override void OnInitialized()
{
foreach (var name in Options.Value.McpServerNames) _mcp[name] = null;
State.OnMcpServerStatusChanged += (name, ok) =>
{
_mcp[name] = ok;
InvokeAsync(StateHasChanged);
};
}
}
The A2A badge takes no data parameter on purpose — its agent list comes from
MentorWidgetOptions.RemoteAgentDisplays, because a remote agent is configuration rather than
runtime state.
TypingIndicator
No parameters — animated dots. Show it while a turn is in flight and nothing has streamed yet.
@if (_busy && _streaming is null)
{
<TypingIndicator />
}
Show it only while a turn is in flight and nothing has streamed yet — once the first token lands,
MessageBubble with IsStreaming="true" carries the signal instead.
Composing your own chat surface
The reason these components take parameters and raise callbacks instead of calling the AI is so you can build a surface that is not the floating widget — an inline panel, a side rail, a page of your own. Everything below is host-agnostic: in Blazor Server the state service comes from DI, on WebAssembly the same interface is backed by the hub.
Without ChatWidget on the page nothing injects the stylesheet and the script, so add both tags
yourself: see Static assets — CSS and JS.
@inject IMentorOrchestrator Orchestrator
@inject IMentorStateService State
@implements IDisposable
<div class="my-chat">
@if (_messages.Count == 0)
{
<WelcomePanel BotName="Assistente" OnChipClick="Send" />
}
@foreach (var m in _messages)
{
<MessageBubble Message="m" />
}
@if (_streaming is not null) { <MessageBubble Message="_streaming" IsStreaming="true" /> }
@if (_busy && _streaming is null) { <TypingIndicator /> }
<RagSourcePanel Sources="_sources" />
@if (_pending is not null)
{
<ConfirmationBanner Request="_pending" OnConfirm="Approve" OnCancel="Reject" />
}
<ChatInput OnSend="OnSend" Disabled="_busy" />
</div>
@code {
private readonly List<ChatMessage> _messages = [];
private ChatMessage? _streaming;
private IReadOnlyList<MentorRagResult>? _sources;
private ConfirmationRequest? _pending;
private bool _busy;
private readonly System.Text.StringBuilder _buffer = new();
protected override void OnInitialized()
{
State.OnStreamingChunk += Chunk;
State.OnStreamingCompleted += Completed;
State.OnBusyChanged += Busy;
State.OnRagSourcesReady += Rag;
State.OnConfirmationRequired += Confirm;
}
private void Chunk(string c)
{
_buffer.Append(c);
_streaming = new ChatMessage(ChatRole.Assistant, _buffer.ToString());
InvokeAsync(StateHasChanged);
}
private void Completed()
{
if (_buffer.Length > 0) _messages.Add(new ChatMessage(ChatRole.Assistant, _buffer.ToString()));
_buffer.Clear();
_streaming = null;
InvokeAsync(StateHasChanged);
}
private void Busy(bool b) { _busy = b; InvokeAsync(StateHasChanged); }
private void Rag(IReadOnlyList<MentorRagResult> s) { _sources = s; InvokeAsync(StateHasChanged); }
private void Confirm(ConfirmationRequest r) { _pending = r; InvokeAsync(StateHasChanged); }
private async Task Send(string text) => await OnSend(new MentorUserMessage(text));
private async Task OnSend(MentorUserMessage m)
{
_messages.Add(new ChatMessage(ChatRole.User, m.Text));
_sources = null;
await Orchestrator.SendMessageAsync(m.Text, m.Attachments);
}
private async Task Approve() { var r = _pending!; _pending = null; await State.ConfirmAsync(r.ActionId); }
private Task Reject() { var r = _pending!; _pending = null; State.Cancel(r.ActionId); return Task.CompletedTask; }
public void Dispose()
{
State.OnStreamingChunk -= Chunk;
State.OnStreamingCompleted -= Completed;
State.OnBusyChanged -= Busy;
State.OnRagSourcesReady -= Rag;
State.OnConfirmationRequired -= Confirm;
}
}
Unsubscribe. These are plain C# events on a scoped service that outlives your component, so a component that subscribes and never detaches is kept alive by the service and re-rendered after disposal.
ChatWidgetdoes this for you; a hand-built surface has to do it itself.
Subscribe to OnError too. A message the host refuses before the model runs produces no streamed
text and no OnStreamingCompleted: only OnError with the localised reason, then OnBusyChanged(false).
That covers a message that is too long or rate-limited, one blocked by the safety check (or, with
SafetyCheckFailure = MentorSafetyCheckFailure.Block, one whose check could not run), and one refused
as out of scope under RefuseOutOfScope. Provider failures arrive the same way. Without a handler, the
surface above shows the user's bubble and then nothing:
@if (_error is not null) { <div class="my-chat__error">@_error</div> }
@code {
private string? _error;
// OnInitialized: State.OnError += Error; Dispose: State.OnError -= Error;
// OnSend: _error = null; before sending the next message
private void Error(string message) { _error = message; InvokeAsync(StateHasChanged); }
}
Static assets — CSS and JS
The stylesheet and the JavaScript layer ship in this package, not in Novior.MentorAgent:
_content/Novior.MentorAgent.Abstractions/css/MentorAgent.css
_content/Novior.MentorAgent.Abstractions/js/MentorAgent.js
_content/Novior.MentorAgent.Abstractions/IconMA.png ← default avatar
ChatWidget injects the first two itself through <HeadContent>, so a Blazor Server or Blazor Web
App host needs no markup, and it versions them for you: the ?v= it writes is the package version
and the commit the package was built from (?v=<version>+<commit>), so every release changes it.
A standalone WASM host references them manually in index.html instead — and neither file is
fingerprinted, and UseStaticFiles serves them without a Cache-Control, so the ?v= query string
is the cache buster: set it to the version of the package you install and change it on every
upgrade. A stale MentorAgent.js fails silently and looks like
missing features rather than a caching problem.
That injection happens only where ChatWidget is rendered, and it relies on the <HeadOutlet />
that the Blazor Web App template already includes. A page that composes the parts without
ChatWidget (see Composing your own chat surface) gets neither
file: the components render unstyled, and ChatInput's microphone and paste / drag & drop stay off
without an error. Sending a message still works: the call that resets the textarea after a send is
guarded, so a missing script neither throws nor ends a Blazor Server circuit. Reference both files yourself in that case, with the same paths
and the package version as the ?v= (ChatWidget adds the commit; a link you write needs only the
version), in App.razor (Blazor Server / Web App) or index.html:
<link href="_content/Novior.MentorAgent.Abstractions/css/MentorAgent.css?v=1.5.0" rel="stylesheet" />
<script src="_content/Novior.MentorAgent.Abstractions/js/MentorAgent.js?v=1.5.0"></script>
The script can safely load a second time on a page where ChatWidget also renders: the later tag
wins and the voice state carries over.
The JS layer covers text-to-speech (sentence-queued, barge-in, hands-free), speech recognition, the
image composer (upload, paste, drag & drop, client-side downscaling) and localStorage helpers. It
is called through IJSRuntime by the components; there is no supported way to call it directly.
For the complete CSS variable reference — palette, widget size, fonts, the dashboard and chart
colours — see Widget customization → CSS variables
in the Novior.MentorAgent README. The variables are defined here but documented there, next to the
options that set them.
When you actually touch this package
Most of the time you never reference these types by name — Novior.MentorAgent and Novior.MentorAgent.Blazor
wire them for you. Three cases where you do:
1. Rendering the admin dashboard yourself. MentorDashboard is presentational, so the same
component works in-process and over HTTP. In Blazor Server, inject the metrics; in WASM, fetch the
snapshot from the admin endpoint:
@* Blazor Server — in-process. It resolves the metrics itself; no parameters needed. *@
<MentorDashboard />
@* WASM — over HTTP. There is no IMentorMetrics in the browser, so pass the snapshot. Language is optional: it follows AddMentorAgentBlazor's Language unless you override it. *@
@inject HttpClient Http
<MentorDashboard Snapshot="_snapshot" Language="MentorLanguage.Italian" />
@code {
MentorMetricsSnapshot? _snapshot;
protected override async Task OnInitializedAsync() =>
_snapshot = await Http.GetFromJsonAsync<MentorMetricsSnapshot>("/mentor/admin/metrics");
}
Put it behind authorization. The snapshot is operator data — cost, volumes, top actions — and must never appear on an end-user page.
The endpoint is gated on its own as well:
GET /mentor/admin/metricsrequires the role inMentorOptions.DashboardRole("Admin"by default;""leaves it open, for development only). TheHttpClientyou fetch with must therefore send the signed-in admin's credentials (cookie or bearer token). Without them the request is refused (401/403, or a redirect to the login page under cookie authentication) andGetFromJsonAsyncthrows instead of the dashboard rendering its empty state. In a standalone WASM app, itsBaseAddressmust also be the server's origin, not the client's.
2. Persisting or aggregating metrics. Implement IMentorMetricsStore and register it before
AddMentorAgent(), in a headless host too, where AddMentorAgentServer() comes after it. Registered
any later, the store still answers QueryAsync, but LoadForSeedAsync and SaveAsync are never called,
because the persistence service is added only when the store is already there. Without one the snapshot
lives in RAM and resets on restart; with one you get durability, or you can serve an external aggregate
instead:
Every method has a default no-op implementation, because the two scenarios use different halves of the contract — implement only the one you need:
// (A) Local durability — restore totals at startup, persist periodically and on shutdown.
// QueryAsync stays default (null) so the dashboard keeps serving the live in-RAM snapshot.
public sealed class FileMetricsStore : IMentorMetricsStore
{
public Task<MentorMetricsSnapshot?> LoadForSeedAsync(CancellationToken ct = default) => /* read */;
public Task SaveAsync(MentorMetricsSnapshot s, CancellationToken ct = default) => /* write */;
}
// (B) External source — serve the aggregate your OpenTelemetry export already pushed to
// Prometheus / Azure Monitor (multi-instance, historical). Nothing to seed, nothing to save.
public sealed class PrometheusMetricsStore : IMentorMetricsStore
{
public Task<MentorMetricsSnapshot?> QueryAsync(CancellationToken ct = default) => /* query */;
}
builder.Services.AddSingleton<IMentorMetricsStore, FileMetricsStore>(); // BEFORE AddMentorAgent()
3. Building your own composer or transcript. MentorUserMessage + MentorAttachment are the shape
of a user turn, and IMentorOrchestrator.SendMessageAsync(text, attachments) is what consumes it — so
a custom input control can replace ChatInput without touching the orchestration layer.
Working implementations ship in the samples repository, Novior.MentorAgent.Samples: the dashboard
in the AdminDashboard page of MentorAgentSample, MentorAgentNuget, MentorAgentBlazor and
MentorAgentNugetWebAssembly; a FileMetricsStore in six hosts (MAUI included), and
PrometheusMetricsStore and AzureMonitorMetricsStore in MentorAgentServer and
MentorAgentNugetApiServer; and a composer of its own in the React client, mentoragentreact,
which sends the same message and attachments over the SignalR hub.
Why a separate package?
Novior.MentorAgent depends on Microsoft.Agents.AI, ModelContextProtocol and other packages that are not compatible with Blazor WebAssembly. Novior.MentorAgent.Blazor (WASM) cannot reference Novior.MentorAgent directly.
Novior.MentorAgent.Abstractions contains only WebAssembly-safe dependencies:
Microsoft.AspNetCore.Components.WebMicrosoft.AspNetCore.Components.AuthorizationMicrosoft.Extensions.AI
Both Novior.MentorAgent and Novior.MentorAgent.Blazor reference Novior.MentorAgent.Abstractions — sharing interfaces, models, and UI components without cross-contaminating dependencies.
The practical rule: anything that must run in the browser goes here. If you are adding a type
and it needs Microsoft.Agents.AI, an HttpContext, or the file system, it does not belong in this
package — the WASM build will not fail at compile time, it will fail at runtime in the browser.
Requirements
- .NET 10.0 or later
Microsoft.AspNetCore.Components.Web10.0.3Microsoft.AspNetCore.Components.Authorization10.0.3Microsoft.Extensions.AI11.0.0
No AI provider, no server packages, no JavaScript dependencies beyond the browser's own Speech and File APIs.
Related Packages
| Package | Purpose |
|---|---|
| Novior.MentorAgent | Blazor Server — full AI assistant |
| Novior.MentorAgent.Server | Any ASP.NET Core app — headless AI backend |
| Novior.MentorAgent.Blazor | Blazor WASM — SignalR client |
| Novior.MentorAgent.Declarative | Optional — Level-2 specialists defined in YAML |
License
Apache License 2.0 — the full text is in the LICENSE file inside this package, with the copyright notice in NOTICE. Versions up to and including 1.0.0-rc.14 were released under the MIT License, which still applies to them.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Authorization (>= 10.0.3)
- Microsoft.AspNetCore.Components.Web (>= 10.0.3)
- Microsoft.Extensions.AI (>= 11.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Novior.MentorAgent.Abstractions:
| Package | Downloads |
|---|---|
|
Novior.MentorAgent
Add AI agents to your .NET application, under your rules. C# methods become tools for an agent built on Microsoft Agent Framework; on each one you declare which roles may use it and whether the user must confirm first. Ready-made chat widget for Blazor and MAUI, or any front end over SignalR and SSE; MCP and A2A with Novior.MentorAgent.Server. Cost control, multi-agent teams, RAG and memory. |
|
|
Novior.MentorAgent.Blazor
Blazor WebAssembly client for MentorAgent. Install in your Blazor WASM / Blazor Auto client project. Connects to a Novior.MentorAgent.Server hub via SignalR and provides the same ChatWidget experience as Blazor Server. |
GitHub repositories
This package is not used by any popular GitHub repositories.
1.5.0 - 2026-11-26
### Added
- The AutoMentor knows the pages of a Blazor application from its routes, with no attribute: with
`options.AutoMentor.Enabled`, the components that carry `@page` in the entry assembly, in the assemblies it
references that use the components, and in the new `AutoMentor.PageAssemblies`, read once. The WebAssembly client of
Novior.MentorAgent.Blazor sends its own pages to the server at every connection, with the new hub method
`ReportPages` (`PageRouteInfo`); `MentorAgentBlazorOptions.PageAssemblies` adds an assembly. Structure only: a route
and the component that serves it. New rules in ACTION-RULES.md: `page.from-routes`, `page.client-routes`,
`page.route-shape`, `page.route-limit`, `page.read`. README: «Pages from your routes».
- The AutoMentor reads the manifest of the pages a scan writes, `mentor-ui-manifest.json` in the project: the targets
of Novior.MentorAgent, in `buildTransitive`, embed it in the application, also one that references only
Novior.MentorAgent.Server, and the host reads it once with the pages. A page it has is scanned, with the elements
the scan read; the others are to scan. It is read as untrusted: a password field, card data (`autocomplete="cc-*"`),
a hidden, disabled or `data-mentor-exclude` element never comes out, and a value has no place in it. New rules in
ACTION-RULES.md: `page.manifest`, `page.manifest-read`, `page.manifest-version`, `page.manifest-excluded`,
`page.manifest-shape`.
- `IMentorActionCatalog.GetPages()` lists the pages the AutoMentor knows, each a `MentorPageInfo` with its route, its
component, its `MentorPageCoverage` (`ToScan` or `Scanned`), when the scan read it and its elements
(`MentorPageElement`: tag, role, label, type, option labels, form, a stable selector, the roles it was seen with).
A catalogue written before the member lists none. New rule in ACTION-RULES.md: `page.catalog`.
- **Novior.MentorAgent:** the package now carries `buildTransitive/Novior.MentorAgent.targets`. When the project has
`mentor-ui-manifest.json` (or the file its `MentorUiManifest` property names), it embeds the file in the application
and takes it out of `Content` and `None`; without the file it does nothing. It holds no target and no check, so it
cannot stop a build.
- `MentorActionInfo.ParametersSchema`: the JSON schema of an action's arguments, the one the model reads in the
action's tool, for every origin. An endpoint declared as an action has the schema of its route, its query and its
body; a command or a query, its type's properties. `null` when there is no tool to read it from, such as an endpoint
in a host without Novior.MentorAgent.Server. New rule in ACTION-RULES.md: `describe.parameters-schema`.
- **Novior.MentorAgent.Scanner**, a new package for development: `AddMentorUiScanner()` scans the pages of a Blazor
application once it has started, in `Development` only, with the Edge or Chrome already installed (it downloads
none), and writes `mentor-ui-manifest.json` in the project for the AutoMentor. Structure only, never a value.
Reference it in Debug only. With `MentorAgent:Scanner:Roles` it also reads the pages as a user of its own with each
role, signed in with a one-time token, in `Development` and from this machine only; it clicks only what opens a tab,
a menu or a collapsed section, never a submit or a delete. MentorAgent's own chat widget, and what the page does not
show, stay out of the manifest; the rows of a table are read once per column, with the column's header. Its browser closes with the application, on Windows also
when the application is killed; elsewhere the next scan closes it. A page with route parameters is opened with the
values of `MentorAgent:Scanner:RouteParameters`. A scan reads again only the pages whose code, or whose layout's,
changed (`MentorAgent:Scanner:Full` reads them all), and writes the manifest only when it changes. In a .NET MAUI
Blazor Hybrid app on Windows, `StartMentorUiScan()` reads the pages in the app's own WebView2, in a Debug build only,
as the app's user. New rules in ACTION-RULES.md: `page.scan`, `page.scan-development`, `page.scan-browser`,
`page.scan-user`, `page.scan-clicks`, `page.scan-parameters`, `page.scan-changed`, `page.scan-webview`.
- **Novior.MentorAgent.Cli**, a new .NET tool: `novior-mentor scan` runs the same scan from outside the app, for a CI
pipeline or a WebAssembly standalone app. The pages come from the app's built dll, the app runs at `--url`, and the
browser runs on the machine that runs the command. `--account <role>=<variable>` reads as an account of the team,
its session cookie taken from an environment variable and never logged; `--fail-on-change` writes nothing and exits
with 3 when the manifest would change. New rules in ACTION-RULES.md: `page.scan-tool`, `page.scan-ci`.
- **Observation of the pages in production** (`MentorAutoMentorOptions.ObservePages`, on by default, with the
AutoMentor, which is off by default): the widget reads what the users open, dialogs, tabs and panels included, with
the scan's own reader, and sends the structure, never a value, no option of a select, no text of a row, a list or a
card. An observed element's selector is its `data-mentor-id`, or a path of tags and positions from the nearest
ancestor with one, or from the body: never an id, a class, a name or a `data-testid`, which may be a record's; give
the elements a `data-mentor-id` for stable selectors. An element reaches `IMentorActionCatalog.GetPages()` only once two users saw it the same (one is enough in a
MAUI Hybrid app, on the user's own device), marked with the new `MentorPageElement.Coverage` (`Observed`), and with
no label and no form: what a user saw stays in the application's process. A page only observed has the new
coverage `MentorPageCoverage.Observed`. Kept in memory, within limits, never in the log. A WebAssembly client of
**Novior.MentorAgent.Blazor** sends it to the hub's new `ReportObservedPage` (**Novior.MentorAgent.Server**), with
the new `PageObservedElement`, once the widget connects to the hub, usually at the first message; until then it
waits in the browser, at most 200 messages. New rules in
ACTION-RULES.md: `page.observe`, `page.observe-private`, `page.observe-values`, `page.observe-repeated`,
`page.observe-shared`, `page.observe-route`, `page.observe-limit`, `page.observe-off`.
- **Recipes of the pages, from a source**: a recipe is a sequence of steps on one page that the widget runs in the
user's browser, with the new `MentorRecipeRunner.js` of **Novior.MentorAgent.Abstractions**, offered to the model as
one of the page's UI actions with its own roles and its own confirmation. An application gets its recipes from an
`IMentorRecipeSource` (`AddMentorRecipeSource<T>()`), typically the bridge of a console where they are approved:
asked once for a session, which keeps them, it gives `MentorRecipeDefinition`s, known by their route and their name.
A recipe that breaks a rule (`MentorRecipeLimits`) is left out with a code of the closed list
`MentorRecipeRejectionReasons`, reported to the new `IMentorAgentSourceObserver.OnRecipesLoaded` (with a default
body), and is never a tool. A recipe is governed as a UI action of its page: the policies answer for it by page and
name when it is offered and when it is called. With the name of a UI action the page registers in code, the source
says who wins (`MentorRecipeSourceResult.Precedence`: `MentorRecipePrecedence.Code`, the default, or `Source`); any
other tool always wins over a recipe. A recipe turned off stays off in its version: a new version is on. A step whose element is gone, hidden, disabled or excluded stops
the recipe and turns it off. New reason code of `Failed`: `MentorActionReasons.ElementMissing` (`element-missing`).
A row step finds the row of a table or a grid by the text of a key cell, compared in the browser, with the page's
filter or scrolling, a virtualized `QuickGrid` included, and clicks an action in it; after writing the page's
filter it waits for the page's answer, up to 5 seconds, so that a server slower than a quiet while (Blazor Server
under load) is not read before it answered, and a render that leaves the rows as they were, as Blazor Server makes
at the first await of the event's handler, is not taken for the answer; nothing inside
`data-mentor-exclude` is read, rows, key cells or filters. The steps of a run weigh at most 16 KB. On a WebAssembly
client the hub asks the client to run the recipe (`RecipeRequested`, with a run id of the server's, answered once),
and the client answers with the new `POST /mentor/recipe-result` of **Novior.MentorAgent.Server**, owner-checked
like `/mentor/cancel`, with done, the step and the reason only; **Novior.MentorAgent.Blazor** sends the path of the
page shown, without its query or fragment, with the page context. New rules in ACTION-RULES.md:
`recipe.shape`, `recipe.offer`, `recipe.gated`, `recipe.run`, `recipe.row`, `recipe.row-excluded`,
`recipe.element-missing`, `recipe.from-source`, `recipe.precedence`, `recipe.session`, `recipe.rejected-with-reason`, `recipe.governed`,
`recipe.hub`, `recipe.hub-result`.
- **Recipes in React, Angular and other front ends**: **Novior.MentorAgent.Server** serves `/mentor/agent.js`, a
JavaScript module with the recipes' runner that a front end that is not Blazor loads with `<script type="module">`
and ties to its own `@microsoft/signalr` connection with `attach(connection, options)`: the recipes the hub asks for
run in the page, the answer goes back with `POST /mentor/recipe-result`, and the front end's routes reach the server,
from `options.routes` (`/orders/:id`) or from the links of the page. A field is written so that React's controlled
fields keep the value in their state and Angular's forms read it, and is then left (`blur`), as `updateOn: 'blur'`
needs. The script has the hub's CORS, never its authorization, and is cached for a year at the address with the
package's version (`?v=`). React and Angular do not observe the pages yet. New rules in ACTION-RULES.md:
`recipe.front-end`, `recipe.front-end-cors`, `page.front-end-routes`. README of Novior.MentorAgent.Server: «Recipes
in React, Angular and other front ends».
- **Angular's own routes for `/mentor/agent.js`**: `attach`'s `routes` also takes the router's configuration, Angular's
`Routes` or React Router's route objects, with their `children`; a redirect is not a page, and a class component is
named by its route. A recipe is tested on an Angular 22 reactive form, built ahead of time and zoneless: the values
stay in the form, `updateOn: 'blur'` included, and the Send it enables is clicked.
- **The scan of a React or Angular front end**: in the .NET backend, **Novior.MentorAgent.Scanner** reads the pages of
a front end it does not serve, at the new `MentorUiScannerOptions.FrontEndUrl` (the development server of Vite or of
the Angular CLI): the routes of the new `FrontEndRoutes` (`/orders/:id`, with the values of `RouteParameters`), or the
pages its links reach from its first page. With no user, each page at every scan. New rule in ACTION-RULES.md:
`page.scan-front-end`.
- **Novior.MentorAgent.Abstractions:** `IMentorAssistantStatus`, for an application that turns its assistant off from
somewhere else, a switch of its own or a console. While its `IsOn` is false, the chat widget disables the input and
the send button, offers no suggestion to send, shows *off* in its header where it shows *online*, and says, right
above the input and before anyone writes, that the assistant was turned off by the administrator, in the ten
languages of the widget. `Changed` may come on a
background thread. Without a service registered nothing changes. README: «Showing that the assistant is off».
- **Novior.MentorAgent.Server, Novior.MentorAgent.Blazor:** the assistant turned off reaches the hub's clients. The hub
method `GetAssistantStatus` answers whether it is on, and the event `AssistantStatus(bool)` goes to every connection
when it is turned off or on, only with an `IMentorAssistantStatus` registered in the server. The WebAssembly widget
reads it when it connects and follows each change, as the widget in the server does; its client now opens the hub
connection when the widget is created, not at the first message, and sends no message while the assistant is off.
Two openings at once now make one connection: the second waits for the first. `/mentor/agent.js` gives a
React or Angular page `assistantIsOn()` and `onAssistantStatus(callback)`.
- **Novior.MentorAgent.Abstractions:** the cost per agent and per user. `IMentorActionObserver.OnModelCallAsync`
receives a `MentorModelCall` for each call to a model: its tokens (cached and reasoning ones included, when the
provider says so), the model, how it ended, the agent that made it, and the session, the turn, the user and the
tenant, never the text. Each agent has its calls: the coordinator, the router of the handoff (`MentorAgentKind.Router`,
new), the specialists, the team members and the agents of an `IMentorAgentSource`. MentorAgent's own calls come
too, with no agent and what they were for (`MentorModelCallPurpose`): the input, output and scope checks, the
request and announced-action checks, the refusal and grounding checks, the memory's extraction, the routing
classifier and the warm-up, the one call outside any session. It has a default that does nothing, so an existing
observer is unchanged and is not called for them. The calls come on a queue of their own: a full one drops calls,
never a decision, and the order between a call and a decision is not kept. README: «The calls to the models».
- **A page's form as a UI action** (**Novior.MentorAgent.Abstractions**): `IMentorPageContext.RegisterForm<TModel>(name,
description, js, configure)` registers the form whose model is `TModel` as one UI action, `fill_<name>`, whose
parameter is the fields to fill. The fields are the model's simple properties with a setter, found in the page by
their `data-mentor-id` (`"<name>.<field>"`), or by a selector of the application's (`MentorFormOptions`); each value
is checked against its field's type, and the fields are written in the browser with the recipes' runner, through the
page's `IJSRuntime`, on Blazor Server, WebAssembly and MAUI Hybrid. The action fills and never submits the form:
sending it stays an action of the application's, with its confirmation if it writes. It goes through the gate as any
UI action. Sensitive fields (passwords, secrets, tokens, PINs, cards, IBANs, one-time codes) are never offered unless
the application lets them in (`IncludeSensitive`), and the runner never writes a password field, for a form or a
recipe, unless its field was let in. New rules in ACTION-RULES.md: `form.fill`, `form.sensitive`.
- **A page's grid as UI actions** (**Novior.MentorAgent.Abstractions**): `IMentorPageContext.RegisterGrid<TRow>(name,
description, js, key, configure)` registers a table of rows, written by hand or a `QuickGrid`, as
`open_<name>_row({ key })`, `sort_<name>({ column, descending? })` and `filter_<name>(text)`, each offered only when
the grid can do it (`MentorGridOptions`: `Filter`, `Sortable`). The parts are found by their `data-mentor-id`, or by
selectors of the application's, which a `QuickGrid` needs. A row is found by its key, after the grid's filter or
scrolling, and opened; a sort clicks the header until its `aria-sort` reads the order asked. Nothing of the rows
goes back to the model. A sensitive column is not sorted by unless the application lets it in, and is never the
key. The steps run with the recipes' runner through the page's `IJSRuntime`, and the actions go through the gate as
any UI action. New rules in ACTION-RULES.md: `grid.open`, `grid.filter`, `grid.sort`, `grid.sensitive`.
- **Novior.MentorAgent.Abstractions:** `MentorActionRequest` and `MentorActionDecision` say who provides the tool, with `Provenance`
(`MentorActionProvenance`: `Application`, `McpServer`, `Library`) and `ProvenanceName`, the MCP server's `Name`. A
policy can be stricter with the tools of an MCP server the application consumes. `Unknown`, the default of a
request built by hand, is never what MentorAgent sends: treat it as not trusted. New rule in ACTION-RULES.md:
`policy.provenance`.
### Changed
- **The widget meets WCAG 2.1 A and AA in what we tested**: axe-core finds no violation in any state and theme, the
keyboard and the focus are checked against EN 301 549, and it was used with Narrator on Windows; `ACCESSIBILITY.md`
says what was tested and what was not (**Novior.MentorAgent.Abstractions**):
- the panel is nearly opaque by default, `--bm-bg-panel: rgba(10,14,26,.96)`, so that the contrast of its text no
longer depends on the page behind it; it was glass at 55%, which that variable brings back, the contrast then
being the page's to keep. `MentorTheme.Dark` is at 96% too;
- `--bm-text-muted` is lighter (`#7d8bb3`; `#5b6b82` in `Minimal`), and the primary button white on the darker accent,
4.5:1 or more on every surface. `Minimal` sets a darker `--bm-accent-bright` (`#1d4ed8`) and the new
`--bm-status-online` (`#047857`): its status, links and connecting pills were pale blue and green on white;
- the conversation is a log a screen reader announces (`role="log"`, `aria-live`), busy while a reply streams so
that it is read once whole, and the keyboard reaches it;
- Esc closes the tour, the image URL's field or a detail first, then the panel, and never answers a confirmation:
the banner is there again when the panel opens; opened by the user, the focus is in the field, and closed, back
on the button;
- the launcher says whether the panel is open (`aria-expanded`); a confirmation is an alert dialog that takes the
focus itself, never on its Confirm button, whose name says the action, also when the panel opens again with it
waiting; after a reply, or a confirmation answered, the focus is back in the field; the tour takes the focus when
it opens; the message field has a name of its own, not only a placeholder; the image button is reached with the
keyboard; the widget says its language (`lang`), also on a page in another;
- a visitor who asks for less motion (`prefers-reduced-motion`) gets none.
- **Behavior change — Novior.MentorAgent.Declarative:** a declarative agent whose file lists a tool the Agent
Framework's factory did not make is no longer loaded without it (BUG-244). Up to 1.4.0 an entry of `tools` without
`kind`, in a list at its key's indentation, was dropped without a word and the agent started without the tool; from
1.5.0 that agent is not loaded, `invalid-definition`, and the reason names the entry, its number and its name, and
says it has no `kind`. What to do: write `kind: function` in every entry of `tools`.
- **Behavior change — Novior.MentorAgent:** with `EnableObservability`, the model calls of the agents under the
coordinator — the router of the handoff, the specialists, the team members, the agents of an `IMentorAgentSource` —
have their own spans, as the coordinator's do. A delegated turn or a team emits more spans than before, and the
GenAI token metrics (`gen_ai.client.token.usage`) now count those calls, which they missed: a threshold or a chart
on them sees a jump. Each call is counted once, and the dashboard's totals do not change. The span of each call
carries `gen_ai.agent.name`, `mentoragent.agent.kind` and `mentoragent.model.purpose`, never the user.
- **Behavior change — Novior.MentorAgent:** with `EnableObservability`, MentorAgent's own calls around a reply — the
checks on `ClassifierChatClient`, the routing classifier, the warm-up — have their spans too, each with its
`mentoragent.model.purpose`, so a turn emits more spans than before. A client the host already traces (one with
`UseOpenTelemetry()` in its chain, as the README told hosts to do) is not traced again: its span stays the host's,
one for each call, and nothing needs to change on the host's side.
- **Behavior change — Novior.MentorAgent:** with `WarmUpChatModel`, the warm-up request is counted on the dashboard
under its model, in no session: one request per client more on each start, which the provider bills.
- The family moves onto the Microsoft Agent Framework 1.28.0 line (`Microsoft.Agents.AI` and
`Microsoft.Agents.AI.Workflows` 1.28.0). **Novior.MentorAgent.Declarative:** `Microsoft.Agents.AI.Declarative` moves
to 1.28.0-rc1, on the same line. The breaking changes of Agent Framework 1.28 are in parts MentorAgent does not
use: its own A2A hosting and `A2AAgent` (MentorAgent uses the A2A SDK directly), the HTTP and MCP handlers and the
Foundry provider of its declarative workflows, CodeAct and GitHub Copilot. One is visible to a host that collects
Agent Framework's telemetry: its workflow spans are renamed.
- The family moves onto Microsoft.Extensions.AI 11.0.0 (`Novior.MentorAgent.Abstractions` and `Novior.MentorAgent`).
It declares no breaking change to the AI API, but it requires the 11.0.0 packages of
`Microsoft.Extensions.DependencyInjection.Abstractions`, `Microsoft.Extensions.Logging.Abstractions`,
`Microsoft.Extensions.Caching.Abstractions`, `Microsoft.Extensions.Primitives`, `System.Diagnostics.DiagnosticSource`
and `System.Numerics.Tensors`, so a .NET 10 application that uses MentorAgent now gets those at 11.0.0, above the
ones of the shared framework. Agent Framework 1.28, built on Microsoft.Extensions.AI 10.11, runs on 11.0.0.
`Microsoft.Extensions.AI.OpenAI` 11.0.0 requires `OpenAI` 2.14.0 or later.
The README's hold for Azure OpenAI with the Responses API (`Microsoft.Extensions.AI.OpenAI` `[10.6.0]`, which keeps
`OpenAI` at 2.10) still works on 11.0.0: verified with turns on the Responses API, with and without a tool.
- The A2A SDK moves to 1.0.0-preview4: `A2A` in Novior.MentorAgent and `A2A.AspNetCore` in
**Novior.MentorAgent.Server**. MentorAgent's own API does not change, and its A2A agent and client behave as before.
- **Breaking — Novior.MentorAgent, .Server:** an application that implements the A2A SDK's `IA2ARequestHandler`
itself, or calls the handler's methods of `A2AServer` directly, no longer compiles: with this version it gets
A2A 1.0.0-preview4, where each of the eleven operations takes an `A2ARequestContext?` before the cancellation
token. Add the argument, and hand it on to an inner handler as it came (null when the request negotiated no
extension). `IAgentHandler` and `IA2AClient` do not change.
### Fixed
- **BUG-265 (S3, present from 1.3.0):** over A2A, a turn that got the second request of `CheckAnnouncedActions`
returned its two replies joined in one text. The caller now gets the second reply alone, or the first when the second
fails or writes nothing (**Novior.MentorAgent**).
- **BUG-263 (S3, present from 1.0.0):** in the onboarding tour, a screen reader said nothing of the step Next or Back
moved to, as the focus stays on the button. The tour now announces the new step, its number, title and text; back
to the first step, the focus goes to Next (**Novior.MentorAgent.Abstractions**).
- **BUG-262 (S3, present from 1.0.0):** Tab could leave the onboarding tour, a modal dialog, for controls of the panel
a screen reader no longer showed. While the tour is open the rest of the panel is now inert, and Tab and Shift+Tab
go round the tour's buttons (**Novior.MentorAgent.Abstractions**).
- **BUG-261 (S3, present from 1.0.0):** on a page rendered without a prerender, the widget's voice output and its
`PrimaryColor` could stay off for the whole visit: the widget asked its script for them before the browser had run
it, and said nothing. The widget now waits for its script, for 10 seconds at most, and then logs a Warning that says
what to check (**Novior.MentorAgent.Abstractions**).
- **BUG-260 (S3, present from 1.0.0):** with `EnableVoiceOutput`, the widget's voice started on at every visit, also
for a visitor who had turned it off: someone with a screen reader, which reads the reply too, heard both at once
and had to turn it off each time. The visitor's choice is now remembered in their browser; with none, the voice
starts on as before (**Novior.MentorAgent.Abstractions**).
- **BUG-257 (S3, present from 1.0.0):** a screen reader read the widget's decorative images and icons: the
assistant's avatar, named beside the name written on the launcher, in the header, in the welcome and before every
reply; the welcome suggestions' emoji; icons not hidden from it. The avatars now have an empty `alt`, every icon is
`aria-hidden`, a suggestion is named by its words and sends them without its icon, and each message in the
conversation starts with who speaks, in the widget's language, for a screen reader only. The close buttons of the
MCP and A2A details are named in the widget's language; they said "Chiudi" in every one
(**Novior.MentorAgent.Abstractions**).
- **BUG-254 (S4, present from 1.0.0):** a request to `/mentor/approve`, `/mentor/cancel` or `/mentor/session` that met
the close of its connection could answer 500 instead of 404; nothing ran. The request now keeps the connection's
scope for the work it does, and once the connection is closing the answer is a 404.
- **BUG-253 (S3, present from 1.0.0):** on a screen narrower than 480 px the widget's panel kept its place and its
height cap instead of taking the whole screen, as the rule of its position won. The panel now takes the whole screen
there, and the launcher is hidden while it is open.
- **The closed panel's controls could be reached with Tab and were read by a screen reader**, invisible (present from
1.0.0). The closed panel is now `inert`.
- **BUG-251 (S2, present from 1.0.0):** with `RequireActionForChangeRequests` on and semantic tool filtering, a request
for what one of the page's own actions does could be taken for a complete request for one of the application's
confirmation-gated actions, and the first call of the turn was then required to be that action: the user was asked
to confirm an action they had not asked for. The request classifier is now shown the page's actions with the actions
too, and a request for one of them is not forced; a complete request for one of the actions still is, page or not.
- **BUG-250 (S3, present from 1.2.0):** the A2A agent card listed an action an action policy turns off for every
caller: it was built once, at startup, without asking the policies. **Novior.MentorAgent.Abstractions:** a new stage,
`MentorActionStage.Card`: the card asks `IsAllowedAsync` with nobody and leaves out what a policy does not allow; a
policy answers no there only for an action off for every caller. The card is built again when it is older than 30
seconds, so a rule changed at run time reaches it. New rule in ACTION-RULES.md: `policy.card`.
- **BUG-248 (S3, present from 1.2.0):** a call an action policy did not allow was refused with the words of a refusal of
the user's own ("you are not allowed to use this action"), where the application has a rule. It now says that a rule
of the application does not offer the action here, in the application's language; a `Stop` keeps its reason.
- **BUG-249 (S4, present from 1.2.0):** on the MCP server, the refusal of a call a policy wanted confirmed, which nobody
can confirm there, was in English. It now follows the application's language, as the other refusals of a policy.
- **BUG-247 (S2, present from 1.0.0):** with `RequireLookupForRecordQuestions` on, a request for what one of the
page's own actions does (a UI action or a recipe) could be taken for a question about the records, and the first
call of the turn was then required to be one of the application's reads, which the page's actions cannot satisfy:
the reply missed what was asked. The request classifier is now shown the page's actions offered on the turn, and a
request for one of them is not forced; a question about a value the records hold still is, page or not. Without page
actions nothing changes.
- **BUG-238 (S3, present from 1.3.0):** `CheckAnnouncedActions` did nothing with `UseServiceManagedHistory`, which the
Responses client requires: a reply that announced an action, or reported one as done, when no tool ran was not
checked. The second request is now sent from the response the turn started from, with the user's message again and
the instruction in its instructions, so nothing of the check is stored; the conversation goes on from its answer,
and the first reply stays on the service, on a branch nobody follows. Only a turn of one request is checked there.
The Warning at startup now says the check is not made only with an `IMentorSessionManager` of the application.
- **BUG-245 (S3, present from 1.3.0):** with routing on, the second request of the announced-action check was routed
again, on MentorAgent's instruction instead of the user's message, and could go to the other model in the middle of
the turn. It is now served by the turn's model.
- **BUG-244 (S3, present from 1.0.0):** a declarative agent whose `tools` list, at its key's indentation, had an entry
without `kind` loaded without that tool, and nothing said so; an entry with `kind` after `name` was refused. The
definition is now given to the Agent Framework's factory again rewritten, `kind` first, and an agent the factory
still makes with fewer tools than its file lists is not loaded: `invalid-definition`, with the reason.
- **BUG-243 (S3, present from 1.0.0):** a declarative agent (`Novior.MentorAgent.Declarative`) written in valid YAML the
Agent Framework's reader refuses was not loaded, `invalid-definition`, with an error naming the end of the file: a
list at its key's indentation (the form YamlDotNet writes by default), an explicit end of the document (`...`), or a
folded scalar (`>`). A definition the reader refuses is now given to it again rewritten, lists indented, no end
marker, folded scalars literal with the same value; one it takes is never rewritten, and the error of one that fails
both ways is the one of the text as written.
- **BUG-242 (S4, present from 1.0.0):** the parameter hint a typed UI action generates told the model to send a
`DateOnly`, a `TimeOnly`, a `TimeSpan` or a `Uri` as an object of its properties, which the handler could not read,
and named `uint`, `ulong`, `ushort`, `sbyte` and `char` by their .NET names. Each is now described by the text or the
number JSON writes it as: `string (ISO 8601 date)`, `string (time, HH:mm:ss)`, `string (duration, d.hh:mm:ss)`,
`string (URI)`, `integer`, `string (one character)`.
- **BUG-241 (S3, present from 1.4.0):** a UI action of the page whose handler threw, or `invoke_ui_action` on Path B,
reached the `IMentorActionObserver`s as `Executed`, while the model was told it had failed. It is now `Failed`, with
the type of the handler's exception, and the model gets the message of `OnException` when the application set it,
as for any other action.
With `OnException` set, the model now gets the application's message for a UI action too, where it got the
exception's.
- **BUG-240 (S3, present from 1.0.0):** with `RoutingStrategy` `Classifier` or `Cascade`, the routing classifier's
call — one a turn: a turn streams, so `Cascade` asks the same question before the answer — was billed by the
provider and counted nowhere: not on the dashboard, not in `MentorTokenUsage`, not on the session's counter, while
the README said so. It is now counted, under the classifier's model, once, and with `EnableObservability` it has its
span.
- **BUG-235:** a call of the model of a specialist, a team member or an agent of an `IMentorAgentSource` to an action
of the application its agent does not hold (one an `IMentorActionGovernor` or `EnabledByDefault = false` left out,
or another agent's) ran nothing, but had no decision, so an audit of the actions did not see it. It now has one,
`Denied`, `not-offered`, with the agent's `AgentKind` and `AgentName`, as the coordinator's has. Nothing more starts.
New rule in ACTION-RULES.md: `agent.not-offered-call`.
- The scan of the pages (Novior.MentorAgent.Scanner, new in this release) read the label of a field from a `<label>`
that holds the field with all its text: a select's options, or what a text area held, went into the label in the
manifest. A label is now read without the fields it holds, in the scan and in the observation.
### Known issues
- **Novior.MentorAgent:** BUG-264 (S3, present from 1.4.0). With `RequireLookupForRecordQuestions`, when
`CheckAnnouncedActions` takes the reply to a record question for a reported action, its second request is required
again to call a read, with only the reads among its tools; the README says that request keeps the tool mode it had.
The reply the user gets is right, as the second request reads again. It is fixed in a later version, together with
the check's judgement of a reply that only states what a read returned.
The full history is in CHANGELOG.md, inside this package.