From f47c480ac80b06abfa5ae918ce150b4d82051108 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 10 May 2026 19:14:32 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- .../Generated/Inworld.OptionsSupport.g.cs | 175 ++++++++++++++++++ ....Models.SpeechToTextStreamServerEvent.g.cs | 36 ++++ ....Models.TextToSpeechStreamServerEvent.g.cs | 48 +++++ .../Inworld.Realtime.OptionsSupport.g.cs | 175 ++++++++++++++++++ 4 files changed, 434 insertions(+) diff --git a/src/libs/Inworld/Generated/Inworld.OptionsSupport.g.cs b/src/libs/Inworld/Generated/Inworld.OptionsSupport.g.cs index 84329bd..d7253dd 100644 --- a/src/libs/Inworld/Generated/Inworld.OptionsSupport.g.cs +++ b/src/libs/Inworld/Generated/Inworld.OptionsSupport.g.cs @@ -54,6 +54,172 @@ public sealed class AutoSDKClientOptions Hooks.Add(hook ?? throw new global::System.ArgumentNullException(nameof(hook))); return this; } + + /// + /// Optional per-request authorization provider invoked before each request is sent. + /// Set this when the client is registered as a singleton in DI but each call needs + /// a fresh credential resolved from a provider, secret-store, or session — instead + /// of mutating the shared Authorizations list at construction time. + /// + public global::Inworld.IAutoSDKAuthorizationProvider? AuthorizationProvider { get; set; } + + /// + /// Convenience helper that registers + /// using so request-level auth is resolved without + /// touching shared client state. + /// + /// + public global::Inworld.AutoSDKClientOptions UseAuthorizationProvider( + global::Inworld.IAutoSDKAuthorizationProvider provider) + { + AuthorizationProvider = provider ?? throw new global::System.ArgumentNullException(nameof(provider)); + if (Hooks.Find(static x => x is global::Inworld.AutoSDKAuthorizationProviderHook) == null) + { + Hooks.Add(new global::Inworld.AutoSDKAuthorizationProviderHook()); + } + + return this; + } + } + + /// + /// A request-level authorization value supplied by . + /// Mirrors the runtime fields the SDK applies for HTTP / OAuth2 / API-key auth without + /// requiring the consumer to construct the generated EndPointAuthorization type. + /// + public readonly struct AutoSDKAuthorizationValue + { + /// + /// Initializes a new . + /// + /// + /// + /// + /// + /// + public AutoSDKAuthorizationValue( + string value, + string scheme = "Bearer", + string? headerName = null, + string location = "Header", + string type = "Http") + { + Value = value ?? string.Empty; + Scheme = string.IsNullOrWhiteSpace(scheme) ? "Bearer" : scheme; + HeaderName = headerName ?? string.Empty; + Location = string.IsNullOrWhiteSpace(location) ? "Header" : location; + Type = string.IsNullOrWhiteSpace(type) ? "Http" : type; + } + + /// The credential value (token, API key, etc.). + public string Value { get; } + + /// The HTTP authorization scheme — typically Bearer, Basic, or Token. + public string Scheme { get; } + + /// The custom header name when is ApiKey; ignored for HTTP/OAuth2 auth. + public string HeaderName { get; } + + /// The credential location — Header, Query, or Cookie. + public string Location { get; } + + /// The auth type — Http, OAuth2, OpenIdConnect, or ApiKey. + public string Type { get; } + + /// Convenience factory for a Bearer token. + public static global::Inworld.AutoSDKAuthorizationValue Bearer(string token) => new(value: token, scheme: "Bearer"); + + /// Convenience factory for an API-key header. + public static global::Inworld.AutoSDKAuthorizationValue ApiKeyHeader(string name, string value) => + new(value: value, headerName: name, location: "Header", type: "ApiKey"); + } + + /// + /// Resolves request-level authorization values without mutating the shared client + /// authorization list. Implementations should be safe to invoke concurrently — + /// the hook calls them once per outgoing request. + /// + public interface IAutoSDKAuthorizationProvider + { + /// + /// Returns one or more values to apply to + /// the current request, or an empty list / null to leave the request as-is. + /// + /// + global::System.Threading.Tasks.Task?> ResolveAsync( + global::Inworld.AutoSDKHookContext context); + } + + /// + /// Built-in that consults + /// before every outgoing + /// request and stamps the resolved values onto the . + /// + public sealed class AutoSDKAuthorizationProviderHook : global::Inworld.AutoSDKHook + { + /// + public override async global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Inworld.AutoSDKHookContext context) + { + context = context ?? throw new global::System.ArgumentNullException(nameof(context)); + + if (context.Request == null) + { + return; + } + + var perRequest = context.RequestOptions?.Authorizations; + if (perRequest != null && perRequest.Count > 0) + { + for (var index = 0; index < perRequest.Count; index++) + { + ApplyAuthorization(context.Request, perRequest[index]); + } + + return; + } + + var provider = context.ClientOptions?.AuthorizationProvider; + if (provider == null) + { + return; + } + + var resolved = await provider.ResolveAsync(context).ConfigureAwait(false); + if (resolved == null || resolved.Count == 0) + { + return; + } + + for (var index = 0; index < resolved.Count; index++) + { + ApplyAuthorization(context.Request, resolved[index]); + } + } + + private static void ApplyAuthorization( + global::System.Net.Http.HttpRequestMessage request, + global::Inworld.AutoSDKAuthorizationValue authorization) + { + switch (authorization.Type) + { + case "Http": + case "OAuth2": + case "OpenIdConnect": + request.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: authorization.Scheme, + parameter: authorization.Value); + break; + case "ApiKey": + if (string.Equals(authorization.Location, "Header", global::System.StringComparison.OrdinalIgnoreCase) && + !string.IsNullOrEmpty(authorization.HeaderName)) + { + request.Headers.Remove(authorization.HeaderName); + request.Headers.TryAddWithoutValidation(authorization.HeaderName, authorization.Value ?? string.Empty); + } + break; + } + } } /// @@ -87,6 +253,15 @@ public sealed class AutoSDKRequestOptions /// Overrides response buffering for this request when set. /// public bool? ReadResponseAsString { get; set; } + + /// + /// Optional per-request authorization values. When non-empty, the built-in + /// applies these instead of consulting + /// for this request only. + /// Useful for multi-tenant routing or "act-as" admin tooling that needs a different + /// credential per call without mutating shared client state. + /// + public global::System.Collections.Generic.IReadOnlyList? Authorizations { get; set; } } /// diff --git a/src/libs/Inworld/Generated/Inworld.Realtime.Models.SpeechToTextStreamServerEvent.g.cs b/src/libs/Inworld/Generated/Inworld.Realtime.Models.SpeechToTextStreamServerEvent.g.cs index b0ee700..bb02758 100644 --- a/src/libs/Inworld/Generated/Inworld.Realtime.Models.SpeechToTextStreamServerEvent.g.cs +++ b/src/libs/Inworld/Generated/Inworld.Realtime.Models.SpeechToTextStreamServerEvent.g.cs @@ -39,6 +39,13 @@ public bool TryPickSttTranscription( return IsSttTranscription; } + /// + /// + /// + public global::Inworld.Realtime.SttTranscription PickSttTranscription() => IsSttTranscription + ? SttTranscription! + : throw new global::System.InvalidOperationException($"Expected union variant 'SttTranscription' but the value was {ToString()}."); + /// /// /// @@ -69,6 +76,13 @@ public bool TryPickSttUsage( return IsSttUsage; } + /// + /// + /// + public global::Inworld.Realtime.SttUsage PickSttUsage() => IsSttUsage + ? SttUsage! + : throw new global::System.InvalidOperationException($"Expected union variant 'SttUsage' but the value was {ToString()}."); + /// /// /// @@ -98,6 +112,13 @@ public bool TryPickSttStarted( value = SttStarted; return IsSttStarted; } + + /// + /// + /// + public global::Inworld.Realtime.SttSpeechStarted PickSttStarted() => IsSttStarted + ? SttStarted! + : throw new global::System.InvalidOperationException($"Expected union variant 'SttStarted' but the value was {ToString()}."); /// /// /// @@ -116,6 +137,11 @@ public SpeechToTextStreamServerEvent(global::Inworld.Realtime.SttTranscription? SttTranscription = value; } + /// + /// + /// + public static SpeechToTextStreamServerEvent FromSttTranscription(global::Inworld.Realtime.SttTranscription? value) => new SpeechToTextStreamServerEvent(value); + /// /// /// @@ -134,6 +160,11 @@ public SpeechToTextStreamServerEvent(global::Inworld.Realtime.SttUsage? value) SttUsage = value; } + /// + /// + /// + public static SpeechToTextStreamServerEvent FromSttUsage(global::Inworld.Realtime.SttUsage? value) => new SpeechToTextStreamServerEvent(value); + /// /// /// @@ -152,6 +183,11 @@ public SpeechToTextStreamServerEvent(global::Inworld.Realtime.SttSpeechStarted? SttStarted = value; } + /// + /// + /// + public static SpeechToTextStreamServerEvent FromSttStarted(global::Inworld.Realtime.SttSpeechStarted? value) => new SpeechToTextStreamServerEvent(value); + /// /// /// diff --git a/src/libs/Inworld/Generated/Inworld.Realtime.Models.TextToSpeechStreamServerEvent.g.cs b/src/libs/Inworld/Generated/Inworld.Realtime.Models.TextToSpeechStreamServerEvent.g.cs index 8259bde..547c578 100644 --- a/src/libs/Inworld/Generated/Inworld.Realtime.Models.TextToSpeechStreamServerEvent.g.cs +++ b/src/libs/Inworld/Generated/Inworld.Realtime.Models.TextToSpeechStreamServerEvent.g.cs @@ -39,6 +39,13 @@ public bool TryPickTtsContextCreated( return IsTtsContextCreated; } + /// + /// + /// + public global::Inworld.Realtime.TtsContextCreated PickTtsContextCreated() => IsTtsContextCreated + ? TtsContextCreated! + : throw new global::System.InvalidOperationException($"Expected union variant 'TtsContextCreated' but the value was {ToString()}."); + /// /// /// @@ -69,6 +76,13 @@ public bool TryPickTtsAudioChunk( return IsTtsAudioChunk; } + /// + /// + /// + public global::Inworld.Realtime.TtsAudioChunk PickTtsAudioChunk() => IsTtsAudioChunk + ? TtsAudioChunk! + : throw new global::System.InvalidOperationException($"Expected union variant 'TtsAudioChunk' but the value was {ToString()}."); + /// /// /// @@ -99,6 +113,13 @@ public bool TryPickTtsFlushCompleted( return IsTtsFlushCompleted; } + /// + /// + /// + public global::Inworld.Realtime.TtsFlushCompleted PickTtsFlushCompleted() => IsTtsFlushCompleted + ? TtsFlushCompleted! + : throw new global::System.InvalidOperationException($"Expected union variant 'TtsFlushCompleted' but the value was {ToString()}."); + /// /// /// @@ -128,6 +149,13 @@ public bool TryPickTtsContextClosed( value = TtsContextClosed; return IsTtsContextClosed; } + + /// + /// + /// + public global::Inworld.Realtime.TtsContextClosed PickTtsContextClosed() => IsTtsContextClosed + ? TtsContextClosed! + : throw new global::System.InvalidOperationException($"Expected union variant 'TtsContextClosed' but the value was {ToString()}."); /// /// /// @@ -146,6 +174,11 @@ public TextToSpeechStreamServerEvent(global::Inworld.Realtime.TtsContextCreated? TtsContextCreated = value; } + /// + /// + /// + public static TextToSpeechStreamServerEvent FromTtsContextCreated(global::Inworld.Realtime.TtsContextCreated? value) => new TextToSpeechStreamServerEvent(value); + /// /// /// @@ -164,6 +197,11 @@ public TextToSpeechStreamServerEvent(global::Inworld.Realtime.TtsAudioChunk? val TtsAudioChunk = value; } + /// + /// + /// + public static TextToSpeechStreamServerEvent FromTtsAudioChunk(global::Inworld.Realtime.TtsAudioChunk? value) => new TextToSpeechStreamServerEvent(value); + /// /// /// @@ -182,6 +220,11 @@ public TextToSpeechStreamServerEvent(global::Inworld.Realtime.TtsFlushCompleted? TtsFlushCompleted = value; } + /// + /// + /// + public static TextToSpeechStreamServerEvent FromTtsFlushCompleted(global::Inworld.Realtime.TtsFlushCompleted? value) => new TextToSpeechStreamServerEvent(value); + /// /// /// @@ -200,6 +243,11 @@ public TextToSpeechStreamServerEvent(global::Inworld.Realtime.TtsContextClosed? TtsContextClosed = value; } + /// + /// + /// + public static TextToSpeechStreamServerEvent FromTtsContextClosed(global::Inworld.Realtime.TtsContextClosed? value) => new TextToSpeechStreamServerEvent(value); + /// /// /// diff --git a/src/libs/Inworld/Generated/Inworld.Realtime.OptionsSupport.g.cs b/src/libs/Inworld/Generated/Inworld.Realtime.OptionsSupport.g.cs index 9513e47..f4db07b 100644 --- a/src/libs/Inworld/Generated/Inworld.Realtime.OptionsSupport.g.cs +++ b/src/libs/Inworld/Generated/Inworld.Realtime.OptionsSupport.g.cs @@ -54,6 +54,172 @@ public sealed class AutoSDKClientOptions Hooks.Add(hook ?? throw new global::System.ArgumentNullException(nameof(hook))); return this; } + + /// + /// Optional per-request authorization provider invoked before each request is sent. + /// Set this when the client is registered as a singleton in DI but each call needs + /// a fresh credential resolved from a provider, secret-store, or session — instead + /// of mutating the shared Authorizations list at construction time. + /// + public global::Inworld.Realtime.IAutoSDKAuthorizationProvider? AuthorizationProvider { get; set; } + + /// + /// Convenience helper that registers + /// using so request-level auth is resolved without + /// touching shared client state. + /// + /// + public global::Inworld.Realtime.AutoSDKClientOptions UseAuthorizationProvider( + global::Inworld.Realtime.IAutoSDKAuthorizationProvider provider) + { + AuthorizationProvider = provider ?? throw new global::System.ArgumentNullException(nameof(provider)); + if (Hooks.Find(static x => x is global::Inworld.Realtime.AutoSDKAuthorizationProviderHook) == null) + { + Hooks.Add(new global::Inworld.Realtime.AutoSDKAuthorizationProviderHook()); + } + + return this; + } + } + + /// + /// A request-level authorization value supplied by . + /// Mirrors the runtime fields the SDK applies for HTTP / OAuth2 / API-key auth without + /// requiring the consumer to construct the generated EndPointAuthorization type. + /// + public readonly struct AutoSDKAuthorizationValue + { + /// + /// Initializes a new . + /// + /// + /// + /// + /// + /// + public AutoSDKAuthorizationValue( + string value, + string scheme = "Bearer", + string? headerName = null, + string location = "Header", + string type = "Http") + { + Value = value ?? string.Empty; + Scheme = string.IsNullOrWhiteSpace(scheme) ? "Bearer" : scheme; + HeaderName = headerName ?? string.Empty; + Location = string.IsNullOrWhiteSpace(location) ? "Header" : location; + Type = string.IsNullOrWhiteSpace(type) ? "Http" : type; + } + + /// The credential value (token, API key, etc.). + public string Value { get; } + + /// The HTTP authorization scheme — typically Bearer, Basic, or Token. + public string Scheme { get; } + + /// The custom header name when is ApiKey; ignored for HTTP/OAuth2 auth. + public string HeaderName { get; } + + /// The credential location — Header, Query, or Cookie. + public string Location { get; } + + /// The auth type — Http, OAuth2, OpenIdConnect, or ApiKey. + public string Type { get; } + + /// Convenience factory for a Bearer token. + public static global::Inworld.Realtime.AutoSDKAuthorizationValue Bearer(string token) => new(value: token, scheme: "Bearer"); + + /// Convenience factory for an API-key header. + public static global::Inworld.Realtime.AutoSDKAuthorizationValue ApiKeyHeader(string name, string value) => + new(value: value, headerName: name, location: "Header", type: "ApiKey"); + } + + /// + /// Resolves request-level authorization values without mutating the shared client + /// authorization list. Implementations should be safe to invoke concurrently — + /// the hook calls them once per outgoing request. + /// + public interface IAutoSDKAuthorizationProvider + { + /// + /// Returns one or more values to apply to + /// the current request, or an empty list / null to leave the request as-is. + /// + /// + global::System.Threading.Tasks.Task?> ResolveAsync( + global::Inworld.Realtime.AutoSDKHookContext context); + } + + /// + /// Built-in that consults + /// before every outgoing + /// request and stamps the resolved values onto the . + /// + public sealed class AutoSDKAuthorizationProviderHook : global::Inworld.Realtime.AutoSDKHook + { + /// + public override async global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Inworld.Realtime.AutoSDKHookContext context) + { + context = context ?? throw new global::System.ArgumentNullException(nameof(context)); + + if (context.Request == null) + { + return; + } + + var perRequest = context.RequestOptions?.Authorizations; + if (perRequest != null && perRequest.Count > 0) + { + for (var index = 0; index < perRequest.Count; index++) + { + ApplyAuthorization(context.Request, perRequest[index]); + } + + return; + } + + var provider = context.ClientOptions?.AuthorizationProvider; + if (provider == null) + { + return; + } + + var resolved = await provider.ResolveAsync(context).ConfigureAwait(false); + if (resolved == null || resolved.Count == 0) + { + return; + } + + for (var index = 0; index < resolved.Count; index++) + { + ApplyAuthorization(context.Request, resolved[index]); + } + } + + private static void ApplyAuthorization( + global::System.Net.Http.HttpRequestMessage request, + global::Inworld.Realtime.AutoSDKAuthorizationValue authorization) + { + switch (authorization.Type) + { + case "Http": + case "OAuth2": + case "OpenIdConnect": + request.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: authorization.Scheme, + parameter: authorization.Value); + break; + case "ApiKey": + if (string.Equals(authorization.Location, "Header", global::System.StringComparison.OrdinalIgnoreCase) && + !string.IsNullOrEmpty(authorization.HeaderName)) + { + request.Headers.Remove(authorization.HeaderName); + request.Headers.TryAddWithoutValidation(authorization.HeaderName, authorization.Value ?? string.Empty); + } + break; + } + } } /// @@ -87,6 +253,15 @@ public sealed class AutoSDKRequestOptions /// Overrides response buffering for this request when set. /// public bool? ReadResponseAsString { get; set; } + + /// + /// Optional per-request authorization values. When non-empty, the built-in + /// applies these instead of consulting + /// for this request only. + /// Useful for multi-tenant routing or "act-as" admin tooling that needs a different + /// credential per call without mutating shared client state. + /// + public global::System.Collections.Generic.IReadOnlyList? Authorizations { get; set; } } ///