/shiny:shiny-aiconversationfrom shiny
Generate code for Shiny.AiConversation v3 - session-based AI conversations for .NET over Microsoft.Extensions.AI with persisted, resumable sessions (IAiSessionManager / IAiSession / IAiTurn), streaming replies, the built-in ask_user tool for typed questions and multiple-choice answers, interruption and supersession, usage and context-window pressure tracking, rolling context compaction, silent assistant memory, conversation search, session titles and long-term memory, session interceptors for tools and prompts, pluggable session/memory stores (in-memory or SQLite via Shiny.AiConversation.Stores.SqliteDocDb), and voice conversations via Shiny.AiConversation.Voice (wake word, push-to-talk, follow-up, quiet-word/barge-in interruption, sentence-streamed text-to-speech over Shiny.Speech, acknowledgement modes, sounds, voice selection tools), the MAUI chat UI via Shiny.AiConversation.Maui (AiChatView bound to a session with streaming bubbles, choice chips, push-to-talk and an AiMemoryView), image attachments with retention, and the use_camera tool via Shiny.AiConversation.Maui.Camera, and AG-UI via Shiny.AiConversation.AgUi (a session as an AG-UI event stream for the Shiny AgentView with ask_user questions as interrupts, the render_ui tool for A2UI surfaces, and a remote AG-UI agent as the chat client)
Trending skills
7-day visitors to each skill page
Ships in shiny. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert in Shiny.AiConversation v3, a session-based library for talking to an AI through
Microsoft.Extensions.AI. A session is a persisted, never-ending conversation: you start or resume it,
send input, and consume streamed turn events. The core package has no audio dependency; voice lives in
Shiny.AiConversation.Voice.
GitHub: https://github.com/shinyorg/speech (under src/aiconversation/)
NuGet: Shiny.AiConversation
Namespace: Shiny.AiConversation (registration extensions live in Shiny)
Infrastructure Namespace: Shiny.AiConversation.Infrastructure (implementations)
The library provides:
Start, Get, GetLatest, Query, Delete. Every Get reads the store and returns a new instance that the caller owns and disposes. See sessions.mdSend(AiInput) returns an IAiTurn; GetEvents() is a hot event stream whose first item is a Snapshot; exposes State, PendingQuestions, Usage, Context, ActiveTurn, GetMessages (history paging), SetTitle, UpdateSettings. Sessions never end; removal is IAiSessionManager.DeleteEvents (replayable), Completion (never faults), Interrupt(spokenText)PendingQuestions and the AwaitingUser state. See questions.mdOnSessionLoaded) or per turn (OnBeforeTurn) and reacts after a turn (OnAfterTurn). Tools are never persisted. See interceptors.mdInMemoryAiSessionStore is the default; opts.SetSqliteDocDbStores(path) (NuGet Shiny.AiConversation.Stores.SqliteDocDb) persists to SQLite. See session-store.mdsession.Compact() folds old messages into a rolling summary; runs automatically at 95% of the context window. See compaction.mdmemory tool (on by default) plus IAiSessionManager.Memory (IAiMemoryService) so the user can see/edit/delete notes. See memory.mdAddConversationSearch(), AddSessionTitles(), AddLongTermMemory(), AddTool(tool, flags, profiles). See built-in-tools.mdShiny.AiConversation.Voice): attaches to one session; wake word, push-to-talk, follow-up, interruption, sentence-streamed TTS over Shiny.Speech. See voice.mdShiny.AiConversation.Maui): a ChatView bound to one IAiSession (streaming bubbles, history paging, choice chips, push-to-talk, context warnings) plus AiMemoryView. See maui.mdAiInput.WithImage(...), ImagePart, IAiAttachmentStore (UseFileAttachments(dir)), ImageRetention, TurnContext.QueueFollowUp. See images.mdShiny.AiConversation.Maui.Camera): AddAiConversationCamera(); the assistant asks to take a photo or scan. See camera.mdIChatClient; optional ContextWindow. See chat-client-provider.mdShiny.AiConversation.AgUi): session.RunAgUiAsync(input, ct) runs a session as an AG-UI event stream, so AgentView takes it with AgentSession.Create(session.SessionId, session.RunAgUiAsync); opts.AddAgUiRenderTool() (A2UI surfaces), opts.AddAgUiChatClient(uri) (remote AG-UI agent). See ag-ui.mdProvider packages:
opts.AddStaticOpenAIChatClient(apiToken, endpointUri, modelName)opts.AddStaticGithubCopilotChatClient(personalAccessToken, modelName)opts.AddGithubCopilotChatClient() (device-code OAuth, SecureStorage)Available now (v3 phases 1–4): sessions, the SQLite store (Shiny.AiConversation.Stores.SqliteDocDb),
compaction, assistant memory, conversation search, titles, long-term memory, voice (Shiny.AiConversation.Voice),
the MAUI chat UI (Shiny.AiConversation.Maui: AiChatView, AiMemoryView, push-to-talk action), image
attachments and the camera tool (Shiny.AiConversation.Maui.Camera). A realtime (speech-to-speech) backend comes later.
The old Shiny.AiConversation.MessageStores.SqliteDocDb package is replaced by Shiny.AiConversation.Stores.SqliteDocDb.
The v2 API (IAiConversationService, TalkTo, ListenAndTalk, IMessageStore, IContextProvider, AiTurn
JSON envelope, AiStructuredOutputMode, AiChatView.AiService) has been removed - never generate code against it.
Microsoft.Extensions.AI - IChatClient, AITool, AIFunctionFactory, ChatMessageInvoke this skill when the user wants to:
using Shiny;
builder.Services.AddChatClient(new OpenAIClient("key").GetChatClient("gpt-4o").AsIChatClient());
builder.Services.AddShinyAiConversation(opts =>
{
opts.AddInterceptor<AssistantInterceptor>();
opts.AddTool(AIFunctionFactory.Create(GetWeather, "get_weather"));
opts.AddTool(AIFunctionFactory.Create(FindRecipe, "find_recipe"), AiToolFlags.None, "cooking");
});
See registration.md for every option and what is registered automatically.
public class ChatViewModel(IAiSessionManager manager) : IAsyncDisposable
{
IAiSession? session;
public async Task Open()
=> this.session = await manager.GetLatest() ?? await manager.Start();
public async Task Send(string text)
{
var turn = this.session!.Send(AiInput.Text(text));
await foreach (var e in turn.Events)
{
if (e is TextDelta delta)
this.AppendToReply(delta.Text);
}
var result = await turn.Completion;
if (result.Outcome == AiTurnOutcome.Failed)
this.ShowError(result.Error!);
}
public async ValueTask DisposeAsync()
{
if (this.session != null)
await this.session.DisposeAsync();
}
}
Run one await foreach over GetEvents on a background task and marshal to the UI thread. The first
event is always a Snapshot, so you never read properties and subscribe separately.
_ = Task.Run(async () =>
{
await foreach (var e in session.GetEvents(cancelToken))
{
MainThread.BeginInvokeOnMainThread(() =>
{
switch (e)
{
case Snapshot s: this.Apply(s.State, s.PendingQuestions); break;
case MessageAdded m: this.AddBubble(m.Message); break;
case MessageUpdated m: this.ReplaceBubble(m.Message); break;
case StateChanged s: this.IsBusy = s.State is AiSessionState.Thinking or AiSessionState.Responding; break;
case TurnEventOccurred { Event: TextDelta d }: this.AppendStreaming(d.Text); break;
case ContextPressureChanged c when c.Context.Pressure == ContextPressure.Warning:
this.ShowBanner("This conversation is getting long"); break;
}
});
}
});
foreach (var q in session.PendingQuestions.Where(x => x.HasChoices))
ShowChoices(q.Text, q.Choices!, choice => session.Send(AiInput.Answer(q, choice.Id)));
See questions.md.
Get / GetLatest return a new instance every call; the caller disposes it (await using). Disposing releases the instance, never the stored session.SessionConflictException (reported as AiTurnOutcome.Failed).Send supersedes. A session has at most one active turn; sending while a turn runs cancels it with AiTurnOutcome.Superseded. Don't queue sends yourself.Completion never faults. Failures come back as AiTurnOutcome.Failed with Result.Error; cancellation and interruption are Interrupted / Superseded, not exceptions. Don't wrap await turn.Completion in try/catch for model errors.opts.AddTool or an ISessionInterceptor (which runs on Start and every Get). There is no Start(tools) overload. Use AiSessionSettings.Profile to vary tools/prompts per session.ask_user tool handles it and a reply ending in ? is the fallback.Shiny.AiConversation.Voice (IVoiceConversation); never put speech/TTS calls in core code or interceptors.ChatMessage/ChatResponse objects. session.GetMessages(beforeSequence, count) pages newest-first by Sequence.session.Usage is cumulative billing; session.Context is how full the model's window is. Pressure is null unless a context window is known (AiSessionSettings.ContextWindow or IChatClientProvider.ContextWindow). The library reports; the app decides what to show.AiConversationJsonContext (source-generated), never reflection-based JsonSerializer calls.memory tool and a <memory_index> prompt. Turn it off with opts.ConfigureMemory(m => m with { Enabled = false }) or per profile with DisabledProfiles = ["private"]. Tell users the assistant can save notes, and give them manager.Memory to view/edit/clear them.ToolCallPart/ToolResultPart with Audience.ModelOnly, never spoken or shown; surface them only through MemoryChanged (e.g. a "Remembered" chip).Compact() waits for the active turn; auto-compaction runs after a turn completes (in the background) and before a turn that's over the threshold. Never compact from inside an interceptor turn hook.MessageRole.Summary messages are UI markers. The current summary is sent to the model from the session header; don't feed summary messages back yourself. Compacted messages stay in the store (Compacted = true) for history and search.SetDocDbStores(key) needs MapAiConversation() on that document store's options (version mapping, full-text index, JSON metadata). SetSqliteDocDbStores(path) does it for you. The key is a keyed IDocumentStore registered with Shiny.DocumentDb 14's services.AddDocumentStore(name, ...); there is no IDocumentStoreProvider or Shiny.DocumentDb.Extensions.DependencyInjection package any more.AddShinyAiConversationVoice() registers no speech engines. Register Shiny.Speech STT/TTS providers yourself (prefer a cloud STT on Android). Add IAudioPlayer for sounds and gapless cloud-voice playback.Attach throws if one is attached. Give the voice conversation the same IAiSession instance the chat UI uses so they never run concurrent turns.WakeWord = null, push-to-talk only). An always-open cloud recognizer streams and bills all room audio; register an IWakeWordDetector or prefer push-to-talk.PendingQuestions. Only the voice loop returns to the wake word / off; the session still awaits the user, so chat choice chips keep working.SpokenText. Don't call turn.Interrupt yourself for voice turns; use PushToTalk / StopSpeaking.Listening / FollowUp / Thinking, so speech after that point is never lost; push-to-talk taps are never dropped. Don't add your own delays before raising PTT.AiChatView owns a session only when Session isn't bound. Bind the app's shared session (the ConversationHost pattern in maui.md) so chat and voice use one instance; an unbound view resumes/starts its own and disposes it on unload.IVoiceConversation to the chat's session (detaching any other). Needs AddShinyAiConversationVoice() and registered Shiny.Speech providers.UseShinyCamera() on the MAUI app builder, plus NSCameraUsageDescription (iOS) / android.permission.CAMERA. Shiny.AiConversation.Maui.Camera requires Microsoft.Maui.Controls >= 10.0.100.ImagePart holds an AttachmentRef). Use UseFileAttachments(dir) on devices; the default store is in-memory. ImageRetention.DontStore images exist for one turn only.TurnContext.QueueFollowUp continues the same turn (a second model round, same IAiTurn events); it's how the camera delivers photos to providers that can't take images in tool results. Don't Send from inside a tool - that supersedes the running turn.UIApplicationSceneManifest in Info.plist + a [Register("SceneDelegate")] class SceneDelegate : MauiUISceneDelegate), or current iOS terminates them at launch. Clean-build after editing Info.plist.ag-ui.md (opens in a new tab)built-in-tools.md (opens in a new tab)camera.md (opens in a new tab)chat-client-provider.md (opens in a new tab)compaction.md (opens in a new tab)images.md (opens in a new tab)interceptors.md (opens in a new tab)maui.md (opens in a new tab)memory.md (opens in a new tab)questions.md (opens in a new tab)registration.md (opens in a new tab)session-store.md (opens in a new tab)sessions.md (opens in a new tab)voice.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub shinyorg/skills --plugin shiny57 skills in this plugin
/localizegenGenerate strongly-typed localization classes from .resx resource files using Shiny.Extensions.Localization.Generator for .NET applications/shiny-accessorysetupGenerate code using Shiny.BluetoothLE.AccessorySetup - the system accessory pairing sheet for BLE devices (AccessorySetupKit on iOS 18+, CompanionDeviceManager on Android) with no MFi, no location prompt and no general Bluetooth prompt on iOS; picked accessories open as Shiny.BluetoothLE peripherals, and Android adds background presence (device appeared / disappeared) events/shiny-actorsGenerate code using Shiny.Actors — Orleans-style virtual actors without the ceremony, AOT/trim-clean, running anywhere .NET runs including .NET MAUI and Blazor WebAssembly. Covers actor interfaces and source-generated proxies, the ShinyActorBuilder (AddShinyActors), persistent state with ETags, named states and auto-save, event-sourced JournaledActor with snapshots, state and event migrations, typed streams (durable, implicit consumers), timers and persistent reminders (background jobs via Shiny.Jobs, on-time OS notifications via Shiny.Notifications), concurrency control ([Reentrant], [AlwaysInterleave], [ReadOnly], [StatelessWorker]), call filters and request context, OpenTelemetry traces and metrics, remoting over HTTP (Shiny.Net.HttpServer server, RemoteActorSystem client), mDNS discovery of actor servers, Shiny.DocumentDb storage (SQLite, PostgreSQL, IndexedDB...), and the ActorTestHost testing kit./shiny-agesignalsGenerate code using Shiny.AgeSignals to read the user's age range as the app store shares it - Apple Declared Age Range (iOS / macOS 26+) and Google Play Age Signals (Android) - for app store accountability laws (Texas SB 2420, Utah, Louisiana, California AB 1043) and age-gated features/shiny-appdevicebridgeGenerate code using Shiny.AppDeviceBridge, device bridges on your app's own Shiny.Net.HttpServer that also host a web app (Blazor WebAssembly, React, Vue, any static build) inside a .NET MAUI app on Android, iOS, Mac Catalyst, Windows and the maui-labs macOS and Linux heads — served from a loopback HTTP server, updated over the air from a signed release server, GitHub releases or a provider of your own, and given device access through bridges with typed C# and TypeScript clients/shiny-appfunctionsGuide for exposing a .NET MAUI / .NET app's functions to Siri, Spotlight, Shortcuts and Apple Intelligence (App Intents) and to Gemini and other agents (Android AppFunctions) from one C# declaration using Shiny.AppFunctions - [AppFunction] records, typed handlers, [AppEntity] entities with queries, [AppShortcut] Siri phrases and delegatesOther plugins' skills for the same job