using System.Text.Json; using System.Text.Json.Nodes; using XFEWorkflow.Abstractions; namespace XFEWorkflow.Plugins.Sample; public sealed class EchoPlugin : IWorkflowPlugin { public void Register(IPluginRegistry registry) { var manifest = JsonSerializer.Deserialize(File.ReadAllText(Path.Combine(Path.GetDirectoryName(typeof(EchoPlugin).Assembly.Location)!, "plugin.json")), WorkflowJson.Options)!; registry.RegisterAction(manifest.Capabilities.Single(), () => new EchoAction()); } private sealed class EchoAction : IWorkflowAction { public async ValueTask ExecuteAsync(JsonObject inputs, IWorkflowContext context, CancellationToken cancellationToken) { var text = inputs.String("text"); await context.LogAsync("示例插件:" + text, cancellationToken); // Other plugins are called through context.InvokeAsync("plugin.id.action", ..., cancellationToken). return new() { ["text"] = text }; } } }