Skip to content
Open
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
164 changes: 164 additions & 0 deletions dotnet/src/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,34 @@ public enum ConnectionState

public class CopilotClientOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="CopilotClientOptions"/> class.
/// </summary>
public CopilotClientOptions() { }

/// <summary>
/// Initializes a new instance of the <see cref="CopilotClientOptions"/> class
/// by copying the properties of the specified instance.
/// </summary>
protected CopilotClientOptions(CopilotClientOptions? other)
{
if (other is null) return;

AutoRestart = other.AutoRestart;
AutoStart = other.AutoStart;
CliArgs = (string[]?)other.CliArgs?.Clone();
CliPath = other.CliPath;
CliUrl = other.CliUrl;
Cwd = other.Cwd;
Environment = other.Environment;
GithubToken = other.GithubToken;
Logger = other.Logger;
LogLevel = other.LogLevel;
Port = other.Port;
UseLoggedInUser = other.UseLoggedInUser;
UseStdio = other.UseStdio;
}

/// <summary>
/// Path to the Copilot CLI executable. If not specified, uses the bundled CLI from the SDK.
/// </summary>
Expand Down Expand Up @@ -53,6 +81,17 @@ public class CopilotClientOptions
/// Default: true (but defaults to false when GithubToken is provided).
/// </summary>
public bool? UseLoggedInUser { get; set; }

/// <summary>
/// Creates a shallow clone of this <see cref="CopilotClientOptions"/> instance.
/// </summary>
/// <remarks>
/// Mutable collection properties are copied into new collection instances so that modifications
/// to those collections on the clone do not affect the original.
/// Other reference-type properties (for example delegates and the logger) are not
/// deep-cloned; the original and the clone will share those objects.
/// </remarks>
public virtual CopilotClientOptions Clone() => new(this);
}

public class ToolBinaryResult
Expand Down Expand Up @@ -692,6 +731,42 @@ public class InfiniteSessionConfig

public class SessionConfig
{
/// <summary>
/// Initializes a new instance of the <see cref="SessionConfig"/> class.
/// </summary>
public SessionConfig() { }

/// <summary>
/// Initializes a new instance of the <see cref="SessionConfig"/> class
/// by copying the properties of the specified instance.
/// </summary>
protected SessionConfig(SessionConfig? other)
{
if (other is null) return;

AvailableTools = other.AvailableTools is not null ? [.. other.AvailableTools] : null;
ConfigDir = other.ConfigDir;
CustomAgents = other.CustomAgents is not null ? [.. other.CustomAgents] : null;
DisabledSkills = other.DisabledSkills is not null ? [.. other.DisabledSkills] : null;
ExcludedTools = other.ExcludedTools is not null ? [.. other.ExcludedTools] : null;
Hooks = other.Hooks;
InfiniteSessions = other.InfiniteSessions;
McpServers = other.McpServers is not null
? new Dictionary<string, object>(other.McpServers, other.McpServers.Comparer)
: null;
Model = other.Model;
OnPermissionRequest = other.OnPermissionRequest;
OnUserInputRequest = other.OnUserInputRequest;
Provider = other.Provider;
ReasoningEffort = other.ReasoningEffort;
SessionId = other.SessionId;
SkillDirectories = other.SkillDirectories is not null ? [.. other.SkillDirectories] : null;
Streaming = other.Streaming;
SystemMessage = other.SystemMessage;
Tools = other.Tools is not null ? [.. other.Tools] : null;
WorkingDirectory = other.WorkingDirectory;
}

public string? SessionId { get; set; }
public string? Model { get; set; }

Expand Down Expand Up @@ -769,10 +844,58 @@ public class SessionConfig
/// When enabled (default), sessions automatically manage context limits and persist state.
/// </summary>
public InfiniteSessionConfig? InfiniteSessions { get; set; }

/// <summary>
/// Creates a shallow clone of this <see cref="SessionConfig"/> instance.
/// </summary>
/// <remarks>
/// Mutable collection properties are copied into new collection instances so that modifications
/// to those collections on the clone do not affect the original.
/// Other reference-type properties (for example provider configuration, system messages,
/// hooks, infinite session configuration, and delegates) are not deep-cloned; the original
/// and the clone will share those nested objects, and changes to them may affect both.
/// </remarks>
public virtual SessionConfig Clone() => new(this);
}

public class ResumeSessionConfig
{
/// <summary>
/// Initializes a new instance of the <see cref="ResumeSessionConfig"/> class.
/// </summary>
public ResumeSessionConfig() { }

/// <summary>
/// Initializes a new instance of the <see cref="ResumeSessionConfig"/> class
/// by copying the properties of the specified instance.
/// </summary>
protected ResumeSessionConfig(ResumeSessionConfig? other)
{
if (other is null) return;

AvailableTools = other.AvailableTools is not null ? [.. other.AvailableTools] : null;
ConfigDir = other.ConfigDir;
CustomAgents = other.CustomAgents is not null ? [.. other.CustomAgents] : null;
DisabledSkills = other.DisabledSkills is not null ? [.. other.DisabledSkills] : null;
DisableResume = other.DisableResume;
ExcludedTools = other.ExcludedTools is not null ? [.. other.ExcludedTools] : null;
Hooks = other.Hooks;
InfiniteSessions = other.InfiniteSessions;
McpServers = other.McpServers is not null
? new Dictionary<string, object>(other.McpServers, other.McpServers.Comparer)
: null;
Model = other.Model;
OnPermissionRequest = other.OnPermissionRequest;
OnUserInputRequest = other.OnUserInputRequest;
Provider = other.Provider;
ReasoningEffort = other.ReasoningEffort;
SkillDirectories = other.SkillDirectories is not null ? [.. other.SkillDirectories] : null;
Streaming = other.Streaming;
SystemMessage = other.SystemMessage;
Tools = other.Tools is not null ? [.. other.Tools] : null;
WorkingDirectory = other.WorkingDirectory;
}

/// <summary>
/// Model to use for this session. Can change the model when resuming.
/// </summary>
Expand Down Expand Up @@ -870,13 +993,54 @@ public class ResumeSessionConfig
/// Infinite session configuration for persistent workspaces and automatic compaction.
/// </summary>
public InfiniteSessionConfig? InfiniteSessions { get; set; }

/// <summary>
/// Creates a shallow clone of this <see cref="ResumeSessionConfig"/> instance.
/// </summary>
/// <remarks>
/// Mutable collection properties are copied into new collection instances so that modifications
/// to those collections on the clone do not affect the original.
/// Other reference-type properties (for example provider configuration, system messages,
/// hooks, infinite session configuration, and delegates) are not deep-cloned; the original
/// and the clone will share those nested objects, and changes to them may affect both.
/// </remarks>
public virtual ResumeSessionConfig Clone() => new(this);
}

public class MessageOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="MessageOptions"/> class.
/// </summary>
public MessageOptions() { }

/// <summary>
/// Initializes a new instance of the <see cref="MessageOptions"/> class
/// by copying the properties of the specified instance.
/// </summary>
protected MessageOptions(MessageOptions? other)
{
if (other is null) return;

Attachments = other.Attachments is not null ? [.. other.Attachments] : null;
Mode = other.Mode;
Prompt = other.Prompt;
}

public string Prompt { get; set; } = string.Empty;
public List<UserMessageDataAttachmentsItem>? Attachments { get; set; }
public string? Mode { get; set; }

/// <summary>
/// Creates a shallow clone of this <see cref="MessageOptions"/> instance.
/// </summary>
/// <remarks>
/// Mutable collection properties are copied into new collection instances so that modifications
/// to those collections on the clone do not affect the original.
/// Other reference-type properties (for example attachment items) are not deep-cloned;
/// the original and the clone will share those nested objects.
/// </remarks>
public virtual MessageOptions Clone() => new(this);
}

public delegate void SessionEventHandler(SessionEvent sessionEvent);
Expand Down
Loading
Loading