Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions agentschema-emitter/lib/model/container.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ alias EnvironmentVariables = Record<EnvironmentVariable> | 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.
*/
Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions docs/src/content/docs/reference/AgentDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ classDiagram
+string dockerfilePath
+ContainerResources resources
+EnvironmentVariable[] environmentVariables
+CodeConfiguration codeConfiguration
}
AgentDefinition <|-- ContainerAgent
```
Expand Down
44 changes: 44 additions & 0 deletions docs/src/content/docs/reference/CodeConfiguration.md
Original file line number Diff line number Diff line change
@@ -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., &#39;python_3_11&#39;, &#39;dotnet_8&#39;). |
| entryPoint | string | The entry point file for the agent (e.g., &#39;main.py&#39; for Python, &#39;HelloWorld.dll&#39; for .NET). |
| dependencyResolution | string | How package dependencies are resolved at deployment time. |
9 changes: 9 additions & 0 deletions docs/src/content/docs/reference/ContainerAgent.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ classDiagram
+string dockerfilePath
+ContainerResources resources
+EnvironmentVariable[] environmentVariables
+CodeConfiguration codeConfiguration
}
class ProtocolVersionRecord {
+string protocol
Expand All @@ -54,6 +55,12 @@ classDiagram
+string value
}
ContainerAgent *-- EnvironmentVariable
class CodeConfiguration {
+string runtime
+string entryPoint
+string dependencyResolution
}
ContainerAgent *-- CodeConfiguration
```

## Yaml Example
Expand Down Expand Up @@ -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

Expand All @@ -91,3 +99,4 @@ The following types are composed within `ContainerAgent`:
- [ProtocolVersionRecord](../protocolversionrecord/)
- [ContainerResources](../containerresources/)
- [EnvironmentVariable](../environmentvariable/)
- [CodeConfiguration](../codeconfiguration/)
8 changes: 8 additions & 0 deletions docs/src/content/docs/reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ classDiagram
+string name
+string value
}
class CodeConfiguration {

+string runtime
+string entryPoint
+string dependencyResolution
}
class ContainerAgent {

+string kind
Expand All @@ -252,6 +258,7 @@ classDiagram
+string dockerfilePath
+ContainerResources resources
+EnvironmentVariable[] environmentVariables
+CodeConfiguration codeConfiguration
}
class Resource {
<<abstract>>
Expand Down Expand Up @@ -326,6 +333,7 @@ classDiagram
ContainerAgent *-- ProtocolVersionRecord
ContainerAgent *-- ContainerResources
ContainerAgent *-- EnvironmentVariable
ContainerAgent *-- CodeConfiguration
AgentManifest *-- AgentDefinition
AgentManifest *-- PropertySchema
AgentManifest *-- Resource
Expand Down
133 changes: 133 additions & 0 deletions runtime/csharp/AgentSchema.Tests/CodeConfigurationConversionTests.cs
Original file line number Diff line number Diff line change
@@ -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<object>(yaml);
Assert.NotNull(parsed);
}
}
Loading
Loading