diff --git a/agentschema-emitter/lib/model/container.tsp b/agentschema-emitter/lib/model/container.tsp index d334ff1..db5126f 100644 --- a/agentschema-emitter/lib/model/container.tsp +++ b/agentschema-emitter/lib/model/container.tsp @@ -23,6 +23,26 @@ alias EnvironmentVariables = Record | Named< alias AgentProtocol = "responses" | "activity" | string; +alias DependencyResolution = "bundled" | "remote_build" | string; + +/** + * Configuration for code-based (ZIP upload) deployment of a hosted agent. + * When present, the agent source code is uploaded directly instead of building a container image. + */ +model CodeConfiguration { + @doc("Runtime identifier for code execution (e.g., 'python_3_11', 'dotnet_8').") + @sample(#{ runtime: "python_3_11" }) + runtime: string; + + @doc("The entry point file for the agent (e.g., 'main.py' for Python, 'HelloWorld.dll' for .NET).") + @sample(#{ entryPoint: "main.py" }) + entryPoint: string; + + @doc("How package dependencies are resolved at deployment time.") + @sample(#{ dependencyResolution: "remote_build" }) + dependencyResolution?: DependencyResolution; +} + /* * A record mapping for a single protocol and its version. */ @@ -81,4 +101,7 @@ model ContainerAgent extends AgentDefinition { environmentVariables: #[#{ name: "MY_ENV_VAR", value: "my-value" }], }) environmentVariables?: EnvironmentVariables; + + @doc("Configuration for code-based (ZIP upload) deployment. When present, agent source code is uploaded directly instead of building a container image.") + codeConfiguration?: CodeConfiguration; } diff --git a/docs/src/content/docs/reference/AgentDefinition.md b/docs/src/content/docs/reference/AgentDefinition.md index 08eb0a2..7c6d8a9 100644 --- a/docs/src/content/docs/reference/AgentDefinition.md +++ b/docs/src/content/docs/reference/AgentDefinition.md @@ -52,6 +52,7 @@ classDiagram +string dockerfilePath +ContainerResources resources +EnvironmentVariable[] environmentVariables + +CodeConfiguration codeConfiguration } AgentDefinition <|-- ContainerAgent ``` diff --git a/docs/src/content/docs/reference/CodeConfiguration.md b/docs/src/content/docs/reference/CodeConfiguration.md new file mode 100644 index 0000000..63f2b07 --- /dev/null +++ b/docs/src/content/docs/reference/CodeConfiguration.md @@ -0,0 +1,44 @@ +--- +title: "CodeConfiguration" +description: "Documentation for the CodeConfiguration type." +slug: "reference/codeconfiguration" +--- + +Configuration for code-based (ZIP upload) deployment of a hosted agent. +When present, the agent source code is uploaded directly instead of building a container image. + +## Class Diagram + +```mermaid +--- +title: CodeConfiguration +config: + look: handDrawn + theme: colorful + class: + hideEmptyMembersBox: true +--- +classDiagram + class CodeConfiguration { + + +string runtime + +string entryPoint + +string dependencyResolution + } +``` + +## Yaml Example + +```yaml +runtime: python_3_11 +entryPoint: main.py +dependencyResolution: remote_build +``` + +## Properties + +| Name | Type | Description | +| ---- | ---- | ----------- | +| runtime | string | Runtime identifier for code execution (e.g., 'python_3_11', 'dotnet_8'). | +| entryPoint | string | The entry point file for the agent (e.g., 'main.py' for Python, 'HelloWorld.dll' for .NET). | +| dependencyResolution | string | How package dependencies are resolved at deployment time. | diff --git a/docs/src/content/docs/reference/ContainerAgent.md b/docs/src/content/docs/reference/ContainerAgent.md index 84b414f..5e5f7e9 100644 --- a/docs/src/content/docs/reference/ContainerAgent.md +++ b/docs/src/content/docs/reference/ContainerAgent.md @@ -38,6 +38,7 @@ classDiagram +string dockerfilePath +ContainerResources resources +EnvironmentVariable[] environmentVariables + +CodeConfiguration codeConfiguration } class ProtocolVersionRecord { +string protocol @@ -54,6 +55,12 @@ classDiagram +string value } ContainerAgent *-- EnvironmentVariable + class CodeConfiguration { + +string runtime + +string entryPoint + +string dependencyResolution + } + ContainerAgent *-- CodeConfiguration ``` ## Yaml Example @@ -83,6 +90,7 @@ environmentVariables: | dockerfilePath | string | Path to a Dockerfile for deployment. Can be relative to the working directory or an absolute path. | | resources | [ContainerResources](../containerresources/) | Resource allocation for the container | | environmentVariables | [EnvironmentVariable[]](../environmentvariable/) | Environment variables to set in the container | +| codeConfiguration | [CodeConfiguration](../codeconfiguration/) | Configuration for code-based (ZIP upload) deployment. When present, agent source code is uploaded directly instead of building a container image. | ## Composed Types @@ -91,3 +99,4 @@ The following types are composed within `ContainerAgent`: - [ProtocolVersionRecord](../protocolversionrecord/) - [ContainerResources](../containerresources/) - [EnvironmentVariable](../environmentvariable/) +- [CodeConfiguration](../codeconfiguration/) diff --git a/docs/src/content/docs/reference/README.md b/docs/src/content/docs/reference/README.md index d52403d..9f25e5a 100644 --- a/docs/src/content/docs/reference/README.md +++ b/docs/src/content/docs/reference/README.md @@ -244,6 +244,12 @@ classDiagram +string name +string value } + class CodeConfiguration { + + +string runtime + +string entryPoint + +string dependencyResolution + } class ContainerAgent { +string kind @@ -252,6 +258,7 @@ classDiagram +string dockerfilePath +ContainerResources resources +EnvironmentVariable[] environmentVariables + +CodeConfiguration codeConfiguration } class Resource { <> @@ -326,6 +333,7 @@ classDiagram ContainerAgent *-- ProtocolVersionRecord ContainerAgent *-- ContainerResources ContainerAgent *-- EnvironmentVariable + ContainerAgent *-- CodeConfiguration AgentManifest *-- AgentDefinition AgentManifest *-- PropertySchema AgentManifest *-- Resource diff --git a/runtime/csharp/AgentSchema.Tests/CodeConfigurationConversionTests.cs b/runtime/csharp/AgentSchema.Tests/CodeConfigurationConversionTests.cs new file mode 100644 index 0000000..0f42ba1 --- /dev/null +++ b/runtime/csharp/AgentSchema.Tests/CodeConfigurationConversionTests.cs @@ -0,0 +1,133 @@ + +using Xunit; + +#pragma warning disable IDE0130 +namespace AgentSchema; +#pragma warning restore IDE0130 + + +public class CodeConfigurationConversionTests +{ + [Fact] + public void LoadYamlInput() + { + string yamlData = """ +runtime: python_3_11 +entryPoint: main.py +dependencyResolution: remote_build + +"""; + + var instance = CodeConfiguration.FromYaml(yamlData); + + Assert.NotNull(instance); + Assert.Equal("python_3_11", instance.Runtime); + Assert.Equal("main.py", instance.EntryPoint); + Assert.Equal("remote_build", instance.DependencyResolution); + } + + [Fact] + public void LoadJsonInput() + { + string jsonData = """ +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +"""; + + var instance = CodeConfiguration.FromJson(jsonData); + Assert.NotNull(instance); + Assert.Equal("python_3_11", instance.Runtime); + Assert.Equal("main.py", instance.EntryPoint); + Assert.Equal("remote_build", instance.DependencyResolution); + } + + [Fact] + public void RoundtripJson() + { + // Test that FromJson -> ToJson -> FromJson produces equivalent data + string jsonData = """ +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +"""; + + var original = CodeConfiguration.FromJson(jsonData); + Assert.NotNull(original); + + var json = original.ToJson(); + Assert.False(string.IsNullOrEmpty(json)); + + var reloaded = CodeConfiguration.FromJson(json); + Assert.NotNull(reloaded); + Assert.Equal("python_3_11", reloaded.Runtime); + Assert.Equal("main.py", reloaded.EntryPoint); + Assert.Equal("remote_build", reloaded.DependencyResolution); + } + + [Fact] + public void RoundtripYaml() + { + // Test that FromYaml -> ToYaml -> FromYaml produces equivalent data + string yamlData = """ +runtime: python_3_11 +entryPoint: main.py +dependencyResolution: remote_build + +"""; + + var original = CodeConfiguration.FromYaml(yamlData); + Assert.NotNull(original); + + var yaml = original.ToYaml(); + Assert.False(string.IsNullOrEmpty(yaml)); + + var reloaded = CodeConfiguration.FromYaml(yaml); + Assert.NotNull(reloaded); + Assert.Equal("python_3_11", reloaded.Runtime); + Assert.Equal("main.py", reloaded.EntryPoint); + Assert.Equal("remote_build", reloaded.DependencyResolution); + } + + [Fact] + public void ToJsonProducesValidJson() + { + string jsonData = """ +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +"""; + + var instance = CodeConfiguration.FromJson(jsonData); + var json = instance.ToJson(); + + // Verify it's valid JSON by parsing it + var parsed = System.Text.Json.JsonDocument.Parse(json); + Assert.NotNull(parsed); + } + + [Fact] + public void ToYamlProducesValidYaml() + { + string yamlData = """ +runtime: python_3_11 +entryPoint: main.py +dependencyResolution: remote_build + +"""; + + var instance = CodeConfiguration.FromYaml(yamlData); + var yaml = instance.ToYaml(); + + // Verify it's valid YAML by parsing it + var deserializer = new YamlDotNet.Serialization.DeserializerBuilder().Build(); + var parsed = deserializer.Deserialize(yaml); + Assert.NotNull(parsed); + } +} diff --git a/runtime/csharp/AgentSchema/CodeConfiguration.cs b/runtime/csharp/AgentSchema/CodeConfiguration.cs new file mode 100644 index 0000000..9124a2b --- /dev/null +++ b/runtime/csharp/AgentSchema/CodeConfiguration.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft. All rights reserved. +using System.Text.Json; +using YamlDotNet.Serialization; + +#pragma warning disable IDE0130 +namespace AgentSchema; +#pragma warning restore IDE0130 + +/// +/// Configuration for code-based (ZIP upload) deployment of a hosted agent. +/// When present, the agent source code is uploaded directly instead of building a container image. +/// +public class CodeConfiguration +{ + /// + /// The shorthand property name for this type, if any. + /// + public static string? ShorthandProperty => null; + + /// + /// Initializes a new instance of . + /// +#pragma warning disable CS8618 + public CodeConfiguration() + { + } +#pragma warning restore CS8618 + + /// + /// Runtime identifier for code execution (e.g., 'python_3_11', 'dotnet_8'). + /// + public string Runtime { get; set; } = string.Empty; + + /// + /// The entry point file for the agent (e.g., 'main.py' for Python, 'HelloWorld.dll' for .NET). + /// + public string EntryPoint { get; set; } = string.Empty; + + /// + /// How package dependencies are resolved at deployment time. + /// + public string? DependencyResolution { get; set; } + + + #region Load Methods + + /// + /// Load a CodeConfiguration instance from a dictionary. + /// + /// The dictionary containing the data. + /// Optional context with pre/post processing callbacks. + /// The loaded CodeConfiguration instance. + public static CodeConfiguration Load(Dictionary data, LoadContext? context = null) + { + if (context is not null) + { + data = context.ProcessInput(data); + } + + + // Create new instance + var instance = new CodeConfiguration(); + + + if (data.TryGetValue("runtime", out var runtimeValue) && runtimeValue is not null) + { + instance.Runtime = runtimeValue?.ToString()!; + } + + if (data.TryGetValue("entryPoint", out var entryPointValue) && entryPointValue is not null) + { + instance.EntryPoint = entryPointValue?.ToString()!; + } + + if (data.TryGetValue("dependencyResolution", out var dependencyResolutionValue) && dependencyResolutionValue is not null) + { + instance.DependencyResolution = dependencyResolutionValue?.ToString()!; + } + + if (context is not null) + { + instance = context.ProcessOutput(instance); + } + return instance; + } + + + + #endregion + + #region Save Methods + + /// + /// Save the CodeConfiguration instance to a dictionary. + /// + /// Optional context with pre/post processing callbacks. + /// The dictionary representation of this instance. + public Dictionary Save(SaveContext? context = null) + { + var obj = this; + if (context is not null) + { + obj = context.ProcessObject(obj); + } + + + var result = new Dictionary(); + + + if (obj.Runtime is not null) + { + result["runtime"] = obj.Runtime; + } + + if (obj.EntryPoint is not null) + { + result["entryPoint"] = obj.EntryPoint; + } + + if (obj.DependencyResolution is not null) + { + result["dependencyResolution"] = obj.DependencyResolution; + } + + + if (context is not null) + { + result = context.ProcessDict(result); + } + + return result; + } + + + /// + /// Convert the CodeConfiguration instance to a YAML string. + /// + /// Optional context with pre/post processing callbacks. + /// The YAML string representation of this instance. + public string ToYaml(SaveContext? context = null) + { + context ??= new SaveContext(); + return context.ToYaml(Save(context)); + } + + /// + /// Convert the CodeConfiguration instance to a JSON string. + /// + /// Optional context with pre/post processing callbacks. + /// Whether to indent the output. Defaults to true. + /// The JSON string representation of this instance. + public string ToJson(SaveContext? context = null, bool indent = true) + { + context ??= new SaveContext(); + return context.ToJson(Save(context), indent); + } + + /// + /// Load a CodeConfiguration instance from a JSON string. + /// + /// The JSON string to parse. + /// Optional context with pre/post processing callbacks. + /// The loaded CodeConfiguration instance. + public static CodeConfiguration FromJson(string json, LoadContext? context = null) + { + using var doc = JsonDocument.Parse(json); + Dictionary dict; + dict = JsonSerializer.Deserialize>(json, JsonUtils.Options) + ?? throw new ArgumentException("Failed to parse JSON as dictionary"); + + return Load(dict, context); + } + + /// + /// Load a CodeConfiguration instance from a YAML string. + /// + /// The YAML string to parse. + /// Optional context with pre/post processing callbacks. + /// The loaded CodeConfiguration instance. + public static CodeConfiguration FromYaml(string yaml, LoadContext? context = null) + { + var dict = YamlUtils.Deserializer.Deserialize>(yaml) + ?? throw new ArgumentException("Failed to parse YAML as dictionary"); + + return Load(dict, context); + } + + #endregion +} diff --git a/runtime/csharp/AgentSchema/ContainerAgent.cs b/runtime/csharp/AgentSchema/ContainerAgent.cs index a746817..0694f44 100644 --- a/runtime/csharp/AgentSchema/ContainerAgent.cs +++ b/runtime/csharp/AgentSchema/ContainerAgent.cs @@ -57,6 +57,11 @@ public ContainerAgent() /// public IList? EnvironmentVariables { get; set; } + /// + /// Configuration for code-based (ZIP upload) deployment. When present, agent source code is uploaded directly instead of building a container image. + /// + public CodeConfiguration? CodeConfiguration { get; set; } + #region Load Methods @@ -108,6 +113,11 @@ public ContainerAgent() instance.EnvironmentVariables = LoadEnvironmentVariables(environmentVariablesValue, context); } + if (data.TryGetValue("codeConfiguration", out var codeConfigurationValue) && codeConfigurationValue is not null) + { + instance.CodeConfiguration = CodeConfiguration.Load(codeConfigurationValue.GetDictionary(), context); + } + if (context is not null) { instance = context.ProcessOutput(instance); @@ -259,6 +269,11 @@ public static IList LoadEnvironmentVariables(object data, L result["environmentVariables"] = SaveEnvironmentVariables(obj.EnvironmentVariables, context); } + if (obj.CodeConfiguration is not null) + { + result["codeConfiguration"] = obj.CodeConfiguration?.Save(context); + } + return result; } diff --git a/runtime/go/agentschema/agent_definition.go b/runtime/go/agentschema/agent_definition.go index 7ab3c8c..12f5787 100644 --- a/runtime/go/agentschema/agent_definition.go +++ b/runtime/go/agentschema/agent_definition.go @@ -382,6 +382,7 @@ type ContainerAgent struct { DockerfilePath *string `json:"dockerfilePath,omitempty" yaml:"dockerfilePath,omitempty"` Resources ContainerResources `json:"resources" yaml:"resources"` EnvironmentVariables []EnvironmentVariable `json:"environmentVariables,omitempty" yaml:"environmentVariables,omitempty"` + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty" yaml:"codeConfiguration,omitempty"` } // LoadContainerAgent creates a ContainerAgent from a map[string]interface{} @@ -429,6 +430,12 @@ func LoadContainerAgent(data interface{}, ctx *LoadContext) (ContainerAgent, err } } } + if val, ok := m["codeConfiguration"]; ok && val != nil { + if m, ok := val.(map[string]interface{}); ok { + loaded, _ := LoadCodeConfiguration(m, ctx) + result.CodeConfiguration = &loaded + } + } } return result, nil @@ -460,6 +467,9 @@ func (obj *ContainerAgent) Save(ctx *SaveContext) map[string]interface{} { } result["environmentVariables"] = arr } + if obj.CodeConfiguration != nil { + result["codeConfiguration"] = obj.CodeConfiguration.Save(ctx) + } return result } diff --git a/runtime/go/agentschema/code_configuration.go b/runtime/go/agentschema/code_configuration.go new file mode 100644 index 0000000..ee700b0 --- /dev/null +++ b/runtime/go/agentschema/code_configuration.go @@ -0,0 +1,93 @@ +// Code generated by AgentSchema emitter; DO NOT EDIT. + +package agentschema + +import ( + "encoding/json" + + "gopkg.in/yaml.v3" +) + +// CodeConfiguration represents Configuration for code-based (ZIP upload) deployment of a hosted agent. +// When present, the agent source code is uploaded directly instead of building a container image. + +type CodeConfiguration struct { + Runtime string `json:"runtime" yaml:"runtime"` + EntryPoint string `json:"entryPoint" yaml:"entryPoint"` + DependencyResolution *string `json:"dependencyResolution,omitempty" yaml:"dependencyResolution,omitempty"` +} + +// LoadCodeConfiguration creates a CodeConfiguration from a map[string]interface{} +func LoadCodeConfiguration(data interface{}, ctx *LoadContext) (CodeConfiguration, error) { + result := CodeConfiguration{} + + // Load from map + if m, ok := data.(map[string]interface{}); ok { + if val, ok := m["runtime"]; ok && val != nil { + result.Runtime = val.(string) + } + if val, ok := m["entryPoint"]; ok && val != nil { + result.EntryPoint = val.(string) + } + if val, ok := m["dependencyResolution"]; ok && val != nil { + v := val.(string) + result.DependencyResolution = &v + } + } + + return result, nil +} + +// Save serializes CodeConfiguration to map[string]interface{} +func (obj *CodeConfiguration) Save(ctx *SaveContext) map[string]interface{} { + result := make(map[string]interface{}) + result["runtime"] = obj.Runtime + result["entryPoint"] = obj.EntryPoint + if obj.DependencyResolution != nil { + result["dependencyResolution"] = *obj.DependencyResolution + } + + return result +} + +// ToJSON serializes CodeConfiguration to JSON string +func (obj *CodeConfiguration) ToJSON() (string, error) { + ctx := NewSaveContext() + data := obj.Save(ctx) + bytes, err := json.Marshal(data) + if err != nil { + return "", err + } + return string(bytes), nil +} + +// ToYAML serializes CodeConfiguration to YAML string +func (obj *CodeConfiguration) ToYAML() (string, error) { + ctx := NewSaveContext() + data := obj.Save(ctx) + bytes, err := yaml.Marshal(data) + if err != nil { + return "", err + } + return string(bytes), nil +} + +// FromJSON creates CodeConfiguration from JSON string +func CodeConfigurationFromJSON(jsonStr string) (CodeConfiguration, error) { + var data map[string]interface{} + if err := json.Unmarshal([]byte(jsonStr), &data); err != nil { + return CodeConfiguration{}, err + } + ctx := NewLoadContext() + return LoadCodeConfiguration(data, ctx) +} + +// FromYAML creates CodeConfiguration from YAML string +func CodeConfigurationFromYAML(yamlStr string) (CodeConfiguration, error) { + var data map[string]interface{} + if err := yaml.Unmarshal([]byte(yamlStr), &data); err != nil { + return CodeConfiguration{}, err + } + ctx := NewLoadContext() + return LoadCodeConfiguration(data, ctx) +} diff --git a/runtime/go/agentschema/code_configuration_test.go b/runtime/go/agentschema/code_configuration_test.go new file mode 100644 index 0000000..9192fc5 --- /dev/null +++ b/runtime/go/agentschema/code_configuration_test.go @@ -0,0 +1,168 @@ +// Code generated by AgentSchema emitter; DO NOT EDIT. + +package agentschema_test + +import ( + "encoding/json" + "testing" + + "gopkg.in/yaml.v3" + + "github.com/microsoft/agentschema-go/agentschema" +) + +// TestCodeConfigurationLoadJSON tests loading CodeConfiguration from JSON +func TestCodeConfigurationLoadJSON(t *testing.T) { + jsonData := ` +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +` + var data map[string]interface{} + if err := json.Unmarshal([]byte(jsonData), &data); err != nil { + t.Fatalf("Failed to parse JSON: %v", err) + } + + ctx := agentschema.NewLoadContext() + instance, err := agentschema.LoadCodeConfiguration(data, ctx) + if err != nil { + t.Fatalf("Failed to load CodeConfiguration: %v", err) + } + if instance.Runtime != "python_3_11" { + t.Errorf(`Expected Runtime to be "python_3_11", got %v`, instance.Runtime) + } + if instance.EntryPoint != "main.py" { + t.Errorf(`Expected EntryPoint to be "main.py", got %v`, instance.EntryPoint) + } + if instance.DependencyResolution == nil || *instance.DependencyResolution != "remote_build" { + t.Errorf(`Expected DependencyResolution to be "remote_build", got %v`, instance.DependencyResolution) + } +} + +// TestCodeConfigurationLoadYAML tests loading CodeConfiguration from YAML +func TestCodeConfigurationLoadYAML(t *testing.T) { + yamlData := ` +runtime: python_3_11 +entryPoint: main.py +dependencyResolution: remote_build + +` + var data map[string]interface{} + if err := yaml.Unmarshal([]byte(yamlData), &data); err != nil { + t.Fatalf("Failed to parse YAML: %v", err) + } + + ctx := agentschema.NewLoadContext() + instance, err := agentschema.LoadCodeConfiguration(data, ctx) + if err != nil { + t.Fatalf("Failed to load CodeConfiguration: %v", err) + } + if instance.Runtime != "python_3_11" { + t.Errorf(`Expected Runtime to be "python_3_11", got %v`, instance.Runtime) + } + if instance.EntryPoint != "main.py" { + t.Errorf(`Expected EntryPoint to be "main.py", got %v`, instance.EntryPoint) + } + if instance.DependencyResolution == nil || *instance.DependencyResolution != "remote_build" { + t.Errorf(`Expected DependencyResolution to be "remote_build", got %v`, instance.DependencyResolution) + } +} + +// TestCodeConfigurationRoundtrip tests load -> save -> load produces equivalent data +func TestCodeConfigurationRoundtrip(t *testing.T) { + jsonData := ` +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +` + var data map[string]interface{} + if err := json.Unmarshal([]byte(jsonData), &data); err != nil { + t.Fatalf("Failed to parse JSON: %v", err) + } + + loadCtx := agentschema.NewLoadContext() + instance, err := agentschema.LoadCodeConfiguration(data, loadCtx) + if err != nil { + t.Fatalf("Failed to load CodeConfiguration: %v", err) + } + saveCtx := agentschema.NewSaveContext() + savedData := instance.Save(saveCtx) + + reloaded, err := agentschema.LoadCodeConfiguration(savedData, loadCtx) + if err != nil { + t.Fatalf("Failed to reload CodeConfiguration: %v", err) + } + if reloaded.Runtime != "python_3_11" { + t.Errorf(`Expected Runtime to be "python_3_11", got %v`, reloaded.Runtime) + } + if reloaded.EntryPoint != "main.py" { + t.Errorf(`Expected EntryPoint to be "main.py", got %v`, reloaded.EntryPoint) + } + if reloaded.DependencyResolution == nil || *reloaded.DependencyResolution != "remote_build" { + t.Errorf(`Expected DependencyResolution to be "remote_build", got %v`, reloaded.DependencyResolution) + } +} + +// TestCodeConfigurationToJSON tests that ToJSON produces valid JSON +func TestCodeConfigurationToJSON(t *testing.T) { + jsonData := ` +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +` + var data map[string]interface{} + if err := json.Unmarshal([]byte(jsonData), &data); err != nil { + t.Fatalf("Failed to parse JSON: %v", err) + } + + ctx := agentschema.NewLoadContext() + instance, err := agentschema.LoadCodeConfiguration(data, ctx) + if err != nil { + t.Fatalf("Failed to load CodeConfiguration: %v", err) + } + jsonOutput, err := instance.ToJSON() + if err != nil { + t.Fatalf("Failed to convert to JSON: %v", err) + } + + var parsed map[string]interface{} + if err := json.Unmarshal([]byte(jsonOutput), &parsed); err != nil { + t.Fatalf("Failed to parse generated JSON: %v", err) + } +} + +// TestCodeConfigurationToYAML tests that ToYAML produces valid YAML +func TestCodeConfigurationToYAML(t *testing.T) { + jsonData := ` +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +` + var data map[string]interface{} + if err := json.Unmarshal([]byte(jsonData), &data); err != nil { + t.Fatalf("Failed to parse JSON: %v", err) + } + + ctx := agentschema.NewLoadContext() + instance, err := agentschema.LoadCodeConfiguration(data, ctx) + if err != nil { + t.Fatalf("Failed to load CodeConfiguration: %v", err) + } + yamlOutput, err := instance.ToYAML() + if err != nil { + t.Fatalf("Failed to convert to YAML: %v", err) + } + + var parsed map[string]interface{} + if err := yaml.Unmarshal([]byte(yamlOutput), &parsed); err != nil { + t.Fatalf("Failed to parse generated YAML: %v", err) + } +} diff --git a/runtime/python/agentschema/src/agentschema/_AgentDefinition.py b/runtime/python/agentschema/src/agentschema/_AgentDefinition.py index 767785b..177b1f9 100644 --- a/runtime/python/agentschema/src/agentschema/_AgentDefinition.py +++ b/runtime/python/agentschema/src/agentschema/_AgentDefinition.py @@ -9,6 +9,7 @@ from typing import Any, ClassVar, Optional from ._context import LoadContext, SaveContext +from ._CodeConfiguration import CodeConfiguration from ._ContainerResources import ContainerResources from ._EnvironmentVariable import EnvironmentVariable from ._Model import Model @@ -465,6 +466,8 @@ class ContainerAgent(AgentDefinition): Resource allocation for the container environmentVariables : list[EnvironmentVariable] Environment variables to set in the container + codeConfiguration : Optional[CodeConfiguration] + Configuration for code-based (ZIP upload) deployment. When present, agent source code is uploaded directly instead of building a container image. """ _shorthand_property: ClassVar[Optional[str]] = None @@ -475,6 +478,7 @@ class ContainerAgent(AgentDefinition): dockerfilePath: Optional[str] = None resources: ContainerResources = field(default_factory=ContainerResources) environmentVariables: list[EnvironmentVariable] = field(default_factory=list) + codeConfiguration: Optional[CodeConfiguration] = None @staticmethod def load(data: Any, context: Optional[LoadContext] = None) -> "ContainerAgent": @@ -512,6 +516,10 @@ def load(data: Any, context: Optional[LoadContext] = None) -> "ContainerAgent": instance.environmentVariables = ContainerAgent.load_environmentVariables( data["environmentVariables"], context ) + if data is not None and "codeConfiguration" in data: + instance.codeConfiguration = CodeConfiguration.load( + data["codeConfiguration"], context + ) if context is not None: instance = context.process_output(instance) return instance @@ -647,6 +655,8 @@ def save(self, context: Optional[SaveContext] = None) -> dict[str, Any]: result["environmentVariables"] = ContainerAgent.save_environmentVariables( obj.environmentVariables, context ) + if obj.codeConfiguration is not None: + result["codeConfiguration"] = obj.codeConfiguration.save(context) return result diff --git a/runtime/python/agentschema/src/agentschema/_CodeConfiguration.py b/runtime/python/agentschema/src/agentschema/_CodeConfiguration.py new file mode 100644 index 0000000..68135f1 --- /dev/null +++ b/runtime/python/agentschema/src/agentschema/_CodeConfiguration.py @@ -0,0 +1,112 @@ +########################################## +# WARNING: This is an auto-generated file. +# DO NOT EDIT THIS FILE DIRECTLY +# ANY EDITS WILL BE LOST +########################################## + +from dataclasses import dataclass, field +from typing import Any, ClassVar, Optional + +from ._context import LoadContext, SaveContext + + +@dataclass +class CodeConfiguration: + """Configuration for code-based (ZIP upload) deployment of a hosted agent. + When present, the agent source code is uploaded directly instead of building a container image. + + Attributes + ---------- + runtime : str + Runtime identifier for code execution (e.g., 'python_3_11', 'dotnet_8'). + entryPoint : str + The entry point file for the agent (e.g., 'main.py' for Python, 'HelloWorld.dll' for .NET). + dependencyResolution : Optional[str] + How package dependencies are resolved at deployment time. + """ + + _shorthand_property: ClassVar[Optional[str]] = None + + runtime: str = field(default="") + entryPoint: str = field(default="") + dependencyResolution: Optional[str] = None + + @staticmethod + def load(data: Any, context: Optional[LoadContext] = None) -> "CodeConfiguration": + """Load a CodeConfiguration instance. + Args: + data (Any): The data to load the instance from. + context (Optional[LoadContext]): Optional context with pre/post processing callbacks. + Returns: + CodeConfiguration: The loaded CodeConfiguration instance. + + """ + + if context is not None: + data = context.process_input(data) + + if not isinstance(data, dict): + raise ValueError(f"Invalid data for CodeConfiguration: {data}") + + # create new instance + instance = CodeConfiguration() + + if data is not None and "runtime" in data: + instance.runtime = data["runtime"] + if data is not None and "entryPoint" in data: + instance.entryPoint = data["entryPoint"] + if data is not None and "dependencyResolution" in data: + instance.dependencyResolution = data["dependencyResolution"] + if context is not None: + instance = context.process_output(instance) + return instance + + def save(self, context: Optional[SaveContext] = None) -> dict[str, Any]: + """Save the CodeConfiguration instance to a dictionary. + Args: + context (Optional[SaveContext]): Optional context with pre/post processing callbacks. + Returns: + dict[str, Any]: The dictionary representation of this instance. + + """ + obj = self + if context is not None: + obj = context.process_object(obj) + + result: dict[str, Any] = {} + + if obj.runtime is not None: + result["runtime"] = obj.runtime + if obj.entryPoint is not None: + result["entryPoint"] = obj.entryPoint + if obj.dependencyResolution is not None: + result["dependencyResolution"] = obj.dependencyResolution + + if context is not None: + result = context.process_dict(result) + return result + + def to_yaml(self, context: Optional[SaveContext] = None) -> str: + """Convert the CodeConfiguration instance to a YAML string. + Args: + context (Optional[SaveContext]): Optional context with pre/post processing callbacks. + Returns: + str: The YAML string representation of this instance. + + """ + if context is None: + context = SaveContext() + return context.to_yaml(self.save(context)) + + def to_json(self, context: Optional[SaveContext] = None, indent: int = 2) -> str: + """Convert the CodeConfiguration instance to a JSON string. + Args: + context (Optional[SaveContext]): Optional context with pre/post processing callbacks. + indent (int): Number of spaces for indentation. Defaults to 2. + Returns: + str: The JSON string representation of this instance. + + """ + if context is None: + context = SaveContext() + return context.to_json(self.save(context), indent) diff --git a/runtime/python/agentschema/src/agentschema/__init__.py b/runtime/python/agentschema/src/agentschema/__init__.py index 652ac00..82ac742 100644 --- a/runtime/python/agentschema/src/agentschema/__init__.py +++ b/runtime/python/agentschema/src/agentschema/__init__.py @@ -72,6 +72,9 @@ from ._EnvironmentVariable import EnvironmentVariable +from ._CodeConfiguration import CodeConfiguration + + from ._Resource import Resource, ModelResource, ToolResource @@ -115,6 +118,7 @@ "ProtocolVersionRecord", "ContainerResources", "EnvironmentVariable", + "CodeConfiguration", "ContainerAgent", "Resource", "ModelResource", diff --git a/runtime/python/agentschema/tests/test_code_configuration.py b/runtime/python/agentschema/tests/test_code_configuration.py new file mode 100644 index 0000000..64dfb31 --- /dev/null +++ b/runtime/python/agentschema/tests/test_code_configuration.py @@ -0,0 +1,88 @@ +import json +import yaml + +from agentschema import CodeConfiguration + + +def test_load_json_codeconfiguration(): + json_data = r""" + { + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" + } + """ + data = json.loads(json_data, strict=False) + instance = CodeConfiguration.load(data) + assert instance is not None + assert instance.runtime == "python_3_11" + assert instance.entryPoint == "main.py" + assert instance.dependencyResolution == "remote_build" + + +def test_load_yaml_codeconfiguration(): + yaml_data = r""" + runtime: python_3_11 + entryPoint: main.py + dependencyResolution: remote_build + + """ + data = yaml.load(yaml_data, Loader=yaml.FullLoader) + instance = CodeConfiguration.load(data) + assert instance is not None + assert instance.runtime == "python_3_11" + assert instance.entryPoint == "main.py" + assert instance.dependencyResolution == "remote_build" + + +def test_roundtrip_json_codeconfiguration(): + """Test that load -> save -> load produces equivalent data.""" + json_data = r""" + { + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" + } + """ + original_data = json.loads(json_data, strict=False) + instance = CodeConfiguration.load(original_data) + saved_data = instance.save() + reloaded = CodeConfiguration.load(saved_data) + assert reloaded is not None + assert reloaded.runtime == "python_3_11" + assert reloaded.entryPoint == "main.py" + assert reloaded.dependencyResolution == "remote_build" + + +def test_to_json_codeconfiguration(): + """Test that to_json produces valid JSON.""" + json_data = r""" + { + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" + } + """ + data = json.loads(json_data, strict=False) + instance = CodeConfiguration.load(data) + json_output = instance.to_json() + assert json_output is not None + parsed = json.loads(json_output) + assert isinstance(parsed, dict) + + +def test_to_yaml_codeconfiguration(): + """Test that to_yaml produces valid YAML.""" + json_data = r""" + { + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" + } + """ + data = json.loads(json_data, strict=False) + instance = CodeConfiguration.load(data) + yaml_output = instance.to_yaml() + assert yaml_output is not None + parsed = yaml.safe_load(yaml_output) + assert isinstance(parsed, dict) diff --git a/runtime/rust/agentschema/src/agent_definition.rs b/runtime/rust/agentschema/src/agent_definition.rs index 9770c9d..a1a5f7c 100644 --- a/runtime/rust/agentschema/src/agent_definition.rs +++ b/runtime/rust/agentschema/src/agent_definition.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + +use crate::code_configuration::CodeConfiguration; + use crate::container_resources::ContainerResources; use crate::environment_variable::EnvironmentVariable; @@ -14,6 +19,8 @@ use crate::template::Template; use crate::tool::Tool; + + /// The following is a specification for defining AI agents with structured metadata, inputs, outputs, tools, and templates. It provides a way to create reusable and composable AI agents that can be executed with specific configurations. The specification includes metadata about the agent, model configuration, input parameters, expected outputs, available tools, and template configurations for prompt rendering. #[derive(Debug, Clone, Default)] pub struct AgentDefinition { @@ -54,36 +61,13 @@ impl AgentDefinition { /// Load AgentDefinition from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - display_name: value - .get("displayName") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - description: value - .get("description") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - metadata: value - .get("metadata") - .cloned() - .unwrap_or(serde_json::Value::Null), - input_schema: value - .get("inputSchema") - .filter(|v| v.is_object() || v.is_array()) - .map(PropertySchema::load_from_value), - output_schema: value - .get("outputSchema") - .filter(|v| v.is_object() || v.is_array()) - .map(PropertySchema::load_from_value), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + display_name: value.get("displayName").and_then(|v| v.as_str()).map(|s| s.to_string()), + description: value.get("description").and_then(|v| v.as_str()).map(|s| s.to_string()), + metadata: value.get("metadata").cloned().unwrap_or(serde_json::Value::Null), + input_schema: value.get("inputSchema").filter(|v| v.is_object() || v.is_array()).map(PropertySchema::load_from_value), + output_schema: value.get("outputSchema").filter(|v| v.is_object() || v.is_array()).map(PropertySchema::load_from_value), } } @@ -91,28 +75,16 @@ impl AgentDefinition { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if let Some(ref val) = self.display_name { - result.insert( - "displayName".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("displayName".to_string(), serde_json::Value::String(val.clone())); } if let Some(ref val) = self.description { - result.insert( - "description".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("description".to_string(), serde_json::Value::String(val.clone())); } if !self.metadata.is_null() { result.insert("metadata".to_string(), self.metadata.clone()); @@ -148,6 +120,7 @@ impl AgentDefinition { } } + /// Prompt based agent definition. Used to create agents that can be executed directly. These agents can leverage tools, input parameters, and templates to generate responses. They are designed to be straightforward and easy to use for various applications. #[derive(Debug, Clone, Default)] pub struct PromptAgent { @@ -186,32 +159,12 @@ impl PromptAgent { /// Load PromptAgent from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - model: value - .get("model") - .filter(|v| v.is_object() || v.is_array()) - .map(Model::load_from_value) - .unwrap_or_default(), - tools: value - .get("tools") - .cloned() - .unwrap_or(serde_json::Value::Null), - template: value - .get("template") - .filter(|v| v.is_object() || v.is_array()) - .map(Template::load_from_value), - instructions: value - .get("instructions") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - additional_instructions: value - .get("additionalInstructions") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + model: value.get("model").filter(|v| v.is_object() || v.is_array()).map(Model::load_from_value).unwrap_or_default(), + tools: value.get("tools").cloned().unwrap_or(serde_json::Value::Null), + template: value.get("template").filter(|v| v.is_object() || v.is_array()).map(Template::load_from_value), + instructions: value.get("instructions").and_then(|v| v.as_str()).map(|s| s.to_string()), + additional_instructions: value.get("additionalInstructions").and_then(|v| v.as_str()).map(|s| s.to_string()), } } @@ -219,10 +172,7 @@ impl PromptAgent { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } { let nested = self.model.to_value(); @@ -240,16 +190,10 @@ impl PromptAgent { } } if let Some(ref val) = self.instructions { - result.insert( - "instructions".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("instructions".to_string(), serde_json::Value::String(val.clone())); } if let Some(ref val) = self.additional_instructions { - result.insert( - "additionalInstructions".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("additionalInstructions".to_string(), serde_json::Value::String(val.clone())); } serde_json::Value::Object(result) } @@ -268,7 +212,9 @@ impl PromptAgent { /// Returns `None` if the field is null or cannot be parsed. pub fn as_tools(&self) -> Option> { match &self.tools { - serde_json::Value::Array(arr) => Some(arr.iter().map(Tool::load_from_value).collect()), + serde_json::Value::Array(arr) => { + Some(arr.iter().map(Tool::load_from_value).collect()) + } serde_json::Value::Object(obj) => { let result: Vec = obj .iter() @@ -279,8 +225,7 @@ impl PromptAgent { serde_json::json!({ "value": value }) }; if let serde_json::Value::Object(ref mut m) = v { - m.entry("name".to_string()) - .or_insert_with(|| serde_json::Value::String(name.clone())); + m.entry("name".to_string()).or_insert_with(|| serde_json::Value::String(name.clone())); } Tool::load_from_value(&v) }) @@ -292,6 +237,7 @@ impl PromptAgent { } } + /// A workflow agent that can orchestrate multiple steps and actions. This agent type is designed to handle complex workflows that may involve multiple tools, models, and decision points. The workflow agent can be configured with a series of steps that define the flow of execution, including conditional logic and parallel processing. This allows for the creation of sophisticated AI-driven processes that can adapt to various scenarios and requirements. Note: The detailed structure of the workflow steps and actions is not defined here and would need to be implemented based on specific use cases and requirements. #[derive(Debug, Clone, Default)] pub struct Workflow { @@ -322,15 +268,8 @@ impl Workflow { /// Load Workflow from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - trigger: value - .get("trigger") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + trigger: value.get("trigger").cloned().unwrap_or(serde_json::Value::Null), } } @@ -338,10 +277,7 @@ impl Workflow { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.trigger.is_null() { result.insert("trigger".to_string(), self.trigger.clone()); @@ -365,6 +301,7 @@ impl Workflow { } } + /// This represents a container based agent hosted by the provider/publisher. The intent is to represent a container application that the user wants to run in a hosted environment that the provider manages. #[derive(Debug, Clone, Default)] pub struct ContainerAgent { @@ -380,6 +317,8 @@ pub struct ContainerAgent { pub resources: ContainerResources, /// Environment variables to set in the container pub environment_variables: serde_json::Value, + /// Configuration for code-based (ZIP upload) deployment. When present, agent source code is uploaded directly instead of building a container image. + pub code_configuration: Option, } impl ContainerAgent { @@ -403,32 +342,13 @@ impl ContainerAgent { /// Load ContainerAgent from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - protocols: value - .get("protocols") - .cloned() - .unwrap_or(serde_json::Value::Null), - image: value - .get("image") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - dockerfile_path: value - .get("dockerfilePath") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - resources: value - .get("resources") - .filter(|v| v.is_object() || v.is_array()) - .map(ContainerResources::load_from_value) - .unwrap_or_default(), - environment_variables: value - .get("environmentVariables") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + protocols: value.get("protocols").cloned().unwrap_or(serde_json::Value::Null), + image: value.get("image").and_then(|v| v.as_str()).map(|s| s.to_string()), + dockerfile_path: value.get("dockerfilePath").and_then(|v| v.as_str()).map(|s| s.to_string()), + resources: value.get("resources").filter(|v| v.is_object() || v.is_array()).map(ContainerResources::load_from_value).unwrap_or_default(), + environment_variables: value.get("environmentVariables").cloned().unwrap_or(serde_json::Value::Null), + code_configuration: value.get("codeConfiguration").filter(|v| v.is_object() || v.is_array()).map(CodeConfiguration::load_from_value), } } @@ -436,10 +356,7 @@ impl ContainerAgent { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.protocols.is_null() { result.insert("protocols".to_string(), self.protocols.clone()); @@ -448,10 +365,7 @@ impl ContainerAgent { result.insert("image".to_string(), serde_json::Value::String(val.clone())); } if let Some(ref val) = self.dockerfile_path { - result.insert( - "dockerfilePath".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("dockerfilePath".to_string(), serde_json::Value::String(val.clone())); } { let nested = self.resources.to_value(); @@ -460,10 +374,13 @@ impl ContainerAgent { } } if !self.environment_variables.is_null() { - result.insert( - "environmentVariables".to_string(), - self.environment_variables.clone(), - ); + result.insert("environmentVariables".to_string(), self.environment_variables.clone()); + } + if let Some(ref val) = self.code_configuration { + let nested = val.to_value(); + if !nested.is_null() { + result.insert("codeConfiguration".to_string(), nested); + } } serde_json::Value::Object(result) } @@ -482,11 +399,9 @@ impl ContainerAgent { /// Returns `None` if the field is null or cannot be parsed. pub fn as_protocols(&self) -> Option> { match &self.protocols { - serde_json::Value::Array(arr) => Some( - arr.iter() - .map(ProtocolVersionRecord::load_from_value) - .collect(), - ), + serde_json::Value::Array(arr) => { + Some(arr.iter().map(ProtocolVersionRecord::load_from_value).collect()) + } serde_json::Value::Object(obj) => { let result: Vec = obj .iter() @@ -497,8 +412,7 @@ impl ContainerAgent { serde_json::json!({ "value": value }) }; if let serde_json::Value::Object(ref mut m) = v { - m.entry("name".to_string()) - .or_insert_with(|| serde_json::Value::String(name.clone())); + m.entry("name".to_string()).or_insert_with(|| serde_json::Value::String(name.clone())); } ProtocolVersionRecord::load_from_value(&v) }) @@ -513,11 +427,9 @@ impl ContainerAgent { /// Returns `None` if the field is null or cannot be parsed. pub fn as_environment_variables(&self) -> Option> { match &self.environment_variables { - serde_json::Value::Array(arr) => Some( - arr.iter() - .map(EnvironmentVariable::load_from_value) - .collect(), - ), + serde_json::Value::Array(arr) => { + Some(arr.iter().map(EnvironmentVariable::load_from_value).collect()) + } serde_json::Value::Object(obj) => { let result: Vec = obj .iter() @@ -528,8 +440,7 @@ impl ContainerAgent { serde_json::json!({ "value": value }) }; if let serde_json::Value::Object(ref mut m) = v { - m.entry("name".to_string()) - .or_insert_with(|| serde_json::Value::String(name.clone())); + m.entry("name".to_string()).or_insert_with(|| serde_json::Value::String(name.clone())); } EnvironmentVariable::load_from_value(&v) }) @@ -540,3 +451,5 @@ impl ContainerAgent { } } } + + diff --git a/runtime/rust/agentschema/src/agent_manifest.rs b/runtime/rust/agentschema/src/agent_manifest.rs index 06f369e..5de9c2d 100644 --- a/runtime/rust/agentschema/src/agent_manifest.rs +++ b/runtime/rust/agentschema/src/agent_manifest.rs @@ -1,9 +1,14 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + use crate::property_schema::PropertySchema; use crate::resource::Resource; + + /// The following represents a manifest that can be used to create agents dynamically. It includes parameters that can be used to configure the agent's behavior. These parameters include values that can be used as publisher parameters that can be used to describe additional variables that have been tested and are known to work. Variables described here are then used to project into a prompt agent that can be executed. Once parameters are provided, these can be referenced in the manifest using the following notation: `{{myParameter}}` This allows for dynamic configuration of the agent based on the provided parameters. (This notation is used elsewhere, but only the `param` scope is supported here) #[derive(Debug, Clone, Default)] pub struct AgentManifest { @@ -44,37 +49,13 @@ impl AgentManifest { /// Load AgentManifest from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - display_name: value - .get("displayName") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - description: value - .get("description") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - metadata: value - .get("metadata") - .cloned() - .unwrap_or(serde_json::Value::Null), - template: value - .get("template") - .cloned() - .unwrap_or(serde_json::Value::Null), - parameters: value - .get("parameters") - .filter(|v| v.is_object() || v.is_array()) - .map(PropertySchema::load_from_value) - .unwrap_or_default(), - resources: value - .get("resources") - .cloned() - .unwrap_or(serde_json::Value::Null), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + display_name: value.get("displayName").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + description: value.get("description").and_then(|v| v.as_str()).map(|s| s.to_string()), + metadata: value.get("metadata").cloned().unwrap_or(serde_json::Value::Null), + template: value.get("template").cloned().unwrap_or(serde_json::Value::Null), + parameters: value.get("parameters").filter(|v| v.is_object() || v.is_array()).map(PropertySchema::load_from_value).unwrap_or_default(), + resources: value.get("resources").cloned().unwrap_or(serde_json::Value::Null), } } @@ -82,22 +63,13 @@ impl AgentManifest { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if !self.display_name.is_empty() { - result.insert( - "displayName".to_string(), - serde_json::Value::String(self.display_name.clone()), - ); + result.insert("displayName".to_string(), serde_json::Value::String(self.display_name.clone())); } if let Some(ref val) = self.description { - result.insert( - "description".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("description".to_string(), serde_json::Value::String(val.clone())); } if !self.metadata.is_null() { result.insert("metadata".to_string(), self.metadata.clone()); @@ -149,8 +121,7 @@ impl AgentManifest { serde_json::json!({ "value": value }) }; if let serde_json::Value::Object(ref mut m) = v { - m.entry("name".to_string()) - .or_insert_with(|| serde_json::Value::String(name.clone())); + m.entry("name".to_string()).or_insert_with(|| serde_json::Value::String(name.clone())); } Resource::load_from_value(&v) }) @@ -161,3 +132,5 @@ impl AgentManifest { } } } + + diff --git a/runtime/rust/agentschema/src/binding.rs b/runtime/rust/agentschema/src/binding.rs index 3728916..8d6e973 100644 --- a/runtime/rust/agentschema/src/binding.rs +++ b/runtime/rust/agentschema/src/binding.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Represents a binding between an input property and a tool parameter. #[derive(Debug, Clone, Default)] pub struct Binding { @@ -35,16 +40,8 @@ impl Binding { return Self::load_from_value(&expansion); } Self { - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - input: value - .get("input") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + input: value.get("input").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -52,16 +49,10 @@ impl Binding { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if !self.input.is_empty() { - result.insert( - "input".to_string(), - serde_json::Value::String(self.input.clone()), - ); + result.insert("input".to_string(), serde_json::Value::String(self.input.clone())); } serde_json::Value::Object(result) } @@ -76,3 +67,5 @@ impl Binding { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/src/code_configuration.rs b/runtime/rust/agentschema/src/code_configuration.rs new file mode 100644 index 0000000..ead6154 --- /dev/null +++ b/runtime/rust/agentschema/src/code_configuration.rs @@ -0,0 +1,72 @@ + + +// Code generated by AgentSchema emitter; DO NOT EDIT. + + + + +/// Configuration for code-based (ZIP upload) deployment of a hosted agent. When present, the agent source code is uploaded directly instead of building a container image. +#[derive(Debug, Clone, Default)] +pub struct CodeConfiguration { + /// Runtime identifier for code execution (e.g., 'python_3_11', 'dotnet_8'). + pub runtime: String, + /// The entry point file for the agent (e.g., 'main.py' for Python, 'HelloWorld.dll' for .NET). + pub entry_point: String, + /// How package dependencies are resolved at deployment time. + pub dependency_resolution: Option, +} + +impl CodeConfiguration { + /// Create a new CodeConfiguration with default values. + pub fn new() -> Self { + Self::default() + } + + /// Load CodeConfiguration from a JSON string. + pub fn from_json(json: &str) -> Result { + let value: serde_json::Value = serde_json::from_str(json)?; + Ok(Self::load_from_value(&value)) + } + + /// Load CodeConfiguration from a YAML string. + pub fn from_yaml(yaml: &str) -> Result { + let value: serde_json::Value = serde_yaml::from_str(yaml)?; + Ok(Self::load_from_value(&value)) + } + + /// Load CodeConfiguration from a `serde_json::Value`. + pub fn load_from_value(value: &serde_json::Value) -> Self { + Self { + runtime: value.get("runtime").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + entry_point: value.get("entryPoint").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + dependency_resolution: value.get("dependencyResolution").and_then(|v| v.as_str()).map(|s| s.to_string()), + } + } + + /// Serialize CodeConfiguration to a `serde_json::Value`. + pub fn to_value(&self) -> serde_json::Value { + let mut result = serde_json::Map::new(); + if !self.runtime.is_empty() { + result.insert("runtime".to_string(), serde_json::Value::String(self.runtime.clone())); + } + if !self.entry_point.is_empty() { + result.insert("entryPoint".to_string(), serde_json::Value::String(self.entry_point.clone())); + } + if let Some(ref val) = self.dependency_resolution { + result.insert("dependencyResolution".to_string(), serde_json::Value::String(val.clone())); + } + serde_json::Value::Object(result) + } + + /// Serialize CodeConfiguration to a JSON string. + pub fn to_json(&self) -> Result { + serde_json::to_string_pretty(&self.to_value()) + } + + /// Serialize CodeConfiguration to a YAML string. + pub fn to_yaml(&self) -> Result { + serde_yaml::to_string(&self.to_value()) + } +} + + diff --git a/runtime/rust/agentschema/src/connection.rs b/runtime/rust/agentschema/src/connection.rs index 73a3d65..75b1bb3 100644 --- a/runtime/rust/agentschema/src/connection.rs +++ b/runtime/rust/agentschema/src/connection.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Connection configuration for AI agents. `provider`, `kind`, and `endpoint` are required properties here, but this section can accept additional via options. #[derive(Debug, Clone, Default)] pub struct Connection { @@ -32,20 +37,9 @@ impl Connection { /// Load Connection from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - authentication_mode: value - .get("authenticationMode") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - usage_description: value - .get("usageDescription") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + authentication_mode: value.get("authenticationMode").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + usage_description: value.get("usageDescription").and_then(|v| v.as_str()).map(|s| s.to_string()), } } @@ -53,22 +47,13 @@ impl Connection { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.authentication_mode.is_empty() { - result.insert( - "authenticationMode".to_string(), - serde_json::Value::String(self.authentication_mode.clone()), - ); + result.insert("authenticationMode".to_string(), serde_json::Value::String(self.authentication_mode.clone())); } if let Some(ref val) = self.usage_description { - result.insert( - "usageDescription".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("usageDescription".to_string(), serde_json::Value::String(val.clone())); } serde_json::Value::Object(result) } @@ -84,6 +69,7 @@ impl Connection { } } + /// Connection configuration for AI services using named connections. #[derive(Debug, Clone, Default)] pub struct ReferenceConnection { @@ -116,20 +102,9 @@ impl ReferenceConnection { /// Load ReferenceConnection from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - target: value - .get("target") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + target: value.get("target").and_then(|v| v.as_str()).map(|s| s.to_string()), } } @@ -137,16 +112,10 @@ impl ReferenceConnection { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if let Some(ref val) = self.target { result.insert("target".to_string(), serde_json::Value::String(val.clone())); @@ -165,6 +134,7 @@ impl ReferenceConnection { } } + /// Connection configuration for AI services using named connections. #[derive(Debug, Clone, Default)] pub struct RemoteConnection { @@ -197,21 +167,9 @@ impl RemoteConnection { /// Load RemoteConnection from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - endpoint: value - .get("endpoint") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + endpoint: value.get("endpoint").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -219,22 +177,13 @@ impl RemoteConnection { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if !self.endpoint.is_empty() { - result.insert( - "endpoint".to_string(), - serde_json::Value::String(self.endpoint.clone()), - ); + result.insert("endpoint".to_string(), serde_json::Value::String(self.endpoint.clone())); } serde_json::Value::Object(result) } @@ -250,6 +199,7 @@ impl RemoteConnection { } } + /// Connection configuration for AI services using API keys. #[derive(Debug, Clone, Default)] pub struct ApiKeyConnection { @@ -282,21 +232,9 @@ impl ApiKeyConnection { /// Load ApiKeyConnection from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - endpoint: value - .get("endpoint") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - api_key: value - .get("apiKey") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + endpoint: value.get("endpoint").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + api_key: value.get("apiKey").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -304,22 +242,13 @@ impl ApiKeyConnection { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.endpoint.is_empty() { - result.insert( - "endpoint".to_string(), - serde_json::Value::String(self.endpoint.clone()), - ); + result.insert("endpoint".to_string(), serde_json::Value::String(self.endpoint.clone())); } if !self.api_key.is_empty() { - result.insert( - "apiKey".to_string(), - serde_json::Value::String(self.api_key.clone()), - ); + result.insert("apiKey".to_string(), serde_json::Value::String(self.api_key.clone())); } serde_json::Value::Object(result) } @@ -335,6 +264,7 @@ impl ApiKeyConnection { } } + /// AnonymousConnection schema type #[derive(Debug, Clone, Default)] pub struct AnonymousConnection { @@ -365,16 +295,8 @@ impl AnonymousConnection { /// Load AnonymousConnection from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - endpoint: value - .get("endpoint") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + endpoint: value.get("endpoint").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -382,16 +304,10 @@ impl AnonymousConnection { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.endpoint.is_empty() { - result.insert( - "endpoint".to_string(), - serde_json::Value::String(self.endpoint.clone()), - ); + result.insert("endpoint".to_string(), serde_json::Value::String(self.endpoint.clone())); } serde_json::Value::Object(result) } @@ -407,6 +323,7 @@ impl AnonymousConnection { } } + /// Connection configuration for Microsoft Foundry projects. Provides project-scoped access to models, tools, and services via Entra ID (DefaultAzureCredential) authentication. #[derive(Debug, Clone, Default)] pub struct FoundryConnection { @@ -441,24 +358,10 @@ impl FoundryConnection { /// Load FoundryConnection from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - endpoint: value - .get("endpoint") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - name: value - .get("name") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - connection_type: value - .get("connectionType") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + endpoint: value.get("endpoint").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + name: value.get("name").and_then(|v| v.as_str()).map(|s| s.to_string()), + connection_type: value.get("connectionType").and_then(|v| v.as_str()).map(|s| s.to_string()), } } @@ -466,25 +369,16 @@ impl FoundryConnection { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.endpoint.is_empty() { - result.insert( - "endpoint".to_string(), - serde_json::Value::String(self.endpoint.clone()), - ); + result.insert("endpoint".to_string(), serde_json::Value::String(self.endpoint.clone())); } if let Some(ref val) = self.name { result.insert("name".to_string(), serde_json::Value::String(val.clone())); } if let Some(ref val) = self.connection_type { - result.insert( - "connectionType".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("connectionType".to_string(), serde_json::Value::String(val.clone())); } serde_json::Value::Object(result) } @@ -500,6 +394,7 @@ impl FoundryConnection { } } + /// Connection configuration using OAuth 2.0 client credentials. Useful for tools and services that require OAuth authentication, such as MCP servers, OpenAPI endpoints, or other REST APIs. #[derive(Debug, Clone, Default)] pub struct OAuthConnection { @@ -538,36 +433,12 @@ impl OAuthConnection { /// Load OAuthConnection from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - endpoint: value - .get("endpoint") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - client_id: value - .get("clientId") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - client_secret: value - .get("clientSecret") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - token_url: value - .get("tokenUrl") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - scopes: value.get("scopes").and_then(|v| v.as_array()).map(|arr| { - arr.iter() - .filter_map(|v| v.as_str().map(|s| s.to_string())) - .collect() - }), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + endpoint: value.get("endpoint").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + client_id: value.get("clientId").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + client_secret: value.get("clientSecret").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + token_url: value.get("tokenUrl").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + scopes: value.get("scopes").and_then(|v| v.as_array()).map(|arr| arr.iter().filter_map(|v| v.as_str().map(|s| s.to_string())).collect()), } } @@ -575,40 +446,22 @@ impl OAuthConnection { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.endpoint.is_empty() { - result.insert( - "endpoint".to_string(), - serde_json::Value::String(self.endpoint.clone()), - ); + result.insert("endpoint".to_string(), serde_json::Value::String(self.endpoint.clone())); } if !self.client_id.is_empty() { - result.insert( - "clientId".to_string(), - serde_json::Value::String(self.client_id.clone()), - ); + result.insert("clientId".to_string(), serde_json::Value::String(self.client_id.clone())); } if !self.client_secret.is_empty() { - result.insert( - "clientSecret".to_string(), - serde_json::Value::String(self.client_secret.clone()), - ); + result.insert("clientSecret".to_string(), serde_json::Value::String(self.client_secret.clone())); } if !self.token_url.is_empty() { - result.insert( - "tokenUrl".to_string(), - serde_json::Value::String(self.token_url.clone()), - ); + result.insert("tokenUrl".to_string(), serde_json::Value::String(self.token_url.clone())); } if let Some(ref items) = self.scopes { - result.insert( - "scopes".to_string(), - serde_json::to_value(items).unwrap_or(serde_json::Value::Null), - ); + result.insert("scopes".to_string(), serde_json::to_value(items).unwrap_or(serde_json::Value::Null)); } serde_json::Value::Object(result) } @@ -623,3 +476,5 @@ impl OAuthConnection { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/src/container_resources.rs b/runtime/rust/agentschema/src/container_resources.rs index 8fc4f29..ab48b5e 100644 --- a/runtime/rust/agentschema/src/container_resources.rs +++ b/runtime/rust/agentschema/src/container_resources.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Resource allocation for a containerized agent. Valid CPU and memory pairings depend on the target hosting provider. #[derive(Debug, Clone, Default)] pub struct ContainerResources { @@ -30,16 +35,8 @@ impl ContainerResources { /// Load ContainerResources from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - cpu: value - .get("cpu") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - memory: value - .get("memory") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + cpu: value.get("cpu").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + memory: value.get("memory").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -47,16 +44,10 @@ impl ContainerResources { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.cpu.is_empty() { - result.insert( - "cpu".to_string(), - serde_json::Value::String(self.cpu.clone()), - ); + result.insert("cpu".to_string(), serde_json::Value::String(self.cpu.clone())); } if !self.memory.is_empty() { - result.insert( - "memory".to_string(), - serde_json::Value::String(self.memory.clone()), - ); + result.insert("memory".to_string(), serde_json::Value::String(self.memory.clone())); } serde_json::Value::Object(result) } @@ -71,3 +62,5 @@ impl ContainerResources { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/src/context.rs b/runtime/rust/agentschema/src/context.rs index eed80c5..7ec8f8b 100644 --- a/runtime/rust/agentschema/src/context.rs +++ b/runtime/rust/agentschema/src/context.rs @@ -1,3 +1,4 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. // AgentSchema Context diff --git a/runtime/rust/agentschema/src/environment_variable.rs b/runtime/rust/agentschema/src/environment_variable.rs index ba576e2..a35c26c 100644 --- a/runtime/rust/agentschema/src/environment_variable.rs +++ b/runtime/rust/agentschema/src/environment_variable.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Definition for an environment variable used in containerized agents. #[derive(Debug, Clone, Default)] pub struct EnvironmentVariable { @@ -30,16 +35,8 @@ impl EnvironmentVariable { /// Load EnvironmentVariable from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - value: value - .get("value") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + value: value.get("value").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -47,16 +44,10 @@ impl EnvironmentVariable { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if !self.value.is_empty() { - result.insert( - "value".to_string(), - serde_json::Value::String(self.value.clone()), - ); + result.insert("value".to_string(), serde_json::Value::String(self.value.clone())); } serde_json::Value::Object(result) } @@ -71,3 +62,5 @@ impl EnvironmentVariable { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/src/format.rs b/runtime/rust/agentschema/src/format.rs index 499eb44..1a0aa7b 100644 --- a/runtime/rust/agentschema/src/format.rs +++ b/runtime/rust/agentschema/src/format.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Template format definition #[derive(Debug, Clone, Default)] pub struct Format { @@ -37,16 +42,9 @@ impl Format { return Self::load_from_value(&expansion); } Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), strict: value.get("strict").and_then(|v| v.as_bool()), - options: value - .get("options") - .cloned() - .unwrap_or(serde_json::Value::Null), + options: value.get("options").cloned().unwrap_or(serde_json::Value::Null), } } @@ -54,10 +52,7 @@ impl Format { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if let Some(val) = self.strict { result.insert("strict".to_string(), serde_json::Value::Bool(val)); @@ -83,3 +78,5 @@ impl Format { self.options.as_object() } } + + diff --git a/runtime/rust/agentschema/src/lib.rs b/runtime/rust/agentschema/src/lib.rs index 53176a1..1712c47 100644 --- a/runtime/rust/agentschema/src/lib.rs +++ b/runtime/rust/agentschema/src/lib.rs @@ -1,3 +1,4 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. pub mod context; @@ -48,8 +49,12 @@ pub use container_resources::*; pub mod environment_variable; pub use environment_variable::*; +pub mod code_configuration; +pub use code_configuration::*; + pub mod resource; pub use resource::*; pub mod agent_manifest; pub use agent_manifest::*; + diff --git a/runtime/rust/agentschema/src/mcp_server_approval_mode.rs b/runtime/rust/agentschema/src/mcp_server_approval_mode.rs index 2526ca5..94d28cd 100644 --- a/runtime/rust/agentschema/src/mcp_server_approval_mode.rs +++ b/runtime/rust/agentschema/src/mcp_server_approval_mode.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// The approval mode for MCP server tools. #[derive(Debug, Clone, Default)] pub struct McpServerApprovalMode { @@ -33,11 +38,7 @@ impl McpServerApprovalMode { return Self::load_from_value(&expansion); } Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -45,10 +46,7 @@ impl McpServerApprovalMode { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } serde_json::Value::Object(result) } @@ -64,6 +62,7 @@ impl McpServerApprovalMode { } } + /// McpServerToolAlwaysRequireApprovalMode schema type #[derive(Debug, Clone, Default)] pub struct McpServerToolAlwaysRequireApprovalMode { @@ -92,11 +91,7 @@ impl McpServerToolAlwaysRequireApprovalMode { /// Load McpServerToolAlwaysRequireApprovalMode from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -104,10 +99,7 @@ impl McpServerToolAlwaysRequireApprovalMode { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } serde_json::Value::Object(result) } @@ -123,6 +115,7 @@ impl McpServerToolAlwaysRequireApprovalMode { } } + /// McpServerToolNeverRequireApprovalMode schema type #[derive(Debug, Clone, Default)] pub struct McpServerToolNeverRequireApprovalMode { @@ -151,11 +144,7 @@ impl McpServerToolNeverRequireApprovalMode { /// Load McpServerToolNeverRequireApprovalMode from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -163,10 +152,7 @@ impl McpServerToolNeverRequireApprovalMode { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } serde_json::Value::Object(result) } @@ -182,6 +168,7 @@ impl McpServerToolNeverRequireApprovalMode { } } + /// McpServerToolSpecifyApprovalMode schema type #[derive(Debug, Clone, Default)] pub struct McpServerToolSpecifyApprovalMode { @@ -214,29 +201,9 @@ impl McpServerToolSpecifyApprovalMode { /// Load McpServerToolSpecifyApprovalMode from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - always_require_approval_tools: value - .get("alwaysRequireApprovalTools") - .and_then(|v| v.as_array()) - .map(|arr| { - arr.iter() - .filter_map(|v| v.as_str().map(|s| s.to_string())) - .collect() - }) - .unwrap_or_default(), - never_require_approval_tools: value - .get("neverRequireApprovalTools") - .and_then(|v| v.as_array()) - .map(|arr| { - arr.iter() - .filter_map(|v| v.as_str().map(|s| s.to_string())) - .collect() - }) - .unwrap_or_default(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + always_require_approval_tools: value.get("alwaysRequireApprovalTools").and_then(|v| v.as_array()).map(|arr| arr.iter().filter_map(|v| v.as_str().map(|s| s.to_string())).collect()).unwrap_or_default(), + never_require_approval_tools: value.get("neverRequireApprovalTools").and_then(|v| v.as_array()).map(|arr| arr.iter().filter_map(|v| v.as_str().map(|s| s.to_string())).collect()).unwrap_or_default(), } } @@ -244,24 +211,13 @@ impl McpServerToolSpecifyApprovalMode { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.always_require_approval_tools.is_empty() { - result.insert( - "alwaysRequireApprovalTools".to_string(), - serde_json::to_value(&self.always_require_approval_tools) - .unwrap_or(serde_json::Value::Null), - ); + result.insert("alwaysRequireApprovalTools".to_string(), serde_json::to_value(&self.always_require_approval_tools).unwrap_or(serde_json::Value::Null)); } if !self.never_require_approval_tools.is_empty() { - result.insert( - "neverRequireApprovalTools".to_string(), - serde_json::to_value(&self.never_require_approval_tools) - .unwrap_or(serde_json::Value::Null), - ); + result.insert("neverRequireApprovalTools".to_string(), serde_json::to_value(&self.never_require_approval_tools).unwrap_or(serde_json::Value::Null)); } serde_json::Value::Object(result) } @@ -276,3 +232,5 @@ impl McpServerToolSpecifyApprovalMode { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/src/model.rs b/runtime/rust/agentschema/src/model.rs index 6444915..1ac48d3 100644 --- a/runtime/rust/agentschema/src/model.rs +++ b/runtime/rust/agentschema/src/model.rs @@ -1,7 +1,12 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + use crate::model_options::ModelOptions; + + /// Model for defining the structure and behavior of AI agents. This model includes properties for specifying the model's provider, connection details, and various options. It allows for flexible configuration of AI models to suit different use cases and requirements. #[derive(Debug, Clone, Default)] pub struct Model { @@ -43,27 +48,11 @@ impl Model { return Self::load_from_value(&expansion); } Self { - id: value - .get("id") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - provider: value - .get("provider") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - api_type: value - .get("apiType") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - connection: value - .get("connection") - .cloned() - .unwrap_or(serde_json::Value::Null), - options: value - .get("options") - .filter(|v| v.is_object() || v.is_array()) - .map(ModelOptions::load_from_value), + id: value.get("id").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + provider: value.get("provider").and_then(|v| v.as_str()).map(|s| s.to_string()), + api_type: value.get("apiType").and_then(|v| v.as_str()).map(|s| s.to_string()), + connection: value.get("connection").cloned().unwrap_or(serde_json::Value::Null), + options: value.get("options").filter(|v| v.is_object() || v.is_array()).map(ModelOptions::load_from_value), } } @@ -74,16 +63,10 @@ impl Model { result.insert("id".to_string(), serde_json::Value::String(self.id.clone())); } if let Some(ref val) = self.provider { - result.insert( - "provider".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("provider".to_string(), serde_json::Value::String(val.clone())); } if let Some(ref val) = self.api_type { - result.insert( - "apiType".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("apiType".to_string(), serde_json::Value::String(val.clone())); } if !self.connection.is_null() { result.insert("connection".to_string(), self.connection.clone()); @@ -107,3 +90,5 @@ impl Model { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/src/model_options.rs b/runtime/rust/agentschema/src/model_options.rs index 654223a..1497b2c 100644 --- a/runtime/rust/agentschema/src/model_options.rs +++ b/runtime/rust/agentschema/src/model_options.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Options for configuring the behavior of the AI model. `kind` is a required property here, but this section can accept additional via options. #[derive(Debug, Clone, Default)] pub struct ModelOptions { @@ -46,40 +51,16 @@ impl ModelOptions { /// Load ModelOptions from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - frequency_penalty: value - .get("frequencyPenalty") - .and_then(|v| v.as_f64()) - .map(|n| n as f32), - max_output_tokens: value - .get("maxOutputTokens") - .and_then(|v| v.as_i64()) - .map(|n| n as i32), - presence_penalty: value - .get("presencePenalty") - .and_then(|v| v.as_f64()) - .map(|n| n as f32), + frequency_penalty: value.get("frequencyPenalty").and_then(|v| v.as_f64()).map(|n| n as f32), + max_output_tokens: value.get("maxOutputTokens").and_then(|v| v.as_i64()).map(|n| n as i32), + presence_penalty: value.get("presencePenalty").and_then(|v| v.as_f64()).map(|n| n as f32), seed: value.get("seed").and_then(|v| v.as_i64()).map(|n| n as i32), - temperature: value - .get("temperature") - .and_then(|v| v.as_f64()) - .map(|n| n as f32), + temperature: value.get("temperature").and_then(|v| v.as_f64()).map(|n| n as f32), top_k: value.get("topK").and_then(|v| v.as_i64()).map(|n| n as i32), top_p: value.get("topP").and_then(|v| v.as_f64()).map(|n| n as f32), - stop_sequences: value - .get("stopSequences") - .and_then(|v| v.as_array()) - .map(|arr| { - arr.iter() - .filter_map(|v| v.as_str().map(|s| s.to_string())) - .collect() - }), - allow_multiple_tool_calls: value - .get("allowMultipleToolCalls") - .and_then(|v| v.as_bool()), - additional_properties: value - .get("additionalProperties") - .cloned() - .unwrap_or(serde_json::Value::Null), + stop_sequences: value.get("stopSequences").and_then(|v| v.as_array()).map(|arr| arr.iter().filter_map(|v| v.as_str().map(|s| s.to_string())).collect()), + allow_multiple_tool_calls: value.get("allowMultipleToolCalls").and_then(|v| v.as_bool()), + additional_properties: value.get("additionalProperties").cloned().unwrap_or(serde_json::Value::Null), } } @@ -87,64 +68,34 @@ impl ModelOptions { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if let Some(ref val) = self.frequency_penalty { - result.insert( - "frequencyPenalty".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("frequencyPenalty".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.max_output_tokens { - result.insert( - "maxOutputTokens".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("maxOutputTokens".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.presence_penalty { - result.insert( - "presencePenalty".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("presencePenalty".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.seed { - result.insert( - "seed".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("seed".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.temperature { - result.insert( - "temperature".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("temperature".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.top_k { - result.insert( - "topK".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("topK".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.top_p { - result.insert( - "topP".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("topP".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref items) = self.stop_sequences { - result.insert( - "stopSequences".to_string(), - serde_json::to_value(items).unwrap_or(serde_json::Value::Null), - ); + result.insert("stopSequences".to_string(), serde_json::to_value(items).unwrap_or(serde_json::Value::Null)); } if let Some(val) = self.allow_multiple_tool_calls { - result.insert( - "allowMultipleToolCalls".to_string(), - serde_json::Value::Bool(val), - ); + result.insert("allowMultipleToolCalls".to_string(), serde_json::Value::Bool(val)); } if !self.additional_properties.is_null() { - result.insert( - "additionalProperties".to_string(), - self.additional_properties.clone(), - ); + result.insert("additionalProperties".to_string(), self.additional_properties.clone()); } serde_json::Value::Object(result) } @@ -160,9 +111,9 @@ impl ModelOptions { } /// Returns typed reference to the map if the field is an object. /// Returns `None` if the field is null or not an object. - pub fn as_additional_properties_dict( - &self, - ) -> Option<&serde_json::Map> { + pub fn as_additional_properties_dict(&self) -> Option<&serde_json::Map> { self.additional_properties.as_object() } } + + diff --git a/runtime/rust/agentschema/src/parser.rs b/runtime/rust/agentschema/src/parser.rs index 6f28c62..73e1463 100644 --- a/runtime/rust/agentschema/src/parser.rs +++ b/runtime/rust/agentschema/src/parser.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Template parser definition #[derive(Debug, Clone, Default)] pub struct Parser { @@ -35,15 +40,8 @@ impl Parser { return Self::load_from_value(&expansion); } Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - options: value - .get("options") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + options: value.get("options").cloned().unwrap_or(serde_json::Value::Null), } } @@ -51,10 +49,7 @@ impl Parser { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.options.is_null() { result.insert("options".to_string(), self.options.clone()); @@ -77,3 +72,5 @@ impl Parser { self.options.as_object() } } + + diff --git a/runtime/rust/agentschema/src/property.rs b/runtime/rust/agentschema/src/property.rs index 394d109..7082a0c 100644 --- a/runtime/rust/agentschema/src/property.rs +++ b/runtime/rust/agentschema/src/property.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Represents a single property. - This model defines the structure of properties that can be used in prompts, including their type, description, whether they are required, and other attributes. - It allows for the definition of dynamic inputs that can be filled with data and processed to generate prompts for AI models. #[derive(Debug, Clone, Default)] pub struct Property { @@ -57,27 +62,13 @@ impl Property { return Self::load_from_value(&expansion); } Self { - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - description: value - .get("description") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + description: value.get("description").and_then(|v| v.as_str()).map(|s| s.to_string()), required: value.get("required").and_then(|v| v.as_bool()), default: value.get("default").cloned(), example: value.get("example").cloned(), - enum_values: value - .get("enumValues") - .and_then(|v| v.as_array()) - .map(|arr| arr.to_vec()), + enum_values: value.get("enumValues").and_then(|v| v.as_array()).map(|arr| arr.to_vec()), } } @@ -85,43 +76,25 @@ impl Property { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if let Some(ref val) = self.description { - result.insert( - "description".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("description".to_string(), serde_json::Value::String(val.clone())); } if let Some(val) = self.required { result.insert("required".to_string(), serde_json::Value::Bool(val)); } if let Some(ref val) = self.default { - result.insert( - "default".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("default".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.example { - result.insert( - "example".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("example".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref items) = self.enum_values { - result.insert( - "enumValues".to_string(), - serde_json::to_value(items).unwrap_or(serde_json::Value::Null), - ); + result.insert("enumValues".to_string(), serde_json::to_value(items).unwrap_or(serde_json::Value::Null)); } serde_json::Value::Object(result) } @@ -137,6 +110,7 @@ impl Property { } } + /// Represents an array property. This extends the base Property model to represent an array of items. #[derive(Debug, Clone, Default)] pub struct ArrayProperty { @@ -166,15 +140,8 @@ impl ArrayProperty { /// Load ArrayProperty from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - items: value - .get("items") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + items: value.get("items").cloned().unwrap_or(serde_json::Value::Null), } } @@ -182,10 +149,7 @@ impl ArrayProperty { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.items.is_null() { result.insert("items".to_string(), self.items.clone()); @@ -204,6 +168,7 @@ impl ArrayProperty { } } + /// Represents an object property. This extends the base Property model to represent a structured object. #[derive(Debug, Clone, Default)] pub struct ObjectProperty { @@ -233,15 +198,8 @@ impl ObjectProperty { /// Load ObjectProperty from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - properties: value - .get("properties") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + properties: value.get("properties").cloned().unwrap_or(serde_json::Value::Null), } } @@ -249,10 +207,7 @@ impl ObjectProperty { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.properties.is_null() { result.insert("properties".to_string(), self.properties.clone()); @@ -287,8 +242,7 @@ impl ObjectProperty { serde_json::json!({ "value": value }) }; if let serde_json::Value::Object(ref mut m) = v { - m.entry("name".to_string()) - .or_insert_with(|| serde_json::Value::String(name.clone())); + m.entry("name".to_string()).or_insert_with(|| serde_json::Value::String(name.clone())); } Property::load_from_value(&v) }) @@ -299,3 +253,5 @@ impl ObjectProperty { } } } + + diff --git a/runtime/rust/agentschema/src/property_schema.rs b/runtime/rust/agentschema/src/property_schema.rs index d4e055c..4e7f2cb 100644 --- a/runtime/rust/agentschema/src/property_schema.rs +++ b/runtime/rust/agentschema/src/property_schema.rs @@ -1,7 +1,12 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + use crate::property::Property; + + /// Definition for the property schema of a model. This includes the properties and example records. #[derive(Debug, Clone, Default)] pub struct PropertySchema { @@ -34,15 +39,9 @@ impl PropertySchema { /// Load PropertySchema from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - examples: value - .get("examples") - .cloned() - .unwrap_or(serde_json::Value::Null), + examples: value.get("examples").cloned().unwrap_or(serde_json::Value::Null), strict: value.get("strict").and_then(|v| v.as_bool()), - properties: value - .get("properties") - .cloned() - .unwrap_or(serde_json::Value::Null), + properties: value.get("properties").cloned().unwrap_or(serde_json::Value::Null), } } @@ -93,8 +92,7 @@ impl PropertySchema { serde_json::json!({ "value": value }) }; if let serde_json::Value::Object(ref mut m) = v { - m.entry("name".to_string()) - .or_insert_with(|| serde_json::Value::String(name.clone())); + m.entry("name".to_string()).or_insert_with(|| serde_json::Value::String(name.clone())); } Property::load_from_value(&v) }) @@ -105,3 +103,5 @@ impl PropertySchema { } } } + + diff --git a/runtime/rust/agentschema/src/protocol_version_record.rs b/runtime/rust/agentschema/src/protocol_version_record.rs index ffe4d14..dfb5baf 100644 --- a/runtime/rust/agentschema/src/protocol_version_record.rs +++ b/runtime/rust/agentschema/src/protocol_version_record.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// ProtocolVersionRecord schema type #[derive(Debug, Clone, Default)] pub struct ProtocolVersionRecord { @@ -30,16 +35,8 @@ impl ProtocolVersionRecord { /// Load ProtocolVersionRecord from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - protocol: value - .get("protocol") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - version: value - .get("version") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + protocol: value.get("protocol").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + version: value.get("version").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -47,16 +44,10 @@ impl ProtocolVersionRecord { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.protocol.is_empty() { - result.insert( - "protocol".to_string(), - serde_json::Value::String(self.protocol.clone()), - ); + result.insert("protocol".to_string(), serde_json::Value::String(self.protocol.clone())); } if !self.version.is_empty() { - result.insert( - "version".to_string(), - serde_json::Value::String(self.version.clone()), - ); + result.insert("version".to_string(), serde_json::Value::String(self.version.clone())); } serde_json::Value::Object(result) } @@ -71,3 +62,5 @@ impl ProtocolVersionRecord { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/src/resource.rs b/runtime/rust/agentschema/src/resource.rs index 12bccc8..582de44 100644 --- a/runtime/rust/agentschema/src/resource.rs +++ b/runtime/rust/agentschema/src/resource.rs @@ -1,5 +1,10 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + + + /// Represents a resource required by the agent Resources can include databases, APIs, or other external systems that the agent needs to interact with to perform its tasks #[derive(Debug, Clone, Default)] pub struct Resource { @@ -30,16 +35,8 @@ impl Resource { /// Load Resource from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -47,16 +44,10 @@ impl Resource { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } serde_json::Value::Object(result) } @@ -72,6 +63,7 @@ impl Resource { } } + /// Represents a model resource required by the agent #[derive(Debug, Clone, Default)] pub struct ModelResource { @@ -102,16 +94,8 @@ impl ModelResource { /// Load ModelResource from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - id: value - .get("id") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + id: value.get("id").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -119,10 +103,7 @@ impl ModelResource { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.id.is_empty() { result.insert("id".to_string(), serde_json::Value::String(self.id.clone())); @@ -141,6 +122,7 @@ impl ModelResource { } } + /// Represents a tool resource required by the agent #[derive(Debug, Clone, Default)] pub struct ToolResource { @@ -173,20 +155,9 @@ impl ToolResource { /// Load ToolResource from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - id: value - .get("id") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - options: value - .get("options") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + id: value.get("id").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + options: value.get("options").cloned().unwrap_or(serde_json::Value::Null), } } @@ -194,10 +165,7 @@ impl ToolResource { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.id.is_empty() { result.insert("id".to_string(), serde_json::Value::String(self.id.clone())); @@ -223,3 +191,5 @@ impl ToolResource { self.options.as_object() } } + + diff --git a/runtime/rust/agentschema/src/template.rs b/runtime/rust/agentschema/src/template.rs index f34f991..95b281a 100644 --- a/runtime/rust/agentschema/src/template.rs +++ b/runtime/rust/agentschema/src/template.rs @@ -1,9 +1,14 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + use crate::format::Format; use crate::parser::Parser; + + /// Template model for defining prompt templates. This model specifies the rendering engine used for slot filling prompts, the parser used to process the rendered template into API-compatible format, and additional options for the template engine. It allows for the creation of reusable templates that can be filled with dynamic data and processed to generate prompts for AI models. #[derive(Debug, Clone, Default)] pub struct Template { @@ -34,16 +39,8 @@ impl Template { /// Load Template from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - format: value - .get("format") - .filter(|v| v.is_object() || v.is_array()) - .map(Format::load_from_value) - .unwrap_or_default(), - parser: value - .get("parser") - .filter(|v| v.is_object() || v.is_array()) - .map(Parser::load_from_value) - .unwrap_or_default(), + format: value.get("format").filter(|v| v.is_object() || v.is_array()).map(Format::load_from_value).unwrap_or_default(), + parser: value.get("parser").filter(|v| v.is_object() || v.is_array()).map(Parser::load_from_value).unwrap_or_default(), } } @@ -75,3 +72,5 @@ impl Template { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/src/tool.rs b/runtime/rust/agentschema/src/tool.rs index 4b7bc61..e696681 100644 --- a/runtime/rust/agentschema/src/tool.rs +++ b/runtime/rust/agentschema/src/tool.rs @@ -1,9 +1,14 @@ + + // Code generated by AgentSchema emitter; DO NOT EDIT. + use crate::binding::Binding; use crate::property_schema::PropertySchema; + + /// Represents a tool that can be used in prompts. #[derive(Debug, Clone, Default)] pub struct Tool { @@ -38,24 +43,10 @@ impl Tool { /// Load Tool from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - name: value - .get("name") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - description: value - .get("description") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - bindings: value - .get("bindings") - .cloned() - .unwrap_or(serde_json::Value::Null), + name: value.get("name").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + description: value.get("description").and_then(|v| v.as_str()).map(|s| s.to_string()), + bindings: value.get("bindings").cloned().unwrap_or(serde_json::Value::Null), } } @@ -63,22 +54,13 @@ impl Tool { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.name.is_empty() { - result.insert( - "name".to_string(), - serde_json::Value::String(self.name.clone()), - ); + result.insert("name".to_string(), serde_json::Value::String(self.name.clone())); } if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if let Some(ref val) = self.description { - result.insert( - "description".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("description".to_string(), serde_json::Value::String(val.clone())); } if !self.bindings.is_null() { result.insert("bindings".to_string(), self.bindings.clone()); @@ -113,8 +95,7 @@ impl Tool { serde_json::json!({ "value": value }) }; if let serde_json::Value::Object(ref mut m) = v { - m.entry("name".to_string()) - .or_insert_with(|| serde_json::Value::String(name.clone())); + m.entry("name".to_string()).or_insert_with(|| serde_json::Value::String(name.clone())); } Binding::load_from_value(&v) }) @@ -126,6 +107,7 @@ impl Tool { } } + /// Represents a local function tool. #[derive(Debug, Clone, Default)] pub struct FunctionTool { @@ -158,16 +140,8 @@ impl FunctionTool { /// Load FunctionTool from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - parameters: value - .get("parameters") - .filter(|v| v.is_object() || v.is_array()) - .map(PropertySchema::load_from_value) - .unwrap_or_default(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + parameters: value.get("parameters").filter(|v| v.is_object() || v.is_array()).map(PropertySchema::load_from_value).unwrap_or_default(), strict: value.get("strict").and_then(|v| v.as_bool()), } } @@ -176,10 +150,7 @@ impl FunctionTool { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } { let nested = self.parameters.to_value(); @@ -204,6 +175,7 @@ impl FunctionTool { } } + /// Represents a generic server tool that runs on a server This tool kind is designed for operations that require server-side execution It may include features such as authentication, data storage, and long-running processes This tool kind is ideal for tasks that involve complex computations or access to secure resources Server tools can be used to offload heavy processing from client applications #[derive(Debug, Clone, Default)] pub struct CustomTool { @@ -236,19 +208,9 @@ impl CustomTool { /// Load CustomTool from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - connection: value - .get("connection") - .cloned() - .unwrap_or(serde_json::Value::Null), - options: value - .get("options") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + connection: value.get("connection").cloned().unwrap_or(serde_json::Value::Null), + options: value.get("options").cloned().unwrap_or(serde_json::Value::Null), } } @@ -256,10 +218,7 @@ impl CustomTool { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.connection.is_null() { result.insert("connection".to_string(), self.connection.clone()); @@ -286,6 +245,7 @@ impl CustomTool { } } + /// The Bing search tool. #[derive(Debug, Clone, Default)] pub struct WebSearchTool { @@ -318,19 +278,9 @@ impl WebSearchTool { /// Load WebSearchTool from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - connection: value - .get("connection") - .cloned() - .unwrap_or(serde_json::Value::Null), - options: value - .get("options") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + connection: value.get("connection").cloned().unwrap_or(serde_json::Value::Null), + options: value.get("options").cloned().unwrap_or(serde_json::Value::Null), } } @@ -338,10 +288,7 @@ impl WebSearchTool { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.connection.is_null() { result.insert("connection".to_string(), self.connection.clone()); @@ -368,6 +315,7 @@ impl WebSearchTool { } } + /// A tool for searching files. This tool allows an AI agent to search for files based on a query. #[derive(Debug, Clone, Default)] pub struct FileSearchTool { @@ -408,40 +356,13 @@ impl FileSearchTool { /// Load FileSearchTool from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - connection: value - .get("connection") - .cloned() - .unwrap_or(serde_json::Value::Null), - vector_store_ids: value - .get("vectorStoreIds") - .and_then(|v| v.as_array()) - .map(|arr| { - arr.iter() - .filter_map(|v| v.as_str().map(|s| s.to_string())) - .collect() - }) - .unwrap_or_default(), - maximum_result_count: value - .get("maximumResultCount") - .and_then(|v| v.as_i64()) - .map(|n| n as i32), - ranker: value - .get("ranker") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - score_threshold: value - .get("scoreThreshold") - .and_then(|v| v.as_f64()) - .map(|n| n as f32), - filters: value - .get("filters") - .cloned() - .unwrap_or(serde_json::Value::Null), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + connection: value.get("connection").cloned().unwrap_or(serde_json::Value::Null), + vector_store_ids: value.get("vectorStoreIds").and_then(|v| v.as_array()).map(|arr| arr.iter().filter_map(|v| v.as_str().map(|s| s.to_string())).collect()).unwrap_or_default(), + maximum_result_count: value.get("maximumResultCount").and_then(|v| v.as_i64()).map(|n| n as i32), + ranker: value.get("ranker").and_then(|v| v.as_str()).map(|s| s.to_string()), + score_threshold: value.get("scoreThreshold").and_then(|v| v.as_f64()).map(|n| n as f32), + filters: value.get("filters").cloned().unwrap_or(serde_json::Value::Null), } } @@ -449,34 +370,22 @@ impl FileSearchTool { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.connection.is_null() { result.insert("connection".to_string(), self.connection.clone()); } if !self.vector_store_ids.is_empty() { - result.insert( - "vectorStoreIds".to_string(), - serde_json::to_value(&self.vector_store_ids).unwrap_or(serde_json::Value::Null), - ); + result.insert("vectorStoreIds".to_string(), serde_json::to_value(&self.vector_store_ids).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.maximum_result_count { - result.insert( - "maximumResultCount".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("maximumResultCount".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if let Some(ref val) = self.ranker { result.insert("ranker".to_string(), serde_json::Value::String(val.clone())); } if let Some(ref val) = self.score_threshold { - result.insert( - "scoreThreshold".to_string(), - serde_json::to_value(val).unwrap_or(serde_json::Value::Null), - ); + result.insert("scoreThreshold".to_string(), serde_json::to_value(val).unwrap_or(serde_json::Value::Null)); } if !self.filters.is_null() { result.insert("filters".to_string(), self.filters.clone()); @@ -500,6 +409,7 @@ impl FileSearchTool { } } + /// The MCP Server tool. #[derive(Debug, Clone, Default)] pub struct McpTool { @@ -538,36 +448,12 @@ impl McpTool { /// Load McpTool from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - connection: value - .get("connection") - .cloned() - .unwrap_or(serde_json::Value::Null), - server_name: value - .get("serverName") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - server_description: value - .get("serverDescription") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()), - approval_mode: value - .get("approvalMode") - .cloned() - .unwrap_or(serde_json::Value::Null), - allowed_tools: value - .get("allowedTools") - .and_then(|v| v.as_array()) - .map(|arr| { - arr.iter() - .filter_map(|v| v.as_str().map(|s| s.to_string())) - .collect() - }), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + connection: value.get("connection").cloned().unwrap_or(serde_json::Value::Null), + server_name: value.get("serverName").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + server_description: value.get("serverDescription").and_then(|v| v.as_str()).map(|s| s.to_string()), + approval_mode: value.get("approvalMode").cloned().unwrap_or(serde_json::Value::Null), + allowed_tools: value.get("allowedTools").and_then(|v| v.as_array()).map(|arr| arr.iter().filter_map(|v| v.as_str().map(|s| s.to_string())).collect()), } } @@ -575,34 +461,22 @@ impl McpTool { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.connection.is_null() { result.insert("connection".to_string(), self.connection.clone()); } if !self.server_name.is_empty() { - result.insert( - "serverName".to_string(), - serde_json::Value::String(self.server_name.clone()), - ); + result.insert("serverName".to_string(), serde_json::Value::String(self.server_name.clone())); } if let Some(ref val) = self.server_description { - result.insert( - "serverDescription".to_string(), - serde_json::Value::String(val.clone()), - ); + result.insert("serverDescription".to_string(), serde_json::Value::String(val.clone())); } if !self.approval_mode.is_null() { result.insert("approvalMode".to_string(), self.approval_mode.clone()); } if let Some(ref items) = self.allowed_tools { - result.insert( - "allowedTools".to_string(), - serde_json::to_value(items).unwrap_or(serde_json::Value::Null), - ); + result.insert("allowedTools".to_string(), serde_json::to_value(items).unwrap_or(serde_json::Value::Null)); } serde_json::Value::Object(result) } @@ -618,6 +492,7 @@ impl McpTool { } } + /// OpenApiTool schema type #[derive(Debug, Clone, Default)] pub struct OpenApiTool { @@ -650,20 +525,9 @@ impl OpenApiTool { /// Load OpenApiTool from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - connection: value - .get("connection") - .cloned() - .unwrap_or(serde_json::Value::Null), - specification: value - .get("specification") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + connection: value.get("connection").cloned().unwrap_or(serde_json::Value::Null), + specification: value.get("specification").and_then(|v| v.as_str()).unwrap_or_default().to_string(), } } @@ -671,19 +535,13 @@ impl OpenApiTool { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.connection.is_null() { result.insert("connection".to_string(), self.connection.clone()); } if !self.specification.is_empty() { - result.insert( - "specification".to_string(), - serde_json::Value::String(self.specification.clone()), - ); + result.insert("specification".to_string(), serde_json::Value::String(self.specification.clone())); } serde_json::Value::Object(result) } @@ -699,6 +557,7 @@ impl OpenApiTool { } } + /// A tool for interpreting and executing code. This tool allows an AI agent to run code snippets and analyze data files. #[derive(Debug, Clone, Default)] pub struct CodeInterpreterTool { @@ -729,20 +588,8 @@ impl CodeInterpreterTool { /// Load CodeInterpreterTool from a `serde_json::Value`. pub fn load_from_value(value: &serde_json::Value) -> Self { Self { - kind: value - .get("kind") - .and_then(|v| v.as_str()) - .unwrap_or_default() - .to_string(), - file_ids: value - .get("fileIds") - .and_then(|v| v.as_array()) - .map(|arr| { - arr.iter() - .filter_map(|v| v.as_str().map(|s| s.to_string())) - .collect() - }) - .unwrap_or_default(), + kind: value.get("kind").and_then(|v| v.as_str()).unwrap_or_default().to_string(), + file_ids: value.get("fileIds").and_then(|v| v.as_array()).map(|arr| arr.iter().filter_map(|v| v.as_str().map(|s| s.to_string())).collect()).unwrap_or_default(), } } @@ -750,16 +597,10 @@ impl CodeInterpreterTool { pub fn to_value(&self) -> serde_json::Value { let mut result = serde_json::Map::new(); if !self.kind.is_empty() { - result.insert( - "kind".to_string(), - serde_json::Value::String(self.kind.clone()), - ); + result.insert("kind".to_string(), serde_json::Value::String(self.kind.clone())); } if !self.file_ids.is_empty() { - result.insert( - "fileIds".to_string(), - serde_json::to_value(&self.file_ids).unwrap_or(serde_json::Value::Null), - ); + result.insert("fileIds".to_string(), serde_json::to_value(&self.file_ids).unwrap_or(serde_json::Value::Null)); } serde_json::Value::Object(result) } @@ -774,3 +615,5 @@ impl CodeInterpreterTool { serde_yaml::to_string(&self.to_value()) } } + + diff --git a/runtime/rust/agentschema/tests/agent_definition_test.rs b/runtime/rust/agentschema/tests/agent_definition_test.rs index f1b1319..e890c76 100644 --- a/runtime/rust/agentschema/tests/agent_definition_test.rs +++ b/runtime/rust/agentschema/tests/agent_definition_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::AgentDefinition; + #[test] fn test_agent_definition_load_json() { let json = r####" @@ -47,11 +49,7 @@ fn test_agent_definition_load_json() { } "####; let result = AgentDefinition::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -87,11 +85,7 @@ outputSchema: "####; let result = AgentDefinition::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -142,6 +136,7 @@ fn test_agent_definition_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + #[test] fn test_agent_definition_load_json_1() { let json = r####" @@ -188,11 +183,7 @@ fn test_agent_definition_load_json_1() { } "####; let result = AgentDefinition::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -228,11 +219,7 @@ outputSchema: "####; let result = AgentDefinition::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -284,6 +271,7 @@ fn test_agent_definition_roundtrip_1() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + #[test] fn test_agent_definition_load_json_2() { let json = r####" @@ -332,11 +320,7 @@ fn test_agent_definition_load_json_2() { } "####; let result = AgentDefinition::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -372,11 +356,7 @@ outputSchema: "####; let result = AgentDefinition::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -430,6 +410,7 @@ fn test_agent_definition_roundtrip_2() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + #[test] fn test_agent_definition_load_json_3() { let json = r####" @@ -479,11 +460,7 @@ fn test_agent_definition_load_json_3() { } "####; let result = AgentDefinition::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -519,11 +496,7 @@ outputSchema: "####; let result = AgentDefinition::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -577,3 +550,6 @@ fn test_agent_definition_roundtrip_3() { let result = AgentDefinition::from_json(json); assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + + diff --git a/runtime/rust/agentschema/tests/agent_manifest_test.rs b/runtime/rust/agentschema/tests/agent_manifest_test.rs index a678d1d..6310c3a 100644 --- a/runtime/rust/agentschema/tests/agent_manifest_test.rs +++ b/runtime/rust/agentschema/tests/agent_manifest_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::AgentManifest; + #[test] fn test_agent_manifest_load_json() { let json = r####" @@ -55,22 +57,12 @@ fn test_agent_manifest_load_json() { } "####; let result = AgentManifest::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.name, "basic-prompt"); assert_eq!(instance.display_name, "My Basic Prompt"); - assert!( - instance.description.is_some(), - "Expected description to be Some" - ); - assert_eq!( - instance.description.as_ref().unwrap(), - &"A basic prompt that uses the GPT-3 chat API to answer questions" - ); + assert!(instance.description.is_some(), "Expected description to be Some"); + assert_eq!(instance.description.as_ref().unwrap(), &"A basic prompt that uses the GPT-3 chat API to answer questions"); } #[test] @@ -111,18 +103,11 @@ resources: "####; let result = AgentManifest::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.name, "basic-prompt"); assert_eq!(instance.display_name, "My Basic Prompt"); - assert!( - instance.description.is_some(), - "Expected description to be Some" - ); + assert!(instance.description.is_some(), "Expected description to be Some"); } #[test] @@ -181,13 +166,10 @@ fn test_agent_manifest_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + #[test] fn test_agent_manifest_load_json_1() { let json = r####" @@ -243,22 +225,12 @@ fn test_agent_manifest_load_json_1() { } "####; let result = AgentManifest::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.name, "basic-prompt"); assert_eq!(instance.display_name, "My Basic Prompt"); - assert!( - instance.description.is_some(), - "Expected description to be Some" - ); - assert_eq!( - instance.description.as_ref().unwrap(), - &"A basic prompt that uses the GPT-3 chat API to answer questions" - ); + assert!(instance.description.is_some(), "Expected description to be Some"); + assert_eq!(instance.description.as_ref().unwrap(), &"A basic prompt that uses the GPT-3 chat API to answer questions"); } #[test] @@ -299,18 +271,11 @@ resources: "####; let result = AgentManifest::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.name, "basic-prompt"); assert_eq!(instance.display_name, "My Basic Prompt"); - assert!( - instance.description.is_some(), - "Expected description to be Some" - ); + assert!(instance.description.is_some(), "Expected description to be Some"); } #[test] @@ -371,9 +336,8 @@ fn test_agent_manifest_roundtrip_1() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/anonymous_connection_test.rs b/runtime/rust/agentschema/tests/anonymous_connection_test.rs index e390713..30713b9 100644 --- a/runtime/rust/agentschema/tests/anonymous_connection_test.rs +++ b/runtime/rust/agentschema/tests/anonymous_connection_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::AnonymousConnection; + #[test] fn test_anonymous_connection_load_json() { let json = r####" @@ -11,17 +13,10 @@ fn test_anonymous_connection_load_json() { } "####; let result = AnonymousConnection::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "anonymous"); - assert_eq!( - instance.endpoint, - "https://{your-custom-endpoint}.openai.azure.com/" - ); + assert_eq!(instance.endpoint, "https://{your-custom-endpoint}.openai.azure.com/"); } #[test] @@ -32,17 +27,10 @@ endpoint: "https://{your-custom-endpoint}.openai.azure.com/" "####; let result = AnonymousConnection::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "anonymous"); - assert_eq!( - instance.endpoint, - "https://{your-custom-endpoint}.openai.azure.com/" - ); + assert_eq!(instance.endpoint, "https://{your-custom-endpoint}.openai.azure.com/"); } #[test] @@ -57,9 +45,8 @@ fn test_anonymous_connection_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/api_key_connection_test.rs b/runtime/rust/agentschema/tests/api_key_connection_test.rs index 755b05c..25020a9 100644 --- a/runtime/rust/agentschema/tests/api_key_connection_test.rs +++ b/runtime/rust/agentschema/tests/api_key_connection_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ApiKeyConnection; + #[test] fn test_api_key_connection_load_json() { let json = r####" @@ -12,17 +14,10 @@ fn test_api_key_connection_load_json() { } "####; let result = ApiKeyConnection::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "key"); - assert_eq!( - instance.endpoint, - "https://{your-custom-endpoint}.openai.azure.com/" - ); + assert_eq!(instance.endpoint, "https://{your-custom-endpoint}.openai.azure.com/"); assert_eq!(instance.api_key, "your-api-key"); } @@ -35,17 +30,10 @@ apiKey: your-api-key "####; let result = ApiKeyConnection::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "key"); - assert_eq!( - instance.endpoint, - "https://{your-custom-endpoint}.openai.azure.com/" - ); + assert_eq!(instance.endpoint, "https://{your-custom-endpoint}.openai.azure.com/"); assert_eq!(instance.api_key, "your-api-key"); } @@ -62,9 +50,8 @@ fn test_api_key_connection_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/array_property_test.rs b/runtime/rust/agentschema/tests/array_property_test.rs index a01dcfe..e78cdc9 100644 --- a/runtime/rust/agentschema/tests/array_property_test.rs +++ b/runtime/rust/agentschema/tests/array_property_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ArrayProperty; + #[test] fn test_array_property_load_json() { let json = r####" @@ -12,11 +14,7 @@ fn test_array_property_load_json() { } "####; let result = ArrayProperty::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); let _ = instance; // load succeeded, no scalar properties to validate } @@ -29,11 +27,7 @@ items: "####; let result = ArrayProperty::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); let _ = instance; // load succeeded, no scalar properties to validate } @@ -51,9 +45,8 @@ fn test_array_property_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/binding_test.rs b/runtime/rust/agentschema/tests/binding_test.rs index 802b5b7..4d20f43 100644 --- a/runtime/rust/agentschema/tests/binding_test.rs +++ b/runtime/rust/agentschema/tests/binding_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Binding; + #[test] fn test_binding_load_json() { let json = r####" @@ -11,11 +13,7 @@ fn test_binding_load_json() { } "####; let result = Binding::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.name, "my-tool"); assert_eq!(instance.input, "input-variable"); @@ -29,11 +27,7 @@ input: input-variable "####; let result = Binding::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.name, "my-tool"); assert_eq!(instance.input, "input-variable"); @@ -51,16 +45,16 @@ fn test_binding_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + #[test] fn test_binding_from_string() { let value = serde_json::json!("example"); let instance = Binding::load_from_value(&value); assert_eq!(instance.input, "example"); } + + diff --git a/runtime/rust/agentschema/tests/code_configuration_test.rs b/runtime/rust/agentschema/tests/code_configuration_test.rs new file mode 100644 index 0000000..cf56c2c --- /dev/null +++ b/runtime/rust/agentschema/tests/code_configuration_test.rs @@ -0,0 +1,58 @@ + +// Code generated by AgentSchema emitter; DO NOT EDIT. + +use agentschema::CodeConfiguration; + + +#[test] +fn test_code_configuration_load_json() { + let json = r####" +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +"####; + let result = CodeConfiguration::from_json(json); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); + let instance = result.unwrap(); + assert_eq!(instance.runtime, "python_3_11"); + assert_eq!(instance.entry_point, "main.py"); + assert!(instance.dependency_resolution.is_some(), "Expected dependency_resolution to be Some"); + assert_eq!(instance.dependency_resolution.as_ref().unwrap(), &"remote_build"); +} + +#[test] +fn test_code_configuration_load_yaml() { + let yaml = r####" +runtime: python_3_11 +entryPoint: main.py +dependencyResolution: remote_build + +"####; + let result = CodeConfiguration::from_yaml(yaml); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); + let instance = result.unwrap(); + assert_eq!(instance.runtime, "python_3_11"); + assert_eq!(instance.entry_point, "main.py"); + assert!(instance.dependency_resolution.is_some(), "Expected dependency_resolution to be Some"); +} + +#[test] +fn test_code_configuration_roundtrip() { + let json = r####" +{ + "runtime": "python_3_11", + "entryPoint": "main.py", + "dependencyResolution": "remote_build" +} +"####; + let result = CodeConfiguration::from_json(json); + assert!(result.is_ok(), "Failed to load: {:?}", result.err()); + let instance = result.unwrap(); + let json_output = instance.to_json(); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); +} + + + diff --git a/runtime/rust/agentschema/tests/code_interpreter_tool_test.rs b/runtime/rust/agentschema/tests/code_interpreter_tool_test.rs index fa0cda1..e54a799 100644 --- a/runtime/rust/agentschema/tests/code_interpreter_tool_test.rs +++ b/runtime/rust/agentschema/tests/code_interpreter_tool_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::CodeInterpreterTool; + #[test] fn test_code_interpreter_tool_load_json() { let json = r####" @@ -14,11 +16,7 @@ fn test_code_interpreter_tool_load_json() { } "####; let result = CodeInterpreterTool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "code_interpreter"); } @@ -33,11 +31,7 @@ fileIds: "####; let result = CodeInterpreterTool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "code_interpreter"); } @@ -57,9 +51,8 @@ fn test_code_interpreter_tool_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/connection_test.rs b/runtime/rust/agentschema/tests/connection_test.rs index 94aeaed..f679d66 100644 --- a/runtime/rust/agentschema/tests/connection_test.rs +++ b/runtime/rust/agentschema/tests/connection_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Connection; + #[test] fn test_connection_load_json() { let json = r####" @@ -12,11 +14,7 @@ fn test_connection_load_json() { } "####; let result = Connection::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -28,11 +26,7 @@ usageDescription: This will allow the agent to respond to an email on your behal "####; let result = Connection::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -47,3 +41,6 @@ fn test_connection_roundtrip() { let result = Connection::from_json(json); assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + + diff --git a/runtime/rust/agentschema/tests/container_agent_test.rs b/runtime/rust/agentschema/tests/container_agent_test.rs index fc63610..fdd1870 100644 --- a/runtime/rust/agentschema/tests/container_agent_test.rs +++ b/runtime/rust/agentschema/tests/container_agent_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ContainerAgent; + #[test] fn test_container_agent_load_json() { let json = r####" @@ -28,22 +30,12 @@ fn test_container_agent_load_json() { } "####; let result = ContainerAgent::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "hosted"); assert!(instance.image.is_some(), "Expected image to be Some"); - assert_eq!( - instance.image.as_ref().unwrap(), - &"myregistry.azurecr.io/my-agent" - ); - assert!( - instance.dockerfile_path.is_some(), - "Expected dockerfile_path to be Some" - ); + assert_eq!(instance.image.as_ref().unwrap(), &"myregistry.azurecr.io/my-agent"); + assert!(instance.dockerfile_path.is_some(), "Expected dockerfile_path to be Some"); assert_eq!(instance.dockerfile_path.as_ref().unwrap(), &"./Dockerfile"); } @@ -65,18 +57,11 @@ environmentVariables: "####; let result = ContainerAgent::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "hosted"); assert!(instance.image.is_some(), "Expected image to be Some"); - assert!( - instance.dockerfile_path.is_some(), - "Expected dockerfile_path to be Some" - ); + assert!(instance.dockerfile_path.is_some(), "Expected dockerfile_path to be Some"); } #[test] @@ -108,9 +93,8 @@ fn test_container_agent_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/container_resources_test.rs b/runtime/rust/agentschema/tests/container_resources_test.rs index 85f2537..b60511e 100644 --- a/runtime/rust/agentschema/tests/container_resources_test.rs +++ b/runtime/rust/agentschema/tests/container_resources_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ContainerResources; + #[test] fn test_container_resources_load_json() { let json = r####" @@ -11,11 +13,7 @@ fn test_container_resources_load_json() { } "####; let result = ContainerResources::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.cpu, "1"); assert_eq!(instance.memory, "2Gi"); @@ -29,11 +27,7 @@ memory: 2Gi "####; let result = ContainerResources::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.cpu, "1"); assert_eq!(instance.memory, "2Gi"); @@ -51,9 +45,8 @@ fn test_container_resources_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/custom_tool_test.rs b/runtime/rust/agentschema/tests/custom_tool_test.rs index 479bcc6..c78e697 100644 --- a/runtime/rust/agentschema/tests/custom_tool_test.rs +++ b/runtime/rust/agentschema/tests/custom_tool_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::CustomTool; + #[test] fn test_custom_tool_load_json() { let json = r####" @@ -16,11 +18,7 @@ fn test_custom_tool_load_json() { } "####; let result = CustomTool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); let _ = instance; // load succeeded, no scalar properties to validate } @@ -36,11 +34,7 @@ options: "####; let result = CustomTool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); let _ = instance; // load succeeded, no scalar properties to validate } @@ -62,9 +56,8 @@ fn test_custom_tool_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/environment_variable_test.rs b/runtime/rust/agentschema/tests/environment_variable_test.rs index 18a9657..e6462fa 100644 --- a/runtime/rust/agentschema/tests/environment_variable_test.rs +++ b/runtime/rust/agentschema/tests/environment_variable_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::EnvironmentVariable; + #[test] fn test_environment_variable_load_json() { let json = r####" @@ -11,11 +13,7 @@ fn test_environment_variable_load_json() { } "####; let result = EnvironmentVariable::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.name, "MY_ENV_VAR"); assert_eq!(instance.value, "my-value"); @@ -29,11 +27,7 @@ value: my-value "####; let result = EnvironmentVariable::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.name, "MY_ENV_VAR"); assert_eq!(instance.value, "my-value"); @@ -51,9 +45,8 @@ fn test_environment_variable_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/file_search_tool_test.rs b/runtime/rust/agentschema/tests/file_search_tool_test.rs index 8841f84..ef53904 100644 --- a/runtime/rust/agentschema/tests/file_search_tool_test.rs +++ b/runtime/rust/agentschema/tests/file_search_tool_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::FileSearchTool; + #[test] fn test_file_search_tool_load_json() { let json = r####" @@ -24,24 +26,14 @@ fn test_file_search_tool_load_json() { } "####; let result = FileSearchTool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "file_search"); - assert!( - instance.maximum_result_count.is_some(), - "Expected maximum_result_count to be Some" - ); + assert!(instance.maximum_result_count.is_some(), "Expected maximum_result_count to be Some"); assert_eq!(instance.maximum_result_count.as_ref().unwrap(), &10); assert!(instance.ranker.is_some(), "Expected ranker to be Some"); assert_eq!(instance.ranker.as_ref().unwrap(), &"auto"); - assert!( - instance.score_threshold.is_some(), - "Expected score_threshold to be Some" - ); + assert!(instance.score_threshold.is_some(), "Expected score_threshold to be Some"); assert_eq!(instance.score_threshold.as_ref().unwrap(), &0.5); } @@ -63,22 +55,12 @@ filters: "####; let result = FileSearchTool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "file_search"); - assert!( - instance.maximum_result_count.is_some(), - "Expected maximum_result_count to be Some" - ); + assert!(instance.maximum_result_count.is_some(), "Expected maximum_result_count to be Some"); assert!(instance.ranker.is_some(), "Expected ranker to be Some"); - assert!( - instance.score_threshold.is_some(), - "Expected score_threshold to be Some" - ); + assert!(instance.score_threshold.is_some(), "Expected score_threshold to be Some"); } #[test] @@ -106,9 +88,8 @@ fn test_file_search_tool_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/format_test.rs b/runtime/rust/agentschema/tests/format_test.rs index 5c25dab..f2b1653 100644 --- a/runtime/rust/agentschema/tests/format_test.rs +++ b/runtime/rust/agentschema/tests/format_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Format; + #[test] fn test_format_load_json() { let json = r####" @@ -14,11 +16,7 @@ fn test_format_load_json() { } "####; let result = Format::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -31,11 +29,7 @@ options: "####; let result = Format::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -53,9 +47,13 @@ fn test_format_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + #[test] fn test_format_from_format() { let value = serde_json::json!("example"); let instance = Format::load_from_value(&value); let _ = instance; // abstract type, load succeeded } + + diff --git a/runtime/rust/agentschema/tests/foundry_connection_test.rs b/runtime/rust/agentschema/tests/foundry_connection_test.rs index 0899f7e..8a13141 100644 --- a/runtime/rust/agentschema/tests/foundry_connection_test.rs +++ b/runtime/rust/agentschema/tests/foundry_connection_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::FoundryConnection; + #[test] fn test_foundry_connection_load_json() { let json = r####" @@ -13,23 +15,13 @@ fn test_foundry_connection_load_json() { } "####; let result = FoundryConnection::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "foundry"); - assert_eq!( - instance.endpoint, - "https://myresource.services.ai.azure.com/api/projects/myproject" - ); + assert_eq!(instance.endpoint, "https://myresource.services.ai.azure.com/api/projects/myproject"); assert!(instance.name.is_some(), "Expected name to be Some"); assert_eq!(instance.name.as_ref().unwrap(), &"my-openai-connection"); - assert!( - instance.connection_type.is_some(), - "Expected connection_type to be Some" - ); + assert!(instance.connection_type.is_some(), "Expected connection_type to be Some"); assert_eq!(instance.connection_type.as_ref().unwrap(), &"model"); } @@ -43,22 +35,12 @@ connectionType: model "####; let result = FoundryConnection::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "foundry"); - assert_eq!( - instance.endpoint, - "https://myresource.services.ai.azure.com/api/projects/myproject" - ); + assert_eq!(instance.endpoint, "https://myresource.services.ai.azure.com/api/projects/myproject"); assert!(instance.name.is_some(), "Expected name to be Some"); - assert!( - instance.connection_type.is_some(), - "Expected connection_type to be Some" - ); + assert!(instance.connection_type.is_some(), "Expected connection_type to be Some"); } #[test] @@ -75,9 +57,8 @@ fn test_foundry_connection_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/function_tool_test.rs b/runtime/rust/agentschema/tests/function_tool_test.rs index a6db141..b1189c7 100644 --- a/runtime/rust/agentschema/tests/function_tool_test.rs +++ b/runtime/rust/agentschema/tests/function_tool_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::FunctionTool; + #[test] fn test_function_tool_load_json() { let json = r####" @@ -27,11 +29,7 @@ fn test_function_tool_load_json() { } "####; let result = FunctionTool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "function"); assert!(instance.strict.is_some(), "Expected strict to be Some"); @@ -57,11 +55,7 @@ strict: true "####; let result = FunctionTool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "function"); assert!(instance.strict.is_some(), "Expected strict to be Some"); @@ -95,13 +89,10 @@ fn test_function_tool_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + #[test] fn test_function_tool_load_json_1() { let json = r####" @@ -130,11 +121,7 @@ fn test_function_tool_load_json_1() { } "####; let result = FunctionTool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "function"); assert!(instance.strict.is_some(), "Expected strict to be Some"); @@ -160,11 +147,7 @@ strict: true "####; let result = FunctionTool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "function"); assert!(instance.strict.is_some(), "Expected strict to be Some"); @@ -201,9 +184,8 @@ fn test_function_tool_roundtrip_1() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/mcp_server_approval_mode_test.rs b/runtime/rust/agentschema/tests/mcp_server_approval_mode_test.rs index 544c62a..6eeb06a 100644 --- a/runtime/rust/agentschema/tests/mcp_server_approval_mode_test.rs +++ b/runtime/rust/agentschema/tests/mcp_server_approval_mode_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::McpServerApprovalMode; + #[test] fn test_mcp_server_approval_mode_load_json() { let json = r####" @@ -10,11 +12,7 @@ fn test_mcp_server_approval_mode_load_json() { } "####; let result = McpServerApprovalMode::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -24,11 +22,7 @@ kind: never "####; let result = McpServerApprovalMode::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -42,9 +36,13 @@ fn test_mcp_server_approval_mode_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + #[test] fn test_mcp_server_approval_mode_from_kind() { let value = serde_json::json!("never"); let instance = McpServerApprovalMode::load_from_value(&value); let _ = instance; // abstract type, load succeeded } + + diff --git a/runtime/rust/agentschema/tests/mcp_server_tool_always_require_approval_mode_test.rs b/runtime/rust/agentschema/tests/mcp_server_tool_always_require_approval_mode_test.rs index cdc711f..8d971d9 100644 --- a/runtime/rust/agentschema/tests/mcp_server_tool_always_require_approval_mode_test.rs +++ b/runtime/rust/agentschema/tests/mcp_server_tool_always_require_approval_mode_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::McpServerToolAlwaysRequireApprovalMode; + #[test] fn test_mcp_server_tool_always_require_approval_mode_load_json() { let json = r####" @@ -10,11 +12,7 @@ fn test_mcp_server_tool_always_require_approval_mode_load_json() { } "####; let result = McpServerToolAlwaysRequireApprovalMode::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "always"); } @@ -26,11 +24,7 @@ kind: always "####; let result = McpServerToolAlwaysRequireApprovalMode::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "always"); } @@ -46,9 +40,8 @@ fn test_mcp_server_tool_always_require_approval_mode_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/mcp_server_tool_never_require_approval_mode_test.rs b/runtime/rust/agentschema/tests/mcp_server_tool_never_require_approval_mode_test.rs index 31fa371..4d8b6f4 100644 --- a/runtime/rust/agentschema/tests/mcp_server_tool_never_require_approval_mode_test.rs +++ b/runtime/rust/agentschema/tests/mcp_server_tool_never_require_approval_mode_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::McpServerToolNeverRequireApprovalMode; + #[test] fn test_mcp_server_tool_never_require_approval_mode_load_json() { let json = r####" @@ -10,11 +12,7 @@ fn test_mcp_server_tool_never_require_approval_mode_load_json() { } "####; let result = McpServerToolNeverRequireApprovalMode::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "never"); } @@ -26,11 +24,7 @@ kind: never "####; let result = McpServerToolNeverRequireApprovalMode::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "never"); } @@ -46,9 +40,8 @@ fn test_mcp_server_tool_never_require_approval_mode_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/mcp_server_tool_specify_approval_mode_test.rs b/runtime/rust/agentschema/tests/mcp_server_tool_specify_approval_mode_test.rs index a9d6b66..11c422d 100644 --- a/runtime/rust/agentschema/tests/mcp_server_tool_specify_approval_mode_test.rs +++ b/runtime/rust/agentschema/tests/mcp_server_tool_specify_approval_mode_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::McpServerToolSpecifyApprovalMode; + #[test] fn test_mcp_server_tool_specify_approval_mode_load_json() { let json = r####" @@ -16,11 +18,7 @@ fn test_mcp_server_tool_specify_approval_mode_load_json() { } "####; let result = McpServerToolSpecifyApprovalMode::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "specify"); } @@ -36,11 +34,7 @@ neverRequireApprovalTools: "####; let result = McpServerToolSpecifyApprovalMode::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "specify"); } @@ -62,9 +56,8 @@ fn test_mcp_server_tool_specify_approval_mode_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/mcp_tool_test.rs b/runtime/rust/agentschema/tests/mcp_tool_test.rs index ad42f56..2823b9c 100644 --- a/runtime/rust/agentschema/tests/mcp_tool_test.rs +++ b/runtime/rust/agentschema/tests/mcp_tool_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::McpTool; + #[test] fn test_mcp_tool_load_json() { let json = r####" @@ -22,22 +24,12 @@ fn test_mcp_tool_load_json() { } "####; let result = McpTool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "mcp"); assert_eq!(instance.server_name, "My MCP Server"); - assert!( - instance.server_description.is_some(), - "Expected server_description to be Some" - ); - assert_eq!( - instance.server_description.as_ref().unwrap(), - &"This tool allows access to MCP services." - ); + assert!(instance.server_description.is_some(), "Expected server_description to be Some"); + assert_eq!(instance.server_description.as_ref().unwrap(), &"This tool allows access to MCP services."); } #[test] @@ -56,18 +48,11 @@ allowedTools: "####; let result = McpTool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "mcp"); assert_eq!(instance.server_name, "My MCP Server"); - assert!( - instance.server_description.is_some(), - "Expected server_description to be Some" - ); + assert!(instance.server_description.is_some(), "Expected server_description to be Some"); } #[test] @@ -93,9 +78,8 @@ fn test_mcp_tool_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/model_options_test.rs b/runtime/rust/agentschema/tests/model_options_test.rs index 5be8f12..1862aab 100644 --- a/runtime/rust/agentschema/tests/model_options_test.rs +++ b/runtime/rust/agentschema/tests/model_options_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ModelOptions; + #[test] fn test_model_options_load_json() { let json = r####" @@ -25,11 +27,7 @@ fn test_model_options_load_json() { } "####; let result = ModelOptions::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -52,11 +50,7 @@ additionalProperties: "####; let result = ModelOptions::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -84,3 +78,6 @@ fn test_model_options_roundtrip() { let result = ModelOptions::from_json(json); assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + + diff --git a/runtime/rust/agentschema/tests/model_resource_test.rs b/runtime/rust/agentschema/tests/model_resource_test.rs index 5dc122a..fdb2c9a 100644 --- a/runtime/rust/agentschema/tests/model_resource_test.rs +++ b/runtime/rust/agentschema/tests/model_resource_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ModelResource; + #[test] fn test_model_resource_load_json() { let json = r####" @@ -11,11 +13,7 @@ fn test_model_resource_load_json() { } "####; let result = ModelResource::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "model"); assert_eq!(instance.id, "gpt-4o"); @@ -29,11 +27,7 @@ id: gpt-4o "####; let result = ModelResource::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "model"); assert_eq!(instance.id, "gpt-4o"); @@ -51,9 +45,8 @@ fn test_model_resource_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/model_test.rs b/runtime/rust/agentschema/tests/model_test.rs index edb52a2..0110e0f 100644 --- a/runtime/rust/agentschema/tests/model_test.rs +++ b/runtime/rust/agentschema/tests/model_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Model; + #[test] fn test_model_load_json() { let json = r####" @@ -22,11 +24,7 @@ fn test_model_load_json() { } "####; let result = Model::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.id, "gpt-35-turbo"); assert!(instance.provider.is_some(), "Expected provider to be Some"); @@ -52,11 +50,7 @@ options: "####; let result = Model::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.id, "gpt-35-turbo"); assert!(instance.provider.is_some(), "Expected provider to be Some"); @@ -86,16 +80,16 @@ fn test_model_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + #[test] fn test_model_from_model() { let value = serde_json::json!("example"); let instance = Model::load_from_value(&value); assert_eq!(instance.id, "example"); } + + diff --git a/runtime/rust/agentschema/tests/o_auth_connection_test.rs b/runtime/rust/agentschema/tests/o_auth_connection_test.rs index 9654eb9..6ee5cd9 100644 --- a/runtime/rust/agentschema/tests/o_auth_connection_test.rs +++ b/runtime/rust/agentschema/tests/o_auth_connection_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::OAuthConnection; + #[test] fn test_o_auth_connection_load_json() { let json = r####" @@ -17,20 +19,13 @@ fn test_o_auth_connection_load_json() { } "####; let result = OAuthConnection::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "oauth"); assert_eq!(instance.endpoint, "https://api.example.com"); assert_eq!(instance.client_id, "your-client-id"); assert_eq!(instance.client_secret, "your-client-secret"); - assert_eq!( - instance.token_url, - "https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token" - ); + assert_eq!(instance.token_url, "https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token"); } #[test] @@ -46,20 +41,13 @@ scopes: "####; let result = OAuthConnection::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "oauth"); assert_eq!(instance.endpoint, "https://api.example.com"); assert_eq!(instance.client_id, "your-client-id"); assert_eq!(instance.client_secret, "your-client-secret"); - assert_eq!( - instance.token_url, - "https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token" - ); + assert_eq!(instance.token_url, "https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token"); } #[test] @@ -80,9 +68,8 @@ fn test_o_auth_connection_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/object_property_test.rs b/runtime/rust/agentschema/tests/object_property_test.rs index 5815317..0b3098c 100644 --- a/runtime/rust/agentschema/tests/object_property_test.rs +++ b/runtime/rust/agentschema/tests/object_property_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ObjectProperty; + #[test] fn test_object_property_load_json() { let json = r####" @@ -17,11 +19,7 @@ fn test_object_property_load_json() { } "####; let result = ObjectProperty::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); let _ = instance; // load succeeded, no scalar properties to validate } @@ -37,11 +35,7 @@ properties: "####; let result = ObjectProperty::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); let _ = instance; // load succeeded, no scalar properties to validate } @@ -64,9 +58,8 @@ fn test_object_property_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/open_api_tool_test.rs b/runtime/rust/agentschema/tests/open_api_tool_test.rs index 821d237..90bf4d8 100644 --- a/runtime/rust/agentschema/tests/open_api_tool_test.rs +++ b/runtime/rust/agentschema/tests/open_api_tool_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::OpenApiTool; + #[test] fn test_open_api_tool_load_json() { let json = r####" @@ -14,11 +16,7 @@ fn test_open_api_tool_load_json() { } "####; let result = OpenApiTool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "openapi"); assert_eq!(instance.specification, "full_sepcification_here"); @@ -34,11 +32,7 @@ specification: full_sepcification_here "####; let result = OpenApiTool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "openapi"); assert_eq!(instance.specification, "full_sepcification_here"); @@ -59,9 +53,8 @@ fn test_open_api_tool_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/parser_test.rs b/runtime/rust/agentschema/tests/parser_test.rs index b12e717..ab1c265 100644 --- a/runtime/rust/agentschema/tests/parser_test.rs +++ b/runtime/rust/agentschema/tests/parser_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Parser; + #[test] fn test_parser_load_json() { let json = r####" @@ -13,11 +15,7 @@ fn test_parser_load_json() { } "####; let result = Parser::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -29,11 +27,7 @@ options: "####; let result = Parser::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -50,9 +44,13 @@ fn test_parser_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + #[test] fn test_parser_from_parser() { let value = serde_json::json!("example"); let instance = Parser::load_from_value(&value); let _ = instance; // abstract type, load succeeded } + + diff --git a/runtime/rust/agentschema/tests/prompt_agent_test.rs b/runtime/rust/agentschema/tests/prompt_agent_test.rs index cea0796..6d021bd 100644 --- a/runtime/rust/agentschema/tests/prompt_agent_test.rs +++ b/runtime/rust/agentschema/tests/prompt_agent_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::PromptAgent; + #[test] fn test_prompt_agent_load_json() { let json = r####" @@ -40,17 +42,10 @@ fn test_prompt_agent_load_json() { } "####; let result = PromptAgent::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "prompt"); - assert!( - instance.instructions.is_some(), - "Expected instructions to be Some" - ); + assert!(instance.instructions.is_some(), "Expected instructions to be Some"); assert_eq!(instance.instructions.as_ref().unwrap(), &"system:\nYou are an AI assistant who helps people find information.\nAs the assistant, you answer questions briefly, succinctly,\nand in a personable manner using markdown and even add some \npersonal flair with appropriate emojis.\n\n# Customer\nYou are helping {{firstName}} {{lastName}} to find answers to \ntheir questions. Use their name to address them in your responses.\nuser:\n{{question}}"); } @@ -101,17 +96,10 @@ instructions: "system: "####; let result = PromptAgent::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "prompt"); - assert!( - instance.instructions.is_some(), - "Expected instructions to be Some" - ); + assert!(instance.instructions.is_some(), "Expected instructions to be Some"); } #[test] @@ -155,13 +143,10 @@ fn test_prompt_agent_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + #[test] fn test_prompt_agent_load_json_1() { let json = r####" @@ -199,17 +184,10 @@ fn test_prompt_agent_load_json_1() { } "####; let result = PromptAgent::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "prompt"); - assert!( - instance.instructions.is_some(), - "Expected instructions to be Some" - ); + assert!(instance.instructions.is_some(), "Expected instructions to be Some"); assert_eq!(instance.instructions.as_ref().unwrap(), &"system:\nYou are an AI assistant who helps people find information.\nAs the assistant, you answer questions briefly, succinctly,\nand in a personable manner using markdown and even add some \npersonal flair with appropriate emojis.\n\n# Customer\nYou are helping {{firstName}} {{lastName}} to find answers to \ntheir questions. Use their name to address them in your responses.\nuser:\n{{question}}"); } @@ -260,17 +238,10 @@ instructions: "system: "####; let result = PromptAgent::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "prompt"); - assert!( - instance.instructions.is_some(), - "Expected instructions to be Some" - ); + assert!(instance.instructions.is_some(), "Expected instructions to be Some"); } #[test] @@ -313,9 +284,8 @@ fn test_prompt_agent_roundtrip_1() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/property_schema_test.rs b/runtime/rust/agentschema/tests/property_schema_test.rs index b420819..50b0824 100644 --- a/runtime/rust/agentschema/tests/property_schema_test.rs +++ b/runtime/rust/agentschema/tests/property_schema_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::PropertySchema; + #[test] fn test_property_schema_load_json() { let json = r####" @@ -29,11 +31,7 @@ fn test_property_schema_load_json() { } "####; let result = PropertySchema::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert!(instance.strict.is_some(), "Expected strict to be Some"); assert_eq!(instance.strict.as_ref().unwrap(), &true); @@ -58,11 +56,7 @@ properties: "####; let result = PropertySchema::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert!(instance.strict.is_some(), "Expected strict to be Some"); } @@ -97,9 +91,8 @@ fn test_property_schema_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/property_test.rs b/runtime/rust/agentschema/tests/property_test.rs index 33d9e6b..3fc2150 100644 --- a/runtime/rust/agentschema/tests/property_test.rs +++ b/runtime/rust/agentschema/tests/property_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Property; + #[test] fn test_property_load_json() { let json = r####" @@ -20,11 +22,7 @@ fn test_property_load_json() { } "####; let result = Property::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -43,11 +41,7 @@ enumValues: "####; let result = Property::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -71,6 +65,8 @@ fn test_property_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + #[test] fn test_property_from_input() { let value = serde_json::json!(false); @@ -78,6 +74,7 @@ fn test_property_from_input() { let _ = instance; // abstract type, load succeeded } + #[test] fn test_property_from_input_2() { let value = serde_json::json!(3.14); @@ -85,6 +82,7 @@ fn test_property_from_input_2() { let _ = instance; // abstract type, load succeeded } + #[test] fn test_property_from_input_3() { let value = serde_json::json!(4); @@ -92,9 +90,12 @@ fn test_property_from_input_3() { let _ = instance; // abstract type, load succeeded } + #[test] fn test_property_from_input_4() { let value = serde_json::json!("example"); let instance = Property::load_from_value(&value); let _ = instance; // abstract type, load succeeded } + + diff --git a/runtime/rust/agentschema/tests/protocol_version_record_test.rs b/runtime/rust/agentschema/tests/protocol_version_record_test.rs index d2f3746..4b3a602 100644 --- a/runtime/rust/agentschema/tests/protocol_version_record_test.rs +++ b/runtime/rust/agentschema/tests/protocol_version_record_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ProtocolVersionRecord; + #[test] fn test_protocol_version_record_load_json() { let json = r####" @@ -11,11 +13,7 @@ fn test_protocol_version_record_load_json() { } "####; let result = ProtocolVersionRecord::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.protocol, "responses"); assert_eq!(instance.version, "v0.1.1"); @@ -29,11 +27,7 @@ version: v0.1.1 "####; let result = ProtocolVersionRecord::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.protocol, "responses"); assert_eq!(instance.version, "v0.1.1"); @@ -51,9 +45,8 @@ fn test_protocol_version_record_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/reference_connection_test.rs b/runtime/rust/agentschema/tests/reference_connection_test.rs index f05c0ba..5abfcde 100644 --- a/runtime/rust/agentschema/tests/reference_connection_test.rs +++ b/runtime/rust/agentschema/tests/reference_connection_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ReferenceConnection; + #[test] fn test_reference_connection_load_json() { let json = r####" @@ -12,11 +14,7 @@ fn test_reference_connection_load_json() { } "####; let result = ReferenceConnection::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "reference"); assert_eq!(instance.name, "my-reference-connection"); @@ -33,11 +31,7 @@ target: my-target-resource "####; let result = ReferenceConnection::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "reference"); assert_eq!(instance.name, "my-reference-connection"); @@ -57,9 +51,8 @@ fn test_reference_connection_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/remote_connection_test.rs b/runtime/rust/agentschema/tests/remote_connection_test.rs index 70b2b64..f097821 100644 --- a/runtime/rust/agentschema/tests/remote_connection_test.rs +++ b/runtime/rust/agentschema/tests/remote_connection_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::RemoteConnection; + #[test] fn test_remote_connection_load_json() { let json = r####" @@ -12,18 +14,11 @@ fn test_remote_connection_load_json() { } "####; let result = RemoteConnection::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "remote"); assert_eq!(instance.name, "my-reference-connection"); - assert_eq!( - instance.endpoint, - "https://{your-custom-endpoint}.openai.azure.com/" - ); + assert_eq!(instance.endpoint, "https://{your-custom-endpoint}.openai.azure.com/"); } #[test] @@ -35,18 +30,11 @@ endpoint: "https://{your-custom-endpoint}.openai.azure.com/" "####; let result = RemoteConnection::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "remote"); assert_eq!(instance.name, "my-reference-connection"); - assert_eq!( - instance.endpoint, - "https://{your-custom-endpoint}.openai.azure.com/" - ); + assert_eq!(instance.endpoint, "https://{your-custom-endpoint}.openai.azure.com/"); } #[test] @@ -62,9 +50,8 @@ fn test_remote_connection_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/resource_test.rs b/runtime/rust/agentschema/tests/resource_test.rs index 2db7bad..2e7d771 100644 --- a/runtime/rust/agentschema/tests/resource_test.rs +++ b/runtime/rust/agentschema/tests/resource_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Resource; + #[test] fn test_resource_load_json() { let json = r####" @@ -11,11 +13,7 @@ fn test_resource_load_json() { } "####; let result = Resource::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -26,11 +24,7 @@ kind: model "####; let result = Resource::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -44,3 +38,6 @@ fn test_resource_roundtrip() { let result = Resource::from_json(json); assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + + diff --git a/runtime/rust/agentschema/tests/template_test.rs b/runtime/rust/agentschema/tests/template_test.rs index 14ce79e..3d7c28b 100644 --- a/runtime/rust/agentschema/tests/template_test.rs +++ b/runtime/rust/agentschema/tests/template_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Template; + #[test] fn test_template_load_json() { let json = r####" @@ -15,11 +17,7 @@ fn test_template_load_json() { } "####; let result = Template::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); let _ = instance; // load succeeded, no scalar properties to validate } @@ -34,11 +32,7 @@ parser: "####; let result = Template::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); let _ = instance; // load succeeded, no scalar properties to validate } @@ -59,9 +53,8 @@ fn test_template_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/tool_resource_test.rs b/runtime/rust/agentschema/tests/tool_resource_test.rs index 323acd8..d155fd1 100644 --- a/runtime/rust/agentschema/tests/tool_resource_test.rs +++ b/runtime/rust/agentschema/tests/tool_resource_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::ToolResource; + #[test] fn test_tool_resource_load_json() { let json = r####" @@ -14,11 +16,7 @@ fn test_tool_resource_load_json() { } "####; let result = ToolResource::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "tool"); assert_eq!(instance.id, "web-search"); @@ -34,11 +32,7 @@ options: "####; let result = ToolResource::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "tool"); assert_eq!(instance.id, "web-search"); @@ -59,9 +53,8 @@ fn test_tool_resource_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/tool_test.rs b/runtime/rust/agentschema/tests/tool_test.rs index e279d61..d510c20 100644 --- a/runtime/rust/agentschema/tests/tool_test.rs +++ b/runtime/rust/agentschema/tests/tool_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Tool; + #[test] fn test_tool_load_json() { let json = r####" @@ -15,11 +17,7 @@ fn test_tool_load_json() { } "####; let result = Tool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); } #[test] @@ -33,11 +31,7 @@ bindings: "####; let result = Tool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); } #[test] @@ -55,3 +49,6 @@ fn test_tool_roundtrip() { let result = Tool::from_json(json); assert!(result.is_ok(), "Failed to load: {:?}", result.err()); } + + + diff --git a/runtime/rust/agentschema/tests/web_search_tool_test.rs b/runtime/rust/agentschema/tests/web_search_tool_test.rs index 4d971a1..c47fd8b 100644 --- a/runtime/rust/agentschema/tests/web_search_tool_test.rs +++ b/runtime/rust/agentschema/tests/web_search_tool_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::WebSearchTool; + #[test] fn test_web_search_tool_load_json() { let json = r####" @@ -20,11 +22,7 @@ fn test_web_search_tool_load_json() { } "####; let result = WebSearchTool::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "bing_search"); } @@ -44,11 +42,7 @@ options: "####; let result = WebSearchTool::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "bing_search"); } @@ -74,9 +68,8 @@ fn test_web_search_tool_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/rust/agentschema/tests/workflow_test.rs b/runtime/rust/agentschema/tests/workflow_test.rs index 3e7ed52..bb72fd1 100644 --- a/runtime/rust/agentschema/tests/workflow_test.rs +++ b/runtime/rust/agentschema/tests/workflow_test.rs @@ -1,7 +1,9 @@ + // Code generated by AgentSchema emitter; DO NOT EDIT. use agentschema::Workflow; + #[test] fn test_workflow_load_json() { let json = r####" @@ -10,11 +12,7 @@ fn test_workflow_load_json() { } "####; let result = Workflow::from_json(json); - assert!( - result.is_ok(), - "Failed to load from JSON: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from JSON: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "workflow"); } @@ -26,11 +24,7 @@ kind: workflow "####; let result = Workflow::from_yaml(yaml); - assert!( - result.is_ok(), - "Failed to load from YAML: {:?}", - result.err() - ); + assert!(result.is_ok(), "Failed to load from YAML: {:?}", result.err()); let instance = result.unwrap(); assert_eq!(instance.kind, "workflow"); } @@ -46,9 +40,8 @@ fn test_workflow_roundtrip() { assert!(result.is_ok(), "Failed to load: {:?}", result.err()); let instance = result.unwrap(); let json_output = instance.to_json(); - assert!( - json_output.is_ok(), - "Failed to serialize to JSON: {:?}", - json_output.err() - ); + assert!(json_output.is_ok(), "Failed to serialize to JSON: {:?}", json_output.err()); } + + + diff --git a/runtime/typescript/agentschema/src/agent-definition.ts b/runtime/typescript/agentschema/src/agent-definition.ts index 23e6675..c8409cd 100644 --- a/runtime/typescript/agentschema/src/agent-definition.ts +++ b/runtime/typescript/agentschema/src/agent-definition.ts @@ -2,6 +2,7 @@ // WARNING: This is an auto-generated file. DO NOT EDIT THIS FILE DIRECTLY. import { LoadContext, SaveContext } from "./context"; +import { CodeConfiguration } from "./code-configuration"; import { ContainerResources } from "./container-resources"; import { EnvironmentVariable } from "./environment-variable"; import { Model } from "./model"; @@ -739,6 +740,11 @@ export class ContainerAgent extends AgentDefinition { */ environmentVariables?: EnvironmentVariable[] = []; + /** + * Configuration for code-based (ZIP upload) deployment. When present, agent source code is uploaded directly instead of building a container image. + */ + codeConfiguration?: CodeConfiguration | undefined; + /** * Initializes a new instance of ContainerAgent. */ @@ -762,6 +768,10 @@ export class ContainerAgent extends AgentDefinition { if (init?.environmentVariables !== undefined) { this.environmentVariables = init.environmentVariables; } + + if (init?.codeConfiguration !== undefined) { + this.codeConfiguration = init.codeConfiguration; + } } //#region Load Methods @@ -810,6 +820,13 @@ export class ContainerAgent extends AgentDefinition { ); } + if (data["codeConfiguration"] !== undefined && data["codeConfiguration"] !== null) { + instance.codeConfiguration = CodeConfiguration.load( + data["codeConfiguration"] as Record, + context + ); + } + if (context) { return context.processOutput(instance) as ContainerAgent; } @@ -930,6 +947,10 @@ export class ContainerAgent extends AgentDefinition { ); } + if (obj.codeConfiguration !== undefined && obj.codeConfiguration !== null) { + result["codeConfiguration"] = obj.codeConfiguration?.save(context); + } + return result; } diff --git a/runtime/typescript/agentschema/src/code-configuration.ts b/runtime/typescript/agentschema/src/code-configuration.ts new file mode 100644 index 0000000..39a516b --- /dev/null +++ b/runtime/typescript/agentschema/src/code-configuration.ts @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft. All rights reserved. +// WARNING: This is an auto-generated file. DO NOT EDIT THIS FILE DIRECTLY. + +import { LoadContext, SaveContext } from "./context"; + +/** + * Configuration for code-based (ZIP upload) deployment of a hosted agent. + * When present, the agent source code is uploaded directly instead of building a container image. + * + */ +export class CodeConfiguration { + /** + * The shorthand property name for this type, if any. + */ + static readonly shorthandProperty: string | undefined = undefined; + + /** + * Runtime identifier for code execution (e.g., 'python_3_11', 'dotnet_8'). + */ + runtime: string = ""; + + /** + * The entry point file for the agent (e.g., 'main.py' for Python, 'HelloWorld.dll' for .NET). + */ + entryPoint: string = ""; + + /** + * How package dependencies are resolved at deployment time. + */ + dependencyResolution?: string | undefined; + + /** + * Initializes a new instance of CodeConfiguration. + */ + constructor(init?: Partial) { + this.runtime = init?.runtime ?? ""; + + this.entryPoint = init?.entryPoint ?? ""; + + if (init?.dependencyResolution !== undefined) { + this.dependencyResolution = init.dependencyResolution; + } + } + + //#region Load Methods + + /** + * Load a CodeConfiguration instance from a dictionary. + * @param data - The dictionary containing the data. + * @param context - Optional context with pre/post processing callbacks. + * @returns The loaded CodeConfiguration instance. + */ + static load(data: Record, context?: LoadContext): CodeConfiguration { + if (context) { + data = context.processInput(data); + } + + // Create new instance + const instance = new CodeConfiguration(); + + if (data["runtime"] !== undefined && data["runtime"] !== null) { + instance.runtime = String(data["runtime"]); + } + + if (data["entryPoint"] !== undefined && data["entryPoint"] !== null) { + instance.entryPoint = String(data["entryPoint"]); + } + + if (data["dependencyResolution"] !== undefined && data["dependencyResolution"] !== null) { + instance.dependencyResolution = String(data["dependencyResolution"]); + } + + if (context) { + return context.processOutput(instance) as CodeConfiguration; + } + return instance; + } + + //#endregion + + //#region Save Methods + + /** + * Save the CodeConfiguration instance to a dictionary. + * @param context - Optional context with pre/post processing callbacks. + * @returns The dictionary representation of this instance. + */ + save(context?: SaveContext): Record { + const obj = context ? (context.processObject(this) as CodeConfiguration) : this; + + const result: Record = {}; + + if (obj.runtime !== undefined && obj.runtime !== null) { + result["runtime"] = obj.runtime; + } + + if (obj.entryPoint !== undefined && obj.entryPoint !== null) { + result["entryPoint"] = obj.entryPoint; + } + + if (obj.dependencyResolution !== undefined && obj.dependencyResolution !== null) { + result["dependencyResolution"] = obj.dependencyResolution; + } + + if (context) { + return context.processDict(result); + } + + return result; + } + + /** + * Convert the CodeConfiguration instance to a YAML string. + * @param context - Optional context with pre/post processing callbacks. + * @returns The YAML string representation of this instance. + */ + toYaml(context?: SaveContext): string { + context = context ?? new SaveContext(); + return context.toYaml(this.save(context)); + } + + /** + * Convert the CodeConfiguration instance to a JSON string. + * @param context - Optional context with pre/post processing callbacks. + * @param indent - Number of spaces for indentation. Defaults to 2. + * @returns The JSON string representation of this instance. + */ + toJson(context?: SaveContext, indent: number = 2): string { + context = context ?? new SaveContext(); + return context.toJson(this.save(context), indent); + } + + /** + * Load a CodeConfiguration instance from a JSON string. + * @param json - The JSON string to parse. + * @param context - Optional context with pre/post processing callbacks. + * @returns The loaded CodeConfiguration instance. + */ + static fromJson(json: string, context?: LoadContext): CodeConfiguration { + const data = JSON.parse(json); + + return CodeConfiguration.load(data as Record, context); + } + + /** + * Load a CodeConfiguration instance from a YAML string. + * @param yaml - The YAML string to parse. + * @param context - Optional context with pre/post processing callbacks. + * @returns The loaded CodeConfiguration instance. + */ + static fromYaml(yaml: string, context?: LoadContext): CodeConfiguration { + const { parse } = require("yaml"); + const data = parse(yaml); + + return CodeConfiguration.load(data as Record, context); + } + + //#endregion +} diff --git a/runtime/typescript/agentschema/src/index.ts b/runtime/typescript/agentschema/src/index.ts index 6af680a..2cb91e7 100644 --- a/runtime/typescript/agentschema/src/index.ts +++ b/runtime/typescript/agentschema/src/index.ts @@ -55,6 +55,8 @@ export { ContainerResources } from "./container-resources"; export { EnvironmentVariable } from "./environment-variable"; +export { CodeConfiguration } from "./code-configuration"; + export { Resource, ModelResource, ToolResource } from "./resource"; export { AgentManifest } from "./agent-manifest"; diff --git a/runtime/typescript/agentschema/tests/code-configuration.test.ts b/runtime/typescript/agentschema/tests/code-configuration.test.ts new file mode 100644 index 0000000..87f14a9 --- /dev/null +++ b/runtime/typescript/agentschema/tests/code-configuration.test.ts @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft. All rights reserved. +// WARNING: This is an auto-generated file. DO NOT EDIT THIS FILE DIRECTLY. + +import { CodeConfiguration } from "../src/index"; + +describe("CodeConfiguration", () => { + describe("construction", () => { + it("should create a new instance with defaults", () => { + const instance = new CodeConfiguration(); + expect(instance).toBeDefined(); + }); + + it("should create a new instance with partial initialization", () => { + const instance = new CodeConfiguration({}); + expect(instance).toBeDefined(); + }); + }); + + describe("JSON serialization", () => { + it("should load from JSON - example 1", () => { + const json = `{\n "runtime": "python_3_11",\n "entryPoint": "main.py",\n "dependencyResolution": "remote_build"\n}`; + const instance = CodeConfiguration.fromJson(json); + expect(instance).toBeDefined(); + + expect(instance.runtime).toEqual("python_3_11"); + + expect(instance.entryPoint).toEqual("main.py"); + + expect(instance.dependencyResolution).toEqual("remote_build"); + }); + + it("should round-trip JSON - example 1", () => { + const json = `{\n "runtime": "python_3_11",\n "entryPoint": "main.py",\n "dependencyResolution": "remote_build"\n}`; + const instance = CodeConfiguration.fromJson(json); + const output = instance.toJson(); + const reloaded = CodeConfiguration.fromJson(output); + + expect(reloaded.runtime).toEqual(instance.runtime); + + expect(reloaded.entryPoint).toEqual(instance.entryPoint); + + expect(reloaded.dependencyResolution).toEqual(instance.dependencyResolution); + }); + }); + + describe("YAML serialization", () => { + it("should load from YAML - example 1", () => { + const yaml = `runtime: python_3_11\nentryPoint: main.py\ndependencyResolution: remote_build\n`; + const instance = CodeConfiguration.fromYaml(yaml); + expect(instance).toBeDefined(); + + expect(instance.runtime).toEqual("python_3_11"); + + expect(instance.entryPoint).toEqual("main.py"); + + expect(instance.dependencyResolution).toEqual("remote_build"); + }); + + it("should round-trip YAML - example 1", () => { + const yaml = `runtime: python_3_11\nentryPoint: main.py\ndependencyResolution: remote_build\n`; + const instance = CodeConfiguration.fromYaml(yaml); + const output = instance.toYaml(); + const reloaded = CodeConfiguration.fromYaml(output); + + expect(reloaded.runtime).toEqual(instance.runtime); + + expect(reloaded.entryPoint).toEqual(instance.entryPoint); + + expect(reloaded.dependencyResolution).toEqual(instance.dependencyResolution); + }); + }); + + describe("load and save", () => { + it("should load from dictionary", () => { + const data: Record = {}; + const instance = CodeConfiguration.load(data); + expect(instance).toBeDefined(); + }); + + it("should save to dictionary", () => { + const instance = new CodeConfiguration(); + const data = instance.save(); + expect(data).toBeDefined(); + expect(typeof data).toBe("object"); + }); + }); +}); diff --git a/schemas/v1.0/CodeConfiguration.yaml b/schemas/v1.0/CodeConfiguration.yaml new file mode 100644 index 0000000..18ca7c4 --- /dev/null +++ b/schemas/v1.0/CodeConfiguration.yaml @@ -0,0 +1,24 @@ +$schema: https://json-schema.org/draft/2020-12/schema +$id: CodeConfiguration.yaml +type: object +properties: + runtime: + type: string + description: Runtime identifier for code execution (e.g., 'python_3_11', 'dotnet_8'). + entryPoint: + type: string + description: The entry point file for the agent (e.g., 'main.py' for Python, 'HelloWorld.dll' for .NET). + dependencyResolution: + anyOf: + - type: string + const: bundled + - type: string + const: remote_build + - type: string + description: How package dependencies are resolved at deployment time. +required: + - runtime + - entryPoint +description: |- + Configuration for code-based (ZIP upload) deployment of a hosted agent. + When present, the agent source code is uploaded directly instead of building a container image. diff --git a/schemas/v1.0/ContainerAgent.yaml b/schemas/v1.0/ContainerAgent.yaml index 965c94f..5d1f4ca 100644 --- a/schemas/v1.0/ContainerAgent.yaml +++ b/schemas/v1.0/ContainerAgent.yaml @@ -38,6 +38,9 @@ properties: - name - value description: Environment variables to set in the container + codeConfiguration: + $ref: CodeConfiguration.yaml + description: Configuration for code-based (ZIP upload) deployment. When present, agent source code is uploaded directly instead of building a container image. required: - kind - protocols