feat(runtime): share chat commands and run login sequence

This commit is contained in:
Erik 2026-08-14 20:27:45 +02:00
parent 5535d0adac
commit 41b15efd4d
57 changed files with 1739 additions and 345 deletions

View file

@ -849,6 +849,11 @@ public sealed class LauncherOrchestrator : ILauncherOrchestrator
activity.Error = $"Plugin failed: {failed.Plugin}: {failed.Error}";
activity.Status = activity.Error;
break;
case LoginCommandFailedStatusEvent failed:
activity.Error =
$"Login command {failed.CommandIndex} failed: {failed.Error}";
activity.Status = activity.Error;
break;
case DisconnectedStatusEvent disconnected:
if (activity.State != LauncherActivityState.Stopping)
{

View file

@ -56,6 +56,15 @@ public sealed record PluginFailedStatusEvent : StatusEvent
public required string Error { get; init; }
}
public sealed record LoginCommandFailedStatusEvent : StatusEvent
{
public required int CommandIndex { get; init; }
public required string Command { get; init; }
public required string Error { get; init; }
}
public sealed record DisconnectedStatusEvent : StatusEvent
{
public required string Reason { get; init; }

View file

@ -101,6 +101,8 @@ public static class StatusEventParser
ParsePluginLoaded(root, v, e, t, sessionId),
"pluginFailed" =>
ParsePluginFailed(root, v, e, t, sessionId),
"loginCommandFailed" =>
ParseLoginCommandFailed(root, v, e, t, sessionId),
"disconnected" =>
ParseDisconnected(root, v, e, t, sessionId),
"exited" =>
@ -128,6 +130,7 @@ public static class StatusEventParser
"enteredWorld" or
"pluginLoaded" or
"pluginFailed" or
"loginCommandFailed" or
"disconnected" or
"exited";
@ -280,6 +283,32 @@ public static class StatusEventParser
Reason = RequireString(root, "reason"),
};
private static StatusEvent ParseLoginCommandFailed(
JsonElement root,
int v,
string e,
DateTimeOffset t,
string sessionId)
{
int commandIndex = RequireInt32(root, "commandIndex");
if (commandIndex < 0)
{
throw new FormatException(
"status event field 'commandIndex' is negative.");
}
return new LoginCommandFailedStatusEvent
{
V = v,
E = e,
T = t,
SessionId = sessionId,
CommandIndex = commandIndex,
Command = RequireString(root, "command"),
Error = RequireString(root, "error"),
};
}
private static StatusEvent ParseExited(
JsonElement root,
int v,