diff --git a/dotnet/src/Generated/Rpc.cs b/dotnet/src/Generated/Rpc.cs index 01911d58..7cc6bdac 100644 --- a/dotnet/src/Generated/Rpc.cs +++ b/dotnet/src/Generated/Rpc.cs @@ -5,245 +5,281 @@ // AUTO-GENERATED FILE - DO NOT EDIT // Generated from: api.schema.json -// Generated code does not have XML doc comments; suppress CS1591 to avoid warnings. -#pragma warning disable CS1591 - using System.Text.Json; using System.Text.Json.Serialization; using StreamJsonRpc; namespace GitHub.Copilot.SDK.Rpc; +/// RPC data type for Ping operations. public class PingResult { - /// Echoed message (or default greeting) + /// Echoed message (or default greeting). [JsonPropertyName("message")] public string Message { get; set; } = string.Empty; - /// Server timestamp in milliseconds + /// Server timestamp in milliseconds. [JsonPropertyName("timestamp")] public double Timestamp { get; set; } - /// Server protocol version number + /// Server protocol version number. [JsonPropertyName("protocolVersion")] public double ProtocolVersion { get; set; } } +/// RPC data type for Ping operations. internal class PingRequest { + /// Optional message to echo back. [JsonPropertyName("message")] public string? Message { get; set; } } +/// RPC data type for ModelCapabilitiesSupports operations. public class ModelCapabilitiesSupports { + /// Gets or sets the vision value. [JsonPropertyName("vision")] public bool? Vision { get; set; } - /// Whether this model supports reasoning effort configuration + /// Whether this model supports reasoning effort configuration. [JsonPropertyName("reasoningEffort")] public bool? ReasoningEffort { get; set; } } +/// RPC data type for ModelCapabilitiesLimits operations. public class ModelCapabilitiesLimits { + /// Gets or sets the max_prompt_tokens value. [JsonPropertyName("max_prompt_tokens")] public double? MaxPromptTokens { get; set; } + /// Gets or sets the max_output_tokens value. [JsonPropertyName("max_output_tokens")] public double? MaxOutputTokens { get; set; } + /// Gets or sets the max_context_window_tokens value. [JsonPropertyName("max_context_window_tokens")] public double MaxContextWindowTokens { get; set; } } -/// Model capabilities and limits +/// Model capabilities and limits. public class ModelCapabilities { + /// Gets or sets the supports value. [JsonPropertyName("supports")] public ModelCapabilitiesSupports Supports { get; set; } = new(); + /// Gets or sets the limits value. [JsonPropertyName("limits")] public ModelCapabilitiesLimits Limits { get; set; } = new(); } -/// Policy state (if applicable) +/// Policy state (if applicable). public class ModelPolicy { + /// Gets or sets the state value. [JsonPropertyName("state")] public string State { get; set; } = string.Empty; + /// Gets or sets the terms value. [JsonPropertyName("terms")] public string Terms { get; set; } = string.Empty; } -/// Billing information +/// Billing information. public class ModelBilling { + /// Gets or sets the multiplier value. [JsonPropertyName("multiplier")] public double Multiplier { get; set; } } +/// RPC data type for Model operations. public class Model { - /// Model identifier (e.g., "claude-sonnet-4.5") + /// Model identifier (e.g., "claude-sonnet-4.5"). [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; - /// Display name + /// Display name. [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; - /// Model capabilities and limits + /// Model capabilities and limits. [JsonPropertyName("capabilities")] public ModelCapabilities Capabilities { get; set; } = new(); - /// Policy state (if applicable) + /// Policy state (if applicable). [JsonPropertyName("policy")] public ModelPolicy? Policy { get; set; } - /// Billing information + /// Billing information. [JsonPropertyName("billing")] public ModelBilling? Billing { get; set; } - /// Supported reasoning effort levels (only present if model supports reasoning effort) + /// Supported reasoning effort levels (only present if model supports reasoning effort). [JsonPropertyName("supportedReasoningEfforts")] public List? SupportedReasoningEfforts { get; set; } - /// Default reasoning effort level (only present if model supports reasoning effort) + /// Default reasoning effort level (only present if model supports reasoning effort). [JsonPropertyName("defaultReasoningEffort")] public string? DefaultReasoningEffort { get; set; } } +/// RPC data type for ModelsList operations. public class ModelsListResult { - /// List of available models with full metadata + /// List of available models with full metadata. [JsonPropertyName("models")] public List Models { get; set; } = []; } +/// RPC data type for Tool operations. public class Tool { - /// Tool identifier (e.g., "bash", "grep", "str_replace_editor") + /// Tool identifier (e.g., "bash", "grep", "str_replace_editor"). [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; - /// Optional namespaced name for declarative filtering (e.g., "playwright/navigate" for MCP tools) + /// Optional namespaced name for declarative filtering (e.g., "playwright/navigate" for MCP tools). [JsonPropertyName("namespacedName")] public string? NamespacedName { get; set; } - /// Description of what the tool does + /// Description of what the tool does. [JsonPropertyName("description")] public string Description { get; set; } = string.Empty; - /// JSON Schema for the tool's input parameters + /// JSON Schema for the tool's input parameters. [JsonPropertyName("parameters")] public Dictionary? Parameters { get; set; } - /// Optional instructions for how to use this tool effectively + /// Optional instructions for how to use this tool effectively. [JsonPropertyName("instructions")] public string? Instructions { get; set; } } +/// RPC data type for ToolsList operations. public class ToolsListResult { - /// List of available built-in tools with metadata + /// List of available built-in tools with metadata. [JsonPropertyName("tools")] public List Tools { get; set; } = []; } +/// RPC data type for ToolsList operations. internal class ToolsListRequest { + /// Optional model ID — when provided, the returned tool list reflects model-specific overrides. [JsonPropertyName("model")] public string? Model { get; set; } } +/// RPC data type for AccountGetQuotaResultQuotaSnapshotsValue operations. public class AccountGetQuotaResultQuotaSnapshotsValue { - /// Number of requests included in the entitlement + /// Number of requests included in the entitlement. [JsonPropertyName("entitlementRequests")] public double EntitlementRequests { get; set; } - /// Number of requests used so far this period + /// Number of requests used so far this period. [JsonPropertyName("usedRequests")] public double UsedRequests { get; set; } - /// Percentage of entitlement remaining + /// Percentage of entitlement remaining. [JsonPropertyName("remainingPercentage")] public double RemainingPercentage { get; set; } - /// Number of overage requests made this period + /// Number of overage requests made this period. [JsonPropertyName("overage")] public double Overage { get; set; } - /// Whether pay-per-request usage is allowed when quota is exhausted + /// Whether pay-per-request usage is allowed when quota is exhausted. [JsonPropertyName("overageAllowedWithExhaustedQuota")] public bool OverageAllowedWithExhaustedQuota { get; set; } - /// Date when the quota resets (ISO 8601) + /// Date when the quota resets (ISO 8601). [JsonPropertyName("resetDate")] public string? ResetDate { get; set; } } +/// RPC data type for AccountGetQuota operations. public class AccountGetQuotaResult { - /// Quota snapshots keyed by type (e.g., chat, completions, premium_interactions) + /// Quota snapshots keyed by type (e.g., chat, completions, premium_interactions). [JsonPropertyName("quotaSnapshots")] public Dictionary QuotaSnapshots { get; set; } = []; } +/// RPC data type for SessionLog operations. public class SessionLogResult { - /// The unique identifier of the emitted session event + /// The unique identifier of the emitted session event. [JsonPropertyName("eventId")] public Guid EventId { get; set; } } +/// RPC data type for SessionLog operations. internal class SessionLogRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// Human-readable message. [JsonPropertyName("message")] public string Message { get; set; } = string.Empty; + /// Log severity level. Determines how the message is displayed in the timeline. Defaults to "info". [JsonPropertyName("level")] public SessionLogRequestLevel? Level { get; set; } + /// When true, the message is transient and not persisted to the session event log on disk. [JsonPropertyName("ephemeral")] public bool? Ephemeral { get; set; } } +/// RPC data type for SessionModelGetCurrent operations. public class SessionModelGetCurrentResult { + /// Gets or sets the modelId value. [JsonPropertyName("modelId")] public string? ModelId { get; set; } } +/// RPC data type for SessionModelGetCurrent operations. internal class SessionModelGetCurrentRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } +/// RPC data type for SessionModelSwitchTo operations. public class SessionModelSwitchToResult { + /// Gets or sets the modelId value. [JsonPropertyName("modelId")] public string? ModelId { get; set; } } +/// RPC data type for SessionModelSwitchTo operations. internal class SessionModelSwitchToRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// Gets or sets the modelId value. [JsonPropertyName("modelId")] public string ModelId { get; set; } = string.Empty; + /// Gets or sets the reasoningEffort value. [JsonPropertyName("reasoningEffort")] public SessionModelSwitchToRequestReasoningEffort? ReasoningEffort { get; set; } } +/// RPC data type for SessionModeGet operations. public class SessionModeGetResult { /// The current agent mode. @@ -251,12 +287,15 @@ public class SessionModeGetResult public SessionModeGetResultMode Mode { get; set; } } +/// RPC data type for SessionModeGet operations. internal class SessionModeGetRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } +/// RPC data type for SessionModeSet operations. public class SessionModeSetResult { /// The agent mode after switching. @@ -264,317 +303,390 @@ public class SessionModeSetResult public SessionModeGetResultMode Mode { get; set; } } +/// RPC data type for SessionModeSet operations. internal class SessionModeSetRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// The mode to switch to. Valid values: "interactive", "plan", "autopilot". [JsonPropertyName("mode")] public SessionModeGetResultMode Mode { get; set; } } +/// RPC data type for SessionPlanRead operations. public class SessionPlanReadResult { - /// Whether the plan file exists in the workspace + /// Whether the plan file exists in the workspace. [JsonPropertyName("exists")] public bool Exists { get; set; } - /// The content of the plan file, or null if it does not exist + /// The content of the plan file, or null if it does not exist. [JsonPropertyName("content")] public string? Content { get; set; } - /// Absolute file path of the plan file, or null if workspace is not enabled + /// Absolute file path of the plan file, or null if workspace is not enabled. [JsonPropertyName("path")] public string? Path { get; set; } } +/// RPC data type for SessionPlanRead operations. internal class SessionPlanReadRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } +/// RPC data type for SessionPlanUpdate operations. public class SessionPlanUpdateResult { } +/// RPC data type for SessionPlanUpdate operations. internal class SessionPlanUpdateRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// The new content for the plan file. [JsonPropertyName("content")] public string Content { get; set; } = string.Empty; } +/// RPC data type for SessionPlanDelete operations. public class SessionPlanDeleteResult { } +/// RPC data type for SessionPlanDelete operations. internal class SessionPlanDeleteRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } +/// RPC data type for SessionWorkspaceListFiles operations. public class SessionWorkspaceListFilesResult { - /// Relative file paths in the workspace files directory + /// Relative file paths in the workspace files directory. [JsonPropertyName("files")] public List Files { get; set; } = []; } +/// RPC data type for SessionWorkspaceListFiles operations. internal class SessionWorkspaceListFilesRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } +/// RPC data type for SessionWorkspaceReadFile operations. public class SessionWorkspaceReadFileResult { - /// File content as a UTF-8 string + /// File content as a UTF-8 string. [JsonPropertyName("content")] public string Content { get; set; } = string.Empty; } +/// RPC data type for SessionWorkspaceReadFile operations. internal class SessionWorkspaceReadFileRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// Relative path within the workspace files directory. [JsonPropertyName("path")] public string Path { get; set; } = string.Empty; } +/// RPC data type for SessionWorkspaceCreateFile operations. public class SessionWorkspaceCreateFileResult { } +/// RPC data type for SessionWorkspaceCreateFile operations. internal class SessionWorkspaceCreateFileRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// Relative path within the workspace files directory. [JsonPropertyName("path")] public string Path { get; set; } = string.Empty; + /// File content to write as a UTF-8 string. [JsonPropertyName("content")] public string Content { get; set; } = string.Empty; } +/// RPC data type for SessionFleetStart operations. public class SessionFleetStartResult { - /// Whether fleet mode was successfully activated + /// Whether fleet mode was successfully activated. [JsonPropertyName("started")] public bool Started { get; set; } } +/// RPC data type for SessionFleetStart operations. internal class SessionFleetStartRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// Optional user prompt to combine with fleet instructions. [JsonPropertyName("prompt")] public string? Prompt { get; set; } } +/// RPC data type for Agent operations. public class Agent { - /// Unique identifier of the custom agent + /// Unique identifier of the custom agent. [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; - /// Human-readable display name + /// Human-readable display name. [JsonPropertyName("displayName")] public string DisplayName { get; set; } = string.Empty; - /// Description of the agent's purpose + /// Description of the agent's purpose. [JsonPropertyName("description")] public string Description { get; set; } = string.Empty; } +/// RPC data type for SessionAgentList operations. public class SessionAgentListResult { - /// Available custom agents + /// Available custom agents. [JsonPropertyName("agents")] public List Agents { get; set; } = []; } +/// RPC data type for SessionAgentList operations. internal class SessionAgentListRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } +/// RPC data type for SessionAgentGetCurrentResultAgent operations. public class SessionAgentGetCurrentResultAgent { - /// Unique identifier of the custom agent + /// Unique identifier of the custom agent. [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; - /// Human-readable display name + /// Human-readable display name. [JsonPropertyName("displayName")] public string DisplayName { get; set; } = string.Empty; - /// Description of the agent's purpose + /// Description of the agent's purpose. [JsonPropertyName("description")] public string Description { get; set; } = string.Empty; } +/// RPC data type for SessionAgentGetCurrent operations. public class SessionAgentGetCurrentResult { - /// Currently selected custom agent, or null if using the default agent + /// Currently selected custom agent, or null if using the default agent. [JsonPropertyName("agent")] public SessionAgentGetCurrentResultAgent? Agent { get; set; } } +/// RPC data type for SessionAgentGetCurrent operations. internal class SessionAgentGetCurrentRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } -/// The newly selected custom agent +/// The newly selected custom agent. public class SessionAgentSelectResultAgent { - /// Unique identifier of the custom agent + /// Unique identifier of the custom agent. [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; - /// Human-readable display name + /// Human-readable display name. [JsonPropertyName("displayName")] public string DisplayName { get; set; } = string.Empty; - /// Description of the agent's purpose + /// Description of the agent's purpose. [JsonPropertyName("description")] public string Description { get; set; } = string.Empty; } +/// RPC data type for SessionAgentSelect operations. public class SessionAgentSelectResult { - /// The newly selected custom agent + /// The newly selected custom agent. [JsonPropertyName("agent")] public SessionAgentSelectResultAgent Agent { get; set; } = new(); } +/// RPC data type for SessionAgentSelect operations. internal class SessionAgentSelectRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// Name of the custom agent to select. [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; } +/// RPC data type for SessionAgentDeselect operations. public class SessionAgentDeselectResult { } +/// RPC data type for SessionAgentDeselect operations. internal class SessionAgentDeselectRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } +/// RPC data type for SessionCompactionCompact operations. public class SessionCompactionCompactResult { - /// Whether compaction completed successfully + /// Whether compaction completed successfully. [JsonPropertyName("success")] public bool Success { get; set; } - /// Number of tokens freed by compaction + /// Number of tokens freed by compaction. [JsonPropertyName("tokensRemoved")] public double TokensRemoved { get; set; } - /// Number of messages removed during compaction + /// Number of messages removed during compaction. [JsonPropertyName("messagesRemoved")] public double MessagesRemoved { get; set; } } +/// RPC data type for SessionCompactionCompact operations. internal class SessionCompactionCompactRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; } +/// RPC data type for SessionToolsHandlePendingToolCall operations. public class SessionToolsHandlePendingToolCallResult { + /// Gets or sets the success value. [JsonPropertyName("success")] public bool Success { get; set; } } +/// RPC data type for SessionToolsHandlePendingToolCall operations. internal class SessionToolsHandlePendingToolCallRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// Gets or sets the requestId value. [JsonPropertyName("requestId")] public string RequestId { get; set; } = string.Empty; + /// Gets or sets the result value. [JsonPropertyName("result")] public object? Result { get; set; } + /// Gets or sets the error value. [JsonPropertyName("error")] public string? Error { get; set; } } +/// RPC data type for SessionPermissionsHandlePendingPermissionRequest operations. public class SessionPermissionsHandlePendingPermissionRequestResult { + /// Gets or sets the success value. [JsonPropertyName("success")] public bool Success { get; set; } } +/// RPC data type for SessionPermissionsHandlePendingPermissionRequest operations. internal class SessionPermissionsHandlePendingPermissionRequestRequest { + /// Target session identifier. [JsonPropertyName("sessionId")] public string SessionId { get; set; } = string.Empty; + /// Gets or sets the requestId value. [JsonPropertyName("requestId")] public string RequestId { get; set; } = string.Empty; + /// Gets or sets the result value. [JsonPropertyName("result")] public object Result { get; set; } = null!; } +/// Log severity level. Determines how the message is displayed in the timeline. Defaults to "info". [JsonConverter(typeof(JsonStringEnumConverter))] public enum SessionLogRequestLevel { + /// The info variant. [JsonStringEnumMemberName("info")] Info, + /// The warning variant. [JsonStringEnumMemberName("warning")] Warning, + /// The error variant. [JsonStringEnumMemberName("error")] Error, } +/// Defines the allowed values. [JsonConverter(typeof(JsonStringEnumConverter))] public enum SessionModelSwitchToRequestReasoningEffort { + /// The low variant. [JsonStringEnumMemberName("low")] Low, + /// The medium variant. [JsonStringEnumMemberName("medium")] Medium, + /// The high variant. [JsonStringEnumMemberName("high")] High, + /// The xhigh variant. [JsonStringEnumMemberName("xhigh")] Xhigh, } +/// The current agent mode. [JsonConverter(typeof(JsonStringEnumConverter))] public enum SessionModeGetResultMode { + /// The interactive variant. [JsonStringEnumMemberName("interactive")] Interactive, + /// The plan variant. [JsonStringEnumMemberName("plan")] Plan, + /// The autopilot variant. [JsonStringEnumMemberName("autopilot")] Autopilot, } -/// Typed server-scoped RPC methods (no session required). +/// Provides server-scoped RPC methods (no session required). public class ServerRpc { private readonly JsonRpc _rpc; @@ -604,7 +716,7 @@ public async Task PingAsync(string? message = null, CancellationToke public ServerAccountApi Account { get; } } -/// Server-scoped Models APIs. +/// Provides server-scoped Models APIs. public class ServerModelsApi { private readonly JsonRpc _rpc; @@ -621,7 +733,7 @@ public async Task ListAsync(CancellationToken cancellationToke } } -/// Server-scoped Tools APIs. +/// Provides server-scoped Tools APIs. public class ServerToolsApi { private readonly JsonRpc _rpc; @@ -639,7 +751,7 @@ public async Task ListAsync(string? model = null, CancellationT } } -/// Server-scoped Account APIs. +/// Provides server-scoped Account APIs. public class ServerAccountApi { private readonly JsonRpc _rpc; @@ -656,7 +768,7 @@ public async Task GetQuotaAsync(CancellationToken cancell } } -/// Typed session-scoped RPC methods. +/// Provides typed session-scoped RPC methods. public class SessionRpc { private readonly JsonRpc _rpc; @@ -677,22 +789,31 @@ internal SessionRpc(JsonRpc rpc, string sessionId) Permissions = new PermissionsApi(rpc, sessionId); } + /// Model APIs. public ModelApi Model { get; } + /// Mode APIs. public ModeApi Mode { get; } + /// Plan APIs. public PlanApi Plan { get; } + /// Workspace APIs. public WorkspaceApi Workspace { get; } + /// Fleet APIs. public FleetApi Fleet { get; } + /// Agent APIs. public AgentApi Agent { get; } + /// Compaction APIs. public CompactionApi Compaction { get; } + /// Tools APIs. public ToolsApi Tools { get; } + /// Permissions APIs. public PermissionsApi Permissions { get; } /// Calls "session.log". @@ -703,6 +824,7 @@ public async Task LogAsync(string message, SessionLogRequestLe } } +/// Provides session-scoped Model APIs. public class ModelApi { private readonly JsonRpc _rpc; @@ -729,6 +851,7 @@ public async Task SwitchToAsync(string modelId, Sess } } +/// Provides session-scoped Mode APIs. public class ModeApi { private readonly JsonRpc _rpc; @@ -755,6 +878,7 @@ public async Task SetAsync(SessionModeGetResultMode mode, } } +/// Provides session-scoped Plan APIs. public class PlanApi { private readonly JsonRpc _rpc; @@ -788,6 +912,7 @@ public async Task DeleteAsync(CancellationToken cancell } } +/// Provides session-scoped Workspace APIs. public class WorkspaceApi { private readonly JsonRpc _rpc; @@ -821,6 +946,7 @@ public async Task CreateFileAsync(string path, } } +/// Provides session-scoped Fleet APIs. public class FleetApi { private readonly JsonRpc _rpc; @@ -840,6 +966,7 @@ public async Task StartAsync(string? prompt = null, Can } } +/// Provides session-scoped Agent APIs. public class AgentApi { private readonly JsonRpc _rpc; @@ -880,6 +1007,7 @@ public async Task DeselectAsync(CancellationToken ca } } +/// Provides session-scoped Compaction APIs. public class CompactionApi { private readonly JsonRpc _rpc; @@ -899,6 +1027,7 @@ public async Task CompactAsync(CancellationToken } } +/// Provides session-scoped Tools APIs. public class ToolsApi { private readonly JsonRpc _rpc; @@ -918,6 +1047,7 @@ public async Task HandlePendingToolCall } } +/// Provides session-scoped Permissions APIs. public class PermissionsApi { private readonly JsonRpc _rpc; diff --git a/dotnet/src/Generated/SessionEvents.cs b/dotnet/src/Generated/SessionEvents.cs index 5bdf50df..6648bd18 100644 --- a/dotnet/src/Generated/SessionEvents.cs +++ b/dotnet/src/Generated/SessionEvents.cs @@ -5,16 +5,13 @@ // AUTO-GENERATED FILE - DO NOT EDIT // Generated from: session-events.schema.json -// Generated code does not have XML doc comments; suppress CS1591 to avoid warnings. -#pragma warning disable CS1591 - using System.Text.Json; using System.Text.Json.Serialization; namespace GitHub.Copilot.SDK; /// -/// Base class for all session events with polymorphic JSON serialization. +/// Provides the base class from which all session events derive. /// [JsonPolymorphic( TypeDiscriminatorPropertyName = "type", @@ -80,15 +77,19 @@ namespace GitHub.Copilot.SDK; [JsonDerivedType(typeof(UserMessageEvent), "user.message")] public abstract partial class SessionEvent { + /// Unique event identifier (UUID v4), generated when the event is emitted. [JsonPropertyName("id")] public Guid Id { get; set; } + /// ISO 8601 timestamp when the event was created. [JsonPropertyName("timestamp")] public DateTimeOffset Timestamp { get; set; } + /// ID of the chronologically preceding event in the session, forming a linked chain. Null for the first event. [JsonPropertyName("parentId")] public Guid? ParentId { get; set; } + /// When true, the event is transient and not persisted to the session event log on disk. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("ephemeral")] public bool? Ephemeral { get; set; } @@ -99,1807 +100,2153 @@ public abstract partial class SessionEvent [JsonIgnore] public abstract string Type { get; } + /// Deserializes a JSON string into a . public static SessionEvent FromJson(string json) => JsonSerializer.Deserialize(json, SessionEventsJsonContext.Default.SessionEvent)!; + /// Serializes this event to a JSON string. public string ToJson() => JsonSerializer.Serialize(this, SessionEventsJsonContext.Default.SessionEvent); } -/// -/// Event: session.start -/// +/// Represents the session.start event. public partial class SessionStartEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.start"; + /// The session.start event payload. [JsonPropertyName("data")] public required SessionStartData Data { get; set; } } -/// -/// Event: session.resume -/// +/// Represents the session.resume event. public partial class SessionResumeEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.resume"; + /// The session.resume event payload. [JsonPropertyName("data")] public required SessionResumeData Data { get; set; } } -/// -/// Event: session.error -/// +/// Represents the session.error event. public partial class SessionErrorEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.error"; + /// The session.error event payload. [JsonPropertyName("data")] public required SessionErrorData Data { get; set; } } -/// -/// Event: session.idle -/// +/// Payload indicating the agent is idle; includes any background tasks still in flight. +/// Represents the session.idle event. public partial class SessionIdleEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.idle"; + /// The session.idle event payload. [JsonPropertyName("data")] public required SessionIdleData Data { get; set; } } -/// -/// Event: session.title_changed -/// +/// Represents the session.title_changed event. public partial class SessionTitleChangedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.title_changed"; + /// The session.title_changed event payload. [JsonPropertyName("data")] public required SessionTitleChangedData Data { get; set; } } -/// -/// Event: session.info -/// +/// Represents the session.info event. public partial class SessionInfoEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.info"; + /// The session.info event payload. [JsonPropertyName("data")] public required SessionInfoData Data { get; set; } } -/// -/// Event: session.warning -/// +/// Represents the session.warning event. public partial class SessionWarningEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.warning"; + /// The session.warning event payload. [JsonPropertyName("data")] public required SessionWarningData Data { get; set; } } -/// -/// Event: session.model_change -/// +/// Represents the session.model_change event. public partial class SessionModelChangeEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.model_change"; + /// The session.model_change event payload. [JsonPropertyName("data")] public required SessionModelChangeData Data { get; set; } } -/// -/// Event: session.mode_changed -/// +/// Represents the session.mode_changed event. public partial class SessionModeChangedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.mode_changed"; + /// The session.mode_changed event payload. [JsonPropertyName("data")] public required SessionModeChangedData Data { get; set; } } -/// -/// Event: session.plan_changed -/// +/// Represents the session.plan_changed event. public partial class SessionPlanChangedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.plan_changed"; + /// The session.plan_changed event payload. [JsonPropertyName("data")] public required SessionPlanChangedData Data { get; set; } } -/// -/// Event: session.workspace_file_changed -/// +/// Represents the session.workspace_file_changed event. public partial class SessionWorkspaceFileChangedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.workspace_file_changed"; + /// The session.workspace_file_changed event payload. [JsonPropertyName("data")] public required SessionWorkspaceFileChangedData Data { get; set; } } -/// -/// Event: session.handoff -/// +/// Represents the session.handoff event. public partial class SessionHandoffEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.handoff"; + /// The session.handoff event payload. [JsonPropertyName("data")] public required SessionHandoffData Data { get; set; } } -/// -/// Event: session.truncation -/// +/// Represents the session.truncation event. public partial class SessionTruncationEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.truncation"; + /// The session.truncation event payload. [JsonPropertyName("data")] public required SessionTruncationData Data { get; set; } } -/// -/// Event: session.snapshot_rewind -/// +/// Represents the session.snapshot_rewind event. public partial class SessionSnapshotRewindEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.snapshot_rewind"; + /// The session.snapshot_rewind event payload. [JsonPropertyName("data")] public required SessionSnapshotRewindData Data { get; set; } } -/// -/// Event: session.shutdown -/// +/// Represents the session.shutdown event. public partial class SessionShutdownEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.shutdown"; + /// The session.shutdown event payload. [JsonPropertyName("data")] public required SessionShutdownData Data { get; set; } } -/// -/// Event: session.context_changed -/// +/// Represents the session.context_changed event. public partial class SessionContextChangedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.context_changed"; + /// The session.context_changed event payload. [JsonPropertyName("data")] public required SessionContextChangedData Data { get; set; } } -/// -/// Event: session.usage_info -/// +/// Represents the session.usage_info event. public partial class SessionUsageInfoEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.usage_info"; + /// The session.usage_info event payload. [JsonPropertyName("data")] public required SessionUsageInfoData Data { get; set; } } -/// -/// Event: session.compaction_start -/// +/// Empty payload; the event signals that LLM-powered conversation compaction has begun. +/// Represents the session.compaction_start event. public partial class SessionCompactionStartEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.compaction_start"; + /// The session.compaction_start event payload. [JsonPropertyName("data")] public required SessionCompactionStartData Data { get; set; } } -/// -/// Event: session.compaction_complete -/// +/// Represents the session.compaction_complete event. public partial class SessionCompactionCompleteEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.compaction_complete"; + /// The session.compaction_complete event payload. [JsonPropertyName("data")] public required SessionCompactionCompleteData Data { get; set; } } -/// -/// Event: session.task_complete -/// +/// Represents the session.task_complete event. public partial class SessionTaskCompleteEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "session.task_complete"; + /// The session.task_complete event payload. [JsonPropertyName("data")] public required SessionTaskCompleteData Data { get; set; } } -/// -/// Event: user.message -/// +/// Represents the user.message event. public partial class UserMessageEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "user.message"; + /// The user.message event payload. [JsonPropertyName("data")] public required UserMessageData Data { get; set; } } -/// -/// Event: pending_messages.modified -/// +/// Empty payload; the event signals that the pending message queue has changed. +/// Represents the pending_messages.modified event. public partial class PendingMessagesModifiedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "pending_messages.modified"; + /// The pending_messages.modified event payload. [JsonPropertyName("data")] public required PendingMessagesModifiedData Data { get; set; } } -/// -/// Event: assistant.turn_start -/// +/// Represents the assistant.turn_start event. public partial class AssistantTurnStartEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.turn_start"; + /// The assistant.turn_start event payload. [JsonPropertyName("data")] public required AssistantTurnStartData Data { get; set; } } -/// -/// Event: assistant.intent -/// +/// Represents the assistant.intent event. public partial class AssistantIntentEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.intent"; + /// The assistant.intent event payload. [JsonPropertyName("data")] public required AssistantIntentData Data { get; set; } } -/// -/// Event: assistant.reasoning -/// +/// Represents the assistant.reasoning event. public partial class AssistantReasoningEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.reasoning"; + /// The assistant.reasoning event payload. [JsonPropertyName("data")] public required AssistantReasoningData Data { get; set; } } -/// -/// Event: assistant.reasoning_delta -/// +/// Represents the assistant.reasoning_delta event. public partial class AssistantReasoningDeltaEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.reasoning_delta"; + /// The assistant.reasoning_delta event payload. [JsonPropertyName("data")] public required AssistantReasoningDeltaData Data { get; set; } } -/// -/// Event: assistant.streaming_delta -/// +/// Represents the assistant.streaming_delta event. public partial class AssistantStreamingDeltaEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.streaming_delta"; + /// The assistant.streaming_delta event payload. [JsonPropertyName("data")] public required AssistantStreamingDeltaData Data { get; set; } } -/// -/// Event: assistant.message -/// +/// Represents the assistant.message event. public partial class AssistantMessageEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.message"; + /// The assistant.message event payload. [JsonPropertyName("data")] public required AssistantMessageData Data { get; set; } } -/// -/// Event: assistant.message_delta -/// +/// Represents the assistant.message_delta event. public partial class AssistantMessageDeltaEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.message_delta"; + /// The assistant.message_delta event payload. [JsonPropertyName("data")] public required AssistantMessageDeltaData Data { get; set; } } -/// -/// Event: assistant.turn_end -/// +/// Represents the assistant.turn_end event. public partial class AssistantTurnEndEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.turn_end"; + /// The assistant.turn_end event payload. [JsonPropertyName("data")] public required AssistantTurnEndData Data { get; set; } } -/// -/// Event: assistant.usage -/// +/// Represents the assistant.usage event. public partial class AssistantUsageEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "assistant.usage"; + /// The assistant.usage event payload. [JsonPropertyName("data")] public required AssistantUsageData Data { get; set; } } -/// -/// Event: abort -/// +/// Represents the abort event. public partial class AbortEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "abort"; + /// The abort event payload. [JsonPropertyName("data")] public required AbortData Data { get; set; } } -/// -/// Event: tool.user_requested -/// +/// Represents the tool.user_requested event. public partial class ToolUserRequestedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "tool.user_requested"; + /// The tool.user_requested event payload. [JsonPropertyName("data")] public required ToolUserRequestedData Data { get; set; } } -/// -/// Event: tool.execution_start -/// +/// Represents the tool.execution_start event. public partial class ToolExecutionStartEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "tool.execution_start"; + /// The tool.execution_start event payload. [JsonPropertyName("data")] public required ToolExecutionStartData Data { get; set; } } -/// -/// Event: tool.execution_partial_result -/// +/// Represents the tool.execution_partial_result event. public partial class ToolExecutionPartialResultEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "tool.execution_partial_result"; + /// The tool.execution_partial_result event payload. [JsonPropertyName("data")] public required ToolExecutionPartialResultData Data { get; set; } } -/// -/// Event: tool.execution_progress -/// +/// Represents the tool.execution_progress event. public partial class ToolExecutionProgressEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "tool.execution_progress"; + /// The tool.execution_progress event payload. [JsonPropertyName("data")] public required ToolExecutionProgressData Data { get; set; } } -/// -/// Event: tool.execution_complete -/// +/// Represents the tool.execution_complete event. public partial class ToolExecutionCompleteEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "tool.execution_complete"; + /// The tool.execution_complete event payload. [JsonPropertyName("data")] public required ToolExecutionCompleteData Data { get; set; } } -/// -/// Event: skill.invoked -/// +/// Represents the skill.invoked event. public partial class SkillInvokedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "skill.invoked"; + /// The skill.invoked event payload. [JsonPropertyName("data")] public required SkillInvokedData Data { get; set; } } -/// -/// Event: subagent.started -/// +/// Represents the subagent.started event. public partial class SubagentStartedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "subagent.started"; + /// The subagent.started event payload. [JsonPropertyName("data")] public required SubagentStartedData Data { get; set; } } -/// -/// Event: subagent.completed -/// +/// Represents the subagent.completed event. public partial class SubagentCompletedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "subagent.completed"; + /// The subagent.completed event payload. [JsonPropertyName("data")] public required SubagentCompletedData Data { get; set; } } -/// -/// Event: subagent.failed -/// +/// Represents the subagent.failed event. public partial class SubagentFailedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "subagent.failed"; + /// The subagent.failed event payload. [JsonPropertyName("data")] public required SubagentFailedData Data { get; set; } } -/// -/// Event: subagent.selected -/// +/// Represents the subagent.selected event. public partial class SubagentSelectedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "subagent.selected"; + /// The subagent.selected event payload. [JsonPropertyName("data")] public required SubagentSelectedData Data { get; set; } } -/// -/// Event: subagent.deselected -/// +/// Empty payload; the event signals that the custom agent was deselected, returning to the default agent. +/// Represents the subagent.deselected event. public partial class SubagentDeselectedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "subagent.deselected"; + /// The subagent.deselected event payload. [JsonPropertyName("data")] public required SubagentDeselectedData Data { get; set; } } -/// -/// Event: hook.start -/// +/// Represents the hook.start event. public partial class HookStartEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "hook.start"; + /// The hook.start event payload. [JsonPropertyName("data")] public required HookStartData Data { get; set; } } -/// -/// Event: hook.end -/// +/// Represents the hook.end event. public partial class HookEndEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "hook.end"; + /// The hook.end event payload. [JsonPropertyName("data")] public required HookEndData Data { get; set; } } -/// -/// Event: system.message -/// +/// Represents the system.message event. public partial class SystemMessageEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "system.message"; + /// The system.message event payload. [JsonPropertyName("data")] public required SystemMessageData Data { get; set; } } -/// -/// Event: system.notification -/// +/// Represents the system.notification event. public partial class SystemNotificationEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "system.notification"; + /// The system.notification event payload. [JsonPropertyName("data")] public required SystemNotificationData Data { get; set; } } -/// -/// Event: permission.requested -/// +/// Represents the permission.requested event. public partial class PermissionRequestedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "permission.requested"; + /// The permission.requested event payload. [JsonPropertyName("data")] public required PermissionRequestedData Data { get; set; } } -/// -/// Event: permission.completed -/// +/// Represents the permission.completed event. public partial class PermissionCompletedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "permission.completed"; + /// The permission.completed event payload. [JsonPropertyName("data")] public required PermissionCompletedData Data { get; set; } } -/// -/// Event: user_input.requested -/// +/// Represents the user_input.requested event. public partial class UserInputRequestedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "user_input.requested"; + /// The user_input.requested event payload. [JsonPropertyName("data")] public required UserInputRequestedData Data { get; set; } } -/// -/// Event: user_input.completed -/// +/// Represents the user_input.completed event. public partial class UserInputCompletedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "user_input.completed"; + /// The user_input.completed event payload. [JsonPropertyName("data")] public required UserInputCompletedData Data { get; set; } } -/// -/// Event: elicitation.requested -/// +/// Represents the elicitation.requested event. public partial class ElicitationRequestedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "elicitation.requested"; + /// The elicitation.requested event payload. [JsonPropertyName("data")] public required ElicitationRequestedData Data { get; set; } } -/// -/// Event: elicitation.completed -/// +/// Represents the elicitation.completed event. public partial class ElicitationCompletedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "elicitation.completed"; + /// The elicitation.completed event payload. [JsonPropertyName("data")] public required ElicitationCompletedData Data { get; set; } } -/// -/// Event: external_tool.requested -/// +/// Represents the external_tool.requested event. public partial class ExternalToolRequestedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "external_tool.requested"; + /// The external_tool.requested event payload. [JsonPropertyName("data")] public required ExternalToolRequestedData Data { get; set; } } -/// -/// Event: external_tool.completed -/// +/// Represents the external_tool.completed event. public partial class ExternalToolCompletedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "external_tool.completed"; + /// The external_tool.completed event payload. [JsonPropertyName("data")] public required ExternalToolCompletedData Data { get; set; } } -/// -/// Event: command.queued -/// +/// Represents the command.queued event. public partial class CommandQueuedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "command.queued"; + /// The command.queued event payload. [JsonPropertyName("data")] public required CommandQueuedData Data { get; set; } } -/// -/// Event: command.completed -/// +/// Represents the command.completed event. public partial class CommandCompletedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "command.completed"; + /// The command.completed event payload. [JsonPropertyName("data")] public required CommandCompletedData Data { get; set; } } -/// -/// Event: exit_plan_mode.requested -/// +/// Represents the exit_plan_mode.requested event. public partial class ExitPlanModeRequestedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "exit_plan_mode.requested"; + /// The exit_plan_mode.requested event payload. [JsonPropertyName("data")] public required ExitPlanModeRequestedData Data { get; set; } } -/// -/// Event: exit_plan_mode.completed -/// +/// Represents the exit_plan_mode.completed event. public partial class ExitPlanModeCompletedEvent : SessionEvent { + /// [JsonIgnore] public override string Type => "exit_plan_mode.completed"; + /// The exit_plan_mode.completed event payload. [JsonPropertyName("data")] public required ExitPlanModeCompletedData Data { get; set; } } +/// Event payload for . public partial class SessionStartData { + /// Unique identifier for the session. [JsonPropertyName("sessionId")] public required string SessionId { get; set; } + /// Schema version number for the session event format. [JsonPropertyName("version")] public required double Version { get; set; } + /// Identifier of the software producing the events (e.g., "copilot-agent"). [JsonPropertyName("producer")] public required string Producer { get; set; } + /// Version string of the Copilot application. [JsonPropertyName("copilotVersion")] public required string CopilotVersion { get; set; } + /// ISO 8601 timestamp when the session was created. [JsonPropertyName("startTime")] public required DateTimeOffset StartTime { get; set; } + /// Model selected at session creation time, if any. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("selectedModel")] public string? SelectedModel { get; set; } + /// Working directory and git context at session start. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("context")] public SessionStartDataContext? Context { get; set; } + /// Gets or sets the alreadyInUse value. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("alreadyInUse")] public bool? AlreadyInUse { get; set; } } +/// Event payload for . public partial class SessionResumeData { + /// ISO 8601 timestamp when the session was resumed. [JsonPropertyName("resumeTime")] public required DateTimeOffset ResumeTime { get; set; } + /// Total number of persisted events in the session at the time of resume. [JsonPropertyName("eventCount")] public required double EventCount { get; set; } + /// Updated working directory and git context at resume time. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("context")] public SessionResumeDataContext? Context { get; set; } + /// Gets or sets the alreadyInUse value. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("alreadyInUse")] public bool? AlreadyInUse { get; set; } } +/// Event payload for . public partial class SessionErrorData { + /// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "query"). [JsonPropertyName("errorType")] public required string ErrorType { get; set; } + /// Human-readable error message. [JsonPropertyName("message")] public required string Message { get; set; } + /// Error stack trace, when available. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("stack")] public string? Stack { get; set; } + /// HTTP status code from the upstream request, if applicable. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("statusCode")] public double? StatusCode { get; set; } + /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("providerCallId")] public string? ProviderCallId { get; set; } } +/// Payload indicating the agent is idle; includes any background tasks still in flight. public partial class SessionIdleData { + /// Background tasks still running when the agent became idle. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("backgroundTasks")] public SessionIdleDataBackgroundTasks? BackgroundTasks { get; set; } } +/// Event payload for . public partial class SessionTitleChangedData { + /// The new display title for the session. [JsonPropertyName("title")] public required string Title { get; set; } } +/// Event payload for . public partial class SessionInfoData { + /// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model"). [JsonPropertyName("infoType")] public required string InfoType { get; set; } + /// Human-readable informational message for display in the timeline. [JsonPropertyName("message")] public required string Message { get; set; } } +/// Event payload for . public partial class SessionWarningData { + /// Category of warning (e.g., "subscription", "policy", "mcp"). [JsonPropertyName("warningType")] public required string WarningType { get; set; } + /// Human-readable warning message for display in the timeline. [JsonPropertyName("message")] public required string Message { get; set; } } +/// Event payload for . public partial class SessionModelChangeData { + /// Model that was previously selected, if any. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("previousModel")] public string? PreviousModel { get; set; } + /// Newly selected model identifier. [JsonPropertyName("newModel")] public required string NewModel { get; set; } } +/// Event payload for . public partial class SessionModeChangedData { + /// Agent mode before the change (e.g., "interactive", "plan", "autopilot"). [JsonPropertyName("previousMode")] public required string PreviousMode { get; set; } + /// Agent mode after the change (e.g., "interactive", "plan", "autopilot"). [JsonPropertyName("newMode")] public required string NewMode { get; set; } } +/// Event payload for . public partial class SessionPlanChangedData { + /// The type of operation performed on the plan file. [JsonPropertyName("operation")] public required SessionPlanChangedDataOperation Operation { get; set; } } +/// Event payload for . public partial class SessionWorkspaceFileChangedData { + /// Relative path within the session workspace files directory. [JsonPropertyName("path")] public required string Path { get; set; } + /// Whether the file was newly created or updated. [JsonPropertyName("operation")] public required SessionWorkspaceFileChangedDataOperation Operation { get; set; } } +/// Event payload for . public partial class SessionHandoffData { + /// ISO 8601 timestamp when the handoff occurred. [JsonPropertyName("handoffTime")] public required DateTimeOffset HandoffTime { get; set; } + /// Origin type of the session being handed off. [JsonPropertyName("sourceType")] public required SessionHandoffDataSourceType SourceType { get; set; } + /// Repository context for the handed-off session. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("repository")] public SessionHandoffDataRepository? Repository { get; set; } + /// Additional context information for the handoff. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("context")] public string? Context { get; set; } + /// Summary of the work done in the source session. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("summary")] public string? Summary { get; set; } + /// Session ID of the remote session being handed off. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("remoteSessionId")] public string? RemoteSessionId { get; set; } } +/// Event payload for . public partial class SessionTruncationData { + /// Maximum token count for the model's context window. [JsonPropertyName("tokenLimit")] public required double TokenLimit { get; set; } + /// Total tokens in conversation messages before truncation. [JsonPropertyName("preTruncationTokensInMessages")] public required double PreTruncationTokensInMessages { get; set; } + /// Number of conversation messages before truncation. [JsonPropertyName("preTruncationMessagesLength")] public required double PreTruncationMessagesLength { get; set; } + /// Total tokens in conversation messages after truncation. [JsonPropertyName("postTruncationTokensInMessages")] public required double PostTruncationTokensInMessages { get; set; } + /// Number of conversation messages after truncation. [JsonPropertyName("postTruncationMessagesLength")] public required double PostTruncationMessagesLength { get; set; } + /// Number of tokens removed by truncation. [JsonPropertyName("tokensRemovedDuringTruncation")] public required double TokensRemovedDuringTruncation { get; set; } + /// Number of messages removed by truncation. [JsonPropertyName("messagesRemovedDuringTruncation")] public required double MessagesRemovedDuringTruncation { get; set; } + /// Identifier of the component that performed truncation (e.g., "BasicTruncator"). [JsonPropertyName("performedBy")] public required string PerformedBy { get; set; } } +/// Event payload for . public partial class SessionSnapshotRewindData { + /// Event ID that was rewound to; all events after this one were removed. [JsonPropertyName("upToEventId")] public required string UpToEventId { get; set; } + /// Number of events that were removed by the rewind. [JsonPropertyName("eventsRemoved")] public required double EventsRemoved { get; set; } } +/// Event payload for . public partial class SessionShutdownData { + /// Whether the session ended normally ("routine") or due to a crash/fatal error ("error"). [JsonPropertyName("shutdownType")] public required SessionShutdownDataShutdownType ShutdownType { get; set; } + /// Error description when shutdownType is "error". [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("errorReason")] public string? ErrorReason { get; set; } + /// Total number of premium API requests used during the session. [JsonPropertyName("totalPremiumRequests")] public required double TotalPremiumRequests { get; set; } + /// Cumulative time spent in API calls during the session, in milliseconds. [JsonPropertyName("totalApiDurationMs")] public required double TotalApiDurationMs { get; set; } + /// Unix timestamp (milliseconds) when the session started. [JsonPropertyName("sessionStartTime")] public required double SessionStartTime { get; set; } + /// Aggregate code change metrics for the session. [JsonPropertyName("codeChanges")] public required SessionShutdownDataCodeChanges CodeChanges { get; set; } + /// Per-model usage breakdown, keyed by model identifier. [JsonPropertyName("modelMetrics")] public required Dictionary ModelMetrics { get; set; } + /// Model that was selected at the time of shutdown. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("currentModel")] public string? CurrentModel { get; set; } } +/// Event payload for . public partial class SessionContextChangedData { + /// Current working directory path. [JsonPropertyName("cwd")] public required string Cwd { get; set; } + /// Root directory of the git repository, resolved via git rev-parse. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("gitRoot")] public string? GitRoot { get; set; } + /// Repository identifier in "owner/name" format, derived from the git remote URL. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("repository")] public string? Repository { get; set; } + /// Current git branch name. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("branch")] public string? Branch { get; set; } } +/// Event payload for . public partial class SessionUsageInfoData { + /// Maximum token count for the model's context window. [JsonPropertyName("tokenLimit")] public required double TokenLimit { get; set; } + /// Current number of tokens in the context window. [JsonPropertyName("currentTokens")] public required double CurrentTokens { get; set; } + /// Current number of messages in the conversation. [JsonPropertyName("messagesLength")] public required double MessagesLength { get; set; } } +/// Empty payload; the event signals that LLM-powered conversation compaction has begun. public partial class SessionCompactionStartData { } +/// Event payload for . public partial class SessionCompactionCompleteData { + /// Whether compaction completed successfully. [JsonPropertyName("success")] public required bool Success { get; set; } + /// Error message if compaction failed. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("error")] public string? Error { get; set; } + /// Total tokens in conversation before compaction. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("preCompactionTokens")] public double? PreCompactionTokens { get; set; } + /// Total tokens in conversation after compaction. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("postCompactionTokens")] public double? PostCompactionTokens { get; set; } + /// Number of messages before compaction. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("preCompactionMessagesLength")] public double? PreCompactionMessagesLength { get; set; } + /// Number of messages removed during compaction. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("messagesRemoved")] public double? MessagesRemoved { get; set; } + /// Number of tokens removed during compaction. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("tokensRemoved")] public double? TokensRemoved { get; set; } + /// LLM-generated summary of the compacted conversation history. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("summaryContent")] public string? SummaryContent { get; set; } + /// Checkpoint snapshot number created for recovery. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("checkpointNumber")] public double? CheckpointNumber { get; set; } + /// File path where the checkpoint was stored. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("checkpointPath")] public string? CheckpointPath { get; set; } + /// Token usage breakdown for the compaction LLM call. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("compactionTokensUsed")] public SessionCompactionCompleteDataCompactionTokensUsed? CompactionTokensUsed { get; set; } + /// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("requestId")] public string? RequestId { get; set; } } +/// Event payload for . public partial class SessionTaskCompleteData { + /// Optional summary of the completed task, provided by the agent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("summary")] public string? Summary { get; set; } } +/// Event payload for . public partial class UserMessageData { + /// The user's message text as displayed in the timeline. [JsonPropertyName("content")] public required string Content { get; set; } + /// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("transformedContent")] public string? TransformedContent { get; set; } + /// Files, selections, or GitHub references attached to the message. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("attachments")] public UserMessageDataAttachmentsItem[]? Attachments { get; set; } + /// Origin of this message, used for timeline filtering (e.g., "skill-pdf" for skill-injected messages that should be hidden from the user). [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("source")] public string? Source { get; set; } + /// The agent mode that was active when this message was sent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("agentMode")] public UserMessageDataAgentMode? AgentMode { get; set; } + /// CAPI interaction ID for correlating this user message with its turn. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("interactionId")] public string? InteractionId { get; set; } } +/// Empty payload; the event signals that the pending message queue has changed. public partial class PendingMessagesModifiedData { } +/// Event payload for . public partial class AssistantTurnStartData { + /// Identifier for this turn within the agentic loop, typically a stringified turn number. [JsonPropertyName("turnId")] public required string TurnId { get; set; } + /// CAPI interaction ID for correlating this turn with upstream telemetry. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("interactionId")] public string? InteractionId { get; set; } } +/// Event payload for . public partial class AssistantIntentData { + /// Short description of what the agent is currently doing or planning to do. [JsonPropertyName("intent")] public required string Intent { get; set; } } +/// Event payload for . public partial class AssistantReasoningData { + /// Unique identifier for this reasoning block. [JsonPropertyName("reasoningId")] public required string ReasoningId { get; set; } + /// The complete extended thinking text from the model. [JsonPropertyName("content")] public required string Content { get; set; } } +/// Event payload for . public partial class AssistantReasoningDeltaData { + /// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event. [JsonPropertyName("reasoningId")] public required string ReasoningId { get; set; } + /// Incremental text chunk to append to the reasoning content. [JsonPropertyName("deltaContent")] public required string DeltaContent { get; set; } } +/// Event payload for . public partial class AssistantStreamingDeltaData { + /// Cumulative total bytes received from the streaming response so far. [JsonPropertyName("totalResponseSizeBytes")] public required double TotalResponseSizeBytes { get; set; } } +/// Event payload for . public partial class AssistantMessageData { + /// Unique identifier for this assistant message. [JsonPropertyName("messageId")] public required string MessageId { get; set; } + /// The assistant's text response content. [JsonPropertyName("content")] public required string Content { get; set; } + /// Tool invocations requested by the assistant in this message. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolRequests")] public AssistantMessageDataToolRequestsItem[]? ToolRequests { get; set; } + /// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("reasoningOpaque")] public string? ReasoningOpaque { get; set; } + /// Readable reasoning text from the model's extended thinking. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("reasoningText")] public string? ReasoningText { get; set; } + /// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("encryptedContent")] public string? EncryptedContent { get; set; } + /// Generation phase for phased-output models (e.g., thinking vs. response phases). [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("phase")] public string? Phase { get; set; } + /// Actual output token count from the API response (completion_tokens), used for accurate token accounting. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("outputTokens")] public double? OutputTokens { get; set; } + /// CAPI interaction ID for correlating this message with upstream telemetry. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("interactionId")] public string? InteractionId { get; set; } + /// Tool call ID of the parent tool invocation when this event originates from a sub-agent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("parentToolCallId")] public string? ParentToolCallId { get; set; } } +/// Event payload for . public partial class AssistantMessageDeltaData { + /// Message ID this delta belongs to, matching the corresponding assistant.message event. [JsonPropertyName("messageId")] public required string MessageId { get; set; } + /// Incremental text chunk to append to the message content. [JsonPropertyName("deltaContent")] public required string DeltaContent { get; set; } + /// Tool call ID of the parent tool invocation when this event originates from a sub-agent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("parentToolCallId")] public string? ParentToolCallId { get; set; } } +/// Event payload for . public partial class AssistantTurnEndData { + /// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event. [JsonPropertyName("turnId")] public required string TurnId { get; set; } } +/// Event payload for . public partial class AssistantUsageData { + /// Model identifier used for this API call. [JsonPropertyName("model")] public required string Model { get; set; } + /// Number of input tokens consumed. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("inputTokens")] public double? InputTokens { get; set; } + /// Number of output tokens produced. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("outputTokens")] public double? OutputTokens { get; set; } + /// Number of tokens read from prompt cache. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("cacheReadTokens")] public double? CacheReadTokens { get; set; } + /// Number of tokens written to prompt cache. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("cacheWriteTokens")] public double? CacheWriteTokens { get; set; } + /// Model multiplier cost for billing purposes. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("cost")] public double? Cost { get; set; } + /// Duration of the API call in milliseconds. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("duration")] public double? Duration { get; set; } + /// What initiated this API call (e.g., "sub-agent"); absent for user-initiated calls. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("initiator")] public string? Initiator { get; set; } + /// Completion ID from the model provider (e.g., chatcmpl-abc123). [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("apiCallId")] public string? ApiCallId { get; set; } + /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("providerCallId")] public string? ProviderCallId { get; set; } + /// Parent tool call ID when this usage originates from a sub-agent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("parentToolCallId")] public string? ParentToolCallId { get; set; } + /// Per-quota resource usage snapshots, keyed by quota identifier. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("quotaSnapshots")] public Dictionary? QuotaSnapshots { get; set; } + /// Per-request cost and usage data from the CAPI copilot_usage response field. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("copilotUsage")] public AssistantUsageDataCopilotUsage? CopilotUsage { get; set; } } +/// Event payload for . public partial class AbortData { + /// Reason the current turn was aborted (e.g., "user initiated"). [JsonPropertyName("reason")] public required string Reason { get; set; } } +/// Event payload for . public partial class ToolUserRequestedData { + /// Unique identifier for this tool call. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Name of the tool the user wants to invoke. [JsonPropertyName("toolName")] public required string ToolName { get; set; } + /// Arguments for the tool invocation. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("arguments")] public object? Arguments { get; set; } } +/// Event payload for . public partial class ToolExecutionStartData { + /// Unique identifier for this tool call. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Name of the tool being executed. [JsonPropertyName("toolName")] public required string ToolName { get; set; } + /// Arguments passed to the tool. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("arguments")] public object? Arguments { get; set; } + /// Name of the MCP server hosting this tool, when the tool is an MCP tool. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("mcpServerName")] public string? McpServerName { get; set; } + /// Original tool name on the MCP server, when the tool is an MCP tool. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("mcpToolName")] public string? McpToolName { get; set; } + /// Tool call ID of the parent tool invocation when this event originates from a sub-agent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("parentToolCallId")] public string? ParentToolCallId { get; set; } } +/// Event payload for . public partial class ToolExecutionPartialResultData { + /// Tool call ID this partial result belongs to. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Incremental output chunk from the running tool. [JsonPropertyName("partialOutput")] public required string PartialOutput { get; set; } } +/// Event payload for . public partial class ToolExecutionProgressData { + /// Tool call ID this progress notification belongs to. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Human-readable progress status message (e.g., from an MCP server). [JsonPropertyName("progressMessage")] public required string ProgressMessage { get; set; } } +/// Event payload for . public partial class ToolExecutionCompleteData { + /// Unique identifier for the completed tool call. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Whether the tool execution completed successfully. [JsonPropertyName("success")] public required bool Success { get; set; } + /// Model identifier that generated this tool call. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("model")] public string? Model { get; set; } + /// CAPI interaction ID for correlating this tool execution with upstream telemetry. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("interactionId")] public string? InteractionId { get; set; } + /// Whether this tool call was explicitly requested by the user rather than the assistant. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("isUserRequested")] public bool? IsUserRequested { get; set; } + /// Tool execution result on success. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("result")] public ToolExecutionCompleteDataResult? Result { get; set; } + /// Error details when the tool execution failed. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("error")] public ToolExecutionCompleteDataError? Error { get; set; } + /// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts). [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolTelemetry")] public Dictionary? ToolTelemetry { get; set; } + /// Tool call ID of the parent tool invocation when this event originates from a sub-agent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("parentToolCallId")] public string? ParentToolCallId { get; set; } } +/// Event payload for . public partial class SkillInvokedData { + /// Name of the invoked skill. [JsonPropertyName("name")] public required string Name { get; set; } + /// File path to the SKILL.md definition. [JsonPropertyName("path")] public required string Path { get; set; } + /// Full content of the skill file, injected into the conversation for the model. [JsonPropertyName("content")] public required string Content { get; set; } + /// Tool names that should be auto-approved when this skill is active. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("allowedTools")] public string[]? AllowedTools { get; set; } + /// Name of the plugin this skill originated from, when applicable. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("pluginName")] public string? PluginName { get; set; } + /// Version of the plugin this skill originated from, when applicable. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("pluginVersion")] public string? PluginVersion { get; set; } } +/// Event payload for . public partial class SubagentStartedData { + /// Tool call ID of the parent tool invocation that spawned this sub-agent. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Internal name of the sub-agent. [JsonPropertyName("agentName")] public required string AgentName { get; set; } + /// Human-readable display name of the sub-agent. [JsonPropertyName("agentDisplayName")] public required string AgentDisplayName { get; set; } + /// Description of what the sub-agent does. [JsonPropertyName("agentDescription")] public required string AgentDescription { get; set; } } +/// Event payload for . public partial class SubagentCompletedData { + /// Tool call ID of the parent tool invocation that spawned this sub-agent. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Internal name of the sub-agent. [JsonPropertyName("agentName")] public required string AgentName { get; set; } + /// Human-readable display name of the sub-agent. [JsonPropertyName("agentDisplayName")] public required string AgentDisplayName { get; set; } } +/// Event payload for . public partial class SubagentFailedData { + /// Tool call ID of the parent tool invocation that spawned this sub-agent. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Internal name of the sub-agent. [JsonPropertyName("agentName")] public required string AgentName { get; set; } + /// Human-readable display name of the sub-agent. [JsonPropertyName("agentDisplayName")] public required string AgentDisplayName { get; set; } + /// Error message describing why the sub-agent failed. [JsonPropertyName("error")] public required string Error { get; set; } } +/// Event payload for . public partial class SubagentSelectedData { + /// Internal name of the selected custom agent. [JsonPropertyName("agentName")] public required string AgentName { get; set; } + /// Human-readable display name of the selected custom agent. [JsonPropertyName("agentDisplayName")] public required string AgentDisplayName { get; set; } + /// List of tool names available to this agent, or null for all tools. [JsonPropertyName("tools")] public string[]? Tools { get; set; } } +/// Empty payload; the event signals that the custom agent was deselected, returning to the default agent. public partial class SubagentDeselectedData { } +/// Event payload for . public partial class HookStartData { + /// Unique identifier for this hook invocation. [JsonPropertyName("hookInvocationId")] public required string HookInvocationId { get; set; } + /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart"). [JsonPropertyName("hookType")] public required string HookType { get; set; } + /// Input data passed to the hook. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("input")] public object? Input { get; set; } } +/// Event payload for . public partial class HookEndData { + /// Identifier matching the corresponding hook.start event. [JsonPropertyName("hookInvocationId")] public required string HookInvocationId { get; set; } + /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart"). [JsonPropertyName("hookType")] public required string HookType { get; set; } + /// Output data produced by the hook. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("output")] public object? Output { get; set; } + /// Whether the hook completed successfully. [JsonPropertyName("success")] public required bool Success { get; set; } + /// Error details when the hook failed. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("error")] public HookEndDataError? Error { get; set; } } +/// Event payload for . public partial class SystemMessageData { + /// The system or developer prompt text. [JsonPropertyName("content")] public required string Content { get; set; } + /// Message role: "system" for system prompts, "developer" for developer-injected instructions. [JsonPropertyName("role")] public required SystemMessageDataRole Role { get; set; } + /// Optional name identifier for the message source. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("name")] public string? Name { get; set; } + /// Metadata about the prompt template and its construction. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("metadata")] public SystemMessageDataMetadata? Metadata { get; set; } } +/// Event payload for . public partial class SystemNotificationData { + /// The notification text, typically wrapped in <system_notification> XML tags. [JsonPropertyName("content")] public required string Content { get; set; } + /// Structured metadata identifying what triggered this notification. [JsonPropertyName("kind")] public required SystemNotificationDataKind Kind { get; set; } } +/// Event payload for . public partial class PermissionRequestedData { + /// Unique identifier for this permission request; used to respond via session.respondToPermission(). [JsonPropertyName("requestId")] public required string RequestId { get; set; } + /// Details of the permission being requested. [JsonPropertyName("permissionRequest")] public required PermissionRequest PermissionRequest { get; set; } } +/// Event payload for . public partial class PermissionCompletedData { + /// Request ID of the resolved permission request; clients should dismiss any UI for this request. [JsonPropertyName("requestId")] public required string RequestId { get; set; } + /// The result of the permission request. [JsonPropertyName("result")] public required PermissionCompletedDataResult Result { get; set; } } +/// Event payload for . public partial class UserInputRequestedData { + /// Unique identifier for this input request; used to respond via session.respondToUserInput(). [JsonPropertyName("requestId")] public required string RequestId { get; set; } + /// The question or prompt to present to the user. [JsonPropertyName("question")] public required string Question { get; set; } + /// Predefined choices for the user to select from, if applicable. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("choices")] public string[]? Choices { get; set; } + /// Whether the user can provide a free-form text response in addition to predefined choices. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("allowFreeform")] public bool? AllowFreeform { get; set; } } +/// Event payload for . public partial class UserInputCompletedData { + /// Request ID of the resolved user input request; clients should dismiss any UI for this request. [JsonPropertyName("requestId")] public required string RequestId { get; set; } } +/// Event payload for . public partial class ElicitationRequestedData { + /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation(). [JsonPropertyName("requestId")] public required string RequestId { get; set; } + /// Message describing what information is needed from the user. [JsonPropertyName("message")] public required string Message { get; set; } + /// Elicitation mode; currently only "form" is supported. Defaults to "form" when absent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("mode")] public string? Mode { get; set; } + /// JSON Schema describing the form fields to present to the user. [JsonPropertyName("requestedSchema")] public required ElicitationRequestedDataRequestedSchema RequestedSchema { get; set; } } +/// Event payload for . public partial class ElicitationCompletedData { + /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request. [JsonPropertyName("requestId")] public required string RequestId { get; set; } } +/// Event payload for . public partial class ExternalToolRequestedData { + /// Unique identifier for this request; used to respond via session.respondToExternalTool(). [JsonPropertyName("requestId")] public required string RequestId { get; set; } + /// Session ID that this external tool request belongs to. [JsonPropertyName("sessionId")] public required string SessionId { get; set; } + /// Tool call ID assigned to this external tool invocation. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Name of the external tool to invoke. [JsonPropertyName("toolName")] public required string ToolName { get; set; } + /// Arguments to pass to the external tool. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("arguments")] public object? Arguments { get; set; } } +/// Event payload for . public partial class ExternalToolCompletedData { + /// Request ID of the resolved external tool request; clients should dismiss any UI for this request. [JsonPropertyName("requestId")] public required string RequestId { get; set; } } +/// Event payload for . public partial class CommandQueuedData { + /// Unique identifier for this request; used to respond via session.respondToQueuedCommand(). [JsonPropertyName("requestId")] public required string RequestId { get; set; } + /// The slash command text to be executed (e.g., /help, /clear). [JsonPropertyName("command")] public required string Command { get; set; } } +/// Event payload for . public partial class CommandCompletedData { + /// Request ID of the resolved command request; clients should dismiss any UI for this request. [JsonPropertyName("requestId")] public required string RequestId { get; set; } } +/// Event payload for . public partial class ExitPlanModeRequestedData { + /// Unique identifier for this request; used to respond via session.respondToExitPlanMode(). [JsonPropertyName("requestId")] public required string RequestId { get; set; } + /// Summary of the plan that was created. [JsonPropertyName("summary")] public required string Summary { get; set; } + /// Full content of the plan file. [JsonPropertyName("planContent")] public required string PlanContent { get; set; } + /// Available actions the user can take (e.g., approve, edit, reject). [JsonPropertyName("actions")] public required string[] Actions { get; set; } + /// The recommended action for the user to take. [JsonPropertyName("recommendedAction")] public required string RecommendedAction { get; set; } } +/// Event payload for . public partial class ExitPlanModeCompletedData { + /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request. [JsonPropertyName("requestId")] public required string RequestId { get; set; } } +/// Working directory and git context at session start. +/// Nested data type for SessionStartDataContext. public partial class SessionStartDataContext { + /// Current working directory path. [JsonPropertyName("cwd")] public required string Cwd { get; set; } + /// Root directory of the git repository, resolved via git rev-parse. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("gitRoot")] public string? GitRoot { get; set; } + /// Repository identifier in "owner/name" format, derived from the git remote URL. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("repository")] public string? Repository { get; set; } + /// Current git branch name. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("branch")] public string? Branch { get; set; } } +/// Updated working directory and git context at resume time. +/// Nested data type for SessionResumeDataContext. public partial class SessionResumeDataContext { + /// Current working directory path. [JsonPropertyName("cwd")] public required string Cwd { get; set; } + /// Root directory of the git repository, resolved via git rev-parse. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("gitRoot")] public string? GitRoot { get; set; } + /// Repository identifier in "owner/name" format, derived from the git remote URL. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("repository")] public string? Repository { get; set; } + /// Current git branch name. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("branch")] public string? Branch { get; set; } } +/// Nested data type for SessionIdleDataBackgroundTasksAgentsItem. public partial class SessionIdleDataBackgroundTasksAgentsItem { + /// Unique identifier of the background agent. [JsonPropertyName("agentId")] public required string AgentId { get; set; } + /// Type of the background agent. [JsonPropertyName("agentType")] public required string AgentType { get; set; } + /// Human-readable description of the agent task. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("description")] public string? Description { get; set; } } +/// Nested data type for SessionIdleDataBackgroundTasksShellsItem. public partial class SessionIdleDataBackgroundTasksShellsItem { + /// Unique identifier of the background shell. [JsonPropertyName("shellId")] public required string ShellId { get; set; } + /// Human-readable description of the shell command. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("description")] public string? Description { get; set; } } +/// Background tasks still running when the agent became idle. +/// Nested data type for SessionIdleDataBackgroundTasks. public partial class SessionIdleDataBackgroundTasks { + /// Currently running background agents. [JsonPropertyName("agents")] public required SessionIdleDataBackgroundTasksAgentsItem[] Agents { get; set; } + /// Currently running background shell commands. [JsonPropertyName("shells")] public required SessionIdleDataBackgroundTasksShellsItem[] Shells { get; set; } } +/// Repository context for the handed-off session. +/// Nested data type for SessionHandoffDataRepository. public partial class SessionHandoffDataRepository { + /// Repository owner (user or organization). [JsonPropertyName("owner")] public required string Owner { get; set; } + /// Repository name. [JsonPropertyName("name")] public required string Name { get; set; } + /// Git branch name, if applicable. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("branch")] public string? Branch { get; set; } } +/// Aggregate code change metrics for the session. +/// Nested data type for SessionShutdownDataCodeChanges. public partial class SessionShutdownDataCodeChanges { + /// Total number of lines added during the session. [JsonPropertyName("linesAdded")] public required double LinesAdded { get; set; } + /// Total number of lines removed during the session. [JsonPropertyName("linesRemoved")] public required double LinesRemoved { get; set; } + /// List of file paths that were modified during the session. [JsonPropertyName("filesModified")] public required string[] FilesModified { get; set; } } +/// Token usage breakdown for the compaction LLM call. +/// Nested data type for SessionCompactionCompleteDataCompactionTokensUsed. public partial class SessionCompactionCompleteDataCompactionTokensUsed { + /// Input tokens consumed by the compaction LLM call. [JsonPropertyName("input")] public required double Input { get; set; } + /// Output tokens produced by the compaction LLM call. [JsonPropertyName("output")] public required double Output { get; set; } + /// Cached input tokens reused in the compaction LLM call. [JsonPropertyName("cachedInput")] public required double CachedInput { get; set; } } +/// Optional line range to scope the attachment to a specific section of the file. +/// Nested data type for UserMessageDataAttachmentsItemFileLineRange. public partial class UserMessageDataAttachmentsItemFileLineRange { + /// Start line number (1-based). [JsonPropertyName("start")] public required double Start { get; set; } + /// End line number (1-based, inclusive). [JsonPropertyName("end")] public required double End { get; set; } } +/// The file variant of . public partial class UserMessageDataAttachmentsItemFile : UserMessageDataAttachmentsItem { + /// [JsonIgnore] public override string Type => "file"; + /// Absolute file or directory path. [JsonPropertyName("path")] public required string Path { get; set; } + /// User-facing display name for the attachment. [JsonPropertyName("displayName")] public required string DisplayName { get; set; } + /// Optional line range to scope the attachment to a specific section of the file. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("lineRange")] public UserMessageDataAttachmentsItemFileLineRange? LineRange { get; set; } } +/// Optional line range to scope the attachment to a specific section of the file. +/// Nested data type for UserMessageDataAttachmentsItemDirectoryLineRange. public partial class UserMessageDataAttachmentsItemDirectoryLineRange { + /// Start line number (1-based). [JsonPropertyName("start")] public required double Start { get; set; } + /// End line number (1-based, inclusive). [JsonPropertyName("end")] public required double End { get; set; } } +/// The directory variant of . public partial class UserMessageDataAttachmentsItemDirectory : UserMessageDataAttachmentsItem { + /// [JsonIgnore] public override string Type => "directory"; + /// Absolute file or directory path. [JsonPropertyName("path")] public required string Path { get; set; } + /// User-facing display name for the attachment. [JsonPropertyName("displayName")] public required string DisplayName { get; set; } + /// Optional line range to scope the attachment to a specific section of the file. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("lineRange")] public UserMessageDataAttachmentsItemDirectoryLineRange? LineRange { get; set; } } +/// Nested data type for UserMessageDataAttachmentsItemSelectionSelectionStart. public partial class UserMessageDataAttachmentsItemSelectionSelectionStart { + /// Start line number (0-based). [JsonPropertyName("line")] public required double Line { get; set; } + /// Start character offset within the line (0-based). [JsonPropertyName("character")] public required double Character { get; set; } } +/// Nested data type for UserMessageDataAttachmentsItemSelectionSelectionEnd. public partial class UserMessageDataAttachmentsItemSelectionSelectionEnd { + /// End line number (0-based). [JsonPropertyName("line")] public required double Line { get; set; } + /// End character offset within the line (0-based). [JsonPropertyName("character")] public required double Character { get; set; } } +/// Position range of the selection within the file. +/// Nested data type for UserMessageDataAttachmentsItemSelectionSelection. public partial class UserMessageDataAttachmentsItemSelectionSelection { + /// Gets or sets the start value. [JsonPropertyName("start")] public required UserMessageDataAttachmentsItemSelectionSelectionStart Start { get; set; } + /// Gets or sets the end value. [JsonPropertyName("end")] public required UserMessageDataAttachmentsItemSelectionSelectionEnd End { get; set; } } +/// The selection variant of . public partial class UserMessageDataAttachmentsItemSelection : UserMessageDataAttachmentsItem { + /// [JsonIgnore] public override string Type => "selection"; + /// Absolute path to the file containing the selection. [JsonPropertyName("filePath")] public required string FilePath { get; set; } + /// User-facing display name for the selection. [JsonPropertyName("displayName")] public required string DisplayName { get; set; } + /// The selected text content. [JsonPropertyName("text")] public required string Text { get; set; } + /// Position range of the selection within the file. [JsonPropertyName("selection")] public required UserMessageDataAttachmentsItemSelectionSelection Selection { get; set; } } +/// The github_reference variant of . public partial class UserMessageDataAttachmentsItemGithubReference : UserMessageDataAttachmentsItem { + /// [JsonIgnore] public override string Type => "github_reference"; + /// Issue, pull request, or discussion number. [JsonPropertyName("number")] public required double Number { get; set; } + /// Title of the referenced item. [JsonPropertyName("title")] public required string Title { get; set; } + /// Type of GitHub reference. [JsonPropertyName("referenceType")] public required UserMessageDataAttachmentsItemGithubReferenceReferenceType ReferenceType { get; set; } + /// Current state of the referenced item (e.g., open, closed, merged). [JsonPropertyName("state")] public required string State { get; set; } + /// URL to the referenced item on GitHub. [JsonPropertyName("url")] public required string Url { get; set; } } +/// Polymorphic base type discriminated by type. [JsonPolymorphic( TypeDiscriminatorPropertyName = "type", UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType)] @@ -1909,161 +2256,210 @@ public partial class UserMessageDataAttachmentsItemGithubReference : UserMessage [JsonDerivedType(typeof(UserMessageDataAttachmentsItemGithubReference), "github_reference")] public partial class UserMessageDataAttachmentsItem { + /// The type discriminator. [JsonPropertyName("type")] public virtual string Type { get; set; } = string.Empty; } +/// Nested data type for AssistantMessageDataToolRequestsItem. public partial class AssistantMessageDataToolRequestsItem { + /// Unique identifier for this tool call. [JsonPropertyName("toolCallId")] public required string ToolCallId { get; set; } + /// Name of the tool being invoked. [JsonPropertyName("name")] public required string Name { get; set; } + /// Arguments to pass to the tool, format depends on the tool. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("arguments")] public object? Arguments { get; set; } + /// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("type")] public AssistantMessageDataToolRequestsItemType? Type { get; set; } } +/// Nested data type for AssistantUsageDataCopilotUsageTokenDetailsItem. public partial class AssistantUsageDataCopilotUsageTokenDetailsItem { + /// Number of tokens in this billing batch. [JsonPropertyName("batchSize")] public required double BatchSize { get; set; } + /// Cost per batch of tokens. [JsonPropertyName("costPerBatch")] public required double CostPerBatch { get; set; } + /// Total token count for this entry. [JsonPropertyName("tokenCount")] public required double TokenCount { get; set; } + /// Token category (e.g., "input", "output"). [JsonPropertyName("tokenType")] public required string TokenType { get; set; } } +/// Per-request cost and usage data from the CAPI copilot_usage response field. +/// Nested data type for AssistantUsageDataCopilotUsage. public partial class AssistantUsageDataCopilotUsage { + /// Itemized token usage breakdown. [JsonPropertyName("tokenDetails")] public required AssistantUsageDataCopilotUsageTokenDetailsItem[] TokenDetails { get; set; } + /// Total cost in nano-AIU (AI Units) for this request. [JsonPropertyName("totalNanoAiu")] public required double TotalNanoAiu { get; set; } } +/// The text variant of . public partial class ToolExecutionCompleteDataResultContentsItemText : ToolExecutionCompleteDataResultContentsItem { + /// [JsonIgnore] public override string Type => "text"; + /// The text content. [JsonPropertyName("text")] public required string Text { get; set; } } +/// The terminal variant of . public partial class ToolExecutionCompleteDataResultContentsItemTerminal : ToolExecutionCompleteDataResultContentsItem { + /// [JsonIgnore] public override string Type => "terminal"; + /// Terminal/shell output text. [JsonPropertyName("text")] public required string Text { get; set; } + /// Process exit code, if the command has completed. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("exitCode")] public double? ExitCode { get; set; } + /// Working directory where the command was executed. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("cwd")] public string? Cwd { get; set; } } +/// The image variant of . public partial class ToolExecutionCompleteDataResultContentsItemImage : ToolExecutionCompleteDataResultContentsItem { + /// [JsonIgnore] public override string Type => "image"; + /// Base64-encoded image data. [JsonPropertyName("data")] public required string Data { get; set; } + /// MIME type of the image (e.g., image/png, image/jpeg). [JsonPropertyName("mimeType")] public required string MimeType { get; set; } } +/// The audio variant of . public partial class ToolExecutionCompleteDataResultContentsItemAudio : ToolExecutionCompleteDataResultContentsItem { + /// [JsonIgnore] public override string Type => "audio"; + /// Base64-encoded audio data. [JsonPropertyName("data")] public required string Data { get; set; } + /// MIME type of the audio (e.g., audio/wav, audio/mpeg). [JsonPropertyName("mimeType")] public required string MimeType { get; set; } } +/// Nested data type for ToolExecutionCompleteDataResultContentsItemResourceLinkIconsItem. public partial class ToolExecutionCompleteDataResultContentsItemResourceLinkIconsItem { + /// URL or path to the icon image. [JsonPropertyName("src")] public required string Src { get; set; } + /// MIME type of the icon image. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("mimeType")] public string? MimeType { get; set; } + /// Available icon sizes (e.g., ['16x16', '32x32']). [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("sizes")] public string[]? Sizes { get; set; } + /// Theme variant this icon is intended for. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("theme")] public ToolExecutionCompleteDataResultContentsItemResourceLinkIconsItemTheme? Theme { get; set; } } +/// The resource_link variant of . public partial class ToolExecutionCompleteDataResultContentsItemResourceLink : ToolExecutionCompleteDataResultContentsItem { + /// [JsonIgnore] public override string Type => "resource_link"; + /// Icons associated with this resource. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("icons")] public ToolExecutionCompleteDataResultContentsItemResourceLinkIconsItem[]? Icons { get; set; } + /// Resource name identifier. [JsonPropertyName("name")] public required string Name { get; set; } + /// Human-readable display title for the resource. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("title")] public string? Title { get; set; } + /// URI identifying the resource. [JsonPropertyName("uri")] public required string Uri { get; set; } + /// Human-readable description of the resource. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("description")] public string? Description { get; set; } + /// MIME type of the resource content. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("mimeType")] public string? MimeType { get; set; } + /// Size of the resource in bytes. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("size")] public double? Size { get; set; } } +/// The resource variant of . public partial class ToolExecutionCompleteDataResultContentsItemResource : ToolExecutionCompleteDataResultContentsItem { + /// [JsonIgnore] public override string Type => "resource"; + /// The embedded resource contents, either text or base64-encoded binary. [JsonPropertyName("resource")] public required object Resource { get; set; } } +/// Polymorphic base type discriminated by type. [JsonPolymorphic( TypeDiscriminatorPropertyName = "type", UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType)] @@ -2075,109 +2471,145 @@ public partial class ToolExecutionCompleteDataResultContentsItemResource : ToolE [JsonDerivedType(typeof(ToolExecutionCompleteDataResultContentsItemResource), "resource")] public partial class ToolExecutionCompleteDataResultContentsItem { + /// The type discriminator. [JsonPropertyName("type")] public virtual string Type { get; set; } = string.Empty; } +/// Tool execution result on success. +/// Nested data type for ToolExecutionCompleteDataResult. public partial class ToolExecutionCompleteDataResult { + /// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency. [JsonPropertyName("content")] public required string Content { get; set; } + /// Full detailed tool result for UI/timeline display, preserving complete content such as diffs. Falls back to content when absent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("detailedContent")] public string? DetailedContent { get; set; } + /// Structured content blocks (text, images, audio, resources) returned by the tool in their native format. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("contents")] public ToolExecutionCompleteDataResultContentsItem[]? Contents { get; set; } } +/// Error details when the tool execution failed. +/// Nested data type for ToolExecutionCompleteDataError. public partial class ToolExecutionCompleteDataError { + /// Human-readable error message. [JsonPropertyName("message")] public required string Message { get; set; } + /// Machine-readable error code. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("code")] public string? Code { get; set; } } +/// Error details when the hook failed. +/// Nested data type for HookEndDataError. public partial class HookEndDataError { + /// Human-readable error message. [JsonPropertyName("message")] public required string Message { get; set; } + /// Error stack trace, when available. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("stack")] public string? Stack { get; set; } } +/// Metadata about the prompt template and its construction. +/// Nested data type for SystemMessageDataMetadata. public partial class SystemMessageDataMetadata { + /// Version identifier of the prompt template used. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("promptVersion")] public string? PromptVersion { get; set; } + /// Template variables used when constructing the prompt. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("variables")] public Dictionary? Variables { get; set; } } +/// The agent_completed variant of . public partial class SystemNotificationDataKindAgentCompleted : SystemNotificationDataKind { + /// [JsonIgnore] public override string Type => "agent_completed"; + /// Unique identifier of the background agent. [JsonPropertyName("agentId")] public required string AgentId { get; set; } + /// Type of the agent (e.g., explore, task, general-purpose). [JsonPropertyName("agentType")] public required string AgentType { get; set; } + /// Whether the agent completed successfully or failed. [JsonPropertyName("status")] public required SystemNotificationDataKindAgentCompletedStatus Status { get; set; } + /// Human-readable description of the agent task. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("description")] public string? Description { get; set; } + /// The full prompt given to the background agent. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("prompt")] public string? Prompt { get; set; } } +/// The shell_completed variant of . public partial class SystemNotificationDataKindShellCompleted : SystemNotificationDataKind { + /// [JsonIgnore] public override string Type => "shell_completed"; + /// Unique identifier of the shell session. [JsonPropertyName("shellId")] public required string ShellId { get; set; } + /// Exit code of the shell command, if available. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("exitCode")] public double? ExitCode { get; set; } + /// Human-readable description of the command. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("description")] public string? Description { get; set; } } +/// The shell_detached_completed variant of . public partial class SystemNotificationDataKindShellDetachedCompleted : SystemNotificationDataKind { + /// [JsonIgnore] public override string Type => "shell_detached_completed"; + /// Unique identifier of the detached shell session. [JsonPropertyName("shellId")] public required string ShellId { get; set; } + /// Human-readable description of the command. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("description")] public string? Description { get; set; } } +/// Structured metadata identifying what triggered this notification. +/// Polymorphic base type discriminated by type. [JsonPolymorphic( TypeDiscriminatorPropertyName = "type", UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType)] @@ -2186,181 +2618,237 @@ public partial class SystemNotificationDataKindShellDetachedCompleted : SystemNo [JsonDerivedType(typeof(SystemNotificationDataKindShellDetachedCompleted), "shell_detached_completed")] public partial class SystemNotificationDataKind { + /// The type discriminator. [JsonPropertyName("type")] public virtual string Type { get; set; } = string.Empty; } +/// Nested data type for PermissionRequestShellCommandsItem. public partial class PermissionRequestShellCommandsItem { + /// Command identifier (e.g., executable name). [JsonPropertyName("identifier")] public required string Identifier { get; set; } + /// Whether this command is read-only (no side effects). [JsonPropertyName("readOnly")] public required bool ReadOnly { get; set; } } +/// Nested data type for PermissionRequestShellPossibleUrlsItem. public partial class PermissionRequestShellPossibleUrlsItem { + /// URL that may be accessed by the command. [JsonPropertyName("url")] public required string Url { get; set; } } +/// The shell variant of . public partial class PermissionRequestShell : PermissionRequest { + /// [JsonIgnore] public override string Kind => "shell"; + /// Tool call ID that triggered this permission request. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolCallId")] public string? ToolCallId { get; set; } + /// The complete shell command text to be executed. [JsonPropertyName("fullCommandText")] public required string FullCommandText { get; set; } + /// Human-readable description of what the command intends to do. [JsonPropertyName("intention")] public required string Intention { get; set; } + /// Parsed command identifiers found in the command text. [JsonPropertyName("commands")] public required PermissionRequestShellCommandsItem[] Commands { get; set; } + /// File paths that may be read or written by the command. [JsonPropertyName("possiblePaths")] public required string[] PossiblePaths { get; set; } + /// URLs that may be accessed by the command. [JsonPropertyName("possibleUrls")] public required PermissionRequestShellPossibleUrlsItem[] PossibleUrls { get; set; } + /// Whether the command includes a file write redirection (e.g., > or >>). [JsonPropertyName("hasWriteFileRedirection")] public required bool HasWriteFileRedirection { get; set; } + /// Whether the UI can offer session-wide approval for this command pattern. [JsonPropertyName("canOfferSessionApproval")] public required bool CanOfferSessionApproval { get; set; } + /// Optional warning message about risks of running this command. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("warning")] public string? Warning { get; set; } } +/// The write variant of . public partial class PermissionRequestWrite : PermissionRequest { + /// [JsonIgnore] public override string Kind => "write"; + /// Tool call ID that triggered this permission request. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolCallId")] public string? ToolCallId { get; set; } + /// Human-readable description of the intended file change. [JsonPropertyName("intention")] public required string Intention { get; set; } + /// Path of the file being written to. [JsonPropertyName("fileName")] public required string FileName { get; set; } + /// Unified diff showing the proposed changes. [JsonPropertyName("diff")] public required string Diff { get; set; } + /// Complete new file contents for newly created files. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("newFileContents")] public string? NewFileContents { get; set; } } +/// The read variant of . public partial class PermissionRequestRead : PermissionRequest { + /// [JsonIgnore] public override string Kind => "read"; + /// Tool call ID that triggered this permission request. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolCallId")] public string? ToolCallId { get; set; } + /// Human-readable description of why the file is being read. [JsonPropertyName("intention")] public required string Intention { get; set; } + /// Path of the file or directory being read. [JsonPropertyName("path")] public required string Path { get; set; } } +/// The mcp variant of . public partial class PermissionRequestMcp : PermissionRequest { + /// [JsonIgnore] public override string Kind => "mcp"; + /// Tool call ID that triggered this permission request. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolCallId")] public string? ToolCallId { get; set; } + /// Name of the MCP server providing the tool. [JsonPropertyName("serverName")] public required string ServerName { get; set; } + /// Internal name of the MCP tool. [JsonPropertyName("toolName")] public required string ToolName { get; set; } + /// Human-readable title of the MCP tool. [JsonPropertyName("toolTitle")] public required string ToolTitle { get; set; } + /// Arguments to pass to the MCP tool. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("args")] public object? Args { get; set; } + /// Whether this MCP tool is read-only (no side effects). [JsonPropertyName("readOnly")] public required bool ReadOnly { get; set; } } +/// The url variant of . public partial class PermissionRequestUrl : PermissionRequest { + /// [JsonIgnore] public override string Kind => "url"; + /// Tool call ID that triggered this permission request. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolCallId")] public string? ToolCallId { get; set; } + /// Human-readable description of why the URL is being accessed. [JsonPropertyName("intention")] public required string Intention { get; set; } + /// URL to be fetched. [JsonPropertyName("url")] public required string Url { get; set; } } +/// The memory variant of . public partial class PermissionRequestMemory : PermissionRequest { + /// [JsonIgnore] public override string Kind => "memory"; + /// Tool call ID that triggered this permission request. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolCallId")] public string? ToolCallId { get; set; } + /// Topic or subject of the memory being stored. [JsonPropertyName("subject")] public required string Subject { get; set; } + /// The fact or convention being stored. [JsonPropertyName("fact")] public required string Fact { get; set; } + /// Source references for the stored fact. [JsonPropertyName("citations")] public required string Citations { get; set; } } +/// The custom-tool variant of . public partial class PermissionRequestCustomTool : PermissionRequest { + /// [JsonIgnore] public override string Kind => "custom-tool"; + /// Tool call ID that triggered this permission request. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("toolCallId")] public string? ToolCallId { get; set; } + /// Name of the custom tool. [JsonPropertyName("toolName")] public required string ToolName { get; set; } + /// Description of what the custom tool does. [JsonPropertyName("toolDescription")] public required string ToolDescription { get; set; } + /// Arguments to pass to the custom tool. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("args")] public object? Args { get; set; } } +/// Details of the permission being requested. +/// Polymorphic base type discriminated by kind. [JsonPolymorphic( TypeDiscriminatorPropertyName = "kind", UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType)] @@ -2373,139 +2861,188 @@ public partial class PermissionRequestCustomTool : PermissionRequest [JsonDerivedType(typeof(PermissionRequestCustomTool), "custom-tool")] public partial class PermissionRequest { + /// The type discriminator. [JsonPropertyName("kind")] public virtual string Kind { get; set; } = string.Empty; } +/// The result of the permission request. +/// Nested data type for PermissionCompletedDataResult. public partial class PermissionCompletedDataResult { + /// The outcome of the permission request. [JsonPropertyName("kind")] public required PermissionCompletedDataResultKind Kind { get; set; } } +/// JSON Schema describing the form fields to present to the user. +/// Nested data type for ElicitationRequestedDataRequestedSchema. public partial class ElicitationRequestedDataRequestedSchema { + /// Gets or sets the type value. [JsonPropertyName("type")] public required string Type { get; set; } + /// Form field definitions, keyed by field name. [JsonPropertyName("properties")] public required Dictionary Properties { get; set; } + /// List of required field names. [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] [JsonPropertyName("required")] public string[]? Required { get; set; } } +/// The type of operation performed on the plan file. [JsonConverter(typeof(JsonStringEnumConverter))] public enum SessionPlanChangedDataOperation { + /// The create variant. [JsonStringEnumMemberName("create")] Create, + /// The update variant. [JsonStringEnumMemberName("update")] Update, + /// The delete variant. [JsonStringEnumMemberName("delete")] Delete, } +/// Whether the file was newly created or updated. [JsonConverter(typeof(JsonStringEnumConverter))] public enum SessionWorkspaceFileChangedDataOperation { + /// The create variant. [JsonStringEnumMemberName("create")] Create, + /// The update variant. [JsonStringEnumMemberName("update")] Update, } +/// Origin type of the session being handed off. [JsonConverter(typeof(JsonStringEnumConverter))] public enum SessionHandoffDataSourceType { + /// The remote variant. [JsonStringEnumMemberName("remote")] Remote, + /// The local variant. [JsonStringEnumMemberName("local")] Local, } +/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error"). [JsonConverter(typeof(JsonStringEnumConverter))] public enum SessionShutdownDataShutdownType { + /// The routine variant. [JsonStringEnumMemberName("routine")] Routine, + /// The error variant. [JsonStringEnumMemberName("error")] Error, } +/// Type of GitHub reference. [JsonConverter(typeof(JsonStringEnumConverter))] public enum UserMessageDataAttachmentsItemGithubReferenceReferenceType { + /// The issue variant. [JsonStringEnumMemberName("issue")] Issue, + /// The pr variant. [JsonStringEnumMemberName("pr")] Pr, + /// The discussion variant. [JsonStringEnumMemberName("discussion")] Discussion, } +/// The agent mode that was active when this message was sent. [JsonConverter(typeof(JsonStringEnumConverter))] public enum UserMessageDataAgentMode { + /// The interactive variant. [JsonStringEnumMemberName("interactive")] Interactive, + /// The plan variant. [JsonStringEnumMemberName("plan")] Plan, + /// The autopilot variant. [JsonStringEnumMemberName("autopilot")] Autopilot, + /// The shell variant. [JsonStringEnumMemberName("shell")] Shell, } +/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent. [JsonConverter(typeof(JsonStringEnumConverter))] public enum AssistantMessageDataToolRequestsItemType { + /// The function variant. [JsonStringEnumMemberName("function")] Function, + /// The custom variant. [JsonStringEnumMemberName("custom")] Custom, } +/// Theme variant this icon is intended for. [JsonConverter(typeof(JsonStringEnumConverter))] public enum ToolExecutionCompleteDataResultContentsItemResourceLinkIconsItemTheme { + /// The light variant. [JsonStringEnumMemberName("light")] Light, + /// The dark variant. [JsonStringEnumMemberName("dark")] Dark, } +/// Message role: "system" for system prompts, "developer" for developer-injected instructions. [JsonConverter(typeof(JsonStringEnumConverter))] public enum SystemMessageDataRole { + /// The system variant. [JsonStringEnumMemberName("system")] System, + /// The developer variant. [JsonStringEnumMemberName("developer")] Developer, } +/// Whether the agent completed successfully or failed. [JsonConverter(typeof(JsonStringEnumConverter))] public enum SystemNotificationDataKindAgentCompletedStatus { + /// The completed variant. [JsonStringEnumMemberName("completed")] Completed, + /// The failed variant. [JsonStringEnumMemberName("failed")] Failed, } +/// The outcome of the permission request. [JsonConverter(typeof(JsonStringEnumConverter))] public enum PermissionCompletedDataResultKind { + /// The approved variant. [JsonStringEnumMemberName("approved")] Approved, + /// The denied-by-rules variant. [JsonStringEnumMemberName("denied-by-rules")] DeniedByRules, + /// The denied-no-approval-rule-and-could-not-request-from-user variant. [JsonStringEnumMemberName("denied-no-approval-rule-and-could-not-request-from-user")] DeniedNoApprovalRuleAndCouldNotRequestFromUser, + /// The denied-interactively-by-user variant. [JsonStringEnumMemberName("denied-interactively-by-user")] DeniedInteractivelyByUser, + /// The denied-by-content-exclusion-policy variant. [JsonStringEnumMemberName("denied-by-content-exclusion-policy")] DeniedByContentExclusionPolicy, } diff --git a/scripts/codegen/csharp.ts b/scripts/codegen/csharp.ts index c72eb06d..1b2f7612 100644 --- a/scripts/codegen/csharp.ts +++ b/scripts/codegen/csharp.ts @@ -44,6 +44,60 @@ function applyTypeRename(className: string): string { // ── C# utilities ──────────────────────────────────────────────────────────── +function escapeXml(text: string): string { + return text.replace(/&/g, "&").replace(//g, ">"); +} + +/** Ensures text ends with sentence-ending punctuation. */ +function ensureTrailingPunctuation(text: string): string { + const trimmed = text.trimEnd(); + if (/[.!?]$/.test(trimmed)) return trimmed; + return `${trimmed}.`; +} + +function xmlDocComment(description: string | undefined, indent: string): string[] { + if (!description) return []; + const escaped = ensureTrailingPunctuation(escapeXml(description.trim())); + const lines = escaped.split(/\r?\n/); + if (lines.length === 1) { + return [`${indent}/// ${lines[0]}`]; + } + return [ + `${indent}/// `, + ...lines.map((l) => `${indent}/// ${l}`), + `${indent}/// `, + ]; +} + +/** Like xmlDocComment but skips XML escaping — use only for codegen-controlled strings that already contain valid XML tags. */ +function rawXmlDocSummary(text: string, indent: string): string[] { + const line = ensureTrailingPunctuation(text.trim()); + return [`${indent}/// ${line}`]; +} + +/** Emits a summary (from description or fallback) and, when a real description exists, a remarks line with the fallback. */ +function xmlDocCommentWithFallback(description: string | undefined, fallback: string, indent: string): string[] { + if (description) { + return [ + ...xmlDocComment(description, indent), + `${indent}/// ${ensureTrailingPunctuation(fallback)}`, + ]; + } + return rawXmlDocSummary(fallback, indent); +} + +/** Emits a summary from the schema description, or a fallback naming the property by its JSON key. */ +function xmlDocPropertyComment(description: string | undefined, jsonPropName: string, indent: string): string[] { + if (description) return xmlDocComment(description, indent); + return rawXmlDocSummary(`Gets or sets the ${escapeXml(jsonPropName)} value.`, indent); +} + +/** Emits a summary from the schema description, or a generic fallback. */ +function xmlDocEnumComment(description: string | undefined, indent: string): string[] { + if (description) return xmlDocComment(description, indent); + return rawXmlDocSummary(`Defines the allowed values.`, indent); +} + function toPascalCase(name: string): string { if (name.includes("_") || name.includes("-")) { return name.split(/[-_]/).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(""); @@ -139,11 +193,12 @@ interface EventVariant { className: string; dataClassName: string; dataSchema: JSONSchema7; + dataDescription?: string; } let generatedEnums = new Map(); -function getOrCreateEnum(parentClassName: string, propName: string, values: string[], enumOutput: string[]): string { +function getOrCreateEnum(parentClassName: string, propName: string, values: string[], enumOutput: string[], description?: string): string { const valuesKey = [...values].sort().join("|"); for (const [, existing] of generatedEnums) { if ([...existing.values].sort().join("|") === valuesKey) return existing.enumName; @@ -151,8 +206,11 @@ function getOrCreateEnum(parentClassName: string, propName: string, values: stri const enumName = `${parentClassName}${propName}`; generatedEnums.set(enumName, { enumName, values }); - const lines = [`[JsonConverter(typeof(JsonStringEnumConverter<${enumName}>))]`, `public enum ${enumName}`, `{`]; + const lines: string[] = []; + lines.push(...xmlDocEnumComment(description, "")); + lines.push(`[JsonConverter(typeof(JsonStringEnumConverter<${enumName}>))]`, `public enum ${enumName}`, `{`); for (const value of values) { + lines.push(` /// The ${escapeXml(value)} variant.`); lines.push(` [JsonStringEnumMemberName("${value}")]`, ` ${toPascalCaseEnumMember(value)},`); } lines.push(`}`, ""); @@ -171,11 +229,13 @@ function extractEventVariants(schema: JSONSchema7): EventVariant[] { const typeName = typeSchema?.const as string; if (!typeName) throw new Error("Variant must have type.const"); const baseName = typeToClassName(typeName); + const dataSchema = variant.properties.data as JSONSchema7; return { typeName, className: `${baseName}Event`, dataClassName: `${baseName}Data`, - dataSchema: variant.properties.data as JSONSchema7, + dataSchema, + dataDescription: dataSchema?.description, }; }) .filter((v) => !EXCLUDED_EVENT_TYPES.has(v.typeName)); @@ -222,12 +282,14 @@ function generatePolymorphicClasses( variants: JSONSchema7[], knownTypes: Map, nestedClasses: Map, - enumOutput: string[] + enumOutput: string[], + description?: string ): string { const lines: string[] = []; const discriminatorInfo = findDiscriminator(variants)!; const renamedBase = applyTypeRename(baseClassName); + lines.push(...xmlDocCommentWithFallback(description, `Polymorphic base type discriminated by ${escapeXml(discriminatorProperty)}.`, "")); lines.push(`[JsonPolymorphic(`); lines.push(` TypeDiscriminatorPropertyName = "${discriminatorProperty}",`); lines.push(` UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FallBackToBaseType)]`); @@ -239,6 +301,7 @@ function generatePolymorphicClasses( lines.push(`public partial class ${renamedBase}`); lines.push(`{`); + lines.push(` /// The type discriminator.`); lines.push(` [JsonPropertyName("${discriminatorProperty}")]`); lines.push(` public virtual string ${toPascalCase(discriminatorProperty)} { get; set; } = string.Empty;`); lines.push(`}`); @@ -269,8 +332,10 @@ function generateDerivedClass( const lines: string[] = []; const required = new Set(schema.required || []); + lines.push(...xmlDocCommentWithFallback(schema.description, `The ${escapeXml(discriminatorValue)} variant of .`, "")); lines.push(`public partial class ${className} : ${baseClassName}`); lines.push(`{`); + lines.push(` /// `); lines.push(` [JsonIgnore]`); lines.push(` public override string ${toPascalCase(discriminatorProperty)} => "${discriminatorValue}";`); lines.push(""); @@ -284,6 +349,7 @@ function generateDerivedClass( const csharpName = toPascalCase(propName); const csharpType = resolveSessionPropertyType(propSchema as JSONSchema7, className, csharpName, isReq, knownTypes, nestedClasses, enumOutput); + lines.push(...xmlDocPropertyComment((propSchema as JSONSchema7).description, propName, " ")); if (!isReq) lines.push(` [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]`); lines.push(` [JsonPropertyName("${propName}")]`); const reqMod = isReq && !csharpType.endsWith("?") ? "required " : ""; @@ -304,7 +370,9 @@ function generateNestedClass( enumOutput: string[] ): string { const required = new Set(schema.required || []); - const lines = [`public partial class ${className}`, `{`]; + const lines: string[] = []; + lines.push(...xmlDocCommentWithFallback(schema.description, `Nested data type for ${className}.`, "")); + lines.push(`public partial class ${className}`, `{`); for (const [propName, propSchema] of Object.entries(schema.properties || {})) { if (typeof propSchema !== "object") continue; @@ -313,6 +381,7 @@ function generateNestedClass( const csharpName = toPascalCase(propName); const csharpType = resolveSessionPropertyType(prop, className, csharpName, isReq, knownTypes, nestedClasses, enumOutput); + lines.push(...xmlDocPropertyComment(prop.description, propName, " ")); if (!isReq) lines.push(` [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]`); lines.push(` [JsonPropertyName("${propName}")]`); const reqMod = isReq && !csharpType.endsWith("?") ? "required " : ""; @@ -345,7 +414,7 @@ function resolveSessionPropertyType( if (discriminatorInfo) { const baseClassName = `${parentClassName}${propName}`; const renamedBase = applyTypeRename(baseClassName); - const polymorphicCode = generatePolymorphicClasses(baseClassName, discriminatorInfo.property, variants, knownTypes, nestedClasses, enumOutput); + const polymorphicCode = generatePolymorphicClasses(baseClassName, discriminatorInfo.property, variants, knownTypes, nestedClasses, enumOutput, propSchema.description); nestedClasses.set(renamedBase, polymorphicCode); return isRequired && !hasNull ? renamedBase : `${renamedBase}?`; } @@ -353,7 +422,7 @@ function resolveSessionPropertyType( return hasNull || !isRequired ? "object?" : "object"; } if (propSchema.enum && Array.isArray(propSchema.enum)) { - const enumName = getOrCreateEnum(parentClassName, propName, propSchema.enum as string[], enumOutput); + const enumName = getOrCreateEnum(parentClassName, propName, propSchema.enum as string[], enumOutput, propSchema.description); return isRequired ? enumName : `${enumName}?`; } if (propSchema.type === "object" && propSchema.properties) { @@ -370,7 +439,7 @@ function resolveSessionPropertyType( if (discriminatorInfo) { const baseClassName = `${parentClassName}${propName}Item`; const renamedBase = applyTypeRename(baseClassName); - const polymorphicCode = generatePolymorphicClasses(baseClassName, discriminatorInfo.property, variants, knownTypes, nestedClasses, enumOutput); + const polymorphicCode = generatePolymorphicClasses(baseClassName, discriminatorInfo.property, variants, knownTypes, nestedClasses, enumOutput, items.description); nestedClasses.set(renamedBase, polymorphicCode); return isRequired ? `${renamedBase}[]` : `${renamedBase}[]?`; } @@ -381,7 +450,7 @@ function resolveSessionPropertyType( return isRequired ? `${itemClassName}[]` : `${itemClassName}[]?`; } if (items.enum && Array.isArray(items.enum)) { - const enumName = getOrCreateEnum(parentClassName, `${propName}Item`, items.enum as string[], enumOutput); + const enumName = getOrCreateEnum(parentClassName, `${propName}Item`, items.enum as string[], enumOutput, items.description); return isRequired ? `${enumName}[]` : `${enumName}[]?`; } const itemType = schemaTypeToCSharp(items, true, knownTypes); @@ -394,7 +463,13 @@ function generateDataClass(variant: EventVariant, knownTypes: Map.`, "")); + } + lines.push(`public partial class ${variant.dataClassName}`, `{`); for (const [propName, propSchema] of Object.entries(variant.dataSchema.properties)) { if (typeof propSchema !== "object") continue; @@ -402,6 +477,7 @@ function generateDataClass(variant: EventVariant, knownTypes: Map(); const enumOutput: string[] = []; + // Extract descriptions for base class properties from the first variant + const firstVariant = (schema.definitions?.SessionEvent as JSONSchema7)?.anyOf?.[0]; + const baseProps = typeof firstVariant === "object" && firstVariant?.properties ? firstVariant.properties : {}; + const baseDesc = (name: string) => { + const prop = baseProps[name]; + return typeof prop === "object" ? (prop as JSONSchema7).description : undefined; + }; + const lines: string[] = []; lines.push(`${COPYRIGHT} // AUTO-GENERATED FILE - DO NOT EDIT // Generated from: session-events.schema.json -// Generated code does not have XML doc comments; suppress CS1591 to avoid warnings. -#pragma warning disable CS1591 - using System.Text.Json; using System.Text.Json.Serialization; @@ -436,25 +517,41 @@ namespace GitHub.Copilot.SDK; // Base class with XML doc lines.push(`/// `); - lines.push(`/// Base class for all session events with polymorphic JSON serialization.`); + lines.push(`/// Provides the base class from which all session events derive.`); lines.push(`/// `); lines.push(`[JsonPolymorphic(`, ` TypeDiscriminatorPropertyName = "type",`, ` UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FailSerialization)]`); for (const variant of [...variants].sort((a, b) => a.typeName.localeCompare(b.typeName))) { lines.push(`[JsonDerivedType(typeof(${variant.className}), "${variant.typeName}")]`); } - lines.push(`public abstract partial class SessionEvent`, `{`, ` [JsonPropertyName("id")]`, ` public Guid Id { get; set; }`, ""); + lines.push(`public abstract partial class SessionEvent`, `{`); + lines.push(...xmlDocComment(baseDesc("id"), " ")); + lines.push(` [JsonPropertyName("id")]`, ` public Guid Id { get; set; }`, ""); + lines.push(...xmlDocComment(baseDesc("timestamp"), " ")); lines.push(` [JsonPropertyName("timestamp")]`, ` public DateTimeOffset Timestamp { get; set; }`, ""); + lines.push(...xmlDocComment(baseDesc("parentId"), " ")); lines.push(` [JsonPropertyName("parentId")]`, ` public Guid? ParentId { get; set; }`, ""); + lines.push(...xmlDocComment(baseDesc("ephemeral"), " ")); lines.push(` [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]`, ` [JsonPropertyName("ephemeral")]`, ` public bool? Ephemeral { get; set; }`, ""); lines.push(` /// `, ` /// The event type discriminator.`, ` /// `); lines.push(` [JsonIgnore]`, ` public abstract string Type { get; }`, ""); + lines.push(` /// Deserializes a JSON string into a .`); lines.push(` public static SessionEvent FromJson(string json) =>`, ` JsonSerializer.Deserialize(json, SessionEventsJsonContext.Default.SessionEvent)!;`, ""); + lines.push(` /// Serializes this event to a JSON string.`); lines.push(` public string ToJson() =>`, ` JsonSerializer.Serialize(this, SessionEventsJsonContext.Default.SessionEvent);`, `}`, ""); // Event classes with XML docs for (const variant of variants) { - lines.push(`/// `, `/// Event: ${variant.typeName}`, `/// `); - lines.push(`public partial class ${variant.className} : SessionEvent`, `{`, ` [JsonIgnore]`, ` public override string Type => "${variant.typeName}";`, ""); + const remarksLine = `/// Represents the ${escapeXml(variant.typeName)} event.`; + if (variant.dataDescription) { + lines.push(...xmlDocComment(variant.dataDescription, "")); + lines.push(remarksLine); + } else { + lines.push(`/// Represents the ${escapeXml(variant.typeName)} event.`); + } + lines.push(`public partial class ${variant.className} : SessionEvent`, `{`); + lines.push(` /// `); + lines.push(` [JsonIgnore]`, ` public override string Type => "${variant.typeName}";`, ""); + lines.push(` /// The ${escapeXml(variant.typeName)} event payload.`); lines.push(` [JsonPropertyName("data")]`, ` public required ${variant.dataClassName} Data { get; set; }`, `}`, ""); } @@ -512,7 +609,7 @@ function resolveRpcType(schema: JSONSchema7, isRequired: boolean, parentClassNam } // Handle enums (string unions like "interactive" | "plan" | "autopilot") if (schema.enum && Array.isArray(schema.enum)) { - const enumName = getOrCreateEnum(parentClassName, propName, schema.enum as string[], rpcEnumOutput); + const enumName = getOrCreateEnum(parentClassName, propName, schema.enum as string[], rpcEnumOutput, schema.description); return isRequired ? enumName : `${enumName}?`; } if (schema.type === "object" && schema.properties) { @@ -549,7 +646,7 @@ function emitRpcClass(className: string, schema: JSONSchema7, visibility: "publi const requiredSet = new Set(schema.required || []); const lines: string[] = []; - if (schema.description) lines.push(`/// ${schema.description}`); + lines.push(...xmlDocComment(schema.description || `RPC data type for ${className.replace(/Request$/, "").replace(/Result$/, "")} operations.`, "")); lines.push(`${visibility} class ${className}`, `{`); const props = Object.entries(schema.properties || {}); @@ -561,7 +658,7 @@ function emitRpcClass(className: string, schema: JSONSchema7, visibility: "publi const csharpName = toPascalCase(propName); const csharpType = resolveRpcType(prop, isReq, className, csharpName, extraClasses); - if (prop.description && visibility === "public") lines.push(` /// ${prop.description}`); + lines.push(...xmlDocPropertyComment(prop.description, propName, " ")); lines.push(` [JsonPropertyName("${propName}")]`); let defaultVal = ""; @@ -591,7 +688,7 @@ function emitServerRpcClasses(node: Record, classes: string[]): // ServerRpc class const srLines: string[] = []; - srLines.push(`/// Typed server-scoped RPC methods (no session required).`); + srLines.push(`/// Provides server-scoped RPC methods (no session required).`); srLines.push(`public class ServerRpc`); srLines.push(`{`); srLines.push(` private readonly JsonRpc _rpc;`); @@ -631,7 +728,7 @@ function emitServerRpcClasses(node: Record, classes: string[]): function emitServerApiClass(className: string, node: Record, classes: string[]): string { const lines: string[] = []; const displayName = className.replace(/^Server/, "").replace(/Api$/, ""); - lines.push(`/// Server-scoped ${displayName} APIs.`); + lines.push(`/// Provides server-scoped ${displayName} APIs.`); lines.push(`public class ${className}`); lines.push(`{`); lines.push(` private readonly JsonRpc _rpc;`); @@ -703,11 +800,11 @@ function emitSessionRpcClasses(node: Record, classes: string[]) const groups = Object.entries(node).filter(([, v]) => typeof v === "object" && v !== null && !isRpcMethod(v)); const topLevelMethods = Object.entries(node).filter(([, v]) => isRpcMethod(v)); - const srLines = [`/// Typed session-scoped RPC methods.`, `public class SessionRpc`, `{`, ` private readonly JsonRpc _rpc;`, ` private readonly string _sessionId;`, ""]; + const srLines = [`/// Provides typed session-scoped RPC methods.`, `public class SessionRpc`, `{`, ` private readonly JsonRpc _rpc;`, ` private readonly string _sessionId;`, ""]; srLines.push(` internal SessionRpc(JsonRpc rpc, string sessionId)`, ` {`, ` _rpc = rpc;`, ` _sessionId = sessionId;`); for (const [groupName] of groups) srLines.push(` ${toPascalCase(groupName)} = new ${toPascalCase(groupName)}Api(rpc, sessionId);`); srLines.push(` }`); - for (const [groupName] of groups) srLines.push("", ` public ${toPascalCase(groupName)}Api ${toPascalCase(groupName)} { get; }`); + for (const [groupName] of groups) srLines.push("", ` /// ${toPascalCase(groupName)} APIs.`, ` public ${toPascalCase(groupName)}Api ${toPascalCase(groupName)} { get; }`); // Emit top-level session RPC methods directly on the SessionRpc class const topLevelLines: string[] = []; @@ -766,7 +863,8 @@ function emitSessionMethod(key: string, method: RpcMethod, lines: string[], clas } function emitSessionApiClass(className: string, node: Record, classes: string[]): string { - const lines = [`public class ${className}`, `{`, ` private readonly JsonRpc _rpc;`, ` private readonly string _sessionId;`, ""]; + const displayName = className.replace(/Api$/, ""); + const lines = [`/// Provides session-scoped ${displayName} APIs.`, `public class ${className}`, `{`, ` private readonly JsonRpc _rpc;`, ` private readonly string _sessionId;`, ""]; lines.push(` internal ${className}(JsonRpc rpc, string sessionId)`, ` {`, ` _rpc = rpc;`, ` _sessionId = sessionId;`, ` }`); for (const [key, value] of Object.entries(node)) { @@ -796,9 +894,6 @@ function generateRpcCode(schema: ApiSchema): string { // AUTO-GENERATED FILE - DO NOT EDIT // Generated from: api.schema.json -// Generated code does not have XML doc comments; suppress CS1591 to avoid warnings. -#pragma warning disable CS1591 - using System.Text.Json; using System.Text.Json.Serialization; using StreamJsonRpc;