Public Access
Validate workflow rule writes
This commit is contained in:
@@ -120,7 +120,7 @@ public sealed class WorkflowRulesEditorTools
|
||||
var updated = replace_file
|
||||
? yaml
|
||||
: AgentFileToolContent.AppendContent(existing, yaml);
|
||||
var validation = ValidateYaml(updated);
|
||||
var validation = await ValidateYamlAsync(updated);
|
||||
if (validation is not null)
|
||||
{
|
||||
return validation;
|
||||
@@ -930,22 +930,27 @@ public sealed class WorkflowRulesEditorTools
|
||||
}
|
||||
}
|
||||
|
||||
private static string? ValidateYaml(string yaml)
|
||||
private static async Task<string?> ValidateYamlAsync(string yaml)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(yaml))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
MeetingWorkflowRulesFile rulesFile;
|
||||
try
|
||||
{
|
||||
_ = YamlDeserializer.Deserialize<MeetingWorkflowRulesFile>(yaml);
|
||||
return null;
|
||||
rulesFile = YamlDeserializer.Deserialize<MeetingWorkflowRulesFile>(yaml) ?? new MeetingWorkflowRulesFile();
|
||||
}
|
||||
catch (YamlException exception)
|
||||
{
|
||||
return $"Refused: workflow rules YAML is invalid. {exception.Message}";
|
||||
}
|
||||
|
||||
var errors = await MeetingWorkflowRulesValidator.ValidateAsync(rulesFile);
|
||||
return errors.Count == 0
|
||||
? null
|
||||
: "Refused: workflow rules are invalid. " + string.Join(" ", errors);
|
||||
}
|
||||
|
||||
private async Task WriteRecommendedProjectSeedAsync(string projectRoot, string projectName)
|
||||
|
||||
Reference in New Issue
Block a user