MentorAgent Docs
Menu

Questa pagina non è ancora tradotta in italiano: qui la trovi in inglese.

ReferencePackage: Novior.MentorAgent.Abstractions

IMentorStateService interface

The IMentorStateService interface of Novior.MentorAgent.Abstractions.Interfaces: Thread-safe event bus between the AI layer (Agent Framework) and the UI…

On this page

Thread-safe event bus between the AI layer (Agent Framework) and the UI layer (Blazor). Agent Framework executes on background threads; Blazor requires StateHasChanged() to be called on the circuit's UI thread. MentorAgentUIMiddleware intercepts AI updates and publishes them through this service. Razor components subscribe and call InvokeAsync(StateHasChanged) to update the UI in a thread-safe manner.

Namespace: Novior.MentorAgent.Abstractions.Interfaces. Package: Novior.MentorAgent.Abstractions.

public interface IMentorStateService

Terminal
dotnet add package Novior.MentorAgent.Abstractions

void Cancel(Guid actionId)

Task ConfirmAsync(Guid actionId)

void NotifyActionCompleted(string toolName)

void NotifyActionExecuting(string toolName, string? displayName = null)

void NotifyActionFailed(string toolName, string error)

void NotifyBusyChanged(bool isBusy)

void NotifyCardsReady(IReadOnlyList<MentorCard> cards)

void NotifyConfirmationRequired(ConfirmationRequest request)

void NotifyError(string message)

void NotifyGeneratedImages(IReadOnlyList<string> imageSources)

void NotifyHostedToolsDeclared(MentorHostedTools tools)

void NotifyMcpServerStatusChanged(string serverName, bool connected)

void NotifyNavigationRequested(string url)

void NotifyRagSourcesReady(IReadOnlyList<MentorRagResult> sources)

void NotifyStreamingChunk(string chunk)

void NotifyStreamingCompleted()

void NotifyTeamMemberSpeaking(string teamName, string memberName)

void NotifyUIActionCompleted(string actionName)

void NotifyUIActionExecuting(string actionName)

event Action<string>? OnActionCompleted

Event: a tool call has completed successfully.

event Action<string>? OnActionExecuting

Event: a tool call has started. Payload: the text shown to the user for it — the action's description, else a readable form of its name, or the routing, team or hosted-tool text. The tool's technical name is in IMentorStateService.OnActionStarted.

event Action<string>? OnActionFailed

Event: a tool call has failed. Payload: error message.

event Action<MentorActionStarted>? OnActionStarted

Event: a tool call has started, with the tool's technical name next to the text shown. Raised with IMentorStateService.OnActionExecuting, where the turn runs: in the Blazor Server circuit or the MAUI app, and on the server for the hub, SSE and A2A. The WebAssembly client's implementation does not raise it, since the hub sends it only the text shown: record actions on the server.

The interface implements it as an event nobody raises, so an implementation written before it still compiles and runs.

event Action<ConfirmationRequest, bool>? OnApprovalResponse

Event: the user's answer to a confirmation dialog (approved or denied) reached the turn that was waiting for it. Not raised for an answer that reaches nothing — given after Stop, after the connection or circuit closed, or a second time — so it can be logged as a decision that was acted on.

event Action<bool>? OnBusyChanged

Event: the AI is busy (true) or idle (false).

event Action<IReadOnlyList<MentorCard>>? OnCardsReady

Event: a tool returned one or more MentorCards to render with the reply (roadmap #14, generative UI L2). Purely additive — a client that ignores it still gets the assistant's text, which describes the same data.

event Action<ConfirmationRequest>? OnConfirmationRequired

Event: confirmation required for a destructive action.

event Action<string>? OnError

Event: critical error to display in the widget.

event Action<IReadOnlyList<string>>? OnGeneratedImages

Event: a provider-hosted image generation tool produced one or more images for the current response. Payload: image sources ready for an <img src> — a data: URI when the provider returned bytes, a remote URL when it returned a link. Fired before IMentorStateService.OnStreamingCompleted, so the widget can attach them to the finished message.

event Action<MentorHostedTools>? OnHostedToolsDeclared

Event: the server declared which provider-hosted tools are actually active (roadmap #15).

Only a remote transport raises this. Hosted tools are a server-side capability, so a detached client (WASM, React, MAUI) cannot know them from its own configuration — mirroring the list by hand means the badge keeps claiming tools the server dropped, or missing ones it gained. The widget prefers this value over its local options as soon as it arrives.

event Action<string, bool>? OnMcpServerStatusChanged

Event: an MCP server connection changed status. Payload: server name, connected (true) or disconnected (false).

event Action<string>? OnNavigationRequested

Event: automatic navigation after tool execution.

event Action<IReadOnlyList<MentorRagResult>>? OnRagSourcesReady

Event: RAG sources available for the current response. Fired just before IMentorStateService.OnStreamingCompleted.

event Action<string>? OnStreamingChunk

Event: new streaming text chunk from the AI.

event Action? OnStreamingCompleted

Event: streaming completed.

event Action<string, string>? OnTeamMemberSpeaking

Event: a team member has started speaking during a GroupChat discussion. Payload: team name, member role name.

event Action<string>? OnUIActionCompleted

Event: UI action completed.

event Action<string>? OnUIActionExecuting

Event: UI action is executing.