2026-03-28 02:08:47 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2026-04-03 19:06:43 +02:00
|
|
|
using MinecraftClient.Scripting;
|
2026-03-28 02:08:47 +01:00
|
|
|
|
|
|
|
|
namespace MinecraftClient.Mcp;
|
|
|
|
|
|
|
|
|
|
public sealed class MccMcpChatHistoryEntry
|
|
|
|
|
{
|
|
|
|
|
public required DateTimeOffset TimestampUtc { get; init; }
|
|
|
|
|
public required string Kind { get; init; }
|
|
|
|
|
public required string Text { get; init; }
|
|
|
|
|
public string? Sender { get; init; }
|
|
|
|
|
public string? Message { get; init; }
|
|
|
|
|
public string? Json { get; init; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class MccMcpChatHistoryStore
|
|
|
|
|
{
|
|
|
|
|
public static void Add(MccMcpChatHistoryEntry entry)
|
|
|
|
|
{
|
2026-04-03 19:06:43 +02:00
|
|
|
MccObservedStateStore.AddChatHistoryEntry(new MccChatHistoryEntry
|
2026-03-28 02:08:47 +01:00
|
|
|
{
|
2026-04-03 19:06:43 +02:00
|
|
|
TimestampUtc = entry.TimestampUtc,
|
|
|
|
|
Kind = entry.Kind,
|
|
|
|
|
Text = entry.Text,
|
|
|
|
|
Sender = entry.Sender,
|
|
|
|
|
Message = entry.Message,
|
|
|
|
|
Json = entry.Json
|
|
|
|
|
});
|
2026-03-28 02:08:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static MccMcpChatHistoryEntry[] GetLatest(int maxCount)
|
|
|
|
|
{
|
2026-04-03 19:06:43 +02:00
|
|
|
return MccObservedStateStore.GetLatestChatHistory(maxCount)
|
|
|
|
|
.Select(entry => new MccMcpChatHistoryEntry
|
|
|
|
|
{
|
|
|
|
|
TimestampUtc = entry.TimestampUtc,
|
|
|
|
|
Kind = entry.Kind,
|
|
|
|
|
Text = entry.Text,
|
|
|
|
|
Sender = entry.Sender,
|
|
|
|
|
Message = entry.Message,
|
|
|
|
|
Json = entry.Json
|
|
|
|
|
})
|
|
|
|
|
.ToArray();
|
2026-03-28 02:08:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Clear()
|
|
|
|
|
{
|
2026-04-03 19:06:43 +02:00
|
|
|
MccObservedStateStore.ClearChatHistory();
|
2026-03-28 02:08:47 +01:00
|
|
|
}
|
|
|
|
|
}
|