33import Foundation
44
55public let GATEWAY_PROTOCOL_VERSION = 4
6- public let GATEWAY_MIN_PROTOCOL_VERSION = 3
6+ public let GATEWAY_MIN_PROTOCOL_VERSION = 4
77
88private struct GatewayAnyCodingKey : CodingKey , Hashable {
99 let stringValue : String
@@ -6244,14 +6244,139 @@ public struct ChatInjectParams: Codable, Sendable {
62446244 }
62456245}
62466246
6247- public struct ChatEvent : Codable , Sendable {
6247+ public struct ChatDeltaEvent : Codable , Sendable {
62486248 public let runid : String
62496249 public let sessionkey : String
62506250 public let spawnedby : String ?
62516251 public let seq : Int
6252- public let state : AnyCodable
6252+ public let state : String
6253+ public let message : AnyCodable ?
6254+ public let deltatext : String
6255+ public let replace : Bool ?
6256+ public let usage : AnyCodable ?
6257+
6258+ public init (
6259+ runid: String ,
6260+ sessionkey: String ,
6261+ spawnedby: String ? ,
6262+ seq: Int ,
6263+ state: String ,
6264+ message: AnyCodable ? ,
6265+ deltatext: String ,
6266+ replace: Bool ? ,
6267+ usage: AnyCodable ? )
6268+ {
6269+ self . runid = runid
6270+ self . sessionkey = sessionkey
6271+ self . spawnedby = spawnedby
6272+ self . seq = seq
6273+ self . state = state
6274+ self . message = message
6275+ self . deltatext = deltatext
6276+ self . replace = replace
6277+ self . usage = usage
6278+ }
6279+
6280+ private enum CodingKeys : String , CodingKey {
6281+ case runid = " runId "
6282+ case sessionkey = " sessionKey "
6283+ case spawnedby = " spawnedBy "
6284+ case seq
6285+ case state
6286+ case message
6287+ case deltatext = " deltaText "
6288+ case replace
6289+ case usage
6290+ }
6291+ }
6292+
6293+ public struct ChatFinalEvent : Codable , Sendable {
6294+ public let runid : String
6295+ public let sessionkey : String
6296+ public let spawnedby : String ?
6297+ public let seq : Int
6298+ public let state : String
6299+ public let message : AnyCodable ?
6300+ public let usage : AnyCodable ?
6301+ public let stopreason : String ?
6302+
6303+ public init (
6304+ runid: String ,
6305+ sessionkey: String ,
6306+ spawnedby: String ? ,
6307+ seq: Int ,
6308+ state: String ,
6309+ message: AnyCodable ? ,
6310+ usage: AnyCodable ? ,
6311+ stopreason: String ? )
6312+ {
6313+ self . runid = runid
6314+ self . sessionkey = sessionkey
6315+ self . spawnedby = spawnedby
6316+ self . seq = seq
6317+ self . state = state
6318+ self . message = message
6319+ self . usage = usage
6320+ self . stopreason = stopreason
6321+ }
6322+
6323+ private enum CodingKeys : String , CodingKey {
6324+ case runid = " runId "
6325+ case sessionkey = " sessionKey "
6326+ case spawnedby = " spawnedBy "
6327+ case seq
6328+ case state
6329+ case message
6330+ case usage
6331+ case stopreason = " stopReason "
6332+ }
6333+ }
6334+
6335+ public struct ChatAbortedEvent : Codable , Sendable {
6336+ public let runid : String
6337+ public let sessionkey : String
6338+ public let spawnedby : String ?
6339+ public let seq : Int
6340+ public let state : String
6341+ public let message : AnyCodable ?
6342+ public let stopreason : String ?
6343+
6344+ public init (
6345+ runid: String ,
6346+ sessionkey: String ,
6347+ spawnedby: String ? ,
6348+ seq: Int ,
6349+ state: String ,
6350+ message: AnyCodable ? ,
6351+ stopreason: String ? )
6352+ {
6353+ self . runid = runid
6354+ self . sessionkey = sessionkey
6355+ self . spawnedby = spawnedby
6356+ self . seq = seq
6357+ self . state = state
6358+ self . message = message
6359+ self . stopreason = stopreason
6360+ }
6361+
6362+ private enum CodingKeys : String , CodingKey {
6363+ case runid = " runId "
6364+ case sessionkey = " sessionKey "
6365+ case spawnedby = " spawnedBy "
6366+ case seq
6367+ case state
6368+ case message
6369+ case stopreason = " stopReason "
6370+ }
6371+ }
6372+
6373+ public struct ChatErrorEvent : Codable , Sendable {
6374+ public let runid : String
6375+ public let sessionkey : String
6376+ public let spawnedby : String ?
6377+ public let seq : Int
6378+ public let state : String
62536379 public let message : AnyCodable ?
6254- public let deltatext : String ?
62556380 public let errormessage : String ?
62566381 public let errorkind : AnyCodable ?
62576382 public let usage : AnyCodable ?
@@ -6262,9 +6387,8 @@ public struct ChatEvent: Codable, Sendable {
62626387 sessionkey: String ,
62636388 spawnedby: String ? ,
62646389 seq: Int ,
6265- state: AnyCodable ,
6390+ state: String ,
62666391 message: AnyCodable ? ,
6267- deltatext: String ? ,
62686392 errormessage: String ? ,
62696393 errorkind: AnyCodable ? ,
62706394 usage: AnyCodable ? ,
@@ -6276,7 +6400,6 @@ public struct ChatEvent: Codable, Sendable {
62766400 self . seq = seq
62776401 self . state = state
62786402 self . message = message
6279- self . deltatext = deltatext
62806403 self . errormessage = errormessage
62816404 self . errorkind = errorkind
62826405 self . usage = usage
@@ -6290,7 +6413,6 @@ public struct ChatEvent: Codable, Sendable {
62906413 case seq
62916414 case state
62926415 case message
6293- case deltatext = " deltaText "
62946416 case errormessage = " errorMessage "
62956417 case errorkind = " errorKind "
62966418 case usage
@@ -6397,6 +6519,43 @@ public enum PluginsSessionActionResult: Codable, Sendable {
63976519 }
63986520}
63996521
6522+ public enum ChatEvent : Codable , Sendable {
6523+ case delta( ChatDeltaEvent )
6524+ case final( ChatFinalEvent )
6525+ case aborted( ChatAbortedEvent )
6526+ case error( ChatErrorEvent )
6527+
6528+ private enum CodingKeys : String , CodingKey {
6529+ case discriminator = " state "
6530+ }
6531+
6532+ public init ( from decoder: Decoder ) throws {
6533+ let container = try decoder. container ( keyedBy: CodingKeys . self)
6534+ let discriminator = try container. decode ( String . self, forKey: . discriminator)
6535+ switch discriminator {
6536+ case " delta " : self = try . delta( ChatDeltaEvent ( from: decoder) )
6537+ case " final " : self = try . final( ChatFinalEvent ( from: decoder) )
6538+ case " aborted " : self = try . aborted( ChatAbortedEvent ( from: decoder) )
6539+ case " error " : self = try . error( ChatErrorEvent ( from: decoder) )
6540+ default :
6541+ throw DecodingError . dataCorruptedError (
6542+ forKey: . discriminator,
6543+ in: container,
6544+ debugDescription: " Unknown ChatEvent discriminator value "
6545+ )
6546+ }
6547+ }
6548+
6549+ public func encode( to encoder: Encoder ) throws {
6550+ switch self {
6551+ case . delta( let value) : try value. encode ( to: encoder)
6552+ case . final( let value) : try value. encode ( to: encoder)
6553+ case . aborted( let value) : try value. encode ( to: encoder)
6554+ case . error( let value) : try value. encode ( to: encoder)
6555+ }
6556+ }
6557+ }
6558+
64006559public enum GatewayFrame : Codable , Sendable {
64016560 case req( RequestFrame )
64026561 case res( ResponseFrame )
0 commit comments