feat: 拆分 CLI 与网页宿主,并在无有效城市时暂停等人确认

将原单体 MAF1 拆成 MAF1(控制台工作流)和 MAF1.Web(可视化编排)。
抽城市失败时暂停:网页弹确认、CLI 控制台询问,超时采用默认结束查询;
也可改填城市后继续。共享决策模型放在 MAF1.Core。
This commit is contained in:
2026-08-28 10:43:57 +08:00
parent 5544788917
commit a3cca78592
42 changed files with 1427 additions and 457 deletions
+35
View File
@@ -0,0 +1,35 @@
using System.Collections.Concurrent;
using MAF1.Decisions;
using MAF1.Plugins;
namespace MAF1.Web;
internal sealed class WorkflowSession
{
public required string RunId { get; init; }
public required WorkflowGraph Graph { get; init; }
public required NodeCatalogSnapshot Catalog { get; init; }
public required List<string> Order { get; init; }
public required Dictionary<string, Dictionary<string, object?>> Outputs { get; init; }
public required List<NodeRunLog> Steps { get; init; }
public int NextIndex { get; set; }
public DecisionRequest? Pending { get; set; }
public bool Completed { get; set; }
public WorkflowRunResult LastResult { get; set; } = new();
public DecisionAnswer? AppliedDecision { get; set; }
public CancellationTokenSource TimeoutCts { get; set; } = new();
public SemaphoreSlim Mutex { get; } = new(1, 1);
public object Sync { get; } = new();
}
public sealed class WorkflowRunStore
{
private readonly ConcurrentDictionary<string, WorkflowSession> _sessions = new(StringComparer.OrdinalIgnoreCase);
internal bool TryAdd(WorkflowSession session) => _sessions.TryAdd(session.RunId, session);
internal bool TryGet(string runId, out WorkflowSession? session) => _sessions.TryGetValue(runId, out session);
public WorkflowRunResult? GetResult(string runId)
=> _sessions.TryGetValue(runId, out WorkflowSession? session) ? session.LastResult : null;
}