Functions/GenXdev.Helpers/ExposedCmdletDefinitions.cs
|
// ################################################################################
// Part of PowerShell module : GenXdev.Helpers // Original cmdlet filename : ExposedCmdletDefinitions.cs // Original author : René Vaessen / GenXdev // Version : 2.1.2025 // ################################################################################ // Copyright (c) René Vaessen / GenXdev // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ################################################################################ using System.Collections; namespace GenXdev.Helpers { /// <summary> /// Represents an error that occurred during a tool call invocation. /// This class encapsulates details about invocation failures, including /// the error message, whether an exception was thrown, and the exception type. /// </summary> public class ExposedToolCallInvocationError { /// <summary> /// Gets or sets the error message describing what went wrong during the invocation. /// </summary> public string error { get; set; } = null; /// <summary> /// Gets or sets a value indicating whether an exception was thrown during the invocation. /// </summary> public bool exceptionThrown { get; set; } = false; /// <summary> /// Gets or sets the class name of the exception that was thrown, if any. /// </summary> public string exceptionClass { get; set; } = null; } /// <summary> /// Represents the result of a tool call invocation, including success status, /// output data, and metadata about the invoked command. /// This class provides comprehensive information about the execution outcome. /// </summary> public class ExposedToolCallInvocationResult { /// <summary> /// Gets or sets a value indicating whether the command was successfully exposed and invoked. /// </summary> public bool CommandExposed { get; set; } = false; /// <summary> /// Gets or sets the reason for the invocation result, such as success or failure details. /// </summary> public string Reason { get; set; } = null; /// <summary> /// Gets or sets the output generated by the invoked command. /// </summary> public string Output { get; set; } = null; /// <summary> /// Gets or sets the full name of the invoked command or cmdlet. /// </summary> public string FullName { get; set; } = null; /// <summary> /// Gets or sets the type of the output returned by the command. /// </summary> public string OutputType { get; set; } = null; /// <summary> /// Gets or sets a hashtable containing all unfiltered arguments passed to the command. /// </summary> public System.Collections.Hashtable UnfilteredArguments { get; set; } = new Hashtable(); /// <summary> /// Gets or sets a hashtable containing the filtered arguments that were actually used by the command. /// </summary> public System.Collections.Hashtable FilteredArguments { get; set; } = new Hashtable(); /// <summary> /// Gets or sets the definition of the exposed cmdlet that was invoked. /// </summary> public ExposedCmdletDefinition ExposedCmdLet { get; set; } = null; /// <summary> /// Gets or sets any error message associated with the invocation, if it failed. /// </summary> public string Error { get; set; } = null; } /// <summary> /// Represents a parameter that is forced to a specific value in a cmdlet definition. /// This allows predefined parameter values to be enforced during command exposure. /// </summary> public class ExposedForcedCmdLetParameter { /// <summary> /// Gets or sets the name of the parameter that is being forced. /// </summary> public string Name { get; set; } /// <summary> /// Gets or sets the value that the parameter is forced to have. /// </summary> public object Value { get; set; } } /// <summary> /// Defines the configuration for exposing a PowerShell cmdlet through the MCP server. /// This class contains metadata about the cmdlet, including its name, description, /// allowed parameters, and various configuration options for exposure. /// </summary> public class ExposedCmdletDefinition { /// <summary> /// Gets or sets the name of the cmdlet being exposed. /// </summary> public string Name { get; set; } /// <summary> /// Gets or sets a description of what the cmdlet does. /// </summary> public string Description { get; set; } /// <summary> /// Gets or sets a list of parameter names that are allowed to be passed to the cmdlet. /// </summary> public List<string> AllowedParams { get; set; } = new List<string>(); /// <summary> /// Gets or sets a list of parameter names that should not be shown during confirmation prompts. /// </summary> public List<string> DontShowDuringConfirmationParamNames { get; set; } = new List<string>(); /// <summary> /// Gets or sets a list of parameters that are forced to specific values. /// </summary> public List<ExposedForcedCmdLetParameter> ForcedParams { get; set; } = new List<ExposedForcedCmdLetParameter>(); /// <summary> /// Gets or sets the maximum depth for JSON serialization of the cmdlet's output. /// </summary> public int JsonDepth { get; set; } = 2; /// <summary> /// Gets or sets a value indicating whether the output should be returned as text. /// </summary> public bool OutputText { get; set; } = true; /// <summary> /// Gets or sets a value indicating whether user confirmation is required before executing the cmdlet. /// </summary> public bool Confirm { get; set; } = true; } } |