| | | 1 | | // Copyright (c) NexusLabs. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | |
| | | 6 | | namespace NexusLabs.Needlr.AgentFramework.Generators; |
| | | 7 | | |
| | | 8 | | internal readonly struct AgentFunctionParameterInfo |
| | | 9 | | { |
| | | 10 | | public AgentFunctionParameterInfo( |
| | | 11 | | string name, string typeFullName, |
| | | 12 | | string jsonSchemaType, string? jsonSchemaFormat, |
| | | 13 | | string? itemJsonSchemaType, |
| | | 14 | | string? itemObjectSchemaJson, |
| | | 15 | | IReadOnlyList<ObjectPropertyInfo>? itemObjectProperties, |
| | | 16 | | string? objectSchemaJson, |
| | | 17 | | IReadOnlyList<ObjectPropertyInfo>? objectProperties, |
| | | 18 | | bool isCancellationToken, bool isNullable, bool hasDefault, |
| | | 19 | | string? defaultLiteral, bool isEnum, string? description) |
| | | 20 | | { |
| | 110 | 21 | | Name = name; TypeFullName = typeFullName; |
| | 110 | 22 | | JsonSchemaType = jsonSchemaType; JsonSchemaFormat = jsonSchemaFormat; |
| | 55 | 23 | | ItemJsonSchemaType = itemJsonSchemaType; |
| | 55 | 24 | | ItemObjectSchemaJson = itemObjectSchemaJson; |
| | 55 | 25 | | ItemObjectProperties = itemObjectProperties; |
| | 55 | 26 | | ObjectSchemaJson = objectSchemaJson; |
| | 55 | 27 | | ObjectProperties = objectProperties; |
| | 110 | 28 | | IsCancellationToken = isCancellationToken; IsNullable = isNullable; |
| | 110 | 29 | | HasDefault = hasDefault; DefaultLiteral = defaultLiteral; |
| | 110 | 30 | | IsEnum = isEnum; Description = description; |
| | 55 | 31 | | } |
| | | 32 | | |
| | 484 | 33 | | public string Name { get; } |
| | 109 | 34 | | public string TypeFullName { get; } |
| | 250 | 35 | | public string JsonSchemaType { get; } |
| | | 36 | | /// <summary> |
| | | 37 | | /// JSON Schema <c>format</c> hint for stringified value types (e.g., <c>"uuid"</c> for |
| | | 38 | | /// <see cref="System.Guid"/>, <c>"date-time"</c> for <see cref="System.DateTime"/>, |
| | | 39 | | /// <c>"duration"</c> for <see cref="System.TimeSpan"/>). <see langword="null"/> when no |
| | | 40 | | /// format applies. |
| | | 41 | | /// </summary> |
| | 68 | 42 | | public string? JsonSchemaFormat { get; } |
| | | 43 | | /// <summary>JSON schema type for array items (e.g., "string", "integer", "object").</summary> |
| | 26 | 44 | | public string? ItemJsonSchemaType { get; } |
| | | 45 | | /// <summary>Pre-built JSON schema for complex object array items (properties, required fields).</summary> |
| | 10 | 46 | | public string? ItemObjectSchemaJson { get; } |
| | | 47 | | /// <summary>Property extraction info for AOT-safe manual deserialization of complex array items.</summary> |
| | 10 | 48 | | public IReadOnlyList<ObjectPropertyInfo>? ItemObjectProperties { get; } |
| | | 49 | | /// <summary> |
| | | 50 | | /// Pre-built JSON schema for a top-level complex object parameter (properties, required |
| | | 51 | | /// fields). Set when <see cref="JsonSchemaType"/> is <c>"object"</c> AND the type has |
| | | 52 | | /// public properties suitable for property-level binding. |
| | | 53 | | /// </summary> |
| | 16 | 54 | | public string? ObjectSchemaJson { get; } |
| | | 55 | | /// <summary> |
| | | 56 | | /// Property extraction info for AOT-safe manual deserialization of a top-level complex |
| | | 57 | | /// object parameter. Mirrors <see cref="ItemObjectProperties"/> but applies to the |
| | | 58 | | /// parameter type itself rather than an array element. |
| | | 59 | | /// </summary> |
| | 8 | 60 | | public IReadOnlyList<ObjectPropertyInfo>? ObjectProperties { get; } |
| | 261 | 61 | | public bool IsCancellationToken { get; } |
| | 142 | 62 | | public bool IsNullable { get; } |
| | 106 | 63 | | public bool HasDefault { get; } |
| | | 64 | | /// <summary> |
| | | 65 | | /// The C# literal expression for the parameter's default value, when |
| | | 66 | | /// <see cref="HasDefault"/> is <see langword="true"/>. For example, <c>"false"</c> for |
| | | 67 | | /// <c>bool flag = false</c>, <c>"5"</c> for <c>int max = 5</c>, <c>"\"x\""</c> for |
| | | 68 | | /// <c>string p = "x"</c>, or <c>"null"</c> for <c>string? p = null</c>. The literal is |
| | | 69 | | /// emitted directly into generated extraction code as the fallback when the model omits |
| | | 70 | | /// the argument or supplies <c>JsonValueKind.Null</c> / <c>JsonValueKind.Undefined</c>. |
| | | 71 | | /// </summary> |
| | 18 | 72 | | public string? DefaultLiteral { get; } |
| | | 73 | | /// <summary> |
| | | 74 | | /// <see langword="true"/> when the parameter type is a C# <see langword="enum"/>. Drives |
| | | 75 | | /// enum-aware extraction emission: the wrapper calls |
| | | 76 | | /// <c>GetStringArgument</c> then <c>Enum.Parse<T>(s, ignoreCase: true)</c> rather |
| | | 77 | | /// than directly assigning a <see cref="string"/> to an enum-typed variable. |
| | | 78 | | /// </summary> |
| | 20 | 79 | | public bool IsEnum { get; } |
| | 60 | 80 | | public string? Description { get; } |
| | 96 | 81 | | public bool IsRequired => !IsCancellationToken && !IsNullable && !HasDefault; |
| | | 82 | | } |