< Summary

Information
Class: Elsa.AI.Host.Tools.Activities.ActivityDescriptorTool
Assembly: Elsa.AI.Host
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.AI.Host/Tools/Activities/ActivityDescriptorTool.cs
Line coverage
38%
Covered lines: 8
Uncovered lines: 13
Coverable lines: 21
Total lines: 37
Line coverage: 38%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Definition()100%11100%
ExecuteAsync(...)0%110100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.AI.Host/Tools/Activities/ActivityDescriptorTool.cs

#LineLine coverage
 1using Elsa.AI.Abstractions.Models;
 2using Elsa.AI.Host.Services;
 3using Elsa.AI.Host.Tools;
 4using Elsa.Workflows;
 5
 6namespace Elsa.AI.Host.Tools.Activities;
 7
 458public class ActivityDescriptorTool(IServiceProvider serviceProvider, ActivityGroundingSearchService searchService, AIGr
 9{
 9010    public override AIToolDefinition Definition { get; } = ReadOnlyDefinition(
 4511        "activities.getDescriptor",
 4512        "Get activity descriptor",
 4513        "Get model-safe metadata for one installed activity descriptor.",
 4514        GroundingToolSchemas.WithProperties(
 4515            ("type", GroundingToolSchemas.String("Activity type name or short name.")),
 4516            ("version", GroundingToolSchemas.Integer("Optional activity version."))));
 17
 18    public override ValueTask<AIToolResult> ExecuteAsync(AIToolExecutionContext context, CancellationToken cancellationT
 19    {
 020        var registry = serviceProvider.GetService(typeof(IActivityRegistry)) as IActivityRegistry;
 021        if (registry == null)
 022            return ValueTask.FromResult(formatter.Unavailable("Activity Registry"));
 23
 024        var type = GetString(context.Arguments, "type");
 025        var version = GetInt(context.Arguments, "version");
 026        var descriptor = string.IsNullOrWhiteSpace(type)
 027            ? null
 028            : version != null
 029                ? registry.Find(type, version.Value)
 030                : registry.Find(x => string.Equals(x.TypeName, type, StringComparison.OrdinalIgnoreCase) || string.Equal
 31
 032        if (descriptor == null)
 033            return ValueTask.FromResult(new AIToolResult { Status = AIToolInvocationStatus.Failed, Error = $"Activity '{
 34
 035        return ValueTask.FromResult(formatter.CreateResult($"Resolved descriptor for {descriptor.TypeName} v{descriptor.
 36    }
 37}