diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props index 0270f0e38b..29eb7c8e42 100644 --- a/dotnet/Directory.Packages.props +++ b/dotnet/Directory.Packages.props @@ -106,6 +106,7 @@ + diff --git a/dotnet/agent-framework-dotnet.slnx b/dotnet/agent-framework-dotnet.slnx index 24b596509e..39c65dfc44 100644 --- a/dotnet/agent-framework-dotnet.slnx +++ b/dotnet/agent-framework-dotnet.slnx @@ -114,6 +114,12 @@ + + + + + + diff --git a/dotnet/samples/02-agents/AGUI/README.md b/dotnet/samples/02-agents/AGUI/README.md index 77a58b3198..8386ed587d 100644 --- a/dotnet/samples/02-agents/AGUI/README.md +++ b/dotnet/samples/02-agents/AGUI/README.md @@ -199,6 +199,49 @@ cd Step05_StateManagement/Client dotnet run ``` +### Step06_McpApps + +Demonstrates AG-UI integration with MCP Apps: HTML UI resources attached to MCP tools and delivered to capable AG-UI clients through the event stream. + +If you are new to MCP Apps themselves, start with the official overview: [MCP Apps Overview](https://modelcontextprotocol.io/extensions/apps/overview). + +This sample is more involved than the earlier getting-started samples because it includes three moving parts: + +- An MCP server that exposes a `get-time` tool and a bundled HTML app resource +- An AG-UI server that attaches those MCP tools to an `AIAgent` and proxies MCP `resources/read` and `tools/call` requests +- A console client that shows the AG-UI protocol flow, including the `ACTIVITY_SNAPSHOT` event that carries the `ui://` resource URI + +The browser-side MCP App, proxied request flow, event ordering, and conformance coverage are documented in the dedicated sample guide: + +- [Step06_McpApps/README.md](Step06_McpApps/README.md) + +Use that README when you want the full architecture, request and response examples, or the exact MCP App protocol details. + +At a high level, `Step06_McpApps` demonstrates: + +- Binding a tool to an MCP App resource via MCP metadata +- Returning `ACTIVITY_SNAPSHOT` events so a browser host can load the HTML app in-place +- Short-circuiting proxied MCP `resources/read` and `tools/call` requests on the same AG-UI endpoint instead of invoking the agent again +- Verifying the integration with sample-level conformance tests + +**Run the sample:** + +```bash +# Terminal 1 +cd Step06_McpApps/McpServer +dotnet run + +# Terminal 2 +cd Step06_McpApps/Server +dotnet run + +# Terminal 3 +cd Step06_McpApps/Client +dotnet run +``` + +Try asking: "What time is it?" + ## How AG-UI Works ### Server-Side @@ -297,6 +340,7 @@ For the most up-to-date AG-UI features, see the [Python samples](../../../../pyt ### Related Documentation - [AG-UI Overview](https://learn.microsoft.com/agent-framework/integrations/ag-ui/) - Complete AG-UI documentation +- [MCP Apps Overview](https://modelcontextprotocol.io/extensions/apps/overview) - Conceptual overview of MCP Apps, rendering model, and host responsibilities - [Getting Started Tutorial](https://learn.microsoft.com/agent-framework/integrations/ag-ui/getting-started) - Step-by-step walkthrough - [Backend Tool Rendering](https://learn.microsoft.com/agent-framework/integrations/ag-ui/backend-tool-rendering) - Function tools tutorial - [Human-in-the-Loop](https://learn.microsoft.com/agent-framework/integrations/ag-ui/human-in-the-loop) - Approval workflows tutorial diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Client/Client.csproj b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Client/Client.csproj new file mode 100644 index 0000000000..a76a2b37ef --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Client/Client.csproj @@ -0,0 +1,15 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + + diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Client/Program.cs b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Client/Program.cs new file mode 100644 index 0000000000..3d735c977c --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Client/Program.cs @@ -0,0 +1,342 @@ +// Copyright (c) Microsoft. All rights reserved. + +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.Agents.AI; +using Microsoft.Agents.AI.AGUI; +using Microsoft.Extensions.AI; + +string serverUrl = Environment.GetEnvironmentVariable("AGUI_SERVER_URL") ?? "http://localhost:5253"; + +Console.WriteLine($"Connecting to AG-UI server at: {serverUrl}\n"); + +// Create the AG-UI client agent +using HttpClient httpClient = new() +{ + Timeout = TimeSpan.FromSeconds(60) +}; + +AGUIChatClient chatClient = new(httpClient, serverUrl); + +AIAgent agent = chatClient.AsAIAgent( + name: "agui-client", + description: "AG-UI Client Agent"); + +AgentSession session = await agent.CreateSessionAsync(); +List messages = +[ + new(ChatRole.System, "You are a helpful assistant.") +]; + +try +{ + while (true) + { + // Get user input + Console.Write("\nUser (:q or quit to exit): "); + string? message = Console.ReadLine(); + + if (string.IsNullOrWhiteSpace(message)) + { + Console.WriteLine("Request cannot be empty."); + continue; + } + + if (message is ":q" or "quit") + { + break; + } + + messages.Add(new ChatMessage(ChatRole.User, message)); + + // Stream the response + bool isFirstUpdate = true; + string? sessionId = null; + List responseUpdates = []; + + await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(messages, session)) + { + ChatResponseUpdate chatUpdate = update.AsChatResponseUpdate(); + + if (ShouldPersistResponseUpdate(chatUpdate)) + { + responseUpdates.Add(chatUpdate); + } + + // First update indicates run started + if (isFirstUpdate) + { + sessionId = chatUpdate.ConversationId; + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine($"\n[Run Started - Session: {chatUpdate.ConversationId}, Run: {chatUpdate.ResponseId}]"); + Console.ResetColor(); + isFirstUpdate = false; + } + + // Display streaming content + foreach (AIContent content in update.Contents) + { + if (content is TextContent textContent) + { + Console.ForegroundColor = ConsoleColor.Cyan; + Console.Write(textContent.Text); + Console.ResetColor(); + } + else if (content is DataContent dataContent && + chatUpdate.AdditionalProperties?.TryGetValue("is_activity_snapshot", out bool isSnapshot) is true && + isSnapshot) + { + await HandleActivitySnapshotAsync(httpClient, serverUrl, dataContent); + } + else if (content is ErrorContent errorContent) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"\n[Error: {errorContent.Message}]"); + Console.ResetColor(); + } + } + } + + AppendResponseMessages(messages, responseUpdates); + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine($"\n[Run Finished - Session: {sessionId}]"); + Console.ResetColor(); + } +} +catch (Exception ex) +{ + Console.WriteLine($"\nAn error occurred: {ex.Message}"); +} + +static async Task HandleActivitySnapshotAsync(HttpClient httpClient, string serverUrl, DataContent dataContent) +{ + Console.WriteLine(); + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("┌─────────────────────────────────────────────────────────┐"); + Console.WriteLine("│ ACTIVITY SNAPSHOT — MCP App detected │"); + Console.WriteLine("└─────────────────────────────────────────────────────────┘"); + Console.ResetColor(); + + // Parse the activity snapshot JSON content + JsonElement snapshot; + try + { + snapshot = JsonDocument.Parse(dataContent.Data.ToArray()).RootElement; + } + catch (JsonException ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"[Failed to parse activity snapshot: {ex.Message}]"); + Console.ResetColor(); + return; + } + + string resourceUri = snapshot.TryGetProperty("resourceUri", out var uriProp) ? uriProp.GetString() ?? "" : ""; + + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine($" Resource URI : {resourceUri}"); + + // Show tool result from the snapshot + if (snapshot.TryGetProperty("result", out var result)) + { + Console.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" Tool Result:"); + if (result.TryGetProperty("content", out var resultContent) && resultContent.ValueKind == JsonValueKind.Array) + { + foreach (JsonElement item in resultContent.EnumerateArray()) + { + string type = item.TryGetProperty("type", out var t) ? t.GetString() ?? "?" : "?"; + string text = item.TryGetProperty("text", out var txt) ? txt.GetString() ?? "" : item.GetRawText(); + Console.WriteLine($" [{type}] {text}"); + } + } + else + { + Console.WriteLine($" {result.GetRawText()}"); + } + } + + Console.ResetColor(); + + if (string.IsNullOrEmpty(resourceUri)) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(" [No resource URI — skipping fetch]"); + Console.ResetColor(); + return; + } + + // Fetch the MCP App resource via a proxied resources/read request + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine($"\n Fetching resource via proxied request: {resourceUri}"); + Console.ResetColor(); + + var proxiedBody = new + { + threadId = Guid.NewGuid().ToString(), + runId = Guid.NewGuid().ToString(), + messages = Array.Empty(), + tools = Array.Empty(), + context = Array.Empty(), + state = new { }, + forwardedProps = new + { + __proxiedMCPRequest = new + { + method = "resources/read", + @params = new { uri = resourceUri } + } + } + }; + + JsonElement? resourceResult = await SendProxiedRequestAsync(httpClient, serverUrl, proxiedBody); + + if (resourceResult is null) + { + return; + } + + Console.ForegroundColor = ConsoleColor.Magenta; + Console.WriteLine("┌─────────────────────────────────────────────────────────┐"); + Console.WriteLine("│ MCP App Resource Contents │"); + Console.WriteLine("└─────────────────────────────────────────────────────────┘"); + Console.ResetColor(); + + if (resourceResult.Value.TryGetProperty("contents", out var contents) && + contents.ValueKind == JsonValueKind.Array) + { + foreach (JsonElement item in contents.EnumerateArray()) + { + string uri = item.TryGetProperty("uri", out var uriEl) ? uriEl.GetString() ?? "" : ""; + string mimeType = item.TryGetProperty("mimeType", out var mimeEl) ? mimeEl.GetString() ?? "" : ""; + bool hasText = item.TryGetProperty("text", out var textEl); + bool hasBlob = item.TryGetProperty("blob", out var blobEl); + + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine($" URI : {uri}"); + Console.WriteLine($" MIME Type : {mimeType}"); + + if (hasText) + { + string text = textEl.GetString() ?? ""; + string preview = text.Length > 300 ? text[..300] + "…" : text; + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine($" Content ({text.Length} chars):"); + Console.WriteLine($" {preview.Replace("\n", "\n ")}"); + } + else if (hasBlob) + { + string blob = blobEl.GetString() ?? ""; + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine($" Blob (base64, {blob.Length} chars)"); + } + else + { + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine($" {item.GetRawText()}"); + } + + Console.ResetColor(); + } + } + else + { + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine($" {resourceResult.Value.GetRawText()}"); + Console.ResetColor(); + } +} + +static async Task SendProxiedRequestAsync(HttpClient httpClient, string serverUrl, object body) +{ + try + { + using HttpRequestMessage request = new(HttpMethod.Post, serverUrl) + { + Content = JsonContent.Create(body) + }; + request.Headers.Accept.ParseAdd("text/event-stream"); + + using HttpResponseMessage response = await httpClient.SendAsync( + request, HttpCompletionOption.ResponseHeadersRead); + response.EnsureSuccessStatusCode(); + + await using Stream stream = await response.Content.ReadAsStreamAsync(); + using StreamReader reader = new(stream); + + string? line; + while ((line = await reader.ReadLineAsync()) is not null) + { + if (!line.StartsWith("data: ", StringComparison.Ordinal)) + { + continue; + } + + string payload = line[6..].Trim(); + if (string.IsNullOrEmpty(payload) || payload == "[DONE]") + { + continue; + } + + try + { + using JsonDocument doc = JsonDocument.Parse(payload); + JsonElement evt = doc.RootElement.Clone(); + + string? eventType = evt.TryGetProperty("type", out var typeProp) + ? typeProp.GetString() + : null; + + if (eventType == "RUN_FINISHED" && + evt.TryGetProperty("result", out var result)) + { + return result.Clone(); + } + + // Stop on terminal events + if (eventType is "RUN_FINISHED" or "RUN_ERROR") + { + break; + } + } + catch (JsonException) { /* skip non-JSON lines */ } + } + } + catch (Exception ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($" [Proxied request failed: {ex.Message}]"); + Console.ResetColor(); + } + + return null; +} + +static void AppendResponseMessages(List messages, List responseUpdates) +{ + if (responseUpdates.Count == 0) + { + return; + } + + ChatResponse response = responseUpdates.ToChatResponse(); + if (response.Messages.Count == 0) + { + return; + } + + messages.AddRange(response.Messages); +} + +static bool ShouldPersistResponseUpdate(ChatResponseUpdate update) +{ + return !HasBooleanFlag(update, "is_activity_snapshot") && + !HasBooleanFlag(update, "is_state_snapshot") && + !HasBooleanFlag(update, "is_state_delta"); +} + +static bool HasBooleanFlag(ChatResponseUpdate update, string key) +{ + return update.AdditionalProperties?.TryGetValue(key, out bool enabled) is true && enabled; +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/McpServer.csproj b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/McpServer.csproj new file mode 100644 index 0000000000..8cdd9d3122 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/McpServer.csproj @@ -0,0 +1,14 @@ + + + + Exe + net10.0 + enable + enable + + + + + + + diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Program.cs b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Program.cs new file mode 100644 index 0000000000..22be897da8 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Program.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft. All rights reserved. + +using System.ComponentModel; +using ModelContextProtocol.Protocol; +using ModelContextProtocol.Server; +using Step06_McpApps.McpServer; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddMcpServer() + .WithHttpTransport(o => o.Stateless = true) + .WithTools() + .WithResources() + ; + +var app = builder.Build(); + +app.MapGet("/", () => "Hello World!"); +app.MapMcp("/mcp"); + +app.Run(); + +namespace Step06_McpApps.McpServer +{ + public class GetTimeApp() + { + private const string URI = "ui://get-time.html"; + + [McpServerTool(Name = "get-time"), Description("Gets the current time.")] + [McpMeta("ui", JsonValue = $$"""{"resourceUri":"{{URI}}"}""")] + [McpMeta("ui/resourceUri", URI)] + public async Task> GetTimeAsync() + { + await Task.Yield(); + return [new TextContentBlock { Text = DateTime.UtcNow.ToString("O") }]; + } + + [McpServerResource(UriTemplate = URI, MimeType = "text/html;profile=mcp-app")] + public async Task GetTimeUIResourceAsync() => await File.ReadAllTextAsync("./dist/get-time.html"); + } +} \ No newline at end of file diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Properties/launchSettings.json b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Properties/launchSettings.json new file mode 100644 index 0000000000..ce1009c977 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5177", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7174;http://localhost:5177", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/appsettings.Development.json b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/appsettings.Development.json new file mode 100644 index 0000000000..0c208ae918 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/appsettings.json b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/appsettings.json new file mode 100644 index 0000000000..10f68b8c8b --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/get-time.html b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/get-time.html new file mode 100644 index 0000000000..1e9c011172 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/get-time.html @@ -0,0 +1,16 @@ + + + + + + Get Time App + + +

+ Server Time: + Loading... +

+ + + + \ No newline at end of file diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/get-time.ts b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/get-time.ts new file mode 100644 index 0000000000..97887a5d82 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/get-time.ts @@ -0,0 +1,27 @@ +// Taken from https://modelcontextprotocol.io/extensions/apps/build + +import { App } from "@modelcontextprotocol/ext-apps"; + +const serverTimeEl = document.getElementById("server-time")!; +const getTimeBtn = document.getElementById("get-time-btn")!; + +const app = new App({ name: "Get Time App", version: "1.0.0" }); + +// Establish communication with the host +app.connect(); + +// Handle the initial tool result pushed by the host +app.ontoolresult = (result) => { + const time = result.content?.find((c) => c.type === "text")?.text; + serverTimeEl.textContent = time ?? "[ERROR]"; +}; + +// Proactively call tools when users interact with the UI +getTimeBtn.addEventListener("click", async () => { + const result = await app.callServerTool({ + name: "get-time", + arguments: {}, + }); + const time = result.content?.find((c) => c.type === "text")?.text; + serverTimeEl.textContent = time ?? "[ERROR]"; +}); \ No newline at end of file diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package-lock.json b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package-lock.json new file mode 100644 index 0000000000..5682a21fb6 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package-lock.json @@ -0,0 +1,2657 @@ +{ + "name": "get-time-mcp-app", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "get-time-mcp-app", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@modelcontextprotocol/ext-apps": "^1.5.0" + }, + "devDependencies": { + "@types/node": "^25.5.2", + "vite": "^8.0.7", + "vite-plugin-singlefile": "^2.3.2" + } + }, + "node_modules/@emnapi/core": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.2.tgz", + "integrity": "sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.1", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.2.tgz", + "integrity": "sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", + "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@hono/node-server": { + "version": "1.19.13", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.13.tgz", + "integrity": "sha512-TsQLe4i2gvoTtrHje625ngThGBySOgSK3Xo2XRYOdqGN1teR8+I7vchQC46uLJi8OF62YTYA3AhSpumtkhsaKQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=18.14.1" + }, + "peerDependencies": { + "hono": "^4" + } + }, + "node_modules/@modelcontextprotocol/ext-apps": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/ext-apps/-/ext-apps-1.5.0.tgz", + "integrity": "sha512-q4fut89TOoP2LEPHSGfZErIf1K1xOTTzV+41h/bB2BqKw2gKb0uLKbHusOy1UtbY0puS16zBho/vFp3f5XMVbQ==", + "license": "MIT", + "workspaces": [ + "examples/*" + ], + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "@modelcontextprotocol/sdk": "^1.29.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0", + "zod": "^3.25.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, + "node_modules/@modelcontextprotocol/sdk": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.29.0.tgz", + "integrity": "sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@hono/node-server": "^1.19.9", + "ajv": "^8.17.1", + "ajv-formats": "^3.0.1", + "content-type": "^1.0.5", + "cors": "^2.8.5", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.0", + "express": "^5.2.1", + "express-rate-limit": "^8.2.1", + "hono": "^4.11.4", + "jose": "^6.1.3", + "json-schema-typed": "^8.0.2", + "pkce-challenge": "^5.0.0", + "raw-body": "^3.0.0", + "zod": "^3.25 || ^4.0", + "zod-to-json-schema": "^3.25.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@cfworker/json-schema": "^4.1.1", + "zod": "^3.25 || ^4.0" + }, + "peerDependenciesMeta": { + "@cfworker/json-schema": { + "optional": true + }, + "zod": { + "optional": false + } + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.3.tgz", + "integrity": "sha512-xK9sGVbJWYb08+mTJt3/YV24WxvxpXcXtP6B172paPZ+Ts69Re9dAr7lKwJoeIx8OoeuimEiRZ7umkiUVClmmQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.124.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.124.0.tgz", + "integrity": "sha512-VBFWMTBvHxS11Z5Lvlr3IWgrwhMTXV+Md+EQF0Xf60+wAdsGFTBx7X7K/hP4pi8N7dcm1RvcHwDxZ16Qx8keUg==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.15.tgz", + "integrity": "sha512-YYe6aWruPZDtHNpwu7+qAHEMbQ/yRl6atqb/AhznLTnD3UY99Q1jE7ihLSahNWkF4EqRPVC4SiR4O0UkLK02tA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.15.tgz", + "integrity": "sha512-oArR/ig8wNTPYsXL+Mzhs0oxhxfuHRfG7Ikw7jXsw8mYOtk71W0OkF2VEVh699pdmzjPQsTjlD1JIOoHkLP1Fg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.15.tgz", + "integrity": "sha512-YzeVqOqjPYvUbJSWJ4EDL8ahbmsIXQpgL3JVipmN+MX0XnXMeWomLN3Fb+nwCmP/jfyqte5I3XRSm7OfQrbyxw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.15.tgz", + "integrity": "sha512-9Erhx956jeQ0nNTyif1+QWAXDRD38ZNjr//bSHrt6wDwB+QkAfl2q6Mn1k6OBPerznjRmbM10lgRb1Pli4xZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.15.tgz", + "integrity": "sha512-cVwk0w8QbZJGTnP/AHQBs5yNwmpgGYStL88t4UIaqcvYJWBfS0s3oqVLZPwsPU6M0zlW4GqjP0Zq5MnAGwFeGA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.15.tgz", + "integrity": "sha512-eBZ/u8iAK9SoHGanqe/jrPnY0JvBN6iXbVOsbO38mbz+ZJsaobExAm1Iu+rxa4S1l2FjG0qEZn4Rc6X8n+9M+w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.15.tgz", + "integrity": "sha512-ZvRYMGrAklV9PEkgt4LQM6MjQX2P58HPAuecwYObY2DhS2t35R0I810bKi0wmaYORt6m/2Sm+Z+nFgb0WhXNcQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.15.tgz", + "integrity": "sha512-VDpgGBzgfg5hLg+uBpCLoFG5kVvEyafmfxGUV0UHLcL5irxAK7PKNeC2MwClgk6ZAiNhmo9FLhRYgvMmedLtnQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.15.tgz", + "integrity": "sha512-y1uXY3qQWCzcPgRJATPSOUP4tCemh4uBdY7e3EZbVwCJTY3gLJWnQABgeUetvED+bt1FQ01OeZwvhLS2bpNrAQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.15.tgz", + "integrity": "sha512-023bTPBod7J3Y/4fzAN6QtpkSABR0rigtrwaP+qSEabUh5zf6ELr9Nc7GujaROuPY3uwdSIXWrvhn1KxOvurWA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.15.tgz", + "integrity": "sha512-witB2O0/hU4CgfOOKUoeFgQ4GktPi1eEbAhaLAIpgD6+ZnhcPkUtPsoKKHRzmOoWPZue46IThdSgdo4XneOLYw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.15.tgz", + "integrity": "sha512-UCL68NJ0Ud5zRipXZE9dF5PmirzJE4E4BCIOOssEnM7wLDsxjc6Qb0sGDxTNRTP53I6MZpygyCpY8Aa8sPfKPg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.15.tgz", + "integrity": "sha512-ApLruZq/ig+nhaE7OJm4lDjayUnOHVUa77zGeqnqZ9pn0ovdVbbNPerVibLXDmWeUZXjIYIT8V3xkT58Rm9u5Q==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "1.9.2", + "@emnapi/runtime": "1.9.2", + "@napi-rs/wasm-runtime": "^1.1.3" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.15.tgz", + "integrity": "sha512-KmoUoU7HnN+Si5YWJigfTws1jz1bKBYDQKdbLspz0UaqjjFkddHsqorgiW1mxcAj88lYUE6NC/zJNwT+SloqtA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.15.tgz", + "integrity": "sha512-3P2A8L+x75qavWLe/Dll3EYBJLQmtkJN8rfh+U/eR3MqMgL/h98PhYI+JFfXuDPgPeCB7iZAKiqii5vqOvnA0g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.15.tgz", + "integrity": "sha512-UromN0peaE53IaBRe9W7CjrZgXl90fqGpK+mIZbA3qSTeYqg3pqpROBdIPvOG3F5ereDHNwoHBI2e50n1BDr1g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.60.1.tgz", + "integrity": "sha512-d6FinEBLdIiK+1uACUttJKfgZREXrF0Qc2SmLII7W2AD8FfiZ9Wjd+rD/iRuf5s5dWrr1GgwXCvPqOuDquOowA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.60.1.tgz", + "integrity": "sha512-YjG/EwIDvvYI1YvYbHvDz/BYHtkY4ygUIXHnTdLhG+hKIQFBiosfWiACWortsKPKU/+dUwQQCKQM3qrDe8c9BA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.60.1.tgz", + "integrity": "sha512-mjCpF7GmkRtSJwon+Rq1N8+pI+8l7w5g9Z3vWj4T7abguC4Czwi3Yu/pFaLvA3TTeMVjnu3ctigusqWUfjZzvw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.60.1.tgz", + "integrity": "sha512-haZ7hJ1JT4e9hqkoT9R/19XW2QKqjfJVv+i5AGg57S+nLk9lQnJ1F/eZloRO3o9Scy9CM3wQ9l+dkXtcBgN5Ew==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.60.1.tgz", + "integrity": "sha512-czw90wpQq3ZsAVBlinZjAYTKduOjTywlG7fEeWKUA7oCmpA8xdTkxZZlwNJKWqILlq0wehoZcJYfBvOyhPTQ6w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.60.1.tgz", + "integrity": "sha512-KVB2rqsxTHuBtfOeySEyzEOB7ltlB/ux38iu2rBQzkjbwRVlkhAGIEDiiYnO2kFOkJp+Z7pUXKyrRRFuFUKt+g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.60.1.tgz", + "integrity": "sha512-L+34Qqil+v5uC0zEubW7uByo78WOCIrBvci69E7sFASRl0X7b/MB6Cqd1lky/CtcSVTydWa2WZwFuWexjS5o6g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.60.1.tgz", + "integrity": "sha512-n83O8rt4v34hgFzlkb1ycniJh7IR5RCIqt6mz1VRJD6pmhRi0CXdmfnLu9dIUS6buzh60IvACM842Ffb3xd6Gg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.60.1.tgz", + "integrity": "sha512-Nql7sTeAzhTAja3QXeAI48+/+GjBJ+QmAH13snn0AJSNL50JsDqotyudHyMbO2RbJkskbMbFJfIJKWA6R1LCJQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.60.1.tgz", + "integrity": "sha512-+pUymDhd0ys9GcKZPPWlFiZ67sTWV5UU6zOJat02M1+PiuSGDziyRuI/pPue3hoUwm2uGfxdL+trT6Z9rxnlMA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.60.1.tgz", + "integrity": "sha512-VSvgvQeIcsEvY4bKDHEDWcpW4Yw7BtlKG1GUT4FzBUlEKQK0rWHYBqQt6Fm2taXS+1bXvJT6kICu5ZwqKCnvlQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.60.1.tgz", + "integrity": "sha512-4LqhUomJqwe641gsPp6xLfhqWMbQV04KtPp7/dIp0nzPxAkNY1AbwL5W0MQpcalLYk07vaW9Kp1PBhdpZYYcEw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.60.1.tgz", + "integrity": "sha512-tLQQ9aPvkBxOc/EUT6j3pyeMD6Hb8QF2BTBnCQWP/uu1lhc9AIrIjKnLYMEroIz/JvtGYgI9dF3AxHZNaEH0rw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.60.1.tgz", + "integrity": "sha512-RMxFhJwc9fSXP6PqmAz4cbv3kAyvD1etJFjTx4ONqFP9DkTkXsAMU4v3Vyc5BgzC+anz7nS/9tp4obsKfqkDHg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.60.1.tgz", + "integrity": "sha512-QKgFl+Yc1eEk6MmOBfRHYF6lTxiiiV3/z/BRrbSiW2I7AFTXoBFvdMEyglohPj//2mZS4hDOqeB0H1ACh3sBbg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.60.1.tgz", + "integrity": "sha512-RAjXjP/8c6ZtzatZcA1RaQr6O1TRhzC+adn8YZDnChliZHviqIjmvFwHcxi4JKPSDAt6Uhf/7vqcBzQJy0PDJg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.60.1.tgz", + "integrity": "sha512-wcuocpaOlaL1COBYiA89O6yfjlp3RwKDeTIA0hM7OpmhR1Bjo9j31G1uQVpDlTvwxGn2nQs65fBFL5UFd76FcQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.60.1.tgz", + "integrity": "sha512-77PpsFQUCOiZR9+LQEFg9GClyfkNXj1MP6wRnzYs0EeWbPcHs02AXu4xuUbM1zhwn3wqaizle3AEYg5aeoohhg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.60.1.tgz", + "integrity": "sha512-5cIATbk5vynAjqqmyBjlciMJl1+R/CwX9oLk/EyiFXDWd95KpHdrOJT//rnUl4cUcskrd0jCCw3wpZnhIHdD9w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.60.1.tgz", + "integrity": "sha512-cl0w09WsCi17mcmWqqglez9Gk8isgeWvoUZ3WiJFYSR3zjBQc2J5/ihSjpl+VLjPqjQ/1hJRcqBfLjssREQILw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "peer": true + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.60.1.tgz", + "integrity": "sha512-4Cv23ZrONRbNtbZa37mLSueXUCtN7MXccChtKpUnQNgF010rjrjfHx3QxkS2PI7LqGT5xXyYs1a7LbzAwT0iCA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "peer": true + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.60.1.tgz", + "integrity": "sha512-i1okWYkA4FJICtr7KpYzFpRTHgy5jdDbZiWfvny21iIKky5YExiDXP+zbXzm3dUcFpkEeYNHgQ5fuG236JPq0g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.60.1.tgz", + "integrity": "sha512-u09m3CuwLzShA0EYKMNiFgcjjzwqtUMLmuCJLeZWjjOYA3IT2Di09KaxGBTP9xVztWyIWjVdsB2E9goMjZvTQg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.60.1.tgz", + "integrity": "sha512-k+600V9Zl1CM7eZxJgMyTUzmrmhB/0XZnF4pRypKAlAgxmedUA+1v9R+XOFv56W4SlHEzfeMtzujLJD22Uz5zg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.60.1.tgz", + "integrity": "sha512-lWMnixq/QzxyhTV6NjQJ4SFo1J6PvOX8vUx5Wb4bBPsEb+8xZ89Bz6kOXpfXj9ak9AHTQVQzlgzBEc1SyM27xQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", + "integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/@types/node": { + "version": "25.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.5.2.tgz", + "integrity": "sha512-tO4ZIRKNC+MDWV4qKVZe3Ql/woTnmHDr5JD8UI5hn2pwBrHEwOEMZK7WlNb5RKB6EoJ02gwmQS9OrjuFnZYdpg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.18.0" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "peer": true, + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ajv": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz", + "integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==", + "license": "MIT", + "peer": true, + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-formats": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz", + "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "ajv": "^8.0.0" + }, + "peerDependencies": { + "ajv": "^8.0.0" + }, + "peerDependenciesMeta": { + "ajv": { + "optional": true + } + } + }, + "node_modules/body-parser": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", + "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", + "license": "MIT", + "peer": true, + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.1", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "peer": true, + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "license": "MIT", + "peer": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "peer": true, + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT", + "peer": true + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT", + "peer": true + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "license": "MIT", + "peer": true, + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.6.tgz", + "integrity": "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "peer": true, + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-rate-limit": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.3.2.tgz", + "integrity": "sha512-77VmFeJkO0/rvimEDuUC5H30oqUC4EyOhyGccfqoLebB0oiEYfM7nwPrsDsBL1gsTpwfzX8SFy2MT3TDyRq+bg==", + "license": "MIT", + "peer": true, + "dependencies": { + "ip-address": "10.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/express-rate-limit" + }, + "peerDependencies": { + "express": ">= 4.11" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "license": "MIT", + "peer": true + }, + "node_modules/fast-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", + "integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause", + "peer": true + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "peer": true, + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "peer": true, + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hono": { + "version": "4.12.12", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.12.tgz", + "integrity": "sha512-p1JfQMKaceuCbpJKAPKVqyqviZdS0eUxH9v82oWo1kb9xjQ5wA6iP3FNVAPDFlz5/p7d45lO+BpSk1tuSZMF4Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=16.9.0" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", + "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "license": "MIT", + "peer": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC", + "peer": true + }, + "node_modules/ip-address": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz", + "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 12" + } + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT", + "peer": true + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "license": "ISC", + "peer": true + }, + "node_modules/jose": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.2.tgz", + "integrity": "sha512-d7kPDd34KO/YnzaDOlikGpOurfF0ByC2sEV4cANCtdqLlTfBlw2p14O/5d/zv40gJPbIQxfES3nSx1/oYNyuZQ==", + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "license": "MIT", + "peer": true + }, + "node_modules/json-schema-typed": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz", + "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==", + "license": "BSD-2-Clause", + "peer": true + }, + "node_modules/lightningcss": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", + "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.32.0", + "lightningcss-darwin-arm64": "1.32.0", + "lightningcss-darwin-x64": "1.32.0", + "lightningcss-freebsd-x64": "1.32.0", + "lightningcss-linux-arm-gnueabihf": "1.32.0", + "lightningcss-linux-arm64-gnu": "1.32.0", + "lightningcss-linux-arm64-musl": "1.32.0", + "lightningcss-linux-x64-gnu": "1.32.0", + "lightningcss-linux-x64-musl": "1.32.0", + "lightningcss-win32-arm64-msvc": "1.32.0", + "lightningcss-win32-x64-msvc": "1.32.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", + "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", + "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", + "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", + "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", + "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", + "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", + "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", + "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", + "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", + "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.32.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", + "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "peer": true, + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT", + "peer": true + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "peer": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "peer": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pkce-challenge": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz", + "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/postcss": { + "version": "8.5.9", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.9.tgz", + "integrity": "sha512-7a70Nsot+EMX9fFU3064K/kdHWZqGVY+BADLyXc8Dfv+mTLLVl6JzJpPaCZ2kQL9gIJvKXSLMHhqdRRjwQeFtw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "peer": true, + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.15.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.1.tgz", + "integrity": "sha512-6YHEFRL9mfgcAvql/XhwTvf5jKcOiiupt2FiJxHkiX1z4j7WL8J/jRHYLluORvc1XxB5rV20KoeK00gVJamspg==", + "license": "BSD-3-Clause", + "peer": true, + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "peer": true, + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rolldown": { + "version": "1.0.0-rc.15", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.15.tgz", + "integrity": "sha512-Ff31guA5zT6WjnGp0SXw76X6hzGRk/OQq2hE+1lcDe+lJdHSgnSX6nK3erbONHyCbpSj9a9E+uX/OvytZoWp2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.124.0", + "@rolldown/pluginutils": "1.0.0-rc.15" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm64": "1.0.0-rc.15", + "@rolldown/binding-darwin-arm64": "1.0.0-rc.15", + "@rolldown/binding-darwin-x64": "1.0.0-rc.15", + "@rolldown/binding-freebsd-x64": "1.0.0-rc.15", + "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.15", + "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.15", + "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.15", + "@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.15", + "@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.15", + "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.15", + "@rolldown/binding-linux-x64-musl": "1.0.0-rc.15", + "@rolldown/binding-openharmony-arm64": "1.0.0-rc.15", + "@rolldown/binding-wasm32-wasi": "1.0.0-rc.15", + "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.15", + "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.15" + } + }, + "node_modules/rollup": { + "version": "4.60.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.1.tgz", + "integrity": "sha512-VmtB2rFU/GroZ4oL8+ZqXgSA38O6GR8KSIvWmEFv63pQ0G6KaBH9s07PO8XTXP4vI+3UJUEypOfjkGfmSBBR0w==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.60.1", + "@rollup/rollup-android-arm64": "4.60.1", + "@rollup/rollup-darwin-arm64": "4.60.1", + "@rollup/rollup-darwin-x64": "4.60.1", + "@rollup/rollup-freebsd-arm64": "4.60.1", + "@rollup/rollup-freebsd-x64": "4.60.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.60.1", + "@rollup/rollup-linux-arm-musleabihf": "4.60.1", + "@rollup/rollup-linux-arm64-gnu": "4.60.1", + "@rollup/rollup-linux-arm64-musl": "4.60.1", + "@rollup/rollup-linux-loong64-gnu": "4.60.1", + "@rollup/rollup-linux-loong64-musl": "4.60.1", + "@rollup/rollup-linux-ppc64-gnu": "4.60.1", + "@rollup/rollup-linux-ppc64-musl": "4.60.1", + "@rollup/rollup-linux-riscv64-gnu": "4.60.1", + "@rollup/rollup-linux-riscv64-musl": "4.60.1", + "@rollup/rollup-linux-s390x-gnu": "4.60.1", + "@rollup/rollup-linux-x64-gnu": "4.60.1", + "@rollup/rollup-linux-x64-musl": "4.60.1", + "@rollup/rollup-openbsd-x64": "4.60.1", + "@rollup/rollup-openharmony-arm64": "4.60.1", + "@rollup/rollup-win32-arm64-msvc": "4.60.1", + "@rollup/rollup-win32-ia32-msvc": "4.60.1", + "@rollup/rollup-win32-x64-gnu": "4.60.1", + "@rollup/rollup-win32-x64-msvc": "4.60.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT", + "peer": true + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "peer": true, + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC", + "peer": true + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "license": "MIT", + "peer": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "peer": true, + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "peer": true, + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz", + "integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "peer": true, + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/undici-types": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", + "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vite": { + "version": "8.0.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.8.tgz", + "integrity": "sha512-dbU7/iLVa8KZALJyLOBOQ88nOXtNG8vxKuOT4I2mD+Ya70KPceF4IAmDsmU0h1Qsn5bPrvsY9HJstCRh3hG6Uw==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.32.0", + "picomatch": "^4.0.4", + "postcss": "^8.5.8", + "rolldown": "1.0.0-rc.15", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.1.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-plugin-singlefile": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/vite-plugin-singlefile/-/vite-plugin-singlefile-2.3.2.tgz", + "integrity": "sha512-b8SxCi/gG7K298oJDcKOuZeU6gf6wIcCJAaEqUmmZXdjfuONlkyNyWZC3tEbN6QockRCNUd3it9eGTtpHGoYmg==", + "dev": true, + "license": "MIT", + "dependencies": { + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">18.0.0" + }, + "peerDependencies": { + "rollup": "^4.59.0", + "vite": "^5.4.11 || ^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "license": "ISC", + "peer": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC", + "peer": true + }, + "node_modules/zod": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", + "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-to-json-schema": { + "version": "3.25.2", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz", + "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==", + "license": "ISC", + "peer": true, + "peerDependencies": { + "zod": "^3.25.28 || ^4" + } + } + } +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package.json b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package.json new file mode 100644 index 0000000000..e4426c7de5 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/package.json @@ -0,0 +1,15 @@ +{ + "name": "get-time-mcp-app", + "version": "1.0.0", + "scripts": { + "build": "INPUT=get-time.html vite build" + }, + "dependencies": { + "@modelcontextprotocol/ext-apps": "^1.5.0" + }, + "devDependencies": { + "@types/node": "^25.5.2", + "vite": "^8.0.7", + "vite-plugin-singlefile": "^2.3.2" + } +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/vite.config.ts b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/vite.config.ts new file mode 100644 index 0000000000..c7dc32d4b4 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/McpServer/vite.config.ts @@ -0,0 +1,14 @@ +// Taken from https://modelcontextprotocol.io/extensions/apps/build + +import { defineConfig } from "vite"; +import { viteSingleFile } from "vite-plugin-singlefile"; + +export default defineConfig({ + plugins: [viteSingleFile()], + build: { + outDir: "dist", + rollupOptions: { + input: process.env.INPUT, + }, + }, +}); \ No newline at end of file diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/README.md b/dotnet/samples/02-agents/AGUI/Step06_McpApps/README.md new file mode 100644 index 0000000000..e7fc1b4300 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/README.md @@ -0,0 +1,395 @@ +# Step06_McpApps — MCP Apps with AG-UI + +This sample demonstrates **MCP Apps**: a mechanism for attaching interactive HTML UI components to MCP tools. When an MCP tool is invoked, the AG-UI host passes the associated `ui://` resource URI alongside the tool result so that a capable client can render the HTML app in-place. + +If you want the broader conceptual model for MCP Apps before diving into this sample, see the official [MCP Apps Overview](https://modelcontextprotocol.io/extensions/apps/overview). + +## What This Sample Demonstrates + +### McpServer (`McpServer/`) + +An ASP.NET Core MCP server that exposes a `get-time` tool together with a bundled HTML UI: + +- Registering MCP tools and resources with `AddMcpServer()` +- Attaching a UI resource to a tool via `[McpMeta("ui", JsonValue = ...)]` +- Exposing an HTML app as an MCP resource with MIME type `text/html;profile=mcp-app` +- Serving the bundled single-file HTML app from the `dist/` directory + +### Server (`Server/`) + +An AG-UI server that bridges the MCP server to AG-UI clients: + +- Connecting to the MCP server with `McpClient` and listing its tools +- Wrapping an OpenAI chat client as an `AIAgent` with the MCP tools attached +- Exposing the agent over HTTP with `MapAGUI` +- Handling proxied MCP `resources/read` and `tools/call` requests through the `MapAGUI` `ProxiedResultResolver` overload + +### Client (`Client/`) + +A console client that connects to the AG-UI server. Demonstrates: + +- Connecting with `AGUIChatClient` +- Streaming responses with `RunStreamingAsync` +- Displaying session and run metadata, text content, and errors + +> **Note:** The console client cannot render the MCP App — HTML rendering requires a browser frontend. However, the AG-UI server correctly emits the `ACTIVITY_SNAPSHOT` event containing the `ui://` resource URI and the full tool result. A browser-based AG-UI client would receive exactly that information and use it to load and display the HTML app. + +### Frontend MCP App (`McpServer/get-time.ts`) + +A small TypeScript web app compiled with Vite that runs inside the MCP host: + +- Using `@modelcontextprotocol/ext-apps` to establish communication with the MCP host +- Receiving the initial tool result via `app.ontoolresult` +- Proactively calling server tools from UI interactions with `app.callServerTool` +- Bundling as a self-contained single HTML file using `vite-plugin-singlefile` + +## Architecture + +```text +┌─────────────┐ AG-UI (SSE) ┌────────────────┐ MCP (HTTP) ┌─────────────────┐ +│ Client │ ────────────────────> │ Server │ ─────────────────> │ McpServer │ +│ (console) │ port 5253 │ port 5253 │ port 5177 │ port 5177 │ +└─────────────┘ └────────────────┘ └─────────────────┘ +``` + +## Prerequisites + +- .NET 10.0 or later +- An OpenAI API key + +```bash +export OPENAI_API_KEY="sk-..." +``` + +## Running the Sample + +### 1. Start the McpServer + +```bash +cd Step06_McpApps/McpServer +dotnet run +``` + +The MCP server starts at `http://localhost:5177` and exposes: + +- `GET /` — health check +- `POST /mcp` — MCP endpoint (stateless HTTP transport) + +### 2. Start the AG-UI Server + +```bash +cd Step06_McpApps/Server +dotnet run +``` + +The server starts at `http://localhost:5253`. It connects to the McpServer, wraps GPT-4o as an AI agent with the MCP tools, and exposes an AG-UI endpoint at `/`. + +### 3. Run the Client + +```bash +cd Step06_McpApps/Client +AGUI_SERVER_URL=http://localhost:5253 dotnet run +``` + +The client connects to `http://localhost:5253` by default. Type messages and press Enter. Type `:q` or `quit` to exit. Try asking: *"What time is it?"* + +## Rebuilding the Frontend (Optional) + +A pre-built `dist/get-time.html` is included. To rebuild from source after editing `get-time.ts` or `get-time.html`: + +```bash +cd Step06_McpApps/McpServer +npm install +npm run build +``` + +This bundles `get-time.ts` and inlines all assets into `dist/get-time.html` as a single self-contained file. + +## Key Concepts + +The sample follows the core MCP Apps pattern described in the [MCP Apps Overview](https://modelcontextprotocol.io/extensions/apps/overview): a tool advertises a UI resource, the host loads that `ui://` resource, and the app communicates back through the host rather than calling the server directly from the browser. + +### Tool ↔ UI Binding + +The `[McpMeta("ui", ...)]` attribute on a tool method points to an MCP resource URI: + +```csharp +[McpServerTool(Name = "get-time"), Description("Gets the current time.")] +[McpMeta("ui", JsonValue = """{"resourceUri":"ui://get-time.html"}""")] +public async Task> GetTimeAsync() { ... } +``` + +### MCP App Resource + +The HTML app is exposed as a resource with the special MIME type `text/html;profile=mcp-app`: + +```csharp +[McpServerResource(UriTemplate = "ui://get-time.html", MimeType = "text/html;profile=mcp-app")] +public async Task GetTimeUIResourceAsync() => + await File.ReadAllTextAsync("./dist/get-time.html"); +``` + +### App SDK Communication + +Inside the frontend, `@modelcontextprotocol/ext-apps` handles the messaging bridge between the HTML app and the MCP host: + +```typescript +const app = new App({ name: "Get Time App", version: "1.0.0" }); +app.connect(); + +// Receive initial tool result pushed by the host +app.ontoolresult = (result) => { ... }; + +// Proactively call tools from UI events +const result = await app.callServerTool({ name: "get-time", arguments: {} }); +``` + +## AG-UI Protocol: MCP Apps in the Event Stream + +When the Server forwards an MCP App tool invocation, the SSE stream contains this event sequence: + +```text +RUN_STARTED +TOOL_CALL_START +TOOL_CALL_ARGS (one or more, streaming JSON delta) +TOOL_CALL_END +TOOL_CALL_RESULT +ACTIVITY_SNAPSHOT ← carries the MCP App resource URI and tool result +RUN_FINISHED +``` + +The `ACTIVITY_SNAPSHOT` event is the key addition over a plain tool call. Its `content` object tells the client which HTML app to load and passes the tool result into it: + +```jsonc +{ + "type": "ACTIVITY_SNAPSHOT", + "messageId": "", + "activityType": "mcp-apps", + "replace": true, + "content": { + "resourceUri": "ui://get-time.html", // MCP App resource to render + "result": { // Full MCP tool result + "content": [{ "type": "text", "text": "..." }] + }, + "toolInput": {} // Arguments passed to the tool + } +} +``` + +### `ACTIVITY_SNAPSHOT` Field Reference + +| Field | Type | Notes | +| --- | --- | --- | +| `activityType` | `"mcp-apps"` | Identifies this as an MCP App activity | +| `replace` | boolean | `true` replaces any previous snapshot for this `messageId` | +| `content.resourceUri` | string | MCP App resource URI, e.g. `"ui://get-time.html"` | +| `content.result` | object | Full MCP tool result: `{ content: [{ type, text }] }` | +| `content.toolInput` | object | Arguments passed to the tool | + +## AG-UI Protocol: Proxied MCP Resource Reads + +After the client receives the `ACTIVITY_SNAPSHOT` containing the `resourceUri`, a capable host (e.g. CopilotKit) fetches the actual resource HTML by sending a second `agent/run` request. The resource URI alone is not enough — the client needs the HTML content to render the app. + +### Proxied Request + +The client embeds the MCP `resources/read` call inside `forwardedProps.__proxiedMCPRequest`: + +```jsonc +{ + "threadId": "", + "runId": "", + "messages": [...], // conversation history + "forwardedProps": { + "__proxiedMCPRequest": { + "serverHash": "", + "serverId": "", + "method": "resources/read", + "params": { + "uri": "ui://get-time.html" + } + } + } +} +``` + +This JSON is the plain AG-UI POST body used by the Step06 sample server. Some hosts, including CopilotKit, may wrap the same body inside an outer `{"method":"agent/run","params":...,"body":...}` envelope. + +The presence of `forwardedProps.__proxiedMCPRequest` signals that this run is a proxy call, not a new LLM turn. The agent should **not** be invoked. + +Hosts may include additional proxy metadata such as `serverHash` and `serverId`. Those fields are host-specific. The Step06 sample ignores them and only uses `method` plus `params.uri`, while some hosts may require them. + +### Expected Response + +The server should short-circuit the agent run and respond with exactly two SSE events: + +```text +RUN_STARTED +RUN_FINISHED ← carries result.contents with the resource HTML +``` + +```jsonc +// RUN_FINISHED +{ + "type": "RUN_FINISHED", + "runId": "", + "threadId": "", + "result": { + "contents": [ + { + "uri": "ui://get-time.html", + "mimeType": "text/html;profile=mcp-app", + "text": "..." + } + ] + } +} +``` + +### Server Implementation + +The server (`Server/Program.cs`) handles both paths on the same AG-UI endpoint: + +1. **Normal agent runs** — the sample calls `app.MapAGUI("/", agent, async (forwardedProperties, cancellationToken) => ...)`, which binds to the `ProxiedResultResolver` overload. When no proxied result is resolved, the AG-UI hosting layer converts the request into chat messages, runs the `AIAgent`, and streams the normal AG-UI SSE event sequence back to the client. + +2. **Resolver invocation guard** — the `MapAGUI` overload only invokes the `ProxiedResultResolver` when `forwardedProps` is a non-empty JSON object. Missing, `null`, `undefined`, or empty-object forwarded properties fall through directly to the normal agent path. + +3. **Proxied MCP resource reads** — when the resolver is invoked and `forwardedProps.__proxiedMCPRequest.method == "resources/read"`, the sample extracts `params.uri`, calls `mcpClient.ReadResourceAsync(uri)`, and maps that MCP response into the `RUN_FINISHED.result.contents` payload expected by AG-UI clients. + +4. **Proxied MCP tool calls** — when `forwardedProps.__proxiedMCPRequest.method == "tools/call"`, the sample extracts `params.name` plus `params.arguments`, calls `mcpClient.CallToolAsync(...)`, and maps that MCP `CallToolResult` into the `RUN_FINISHED.result.content` payload expected by AG-UI clients and MCP App hosts. + +5. **Minimal proxy SSE response** — the hosting layer still emits exactly two events: + +- `RUN_STARTED` +- `RUN_FINISHED`, with `result.contents` for proxied `resources/read` and `result.content` for proxied `tools/call` + +This keeps proxied resource fetches and in-app tool invocations out of the agent loop while preserving the same `/` endpoint shape expected by AG-UI clients and hosts such as CopilotKit, without inlining custom endpoint logic into the sample. + +## AG-UI Protocol: Proxied MCP Tool Calls from the Loaded App + +Once the host has fetched and rendered the MCP App HTML, the app can initiate further MCP calls through the same AG-UI endpoint. In this sample, the frontend uses `app.callServerTool({ name: "get-time", arguments: {} })` to issue a fresh `tools/call` request back to the MCP server. + +Just like proxied `resources/read`, this is a proxy operation, not a new LLM turn. The AG-UI host forwards the MCP request shape inside `forwardedProps.__proxiedMCPRequest`, and the server should short-circuit the agent and call the MCP server directly. + +### Proxied Tool Call Request + +The request shape below is the plain AG-UI body sent after the app is already loaded: + +```jsonc +{ + "threadId": "", + "runId": "", + "tools": [], + "context": [], + "state": {}, + "messages": [ + { "id": "", "role": "user", "content": "what time is it?" }, + { + "id": "", + "role": "assistant", + "toolCalls": [ + { + "id": "", + "type": "function", + "function": { "name": "get-time", "arguments": "{}" } + } + ] + }, + { + "id": "", + "toolCallId": "", + "role": "tool", + "content": "2026-04-11T09:54:05.2880570Z" + } + ], + "forwardedProps": { + "__proxiedMCPRequest": { + "serverHash": "", + "serverId": "", + "method": "tools/call", + "params": { + "name": "get-time", + "arguments": {} + } + } + } +} +``` + +Some hosts, including CopilotKit, may wrap this AG-UI body inside an outer `{"method":"agent/run","params":...,"body":...}` envelope. The Step06 sample server itself accepts the plain AG-UI body shown above. + +The conversation history is host-managed context. The critical signal is still `forwardedProps.__proxiedMCPRequest`: the agent should not run, and the server should proxy the embedded MCP call directly. + +### Expected Tool Call Response + +The server again emits only the minimal proxy SSE envelope: + +```text +RUN_STARTED +RUN_FINISHED ← carries result.content with the proxied tool result +``` + +```jsonc +// RUN_FINISHED +{ + "type": "RUN_FINISHED", + "runId": "", + "threadId": "", + "result": { + "content": [ + { + "type": "text", + "text": "2026-04-11T09:54:12.0752760Z" + } + ] + } +} +``` + +Unlike proxied `resources/read`, the `RUN_FINISHED.result` payload follows MCP `CallToolResult` shape, so text tool output appears under `result.content` rather than `result.contents`. + +## Conformance Tests + +[Tests/ConformanceTests.cs](Tests/ConformanceTests.cs) covers integration-level concerns that cannot be reached by unit tests. All AG-UI protocol output behaviour (event ordering, field values, wire format) is verified by the unit tests in `Microsoft.Agents.AI.AGUI.UnitTests`. + +### Running against the sample AG-UI server + +Both the McpServer (port 5177) and the AG-UI Server (port 5253) must be running before executing the tests. + +```bash +cd Step06_McpApps/Tests +dotnet test +``` + +### Running against a CopilotKit endpoint + +The tests auto-detect whether the target host expects a plain AG-UI body or a CopilotKit-style envelope (`{"method":"agent/run","params":{"agentId":"..."},"body":{...}}`). Override `AG_UI_HOST` to point at any compatible host: + +```bash +cd Step06_McpApps/Tests +AG_UI_HOST=http://localhost:3000/api/copilotkit dotnet test +``` + +The detection works by sending a minimal probe request (empty `messages` array, no LLM call) before the first real test. A `200 text/event-stream` response means direct format; any non-success response falls back to the CopilotKit-style envelope, with `"default"` used as the agent ID. A common case is CopilotKit returning `400` with a missing-method error for the direct-format probe. Set `AG_UI_AGENT_ID` to override the agent ID explicitly. + +When targeting CopilotKit, the `serverHash` and `serverId` values used in proxied resource-read and proxied tool-call requests are auto-discovered from the first real tool call, typically from CopilotKit-specific data associated with the emitted `ACTIVITY_SNAPSHOT` flow. These values are not part of the standard AG-UI `ACTIVITY_SNAPSHOT` fields documented above, so no manual configuration is needed when the host provides them. + +### Cancellation + +All tests are linked to the test runner's cancellation token. Pressing Ctrl+C (or using the IDE's stop button) aborts all in-flight HTTP requests immediately rather than waiting for the 60-second per-test timeout to expire. + +### Test reference + +| # | Test | What it verifies | +| --- | --- | --- | +| 1 | `HttpResponse_HasContentType_TextEventStream` | ASP.NET Core hosting layer emits `Content-Type: text/event-stream` | +| 2 | `AskingWhatTimeIsIt_CausesToolCallStart_ForGetTime` | Live LLM routes a natural-language time query to the `get-time` MCP tool | +| 3 | `ProxiedResourceRead_EmitsOnlyRunStartedAndRunFinished` | Proxied `resources/read` emits exactly `RUN_STARTED` + `RUN_FINISHED` — no agent events | +| 4 | `ProxiedResourceRead_RunFinished_HasResultContents` | `RUN_FINISHED` carries `result.contents` with at least one entry | +| 5 | `ProxiedResourceRead_RunFinished_ResourceUri_MatchesRequest` | `result.contents[0].uri` echoes the requested resource URI | +| 6 | `ProxiedResourceRead_RunFinished_MimeType_IsMcpApp` | `result.contents[0].mimeType` is `text/html;profile=mcp-app` | +| 7 | `ProxiedResourceRead_RunFinished_ResourceText_IsNonEmpty` | `result.contents[0].text` contains the actual HTML | +| 8 | `ProxiedResourceRead_RunFinished_EchoesRunId` | `RUN_FINISHED.runId` matches the `runId` from the request | +| 9 | `ProxiedToolCall_EmitsOnlyRunStartedAndRunFinished` | Proxied `tools/call` emits exactly `RUN_STARTED` + `RUN_FINISHED` — no agent events | +| 10 | `ProxiedToolCall_RunFinished_HasResultContent` | `RUN_FINISHED` carries `result.content` with at least one entry | +| 11 | `ProxiedToolCall_RunFinished_ResultContainsTextContent` | `result.content[0]` is a non-empty text content block | +| 12 | `ProxiedToolCall_RunFinished_EchoesRunId` | `RUN_FINISHED.runId` matches the `runId` from the proxied `tools/call` request | diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Program.cs b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Program.cs new file mode 100644 index 0000000000..bc2c445e1b --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Program.cs @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft. All rights reserved. + +using Microsoft.Agents.AI; +using Microsoft.Agents.AI.Hosting.AGUI.AspNetCore; +using Microsoft.Extensions.AI; +using ModelContextProtocol.Client; +using ModelContextProtocol.Protocol; +using OpenAI; +using System.Text; +using System.Text.Json; + +WebApplicationBuilder builder = WebApplication.CreateBuilder(args); +builder.Services.AddHttpClient().AddLogging(); +builder.Services.AddAGUI(); + +var openaiApiKey = builder.Configuration["OPENAI_API_KEY"] ?? throw new InvalidOperationException("OPENAI_API_KEY is not set."); +var chatClient = new OpenAIClient(openaiApiKey) + .GetChatClient("gpt-4o") + .AsIChatClient() + .AsBuilder() + .ConfigureOptions(o => o.Temperature = 0f) + .Build(); + +var mcpClient = await McpClient.CreateAsync(new HttpClientTransport(new() +{ + Endpoint = new Uri("http://localhost:5177/mcp"), + TransportMode = HttpTransportMode.StreamableHttp, +})); +var mcpTools = await mcpClient.ListToolsAsync(); + +WebApplication app = builder.Build(); + +AIAgent agent = chatClient.AsAIAgent( + name: "AGUIAssistant", + instructions: """ + You are a helpful assistant. + IMPORTANT RULES: + (1) You MUST use the get-time tool to answer any question about the current time or date — never answer from memory. + (2) Do not guess or make up the time. + """, + tools: mcpTools.Cast().ToList()) + .AsBuilder() + .UseEmitToolMetadata(mcpTools.ToDictionary(static t => t.Name, static t => t.ProtocolTool.Meta)) + .Build() + ; + +app.MapAGUI("/", agent, proxiedResultResolver: async (forwardedProperties, cancellationToken) => +{ + if (!TryGetProxiedRequest(forwardedProperties, out var proxiedRequest) || proxiedRequest is null) + { + return null; + } + + var request = proxiedRequest.Value; + + return request.Method switch + { + "resources/read" when request.ResourceUri is not null => + BuildProxiedReadResult( + request.ResourceUri, + await mcpClient.ReadResourceAsync(new Uri(request.ResourceUri), cancellationToken: cancellationToken)), + "tools/call" when request.ToolName is not null => + BuildProxiedToolCallResult( + await mcpClient.CallToolAsync( + request.ToolName, + request.Arguments, + cancellationToken: cancellationToken)), + _ => null, + }; +}); + +await app.RunAsync(); + +static JsonElement? BuildProxiedReadResult(string requestedResourceUri, ReadResourceResult readResult) +{ + var contentsJson = string.Join(",", readResult.Contents.Select(content => BuildProxiedReadContentJson(requestedResourceUri, content))); + using var document = JsonDocument.Parse($"{{\"contents\":[{contentsJson}]}}"); + return document.RootElement.Clone(); +} + +static JsonElement? BuildProxiedToolCallResult(CallToolResult callToolResult) +{ + var contentJson = callToolResult.Content is null + ? string.Empty + : string.Join(",", callToolResult.Content.Select(BuildProxiedToolCallContentJson)); + + var structuredContentJson = callToolResult.StructuredContent is null + ? string.Empty + : $",\"structuredContent\":{JsonSerializer.Serialize(callToolResult.StructuredContent)}"; + var isErrorJson = callToolResult.IsError is null + ? string.Empty + : $",\"isError\":{(callToolResult.IsError.Value ? "true" : "false")}"; + + using var document = JsonDocument.Parse($"{{\"content\":[{contentJson}]{structuredContentJson}{isErrorJson}}}"); + return document.RootElement.Clone(); +} + +static string BuildProxiedReadContentJson(string requestedResourceUri, ResourceContents content) +{ + var encodedUri = JsonSerializer.Serialize(requestedResourceUri); + var encodedMimeType = content.MimeType is null ? "null" : JsonSerializer.Serialize(content.MimeType); + + return content switch + { + TextResourceContents text => + $"{{\"uri\":{encodedUri},\"mimeType\":{encodedMimeType},\"text\":{JsonSerializer.Serialize(text.Text ?? string.Empty)}}}", + BlobResourceContents blob => + $"{{\"uri\":{encodedUri},\"mimeType\":{encodedMimeType},\"blob\":{JsonSerializer.Serialize(Convert.ToBase64String(blob.DecodedData.ToArray()))}}}", + _ => + $"{{\"uri\":{encodedUri},\"mimeType\":{encodedMimeType},\"text\":{JsonSerializer.Serialize(content.ToString() ?? string.Empty)}}}", + }; +} + +static string BuildProxiedToolCallContentJson(ContentBlock content) +{ + return content switch + { + TextContentBlock text => + $"{{\"type\":\"text\",\"text\":{JsonSerializer.Serialize(text.Text ?? string.Empty)}}}", + ImageContentBlock image => + $"{{\"type\":\"image\",\"mimeType\":{JsonSerializer.Serialize(image.MimeType)},\"data\":{JsonSerializer.Serialize(Convert.ToBase64String(image.Data.ToArray()))}}}", + AudioContentBlock audio => + $"{{\"type\":\"audio\",\"mimeType\":{JsonSerializer.Serialize(audio.MimeType)},\"data\":{JsonSerializer.Serialize(Convert.ToBase64String(audio.Data.ToArray()))}}}", + _ => + $"{{\"type\":\"text\",\"text\":{JsonSerializer.Serialize(content.ToString() ?? string.Empty)}}}", + }; +} + +static bool TryGetProxiedRequest( + JsonElement forwardedProperties, + out (string Method, string? ResourceUri, string? ToolName, IReadOnlyDictionary? Arguments)? proxiedRequest) +{ + proxiedRequest = null; + + if (forwardedProperties.ValueKind != JsonValueKind.Object || + !forwardedProperties.TryGetProperty("__proxiedMCPRequest", out var proxiedRequestProperty) || + proxiedRequestProperty.ValueKind != JsonValueKind.Object || + !proxiedRequestProperty.TryGetProperty("method", out var methodProperty)) + { + return false; + } + + var method = methodProperty.GetString(); + if (string.IsNullOrWhiteSpace(method)) + { + return false; + } + + if (!proxiedRequestProperty.TryGetProperty("params", out var parameters) || + parameters.ValueKind != JsonValueKind.Object) + { + proxiedRequest = (method, null, null, null); + return true; + } + + if (string.Equals(method, "resources/read", StringComparison.Ordinal) && + parameters.TryGetProperty("uri", out var uriProperty)) + { + var resourceUri = uriProperty.GetString(); + proxiedRequest = (method, resourceUri, null, null); + return !string.IsNullOrWhiteSpace(resourceUri); + } + + if (string.Equals(method, "tools/call", StringComparison.Ordinal) && + parameters.TryGetProperty("name", out var nameProperty)) + { + var toolName = nameProperty.GetString(); + var arguments = TryGetArguments(parameters, out var argumentsValue) + ? argumentsValue + : null; + + proxiedRequest = (method, null, toolName, arguments); + return !string.IsNullOrWhiteSpace(toolName); + } + + proxiedRequest = (method, null, null, null); + return true; +} + +static bool TryGetArguments(JsonElement parameters, out IReadOnlyDictionary? arguments) +{ + arguments = null; + + if (!parameters.TryGetProperty("arguments", out var argumentsProperty) || + argumentsProperty.ValueKind is JsonValueKind.Null or JsonValueKind.Undefined) + { + return false; + } + + if (argumentsProperty.ValueKind != JsonValueKind.Object) + { + return false; + } + + using var document = JsonDocument.Parse(argumentsProperty.GetRawText()); + arguments = JsonSerializer.Deserialize>(document.RootElement.GetRawText()); + return arguments is not null; +} \ No newline at end of file diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Properties/launchSettings.json b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Properties/launchSettings.json new file mode 100644 index 0000000000..2bac1b9426 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5253", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7047;http://localhost:5253", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Server.csproj b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Server.csproj new file mode 100644 index 0000000000..d7da8e3f8e --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/Server.csproj @@ -0,0 +1,22 @@ + + + + Exe + net10.0 + enable + enable + 24653264-bb7f-4e9f-84ed-965c80233300 + + + + + + + + + + + + + + diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/appsettings.Development.json b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/appsettings.Development.json new file mode 100644 index 0000000000..0c208ae918 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/appsettings.json b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/appsettings.json new file mode 100644 index 0000000000..10f68b8c8b --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Server/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/ConformanceTests.cs b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/ConformanceTests.cs new file mode 100644 index 0000000000..b58956fdf4 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/ConformanceTests.cs @@ -0,0 +1,624 @@ +// Copyright (c) Microsoft. All rights reserved. + +// AG-UI MCP App Host Conformance Tests +// Verifies integration-level concerns that cannot be covered by unit tests: +// 1. The HTTP response carries Content-Type: text/event-stream (hosting layer). +// 2. An actual LLM routes "What time is it?" to the get-time MCP tool (E2E routing). +// 3. Proxied MCP resources/read and tools/call requests are handled without invoking the agent. +// +// All protocol-level output behaviour (event ordering, field values, wire format) is +// covered by the unit tests in Microsoft.Agents.AI.AGUI.UnitTests. +// +// Environment variables: +// AG_UI_HOST - URL of the AG-UI host under test (default: http://localhost:5253) +// AG_UI_AGENT_ID - Override the auto-detected agent ID used in the CopilotKit envelope. +// When absent the format is detected automatically on the first request. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using xRetry.v3; +using Xunit; + +namespace Step06_McpApps.Tests; + +public sealed class ConformanceTests +{ + private const string SkipConformanceReason = "Conformance tests are skipped during regular dotnet test runs."; + + /// URL of the AG-UI host under test. + private static readonly string s_agUiHost = System.Environment.GetEnvironmentVariable("AG_UI_HOST") ?? "http://localhost:5253"; + + /// Resource URI exposed by the get-time MCP App. + private const string GetTimeResourceUri = "ui://get-time.html"; + + /// Tool name exposed by the MCP server and used by the MCP App. + private const string GetTimeToolName = "get-time"; + + /// Expected MIME type for MCP App resources. + private const string McpAppMimeType = "text/html;profile=mcp-app"; + + /// Per-test timeout. LLM + MCP tool round-trips can be slow. + private static readonly TimeSpan s_testTimeout = TimeSpan.FromSeconds(60); + + /// Network operation timeout so hung SSE/HTTP work fails instead of idling. + private static readonly TimeSpan s_operationTimeout = TimeSpan.FromSeconds(20); + + private static readonly HttpClient s_httpClient = new(); + + private static readonly string[] s_expectedProxyEventSequence = ["RUN_STARTED", "RUN_FINISHED"]; + + // --------------------------------------------------------------------------- + // CancellationTokenSource factory + // --------------------------------------------------------------------------- + + /// + /// Creates a that cancels on whichever comes first: + /// expiring, or the test runner signalling shutdown (Ctrl+C, etc.). + /// Using a linked source ensures tests abort immediately when the runner is cancelled, + /// rather than waiting for the full timeout to elapse. + /// + private static CancellationTokenSource CreateLinkedCts(TimeSpan timeout) + { + // Link to the framework token so Ctrl+C cancels us immediately. + var cts = CancellationTokenSource.CreateLinkedTokenSource( + TestContext.Current.CancellationToken); + // Also cancel after the per-test wall-clock limit. + cts.CancelAfter(timeout); + return cts; + } + + // --------------------------------------------------------------------------- + // Request-format detection — plain AG-UI vs. CopilotKit envelope + // --------------------------------------------------------------------------- + + /// + /// Cached task that resolves to the agent ID to use in the CopilotKit envelope, or + /// when the endpoint accepts plain AG-UI bodies directly. + /// Detected by probing the endpoint once; variable + /// AG_UI_AGENT_ID overrides detection. + /// + private static Task? s_agentIdTask; + private static readonly object s_agentIdLock = new(); + + private static Task GetAgentIdAsync(CancellationToken cancellationToken) + { + // Explicit override always wins — no probe needed. + var overrideId = System.Environment.GetEnvironmentVariable("AG_UI_AGENT_ID"); + if (overrideId is not null) + { + return Task.FromResult(overrideId); + } + + lock (s_agentIdLock) + { + // Reuse a running or successfully completed detection; restart if cancelled/faulted. + if (s_agentIdTask is { IsCompleted: false } or { IsCompletedSuccessfully: true }) + { + return s_agentIdTask; + } + + return s_agentIdTask = DetectAgentIdAsync(cancellationToken); + } + } + + /// + /// Probes with a minimal direct-format POST. + /// + /// Plain AG-UI server → 200 text/event-stream → returns (use direct format). + /// Non-success response (for example CopilotKit returning 400 "Missing method field") → returns "default" (use envelope). + /// + /// + private static async Task DetectAgentIdAsync(CancellationToken cancellationToken) + { + // Use an empty messages array so the probe does not trigger a real LLM call. + var probeJson = JsonSerializer.Serialize(new + { + threadId = "format-probe", + runId = "format-probe", + messages = Array.Empty(), + tools = Array.Empty(), + context = Array.Empty(), + state = new { }, + forwardedProps = new { } + }); + + using var request = new HttpRequestMessage(HttpMethod.Post, s_agUiHost) + { + Content = new StringContent(probeJson, Encoding.UTF8, "application/json") + }; + request.Headers.Accept.ParseAdd("text/event-stream"); + + // Read headers only — we only need the status code and content-type. + using var response = await s_httpClient.SendAsync( + request, HttpCompletionOption.ResponseHeadersRead, cancellationToken) + .WaitAsync(s_operationTimeout, cancellationToken); + + // 200 text/event-stream → plain AG-UI server. + if (response.IsSuccessStatusCode) + { + return null; + } + + // Any non-success response falls back to CopilotKit-style envelope mode; + // "default" is the standard agent ID. + return "default"; + } + + // --------------------------------------------------------------------------- + // MCP server info — auto-discovered once from ACTIVITY_SNAPSHOT + // --------------------------------------------------------------------------- + + /// + /// Cached task for MCP server identity (serverHash + serverId). Resolved on first access by + /// running the agent once and extracting the values from the ACTIVITY_SNAPSHOT event. + /// Only needed for hosts that validate server identity in proxied requests (e.g. CopilotKit). + /// A cancelled or faulted task is discarded so the next caller can retry. + /// + private static Task<(string Hash, string Id)>? s_mcpServerInfoTask; + private static readonly object s_mcpServerInfoLock = new(); + + private static Task<(string Hash, string Id)> GetMcpServerInfoAsync(CancellationToken cancellationToken) + { + lock (s_mcpServerInfoLock) + { + // Reuse a running or successfully completed discovery; discard cancelled/faulted ones. + if (s_mcpServerInfoTask is { IsCompleted: false } or { IsCompletedSuccessfully: true }) + { + return s_mcpServerInfoTask; + } + + return s_mcpServerInfoTask = DiscoverMcpServerInfoAsync(cancellationToken); + } + } + + /// + /// Runs the agent with a time query and extracts serverHash/serverId from the + /// resulting ACTIVITY_SNAPSHOT. Retries up to 3 times in case the LLM doesn't call + /// the tool on the first attempt. + /// + private static async Task<(string Hash, string Id)> DiscoverMcpServerInfoAsync( + CancellationToken cancellationToken) + { + for (int attempt = 0; attempt < 3; attempt++) + { + cancellationToken.ThrowIfCancellationRequested(); + var (_, events) = await SendAgUiRequestAsync( + BuildAgentRunBody("what time is it?"), cancellationToken); + + foreach (var evt in events) + { + if (GetEventType(evt) != "ACTIVITY_SNAPSHOT") { continue; } + if (!evt.TryGetProperty("content", out var content)) { continue; } + + var hash = content.TryGetProperty("serverHash", out var h) ? h.GetString() ?? "" : ""; + var id = content.TryGetProperty("serverId", out var s) ? s.GetString() ?? "" : ""; + + if (!string.IsNullOrEmpty(hash)) + { + return (hash, id); + } + } + } + + // No ACTIVITY_SNAPSHOT found — return empty strings; tests will fail with a clear message. + return ("", ""); + } + + // --------------------------------------------------------------------------- + // Request building + // --------------------------------------------------------------------------- + + /// + /// Serialises as the AG-UI request payload. Wraps it in the + /// CopilotKit envelope when is non-null. + /// + private static string SerializePayload(object body, string? agentId) + { + var bodyJson = JsonSerializer.Serialize(body); + + if (agentId is null) + { + return bodyJson; + } + + // Embed the pre-serialized body as a raw JsonElement so it is not double-serialized. + using var doc = JsonDocument.Parse(bodyJson); + return JsonSerializer.Serialize(new + { + method = "agent/run", + @params = new { agentId }, + body = doc.RootElement + }); + } + + private static object BuildAgentRunBody(string userContent) => new + { + threadId = Guid.NewGuid().ToString(), + runId = Guid.NewGuid().ToString(), + messages = new[] { new { id = Guid.NewGuid().ToString(), role = "user", content = userContent } }, + tools = Array.Empty(), + context = Array.Empty(), + state = new { }, + forwardedProps = new { } + }; + + private static object BuildProxiedReadBody(string resourceUri, string threadId, string runId, + string serverHash, string serverId) => + BuildProxiedBody( + threadId, + runId, + serverHash, + serverId, + "resources/read", + new { uri = resourceUri }); + + private static object BuildProxiedToolCallBody(string toolName, string threadId, string runId, + string serverHash, string serverId) => + BuildProxiedBody( + threadId, + runId, + serverHash, + serverId, + "tools/call", + new { name = toolName, arguments = new { } }); + + private static object BuildProxiedBody(string threadId, string runId, string serverHash, + string serverId, string method, object parameters) => new + { + threadId, + runId, + messages = BuildCompletedTimeConversation(), + tools = Array.Empty(), + context = Array.Empty(), + state = new { }, + forwardedProps = new + { + __proxiedMCPRequest = new + { + serverHash, + serverId, + method, + @params = parameters + } + } + }; + + private static object[] BuildCompletedTimeConversation() => + [ + new { id = Guid.NewGuid().ToString(), role = "user", content = "what time is it?" }, + new + { + id = Guid.NewGuid().ToString(), + role = "assistant", + toolCalls = new[] + { + new { id = "call_test", type = "function", function = new { name = GetTimeToolName, arguments = "{}" } } + } + }, + new + { + id = Guid.NewGuid().ToString(), + toolCallId = "call_test", + role = "tool", + content = DateTimeOffset.UtcNow.ToString("o") + } + ]; + + // --------------------------------------------------------------------------- + // HTTP helpers + // --------------------------------------------------------------------------- + + private static async Task SendAgUiRequestForHeadersAsync( + object body, + CancellationToken cancellationToken) + { + var agentId = await GetAgentIdAsync(cancellationToken); + + using var request = new HttpRequestMessage(HttpMethod.Post, s_agUiHost) + { + Content = new StringContent(SerializePayload(body, agentId), Encoding.UTF8, "application/json") + }; + request.Headers.Accept.ParseAdd("text/event-stream"); + + using var response = await s_httpClient.SendAsync( + request, HttpCompletionOption.ResponseHeadersRead, cancellationToken) + .WaitAsync(s_operationTimeout, cancellationToken); + + return response.Content.Headers.ContentType?.ToString() ?? ""; + } + + private static async Task<(string ContentType, List Events)> SendAgUiRequestAsync( + object body, + CancellationToken cancellationToken) + { + var agentId = await GetAgentIdAsync(cancellationToken); + + using var request = new HttpRequestMessage(HttpMethod.Post, s_agUiHost) + { + Content = new StringContent(SerializePayload(body, agentId), Encoding.UTF8, "application/json") + }; + request.Headers.Accept.ParseAdd("text/event-stream"); + + using var response = await s_httpClient.SendAsync( + request, HttpCompletionOption.ResponseHeadersRead, cancellationToken) + .WaitAsync(s_operationTimeout, cancellationToken); + + var contentType = response.Content.Headers.ContentType?.ToString() ?? ""; + var events = await CollectSseEventsAsync(response, cancellationToken); + return (contentType, events); + } + + private static async Task> CollectSseEventsAsync( + HttpResponseMessage response, + CancellationToken cancellationToken) + { + var events = new List(); + await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken); + using var reader = new StreamReader(stream); + + string? line; + while ((line = await reader.ReadLineAsync(cancellationToken) + .AsTask() + .WaitAsync(s_operationTimeout, cancellationToken)) is not null) + { + if (!line.StartsWith("data: ", StringComparison.Ordinal)) + { + continue; + } + + var payload = line[6..].Trim(); + if (string.IsNullOrEmpty(payload) || payload == "[DONE]") + { + continue; + } + + try + { + var evt = JsonDocument.Parse(payload).RootElement.Clone(); + events.Add(evt); + + if (IsTerminalEvent(evt)) + { + break; + } + } + catch (JsonException) { /* skip non-JSON lines */ } + } + + return events; + } + + private static string GetEventType(JsonElement evt) + => evt.TryGetProperty("type", out var t) ? t.GetString() ?? "" : ""; + + private static bool IsTerminalEvent(JsonElement evt) + => GetEventType(evt) is "RUN_FINISHED" or "RUN_ERROR"; + + private static string EventSequence(List events) + => string.Join(", ", events.Select(GetEventType)); + + private static async Task> RunProxiedReadAsync( + string resourceUri, string threadId, string runId, CancellationToken cancellationToken) + { + var (serverHash, serverId) = await GetMcpServerInfoAsync(cancellationToken); + var (_, events) = await SendAgUiRequestAsync( + BuildProxiedReadBody(resourceUri, threadId, runId, serverHash, serverId), + cancellationToken); + return events; + } + + private static async Task> RunProxiedToolCallAsync( + string toolName, string threadId, string runId, CancellationToken cancellationToken) + { + var (serverHash, serverId) = await GetMcpServerInfoAsync(cancellationToken); + var (_, events) = await SendAgUiRequestAsync( + BuildProxiedToolCallBody(toolName, threadId, runId, serverHash, serverId), + cancellationToken); + return events; + } + + private static string GetRequiredToolCallId(List events, string toolCallName) + { + int startIdx = events.FindIndex( + e => GetEventType(e) == "TOOL_CALL_START" && + e.TryGetProperty("toolCallName", out var n) && n.GetString() == toolCallName); + + Assert.True(startIdx >= 0, + $"Expected a TOOL_CALL_START with toolCallName \"{toolCallName}\". Full sequence: {EventSequence(events)}"); + Assert.True( + events[startIdx].TryGetProperty("toolCallId", out var idProp) && + !string.IsNullOrEmpty(idProp.GetString()), + "TOOL_CALL_START must carry a toolCallId"); + + return idProp.GetString()!; + } + + // --------------------------------------------------------------------------- + // Conformance tests — agent / HTTP layer + // --------------------------------------------------------------------------- + + [Fact(Skip = SkipConformanceReason)] + public async Task HttpResponse_HasContentType_TextEventStreamAsync() + { + using var cts = CreateLinkedCts(s_testTimeout); + var contentType = await SendAgUiRequestForHeadersAsync(BuildAgentRunBody("ping"), cts.Token); + + Assert.Contains("text/event-stream", contentType, StringComparison.OrdinalIgnoreCase); + } + + [RetryFact(3, Skip = SkipConformanceReason)] + public async Task AskingWhatTimeIsIt_CausesToolCallStart_ForGetTime_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var (_, events) = await SendAgUiRequestAsync(BuildAgentRunBody("What time is it?"), cts.Token); + Assert.NotEmpty(events); + + _ = GetRequiredToolCallId(events, "get-time"); + } + + // --------------------------------------------------------------------------- + // Conformance tests — proxied MCP resource reads + // --------------------------------------------------------------------------- + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedResourceRead_EmitsOnlyRunStartedAndRunFinished_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var events = await RunProxiedReadAsync( + GetTimeResourceUri, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), cts.Token); + + Assert.NotEmpty(events); + Assert.Equal(s_expectedProxyEventSequence, events.ConvertAll(GetEventType)); + } + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedResourceRead_RunFinished_HasResultContents_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var events = await RunProxiedReadAsync( + GetTimeResourceUri, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), cts.Token); + + var runFinished = events.Single(e => GetEventType(e) == "RUN_FINISHED"); + Assert.True( + runFinished.TryGetProperty("result", out var result) && + result.TryGetProperty("contents", out var contents) && + contents.GetArrayLength() > 0, + $"RUN_FINISHED must have result.contents with at least one entry. Event: {runFinished}"); + } + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedResourceRead_RunFinished_ResourceUri_MatchesRequest_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var events = await RunProxiedReadAsync( + GetTimeResourceUri, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), cts.Token); + + var firstContent = events.Single(e => GetEventType(e) == "RUN_FINISHED") + .GetProperty("result").GetProperty("contents")[0]; + + Assert.True( + firstContent.TryGetProperty("uri", out var uriProp) && + uriProp.GetString() == GetTimeResourceUri, + $"result.contents[0].uri must equal \"{GetTimeResourceUri}\". Got: {firstContent}"); + } + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedResourceRead_RunFinished_MimeType_IsMcpApp_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var events = await RunProxiedReadAsync( + GetTimeResourceUri, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), cts.Token); + + var firstContent = events.Single(e => GetEventType(e) == "RUN_FINISHED") + .GetProperty("result").GetProperty("contents")[0]; + + Assert.True( + firstContent.TryGetProperty("mimeType", out var mimeTypeProp) && + mimeTypeProp.GetString() == McpAppMimeType, + $"result.contents[0].mimeType must equal \"{McpAppMimeType}\". Got: {firstContent}"); + } + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedResourceRead_RunFinished_ResourceText_IsNonEmpty_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var events = await RunProxiedReadAsync( + GetTimeResourceUri, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), cts.Token); + + var firstContent = events.Single(e => GetEventType(e) == "RUN_FINISHED") + .GetProperty("result").GetProperty("contents")[0]; + + Assert.True( + firstContent.TryGetProperty("text", out var textProp) && + !string.IsNullOrWhiteSpace(textProp.GetString()), + $"result.contents[0].text must be non-empty HTML. Got: {firstContent}"); + } + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedResourceRead_RunFinished_EchoesRunId_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var runId = Guid.NewGuid().ToString(); + + var events = await RunProxiedReadAsync( + GetTimeResourceUri, Guid.NewGuid().ToString(), runId, cts.Token); + + var runFinished = events.Single(e => GetEventType(e) == "RUN_FINISHED"); + Assert.True( + runFinished.TryGetProperty("runId", out var runIdProp) && + runIdProp.GetString() == runId, + $"RUN_FINISHED.runId must echo the request runId \"{runId}\". Got: {runFinished}"); + } + + // --------------------------------------------------------------------------- + // Conformance tests — proxied MCP tool calls from loaded MCP apps + // --------------------------------------------------------------------------- + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedToolCall_EmitsOnlyRunStartedAndRunFinished_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var events = await RunProxiedToolCallAsync( + GetTimeToolName, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), cts.Token); + + Assert.NotEmpty(events); + Assert.Equal(s_expectedProxyEventSequence, events.ConvertAll(GetEventType)); + } + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedToolCall_RunFinished_HasResultContent_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var events = await RunProxiedToolCallAsync( + GetTimeToolName, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), cts.Token); + + var runFinished = events.Single(e => GetEventType(e) == "RUN_FINISHED"); + Assert.True( + runFinished.TryGetProperty("result", out var result) && + result.TryGetProperty("content", out var content) && + content.ValueKind == JsonValueKind.Array && + content.GetArrayLength() > 0, + $"RUN_FINISHED must have result.content with at least one entry. Event: {runFinished}"); + } + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedToolCall_RunFinished_ResultContainsTextContent_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var events = await RunProxiedToolCallAsync( + GetTimeToolName, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), cts.Token); + + var firstContent = events.Single(e => GetEventType(e) == "RUN_FINISHED") + .GetProperty("result").GetProperty("content")[0]; + + Assert.True( + firstContent.TryGetProperty("type", out var typeProp) && + typeProp.GetString() == "text" && + firstContent.TryGetProperty("text", out var textProp) && + !string.IsNullOrWhiteSpace(textProp.GetString()), + $"result.content[0] must be a non-empty text block. Got: {firstContent}"); + } + + [Fact(Skip = SkipConformanceReason)] + public async Task ProxiedToolCall_RunFinished_EchoesRunId_Async() + { + using var cts = CreateLinkedCts(s_testTimeout); + var runId = Guid.NewGuid().ToString(); + + var events = await RunProxiedToolCallAsync( + GetTimeToolName, Guid.NewGuid().ToString(), runId, cts.Token); + + var runFinished = events.Single(e => GetEventType(e) == "RUN_FINISHED"); + Assert.True( + runFinished.TryGetProperty("runId", out var runIdProp) && + runIdProp.GetString() == runId, + $"RUN_FINISHED.runId must echo the request runId \"{runId}\". Got: {runFinished}"); + } +} diff --git a/dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/Tests.csproj b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/Tests.csproj new file mode 100644 index 0000000000..4f4cb37798 --- /dev/null +++ b/dotnet/samples/02-agents/AGUI/Step06_McpApps/Tests/Tests.csproj @@ -0,0 +1,20 @@ + + + + Exe + net10.0 + true + true + + + + + + + + + + + + + diff --git a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIEventTypes.cs b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIEventTypes.cs index 1b8958cdf0..c656c2a46e 100644 --- a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIEventTypes.cs +++ b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIEventTypes.cs @@ -31,4 +31,6 @@ internal static class AGUIEventTypes public const string StateSnapshot = "STATE_SNAPSHOT"; public const string StateDelta = "STATE_DELTA"; + + public const string ActivitySnapshot = "ACTIVITY_SNAPSHOT"; } diff --git a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIJsonSerializerContext.cs b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIJsonSerializerContext.cs index b13a803625..df610f348b 100644 --- a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIJsonSerializerContext.cs +++ b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/AGUIJsonSerializerContext.cs @@ -46,6 +46,7 @@ namespace Microsoft.Agents.AI.AGUI; [JsonSerializable(typeof(ToolCallResultEvent))] [JsonSerializable(typeof(StateSnapshotEvent))] [JsonSerializable(typeof(StateDeltaEvent))] +[JsonSerializable(typeof(ActivitySnapshotEvent))] [JsonSerializable(typeof(IDictionary))] [JsonSerializable(typeof(Dictionary))] [JsonSerializable(typeof(IDictionary))] diff --git a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ActivitySnapshotEvent.cs b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ActivitySnapshotEvent.cs new file mode 100644 index 0000000000..e1774773d1 --- /dev/null +++ b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ActivitySnapshotEvent.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft. All rights reserved. + +using System.Text.Json; +using System.Text.Json.Serialization; + +#if ASPNETCORE +namespace Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.Shared; +#else +namespace Microsoft.Agents.AI.AGUI.Shared; +#endif + +internal sealed class ActivitySnapshotEvent : BaseEvent +{ + public ActivitySnapshotEvent() + { + this.Type = AGUIEventTypes.ActivitySnapshot; + } + + [JsonPropertyName("messageId")] + public string? MessageId { get; set; } + + [JsonPropertyName("activityType")] + public string ActivityType { get; set; } = string.Empty; + + [JsonPropertyName("replace")] + public bool Replace { get; set; } + + [JsonPropertyName("content")] + public JsonElement? Content { get; set; } +} diff --git a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/BaseEventJsonConverter.cs b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/BaseEventJsonConverter.cs index eca2131f23..ec7354d9a5 100644 --- a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/BaseEventJsonConverter.cs +++ b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/BaseEventJsonConverter.cs @@ -47,6 +47,7 @@ public override BaseEvent Read( AGUIEventTypes.ToolCallEnd => jsonElement.Deserialize(options.GetTypeInfo(typeof(ToolCallEndEvent))) as ToolCallEndEvent, AGUIEventTypes.ToolCallResult => jsonElement.Deserialize(options.GetTypeInfo(typeof(ToolCallResultEvent))) as ToolCallResultEvent, AGUIEventTypes.StateSnapshot => jsonElement.Deserialize(options.GetTypeInfo(typeof(StateSnapshotEvent))) as StateSnapshotEvent, + AGUIEventTypes.ActivitySnapshot => jsonElement.Deserialize(options.GetTypeInfo(typeof(ActivitySnapshotEvent))) as ActivitySnapshotEvent, _ => throw new JsonException($"Unknown BaseEvent type discriminator: '{discriminator}'") }; @@ -102,6 +103,9 @@ public override void Write( case StateDeltaEvent stateDelta: JsonSerializer.Serialize(writer, stateDelta, options.GetTypeInfo(typeof(StateDeltaEvent))); break; + case ActivitySnapshotEvent activitySnapshot: + JsonSerializer.Serialize(writer, activitySnapshot, options.GetTypeInfo(typeof(ActivitySnapshotEvent))); + break; default: throw new InvalidOperationException($"Unknown event type: {value.GetType().Name}"); } diff --git a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs index b11475ddfc..31ad1b4d40 100644 --- a/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.AGUI/Shared/ChatResponseUpdateAGUIExtensions.cs @@ -7,6 +7,7 @@ using System.Runtime.CompilerServices; using System.Text; using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.AI; @@ -88,6 +89,11 @@ public static async IAsyncEnumerable AsChatResponseUpdatesAs yield return CreateStateDeltaUpdate(stateDelta, conversationId, responseId, jsonSerializerOptions); } break; + + // Activity snapshot events (e.g. MCP App tool results) + case ActivitySnapshotEvent activitySnapshot when activitySnapshot.Content.HasValue: + yield return CreateActivitySnapshotUpdate(activitySnapshot, conversationId, responseId, jsonSerializerOptions); + break; } } } @@ -140,6 +146,30 @@ private static ChatResponseUpdate CreateStateDeltaUpdate( }; } + private static ChatResponseUpdate CreateActivitySnapshotUpdate( + ActivitySnapshotEvent activitySnapshot, + string? conversationId, + string? responseId, + JsonSerializerOptions jsonSerializerOptions) + { + byte[] jsonBytes = JsonSerializer.SerializeToUtf8Bytes( + activitySnapshot.Content!.Value, + jsonSerializerOptions.GetTypeInfo(typeof(JsonElement))); + DataContent dataContent = new(jsonBytes, "application/json"); + + return new ChatResponseUpdate(ChatRole.Assistant, [dataContent]) + { + ConversationId = conversationId, + ResponseId = responseId, + CreatedAt = DateTimeOffset.UtcNow, + AdditionalProperties = new AdditionalPropertiesDictionary + { + ["is_activity_snapshot"] = true, + ["activity_type"] = activitySnapshot.ActivityType + } + }; + } + private sealed class TextMessageBuilder() { private ChatRole _currentRole; @@ -342,6 +372,7 @@ public static async IAsyncEnumerable AsAGUIEventStreamAsync( string? currentMessageId = null; string? streamingMessageId = null; + var toolArgsByCallId = new Dictionary(StringComparer.Ordinal); await foreach (var chatResponse in updates.WithCancellation(cancellationToken).ConfigureAwait(false)) { // Generate a fallback MessageId when the provider doesn't supply one. @@ -400,12 +431,15 @@ chatResponse.Contents[0] is TextContent && ParentMessageId = chatResponse.MessageId }; + var argsJson = JsonSerializer.Serialize( + functionCallContent.Arguments, + jsonSerializerOptions.GetTypeInfo(typeof(IDictionary))); + toolArgsByCallId[functionCallContent.CallId] = argsJson; + yield return new ToolCallArgsEvent { ToolCallId = functionCallContent.CallId, - Delta = JsonSerializer.Serialize( - functionCallContent.Arguments, - jsonSerializerOptions.GetTypeInfo(typeof(IDictionary))) + Delta = argsJson }; yield return new ToolCallEndEvent @@ -415,13 +449,23 @@ chatResponse.Contents[0] is TextContent && } else if (content is FunctionResultContent functionResultContent) { + var resultContent = SerializeResultContent(functionResultContent, jsonSerializerOptions) ?? ""; + yield return new ToolCallResultEvent { MessageId = chatResponse.MessageId, ToolCallId = functionResultContent.CallId, - Content = SerializeResultContent(functionResultContent, jsonSerializerOptions) ?? "", + Content = resultContent, Role = AGUIRoles.Tool }; + + if (functionResultContent.Result is AIContent aic && GetToolMetadata(aic) is JsonObject toolMetadata) + { + toolArgsByCallId.TryGetValue(functionResultContent.CallId, out var toolInputJson); + toolArgsByCallId.Remove(functionResultContent.CallId); + var resourceUri = toolMetadata["ui"]?["resourceUri"]?.ToString() ?? string.Empty; + yield return BuildActivitySnapshot(chatResponse.MessageId, resourceUri, resultContent, toolInputJson ?? "{}", jsonSerializerOptions); + } } else if (content is DataContent dataContent) { @@ -498,8 +542,142 @@ chatResponse.Contents[0] is TextContent && { null => null, string str => str, + TextContent textContent => JsonSerializer.Serialize(textContent.Text ?? string.Empty, options.GetTypeInfo(typeof(string))), JsonElement jsonElement => jsonElement.GetRawText(), _ => JsonSerializer.Serialize(functionResultContent.Result, options.GetTypeInfo(functionResultContent.Result.GetType())), }; } + + private static JsonObject? GetToolMetadata(AIContent content) + { + return content.AdditionalProperties?["ToolMetadata"] as JsonObject; + } + + /// + /// Builds an for an MCP App tool result. + /// The content.result is normalized to a {"content":[...]} structure so that + /// clients always receive a consistent MCP CallToolResult shape. + /// + private static ActivitySnapshotEvent BuildActivitySnapshot( + string? messageId, + string resourceUri, + string resultContent, + string toolInputJson, + JsonSerializerOptions options) + { + // Normalize the tool result into {"content":[...]} form. + string normalizedResult = NormalizeToCallToolResult(resultContent, options); + + // Inline-build the content JSON to avoid allocating intermediate objects. + string encodedResourceUri = JsonSerializer.Serialize(resourceUri, options.GetTypeInfo(typeof(string))); + string contentJson = + $"{{\"resourceUri\":{encodedResourceUri}," + + $"\"result\":{normalizedResult}," + + $"\"toolInput\":{toolInputJson}}}"; + + var contentElement = (JsonElement?)JsonSerializer.Deserialize( + contentJson, + options.GetTypeInfo(typeof(JsonElement))); + + return new ActivitySnapshotEvent + { + MessageId = messageId, + ActivityType = "mcp-apps", + Replace = true, + Content = contentElement + }; + } + + /// + /// Ensures the raw tool result string has the shape {"content":[{"type":"text","text":"..."}]} + /// expected by clients. Handles the case where the MCP SDK strips the "type" discriminator when + /// converting TextContentBlock into Microsoft.Extensions.AI.TextContent. + /// + private static string NormalizeToCallToolResult(string raw, JsonSerializerOptions options) + { + if (string.IsNullOrEmpty(raw)) + { + return "{\"content\":[]}"; + } + + try + { + using var doc = JsonDocument.Parse(raw); + var root = doc.RootElement; + + // CallToolResult-like object with a content array. + // Validate that every item carries a "type" discriminator before returning as-is; + // the MCP SDK may strip the discriminator when mapping TextContentBlock → + // Microsoft.Extensions.AI.TextContent, producing {"content":[{"text":"..."}]}. + if (root.ValueKind == JsonValueKind.Object && + root.TryGetProperty("content", out var existing) && + existing.ValueKind == JsonValueKind.Array) + { + bool needsNormalization = false; + foreach (var item in existing.EnumerateArray()) + { + if (item.ValueKind != JsonValueKind.Object || !item.TryGetProperty("type", out _)) + { + needsNormalization = true; + break; + } + } + + if (!needsNormalization) + { + return raw; + } + + // Rebuild the content array, injecting "type":"text" for any text-only items. + var sb = new StringBuilder("{\"content\":["); + bool first = true; + foreach (var item in existing.EnumerateArray()) + { + if (!first) { sb.Append(','); } + first = false; + + if (item.ValueKind == JsonValueKind.Object && + !item.TryGetProperty("type", out _) && + item.TryGetProperty("text", out var itemTextProp) && + itemTextProp.ValueKind == JsonValueKind.String) + { + string encodedText = JsonSerializer.Serialize(itemTextProp.GetString(), options.GetTypeInfo(typeof(string))); + sb.Append($"{{\"type\":\"text\",\"text\":{encodedText}}}"); + } + else + { + sb.Append(item.GetRawText()); + } + } + sb.Append("]}"); + return sb.ToString(); + } + + // Single object with a "text" property (Microsoft.Extensions.AI TextContent — type stripped). + // Reconstruct as a proper MCP text content block. + if (root.ValueKind == JsonValueKind.Object && + root.TryGetProperty("text", out var textProp) && + textProp.ValueKind == JsonValueKind.String) + { + string encodedText = JsonSerializer.Serialize(textProp.GetString(), options.GetTypeInfo(typeof(string))); + return $"{{\"content\":[{{\"type\":\"text\",\"text\":{encodedText}}}]}}"; + } + + // JSON string — SerializeResultContent encodes string/TextContent results as a JSON string. + if (root.ValueKind == JsonValueKind.String) + { + string encodedText = JsonSerializer.Serialize(root.GetString(), options.GetTypeInfo(typeof(string))); + return $"{{\"content\":[{{\"type\":\"text\",\"text\":{encodedText}}}]}}"; + } + + // Any other single JSON value — wrap it. + return $"{{\"content\":[{raw}]}}"; + } + catch (JsonException) + { + // Plain string — wrap as a text content block. + string encodedRaw = JsonSerializer.Serialize(raw, options.GetTypeInfo(typeof(string))); + return $"{{\"content\":[{{\"type\":\"text\",\"text\":{encodedRaw}}}]}}"; + } + } } diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs index e20d1ab448..83ccde105d 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs @@ -1,9 +1,12 @@ // Copyright (c) Microsoft. All rights reserved. +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Text.Json; using System.Threading; +using System.Threading.Tasks; using Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.Shared; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; @@ -21,6 +24,17 @@ namespace Microsoft.Agents.AI.Hosting.AGUI.AspNetCore; /// public static class AGUIEndpointRouteBuilderExtensions { + /// + /// Resolves a proxied AG-UI result from forwarded properties. + /// + /// The forwarded properties from the AG-UI request. + /// The cancellation token. + /// + /// A proxied result payload for RUN_FINISHED.result, or to + /// continue through the normal agent execution path. + /// + public delegate ValueTask ProxiedResultResolver(JsonElement forwardedProperties, CancellationToken cancellationToken); + /// /// Maps an AG-UI agent endpoint. /// @@ -32,6 +46,36 @@ public static IEndpointConventionBuilder MapAGUI( this IEndpointRouteBuilder endpoints, [StringSyntax("route")] string pattern, AIAgent aiAgent) + { + return MapAGUIInternal(endpoints, pattern, aiAgent, null); + } + + /// + /// Maps an AG-UI agent endpoint with optional proxied-result support. + /// + /// The endpoint route builder. + /// The URL pattern for the endpoint. + /// The agent instance. + /// + /// Optional delegate that resolves a proxied result from + /// when forwarded properties are present. + /// + /// An for the mapped endpoint. + public static IEndpointConventionBuilder MapAGUI( + this IEndpointRouteBuilder endpoints, + [StringSyntax("route")] string pattern, + AIAgent aiAgent, + ProxiedResultResolver proxiedResultResolver) + { + ArgumentNullException.ThrowIfNull(proxiedResultResolver); + return MapAGUIInternal(endpoints, pattern, aiAgent, proxiedResultResolver); + } + + private static RouteHandlerBuilder MapAGUIInternal( + IEndpointRouteBuilder endpoints, + [StringSyntax("route")] string pattern, + AIAgent aiAgent, + ProxiedResultResolver? proxiedResultResolver) { return endpoints.MapPost(pattern, async ([FromBody] RunAgentInput? input, HttpContext context, CancellationToken cancellationToken) => { @@ -43,6 +87,17 @@ public static IEndpointConventionBuilder MapAGUI( var jsonOptions = context.RequestServices.GetRequiredService>(); var jsonSerializerOptions = jsonOptions.Value.SerializerOptions; + if (proxiedResultResolver is not null && HasForwardedProperties(input.ForwardedProperties)) + { + var proxiedResult = await proxiedResultResolver(input.ForwardedProperties, cancellationToken).ConfigureAwait(false); + if (proxiedResult.HasValue) + { + var proxiedEvents = StreamProxiedReadEventsAsync(input.ThreadId, input.RunId, proxiedResult.Value); + var proxiedLogger = context.RequestServices.GetRequiredService>(); + return new AGUIServerSentEventsResult(proxiedEvents, proxiedLogger); + } + } + var messages = input.Messages.AsChatMessages(jsonSerializerOptions); var clientTools = input.Tools?.AsAITools().ToList(); @@ -80,4 +135,29 @@ public static IEndpointConventionBuilder MapAGUI( return new AGUIServerSentEventsResult(events, sseLogger); }); } + + private static async IAsyncEnumerable StreamProxiedReadEventsAsync( + string threadId, + string runId, + JsonElement proxiedResult) + { + yield return new RunStartedEvent + { + ThreadId = threadId, + RunId = runId, + }; + + yield return new RunFinishedEvent + { + ThreadId = threadId, + RunId = runId, + Result = proxiedResult, + }; + + await Task.CompletedTask.ConfigureAwait(false); + } + + private static bool HasForwardedProperties(JsonElement forwardedProperties) => + forwardedProperties.ValueKind == JsonValueKind.Object && + forwardedProperties.EnumerateObject().MoveNext(); } diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/EmitToolMetadataMiddleware.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/EmitToolMetadataMiddleware.cs new file mode 100644 index 0000000000..e0ed926219 --- /dev/null +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/EmitToolMetadataMiddleware.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft. All rights reserved. + +using System; +using System.Collections.Generic; +using System.Text.Json.Nodes; +using Microsoft.Extensions.AI; + +namespace Microsoft.Agents.AI.Hosting.AGUI.AspNetCore; + +/// +/// This middleware enriches tool result content with tool metadata. +/// +public static class EmitToolMetadataMiddleware +{ + /// + /// Enriches tool result contents with tool metadata (e.g. MCP Tool Meta). + /// + public static AIAgentBuilder UseEmitToolMetadata(this AIAgentBuilder agentBuilder, Dictionary metadata) + { + ArgumentNullException.ThrowIfNull(metadata); + return agentBuilder.Use(async (agent, context, next, cancel) => + { + var result = await next(context, cancel).ConfigureAwait(false); + if (result is AIContent content) + { + var toolMetadata = metadata.TryGetValue(context.Function.Name, out var meta) ? meta : null; + if (toolMetadata is not null) + { + content.AdditionalProperties ??= []; + if (!content.AdditionalProperties.ContainsKey("ToolMetadata")) + { + content.AdditionalProperties["ToolMetadata"] = toolMetadata; + } + else + { + throw new InvalidOperationException($"Result content of tool '{context.Function.Name}' already contains 'ToolMetadata' in AdditionalProperties."); + } + } + } + return result; + }); + } +} diff --git a/dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/ChatResponseUpdateAGUIExtensionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/ChatResponseUpdateAGUIExtensionsTests.cs index 7d40cc014d..b8f7ac74f0 100644 --- a/dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/ChatResponseUpdateAGUIExtensionsTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/ChatResponseUpdateAGUIExtensionsTests.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Agents.AI.AGUI.Shared; using Microsoft.Extensions.AI; @@ -777,4 +778,271 @@ public async Task StateDeltaEvent_RoundTrip_PreservesJsonPatchOperationsAsync() } #endregion State Delta Tests + + #region AsAGUIEventStreamAsync Protocol Conformance Tests + + // ---- Helpers ---- + + private static async Task> RunStreamAsync( + IEnumerable updates, + string threadId = "thread1", + string runId = "run1") + { + var events = new List(); + await foreach (BaseEvent evt in updates + .ToAsyncEnumerableAsync() + .AsAGUIEventStreamAsync(threadId, runId, AGUIJsonSerializerContext.Default.Options)) + { + events.Add(evt); + } + return events; + } + + /// Builds a tool-metadata JsonObject that points to a ui:// resource URI. + private static JsonObject BuildToolMetadata(string resourceUri) => + new() { ["ui"] = new JsonObject { ["resourceUri"] = resourceUri } }; + + // ---- Lifecycle ---- + + [Fact] + public async Task AsAGUIEventStreamAsync_FirstEvent_IsRunStartedAsync() + { + List events = await RunStreamAsync([]); + Assert.IsType(events[0]); + } + + [Fact] + public async Task AsAGUIEventStreamAsync_LastEvent_IsRunFinishedAsync() + { + List events = await RunStreamAsync([]); + Assert.IsType(events[^1]); + } + + [Fact] + public async Task AsAGUIEventStreamAsync_RunStartedEvent_EchoesThreadIdAndRunIdAsync() + { + List events = await RunStreamAsync([], "my-thread", "my-run"); + var runStarted = Assert.IsType(events[0]); + Assert.Equal("my-thread", runStarted.ThreadId); + Assert.Equal("my-run", runStarted.RunId); + } + + [Fact] + public async Task AsAGUIEventStreamAsync_RunFinishedEvent_EchoesThreadIdAndRunIdAsync() + { + List events = await RunStreamAsync([], "my-thread", "my-run"); + var runFinished = Assert.IsType(events[^1]); + Assert.Equal("my-thread", runFinished.ThreadId); + Assert.Equal("my-run", runFinished.RunId); + } + + [Fact] + public async Task AsAGUIEventStreamAsync_NormalFlow_ContainsNoRunErrorAsync() + { + List updates = + [ + new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("hi")]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + Assert.DoesNotContain(events, e => e is RunErrorEvent); + } + + // ---- Tool call ordering ---- + + [Fact] + public async Task AsAGUIEventStreamAsync_FunctionCallContent_EmitsToolCallStartArgsDeltaEndInOrderAsync() + { + var functionCall = new FunctionCallContent("call_1", "get-time", null); + List updates = + [ + new ChatResponseUpdate(ChatRole.Assistant, [functionCall]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + + int startIdx = events.FindIndex(e => e is ToolCallStartEvent); + int argsIdx = events.FindIndex(e => e is ToolCallArgsEvent); + int endIdx = events.FindIndex(e => e is ToolCallEndEvent); + + Assert.True(startIdx >= 0, "Expected TOOL_CALL_START"); + Assert.True(argsIdx > startIdx, "TOOL_CALL_ARGS must follow TOOL_CALL_START"); + Assert.True(endIdx > argsIdx, "TOOL_CALL_END must follow TOOL_CALL_ARGS"); + } + + [Fact] + public async Task AsAGUIEventStreamAsync_FunctionCallContent_ToolCallIdIsConsistentAcrossStartArgsDeltaEndAsync() + { + var functionCall = new FunctionCallContent("call_1", "get-time", null); + List updates = + [ + new ChatResponseUpdate(ChatRole.Assistant, [functionCall]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + + var start = events.OfType().Single(); + var args = events.OfType().Single(); + var end = events.OfType().Single(); + + Assert.Equal(start.ToolCallId, args.ToolCallId); + Assert.Equal(start.ToolCallId, end.ToolCallId); + } + + [Fact] + public async Task AsAGUIEventStreamAsync_FullToolCallSequence_ToolCallResultAppearsAfterToolCallEndAsync() + { + var functionCall = new FunctionCallContent("call_1", "get-time", null); + var functionResult = new FunctionResultContent("call_1", new TextContent("2026-04-10T18:00:00Z")); + List updates = + [ + new ChatResponseUpdate(ChatRole.Assistant, [functionCall]) { MessageId = "msg1" }, + new ChatResponseUpdate(ChatRole.Tool, [functionResult]) { MessageId = "msg2" } + ]; + List events = await RunStreamAsync(updates); + + int endIdx = events.FindIndex(e => e is ToolCallEndEvent); + int resultIdx = events.FindIndex(e => e is ToolCallResultEvent); + + Assert.True(endIdx >= 0, "Expected TOOL_CALL_END"); + Assert.True(resultIdx > endIdx, "TOOL_CALL_RESULT must come after TOOL_CALL_END"); + } + + // ---- TOOL_CALL_RESULT content format ---- + + [Fact] + public async Task AsAGUIEventStreamAsync_FunctionResultWithTextContent_ContentIsJsonEncodedStringAsync() + { + const string Timestamp = "2026-04-10T18:27:48Z"; + var functionResult = new FunctionResultContent("call_1", new TextContent(Timestamp)); + List updates = + [ + new ChatResponseUpdate(ChatRole.Tool, [functionResult]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + + ToolCallResultEvent result = events.OfType().Single(); + // TextContent is serialized as a JSON-encoded string so Content is always valid JSON. + using var doc = JsonDocument.Parse(result.Content!); + Assert.Equal(JsonValueKind.String, doc.RootElement.ValueKind); + Assert.Equal(Timestamp, doc.RootElement.GetString()); + } + + // ---- Activity snapshot ---- + + [Fact] + public async Task AsAGUIEventStreamAsync_FunctionResultWithToolMetadata_EmitsActivitySnapshotAfterResultAsync() + { + var textContent = new TextContent("2026-04-10T18:27:48Z") + { + AdditionalProperties = new() { ["ToolMetadata"] = BuildToolMetadata("ui://get-time.html") } + }; + var functionResult = new FunctionResultContent("call_1", textContent); + List updates = + [ + new ChatResponseUpdate(ChatRole.Tool, [functionResult]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + + int resultIdx = events.FindIndex(e => e is ToolCallResultEvent); + int snapshotIdx = events.FindIndex(e => e is ActivitySnapshotEvent); + + Assert.True(resultIdx >= 0, "Expected TOOL_CALL_RESULT"); + Assert.True(snapshotIdx > resultIdx, "ACTIVITY_SNAPSHOT must follow TOOL_CALL_RESULT"); + } + + [Fact] + public async Task AsAGUIEventStreamAsync_ActivitySnapshot_HasMcpAppsActivityTypeAndResourceUriAsync() + { + const string ResourceUri = "ui://get-time.html"; + var textContent = new TextContent("2026-04-10T18:27:48Z") + { + AdditionalProperties = new() { ["ToolMetadata"] = BuildToolMetadata(ResourceUri) } + }; + var functionResult = new FunctionResultContent("call_1", textContent); + List updates = + [ + new ChatResponseUpdate(ChatRole.Tool, [functionResult]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + + ActivitySnapshotEvent snapshot = Assert.IsType( + events.Single(e => e is ActivitySnapshotEvent)); + + Assert.Equal("mcp-apps", snapshot.ActivityType); + Assert.True(snapshot.Replace); + Assert.NotNull(snapshot.Content); + Assert.Equal(ResourceUri, snapshot.Content.Value.GetProperty("resourceUri").GetString()); + } + + [Fact] + public async Task AsAGUIEventStreamAsync_ActivitySnapshot_ResultContainsTextContentItemAsync() + { + const string Timestamp = "2026-04-10T18:27:48Z"; + const string ResourceUri = "ui://get-time.html"; + var textContent = new TextContent(Timestamp) + { + AdditionalProperties = new() { ["ToolMetadata"] = BuildToolMetadata(ResourceUri) } + }; + var functionResult = new FunctionResultContent("call_1", textContent); + List updates = + [ + new ChatResponseUpdate(ChatRole.Tool, [functionResult]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + + ActivitySnapshotEvent snapshot = (ActivitySnapshotEvent)events.Single(e => e is ActivitySnapshotEvent); + JsonElement resultContent = snapshot.Content!.Value + .GetProperty("result") + .GetProperty("content"); + + Assert.Equal(JsonValueKind.Array, resultContent.ValueKind); + JsonElement textItem = resultContent.EnumerateArray() + .First(i => i.TryGetProperty("type", out var t) && t.GetString() == "text"); + Assert.Equal(Timestamp, textItem.GetProperty("text").GetString()); + } + + // ---- Text message nesting ---- + + [Fact] + public async Task AsAGUIEventStreamAsync_TextContent_EmitsProperlyNestedTextMessageEventsAsync() + { + List updates = + [ + new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Hello")]) { MessageId = "msg1" }, + new ChatResponseUpdate(ChatRole.Assistant, [new TextContent(" World")]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + + int startIdx = events.FindIndex(e => e is TextMessageStartEvent); + int endIdx = events.FindLastIndex(e => e is TextMessageEndEvent); + + Assert.True(startIdx >= 0, "Expected TEXT_MESSAGE_START"); + Assert.True(endIdx > startIdx, "TEXT_MESSAGE_END must follow TEXT_MESSAGE_START"); + + for (int i = 0; i < events.Count; i++) + { + if (events[i] is TextMessageContentEvent) + { + Assert.True( + i > startIdx && i < endIdx, + $"TEXT_MESSAGE_CONTENT at index {i} is outside START ({startIdx}) / END ({endIdx})"); + } + } + } + + [Fact] + public async Task AsAGUIEventStreamAsync_TextContent_StartAndEndCountsMatchAsync() + { + List updates = + [ + new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("A")]) { MessageId = "msg1" }, + new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("B")]) { MessageId = "msg1" }, + new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("C")]) { MessageId = "msg1" } + ]; + List events = await RunStreamAsync(updates); + + int starts = events.Count(e => e is TextMessageStartEvent); + int ends = events.Count(e => e is TextMessageEndEvent); + Assert.Equal(starts, ends); + } + + #endregion AsAGUIEventStreamAsync Protocol Conformance Tests } diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs index 84a20e1938..7ff10730d6 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Net.Http; using System.Linq; using System.Text; using System.Text.Json; @@ -11,9 +12,12 @@ using System.Threading.Tasks; using Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.Shared; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.AI; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; @@ -387,6 +391,167 @@ public async Task MapAGUIAgent_ProducesCorrectSessionAndRunIds_InAllEventsAsync( Assert.Equal("test_run_456", runStarted.GetProperty("runId").GetString()); } + [Fact] + public async Task MapAGUIAgent_WithProxiedResultResolver_EmitsOnlyRunStartedAndRunFinishedAsync() + { + // Arrange + const string ThreadId = "proxy-thread"; + const string RunId = "proxy-run"; + int resolverCalls = 0; + int agentCalls = 0; + + await using TestServerHost host = await TestServerHost.CreateAsync( + new CountingAgent(() => agentCalls++), + async (forwardedProperties, cancellationToken) => + { + resolverCalls++; + Assert.Equal(JsonValueKind.Object, forwardedProperties.ValueKind); + Assert.Equal("resources/read", forwardedProperties.GetProperty("__proxiedMCPRequest").GetProperty("method").GetString()); + await Task.CompletedTask.ConfigureAwait(false); + using JsonDocument document = JsonDocument.Parse(""" + { + "contents": [ + { + "uri": "ui://get-time.html", + "mimeType": "text/html;profile=mcp-app", + "text": "" + } + ] + } + """); + return document.RootElement.Clone(); + }); + + using StringContent content = new(BuildRequestJson(ThreadId, RunId, forwardedPropsJson: """ + { + "__proxiedMCPRequest": { + "method": "resources/read", + "params": { "uri": "ui://get-time.html" } + } + } + """), Encoding.UTF8, "application/json"); + + // Act + HttpResponseMessage response = await host.Client.PostAsync(new Uri("/agent", UriKind.Relative), content); + response.EnsureSuccessStatusCode(); + string responseContent = await response.Content.ReadAsStringAsync(); + + // Assert + List events = ParseSseEvents(responseContent); + Assert.Equal(1, resolverCalls); + Assert.Equal(0, agentCalls); + Assert.Collection( + events, + evt => + { + Assert.Equal(AGUIEventTypes.RunStarted, evt.GetProperty("type").GetString()); + Assert.Equal(ThreadId, evt.GetProperty("threadId").GetString()); + Assert.Equal(RunId, evt.GetProperty("runId").GetString()); + }, + evt => + { + Assert.Equal(AGUIEventTypes.RunFinished, evt.GetProperty("type").GetString()); + Assert.Equal(ThreadId, evt.GetProperty("threadId").GetString()); + Assert.Equal(RunId, evt.GetProperty("runId").GetString()); + JsonElement result = evt.GetProperty("result"); + JsonElement contents = result.GetProperty("contents"); + Assert.Single(contents.EnumerateArray()); + JsonElement firstContent = contents[0]; + Assert.Equal("ui://get-time.html", firstContent.GetProperty("uri").GetString()); + }); + } + + [Fact] + public async Task MapAGUIAgent_WithEmptyForwardedProperties_DoesNotInvokeProxiedResultResolverAsync() + { + // Arrange + int resolverCalls = 0; + int agentCalls = 0; + + await using TestServerHost host = await TestServerHost.CreateAsync( + new CountingAgent(() => agentCalls++), + (forwardedProperties, cancellationToken) => + { + resolverCalls++; + return ValueTask.FromResult(null); + }); + + using StringContent content = new(BuildRequestJson("thread1", "run1", forwardedPropsJson: "{}"), Encoding.UTF8, "application/json"); + + // Act + HttpResponseMessage response = await host.Client.PostAsync(new Uri("/agent", UriKind.Relative), content); + response.EnsureSuccessStatusCode(); + string responseContent = await response.Content.ReadAsStringAsync(); + + // Assert + List events = ParseSseEvents(responseContent); + Assert.Equal(0, resolverCalls); + Assert.Equal(1, agentCalls); + Assert.Contains(events, static evt => evt.GetProperty("type").GetString() == AGUIEventTypes.TextMessageContent); + } + + [Fact] + public async Task MapAGUIAgent_WithoutForwardedProperties_DoesNotInvokeProxiedResultResolverAsync() + { + // Arrange + int resolverCalls = 0; + int agentCalls = 0; + + await using TestServerHost host = await TestServerHost.CreateAsync( + new CountingAgent(() => agentCalls++), + (forwardedProperties, cancellationToken) => + { + resolverCalls++; + return ValueTask.FromResult(null); + }); + + using StringContent content = new(BuildRequestJson("thread1", "run1"), Encoding.UTF8, "application/json"); + + // Act + HttpResponseMessage response = await host.Client.PostAsync(new Uri("/agent", UriKind.Relative), content); + response.EnsureSuccessStatusCode(); + string responseContent = await response.Content.ReadAsStringAsync(); + + // Assert + List events = ParseSseEvents(responseContent); + Assert.Equal(0, resolverCalls); + Assert.Equal(1, agentCalls); + Assert.Contains(events, static evt => evt.GetProperty("type").GetString() == AGUIEventTypes.RunFinished); + } + + [Fact] + public async Task MapAGUIAgent_WhenProxiedResultResolverReturnsNull_FallsBackToAgentAsync() + { + // Arrange + int resolverCalls = 0; + int agentCalls = 0; + + await using TestServerHost host = await TestServerHost.CreateAsync( + new CountingAgent(() => agentCalls++), + (forwardedProperties, cancellationToken) => + { + resolverCalls++; + return ValueTask.FromResult(null); + }); + + using StringContent content = new(BuildRequestJson("thread1", "run1", forwardedPropsJson: """ + { + "customProp": "value" + } + """), Encoding.UTF8, "application/json"); + + // Act + HttpResponseMessage response = await host.Client.PostAsync(new Uri("/agent", UriKind.Relative), content); + response.EnsureSuccessStatusCode(); + string responseContent = await response.Content.ReadAsStringAsync(); + + // Assert + List events = ParseSseEvents(responseContent); + Assert.Equal(1, resolverCalls); + Assert.Equal(1, agentCalls); + Assert.Contains(events, static evt => evt.GetProperty("type").GetString() == AGUIEventTypes.TextMessageContent); + } + private static List ParseSseEvents(string responseContent) { List events = []; @@ -420,6 +585,19 @@ private static List ParseSseEvents(string responseContent) return events; } + private static string BuildRequestJson(string threadId, string runId, string? forwardedPropsJson = null) + { + forwardedPropsJson ??= null; + + return $$""" + { + "threadId": "{{threadId}}", + "runId": "{{runId}}", + "messages": [{ "id": "m1", "role": "user", "content": "Test" }]{{(forwardedPropsJson is null ? string.Empty : ",\n \"forwardedProps\": " + forwardedPropsJson)}} + } + """; + } + private sealed class MultiResponseAgent : AIAgent { protected override string? IdCore => "multi-response-agent"; @@ -460,6 +638,88 @@ protected override async IAsyncEnumerable RunCoreStreamingA } } + private sealed class CountingAgent(Action onRunStreaming) : AIAgent + { + protected override string? IdCore => "counting-agent"; + + public override string? Description => "Agent that counts streaming invocations"; + + protected override ValueTask CreateSessionCoreAsync(CancellationToken cancellationToken = default) => + new(new TestAgentSession()); + + protected override ValueTask DeserializeSessionCoreAsync(JsonElement serializedState, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) => + new(serializedState.Deserialize(jsonSerializerOptions)!); + + protected override ValueTask SerializeSessionCoreAsync(AgentSession session, JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default) + { + if (session is not TestAgentSession testSession) + { + throw new InvalidOperationException($"The provided session type '{session.GetType().Name}' is not compatible with this agent. Only sessions of type '{nameof(TestAgentSession)}' can be serialized by this agent."); + } + + return new(JsonSerializer.SerializeToElement(testSession, jsonSerializerOptions)); + } + + protected override Task RunCoreAsync(IEnumerable messages, AgentSession? session = null, AgentRunOptions? options = null, CancellationToken cancellationToken = default) + { + throw new NotImplementedException(); + } + + protected override async IAsyncEnumerable RunCoreStreamingAsync( + IEnumerable messages, + AgentSession? session = null, + AgentRunOptions? options = null, + [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken = default) + { + onRunStreaming(); + await Task.CompletedTask; + yield return new AgentResponseUpdate(new ChatResponseUpdate(ChatRole.Assistant, "Test response")); + } + } + + private sealed class TestServerHost : IAsyncDisposable + { + private readonly WebApplication _app; + + private TestServerHost(WebApplication app, HttpClient client) + { + this._app = app; + this.Client = client; + } + + public HttpClient Client { get; } + + public static async Task CreateAsync(AIAgent agent, AGUIEndpointRouteBuilderExtensions.ProxiedResultResolver? proxiedResultResolver = null) + { + WebApplicationBuilder builder = WebApplication.CreateBuilder(); + builder.Services.AddAGUI(); + builder.WebHost.UseTestServer(); + + WebApplication app = builder.Build(); + if (proxiedResultResolver is null) + { + app.MapAGUI("/agent", agent); + } + else + { + app.MapAGUI("/agent", agent, proxiedResultResolver); + } + + await app.StartAsync().ConfigureAwait(false); + + TestServer testServer = app.Services.GetRequiredService() as TestServer + ?? throw new InvalidOperationException("TestServer not found"); + + return new TestServerHost(app, testServer.CreateClient()); + } + + public async ValueTask DisposeAsync() + { + this.Client.Dispose(); + await this._app.DisposeAsync().ConfigureAwait(false); + } + } + private RequestDelegate CreateRequestDelegate( Func, IEnumerable, IEnumerable>, JsonElement, AIAgent> factory) { diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests.csproj b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests.csproj index 57a653d9f0..65e1eb8f50 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests.csproj +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests.csproj @@ -6,6 +6,7 @@ +