Commit ff04e0a8 authored by shrabbit's avatar shrabbit
Browse files

feat(RequestTools): InfiniteWait 消息支持 Spectre.Console 标记语法并降级输出无效标记

parent 157d6af9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ namespace McpBase.McpServer.Tools;
public class RequestTools
{
    [McpServerTool, Description("Pause execution and wait indefinitely for human interaction. A separate window (McpBase.Request.exe) is launched showing the provided message to the user; the call blocks until the user closes that window. Use this when the agent needs human confirmation, review, or intervention before continuing. Returns the elapsed wait time in seconds (string, 3 decimal places). Note: the launched window is independent and does not share stdin/stdout with the MCP server.")]
    public async Task<string> InfiniteWait([Description("Message displayed to the user in the waiting window. Explain clearly what the agent is waiting for and what action the user should take to resume (e.g. 'Please review the proposed change and close this window when ready to continue').")] string? msg)
    public async Task<string> InfiniteWait([Description("Message displayed to the user in the waiting window. Explain clearly what the agent is waiting for and what action the user should take to resume (e.g. 'Please review the proposed change and close this window when ready to continue'). Supports Spectre.Console markup syntax for colored/styled output; use explicit closing tags for clarity (e.g. [red]error text[/red], [bold]important[/bold], [green]success[/green], [dim]secondary[/dim], [yellow]warning[/yellow]). Styles can be combined (e.g. [bold red]critical[/bold red]). To output a literal '[' or ']' character, double it as '[[' or ']]'.")] string? msg)
    {
        var sw = Stopwatch.StartNew();
        var self = Process.GetCurrentProcess().Id;
+10 −1
Original line number Diff line number Diff line
@@ -15,7 +15,16 @@ class Program

        HandleTid<SendInfWaitTransport>(tp!.Tid, args[0], 1, s =>
        {
            AnsiConsole.MarkupLine($"PID: {s.Pid} 正在进行无限等待。\n输入 'y' 或关闭控制台来结束等待。\n\n{s.Message}\n");
            var message = $"PID: {s.Pid} 正在进行无限等待。\n输入 'y' 或关闭控制台来结束等待。\n\n{s.Message}\n";
            try
            {
                AnsiConsole.MarkupLine(message);
            }
            catch (Exception e)
            {
                // 当标记语法错误时,降级普通输出。
                Console.WriteLine(message);
            }
            while (Console.ReadKey().Key != ConsoleKey.Y)
            {
            }