diff --git a/CHANGELOG.md b/CHANGELOG.md index af8d1f7b9..9ecd33b5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- **`SmartHopper.ProviderSdk` package** — new MIT-licensed assembly that exposes the provider-facing surface (contracts, base classes, request/response DTOs, model capabilities, settings descriptors, streaming, tool DTOs, version attributes) so community providers can build against it without cloning SmartHopper. See [docs/Providers/ProviderSdk.md](docs/Providers/ProviderSdk.md). +- **Host abstractions** — `IProviderTrustHost`, `IProviderRegistryHost`, `IPolicyPipelineHost`, `IContextProviderHost`, `IToolRegistryHost`, `IProviderSettingsStore`, `IProviderLogger`, `IProviderHttpClientFactory`, `IProviderDiagnostics`, and the `ProviderSdkHost` composition root in the SDK; `SmartHopperProviderTrustHost` adapter in Infrastructure wires `ProviderManager` into the SDK. +- **Per-provider `AssemblyLoadContext`** (`ProviderAssemblyLoader`) — loads provider-private DLLs in isolation while delegating SDK/Infrastructure/`Newtonsoft.Json`/`System.Drawing.Common` to the default ALC. Rejects providers whose `IAIProviderFactory` type identity does not match the host. +- **SDK SemVer metadata** — `SmartHopperProviderSdkVersionAttribute`, `BuiltAgainstSdkAttribute`, `MinHostSdkAttribute`, `SmartHopperProviderIdAttribute`, and `SdkCompatibility.Check` enforce `BuiltAgainstSdk.MAJOR == HostSdk.MAJOR` and `HostSdk >= MinHostSdk` at load time. +- **`ProviderClassifier`** — cryptographic classification (strong-name + Authenticode + SHA-256 manifest) producing `Official`, `OfficialTampered`, `Community`, or `Invalid`. File names and provider ids no longer affect classification. +- **Trust settings** — `AllowCommunityProviders` and `BlockNonOfficialProviders` toggles in `SmartHopperSettings`. Structured `TrustedProviderRecords` schema with classification, hash-at-decision, signer thumbprint, and strong-name token; legacy `TrustedProviders` boolean map is migrated automatically on first load. +- **`ProviderManager` warning APIs** — `IsProviderCommunity`, `IsProviderUnsigned`, `GetProviderClassification`, `GetProviderTrustRecord`, plus existing mismatched/unknown/unavailable accessors. +- **AI component badges** — `AIRequestCall` validation now emits runtime warning messages when the selected provider is community/unsigned, in addition to the existing mismatched/unavailable/unknown warnings. +- **User-local provider directory** — `%AppData%/SmartHopper/Providers` is scanned in addition to the app-local directory. App-local providers win on duplicate-id conflicts. +- **Initialization isolation** — `InitializeProviderAsync` runs under a 30-second per-provider timeout so a hanging provider cannot block discovery. + +### Changed + +- Provider-facing types moved from `SmartHopper.Infrastructure.*` to `SmartHopper.ProviderSdk.*` namespaces. All callers in the repo updated accordingly. +- `ProviderManager.LoadProviderAssemblyAsync` now consults `ProviderClassifier` and applies policy decisions based on classification + the new trust settings before falling through to the existing hash/trust flow. +- Duplicate provider ids: subsequent registrations of an id already held by an `Official` provider are rejected. Other duplicates replace the previously registered instance. +- Provider integrity warnings (mismatched, unavailable, unknown, community, unsigned) are now surfaced via the existing `AIRuntimeMessage` pipeline on every AI component that selects the affected provider. + +### Removed + +- `InternalsVisibleTo` entries for `SmartHopper.Providers.*` in `SmartHopper.Infrastructure.csproj`. Built-in providers now compile only against the public SDK surface. + +### Security + +- Provider classification is now purely cryptographic; spoofed names cannot reach `Official` without matching strong-name, Authenticode, or hash manifest signals. +- `BlockNonOfficialProviders=true` is a hard gate that blocks any non-Official provider regardless of per-provider trust or `AllowCommunityProviders`. +- Community/unsigned providers are blocked at load time unless `AllowCommunityProviders=true` AND a per-provider trust prompt has been accepted; trust is invalidated automatically if a community provider's SHA-256 changes. +- Trusting a community provider grants full process privileges and is documented as a deliberate user decision. + ### ⚠️ BREAKING CHANGES - **Renamed AI Tools** (old → new): diff --git a/SmartHopper.sln b/SmartHopper.sln index 506d4a01c..df3558601 100644 --- a/SmartHopper.sln +++ b/SmartHopper.sln @@ -35,6 +35,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartHopper.Core.Grasshoppe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartHopper.Core.Tests", "src\SmartHopper.Core.Tests\SmartHopper.Core.Tests.csproj", "{C7E24C95-ADF6-4DBA-BDB7-73CFB1291053}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartHopper.ProviderSdk", "src\SmartHopper.ProviderSdk\SmartHopper.ProviderSdk.csproj", "{F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -224,6 +226,18 @@ Global {C7E24C95-ADF6-4DBA-BDB7-73CFB1291053}.Release|x64.Build.0 = Release|Any CPU {C7E24C95-ADF6-4DBA-BDB7-73CFB1291053}.Release|x86.ActiveCfg = Release|Any CPU {C7E24C95-ADF6-4DBA-BDB7-73CFB1291053}.Release|x86.Build.0 = Release|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Debug|x64.ActiveCfg = Debug|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Debug|x64.Build.0 = Debug|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Debug|x86.ActiveCfg = Debug|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Debug|x86.Build.0 = Debug|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Release|Any CPU.Build.0 = Release|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Release|x64.ActiveCfg = Release|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Release|x64.Build.0 = Release|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Release|x86.ActiveCfg = Release|Any CPU + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -231,4 +245,7 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0D5011CB-B808-41E4-A6FC-C01F3190649C} EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {F59F33CC-DCD6-4EEE-9766-6E3C08E8AD43} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B} + EndGlobalSection EndGlobal diff --git a/docs/Providers/ProviderManager.md b/docs/Providers/ProviderManager.md index e920acb70..94d9013ea 100644 --- a/docs/Providers/ProviderManager.md +++ b/docs/Providers/ProviderManager.md @@ -11,19 +11,29 @@ Provide a central service to load external providers (`SmartHopper.Providers.*.d ## Key features - Discovery - - Scans application directory for `SmartHopper.Providers.*.dll`. - - Instantiates `IAIProviderFactory` implementations to create providers and settings. -- Supply-chain security - - Authenticode certificate thumbprint must match host. - - Strong-name public key token must match host. - - First discovery prompts user to trust; decision persisted. + - Scans the app-local directory and `%AppData%/SmartHopper/Providers` for `SmartHopper.Providers.*.dll`. + - Each candidate is loaded into a per-provider `AssemblyLoadContext` (see `ProviderAssemblyLoader`) so private dependencies stay isolated. + - SDK type identity (`IAIProviderFactory`) is validated before activation. Mismatch → `Invalid`. + - SemVer compatibility is checked via `BuiltAgainstSdk`/`MinHostSdk` assembly attributes. +- Cryptographic classification (`ProviderClassifier`) + - `Official` — strong-name token matches host AND/OR Authenticode matches host AND/OR SHA-256 is in the published manifest, with no contradicting signal. + - `OfficialTampered` — one signal says official but another contradicts. Always blocked. + - `Community` — valid managed assembly not tied to SmartHopper. Subject to `AllowCommunityProviders` and `BlockNonOfficialProviders`. + - `Invalid` — load failure, missing factory, SDK type-identity mismatch, version incompatibility. +- Trust settings (`SmartHopperSettings`) + - `AllowCommunityProviders` (default `false`): community providers are blocked unless this is on. + - `BlockNonOfficialProviders` (default `false`): hard override that allows only `Official` providers. + - `ProviderIntegrityCheckMode` continues to govern hash-mismatch behavior for Official providers. + - `TrustedProviderRecords` — structured per-provider trust records (legacy `TrustedProviders` boolean map is migrated automatically). - Registration & initialization - - Registers provider + settings; runs `InitializeProviderAsync()` in background. + - Duplicate provider ids: Official > Community > everything else. Tampered/Invalid never win. + - `InitializeProviderAsync()` is wrapped in a 30-second per-provider timeout so a hanging provider can't block discovery. - Accessors - `GetProviders(includeUntrusted=false)` - `GetProvider(name)` (handles "Default" indirection) - `GetProviderSettings(name)`, `GetProviderAssembly(name)`, `GetProviderIcon(name)` - `GetDefaultAIProvider()` + - `GetProviderClassification(name)`, `IsProviderCommunity(name)`, `IsProviderUnsigned(name)`, `IsProviderMismatched(name)`, `IsProviderUnknown(name)`, `IsProviderUnavailable(name)`, `GetProviderTrustRecord(name)` - Settings management - `UpdateProviderSettings(name, Dictionary)` - Validates via `IAIProviderSettings.ValidateSettings`, persists via `SmartHopperSettings`, refreshes provider cache. diff --git a/docs/Providers/ProviderSdk.md b/docs/Providers/ProviderSdk.md new file mode 100644 index 000000000..dfe9ce361 --- /dev/null +++ b/docs/Providers/ProviderSdk.md @@ -0,0 +1,85 @@ +# SmartHopper Provider SDK + +The Provider SDK (`SmartHopper.ProviderSdk`) is a standalone, MIT-licensed assembly that exposes the contracts, base classes, and DTOs a community AI provider needs to integrate with SmartHopper. Provider authors can build against this SDK on a clean machine without cloning or building the rest of the SmartHopper repo. + +## What the SDK contains + +The SDK is **API-connection only**: + +- **Contracts** — `IAIProvider`, `IAIProviderFactory`, `IAIProviderSettings`, `IAIProviderModels`. +- **Base classes** — `AIProvider`, `AIProvider`, `AIProviderSettings`, `AIProviderModels`, `AIProviderStreamingAdapter`. +- **Request / response DTOs** — `AICall.Core.{Base, Interactions, Requests, Returns}`, `AICall.Metrics`, minimal `AICall.JsonSchemas` types referenced by request bodies. +- **Model capabilities** — `AIModels.*`, `AIExtraDescriptor`, `AIModelCapabilityRegistry` singleton. +- **Settings descriptors** — `SettingDescriptor`, secret flags, validation result types. +- **Streaming** — `IStreamingAdapter` and provider-facing delta/result types. +- **Tool DTOs** — structures required to encode/decode tool calls and tool results inside a provider response (no `ToolManager`, no tool registration). +- **Compatibility metadata** — `SmartHopperProviderSdkVersionAttribute`, `BuiltAgainstSdkAttribute`, `MinHostSdkAttribute`, `SmartHopperProviderIdAttribute`. + +## What is NOT in the SDK + +These types stay host-side in `SmartHopper.Infrastructure` and the rest of the application: + +- `ProviderManager`, `ProviderHashVerifier`, `ProviderClassifier`, trust dialogs, signature/hash policy, `SmartHopperSettings` persistence, secret storage. +- `AICall.{Policies, Sessions, Validation, Execution, Batch}`. +- `AITools.*` (`ToolManager`, `IAIToolProvider`). +- Rhino/Eto UI, WebChat, badges. + +## Target frameworks + +- `net7.0` (cross-platform; macOS-friendly) +- `net7.0-windows` (Windows-specific surface) + +## License + +The SDK is licensed under **MIT**. SmartHopper itself remains LGPLv3. The permissive license on the SDK lets closed-source community providers link against it without taking on LGPL obligations on their own assemblies. + +## Naming convention + +Provider assemblies discovered at runtime must match `SmartHopper.Providers.*.dll`. SmartHopper scans: + +1. The app-local directory (next to `SmartHopper.Infrastructure.dll`). +2. `%AppData%/SmartHopper/Providers` (Windows) or the platform equivalent under the user's application data folder. + +App-local providers win on duplicate-id conflicts (see plan §2.2). + +## Minimal provider + +```csharp +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; + +[assembly: SmartHopper.ProviderSdk.Metadata.BuiltAgainstSdk("1.0.0")] +[assembly: SmartHopper.ProviderSdk.Metadata.MinHostSdk("1.0.0")] +[assembly: SmartHopper.ProviderSdk.Metadata.SmartHopperProviderId("my-provider")] + +public sealed class MyProviderFactory : IAIProviderFactory +{ + public IAIProvider CreateProvider() => new MyProvider(); + public IAIProviderSettings CreateProviderSettings() => new MyProviderSettings(); +} +``` + +The host instantiates the factory through an isolated `AssemblyLoadContext` so private dependencies of the provider don't leak into the rest of the SmartHopper process. + +## SemVer & compatibility + +- The SDK uses Semantic Versioning. `MAJOR` is reserved for breaking provider contract changes. +- Providers declare both `BuiltAgainstSdk` and `MinHostSdk` via assembly attributes. +- At load time the host enforces `BuiltAgainstSdk.MAJOR == HostSdk.MAJOR` and `HostSdk >= provider.MinHostSdk`. Mismatches classify the provider as `Invalid` and block it with a clear diagnostic. +- Two host majors cannot coexist in one Rhino process and this is documented as unsupported. + +## Trust model + +Community providers (those not cryptographically attributable to SmartHopper) are only loaded when: + +1. `AllowCommunityProviders = true` in `SmartHopperSettings.json`, and +2. `BlockNonOfficialProviders = false`, and +3. The user accepts the per-provider trust prompt the first time a given community DLL is discovered. + +The classification is purely cryptographic — strong-name token + Authenticode (Windows) + the SmartHopper hash manifest. File names and provider ids cannot reach `Official` without one of those signals. + +Community/unsigned providers surface warning runtime messages on every AI component that uses them. + +## Threat notes + +Trusting a community provider grants it full SmartHopper process privileges. The SDK does not sandbox provider code. Community providers can read other providers' settings only through the `IProviderSettingsStore` abstraction, which scopes access by provider id. diff --git a/docs/Providers/index.md b/docs/Providers/index.md index 21f2461eb..2df71f29f 100644 --- a/docs/Providers/index.md +++ b/docs/Providers/index.md @@ -24,8 +24,11 @@ Providers implement API-specific logic while conforming to a common contract so ## Security -- Signature verification before load, trusted providers tracked in settings. -- Secrets stored using OS secure mechanisms; no hardcoded keys. +- **Cryptographic classification** — providers are classified as `Official`, `OfficialTampered`, `Community`, or `Invalid` based purely on strong-name token, Authenticode signature (Windows), and SHA-256 manifest. Names and provider ids never affect classification. +- **Trust gates** — community providers are blocked unless `AllowCommunityProviders=true`. The global `BlockNonOfficialProviders=true` switch overrides everything to allow Official providers only. +- **Per-provider trust** — first-time discovery of an allowed community provider triggers a trust prompt. Trust is invalidated automatically if the file's SHA-256 changes. +- **Visible warnings** — every AI component using a community/unsigned/unverified provider receives a runtime warning message in Grasshopper. +- **Secrets** — stored using OS secure mechanisms (DPAPI on Windows, Keychain on macOS); no hardcoded keys. Provider code is scoped to its own keys via `IProviderSettingsStore`. ## Extensibility @@ -35,6 +38,7 @@ Providers implement API-specific logic while conforming to a common contract so ## Detailed docs +- [Provider SDK (community-facing)](./ProviderSdk.md) - [ProviderManager](./ProviderManager.md) - [IAIProvider](./IAIProvider.md) - [AIProvider](./AIProvider.md) diff --git a/samples/SmartHopper.Providers.Sample/README.md b/samples/SmartHopper.Providers.Sample/README.md new file mode 100644 index 000000000..35e53b011 --- /dev/null +++ b/samples/SmartHopper.Providers.Sample/README.md @@ -0,0 +1,34 @@ +# SmartHopper Provider SDK — Sample scaffolding + +This directory contains a starter csproj that builds a SmartHopper community provider against the `SmartHopper.ProviderSdk` package only — no SmartHopper host references required. + +## Layout + +``` +samples/ +└── SmartHopper.Providers.Sample/ + ├── SmartHopper.Providers.Sample.csproj # references SmartHopper.ProviderSdk + └── README.md # this file +``` + +To turn this into a working provider: + +1. Add a class deriving from `SmartHopper.ProviderSdk.AIProviders.AIProvider` (or `AIProvider` for typed responses). +2. Add an `IAIProviderFactory` implementation that returns instances of your provider and its settings. +3. Add an `IAIProviderSettings` subclass with descriptors for API key, model id, etc. +4. Decorate the assembly with: + ```csharp + [assembly: SmartHopper.ProviderSdk.Metadata.BuiltAgainstSdk("1.0.0")] + [assembly: SmartHopper.ProviderSdk.Metadata.MinHostSdk("1.0.0")] + [assembly: SmartHopper.ProviderSdk.Metadata.SmartHopperProviderId("my-provider")] + ``` +5. Build, copy the resulting `SmartHopper.Providers.MyProvider.dll` into either: + - the SmartHopper app-local directory (next to `SmartHopper.Infrastructure.dll`), or + - `%AppData%/SmartHopper/Providers` on Windows (platform equivalent elsewhere). +6. In SmartHopper settings, enable `AllowCommunityProviders` and accept the per-provider trust prompt. + +For full reference docs, see [docs/Providers/ProviderSdk.md](../../docs/Providers/ProviderSdk.md) and the in-tree providers under `src/SmartHopper.Providers.*` for working examples. + +## License + +Sample code is licensed under MIT, matching the SDK itself. SmartHopper host code remains under LGPLv3. diff --git a/samples/SmartHopper.Providers.Sample/SmartHopper.Providers.Sample.csproj b/samples/SmartHopper.Providers.Sample/SmartHopper.Providers.Sample.csproj new file mode 100644 index 000000000..2da4c3634 --- /dev/null +++ b/samples/SmartHopper.Providers.Sample/SmartHopper.Providers.Sample.csproj @@ -0,0 +1,32 @@ + + + + + net7.0;net7.0-windows + SmartHopper.Providers.Sample + SmartHopper.Providers.Sample + enable + latest + true + true + true + CS1591;NU1701 + + + + + + + + diff --git a/src/SmartHopper.Components.Test/Providers/TestAnthropicBatchCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestAnthropicBatchCallComponent.cs index be50e1cf6..2fcea0f1b 100644 --- a/src/SmartHopper.Components.Test/Providers/TestAnthropicBatchCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestAnthropicBatchCallComponent.cs @@ -24,11 +24,11 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestAnthropicDecodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestAnthropicDecodeComponent.cs index f9f9dcdd2..2a2397cfc 100644 --- a/src/SmartHopper.Components.Test/Providers/TestAnthropicDecodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestAnthropicDecodeComponent.cs @@ -25,8 +25,8 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Providers.Anthropic; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestAnthropicEncodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestAnthropicEncodeComponent.cs index 436d5ca86..85d22d0c3 100644 --- a/src/SmartHopper.Components.Test/Providers/TestAnthropicEncodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestAnthropicEncodeComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestAnthropicStandardCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestAnthropicStandardCallComponent.cs index 5ac9b28e7..07e708e7c 100644 --- a/src/SmartHopper.Components.Test/Providers/TestAnthropicStandardCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestAnthropicStandardCallComponent.cs @@ -25,10 +25,10 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestAnthropicToolsComponent.cs b/src/SmartHopper.Components.Test/Providers/TestAnthropicToolsComponent.cs index 7a5a32ea4..355a802dc 100644 --- a/src/SmartHopper.Components.Test/Providers/TestAnthropicToolsComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestAnthropicToolsComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestAnthropicVisionComponent.cs b/src/SmartHopper.Components.Test/Providers/TestAnthropicVisionComponent.cs index aa286c4f2..69d9ddeaf 100644 --- a/src/SmartHopper.Components.Test/Providers/TestAnthropicVisionComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestAnthropicVisionComponent.cs @@ -24,11 +24,12 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.Anthropic; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestDeepSeekBatchCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestDeepSeekBatchCallComponent.cs index 552cad1f3..6f60b1390 100644 --- a/src/SmartHopper.Components.Test/Providers/TestDeepSeekBatchCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestDeepSeekBatchCallComponent.cs @@ -24,11 +24,11 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestDeepSeekDecodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestDeepSeekDecodeComponent.cs index b36e17c26..794a9d793 100644 --- a/src/SmartHopper.Components.Test/Providers/TestDeepSeekDecodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestDeepSeekDecodeComponent.cs @@ -25,9 +25,10 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.DeepSeek; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestDeepSeekEncodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestDeepSeekEncodeComponent.cs index 3ee906c79..ab53b4ddd 100644 --- a/src/SmartHopper.Components.Test/Providers/TestDeepSeekEncodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestDeepSeekEncodeComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestDeepSeekStandardCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestDeepSeekStandardCallComponent.cs index 985187747..cb811e676 100644 --- a/src/SmartHopper.Components.Test/Providers/TestDeepSeekStandardCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestDeepSeekStandardCallComponent.cs @@ -24,10 +24,10 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestDeepSeekToolsComponent.cs b/src/SmartHopper.Components.Test/Providers/TestDeepSeekToolsComponent.cs index 196c71e1b..16642f7d8 100644 --- a/src/SmartHopper.Components.Test/Providers/TestDeepSeekToolsComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestDeepSeekToolsComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestDeepSeekVisionComponent.cs b/src/SmartHopper.Components.Test/Providers/TestDeepSeekVisionComponent.cs index 5636f2686..e4fa138f5 100644 --- a/src/SmartHopper.Components.Test/Providers/TestDeepSeekVisionComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestDeepSeekVisionComponent.cs @@ -24,11 +24,12 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.DeepSeek; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestGeminiBatchCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestGeminiBatchCallComponent.cs index 7c9dad482..53b37a966 100644 --- a/src/SmartHopper.Components.Test/Providers/TestGeminiBatchCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestGeminiBatchCallComponent.cs @@ -24,11 +24,11 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestGeminiDecodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestGeminiDecodeComponent.cs index 681867b6c..7232f54c4 100644 --- a/src/SmartHopper.Components.Test/Providers/TestGeminiDecodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestGeminiDecodeComponent.cs @@ -25,9 +25,10 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.Gemini; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestGeminiEncodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestGeminiEncodeComponent.cs index 67b379755..baf38ace7 100644 --- a/src/SmartHopper.Components.Test/Providers/TestGeminiEncodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestGeminiEncodeComponent.cs @@ -24,11 +24,12 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestGeminiFunctionCallingComponent.cs b/src/SmartHopper.Components.Test/Providers/TestGeminiFunctionCallingComponent.cs index f6443c764..e512b5838 100644 --- a/src/SmartHopper.Components.Test/Providers/TestGeminiFunctionCallingComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestGeminiFunctionCallingComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestGeminiStandardCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestGeminiStandardCallComponent.cs index d880ab2a1..9240fe0fb 100644 --- a/src/SmartHopper.Components.Test/Providers/TestGeminiStandardCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestGeminiStandardCallComponent.cs @@ -26,11 +26,12 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestGeminiVisionComponent.cs b/src/SmartHopper.Components.Test/Providers/TestGeminiVisionComponent.cs index b6f2e311c..23d264beb 100644 --- a/src/SmartHopper.Components.Test/Providers/TestGeminiVisionComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestGeminiVisionComponent.cs @@ -24,11 +24,12 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.Gemini; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestMistralAIBatchCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestMistralAIBatchCallComponent.cs index 3efb65de8..db7ebeee5 100644 --- a/src/SmartHopper.Components.Test/Providers/TestMistralAIBatchCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestMistralAIBatchCallComponent.cs @@ -26,12 +26,13 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestMistralAIDecodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestMistralAIDecodeComponent.cs index cba550e1a..513700e8e 100644 --- a/src/SmartHopper.Components.Test/Providers/TestMistralAIDecodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestMistralAIDecodeComponent.cs @@ -25,9 +25,10 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.MistralAI; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestMistralAIEncodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestMistralAIEncodeComponent.cs index 92a569ca9..6fc55fea4 100644 --- a/src/SmartHopper.Components.Test/Providers/TestMistralAIEncodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestMistralAIEncodeComponent.cs @@ -24,11 +24,12 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestMistralAIStandardCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestMistralAIStandardCallComponent.cs index 124704de8..cec8f2f60 100644 --- a/src/SmartHopper.Components.Test/Providers/TestMistralAIStandardCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestMistralAIStandardCallComponent.cs @@ -25,11 +25,12 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestMistralAIToolsComponent.cs b/src/SmartHopper.Components.Test/Providers/TestMistralAIToolsComponent.cs index d1b6b7a96..0d8a57e72 100644 --- a/src/SmartHopper.Components.Test/Providers/TestMistralAIToolsComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestMistralAIToolsComponent.cs @@ -24,11 +24,12 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenAIBatchCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenAIBatchCallComponent.cs index 07c2da123..4822a6b2c 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenAIBatchCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenAIBatchCallComponent.cs @@ -25,12 +25,13 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenAIDecodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenAIDecodeComponent.cs index 5a425f8f5..83e394e7e 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenAIDecodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenAIDecodeComponent.cs @@ -25,9 +25,10 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenAIEncodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenAIEncodeComponent.cs index 2979b3b3d..2051d32ff 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenAIEncodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenAIEncodeComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenAIStandardCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenAIStandardCallComponent.cs index 0d0516c37..3aa7b0648 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenAIStandardCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenAIStandardCallComponent.cs @@ -25,11 +25,12 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenAIToolsComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenAIToolsComponent.cs index 37a821db9..bb13b67b6 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenAIToolsComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenAIToolsComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenRouterBatchCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenRouterBatchCallComponent.cs index 1440ba914..a73651676 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenRouterBatchCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenRouterBatchCallComponent.cs @@ -24,11 +24,11 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenRouterDecodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenRouterDecodeComponent.cs index 4037c6fa0..d4f31b726 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenRouterDecodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenRouterDecodeComponent.cs @@ -25,9 +25,10 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.OpenRouter; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenRouterEncodeComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenRouterEncodeComponent.cs index e1208f407..764c717a2 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenRouterEncodeComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenRouterEncodeComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenRouterStandardCallComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenRouterStandardCallComponent.cs index cc459f261..c6d6816f1 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenRouterStandardCallComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenRouterStandardCallComponent.cs @@ -25,10 +25,10 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenRouterToolsComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenRouterToolsComponent.cs index 053a99699..998cc7869 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenRouterToolsComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenRouterToolsComponent.cs @@ -24,9 +24,9 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components.Test/Providers/TestOpenRouterVisionComponent.cs b/src/SmartHopper.Components.Test/Providers/TestOpenRouterVisionComponent.cs index ff0e12e5d..bd98c4866 100644 --- a/src/SmartHopper.Components.Test/Providers/TestOpenRouterVisionComponent.cs +++ b/src/SmartHopper.Components.Test/Providers/TestOpenRouterVisionComponent.cs @@ -24,11 +24,12 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.OpenRouter; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.Test.Providers { diff --git a/src/SmartHopper.Components/AI/AIChatComponent.cs b/src/SmartHopper.Components/AI/AIChatComponent.cs index 792f00583..19c234d34 100644 --- a/src/SmartHopper.Components/AI/AIChatComponent.cs +++ b/src/SmartHopper.Components/AI/AIChatComponent.cs @@ -31,9 +31,9 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.UI.Chat; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Components.AI { diff --git a/src/SmartHopper.Components/AI/AIExtraSettingsComponent.cs b/src/SmartHopper.Components/AI/AIExtraSettingsComponent.cs index 6c96907ef..087dae3d8 100644 --- a/src/SmartHopper.Components/AI/AIExtraSettingsComponent.cs +++ b/src/SmartHopper.Components/AI/AIExtraSettingsComponent.cs @@ -29,6 +29,7 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.AI { diff --git a/src/SmartHopper.Components/AI/AIModelsComponent.cs b/src/SmartHopper.Components/AI/AIModelsComponent.cs index 4077435be..d91a39a8c 100644 --- a/src/SmartHopper.Components/AI/AIModelsComponent.cs +++ b/src/SmartHopper.Components/AI/AIModelsComponent.cs @@ -29,7 +29,7 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.ComponentBase.Contracts; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Components.AI { diff --git a/src/SmartHopper.Components/AI/AISettingsComponent.cs b/src/SmartHopper.Components/AI/AISettingsComponent.cs index c9fdd9c7b..1aa56ceb5 100644 --- a/src/SmartHopper.Components/AI/AISettingsComponent.cs +++ b/src/SmartHopper.Components/AI/AISettingsComponent.cs @@ -29,8 +29,9 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Components.AI { diff --git a/src/SmartHopper.Components/Grasshopper/GhGetComponents.cs b/src/SmartHopper.Components/Grasshopper/GhGetComponents.cs index 1f34f0332..884ed0558 100644 --- a/src/SmartHopper.Components/Grasshopper/GhGetComponents.cs +++ b/src/SmartHopper.Components/Grasshopper/GhGetComponents.cs @@ -31,10 +31,10 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Grasshopper { diff --git a/src/SmartHopper.Components/Grasshopper/GhMergeComponents.cs b/src/SmartHopper.Components/Grasshopper/GhMergeComponents.cs index 0f6fcaf3e..fe44c34a4 100644 --- a/src/SmartHopper.Components/Grasshopper/GhMergeComponents.cs +++ b/src/SmartHopper.Components/Grasshopper/GhMergeComponents.cs @@ -21,9 +21,9 @@ using Grasshopper.Kernel; using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AICall.Tools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Grasshopper { diff --git a/src/SmartHopper.Components/Grasshopper/GhPutComponents.cs b/src/SmartHopper.Components/Grasshopper/GhPutComponents.cs index 9ab2d914f..87723f76f 100644 --- a/src/SmartHopper.Components/Grasshopper/GhPutComponents.cs +++ b/src/SmartHopper.Components/Grasshopper/GhPutComponents.cs @@ -27,9 +27,9 @@ using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AICall.Tools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Grasshopper { diff --git a/src/SmartHopper.Components/Grasshopper/GhRetrieveComponents.cs b/src/SmartHopper.Components/Grasshopper/GhRetrieveComponents.cs index 48bbcee1f..2446e720a 100644 --- a/src/SmartHopper.Components/Grasshopper/GhRetrieveComponents.cs +++ b/src/SmartHopper.Components/Grasshopper/GhRetrieveComponents.cs @@ -22,9 +22,9 @@ using Grasshopper.Kernel; using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AICall.Tools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Grasshopper { diff --git a/src/SmartHopper.Components/Grasshopper/GhTidyUpComponents.cs b/src/SmartHopper.Components/Grasshopper/GhTidyUpComponents.cs index 84da32032..5c0a09f9d 100644 --- a/src/SmartHopper.Components/Grasshopper/GhTidyUpComponents.cs +++ b/src/SmartHopper.Components/Grasshopper/GhTidyUpComponents.cs @@ -26,10 +26,10 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Grasshopper { diff --git a/src/SmartHopper.Components/Img/AIImg2TextComponent.cs b/src/SmartHopper.Components/Img/AIImg2TextComponent.cs index 9e8cb587b..825435847 100644 --- a/src/SmartHopper.Components/Img/AIImg2TextComponent.cs +++ b/src/SmartHopper.Components/Img/AIImg2TextComponent.cs @@ -33,11 +33,12 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Img { diff --git a/src/SmartHopper.Components/Input/AIPromptComponent.cs b/src/SmartHopper.Components/Input/AIPromptComponent.cs index 3ea79931d..4573b0c0d 100644 --- a/src/SmartHopper.Components/Input/AIPromptComponent.cs +++ b/src/SmartHopper.Components/Input/AIPromptComponent.cs @@ -23,8 +23,8 @@ using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/Audio2AIComponent.cs b/src/SmartHopper.Components/Input/Audio2AIComponent.cs index b6219b973..de8b006f7 100644 --- a/src/SmartHopper.Components/Input/Audio2AIComponent.cs +++ b/src/SmartHopper.Components/Input/Audio2AIComponent.cs @@ -24,7 +24,7 @@ using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/DiscoursePost2AIComponent.cs b/src/SmartHopper.Components/Input/DiscoursePost2AIComponent.cs index db94f06cf..712c5378a 100644 --- a/src/SmartHopper.Components/Input/DiscoursePost2AIComponent.cs +++ b/src/SmartHopper.Components/Input/DiscoursePost2AIComponent.cs @@ -32,11 +32,11 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/DiscourseTopic2AIComponent.cs b/src/SmartHopper.Components/Input/DiscourseTopic2AIComponent.cs index e6956a4ee..a9a663d49 100644 --- a/src/SmartHopper.Components/Input/DiscourseTopic2AIComponent.cs +++ b/src/SmartHopper.Components/Input/DiscourseTopic2AIComponent.cs @@ -32,11 +32,11 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/File2AIComponent.cs b/src/SmartHopper.Components/Input/File2AIComponent.cs index 1dd1c1d1d..f4b1b82f4 100644 --- a/src/SmartHopper.Components/Input/File2AIComponent.cs +++ b/src/SmartHopper.Components/Input/File2AIComponent.cs @@ -33,12 +33,13 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Input { @@ -268,7 +269,7 @@ private async Task>> ProcessBranches(Dictionary payload = AIInputPayload.FromText(markdown); } - var toolMessages = RuntimeMessageUtility.ExtractMessages(toolResult); + var toolMessages = ToolCallResultRuntimeMessageExtensions.ExtractMessages(toolResult); foreach (var m in toolMessages) this.CollectMessage(m); outputs["Input >"].Add(new GH_AIInputPayload(payload)); diff --git a/src/SmartHopper.Components/Input/GhJSON2AIComponent.cs b/src/SmartHopper.Components/Input/GhJSON2AIComponent.cs index 4891ff527..529a14ca1 100644 --- a/src/SmartHopper.Components/Input/GhJSON2AIComponent.cs +++ b/src/SmartHopper.Components/Input/GhJSON2AIComponent.cs @@ -28,10 +28,10 @@ using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/LadybugPost2AIComponent.cs b/src/SmartHopper.Components/Input/LadybugPost2AIComponent.cs index 16b650f25..6e7e6d6bf 100644 --- a/src/SmartHopper.Components/Input/LadybugPost2AIComponent.cs +++ b/src/SmartHopper.Components/Input/LadybugPost2AIComponent.cs @@ -32,11 +32,11 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/LadybugTopic2AIComponent.cs b/src/SmartHopper.Components/Input/LadybugTopic2AIComponent.cs index 60aaba8db..101d0eae5 100644 --- a/src/SmartHopper.Components/Input/LadybugTopic2AIComponent.cs +++ b/src/SmartHopper.Components/Input/LadybugTopic2AIComponent.cs @@ -32,11 +32,11 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/McNeelPost2AIComponent.cs b/src/SmartHopper.Components/Input/McNeelPost2AIComponent.cs index e163d1805..414628930 100644 --- a/src/SmartHopper.Components/Input/McNeelPost2AIComponent.cs +++ b/src/SmartHopper.Components/Input/McNeelPost2AIComponent.cs @@ -32,11 +32,11 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/McNeelTopic2AIComponent.cs b/src/SmartHopper.Components/Input/McNeelTopic2AIComponent.cs index f55bbb9e0..6d4a99ec7 100644 --- a/src/SmartHopper.Components/Input/McNeelTopic2AIComponent.cs +++ b/src/SmartHopper.Components/Input/McNeelTopic2AIComponent.cs @@ -32,11 +32,11 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Input { diff --git a/src/SmartHopper.Components/Input/Web2AIComponent.cs b/src/SmartHopper.Components/Input/Web2AIComponent.cs index a4f82f8c6..47f014796 100644 --- a/src/SmartHopper.Components/Input/Web2AIComponent.cs +++ b/src/SmartHopper.Components/Input/Web2AIComponent.cs @@ -32,12 +32,13 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Input { @@ -211,7 +212,7 @@ private async Task>> ProcessBranches(Dictionary } // Extract and collect any messages from tool result - var toolMessages = RuntimeMessageUtility.ExtractMessages(toolResult); + var toolMessages = ToolCallResultRuntimeMessageExtensions.ExtractMessages(toolResult); foreach (var m in toolMessages) this.CollectMessage(m); outputs["Input >"].Add(new GH_AIInputPayload(payload)); diff --git a/src/SmartHopper.Components/JSON/AIText2JsonComponent.cs b/src/SmartHopper.Components/JSON/AIText2JsonComponent.cs index 3a7b0a8f9..82bdfba3f 100644 --- a/src/SmartHopper.Components/JSON/AIText2JsonComponent.cs +++ b/src/SmartHopper.Components/JSON/AIText2JsonComponent.cs @@ -31,12 +31,13 @@ using SmartHopper.Core.ComponentBase; using SmartHopper.Core.ComponentBase.Batch; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Components.JSON { diff --git a/src/SmartHopper.Components/JSON/JsonGetValueComponent.cs b/src/SmartHopper.Components/JSON/JsonGetValueComponent.cs index 91cb91db9..12be10315 100644 --- a/src/SmartHopper.Components/JSON/JsonGetValueComponent.cs +++ b/src/SmartHopper.Components/JSON/JsonGetValueComponent.cs @@ -21,7 +21,7 @@ using Grasshopper.Kernel; using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Components.JSON { diff --git a/src/SmartHopper.Components/JSON/JsonMergeComponent.cs b/src/SmartHopper.Components/JSON/JsonMergeComponent.cs index 4aa78aa16..542ee313d 100644 --- a/src/SmartHopper.Components/JSON/JsonMergeComponent.cs +++ b/src/SmartHopper.Components/JSON/JsonMergeComponent.cs @@ -22,7 +22,7 @@ using Grasshopper.Kernel; using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Components.JSON { diff --git a/src/SmartHopper.Components/JSON/JsonObjectComponent.cs b/src/SmartHopper.Components/JSON/JsonObjectComponent.cs index 7aba7725a..3d29e711b 100644 --- a/src/SmartHopper.Components/JSON/JsonObjectComponent.cs +++ b/src/SmartHopper.Components/JSON/JsonObjectComponent.cs @@ -23,7 +23,7 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Components.JSON { diff --git a/src/SmartHopper.Components/JSON/JsonSanitizerComponent.cs b/src/SmartHopper.Components/JSON/JsonSanitizerComponent.cs index b8597a210..6d1bae7af 100644 --- a/src/SmartHopper.Components/JSON/JsonSanitizerComponent.cs +++ b/src/SmartHopper.Components/JSON/JsonSanitizerComponent.cs @@ -24,7 +24,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Components.JSON { diff --git a/src/SmartHopper.Components/JSON/JsonSchemaComponent.cs b/src/SmartHopper.Components/JSON/JsonSchemaComponent.cs index 5fedbda09..f5d74fc51 100644 --- a/src/SmartHopper.Components/JSON/JsonSchemaComponent.cs +++ b/src/SmartHopper.Components/JSON/JsonSchemaComponent.cs @@ -24,7 +24,7 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Components.JSON { diff --git a/src/SmartHopper.Components/Knowledge/AIFile2MdComponent.cs b/src/SmartHopper.Components/Knowledge/AIFile2MdComponent.cs index 921ccffef..4008ceccd 100644 --- a/src/SmartHopper.Components/Knowledge/AIFile2MdComponent.cs +++ b/src/SmartHopper.Components/Knowledge/AIFile2MdComponent.cs @@ -33,12 +33,14 @@ using SmartHopper.Core.ComponentBase.Batch; using SmartHopper.Core.DataTree; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Metrics; using SmartHopper.Infrastructure.AICall.Utilities; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { @@ -610,7 +612,7 @@ public override async Task DoWorkAsync(CancellationToken token) } } - var localMessages = RuntimeMessageUtility.ExtractMessages(localResult); + var localMessages = ToolCallResultRuntimeMessageExtensions.ExtractMessages(localResult); foreach (var m in localMessages) { this.CollectMessage(m); diff --git a/src/SmartHopper.Components/Knowledge/DiscoursePostGetComponent.cs b/src/SmartHopper.Components/Knowledge/DiscoursePostGetComponent.cs index d3f849cbd..2f2ea455b 100644 --- a/src/SmartHopper.Components/Knowledge/DiscoursePostGetComponent.cs +++ b/src/SmartHopper.Components/Knowledge/DiscoursePostGetComponent.cs @@ -29,11 +29,11 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/DiscoursePostOpenComponent.cs b/src/SmartHopper.Components/Knowledge/DiscoursePostOpenComponent.cs index 63419756b..2da3a0abc 100644 --- a/src/SmartHopper.Components/Knowledge/DiscoursePostOpenComponent.cs +++ b/src/SmartHopper.Components/Knowledge/DiscoursePostOpenComponent.cs @@ -25,7 +25,7 @@ using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/DiscourseSearchComponent.cs b/src/SmartHopper.Components/Knowledge/DiscourseSearchComponent.cs index 53aee2cb5..d1e2d4996 100644 --- a/src/SmartHopper.Components/Knowledge/DiscourseSearchComponent.cs +++ b/src/SmartHopper.Components/Knowledge/DiscourseSearchComponent.cs @@ -29,11 +29,11 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/File2MdComponent.cs b/src/SmartHopper.Components/Knowledge/File2MdComponent.cs index c0f7c8485..160ef7290 100644 --- a/src/SmartHopper.Components/Knowledge/File2MdComponent.cs +++ b/src/SmartHopper.Components/Knowledge/File2MdComponent.cs @@ -32,11 +32,11 @@ using SmartHopper.Core.Models; using SmartHopper.Core.Parameters; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/LadybugForumPostGetComponent.cs b/src/SmartHopper.Components/Knowledge/LadybugForumPostGetComponent.cs index dc6903d2b..233b79a40 100644 --- a/src/SmartHopper.Components/Knowledge/LadybugForumPostGetComponent.cs +++ b/src/SmartHopper.Components/Knowledge/LadybugForumPostGetComponent.cs @@ -29,11 +29,11 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/LadybugForumPostOpenComponent.cs b/src/SmartHopper.Components/Knowledge/LadybugForumPostOpenComponent.cs index 4bea11237..7a8f094f7 100644 --- a/src/SmartHopper.Components/Knowledge/LadybugForumPostOpenComponent.cs +++ b/src/SmartHopper.Components/Knowledge/LadybugForumPostOpenComponent.cs @@ -25,7 +25,7 @@ using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/LadybugForumSearchComponent.cs b/src/SmartHopper.Components/Knowledge/LadybugForumSearchComponent.cs index d18779f8d..375367784 100644 --- a/src/SmartHopper.Components/Knowledge/LadybugForumSearchComponent.cs +++ b/src/SmartHopper.Components/Knowledge/LadybugForumSearchComponent.cs @@ -29,11 +29,11 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/McNeelForumPostGetComponent.cs b/src/SmartHopper.Components/Knowledge/McNeelForumPostGetComponent.cs index ed0cc2d87..09e67746d 100644 --- a/src/SmartHopper.Components/Knowledge/McNeelForumPostGetComponent.cs +++ b/src/SmartHopper.Components/Knowledge/McNeelForumPostGetComponent.cs @@ -29,11 +29,11 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/McNeelForumPostOpenComponent.cs b/src/SmartHopper.Components/Knowledge/McNeelForumPostOpenComponent.cs index 3fd2e1d8c..d58e912ce 100644 --- a/src/SmartHopper.Components/Knowledge/McNeelForumPostOpenComponent.cs +++ b/src/SmartHopper.Components/Knowledge/McNeelForumPostOpenComponent.cs @@ -25,7 +25,7 @@ using Newtonsoft.Json.Linq; using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/McNeelForumSearchComponent.cs b/src/SmartHopper.Components/Knowledge/McNeelForumSearchComponent.cs index 4189ee20e..a79b9e1e1 100644 --- a/src/SmartHopper.Components/Knowledge/McNeelForumSearchComponent.cs +++ b/src/SmartHopper.Components/Knowledge/McNeelForumSearchComponent.cs @@ -29,11 +29,11 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { diff --git a/src/SmartHopper.Components/Knowledge/Web2MdComponent.cs b/src/SmartHopper.Components/Knowledge/Web2MdComponent.cs index e1d52ef85..868fd293d 100644 --- a/src/SmartHopper.Components/Knowledge/Web2MdComponent.cs +++ b/src/SmartHopper.Components/Knowledge/Web2MdComponent.cs @@ -30,12 +30,13 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Knowledge { @@ -210,7 +211,7 @@ public override async Task DoWorkAsync(CancellationToken token) outputs["Format"].Add(new GH_String(format)); // Extract and collect any messages from tool result - var toolMessages = RuntimeMessageUtility.ExtractMessages(toolResult); + var toolMessages = ToolCallResultRuntimeMessageExtensions.ExtractMessages(toolResult); foreach (var m in toolMessages) this.CollectMessage(m); } } diff --git a/src/SmartHopper.Components/List/AIList2BooleanComponent.cs b/src/SmartHopper.Components/List/AIList2BooleanComponent.cs index ea37d6b7b..c649e1042 100644 --- a/src/SmartHopper.Components/List/AIList2BooleanComponent.cs +++ b/src/SmartHopper.Components/List/AIList2BooleanComponent.cs @@ -34,10 +34,11 @@ using SmartHopper.Core.Grasshopper.Converters; using SmartHopper.Core.Grasshopper.Utils; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.List { diff --git a/src/SmartHopper.Components/List/AIListFilter.cs b/src/SmartHopper.Components/List/AIListFilter.cs index 69e73b6c0..e3a851413 100644 --- a/src/SmartHopper.Components/List/AIListFilter.cs +++ b/src/SmartHopper.Components/List/AIListFilter.cs @@ -31,7 +31,7 @@ using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.List { diff --git a/src/SmartHopper.Components/Output/AI2BooleanComponent.cs b/src/SmartHopper.Components/Output/AI2BooleanComponent.cs index 2d490751a..30ee288db 100644 --- a/src/SmartHopper.Components/Output/AI2BooleanComponent.cs +++ b/src/SmartHopper.Components/Output/AI2BooleanComponent.cs @@ -24,7 +24,7 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2BooleanListComponent.cs b/src/SmartHopper.Components/Output/AI2BooleanListComponent.cs index 45f9b147f..61772cdd4 100644 --- a/src/SmartHopper.Components/Output/AI2BooleanListComponent.cs +++ b/src/SmartHopper.Components/Output/AI2BooleanListComponent.cs @@ -25,8 +25,8 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2GhJsonComponent.cs b/src/SmartHopper.Components/Output/AI2GhJsonComponent.cs index 2c28dadc4..dd8a28a96 100644 --- a/src/SmartHopper.Components/Output/AI2GhJsonComponent.cs +++ b/src/SmartHopper.Components/Output/AI2GhJsonComponent.cs @@ -24,8 +24,8 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2ImgComponent.cs b/src/SmartHopper.Components/Output/AI2ImgComponent.cs index e6c8010b5..c3f586330 100644 --- a/src/SmartHopper.Components/Output/AI2ImgComponent.cs +++ b/src/SmartHopper.Components/Output/AI2ImgComponent.cs @@ -25,7 +25,7 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2IntegerComponent.cs b/src/SmartHopper.Components/Output/AI2IntegerComponent.cs index ea3664094..158d84679 100644 --- a/src/SmartHopper.Components/Output/AI2IntegerComponent.cs +++ b/src/SmartHopper.Components/Output/AI2IntegerComponent.cs @@ -24,7 +24,7 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2IntegerListComponent.cs b/src/SmartHopper.Components/Output/AI2IntegerListComponent.cs index a7314109b..cab2031d2 100644 --- a/src/SmartHopper.Components/Output/AI2IntegerListComponent.cs +++ b/src/SmartHopper.Components/Output/AI2IntegerListComponent.cs @@ -25,8 +25,8 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2JsonComponent.cs b/src/SmartHopper.Components/Output/AI2JsonComponent.cs index 877e703de..b2bc1f8fa 100644 --- a/src/SmartHopper.Components/Output/AI2JsonComponent.cs +++ b/src/SmartHopper.Components/Output/AI2JsonComponent.cs @@ -26,7 +26,7 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2MarkdownComponent.cs b/src/SmartHopper.Components/Output/AI2MarkdownComponent.cs index 7ac6263b6..974a73848 100644 --- a/src/SmartHopper.Components/Output/AI2MarkdownComponent.cs +++ b/src/SmartHopper.Components/Output/AI2MarkdownComponent.cs @@ -23,7 +23,7 @@ using Grasshopper.Kernel.Parameters; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2NumberComponent.cs b/src/SmartHopper.Components/Output/AI2NumberComponent.cs index 9a474b93f..60700b6ae 100644 --- a/src/SmartHopper.Components/Output/AI2NumberComponent.cs +++ b/src/SmartHopper.Components/Output/AI2NumberComponent.cs @@ -24,7 +24,7 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2NumberListComponent.cs b/src/SmartHopper.Components/Output/AI2NumberListComponent.cs index 68183b9e4..6eabfd2e0 100644 --- a/src/SmartHopper.Components/Output/AI2NumberListComponent.cs +++ b/src/SmartHopper.Components/Output/AI2NumberListComponent.cs @@ -25,8 +25,8 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2ScriptComponent.cs b/src/SmartHopper.Components/Output/AI2ScriptComponent.cs index 6aad5bd3c..3abb896e5 100644 --- a/src/SmartHopper.Components/Output/AI2ScriptComponent.cs +++ b/src/SmartHopper.Components/Output/AI2ScriptComponent.cs @@ -24,7 +24,7 @@ using Grasshopper.Kernel.Parameters; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2SpeechComponent.cs b/src/SmartHopper.Components/Output/AI2SpeechComponent.cs index 97a630117..ff335ab65 100644 --- a/src/SmartHopper.Components/Output/AI2SpeechComponent.cs +++ b/src/SmartHopper.Components/Output/AI2SpeechComponent.cs @@ -25,7 +25,7 @@ using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Parameters; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2TextComponent.cs b/src/SmartHopper.Components/Output/AI2TextComponent.cs index 9290b3935..0f835ee2d 100644 --- a/src/SmartHopper.Components/Output/AI2TextComponent.cs +++ b/src/SmartHopper.Components/Output/AI2TextComponent.cs @@ -23,7 +23,7 @@ using Grasshopper.Kernel.Parameters; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Output/AI2TextListComponent.cs b/src/SmartHopper.Components/Output/AI2TextListComponent.cs index 407a2f8e0..d86b5e7ab 100644 --- a/src/SmartHopper.Components/Output/AI2TextListComponent.cs +++ b/src/SmartHopper.Components/Output/AI2TextListComponent.cs @@ -25,8 +25,8 @@ using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Components.Output { diff --git a/src/SmartHopper.Components/Script/AIScriptGenerateComponent.cs b/src/SmartHopper.Components/Script/AIScriptGenerateComponent.cs index 5e9d9ba8b..7ab559f62 100644 --- a/src/SmartHopper.Components/Script/AIScriptGenerateComponent.cs +++ b/src/SmartHopper.Components/Script/AIScriptGenerateComponent.cs @@ -32,7 +32,8 @@ using SmartHopper.Core.DataTree; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Script { @@ -246,7 +247,7 @@ private void StoreResult(GH_Path path, ToolCallResult toolResult, bool isEdit) } // Extract and collect messages from tool result (errors, warnings, etc.) - var toolMessages = RuntimeMessageUtility.ExtractMessages(toolResult); + var toolMessages = ToolCallResultRuntimeMessageExtensions.ExtractMessages(toolResult); foreach (var m in toolMessages) this.CollectMessage(m); var hasErrors = toolMessages.Any(m => m.Severity == SHRuntimeMessageSeverity.Error); diff --git a/src/SmartHopper.Components/Script/AIScriptReviewComponent.cs b/src/SmartHopper.Components/Script/AIScriptReviewComponent.cs index ba3d1afc4..89a156b61 100644 --- a/src/SmartHopper.Components/Script/AIScriptReviewComponent.cs +++ b/src/SmartHopper.Components/Script/AIScriptReviewComponent.cs @@ -32,7 +32,8 @@ using SmartHopper.Core.DataTree; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Script { @@ -225,7 +226,7 @@ private void StoreResult(GH_Path path, ToolCallResult toolResult) } // Extract and collect messages from tool result - var toolMessages = RuntimeMessageUtility.ExtractMessages(toolResult); + var toolMessages = ToolCallResultRuntimeMessageExtensions.ExtractMessages(toolResult); foreach (var m in toolMessages) this.CollectMessage(m); if (toolMessages.Any(m => m.Severity == SHRuntimeMessageSeverity.Error)) diff --git a/src/SmartHopper.Components/Text/AIText2BooleanComponent.cs b/src/SmartHopper.Components/Text/AIText2BooleanComponent.cs index c38dacd64..b035ab4cc 100644 --- a/src/SmartHopper.Components/Text/AIText2BooleanComponent.cs +++ b/src/SmartHopper.Components/Text/AIText2BooleanComponent.cs @@ -22,6 +22,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using CommonDrawing = System.Drawing; using Grasshopper.Kernel; using Grasshopper.Kernel.Data; using Grasshopper.Kernel.Types; @@ -33,11 +34,11 @@ using SmartHopper.Core.Grasshopper.Converters; using SmartHopper.Core.Grasshopper.Utils; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; -using CommonDrawing = System.Drawing; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Text { diff --git a/src/SmartHopper.Components/Text/AIText2TextComponent.cs b/src/SmartHopper.Components/Text/AIText2TextComponent.cs index aba0e9927..2d9b716e8 100644 --- a/src/SmartHopper.Components/Text/AIText2TextComponent.cs +++ b/src/SmartHopper.Components/Text/AIText2TextComponent.cs @@ -30,11 +30,12 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Text { diff --git a/src/SmartHopper.Components/Text/AIText2TextListComponent.cs b/src/SmartHopper.Components/Text/AIText2TextListComponent.cs index 1fbbc1d0c..f88090d91 100644 --- a/src/SmartHopper.Components/Text/AIText2TextListComponent.cs +++ b/src/SmartHopper.Components/Text/AIText2TextListComponent.cs @@ -30,11 +30,12 @@ using SmartHopper.Components.Properties; using SmartHopper.Core.ComponentBase; using SmartHopper.Core.DataTree; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Components.Text { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/DiscourseToolsBase.cs b/src/SmartHopper.Core.Grasshopper/AITools/DiscourseToolsBase.cs index acd6f290f..a5d5c033c 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/DiscourseToolsBase.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/DiscourseToolsBase.cs @@ -24,15 +24,15 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.Metrics; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/_gh_connect.cs b/src/SmartHopper.Core.Grasshopper/AITools/_gh_connect.cs index bf8a17424..d2a5f10c6 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/_gh_connect.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/_gh_connect.cs @@ -23,10 +23,10 @@ using Grasshopper; using Grasshopper.Kernel; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/_gh_generate.cs b/src/SmartHopper.Core.Grasshopper/AITools/_gh_generate.cs index 6468fcf04..1e435f03e 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/_gh_generate.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/_gh_generate.cs @@ -28,10 +28,10 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Constants; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/_gh_parameter_modifier.cs b/src/SmartHopper.Core.Grasshopper/AITools/_gh_parameter_modifier.cs index 4c68f2d40..360f4acda 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/_gh_parameter_modifier.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/_gh_parameter_modifier.cs @@ -26,11 +26,11 @@ using Rhino; using SmartHopper.Core.Grasshopper.Utils.Canvas; using SmartHopper.Core.Grasshopper.Utils.Components; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/_rhino_get_geometry_3dm.cs b/src/SmartHopper.Core.Grasshopper/AITools/_rhino_get_geometry_3dm.cs index 504aae683..04556f47f 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/_rhino_get_geometry_3dm.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/_rhino_get_geometry_3dm.cs @@ -22,10 +22,10 @@ using Newtonsoft.Json.Linq; using Rhino.DocObjects; using SmartHopper.Core.Grasshopper.Utils.Rhino; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/_rhino_read_3dm.cs b/src/SmartHopper.Core.Grasshopper/AITools/_rhino_read_3dm.cs index 0f73d79a1..6a0ac8f58 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/_rhino_read_3dm.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/_rhino_read_3dm.cs @@ -23,10 +23,10 @@ using Newtonsoft.Json.Linq; using Rhino.DocObjects; using SmartHopper.Core.Grasshopper.Utils.Rhino; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/_script_parameter_modifier.cs b/src/SmartHopper.Core.Grasshopper/AITools/_script_parameter_modifier.cs index f8dd1313f..436551469 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/_script_parameter_modifier.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/_script_parameter_modifier.cs @@ -27,11 +27,11 @@ using RhinoCodePlatform.GH; using SmartHopper.Core.Grasshopper.Utils.Canvas; using SmartHopper.Core.Grasshopper.Utils.Components; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/file2md.cs b/src/SmartHopper.Core.Grasshopper/AITools/file2md.cs index 2a2fa6b52..feb80017d 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/file2md.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/file2md.cs @@ -25,11 +25,11 @@ using SmartHopper.Core.Grasshopper.Converters; using SmartHopper.Core.Grasshopper.Converters.Formats; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_component_lock.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_component_lock.cs index 55acfb6fe..7fb798b4b 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_component_lock.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_component_lock.cs @@ -23,10 +23,10 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Canvas; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_component_preview.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_component_preview.cs index 1e1971bb8..8256c9ae0 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_component_preview.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_component_preview.cs @@ -23,10 +23,10 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Canvas; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_get.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_get.cs index 096824366..35bed6ccb 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_get.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_get.cs @@ -28,10 +28,10 @@ using GhJSON.Grasshopper.Serialization; using Grasshopper.Kernel; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_group.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_group.cs index bee656de1..e4ae29d14 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_group.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_group.cs @@ -26,10 +26,10 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Converters; using SmartHopper.Core.Grasshopper.Utils.Canvas; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_list_categories.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_list_categories.cs index 17130a657..d3974794e 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_list_categories.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_list_categories.cs @@ -22,10 +22,10 @@ using System.Threading.Tasks; using Grasshopper; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_list_components.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_list_components.cs index 1910b7dc7..94b4a31cc 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_list_components.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_list_components.cs @@ -26,10 +26,10 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Canvas; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_merge.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_merge.cs index eefe86481..eb86a9795 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_merge.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_merge.cs @@ -23,10 +23,10 @@ using GhJSON.Core; using GhJSON.Core.Serialization; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_move.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_move.cs index 932345cf5..d59cbbf6c 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_move.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_move.cs @@ -24,10 +24,10 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Canvas; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_put.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_put.cs index ac74d3f2e..d391446e1 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_put.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_put.cs @@ -29,11 +29,11 @@ using Grasshopper.Kernel; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Canvas; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; using SmartHopper.Infrastructure.Dialogs; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/gh_tidy_up.cs b/src/SmartHopper.Core.Grasshopper/AITools/gh_tidy_up.cs index 26f4b1d3b..35f8087a8 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/gh_tidy_up.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/gh_tidy_up.cs @@ -27,10 +27,10 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Graph; using SmartHopper.Core.Grasshopper.Utils.Canvas; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/img2text.cs b/src/SmartHopper.Core.Grasshopper/AITools/img2text.cs index fdb7fcdc0..1fc0e8498 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/img2text.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/img2text.cs @@ -21,13 +21,13 @@ using System.Diagnostics; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/instruction_get.cs b/src/SmartHopper.Core.Grasshopper/AITools/instruction_get.cs index 627db1709..1c249faea 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/instruction_get.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/instruction_get.cs @@ -20,10 +20,10 @@ using System.Collections.Generic; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/list_filter.cs b/src/SmartHopper.Core.Grasshopper/AITools/list_filter.cs index 79adf7a0b..1b5e42f32 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/list_filter.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/list_filter.cs @@ -24,13 +24,13 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/script_edit.cs b/src/SmartHopper.Core.Grasshopper/AITools/script_edit.cs index e87bcc36b..b13fb1046 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/script_edit.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/script_edit.cs @@ -28,13 +28,13 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Constants; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/script_generate.cs b/src/SmartHopper.Core.Grasshopper/AITools/script_generate.cs index 30de69e42..10828b824 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/script_generate.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/script_generate.cs @@ -29,14 +29,14 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Constants; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/script_review.cs b/src/SmartHopper.Core.Grasshopper/AITools/script_review.cs index 4bccc15ae..b6e495d96 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/script_review.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/script_review.cs @@ -29,13 +29,13 @@ using RhinoCodePlatform.GH; using SmartHopper.Core.Grasshopper.Utils.Canvas; using SmartHopper.Core.Grasshopper.Utils.Constants; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/speech_generate.cs b/src/SmartHopper.Core.Grasshopper/AITools/speech_generate.cs index ea40d7c63..2097c5412 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/speech_generate.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/speech_generate.cs @@ -22,15 +22,16 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/text2boolean.cs b/src/SmartHopper.Core.Grasshopper/AITools/text2boolean.cs index 3e2f6d1a9..1a9d1333b 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/text2boolean.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/text2boolean.cs @@ -24,13 +24,13 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Converters; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/text2img.cs b/src/SmartHopper.Core.Grasshopper/AITools/text2img.cs index 9f5250189..acb3f6774 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/text2img.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/text2img.cs @@ -21,13 +21,13 @@ using System.Diagnostics; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/text2json.cs b/src/SmartHopper.Core.Grasshopper/AITools/text2json.cs index 4b3dbdb47..1b0e09a1f 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/text2json.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/text2json.cs @@ -23,14 +23,14 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/text2text.cs b/src/SmartHopper.Core.Grasshopper/AITools/text2text.cs index b2346d306..63dc772ef 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/text2text.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/text2text.cs @@ -21,13 +21,13 @@ using System.Diagnostics; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/text2textlist.cs b/src/SmartHopper.Core.Grasshopper/AITools/text2textlist.cs index cd565f8e8..52ec0996c 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/text2textlist.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/text2textlist.cs @@ -24,15 +24,15 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.Metrics; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/textlist2boolean.cs b/src/SmartHopper.Core.Grasshopper/AITools/textlist2boolean.cs index 70fc1ffc3..4940a32d6 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/textlist2boolean.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/textlist2boolean.cs @@ -25,13 +25,13 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Converters; using SmartHopper.Core.Grasshopper.Utils.Parsing; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/AITools/web2md.cs b/src/SmartHopper.Core.Grasshopper/AITools/web2md.cs index 1c349c16e..aa62919da 100644 --- a/src/SmartHopper.Core.Grasshopper/AITools/web2md.cs +++ b/src/SmartHopper.Core.Grasshopper/AITools/web2md.cs @@ -23,10 +23,10 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.Grasshopper.Converters; using SmartHopper.Core.Grasshopper.Converters.Formats; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.Grasshopper.AITools { diff --git a/src/SmartHopper.Core.Grasshopper/Converters/Formats/PptxConverter.cs b/src/SmartHopper.Core.Grasshopper/Converters/Formats/PptxConverter.cs index 18d47eba5..412e59f36 100644 --- a/src/SmartHopper.Core.Grasshopper/Converters/Formats/PptxConverter.cs +++ b/src/SmartHopper.Core.Grasshopper/Converters/Formats/PptxConverter.cs @@ -22,10 +22,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using A = DocumentFormat.OpenXml.Drawing; using DocumentFormat.OpenXml.Packaging; using DocumentFormat.OpenXml.Presentation; using SmartHopper.Core.Types; -using A = DocumentFormat.OpenXml.Drawing; namespace SmartHopper.Core.Grasshopper.Converters.Formats { diff --git a/src/SmartHopper.Core.Grasshopper/Utils/Parsing/AIResponseParser.cs b/src/SmartHopper.Core.Grasshopper/Utils/Parsing/AIResponseParser.cs index 6ec8d6459..2e50b0147 100644 --- a/src/SmartHopper.Core.Grasshopper/Utils/Parsing/AIResponseParser.cs +++ b/src/SmartHopper.Core.Grasshopper/Utils/Parsing/AIResponseParser.cs @@ -24,7 +24,7 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Core.Grasshopper.Utils.Parsing { diff --git a/src/SmartHopper.Core.Grasshopper/Utils/Parsing/BooleanResultResolver.cs b/src/SmartHopper.Core.Grasshopper/Utils/Parsing/BooleanResultResolver.cs index 06e37a647..8ddd816eb 100644 --- a/src/SmartHopper.Core.Grasshopper/Utils/Parsing/BooleanResultResolver.cs +++ b/src/SmartHopper.Core.Grasshopper/Utils/Parsing/BooleanResultResolver.cs @@ -20,8 +20,8 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.Grasshopper.Utils.Parsing { diff --git a/src/SmartHopper.Core.Grasshopper/Utils/Parsing/IntegerResultResolver.cs b/src/SmartHopper.Core.Grasshopper/Utils/Parsing/IntegerResultResolver.cs index e5e004b82..01fb4a6cf 100644 --- a/src/SmartHopper.Core.Grasshopper/Utils/Parsing/IntegerResultResolver.cs +++ b/src/SmartHopper.Core.Grasshopper/Utils/Parsing/IntegerResultResolver.cs @@ -20,8 +20,8 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.Grasshopper.Utils.Parsing { diff --git a/src/SmartHopper.Core.Grasshopper/Utils/Parsing/NumberResultResolver.cs b/src/SmartHopper.Core.Grasshopper/Utils/Parsing/NumberResultResolver.cs index ad35ebed5..af62d6770 100644 --- a/src/SmartHopper.Core.Grasshopper/Utils/Parsing/NumberResultResolver.cs +++ b/src/SmartHopper.Core.Grasshopper/Utils/Parsing/NumberResultResolver.cs @@ -20,8 +20,8 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.Grasshopper.Utils.Parsing { diff --git a/src/SmartHopper.Core/ComponentBase/AIInputAdapterBase.cs b/src/SmartHopper.Core/ComponentBase/AIInputAdapterBase.cs index eaabb2e21..0fd3482fe 100644 --- a/src/SmartHopper.Core/ComponentBase/AIInputAdapterBase.cs +++ b/src/SmartHopper.Core/ComponentBase/AIInputAdapterBase.cs @@ -21,8 +21,8 @@ using Grasshopper.Kernel; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/AIOutputAdapterBase.cs b/src/SmartHopper.Core/ComponentBase/AIOutputAdapterBase.cs index 69ddc223b..244a06fa2 100644 --- a/src/SmartHopper.Core/ComponentBase/AIOutputAdapterBase.cs +++ b/src/SmartHopper.Core/ComponentBase/AIOutputAdapterBase.cs @@ -31,12 +31,12 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Models; using SmartHopper.Core.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Validation; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.ComponentBase { @@ -409,7 +409,7 @@ private void ProcessMappingsBatchResults( } var allInteractions = new List(); - var allMetrics = new List(); + var allMetrics = new List(); foreach (var path in primarySentinelTree.Paths) { @@ -494,7 +494,7 @@ private void ProcessMappingsBatchResults( // Aggregate metrics and publish a synthetic AIReturn snapshot — same as ProcessBatchResults. if (allInteractions.Count > 0) { - var aggregatedMetrics = new SmartHopper.Infrastructure.AICall.Metrics.AIMetrics + var aggregatedMetrics = new SmartHopper.ProviderSdk.AICall.Metrics.AIMetrics { Provider = providerName, Model = this.GetModel(), @@ -507,7 +507,7 @@ private void ProcessMappingsBatchResults( this.PersistedMetrics = aggregatedMetrics; var batchReturn = new AIReturn(); - var batchRequest = new SmartHopper.Infrastructure.AICall.Core.Requests.AIRequestCall(); + var batchRequest = new SmartHopper.ProviderSdk.AICall.Core.Requests.AIRequestCall(); batchRequest.Initialize( aggregatedMetrics.Provider, aggregatedMetrics.Model, diff --git a/src/SmartHopper.Core/ComponentBase/AIProviderComponentBase.cs b/src/SmartHopper.Core/ComponentBase/AIProviderComponentBase.cs index 211010817..3131c771d 100644 --- a/src/SmartHopper.Core/ComponentBase/AIProviderComponentBase.cs +++ b/src/SmartHopper.Core/ComponentBase/AIProviderComponentBase.cs @@ -23,6 +23,7 @@ using SmartHopper.Core.ComponentBase.Contracts; using SmartHopper.Core.ComponentBase.Cores; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.AI.cs b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.AI.cs index 1c8e8f378..0b82fd91c 100644 --- a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.AI.cs +++ b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.AI.cs @@ -24,14 +24,14 @@ using Grasshopper.Kernel; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase.Batch; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Batch.cs b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Batch.cs index 88931d0f8..97a744ad9 100644 --- a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Batch.cs +++ b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Batch.cs @@ -28,12 +28,14 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase.Cores; using SmartHopper.Core.ComponentBase.State; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Lifecycle.cs b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Lifecycle.cs index 210177eb8..391db18ae 100644 --- a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Lifecycle.cs +++ b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Lifecycle.cs @@ -25,9 +25,10 @@ using SmartHopper.Core.ComponentBase.Contracts; using SmartHopper.Core.ComponentBase.Cores; using SmartHopper.Core.ComponentBase.Mixins; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Main.cs b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Main.cs index 50bf8d739..930482350 100644 --- a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Main.cs +++ b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Main.cs @@ -30,14 +30,14 @@ using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase.Contracts; using SmartHopper.Core.ComponentBase.Cores; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Metrics.cs b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Metrics.cs index 403384569..6ed10b46a 100644 --- a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Metrics.cs +++ b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Metrics.cs @@ -25,11 +25,11 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json.Linq; using SmartHopper.Core.ComponentBase.Contracts; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Metrics; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Persistence.cs b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Persistence.cs index 6be4583f8..929299838 100644 --- a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Persistence.cs +++ b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Persistence.cs @@ -29,13 +29,14 @@ using SmartHopper.Core.ComponentBase.Batch; using SmartHopper.Core.ComponentBase.Contracts; using SmartHopper.Core.ComponentBase.State; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.ComponentBase { @@ -230,7 +231,7 @@ public override bool Read(GH_IO.Serialization.GH_IReader reader) if (!string.IsNullOrEmpty(batchId) && !string.IsNullOrEmpty(providerName)) { - this._batchState.Submission = new SmartHopper.Infrastructure.AICall.Batch.AIBatchSubmission(batchId, providerName, serializedReq, customIds ?? new List().AsReadOnly()); + this._batchState.Submission = new SmartHopper.ProviderSdk.AICall.Batch.AIBatchSubmission(batchId, providerName, serializedReq, customIds ?? new List().AsReadOnly()); Debug.WriteLine($"[AIStatefulAsync] Read: restored batch state, batchId={batchId}, items={customIds?.Count ?? 0}"); // Restore component to Processing state so sentinel values aren't output diff --git a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Processing.cs b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Processing.cs index 0269f1230..083564e39 100644 --- a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Processing.cs +++ b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.Processing.cs @@ -22,13 +22,13 @@ using Grasshopper.Kernel.Data; using Grasshopper.Kernel.Types; using SmartHopper.Core.ComponentBase.Batch; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.UI.cs b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.UI.cs index dbf2bab2a..841f37632 100644 --- a/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.UI.cs +++ b/src/SmartHopper.Core/ComponentBase/AIStatefulAsyncComponentBase.UI.cs @@ -23,11 +23,12 @@ using SmartHopper.Core.ComponentBase.Attributes; using SmartHopper.Core.ComponentBase.Contracts; using SmartHopper.Core.ComponentBase.State; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.Diagnostics; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Core.ComponentBase { @@ -88,7 +89,7 @@ internal void UpdateBadgeCache() new AIInteractionText { Agent = AIAgent.System, Content = "badge-check" }, }; - var req = new SmartHopper.Infrastructure.AICall.Core.Requests.AIRequestCall(); + var req = new SmartHopper.ProviderSdk.AICall.Core.Requests.AIRequestCall(); req.Initialize(providerName, configuredModel ?? string.Empty, interactions, endpoint: "badge_check", capability: this.RequiredCapability, toolFilter: null); // This triggers provider-scoped selection/fallback based on capability @@ -144,7 +145,7 @@ internal void UpdateBadgeCache() Debug.WriteLine($"[UpdateBadgeCache] badgeInvalidModel={this.badgeInvalidModel}"); // Read metadata from the resolved model to set Verified/Deprecated/NotRecommended when available - var resolvedCaps = string.IsNullOrWhiteSpace(resolvedModel) ? null : ModelManager.Instance.GetCapabilities(providerName, resolvedModel); + var resolvedCaps = string.IsNullOrWhiteSpace(resolvedModel) ? null : AIModelCapabilityRegistry.Instance.GetCapabilities(providerName, resolvedModel); if (resolvedCaps == null) { // No metadata available for the resolved model – do not render badges diff --git a/src/SmartHopper.Core/ComponentBase/AsyncWorkerBase.cs b/src/SmartHopper.Core/ComponentBase/AsyncWorkerBase.cs index be09b4d66..8ec615203 100644 --- a/src/SmartHopper.Core/ComponentBase/AsyncWorkerBase.cs +++ b/src/SmartHopper.Core/ComponentBase/AsyncWorkerBase.cs @@ -21,7 +21,7 @@ using System.Threading; using System.Threading.Tasks; using Grasshopper.Kernel; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/Attributes/AIProviderComponentAttributes.cs b/src/SmartHopper.Core/ComponentBase/Attributes/AIProviderComponentAttributes.cs index f4d25a413..c06684e6d 100644 --- a/src/SmartHopper.Core/ComponentBase/Attributes/AIProviderComponentAttributes.cs +++ b/src/SmartHopper.Core/ComponentBase/Attributes/AIProviderComponentAttributes.cs @@ -25,6 +25,8 @@ using SmartHopper.Core.ComponentBase.Cores; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; using Timer = System.Timers.Timer; namespace SmartHopper.Core.ComponentBase.Attributes diff --git a/src/SmartHopper.Core/ComponentBase/Contracts/IProviderComponent.cs b/src/SmartHopper.Core/ComponentBase/Contracts/IProviderComponent.cs index f1301cb39..3c261d527 100644 --- a/src/SmartHopper.Core/ComponentBase/Contracts/IProviderComponent.cs +++ b/src/SmartHopper.Core/ComponentBase/Contracts/IProviderComponent.cs @@ -17,6 +17,7 @@ */ using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Core.ComponentBase.Contracts { diff --git a/src/SmartHopper.Core/ComponentBase/Cores/BatchRunState.cs b/src/SmartHopper.Core/ComponentBase/Cores/BatchRunState.cs index 231c2b9c5..76ffcf153 100644 --- a/src/SmartHopper.Core/ComponentBase/Cores/BatchRunState.cs +++ b/src/SmartHopper.Core/ComponentBase/Cores/BatchRunState.cs @@ -18,9 +18,9 @@ using System; using System.Collections.Generic; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Metrics; namespace SmartHopper.Core.ComponentBase.Cores { diff --git a/src/SmartHopper.Core/ComponentBase/Cores/ProviderSelectionCore.cs b/src/SmartHopper.Core/ComponentBase/Cores/ProviderSelectionCore.cs index 49d943d86..dadbbef75 100644 --- a/src/SmartHopper.Core/ComponentBase/Cores/ProviderSelectionCore.cs +++ b/src/SmartHopper.Core/ComponentBase/Cores/ProviderSelectionCore.cs @@ -23,6 +23,7 @@ using Grasshopper.Kernel; using SmartHopper.Core.ComponentBase.Contracts; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Core.ComponentBase.Cores { diff --git a/src/SmartHopper.Core/ComponentBase/Mixins/AIRequestParametersGooParser.cs b/src/SmartHopper.Core/ComponentBase/Mixins/AIRequestParametersGooParser.cs index 5d89b6624..289ef4621 100644 --- a/src/SmartHopper.Core/ComponentBase/Mixins/AIRequestParametersGooParser.cs +++ b/src/SmartHopper.Core/ComponentBase/Mixins/AIRequestParametersGooParser.cs @@ -17,7 +17,7 @@ */ using Grasshopper.Kernel.Types; -using SmartHopper.Infrastructure.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core; namespace SmartHopper.Core.ComponentBase.Mixins { diff --git a/src/SmartHopper.Core/ComponentBase/ProviderComponentBase.cs b/src/SmartHopper.Core/ComponentBase/ProviderComponentBase.cs index da012aef0..6966892e9 100644 --- a/src/SmartHopper.Core/ComponentBase/ProviderComponentBase.cs +++ b/src/SmartHopper.Core/ComponentBase/ProviderComponentBase.cs @@ -23,6 +23,7 @@ using SmartHopper.Core.ComponentBase.Contracts; using SmartHopper.Core.ComponentBase.Cores; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/ComponentBase/StatefulComponentBase.cs b/src/SmartHopper.Core/ComponentBase/StatefulComponentBase.cs index aae068e24..7caaf2038 100644 --- a/src/SmartHopper.Core/ComponentBase/StatefulComponentBase.cs +++ b/src/SmartHopper.Core/ComponentBase/StatefulComponentBase.cs @@ -49,8 +49,9 @@ using SmartHopper.Core.DataTree; using SmartHopper.Core.Diagnostics; using SmartHopper.Core.IO; -using SmartHopper.Infrastructure.Diagnostics; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Core.ComponentBase { diff --git a/src/SmartHopper.Core/DataTree/DataTreeProcessor.cs b/src/SmartHopper.Core/DataTree/DataTreeProcessor.cs index dde36665e..7a0a4a1b3 100644 --- a/src/SmartHopper.Core/DataTree/DataTreeProcessor.cs +++ b/src/SmartHopper.Core/DataTree/DataTreeProcessor.cs @@ -24,8 +24,8 @@ using System.Threading.Tasks; using Grasshopper.Kernel.Data; using Grasshopper.Kernel.Types; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.DataTree { diff --git a/src/SmartHopper.Core/Diagnostics/SHRuntimeMessageExtensions.cs b/src/SmartHopper.Core/Diagnostics/SHRuntimeMessageExtensions.cs index bec3c0355..6ee453e46 100644 --- a/src/SmartHopper.Core/Diagnostics/SHRuntimeMessageExtensions.cs +++ b/src/SmartHopper.Core/Diagnostics/SHRuntimeMessageExtensions.cs @@ -17,7 +17,7 @@ */ using Grasshopper.Kernel; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.Diagnostics { diff --git a/src/SmartHopper.Core/Models/AIInputPayload.cs b/src/SmartHopper.Core/Models/AIInputPayload.cs index a8d8d9016..a2148ba9e 100644 --- a/src/SmartHopper.Core/Models/AIInputPayload.cs +++ b/src/SmartHopper.Core/Models/AIInputPayload.cs @@ -18,9 +18,9 @@ using System; using System.Collections.Generic; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Models { diff --git a/src/SmartHopper.Core/Parameters/VersatileImageParameter.cs b/src/SmartHopper.Core/Parameters/VersatileImageParameter.cs index d4786e6f2..3f11d36a6 100644 --- a/src/SmartHopper.Core/Parameters/VersatileImageParameter.cs +++ b/src/SmartHopper.Core/Parameters/VersatileImageParameter.cs @@ -16,9 +16,9 @@ * along with this library; if not, see . */ +using System; using Grasshopper.Kernel; using SmartHopper.Core.Types; -using System; namespace SmartHopper.Core.Parameters { diff --git a/src/SmartHopper.Core/Types/AIInputPayloadMerger.cs b/src/SmartHopper.Core/Types/AIInputPayloadMerger.cs index c4c7df9ce..d3e4d1202 100644 --- a/src/SmartHopper.Core/Types/AIInputPayloadMerger.cs +++ b/src/SmartHopper.Core/Types/AIInputPayloadMerger.cs @@ -22,9 +22,9 @@ using System.Linq; using Grasshopper.Kernel.Data; using SmartHopper.Core.Models; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.Types { diff --git a/src/SmartHopper.Core/Types/AIInputPayloadRenderer.cs b/src/SmartHopper.Core/Types/AIInputPayloadRenderer.cs index 6334f8283..301f98505 100644 --- a/src/SmartHopper.Core/Types/AIInputPayloadRenderer.cs +++ b/src/SmartHopper.Core/Types/AIInputPayloadRenderer.cs @@ -20,8 +20,8 @@ using System.Linq; using System.Text; using SmartHopper.Core.Models; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.Types { diff --git a/src/SmartHopper.Core/Types/GH_AIInputPayload.cs b/src/SmartHopper.Core/Types/GH_AIInputPayload.cs index 62bacf3fb..a9501fa49 100644 --- a/src/SmartHopper.Core/Types/GH_AIInputPayload.cs +++ b/src/SmartHopper.Core/Types/GH_AIInputPayload.cs @@ -19,7 +19,7 @@ using System; using Grasshopper.Kernel.Types; using SmartHopper.Core.Models; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.Types { diff --git a/src/SmartHopper.Core/Types/GH_AIRequestParameters.cs b/src/SmartHopper.Core/Types/GH_AIRequestParameters.cs index 8406893c6..af0c6d65c 100644 --- a/src/SmartHopper.Core/Types/GH_AIRequestParameters.cs +++ b/src/SmartHopper.Core/Types/GH_AIRequestParameters.cs @@ -22,7 +22,7 @@ using Grasshopper.Kernel.Types; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core; namespace SmartHopper.Core.Types { diff --git a/src/SmartHopper.Core/Types/VersatileImage.cs b/src/SmartHopper.Core/Types/VersatileImage.cs index c2df36450..0c1861f90 100644 --- a/src/SmartHopper.Core/Types/VersatileImage.cs +++ b/src/SmartHopper.Core/Types/VersatileImage.cs @@ -24,8 +24,8 @@ using System.Linq; using System.Net.Http; using System.Text.RegularExpressions; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.Types { diff --git a/src/SmartHopper.Core/UI/CanvasButton.cs b/src/SmartHopper.Core/UI/CanvasButton.cs index 1721b270c..baae3c364 100644 --- a/src/SmartHopper.Core/UI/CanvasButton.cs +++ b/src/SmartHopper.Core/UI/CanvasButton.cs @@ -32,11 +32,13 @@ using Grasshopper.GUI.Canvas; using Rhino; using SmartHopper.Core.UI.Chat; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Properties; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Core.UI { diff --git a/src/SmartHopper.Core/UI/CanvasButtonBootstrap.cs b/src/SmartHopper.Core/UI/CanvasButtonBootstrap.cs index 7c5bac2a8..225e2b341 100644 --- a/src/SmartHopper.Core/UI/CanvasButtonBootstrap.cs +++ b/src/SmartHopper.Core/UI/CanvasButtonBootstrap.cs @@ -20,6 +20,7 @@ using System.Runtime.CompilerServices; using Rhino; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Core.UI { diff --git a/src/SmartHopper.Core/UI/Chat/ChatResourceManager.cs b/src/SmartHopper.Core/UI/Chat/ChatResourceManager.cs index 0a7f1057b..65a033da5 100644 --- a/src/SmartHopper.Core/UI/Chat/ChatResourceManager.cs +++ b/src/SmartHopper.Core/UI/Chat/ChatResourceManager.cs @@ -30,8 +30,8 @@ using System.Reflection; using System.Text.RegularExpressions; using Markdig; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.UI.Chat { diff --git a/src/SmartHopper.Core/UI/Chat/HtmlChatRenderer.cs b/src/SmartHopper.Core/UI/Chat/HtmlChatRenderer.cs index 0861f9ffa..8f86ba6e0 100644 --- a/src/SmartHopper.Core/UI/Chat/HtmlChatRenderer.cs +++ b/src/SmartHopper.Core/UI/Chat/HtmlChatRenderer.cs @@ -25,7 +25,7 @@ using System.Diagnostics; using System.Globalization; using Markdig; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Core.UI.Chat { diff --git a/src/SmartHopper.Core/UI/Chat/WebChatDialog.cs b/src/SmartHopper.Core/UI/Chat/WebChatDialog.cs index e19e42402..c3a313efd 100644 --- a/src/SmartHopper.Core/UI/Chat/WebChatDialog.cs +++ b/src/SmartHopper.Core/UI/Chat/WebChatDialog.cs @@ -33,15 +33,15 @@ using Newtonsoft.Json; using Rhino; using Rhino.UI; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.Metrics; using SmartHopper.Infrastructure.AICall.Sessions; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Streaming; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Streaming; namespace SmartHopper.Core.UI.Chat { diff --git a/src/SmartHopper.Core/UI/Chat/WebChatObserver.cs b/src/SmartHopper.Core/UI/Chat/WebChatObserver.cs index cd1d6365d..bdc2c4032 100644 --- a/src/SmartHopper.Core/UI/Chat/WebChatObserver.cs +++ b/src/SmartHopper.Core/UI/Chat/WebChatObserver.cs @@ -21,13 +21,13 @@ using System.Diagnostics; using System.Linq; using Rhino; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Sessions; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Core.UI.Chat { diff --git a/src/SmartHopper.Core/UI/Chat/WebChatUtils.Helpers.cs b/src/SmartHopper.Core/UI/Chat/WebChatUtils.Helpers.cs index 1e06e78b5..c32ee8e06 100644 --- a/src/SmartHopper.Core/UI/Chat/WebChatUtils.Helpers.cs +++ b/src/SmartHopper.Core/UI/Chat/WebChatUtils.Helpers.cs @@ -19,10 +19,10 @@ using System; using System.Threading.Tasks; using Eto.Forms; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Core.UI.Chat { diff --git a/src/SmartHopper.Core/UI/Chat/WebChatUtils.cs b/src/SmartHopper.Core/UI/Chat/WebChatUtils.cs index 748969692..82dd9c102 100644 --- a/src/SmartHopper.Core/UI/Chat/WebChatUtils.cs +++ b/src/SmartHopper.Core/UI/Chat/WebChatUtils.cs @@ -26,8 +26,8 @@ using System.Diagnostics; using System.Linq; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.UI.Chat { diff --git a/src/SmartHopper.Core/UI/Chat/WebChatWorker.cs b/src/SmartHopper.Core/UI/Chat/WebChatWorker.cs index 4b6540898..1f4473b94 100644 --- a/src/SmartHopper.Core/UI/Chat/WebChatWorker.cs +++ b/src/SmartHopper.Core/UI/Chat/WebChatWorker.cs @@ -28,8 +28,8 @@ using System.Threading.Tasks; using Grasshopper; using Grasshopper.Kernel; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; namespace SmartHopper.Core.UI.Chat { diff --git a/src/SmartHopper.Infrastructure.Tests/AICall/AIBatchTypesTests.cs b/src/SmartHopper.Infrastructure.Tests/AICall/AIBatchTypesTests.cs index 9bab307c3..f5a2f477d 100644 --- a/src/SmartHopper.Infrastructure.Tests/AICall/AIBatchTypesTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/AICall/AIBatchTypesTests.cs @@ -20,8 +20,8 @@ namespace SmartHopper.Infrastructure.Tests.AICall { using System; using System.Collections.Generic; - using SmartHopper.Infrastructure.AICall.Batch; - using SmartHopper.Infrastructure.Diagnostics; + using SmartHopper.ProviderSdk.AICall.Batch; + using SmartHopper.ProviderSdk.Diagnostics; using Xunit; public class AIBatchSubmissionTests diff --git a/src/SmartHopper.Infrastructure.Tests/AICall/AIInteractionImageTests.cs b/src/SmartHopper.Infrastructure.Tests/AICall/AIInteractionImageTests.cs index 3d6087cd5..ce6ac6aa1 100644 --- a/src/SmartHopper.Infrastructure.Tests/AICall/AIInteractionImageTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/AICall/AIInteractionImageTests.cs @@ -19,7 +19,7 @@ namespace SmartHopper.Infrastructure.Tests.AICall { using System; - using SmartHopper.Infrastructure.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; using Xunit; public class AIInteractionImageTests diff --git a/src/SmartHopper.Infrastructure.Tests/AICall/AIRequestParametersTests.cs b/src/SmartHopper.Infrastructure.Tests/AICall/AIRequestParametersTests.cs index dafc276e1..4255a885e 100644 --- a/src/SmartHopper.Infrastructure.Tests/AICall/AIRequestParametersTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/AICall/AIRequestParametersTests.cs @@ -20,7 +20,7 @@ namespace SmartHopper.Infrastructure.Tests.AICall { using System.Collections.Generic; using Newtonsoft.Json.Linq; - using SmartHopper.Infrastructure.AICall.Core; + using SmartHopper.ProviderSdk.AICall.Core; using Xunit; public class AIRequestParametersTests diff --git a/src/SmartHopper.Infrastructure.Tests/AICall/AIReturnTests.cs b/src/SmartHopper.Infrastructure.Tests/AICall/AIReturnTests.cs index 829663dd1..ccb07ae46 100644 --- a/src/SmartHopper.Infrastructure.Tests/AICall/AIReturnTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/AICall/AIReturnTests.cs @@ -21,12 +21,12 @@ namespace SmartHopper.Infrastructure.Tests.AICall using System; using System.Collections.Generic; using System.Linq; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AICall.Core.Requests; - using SmartHopper.Infrastructure.AICall.Core.Returns; - using SmartHopper.Infrastructure.AICall.Metrics; - using SmartHopper.Infrastructure.Diagnostics; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Requests; + using SmartHopper.ProviderSdk.AICall.Core.Returns; + using SmartHopper.ProviderSdk.AICall.Metrics; + using SmartHopper.ProviderSdk.Diagnostics; using Xunit; /// diff --git a/src/SmartHopper.Infrastructure.Tests/AIToolManagerTests.cs b/src/SmartHopper.Infrastructure.Tests/AIToolManagerTests.cs index a84b221d9..cac660332 100644 --- a/src/SmartHopper.Infrastructure.Tests/AIToolManagerTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/AIToolManagerTests.cs @@ -21,8 +21,8 @@ namespace SmartHopper.Infrastructure.Tests using System.Collections.Generic; using System.Reflection; using System.Threading.Tasks; - using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AITools; + using SmartHopper.ProviderSdk.AICall.Core.Returns; using Xunit; /// diff --git a/src/SmartHopper.Infrastructure.Tests/AdvancedConfigTests.cs b/src/SmartHopper.Infrastructure.Tests/AdvancedConfigTests.cs index a9deb42af..702591026 100644 --- a/src/SmartHopper.Infrastructure.Tests/AdvancedConfigTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/AdvancedConfigTests.cs @@ -24,13 +24,15 @@ namespace SmartHopper.Infrastructure.Tests using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AICall.Core.Requests; - using SmartHopper.Infrastructure.AICall.Core.Returns; - using SmartHopper.Infrastructure.AIModels; - using SmartHopper.Infrastructure.AIProviders; - using SmartHopper.Infrastructure.Settings; - using SmartHopper.Infrastructure.Streaming; +using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.Infrastructure.Settings; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Requests; + using SmartHopper.ProviderSdk.AICall.Core.Returns; + using SmartHopper.ProviderSdk.AIModels; + using SmartHopper.ProviderSdk.AIProviders; + using SmartHopper.ProviderSdk.Settings; + using SmartHopper.ProviderSdk.Streaming; using Xunit; public class AdvancedConfigTests @@ -51,7 +53,7 @@ public async Task InitializeProviderAsync() var models = await this.Models.RetrieveModels().ConfigureAwait(false); foreach (var m in models) { - ModelManager.Instance.SetCapabilities(m); + AIModelCapabilityRegistry.Instance.SetCapabilities(m); } } diff --git a/src/SmartHopper.Infrastructure.Tests/InteractionKeyGenerationTests.cs b/src/SmartHopper.Infrastructure.Tests/InteractionKeyGenerationTests.cs index 49321b36f..0768aca86 100644 --- a/src/SmartHopper.Infrastructure.Tests/InteractionKeyGenerationTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/InteractionKeyGenerationTests.cs @@ -20,9 +20,9 @@ namespace SmartHopper.Infrastructure.Tests { using System; using Newtonsoft.Json.Linq; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.Diagnostics; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.Diagnostics; using Xunit; /// diff --git a/src/SmartHopper.Infrastructure.Tests/ModelManagerTests.cs b/src/SmartHopper.Infrastructure.Tests/ModelManagerTests.cs index 8ad3762f5..b26d6e8c1 100644 --- a/src/SmartHopper.Infrastructure.Tests/ModelManagerTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/ModelManagerTests.cs @@ -21,7 +21,7 @@ namespace SmartHopper.Infrastructure.Tests using System.Collections.Generic; using System.Globalization; using System.Reflection; - using SmartHopper.Infrastructure.AIModels; + using SmartHopper.ProviderSdk.AIModels; using Xunit; /// @@ -34,10 +34,8 @@ public class ModelManagerTests /// private static void ResetManager() { - var manager = ModelManager.Instance; - var registryField = typeof(ModelManager).GetField("_registry", BindingFlags.NonPublic | BindingFlags.Instance); - var newRegistry = System.Activator.CreateInstance(typeof(AIModelCapabilityRegistry)); - registryField?.SetValue(manager, newRegistry); + var registry = AIModelCapabilityRegistry.Instance; + registry.Models.Clear(); } /// @@ -51,8 +49,8 @@ private static void ResetManager() public void Instance_ShouldReturnSameInstance() { // Arrange & Act - var instance1 = ModelManager.Instance; - var instance2 = ModelManager.Instance; + var instance1 = AIModelCapabilityRegistry.Instance; + var instance2 = AIModelCapabilityRegistry.Instance; // Assert Assert.Same(instance1, instance2); @@ -71,7 +69,7 @@ public void RegisterCapabilities_ShouldRegisterModel() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; const string model = "TestModel"; const AICapability capabilities = AICapability.Text2Text | AICapability.Text2Json; @@ -101,7 +99,7 @@ public void RegisterCapabilities_ShouldIgnoreInvalidInput() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; // Act & Assert - null/empty provider manager.RegisterCapabilities(null!, "TestModel", AICapability.Text2Text); @@ -131,7 +129,7 @@ public void SetCapabilities_ShouldHandleNullInput() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; // Act & Assert - should not throw manager.SetCapabilities(null!); @@ -149,7 +147,7 @@ public void GetCapabilities_ShouldReturnNullForUnregistered() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; // Act var capabilities = manager.GetCapabilities("UnknownProvider", "UnknownModel"); @@ -170,7 +168,7 @@ public void GetDefaultModel_ShouldReturnCorrectDefault() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; const string chatModel = "ChatModel"; const string toolsModel = "ToolsModel"; @@ -198,7 +196,7 @@ public void HasProviderCapabilities_ShouldReturnCorrectStatus() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string registeredProvider = "RegisteredProvider"; const string unregisteredProvider = "UnregisteredProvider"; @@ -224,7 +222,7 @@ public void ValidateCapabilities_ShouldValidateCorrectly() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; const string model = "TestModel"; const AICapability capabilities = AICapability.Text2Text | AICapability.Text2Json; @@ -258,7 +256,7 @@ public void SelectBestModel_UserUnknown_PassesThrough() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; manager.RegisterCapabilities(provider, "KnownModel", AICapability.Text2Text); @@ -281,7 +279,7 @@ public void SelectBestModel_UserKnownCapable_UsesUser() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; const string model = "CapableModel"; manager.RegisterCapabilities(provider, model, AICapability.Text2Text); @@ -305,7 +303,7 @@ public void SelectBestModel_UserKnownNotCapable_FallbacksToPreferred() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; const string notCapable = "JsonOnly"; const string preferred = "TextChat"; @@ -331,7 +329,7 @@ public void SelectBestModel_Priority_DefaultExactThenCompatibleThenBest() { // Arrange 1: exact default exists ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; // exact default for Text2Text @@ -376,7 +374,7 @@ public void SelectBestModel_Priority_DefaultExactThenCompatibleThenBest() // Arrange 2: remove exact default flag to test compatible-default path ResetManager(); - manager = ModelManager.Instance; + manager = AIModelCapabilityRegistry.Instance; manager.SetCapabilities(new AIModelCapabilities { Provider = provider.ToLower(System.Globalization.CultureInfo.InvariantCulture), @@ -403,7 +401,7 @@ public void SelectBestModel_Priority_DefaultExactThenCompatibleThenBest() // Arrange 3: no defaults -> choose best by quality (Verified, Rank, !Deprecated) ResetManager(); - manager = ModelManager.Instance; + manager = AIModelCapabilityRegistry.Instance; manager.SetCapabilities(new AIModelCapabilities { Provider = provider.ToLower(System.Globalization.CultureInfo.InvariantCulture), @@ -439,7 +437,7 @@ public void SetDefault_ShouldBeExclusivePerProvider() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; manager.RegisterCapabilities(provider, "A", AICapability.Text2Text, AICapability.Text2Text); manager.RegisterCapabilities(provider, "B", AICapability.Text2Text); @@ -468,7 +466,7 @@ public void SetDefault_ShouldCreateEntryWhenMissing() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; // Act @@ -492,7 +490,7 @@ public void GetCapabilities_ByAlias_ShouldResolve() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "AliasProvider"; manager.SetCapabilities(new AIModelCapabilities @@ -523,7 +521,7 @@ public void ValidateCapabilities_Image2Text_ReturnsCorrectStatus() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; // Register model with Image2Text capability @@ -550,7 +548,7 @@ public void ValidateCapabilities_Text2Image_ReturnsCorrectStatus() { // Arrange ResetManager(); - var manager = ModelManager.Instance; + var manager = AIModelCapabilityRegistry.Instance; const string provider = "TestProvider"; // Register model with Text2Image capability diff --git a/src/SmartHopper.Infrastructure.Tests/ProviderHashVerifierTests.cs b/src/SmartHopper.Infrastructure.Tests/ProviderHashVerifierTests.cs index c6dccb2f1..b10f9aa73 100644 --- a/src/SmartHopper.Infrastructure.Tests/ProviderHashVerifierTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/ProviderHashVerifierTests.cs @@ -20,7 +20,8 @@ namespace SmartHopper.Infrastructure.Tests { using System.IO; using System.Text; - using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.Infrastructure.AIProviders; + using SmartHopper.ProviderSdk.AIProviders; using Xunit; public class ProviderHashVerifierTests diff --git a/src/SmartHopper.Infrastructure.Tests/ProviderManagerSignatureTests.cs b/src/SmartHopper.Infrastructure.Tests/ProviderManagerSignatureTests.cs index 91c281c88..ef9313633 100644 --- a/src/SmartHopper.Infrastructure.Tests/ProviderManagerSignatureTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/ProviderManagerSignatureTests.cs @@ -29,7 +29,8 @@ namespace SmartHopper.Infrastructure.Tests using System.Security.Cryptography; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; - using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.Infrastructure.AIProviders; + using SmartHopper.ProviderSdk.AIProviders; using Xunit; using Xunit.Abstractions; using Xunit.Sdk; diff --git a/src/SmartHopper.Infrastructure.Tests/ProviderManagerTests.cs b/src/SmartHopper.Infrastructure.Tests/ProviderManagerTests.cs index 5ffa6d9ef..bcb73353f 100644 --- a/src/SmartHopper.Infrastructure.Tests/ProviderManagerTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/ProviderManagerTests.cs @@ -18,7 +18,8 @@ namespace SmartHopper.Infrastructure.Tests { - using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.Infrastructure.AIProviders; + using SmartHopper.ProviderSdk.AIProviders; using Xunit; public class ProviderManagerTests diff --git a/src/SmartHopper.Infrastructure.Tests/SmartHopperSettingsTests.cs b/src/SmartHopper.Infrastructure.Tests/SmartHopperSettingsTests.cs index bf9dfcf7b..d27f82440 100644 --- a/src/SmartHopper.Infrastructure.Tests/SmartHopperSettingsTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/SmartHopperSettingsTests.cs @@ -21,7 +21,8 @@ namespace SmartHopper.Infrastructure.Tests using System; using System.IO; using Newtonsoft.Json; - using SmartHopper.Infrastructure.Settings; +using SmartHopper.Infrastructure.Settings; + using SmartHopper.ProviderSdk.Settings; using Xunit; /// diff --git a/src/SmartHopper.Infrastructure.Tests/VersionHelperTests.cs b/src/SmartHopper.Infrastructure.Tests/VersionHelperTests.cs index 2bfd8d65f..dcb7e970a 100644 --- a/src/SmartHopper.Infrastructure.Tests/VersionHelperTests.cs +++ b/src/SmartHopper.Infrastructure.Tests/VersionHelperTests.cs @@ -18,7 +18,8 @@ namespace SmartHopper.Infrastructure.Tests { - using SmartHopper.Infrastructure.Utils; +using SmartHopper.Infrastructure.Utils; + using SmartHopper.ProviderSdk.Utils; using Xunit; public class VersionHelperTests diff --git a/src/SmartHopper.Infrastructure/AICall/Execution/DefaultProviderExecutor.cs b/src/SmartHopper.Infrastructure/AICall/Execution/DefaultProviderExecutor.cs index 87cdd064e..5b9560b01 100644 --- a/src/SmartHopper.Infrastructure/AICall/Execution/DefaultProviderExecutor.cs +++ b/src/SmartHopper.Infrastructure/AICall/Execution/DefaultProviderExecutor.cs @@ -20,10 +20,10 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Streaming; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Streaming; namespace SmartHopper.Infrastructure.AICall.Execution { diff --git a/src/SmartHopper.Infrastructure/AICall/Execution/IProviderExecutor.cs b/src/SmartHopper.Infrastructure/AICall/Execution/IProviderExecutor.cs index 421c8e126..d7ce5e56b 100644 --- a/src/SmartHopper.Infrastructure/AICall/Execution/IProviderExecutor.cs +++ b/src/SmartHopper.Infrastructure/AICall/Execution/IProviderExecutor.cs @@ -18,10 +18,10 @@ using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Streaming; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Streaming; namespace SmartHopper.Infrastructure.AICall.Execution { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/PolicyContext.cs b/src/SmartHopper.Infrastructure/AICall/Policies/PolicyContext.cs index ce2cd9a48..a8eb5d70c 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/PolicyContext.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/PolicyContext.cs @@ -17,11 +17,11 @@ */ using System.Collections.Generic; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Policies { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/PolicyPipeline.cs b/src/SmartHopper.Infrastructure/AICall/Policies/PolicyPipeline.cs index f520893fe..4198afb30 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/PolicyPipeline.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/PolicyPipeline.cs @@ -21,13 +21,13 @@ using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Policies.Request; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Policies { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/Request/AIToolValidationRequestPolicy.cs b/src/SmartHopper.Infrastructure/AICall/Policies/Request/AIToolValidationRequestPolicy.cs index 56cf65ab8..bf62f74ef 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/Request/AIToolValidationRequestPolicy.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/Request/AIToolValidationRequestPolicy.cs @@ -19,10 +19,10 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AICall.Validation; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Policies.Request { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/Request/ContextInjectionRequestPolicy.cs b/src/SmartHopper.Infrastructure/AICall/Policies/Request/ContextInjectionRequestPolicy.cs index 9b2aea2ad..6d323083b 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/Request/ContextInjectionRequestPolicy.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/Request/ContextInjectionRequestPolicy.cs @@ -19,9 +19,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.AIContext; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; namespace SmartHopper.Infrastructure.AICall.Policies.Request { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/Request/RequestTimeoutPolicy.cs b/src/SmartHopper.Infrastructure/AICall/Policies/Request/RequestTimeoutPolicy.cs index a03de981a..87ed46a28 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/Request/RequestTimeoutPolicy.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/Request/RequestTimeoutPolicy.cs @@ -17,9 +17,10 @@ */ using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Infrastructure.AICall.Policies.Request { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/Request/SchemaAttachRequestPolicy.cs b/src/SmartHopper.Infrastructure/AICall/Policies/Request/SchemaAttachRequestPolicy.cs index 66586f235..20bd55c68 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/Request/SchemaAttachRequestPolicy.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/Request/SchemaAttachRequestPolicy.cs @@ -19,8 +19,8 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; namespace SmartHopper.Infrastructure.AICall.Policies.Request { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/Request/SchemaValidateRequestPolicy.cs b/src/SmartHopper.Infrastructure/AICall/Policies/Request/SchemaValidateRequestPolicy.cs index 2dde50f98..4e78fe945 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/Request/SchemaValidateRequestPolicy.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/Request/SchemaValidateRequestPolicy.cs @@ -19,9 +19,9 @@ using System; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.JsonSchemas; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Policies.Request { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/Request/ToolFilterNormalizationRequestPolicy.cs b/src/SmartHopper.Infrastructure/AICall/Policies/Request/ToolFilterNormalizationRequestPolicy.cs index 19f1a66e4..855646572 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/Request/ToolFilterNormalizationRequestPolicy.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/Request/ToolFilterNormalizationRequestPolicy.cs @@ -20,8 +20,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Interactions; using SmartHopper.Infrastructure.Utils; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.Utils; namespace SmartHopper.Infrastructure.AICall.Policies.Request { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/Response/FinishReasonNormalizeResponsePolicy.cs b/src/SmartHopper.Infrastructure/AICall/Policies/Response/FinishReasonNormalizeResponsePolicy.cs index 09d2362de..2f8481907 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/Response/FinishReasonNormalizeResponsePolicy.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/Response/FinishReasonNormalizeResponsePolicy.cs @@ -20,10 +20,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Policies.Response { diff --git a/src/SmartHopper.Infrastructure/AICall/Policies/Response/SchemaValidateResponsePolicy.cs b/src/SmartHopper.Infrastructure/AICall/Policies/Response/SchemaValidateResponsePolicy.cs index 92cdf6165..8c00bd977 100644 --- a/src/SmartHopper.Infrastructure/AICall/Policies/Response/SchemaValidateResponsePolicy.cs +++ b/src/SmartHopper.Infrastructure/AICall/Policies/Response/SchemaValidateResponsePolicy.cs @@ -19,9 +19,9 @@ using System; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; using SmartHopper.Infrastructure.AICall.Validation; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Policies.Response { diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.ContextManagement.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.ContextManagement.cs index 6d8b1e076..9a56a1d6a 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.ContextManagement.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.ContextManagement.cs @@ -24,12 +24,12 @@ namespace SmartHopper.Infrastructure.AICall.Sessions using System.Linq; using System.Threading; using System.Threading.Tasks; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Sessions.SpecialTurns; using SmartHopper.Infrastructure.AICall.Sessions.SpecialTurns.BuiltIn; - using SmartHopper.Infrastructure.AIModels; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Returns; + using SmartHopper.ProviderSdk.AIModels; /// /// ConversationSession partial class containing context management and auto-summarization logic. @@ -107,7 +107,7 @@ public async Task TrySummarizeContextAsync(CancellationToken cancellationT var provider = this.Request?.Body?.Metrics?.Provider; var model = this.Request?.Body?.Metrics?.Model; var contextLimit = !string.IsNullOrEmpty(provider) && !string.IsNullOrEmpty(model) - ? ModelManager.Instance?.GetCapabilities(provider, model)?.ContextLimit + ? AIModelCapabilityRegistry.Instance?.GetCapabilities(provider, model)?.ContextLimit : null; Debug.WriteLine($"[ConversationSession.ContextManagement] Starting context summarization: tokens={currentTokens}/{contextLimit}, usage={usage:P1}"); diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.SpecialTurns.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.SpecialTurns.cs index 76352a530..a20d37e11 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.SpecialTurns.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.SpecialTurns.cs @@ -24,16 +24,16 @@ namespace SmartHopper.Infrastructure.AICall.Sessions using System.Linq; using System.Threading; using System.Threading.Tasks; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AICall.Core.Requests; - using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Execution; using SmartHopper.Infrastructure.AICall.Policies; using SmartHopper.Infrastructure.AICall.Sessions.SpecialTurns; - using SmartHopper.Infrastructure.AICall.Utilities; - using SmartHopper.Infrastructure.AIModels; - using SmartHopper.Infrastructure.Streaming; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Requests; + using SmartHopper.ProviderSdk.AICall.Core.Returns; + using SmartHopper.ProviderSdk.AICall.Utilities; + using SmartHopper.ProviderSdk.AIModels; + using SmartHopper.ProviderSdk.Streaming; /// /// ConversationSession partial class containing special turn execution logic. diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.cs index 607901de0..e315c16c2 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSession.cs @@ -25,17 +25,18 @@ namespace SmartHopper.Infrastructure.AICall.Sessions using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AICall.Core.Requests; - using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Execution; - using SmartHopper.Infrastructure.AICall.Metrics; using SmartHopper.Infrastructure.AICall.Policies; - using SmartHopper.Infrastructure.AICall.Utilities; - using SmartHopper.Infrastructure.Diagnostics; - using SmartHopper.Infrastructure.Settings; - using SmartHopper.Infrastructure.Streaming; +using SmartHopper.Infrastructure.Settings; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Requests; + using SmartHopper.ProviderSdk.AICall.Core.Returns; + using SmartHopper.ProviderSdk.AICall.Metrics; + using SmartHopper.ProviderSdk.AICall.Utilities; + using SmartHopper.ProviderSdk.Diagnostics; + using SmartHopper.ProviderSdk.Settings; + using SmartHopper.ProviderSdk.Streaming; /// /// Conversation session that manages chat history and orchestrates multi-turn conversations. diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSessionHelpers.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSessionHelpers.cs index 1dda35229..2a70fb993 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSessionHelpers.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/ConversationSessionHelpers.cs @@ -27,14 +27,14 @@ namespace SmartHopper.Infrastructure.AICall.Sessions using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AICall.Core.Requests; - using SmartHopper.Infrastructure.AICall.Core.Returns; - using SmartHopper.Infrastructure.AICall.Metrics; using SmartHopper.Infrastructure.AICall.Tools; - using SmartHopper.Infrastructure.AICall.Utilities; - using SmartHopper.Infrastructure.Diagnostics; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Requests; + using SmartHopper.ProviderSdk.AICall.Core.Returns; + using SmartHopper.ProviderSdk.AICall.Metrics; + using SmartHopper.ProviderSdk.AICall.Utilities; + using SmartHopper.ProviderSdk.Diagnostics; /// /// Helper methods supporting orchestration logic. diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/IConversationObserver.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/IConversationObserver.cs index 8f42f54a3..b61dba2c9 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/IConversationObserver.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/IConversationObserver.cs @@ -20,9 +20,9 @@ namespace SmartHopper.Infrastructure.AICall.Sessions { - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AICall.Core.Requests; - using SmartHopper.Infrastructure.AICall.Core.Returns; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Requests; + using SmartHopper.ProviderSdk.AICall.Core.Returns; /// /// Observer of conversation session lifecycle and streaming deltas. diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/IConversationSession.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/IConversationSession.cs index 0e37bb293..0b6016206 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/IConversationSession.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/IConversationSession.cs @@ -21,9 +21,9 @@ namespace SmartHopper.Infrastructure.AICall.Sessions using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; - using SmartHopper.Infrastructure.AICall.Core.Requests; - using SmartHopper.Infrastructure.AICall.Core.Returns; - using SmartHopper.Infrastructure.Streaming; + using SmartHopper.ProviderSdk.AICall.Core.Requests; + using SmartHopper.ProviderSdk.AICall.Core.Returns; + using SmartHopper.ProviderSdk.Streaming; /// /// Contract for conversation session orchestrator. Minimal non-streaming API. diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/BuiltIn/GreetingSpecialTurn.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/BuiltIn/GreetingSpecialTurn.cs index da7697cee..2a2f1f828 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/BuiltIn/GreetingSpecialTurn.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/BuiltIn/GreetingSpecialTurn.cs @@ -19,9 +19,9 @@ namespace SmartHopper.Infrastructure.AICall.Sessions.SpecialTurns.BuiltIn { using System.Collections.Generic; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AIModels; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AIModels; /// /// Factory for creating greeting special turn configurations. @@ -37,7 +37,7 @@ public static class GreetingSpecialTurn public static SpecialTurnConfig Create(string providerName, string? systemPrompt = null) { var greetingInteractions = BuildGreetingInteractions(systemPrompt); - var defaultModel = ModelManager.Instance.GetDefaultModel(providerName, AICapability.Text2Text); + var defaultModel = AIModelCapabilityRegistry.Instance.GetDefaultModel(providerName, AICapability.Text2Text); return new SpecialTurnConfig { diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/BuiltIn/SummarizeSpecialTurn.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/BuiltIn/SummarizeSpecialTurn.cs index 0d8b1027d..543b1feba 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/BuiltIn/SummarizeSpecialTurn.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/BuiltIn/SummarizeSpecialTurn.cs @@ -21,9 +21,9 @@ namespace SmartHopper.Infrastructure.AICall.Sessions.SpecialTurns.BuiltIn using System.Collections.Generic; using System.Linq; using System.Text; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AIModels; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AIModels; /// /// Factory for creating summarization special turn configurations. @@ -47,7 +47,7 @@ public static SpecialTurnConfig Create( IAIInteraction lastUserMessage = null) { var summarizeInteractions = BuildSummarizeInteractions(conversationHistory, lastUserMessage); - var defaultModel = ModelManager.Instance.GetDefaultModel(providerName, AICapability.Text2Text); + var defaultModel = AIModelCapabilityRegistry.Instance.GetDefaultModel(providerName, AICapability.Text2Text); var effectiveModel = !string.IsNullOrWhiteSpace(conversationModel) ? conversationModel : defaultModel; return new SpecialTurnConfig diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/InteractionFilter.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/InteractionFilter.cs index 648e6c559..af5c7a257 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/InteractionFilter.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/InteractionFilter.cs @@ -19,8 +19,8 @@ namespace SmartHopper.Infrastructure.AICall.Sessions.SpecialTurns { using System.Collections.Generic; - using SmartHopper.Infrastructure.AICall.Core.Base; - using SmartHopper.Infrastructure.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AICall.Core.Base; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; /// /// Filter to control which interaction types are included/excluded during persistence. diff --git a/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/SpecialTurnConfig.cs b/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/SpecialTurnConfig.cs index ef7edcb8d..db03dd898 100644 --- a/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/SpecialTurnConfig.cs +++ b/src/SmartHopper.Infrastructure/AICall/Sessions/SpecialTurns/SpecialTurnConfig.cs @@ -19,8 +19,8 @@ namespace SmartHopper.Infrastructure.AICall.Sessions.SpecialTurns { using System.Collections.Generic; - using SmartHopper.Infrastructure.AICall.Core.Interactions; - using SmartHopper.Infrastructure.AIModels; + using SmartHopper.ProviderSdk.AICall.Core.Interactions; + using SmartHopper.ProviderSdk.AIModels; /// /// Configuration for executing a special turn with custom overrides. diff --git a/src/SmartHopper.Infrastructure/AICall/Tools/AIToolCall.cs b/src/SmartHopper.Infrastructure/AICall/Tools/AIToolCall.cs index b93792a86..9048c9404 100644 --- a/src/SmartHopper.Infrastructure/AICall/Tools/AIToolCall.cs +++ b/src/SmartHopper.Infrastructure/AICall/Tools/AIToolCall.cs @@ -22,14 +22,14 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Validation; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Tools { diff --git a/src/SmartHopper.Infrastructure/AICall/Tools/ToolCallResult.cs b/src/SmartHopper.Infrastructure/AICall/Tools/ToolCallResult.cs index a880656a3..46ae5d5d7 100644 --- a/src/SmartHopper.Infrastructure/AICall/Tools/ToolCallResult.cs +++ b/src/SmartHopper.Infrastructure/AICall/Tools/ToolCallResult.cs @@ -19,10 +19,10 @@ using System.Collections.Generic; using System.Linq; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Tools { diff --git a/src/SmartHopper.Infrastructure/AICall/Utilities/ToolCallResultRuntimeMessageExtensions.cs b/src/SmartHopper.Infrastructure/AICall/Utilities/ToolCallResultRuntimeMessageExtensions.cs new file mode 100644 index 000000000..462421659 --- /dev/null +++ b/src/SmartHopper.Infrastructure/AICall/Utilities/ToolCallResultRuntimeMessageExtensions.cs @@ -0,0 +1,62 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System.Collections.Generic; +using SmartHopper.Infrastructure.AICall.Tools; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; + +namespace SmartHopper.Infrastructure.AICall.Utilities +{ + /// + /// Host-side extension that bridges (host-only) into + /// (SDK) for runtime-message extraction. + /// + public static class ToolCallResultRuntimeMessageExtensions + { + /// + /// Extracts runtime messages from a envelope. + /// Combines diagnostics carried on the envelope with messages found inside + /// the underlying JSON payload. + /// + /// The envelope to extract messages from. + /// A list of extracted SHRuntimeMessage objects, or empty list if none found. + public static List ExtractMessages(ToolCallResult toolResult) + { + var messages = new List(); + if (toolResult == null) + { + return messages; + } + + if (toolResult.Messages != null) + { + foreach (var m in toolResult.Messages) + { + if (m != null) + { + messages.Add(m); + } + } + } + + messages.AddRange(RuntimeMessageUtility.ExtractMessages(toolResult.Result)); + return messages; + } + } +} diff --git a/src/SmartHopper.Infrastructure/AICall/Validation/ComponentCapabilityValidator.cs b/src/SmartHopper.Infrastructure/AICall/Validation/ComponentCapabilityValidator.cs index 9a57bb776..48fd0aa1c 100644 --- a/src/SmartHopper.Infrastructure/AICall/Validation/ComponentCapabilityValidator.cs +++ b/src/SmartHopper.Infrastructure/AICall/Validation/ComponentCapabilityValidator.cs @@ -20,11 +20,12 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Validation { @@ -101,7 +102,7 @@ public ValidationResult ValidateSync(AICapability capability) } // Step 3: Check capability support - var modelManager = ModelManager.Instance; + var modelManager = AIModelCapabilityRegistry.Instance; var supportsCapability = modelManager.ValidateCapabilities(this._providerName, effectiveModel, capability); if (supportsCapability) diff --git a/src/SmartHopper.Infrastructure/AICall/Validation/IValidator.cs b/src/SmartHopper.Infrastructure/AICall/Validation/IValidator.cs index 684354ef1..3d222f2cf 100644 --- a/src/SmartHopper.Infrastructure/AICall/Validation/IValidator.cs +++ b/src/SmartHopper.Infrastructure/AICall/Validation/IValidator.cs @@ -20,8 +20,8 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Validation { diff --git a/src/SmartHopper.Infrastructure/AICall/Validation/JsonSchemaResponseValidator.cs b/src/SmartHopper.Infrastructure/AICall/Validation/JsonSchemaResponseValidator.cs index f56612efa..b09967010 100644 --- a/src/SmartHopper.Infrastructure/AICall/Validation/JsonSchemaResponseValidator.cs +++ b/src/SmartHopper.Infrastructure/AICall/Validation/JsonSchemaResponseValidator.cs @@ -20,12 +20,12 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.JsonSchemas; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Validation { diff --git a/src/SmartHopper.Infrastructure/AICall/Validation/ToolCapabilityValidator.cs b/src/SmartHopper.Infrastructure/AICall/Validation/ToolCapabilityValidator.cs index 66df84f06..a6a0bb172 100644 --- a/src/SmartHopper.Infrastructure/AICall/Validation/ToolCapabilityValidator.cs +++ b/src/SmartHopper.Infrastructure/AICall/Validation/ToolCapabilityValidator.cs @@ -19,12 +19,12 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Validation { @@ -88,7 +88,7 @@ public Task ValidateAsync(AIInteractionToolCall instance, Vali return Task.FromResult(pass); } - var ok = ModelManager.Instance.ValidateCapabilities(this.provider, this.model, required); + var ok = AIModelCapabilityRegistry.Instance.ValidateCapabilities(this.provider, this.model, required); if (!ok) { messages.Add(new SHRuntimeMessage( diff --git a/src/SmartHopper.Infrastructure/AICall/Validation/ToolExistsValidator.cs b/src/SmartHopper.Infrastructure/AICall/Validation/ToolExistsValidator.cs index 2d1c10302..ed5ee248d 100644 --- a/src/SmartHopper.Infrastructure/AICall/Validation/ToolExistsValidator.cs +++ b/src/SmartHopper.Infrastructure/AICall/Validation/ToolExistsValidator.cs @@ -19,11 +19,11 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Utilities; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Validation { diff --git a/src/SmartHopper.Infrastructure/AICall/Validation/ToolJsonSchemaValidator.cs b/src/SmartHopper.Infrastructure/AICall/Validation/ToolJsonSchemaValidator.cs index c2ee0ff8a..c3a8cbdf6 100644 --- a/src/SmartHopper.Infrastructure/AICall/Validation/ToolJsonSchemaValidator.cs +++ b/src/SmartHopper.Infrastructure/AICall/Validation/ToolJsonSchemaValidator.cs @@ -21,12 +21,12 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.JsonSchemas; -using SmartHopper.Infrastructure.AICall.Utilities; using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AICall.Validation { diff --git a/src/SmartHopper.Infrastructure/AICall/Validation/ValidationContext.cs b/src/SmartHopper.Infrastructure/AICall/Validation/ValidationContext.cs index a9b9d9872..eb153fc0f 100644 --- a/src/SmartHopper.Infrastructure/AICall/Validation/ValidationContext.cs +++ b/src/SmartHopper.Infrastructure/AICall/Validation/ValidationContext.cs @@ -18,9 +18,9 @@ using System; using System.Collections.Generic; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Infrastructure.AICall.Validation { diff --git a/src/SmartHopper.Infrastructure/AIContext/ContextManager.cs b/src/SmartHopper.Infrastructure/AIContext/ContextManager.cs index b3ac2b4c6..758d994d6 100644 --- a/src/SmartHopper.Infrastructure/AIContext/ContextManager.cs +++ b/src/SmartHopper.Infrastructure/AIContext/ContextManager.cs @@ -21,6 +21,7 @@ using System.Diagnostics; using System.Linq; using SmartHopper.Infrastructure.Utils; +using SmartHopper.ProviderSdk.Utils; namespace SmartHopper.Infrastructure.AIContext { diff --git a/src/SmartHopper.Infrastructure/AIModels/AIModelCapabilityRegistry.cs b/src/SmartHopper.Infrastructure/AIModels/AIModelCapabilityRegistry.cs deleted file mode 100644 index f19d6aa00..000000000 --- a/src/SmartHopper.Infrastructure/AIModels/AIModelCapabilityRegistry.cs +++ /dev/null @@ -1,151 +0,0 @@ -/* - * SmartHopper - AI-powered Grasshopper Plugin - * Copyright (C) 2024-2026 Marc Roca Musach - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; - -namespace SmartHopper.Infrastructure.AIModels -{ - /// - /// Registry containing capability information for all known models. - /// Thread-safe: uses ConcurrentDictionary for reads/writes. - /// - public sealed class AIModelCapabilityRegistry - { - /// - /// Gets the dictionary of model capabilities keyed by "provider.model". - /// Thread-safe: uses ConcurrentDictionary for reads/writes. - /// - public ConcurrentDictionary Models { get; } = new ConcurrentDictionary(); - - /// - /// Gets capabilities for a specific model. - /// Enforces exact name or alias matching only. Wildcard patterns are not supported. - /// - /// The provider name. - /// The model name. - /// Model capabilities or null if not found. - public AIModelCapabilities GetCapabilities(string provider, string model) - { - var key = $"{provider?.ToLowerInvariant()}.{model?.ToLowerInvariant()}"; - Debug.WriteLine($"[GetCapabilities] Looking for '{key}'"); - - // Try exact match first (fastest path) - if (this.Models.TryGetValue(key, out var capabilities)) - { - Debug.WriteLine($"[GetCapabilities] Found exact match for '{key}' with capabilities {capabilities.Capabilities.ToDetailedString()}"); - return capabilities; - } - - // Fallback: search by alias within the same provider - var providerLower = provider?.ToLowerInvariant(); - var modelLower = model?.ToLowerInvariant(); - var byAlias = this.Models.Values - .Where(m => m != null && m.Provider.Equals(providerLower, StringComparison.OrdinalIgnoreCase)) - .FirstOrDefault(m => m.Aliases != null && m.Aliases.Any(a => string.Equals(a, modelLower, StringComparison.OrdinalIgnoreCase))); - - if (byAlias != null) - { - Debug.WriteLine($"[GetCapabilities] Found alias match for '{key}' -> '{byAlias.GetKey()}'"); - return byAlias; - } - - return null; - } - - /// - /// Adds or updates capabilities for a specific model. - /// - /// The model capabilities to add/update. - public void SetCapabilities(AIModelCapabilities capabilities) - { - if (capabilities == null) return; - - var key = capabilities.GetKey(); - this.Models[key] = capabilities; - } - - /// - /// Gets all models that support the specified capabilities. - /// - /// The required capabilities. - /// List of matching model capabilities. - public List FindModelsWithCapabilities(AICapability requiredCapabilities) - { - if (requiredCapabilities == AICapability.None) - { - return this.Models.Values.ToList(); - } - - return this.Models.Values - .Where(model => model.HasCapability(requiredCapabilities)) - .ToList(); - } - - /// - /// Gets the default model for a provider and specific capability. - /// Exact names only; no wildcard resolution. Prioritizes exact default flag; then any compatible default. - /// - /// The provider name. - /// The required capability. - /// The default model name or null if none found. - public string GetDefaultModel(string provider, AICapability requiredCapability = AICapability.Text2Text) - { - if (string.IsNullOrEmpty(provider)) - { - return null; - } - - var providerModels = this.Models.Values - .Where(m => m != null && string.Equals(m.Provider, provider, System.StringComparison.OrdinalIgnoreCase)) - .ToList(); - - Debug.WriteLine($"[ModelManager] Getting the default model among {providerModels.Count} models for {provider} with capability {requiredCapability.ToDetailedString()}"); - - if (!providerModels.Any()) - return null; - - // PRIORITY 1: Exact defaults for the required capability - var concreteExactModel = providerModels - .FirstOrDefault(m => (m.Default & requiredCapability) == requiredCapability); - - if (concreteExactModel != null) - { - Debug.WriteLine($"[ModelManager] Found concrete exact default model {concreteExactModel.Model} for {provider} with capability {requiredCapability.ToDetailedString()}"); - return concreteExactModel.Model; - } - - // PRIORITY 2: Any default that is compatible with the required capability - var concreteCompatibleModel = providerModels - .Where(m => m.Default != AICapability.None && m.HasCapability(requiredCapability)) - .FirstOrDefault(); - - if (concreteCompatibleModel != null) - { - Debug.WriteLine($"[ModelManager] Found concrete compatible default model {concreteCompatibleModel.Model} for {provider} with capability {requiredCapability.ToDetailedString()}"); - return concreteCompatibleModel.Model; - } - - Debug.WriteLine($"[ModelManager] No default model found for {provider} with capability {requiredCapability.ToDetailedString()}"); - return null; - } - } -} diff --git a/src/SmartHopper.Infrastructure/AIModels/ModelManager.cs b/src/SmartHopper.Infrastructure/AIModels/ModelManager.cs deleted file mode 100644 index 31b7395ec..000000000 --- a/src/SmartHopper.Infrastructure/AIModels/ModelManager.cs +++ /dev/null @@ -1,412 +0,0 @@ -/* - * SmartHopper - AI-powered Grasshopper Plugin - * Copyright (C) 2024-2026 Marc Roca Musach - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; - -namespace SmartHopper.Infrastructure.AIModels -{ - /// - /// Unified manager for AI model capabilities with persistent storage. - /// Combines model discovery, capability management, and validation in a single service. - /// - public class ModelManager - { - private static readonly Lazy _instance = new Lazy(() => new ModelManager()); - private AIModelCapabilityRegistry _registry; - private readonly object _syncRoot = new object(); - - /// - /// Gets the singleton instance of the ModelManager. - /// - public static ModelManager Instance => _instance.Value; - - /// - /// Initializes a new instance of the ModelManager. - /// - private ModelManager() - { - this._registry = new AIModelCapabilityRegistry(); - Debug.WriteLine("[ModelManager] Initialized with new capability registry"); - } - - #region Capability Management - - /// - /// Registers model capabilities for a specific provider and model. - /// This is the primary method for providers to register their model capabilities. - /// - /// The provider name. - /// The model name. - /// The model capabilities. - /// The capabilities for which this model should be the default. - public void RegisterCapabilities( - string provider, - string modelName, - AICapability capabilities, - AICapability defaultFor = AICapability.None) - { - if (string.IsNullOrWhiteSpace(provider) || string.IsNullOrWhiteSpace(modelName)) - { - Debug.WriteLine($"[ModelManager] Invalid provider or model name provided for registration"); - return; - } - - var AIModelCapabilities = new AIModelCapabilities - { - Provider = provider.ToLowerInvariant(), - Model = modelName, - Capabilities = capabilities, - Default = defaultFor, - }; - - this.SetCapabilities(AIModelCapabilities); - } - - /// - /// Sets the capability information for a specific model. - /// - /// The model capabilities to store. - public void SetCapabilities(AIModelCapabilities AIModelCapabilities) - { - if (AIModelCapabilities == null) return; - - lock (this._syncRoot) - { - this._registry.SetCapabilities(AIModelCapabilities); - } - - Debug.WriteLine($"[ModelManager] Registered capabilities for {AIModelCapabilities.Provider}.{AIModelCapabilities.Model}"); - } - - /// - /// Marks a model as the default for the given capabilities. When exclusive is true (default), - /// clears those capabilities from Default on other models of the same provider to ensure - /// at most one default per capability. - /// - /// Provider name. - /// Model name. - /// Capabilities to set as default for this model. - /// If true, unsets these defaults from other models of the provider. - public void SetDefault(string provider, string model, AICapability caps, bool exclusive = true) - { - if (string.IsNullOrWhiteSpace(provider) || string.IsNullOrWhiteSpace(model) || caps == AICapability.None) - { - return; - } - - var normalizedProvider = provider.ToLowerInvariant(); - - lock (this._syncRoot) - { - // Optionally clear the bits from other models in the same provider - if (exclusive) - { - var all = this.GetProviderModels(normalizedProvider); - foreach (var m in all) - { - if (!string.Equals(m.Model, model, StringComparison.Ordinal)) - { - var before = m.Default; - m.Default &= ~caps; // clear the specified capability bits - if (m.Default != before) - { - this._registry.SetCapabilities(m); - } - } - } - } - - // Ensure the target model exists (create or update) - var target = this.GetCapabilities(normalizedProvider, model); - if (target == null) - { - target = new AIModelCapabilities - { - Provider = normalizedProvider, - Model = model, - Capabilities = AICapability.None, - Default = AICapability.None, - }; - } - - target.Default |= caps; - this._registry.SetCapabilities(target); - } - - Debug.WriteLine($"[ModelManager] Set default for {normalizedProvider}.{model} -> {caps}"); - } - - /// - /// Gets the capability information for a specific model. - /// - /// The provider name. - /// The model name. - /// Model capabilities or null if not found. - public AIModelCapabilities GetCapabilities(string provider, string model) - { - return this._registry.GetCapabilities(provider, model); - } - - /// - /// Gets the default model for a provider and specific capability. - /// - /// The provider name. - /// The required capability. - /// The default model name or null if none found. - public string GetDefaultModel(string provider, AICapability requiredCapability) - { - if (string.IsNullOrWhiteSpace(provider)) return string.Empty; - - // Snapshot of provider models - var providerModels = this.GetProviderModels(provider); - if (providerModels.Count == 0) return string.Empty; - - // Exact defaults for the capability - var exact = providerModels - .Where(m => (m.Default & requiredCapability) == requiredCapability) - .OrderByDescending(m => m.Verified) - .ThenByDescending(m => m.Rank) - .ThenBy(m => m.Deprecated) - .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) - .FirstOrDefault(); - if (exact != null) return exact.Model; - - // Any default that is compatible - var compatible = providerModels - .Where(m => m.Default != AICapability.None && m.HasCapability(requiredCapability)) - .OrderByDescending(m => m.Verified) - .ThenByDescending(m => m.Rank) - .ThenBy(m => m.Deprecated) - .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) - .FirstOrDefault(); - if (compatible != null) return compatible.Model; - - return string.Empty; - } - - /// - /// Checks if a provider has any registered model capabilities. - /// - /// The provider name to check. - /// True if the provider has any registered capabilities. - public bool HasProviderCapabilities(string provider) - { - if (string.IsNullOrWhiteSpace(provider)) - return false; - - return this._registry.Models.Keys.Any(key => key.StartsWith($"{provider}.", StringComparison.OrdinalIgnoreCase)); - } - - #endregion - - #region Streaming capability - - /// - /// Returns whether the specified provider/model pair supports provider-side streaming. - /// Unknown models are treated as not supporting streaming (safe fallback). - /// - /// Provider name. - /// Model name. - /// True only when the model is registered and explicitly marked as supporting streaming. - public bool ModelSupportsStreaming(string provider, string model) - { - if (string.IsNullOrWhiteSpace(provider) || string.IsNullOrWhiteSpace(model)) - { - return false; - } - - var caps = this.GetCapabilities(provider, model); - if (caps == null) - { - Debug.WriteLine($"[ModelManager] Streaming check: '{provider}.{model}' not registered -> treating as non-streaming"); - return false; - } - - return caps.SupportsStreaming; - } - - #endregion - - #region Model Listing and Selection - - /// - /// Returns all registered models for a provider. - /// - public List GetProviderModels(string provider) - { - if (string.IsNullOrWhiteSpace(provider)) return new List(); - - var models = this._registry.Models.Values - .Where(m => m != null && string.Equals(m.Provider, provider, StringComparison.OrdinalIgnoreCase)) - .ToList(); - - return models; - } - - /// - /// DO NOT CALL THIS DIRECTLY. USE AIProvider.SelectModel() INSTEAD. - /// Centralized model selection and fallback. - /// - If user specified a model: - /// * If known and capable -> use it. - /// * If unknown -> allow it to pass through. - /// * If known but not capable -> fallback. - /// - If no user model or fallback needed: - /// * Prefer preferredDefault when capable. - /// * Then provider defaults with exact capability. - /// * Then other defaults compatible with capability. - /// * Then other registered models ordered by Verified, Rank, and not Deprecated. - /// - /// Provider name. - /// User-specified model (optional). - /// Required capability flags. - /// A preferred default (e.g., settings default) to try first when falling back. - /// Selected model name or empty when none. - public string SelectBestModel(string provider, string userModel, AICapability requiredCapability, string preferredDefault = null) - { - if (string.IsNullOrWhiteSpace(provider) || requiredCapability == AICapability.None) - { - Debug.WriteLine($"[ModelManager.SelectBestModel] Invalid args -> provider='{provider}', requiredCapability='{requiredCapability.ToDetailedString()}'"); - return string.Empty; - } - - Debug.WriteLine($"[ModelManager.SelectBestModel] provider='{provider}', userModel='{userModel}', required='{requiredCapability.ToDetailedString()}', preferredDefault='{preferredDefault}'"); - - // If user specified a model, validate capability if known; allow unknown to pass - if (!string.IsNullOrWhiteSpace(userModel)) - { - var known = this.GetCapabilities(provider, userModel); - if (known == null) - { - // Unknown model -> pass through - Debug.WriteLine($"[ModelManager.SelectBestModel] User model '{userModel}' is unknown for provider '{provider}'. Passing through without override."); - return userModel; - } - - if (known.HasCapability(requiredCapability)) - { - // Known and capable - Debug.WriteLine($"[ModelManager.SelectBestModel] Using user model '{userModel}' (known and capable: {known.Capabilities.ToDetailedString()})"); - return userModel; - } - - // else: fall through to fallback selection - Debug.WriteLine($"[ModelManager.SelectBestModel] User model '{userModel}' is known but NOT capable of {requiredCapability.ToDetailedString()} (has {known.Capabilities.ToDetailedString()}). Falling back."); - } - - // Build candidate list of models that support the capability - var candidates = this.GetProviderModels(provider) - .Where(m => m.HasCapability(requiredCapability)) - .ToList(); - - // Try preferred default first if it is capable - if (!string.IsNullOrWhiteSpace(preferredDefault)) - { - var preferredCaps = this.GetCapabilities(provider, preferredDefault); - if (preferredCaps != null && preferredCaps.HasCapability(requiredCapability)) - { - Debug.WriteLine($"[ModelManager.SelectBestModel] Using preferredDefault '{preferredDefault}' (capable: {preferredCaps.Capabilities.ToDetailedString()})"); - return preferredDefault; - } - else - { - Debug.WriteLine($"[ModelManager.SelectBestModel] preferredDefault '{preferredDefault}' is not capable or unknown. Continuing selection."); - } - } - - if (candidates.Count == 0) - { - Debug.WriteLine($"[ModelManager.SelectBestModel] No candidates found for provider '{provider}' with capability {requiredCapability.ToDetailedString()}."); - return string.Empty; - } - - // 1) Defaults with exact capability - var defaultExact = candidates - .Where(m => (m.Default & requiredCapability) == requiredCapability) - .OrderByDescending(m => m.Verified) - .ThenByDescending(m => m.Rank) - .ThenBy(m => m.Deprecated) - .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) - .FirstOrDefault(); - if (defaultExact != null) - { - Debug.WriteLine($"[ModelManager.SelectBestModel] Selecting provider default (exact) '{defaultExact.Model}'."); - return defaultExact.Model; - } - - // 2) Other defaults that are compatible - var defaultCompatible = candidates - .Where(m => m.Default != AICapability.None) - .OrderByDescending(m => m.Verified) - .ThenByDescending(m => m.Rank) - .ThenBy(m => m.Deprecated) - .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) - .FirstOrDefault(); - if (defaultCompatible != null) - { - Debug.WriteLine($"[ModelManager.SelectBestModel] Selecting provider default (compatible) '{defaultCompatible.Model}'."); - return defaultCompatible.Model; - } - - // 3) Any other registered model, ordered by quality - var best = candidates - .OrderByDescending(m => m.Verified) - .ThenByDescending(m => m.Rank) - .ThenBy(m => m.Deprecated) - .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) - .FirstOrDefault(); - if (best != null) - { - Debug.WriteLine($"[ModelManager.SelectBestModel] Selecting best available '{best.Model}'."); - return best.Model; - } - - Debug.WriteLine($"[ModelManager.SelectBestModel] Failed to select a model; returning empty."); - return string.Empty; - } - - #endregion - - #region Tool Validation - - /// - /// Validates if a model has the required capabilities. - /// - /// The provider name. - /// The model name. - /// The required capability. - /// True if the model has the required capabilities. - public bool ValidateCapabilities(string provider, string model, AICapability requiredCapability) - { - var capabilities = this.GetCapabilities(provider, model); - if (capabilities == null) - { - // Bypass validation for unregistered models - assume they support the required capabilities - Debug.WriteLine($"[ModelManager] Model '{model}' from '{provider}' not registered; bypassing capability validation"); - return true; - } - - Debug.WriteLine($"[ModelManager] Model '{model}' from '{provider}' has capabilities {capabilities.Capabilities.ToDetailedString()}"); - return capabilities.HasCapability(requiredCapability); - } - - #endregion - } -} diff --git a/src/SmartHopper.Infrastructure/AIProviders/ProviderAssemblyLoader.cs b/src/SmartHopper.Infrastructure/AIProviders/ProviderAssemblyLoader.cs new file mode 100644 index 000000000..fdda629a3 --- /dev/null +++ b/src/SmartHopper.Infrastructure/AIProviders/ProviderAssemblyLoader.cs @@ -0,0 +1,249 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.Loader; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Metadata; + +namespace SmartHopper.Infrastructure.AIProviders +{ + /// + /// Custom used to load provider plug-in assemblies in + /// isolation while still binding their references to the host's copy of + /// and other shared dependencies. + /// + /// + /// Loading strategy: + /// + /// + /// Assemblies whose simple name is present in + /// are delegated to , so a provider's + /// IAIProvider resolves to the SAME type identity as the host expects. + /// This is what allows reflection-based plug-in dispatch to work across the ALC + /// boundary. + /// + /// + /// Any other DLL co-located with the provider (provider-private dependencies) + /// is loaded into this ALC, isolated from the host's load context. + /// + /// + /// Native libraries are also resolved relative to the provider directory. + /// + /// + /// + /// + /// + /// Combined with the type-identity check in , + /// this fulfils plan §4.5 (Type identity & dependency loading): providers built + /// against a mismatched copy of the SDK are rejected with a clear error rather than + /// silently failing at activation time. + /// + /// + internal sealed class ProviderLoadContext : AssemblyLoadContext + { + /// + /// Simple assembly names that MUST resolve to the host's copy (default ALC). + /// + private static readonly HashSet SharedAssemblyNames = new(StringComparer.OrdinalIgnoreCase) + { + "SmartHopper.ProviderSdk", + "SmartHopper.Infrastructure", + "Newtonsoft.Json", + "System.Drawing.Common", + }; + + private readonly AssemblyDependencyResolver _resolver; + private readonly string _providerDirectory; + + public ProviderLoadContext(string providerAssemblyPath) + : base(name: $"ProviderLoadContext::{Path.GetFileNameWithoutExtension(providerAssemblyPath)}", isCollectible: false) + { + this._resolver = new AssemblyDependencyResolver(providerAssemblyPath); + this._providerDirectory = Path.GetDirectoryName(providerAssemblyPath) + ?? throw new ArgumentException("Provider assembly path has no directory.", nameof(providerAssemblyPath)); + } + + /// + protected override Assembly Load(AssemblyName assemblyName) + { + // Shared types MUST come from the default ALC so type identity matches host. + if (assemblyName.Name != null && SharedAssemblyNames.Contains(assemblyName.Name)) + { + return null!; + } + + var resolved = this._resolver.ResolveAssemblyToPath(assemblyName); + if (!string.IsNullOrEmpty(resolved) && File.Exists(resolved)) + { + return this.LoadFromAssemblyPath(resolved); + } + + // Fallback: look in the provider directory. + var candidate = Path.Combine(this._providerDirectory, assemblyName.Name + ".dll"); + if (File.Exists(candidate)) + { + return this.LoadFromAssemblyPath(candidate); + } + + return null!; + } + + /// + protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) + { + var path = this._resolver.ResolveUnmanagedDllToPath(unmanagedDllName); + return string.IsNullOrEmpty(path) ? IntPtr.Zero : this.LoadUnmanagedDllFromPath(path); + } + } + + /// + /// Outcome of loading a provider assembly via . + /// + internal enum ProviderLoadOutcome + { + /// Assembly loaded successfully and SDK type identity matched the host. + Loaded, + + /// The file is not a valid managed assembly. + InvalidAssembly, + + /// The assembly was loaded but does not expose any IAIProviderFactory. + NoFactory, + + /// + /// The provider's SDK type identity does not match the host's SDK copy + /// (it was likely built against a different SDK version). + /// + SdkTypeIdentityMismatch, + + /// + /// The provider's / + /// metadata is incompatible with the host's SDK version. + /// + SdkVersionIncompatible, + } + + /// + /// Loads a provider assembly into an isolated , + /// verifies that its SDK type identity matches the host's copy, and returns the + /// loaded assembly plus an outcome value the caller can act on. + /// + internal static class ProviderAssemblyLoader + { + /// + /// Try to load into a per-provider ALC and validate + /// it against the host's SDK type identity. + /// + /// Full path to the provider DLL. + /// The loaded assembly on success; otherwise null. + /// A user-facing diagnostic message describing the outcome. + /// The outcome of the load attempt. + public static ProviderLoadOutcome TryLoad( + string assemblyPath, + out Assembly? assembly, + out string diagnostic) + { + assembly = null; + diagnostic = string.Empty; + + try + { + var alc = new ProviderLoadContext(assemblyPath); + assembly = alc.LoadFromAssemblyPath(assemblyPath); + } + catch (BadImageFormatException ex) + { + diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' is not a valid managed assembly: {ex.Message}"; + return ProviderLoadOutcome.InvalidAssembly; + } + catch (FileLoadException ex) + { + diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' failed to load: {ex.Message}"; + return ProviderLoadOutcome.InvalidAssembly; + } + catch (Exception ex) + { + diagnostic = $"Unexpected error loading provider '{Path.GetFileName(assemblyPath)}': {ex.Message}"; + return ProviderLoadOutcome.InvalidAssembly; + } + + // Type-identity check: any IAIProviderFactory exposed by the provider must + // refer to the SAME runtime type as the one in the host's loaded SDK. + Type[] exportedTypes; + try + { + exportedTypes = assembly.GetTypes(); + } + catch (ReflectionTypeLoadException ex) + { + exportedTypes = ex.Types.Where(t => t != null).ToArray()!; + Debug.WriteLine($"[ProviderAssemblyLoader] ReflectionTypeLoadException in {Path.GetFileName(assemblyPath)}: {ex.Message}"); + } + + var factoryTypeFromHost = typeof(IAIProviderFactory); + var factoryFromAssembly = exportedTypes + .FirstOrDefault(t => t is not null && t.GetInterfaces().Any(i => + string.Equals(i.FullName, factoryTypeFromHost.FullName, StringComparison.Ordinal))); + + if (factoryFromAssembly is null) + { + diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' does not expose any type implementing IAIProviderFactory and will be ignored."; + return ProviderLoadOutcome.NoFactory; + } + + var sdkInterfaceSeenByProvider = factoryFromAssembly + .GetInterfaces() + .FirstOrDefault(i => string.Equals(i.FullName, factoryTypeFromHost.FullName, StringComparison.Ordinal)); + + if (sdkInterfaceSeenByProvider is null + || sdkInterfaceSeenByProvider.Assembly != factoryTypeFromHost.Assembly) + { + var hostSdk = factoryTypeFromHost.Assembly.GetName(); + var providerSdk = sdkInterfaceSeenByProvider?.Assembly.GetName(); + diagnostic = + $"Provider '{Path.GetFileName(assemblyPath)}' was built against a different SmartHopper.ProviderSdk and cannot be loaded.\n" + + $"Host SDK: {hostSdk.Name} v{hostSdk.Version}\n" + + $"Provider SDK: {(providerSdk == null ? "(unresolved)" : $"{providerSdk.Name} v{providerSdk.Version}")}"; + return ProviderLoadOutcome.SdkTypeIdentityMismatch; + } + + // SemVer-based compatibility check using BuiltAgainstSdk/MinHostSdk attributes. + // MissingMetadata is tolerated (logged via diagnostic but not blocking) because + // first-party providers ship without these attributes set explicitly today. + var compatResult = SdkCompatibility.Check(assembly, out var compatDiagnostic); + switch (compatResult) + { + case SdkCompatibility.CompatibilityResult.MajorMismatch: + case SdkCompatibility.CompatibilityResult.HostTooOld: + diagnostic = compatDiagnostic; + return ProviderLoadOutcome.SdkVersionIncompatible; + case SdkCompatibility.CompatibilityResult.MissingMetadata: + Debug.WriteLine($"[ProviderAssemblyLoader] {compatDiagnostic}"); + break; + } + + return ProviderLoadOutcome.Loaded; + } + } +} diff --git a/src/SmartHopper.Infrastructure/AIProviders/ProviderClassifier.cs b/src/SmartHopper.Infrastructure/AIProviders/ProviderClassifier.cs new file mode 100644 index 000000000..b3c46124a --- /dev/null +++ b/src/SmartHopper.Infrastructure/AIProviders/ProviderClassifier.cs @@ -0,0 +1,315 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Threading.Tasks; +using SmartHopper.Infrastructure.Utils; + +namespace SmartHopper.Infrastructure.AIProviders +{ + /// + /// High-level classification of a provider assembly as determined by the + /// cryptographic checks in . + /// + /// + /// Classification is based purely on strong-name token, Authenticode certificate + /// (Windows only), and the SmartHopper-managed SHA-256 hash manifest. It deliberately + /// ignores provider id, assembly file name, and any metadata claim — those can be + /// trivially spoofed and provide no security guarantee. + /// + /// + public enum ProviderClassification + { + /// + /// The provider is cryptographically attributable to SmartHopper itself: it + /// passes strong-name + Authenticode verification (where applicable) and/or + /// matches the official hash manifest, with no contradicting signals. + /// + Official, + + /// + /// The provider claims to be official by one signal (e.g. hash listed in the + /// manifest) but another signal contradicts it (e.g. signature mismatch, or + /// hash mismatch). Always blocked. + /// + OfficialTampered, + + /// + /// The provider is a valid managed assembly that is NOT cryptographically tied + /// to SmartHopper. Includes both signed-by-other-key and unsigned third-party + /// DLLs. + /// + Community, + + /// + /// The file is not a valid managed assembly, fails SDK type identity, has no + /// IAIProviderFactory, has malformed metadata, or could not be loaded. + /// Always blocked. + /// + Invalid, + } + + /// + /// Result of a single call. + /// + public sealed class ProviderClassificationResult + { + /// The final classification. + public ProviderClassification Classification { get; init; } + + /// The SHA-256 hash of the file (hex, lower-case), or null if not computed. + public string? Sha256 { get; init; } + + /// Strong-name public key token (hex), or null if unsigned/unreadable. + public string? StrongNameToken { get; init; } + + /// Whether the strong-name token matches the host's token. + public bool StrongNameMatchesHost { get; init; } + + /// Authenticode signer subject (Windows only), or null. + public string? AuthenticodeSubject { get; init; } + + /// Authenticode signer SHA-1 thumbprint (Windows only), or null. + public string? AuthenticodeThumbprint { get; init; } + + /// Whether the Authenticode signature matches the host's certificate. + public bool AuthenticodeMatchesHost { get; init; } + + /// Result of the official-hash-manifest lookup, when performed. + public ProviderVerificationStatus HashStatus { get; init; } + + /// Diagnostic message for logs and dialogs. + public string Diagnostic { get; init; } = string.Empty; + } + + /// + /// Cryptographic classifier for provider assemblies. Returns a + /// the caller can act on — it never + /// throws to block loading, and it never trusts file names or assembly metadata. + /// + public static class ProviderClassifier + { + /// + /// Classify the provider assembly at . + /// + /// Full path to the candidate provider DLL. + public static async Task ClassifyAsync(string assemblyPath) + { + if (assemblyPath is null) + { + throw new ArgumentNullException(nameof(assemblyPath)); + } + + if (!File.Exists(assemblyPath)) + { + return new ProviderClassificationResult + { + Classification = ProviderClassification.Invalid, + Diagnostic = $"Provider file not found: {assemblyPath}", + }; + } + + string? sha256 = null; + try + { + sha256 = ProviderHashVerifier.CalculateFileHash(assemblyPath); + } + catch (Exception ex) + { + Debug.WriteLine($"[ProviderClassifier] Failed to hash {assemblyPath}: {ex.Message}"); + } + + string? token = null; + bool tokenMatchesHost = false; + try + { + var asmName = AssemblyName.GetAssemblyName(assemblyPath); + var rawToken = asmName.GetPublicKeyToken(); + if (rawToken is { Length: > 0 }) + { + token = BitConverter.ToString(rawToken).Replace("-", string.Empty).ToLowerInvariant(); + var hostToken = typeof(ProviderClassifier).Assembly.GetName().GetPublicKeyToken(); + if (hostToken is { Length: > 0 }) + { + tokenMatchesHost = rawToken.SequenceEqual(hostToken); + } + } + } + catch (BadImageFormatException ex) + { + return new ProviderClassificationResult + { + Classification = ProviderClassification.Invalid, + Sha256 = sha256, + Diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' is not a valid managed assembly: {ex.Message}", + }; + } + catch (Exception ex) + { + Debug.WriteLine($"[ProviderClassifier] Failed to read strong name for {assemblyPath}: {ex.Message}"); + } + + string? authSubject = null; + string? authThumb = null; + bool authMatchesHost = false; + bool authSignaturePresent = false; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + try + { + var cert = new X509Certificate2(X509Certificate.CreateFromSignedFile(assemblyPath)); + authSubject = cert.Subject; + authThumb = cert.Thumbprint; + authSignaturePresent = true; + + try + { + var hostCert = new X509Certificate2(X509Certificate.CreateFromSignedFile( + Assembly.GetExecutingAssembly().Location)); + authMatchesHost = string.Equals(cert.Thumbprint, hostCert.Thumbprint, StringComparison.OrdinalIgnoreCase); + } + catch (Exception) + { + // Host not signed (e.g. local dev build); cannot compare. + authMatchesHost = false; + } + } + catch (CryptographicException) + { + // No Authenticode signature; treat as unsigned. + } + catch (Exception ex) + { + Debug.WriteLine($"[ProviderClassifier] Authenticode read error for {assemblyPath}: {ex.Message}"); + } + } + + // Official hash manifest lookup (cross-platform). + var hashStatus = ProviderVerificationStatus.NotFound; + try + { + var platform = VersionHelper.GetPlatform(); + var version = VersionHelper.GetDisplayVersion(); + var hashResult = await ProviderHashVerifier.VerifyProviderAsync(assemblyPath, version, platform).ConfigureAwait(false); + hashStatus = hashResult.Status; + } + catch (Exception ex) + { + Debug.WriteLine($"[ProviderClassifier] Hash manifest lookup failed for {assemblyPath}: {ex.Message}"); + } + + // Tampered: any positive signal of "official" combined with a negative crypto signal. + bool hashOnAllowList = hashStatus == ProviderVerificationStatus.Match; + bool hashMismatch = hashStatus == ProviderVerificationStatus.Mismatch; + + if (hashOnAllowList && (token is not null && !tokenMatchesHost && tokenMatchesHost == false)) + { + // Hash claims official but strong-name token disagrees — tampered. + if (token is not null && !tokenMatchesHost) + { + return new ProviderClassificationResult + { + Classification = ProviderClassification.OfficialTampered, + Sha256 = sha256, + StrongNameToken = token, + StrongNameMatchesHost = tokenMatchesHost, + AuthenticodeSubject = authSubject, + AuthenticodeThumbprint = authThumb, + AuthenticodeMatchesHost = authMatchesHost, + HashStatus = hashStatus, + Diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' is listed in the official hash manifest but its strong-name token does not match SmartHopper. The file has been tampered with.", + }; + } + } + + if (hashMismatch && tokenMatchesHost) + { + // Strong-name matches SmartHopper but hash mismatches — tampered official build. + return new ProviderClassificationResult + { + Classification = ProviderClassification.OfficialTampered, + Sha256 = sha256, + StrongNameToken = token, + StrongNameMatchesHost = tokenMatchesHost, + AuthenticodeSubject = authSubject, + AuthenticodeThumbprint = authThumb, + AuthenticodeMatchesHost = authMatchesHost, + HashStatus = hashStatus, + Diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' is strong-named by SmartHopper but its SHA-256 hash does not match the published value. The file has been tampered with.", + }; + } + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + && authSignaturePresent && !authMatchesHost && tokenMatchesHost) + { + // Authenticode says someone else signed it, but the strong-name token claims SmartHopper. + return new ProviderClassificationResult + { + Classification = ProviderClassification.OfficialTampered, + Sha256 = sha256, + StrongNameToken = token, + StrongNameMatchesHost = tokenMatchesHost, + AuthenticodeSubject = authSubject, + AuthenticodeThumbprint = authThumb, + AuthenticodeMatchesHost = authMatchesHost, + HashStatus = hashStatus, + Diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' carries SmartHopper's strong-name token but its Authenticode certificate does not match. The file has been tampered with.", + }; + } + + // Official: any positive crypto signal, with no contradicting signal. + bool authOfficialOnWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && authMatchesHost; + if (tokenMatchesHost || authOfficialOnWindows || hashOnAllowList) + { + return new ProviderClassificationResult + { + Classification = ProviderClassification.Official, + Sha256 = sha256, + StrongNameToken = token, + StrongNameMatchesHost = tokenMatchesHost, + AuthenticodeSubject = authSubject, + AuthenticodeThumbprint = authThumb, + AuthenticodeMatchesHost = authMatchesHost, + HashStatus = hashStatus, + Diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' classified as Official.", + }; + } + + // Community: not an official signal, but still a valid managed assembly. + return new ProviderClassificationResult + { + Classification = ProviderClassification.Community, + Sha256 = sha256, + StrongNameToken = token, + StrongNameMatchesHost = tokenMatchesHost, + AuthenticodeSubject = authSubject, + AuthenticodeThumbprint = authThumb, + AuthenticodeMatchesHost = authMatchesHost, + HashStatus = hashStatus, + Diagnostic = $"Provider '{Path.GetFileName(assemblyPath)}' classified as Community (not signed by SmartHopper).", + }; + } + } +} diff --git a/src/SmartHopper.Infrastructure/AIProviders/ProviderHashVerifier.cs b/src/SmartHopper.Infrastructure/AIProviders/ProviderHashVerifier.cs index 149f2ac35..74d7ed898 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/ProviderHashVerifier.cs +++ b/src/SmartHopper.Infrastructure/AIProviders/ProviderHashVerifier.cs @@ -28,6 +28,8 @@ using System.Threading.Tasks; using Newtonsoft.Json; using SmartHopper.Infrastructure.Utils; +using SmartHopper.ProviderSdk.Hosting; +using SmartHopper.ProviderSdk.Utils; namespace SmartHopper.Infrastructure.AIProviders { @@ -49,30 +51,6 @@ public enum ProviderVerificationStatus NotFound } - /// - /// Provider integrity check mode defining how verification failures are handled. - /// - public enum ProviderIntegrityCheckMode - { - /// - /// Strict mode: Will block providers on mismatch, unavailable and not found. - /// Highest security, requires all providers to have valid published hashes. - /// - Strict, - - /// - /// Hard check mode: Will block providers on mismatch and not found. - /// Allows loading when hash repository is unavailable (network issues). - /// - Hard, - - /// - /// Soft check mode: Will warn but not block providers on mismatch, unavailable and not found. - /// Best for development and third-party providers. Default mode. - /// - Soft - } - /// /// Verification result containing hash comparison status and details. /// @@ -92,7 +70,7 @@ public sealed class ProviderVerificationResult /// /// Verifies provider DLL integrity using SHA-256 hashes from public repository. /// - internal class ProviderHashVerifier + public class ProviderHashVerifier { private const string HashBaseUrl = "https://architects-toolkit.github.io/SmartHopper/hashes"; private static readonly HttpClient HttpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) }; diff --git a/src/SmartHopper.Infrastructure/AIProviders/ProviderManager.cs b/src/SmartHopper.Infrastructure/AIProviders/ProviderManager.cs index a8bad3a9b..3f6d69255 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/ProviderManager.cs +++ b/src/SmartHopper.Infrastructure/AIProviders/ProviderManager.cs @@ -33,6 +33,10 @@ using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Settings; using SmartHopper.Infrastructure.Utils; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Hosting; +using SmartHopper.ProviderSdk.Settings; +using SmartHopper.ProviderSdk.Utils; namespace SmartHopper.Infrastructure.AIProviders { @@ -52,11 +56,18 @@ public class ProviderManager private readonly ConcurrentDictionary _mismatchedProviders = new ConcurrentDictionary(); // Tracks providers with hash mismatches private readonly ConcurrentDictionary _unavailableProviders = new ConcurrentDictionary(); // Tracks providers where hash check was unavailable (network issues) private readonly ConcurrentDictionary _unknownProviders = new ConcurrentDictionary(); // Tracks providers not found in hash manifest (custom/third-party) + private readonly ConcurrentDictionary _providerClassifications = new ConcurrentDictionary(); // Tracks each loaded provider's classification + private readonly ConcurrentDictionary _unsignedProviders = new ConcurrentDictionary(); // Tracks providers loaded without any strong-name signature private ProviderManager() { // NOTE: Do NOT automatically call RefreshProviders() here to avoid circular dependencies // RefreshProviders() should be called explicitly after initialization + + // Wire the SDK host composition root so SDK code (validation, runtime + // messages, request building) can consume host services without taking + // a hard dependency on Infrastructure singletons. + ProviderSdkHost.ProviderTrust = new SmartHopperProviderTrustHost(); } /// @@ -70,22 +81,54 @@ private async Task DiscoverProvidersAsync() this._mismatchedProviders.Clear(); this._unavailableProviders.Clear(); this._unknownProviders.Clear(); - - // Get the directory where the current assembly is located + this._providerClassifications.Clear(); + this._unsignedProviders.Clear(); + + // Scan both the app-local provider directory (next to the executing + // assembly) and the user-local provider directory under + // %AppData%/SmartHopper/Providers. App-local wins on duplicate ids per + // plan §2.2 — we discover app-local first, then user-local, and the + // loader rejects duplicates. string assemblyLocation = Assembly.GetExecutingAssembly().Location; - string baseDirectory = Path.GetDirectoryName(assemblyLocation); + string baseDirectory = Path.GetDirectoryName(assemblyLocation) ?? string.Empty; + var providerSearchPaths = new List { baseDirectory }; - // Find all external provider DLLs - string[] providerFiles = Directory.GetFiles(baseDirectory, "SmartHopper.Providers.*.dll"); - foreach (string providerFile in providerFiles) + try { + var userLocal = GetUserLocalProvidersDirectory(); + if (!string.IsNullOrEmpty(userLocal) && Directory.Exists(userLocal)) + { + providerSearchPaths.Add(userLocal); + } + } + catch (Exception ex) + { + Debug.WriteLine($"[ProviderManager] Could not resolve user-local provider directory: {ex.Message}"); + } + + foreach (var searchPath in providerSearchPaths) + { + string[] providerFiles; try { - await this.LoadProviderAssemblyAsync(providerFile).ConfigureAwait(false); + providerFiles = Directory.GetFiles(searchPath, "SmartHopper.Providers.*.dll"); } catch (Exception ex) { - Debug.WriteLine($"Error loading provider assembly {providerFile}: {ex.Message}"); + Debug.WriteLine($"[ProviderManager] Could not enumerate provider files in {searchPath}: {ex.Message}"); + continue; + } + + foreach (string providerFile in providerFiles) + { + try + { + await this.LoadProviderAssemblyAsync(providerFile).ConfigureAwait(false); + } + catch (Exception ex) + { + Debug.WriteLine($"Error loading provider assembly {providerFile}: {ex.Message}"); + } } } } @@ -95,6 +138,19 @@ private async Task DiscoverProvidersAsync() } } + /// + /// Returns the user-local provider directory, typically + /// %AppData%/SmartHopper/Providers on Windows and the equivalent + /// ~/Library/Application Support/SmartHopper/Providers on macOS. This + /// directory is in addition to the app-local provider folder (next to the + /// SmartHopper assemblies) and is rescanned on every . + /// + public static string GetUserLocalProvidersDirectory() + { + var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + return Path.Combine(appData, "SmartHopper", "Providers"); + } + /// /// Manually triggers discovery of external AI providers. /// @@ -168,26 +224,62 @@ private async Task LoadProviderAssemblyAsync(string assemblyPath) { try { - // Authenticode signature validation (Windows-only, skip on macOS) - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + // Cryptographic classification: replaces the old throw-to-block VerifySignature + // path. Returns a structured result so we can apply policy uniformly. + var classification = await ProviderClassifier.ClassifyAsync(assemblyPath).ConfigureAwait(false); + var policySettings = SmartHopperSettings.Instance; + var asmFileName = Path.GetFileName(assemblyPath); + var asmBaseName = Path.GetFileNameWithoutExtension(assemblyPath); + + // Track strong-name absence for warning surfacing. + if (string.IsNullOrEmpty(classification.StrongNameToken)) { - try - { - this.VerifySignature(assemblyPath); - } - catch (CryptographicException ex) - { - Debug.WriteLine($"Authenticode signature verification failed for {assemblyPath}: {ex.Message}"); + this._unsignedProviders[asmBaseName] = true; + } + + switch (classification.Classification) + { + case ProviderClassification.Invalid: + Debug.WriteLine($"[ProviderManager] {classification.Diagnostic}"); + RhinoApp.WriteLine($"[SmartHopper] {classification.Diagnostic}"); + return; + + case ProviderClassification.OfficialTampered: + // Always block, regardless of settings. + Debug.WriteLine($"[ProviderManager] {classification.Diagnostic}"); + RhinoApp.WriteLine($"[SmartHopper] {classification.Diagnostic}"); await Task.Run(() => RhinoApp.InvokeOnUiThread(() => { - StyledMessageDialog.ShowError($"Authenticode signature verification failed for provider '{Path.GetFileName(assemblyPath)}'. Please replace it with a file downloaded from official SmartHopper sources.", "SmartHopper"); + StyledMessageDialog.ShowError( + classification.Diagnostic + "\n\nThe provider will not be loaded.", + "Provider Tampering Detected - SmartHopper"); })).ConfigureAwait(false); return; - } - } - else - { - Debug.WriteLine($"[ProviderManager] Skipping Authenticode verification on non-Windows platform for {Path.GetFileName(assemblyPath)}"); + + case ProviderClassification.Community: + if (policySettings.BlockNonOfficialProviders) + { + Debug.WriteLine($"[ProviderManager] Community provider '{asmFileName}' blocked by BlockNonOfficialProviders policy."); + RhinoApp.WriteLine($"[SmartHopper] Community provider '{asmFileName}' blocked by the BlockNonOfficialProviders policy."); + return; + } + + if (!policySettings.AllowCommunityProviders) + { + Debug.WriteLine($"[ProviderManager] Community provider '{asmFileName}' blocked because AllowCommunityProviders is disabled."); + RhinoApp.WriteLine($"[SmartHopper] Community provider '{asmFileName}' was not loaded. To enable community providers, turn on 'Allow community providers' in Settings."); + return; + } + + // Allowed to attempt load. The hash-mode / per-provider trust + // flow below still applies; we additionally record the classification + // on successful registration so components can surface warnings. + break; + + case ProviderClassification.Official: + // Continue through the rest of the flow (hash policy, trust prompt + // on first discovery if it's an unknown DLL). + break; } // SHA-256 hash verification (cross-platform) @@ -377,8 +469,16 @@ await Task.Run(() => RhinoApp.InvokeOnUiThread(() => Debug.WriteLine($"[ProviderManager] Trust already exists for: {asmName} = {settings.TrustedProviders[asmName]}"); } - // Load the assembly - var assembly = Assembly.LoadFrom(assemblyPath); + // Load the assembly into an isolated per-provider ALC and validate + // that its IAIProviderFactory references resolve to the host's SDK + // type identity. This rejects providers built against a mismatched SDK. + var loadOutcome = ProviderAssemblyLoader.TryLoad(assemblyPath, out var assembly, out var loadDiagnostic); + if (loadOutcome != ProviderLoadOutcome.Loaded || assembly is null) + { + Debug.WriteLine($"[ProviderManager] {loadDiagnostic} (outcome={loadOutcome})"); + RhinoApp.WriteLine($"[SmartHopper] {loadDiagnostic}"); + return; + } // Find all types that implement IAIProviderFactory var factoryTypes = assembly.GetTypes() @@ -396,10 +496,12 @@ await Task.Run(() => RhinoApp.InvokeOnUiThread(() => var provider = factory.CreateProvider(); var providerSettings = factory.CreateProviderSettings(); - // Register the provider + // Register the provider with its cryptographic classification so + // components and the WebChat banner can surface warnings. this.RegisterProvider(provider, providerSettings, assembly); + this._providerClassifications[provider.Name] = classification.Classification; - Debug.WriteLine($"Successfully registered provider: {provider.Name} from {assembly.GetName().Name}"); + Debug.WriteLine($"Successfully registered provider: {provider.Name} from {assembly.GetName().Name} (classification={classification.Classification})"); } catch (Exception ex) { @@ -424,6 +526,40 @@ private void RegisterProvider(IAIProvider provider, IAIProviderSettings settings if (provider == null || string.IsNullOrEmpty(provider.Name)) return; + // Duplicate provider id resolution per plan §2.2: + // Official > trusted Community > everything else. + // Tampered/Invalid never reach this method (they're filtered earlier). + if (this._providers.ContainsKey(provider.Name)) + { + var existingClass = this._providerClassifications.TryGetValue(provider.Name, out var ec) + ? ec + : ProviderClassification.Community; + + // We don't know the incoming classification here without re-running the + // classifier; the caller of RegisterProvider always sets the entry into + // _providerClassifications immediately after, so for now we treat ties + // as "first one wins" unless the incoming provider's assembly is signed + // by SmartHopper (which we can detect cheaply). + var existingTokenMatches = false; + if (this._providerAssemblies.TryGetValue(provider.Name, out var existingAssembly)) + { + var hostToken = typeof(ProviderManager).Assembly.GetName().GetPublicKeyToken(); + var existingToken = existingAssembly.GetName().GetPublicKeyToken(); + existingTokenMatches = hostToken is { Length: > 0 } + && existingToken is { Length: > 0 } + && hostToken.SequenceEqual(existingToken); + } + + if (existingTokenMatches || existingClass == ProviderClassification.Official) + { + Debug.WriteLine($"[ProviderManager] Duplicate provider id '{provider.Name}' rejected from '{assembly?.GetName().Name}' — an official provider with that id is already registered."); + RhinoApp.WriteLine($"[SmartHopper] A duplicate provider id '{provider.Name}' was ignored (an official provider with that id is already loaded)."); + return; + } + + Debug.WriteLine($"[ProviderManager] Duplicate provider id '{provider.Name}' from '{assembly?.GetName().Name}' is replacing the previously registered instance."); + } + // Add the provider and its settings to our dictionaries this._providers[provider.Name] = provider; this._providerSettings[provider.Name] = settings; @@ -434,13 +570,26 @@ private void RegisterProvider(IAIProvider provider, IAIProviderSettings settings this._providerAssemblies[provider.Name] = assembly; } - // Initialize provider asynchronously without blocking + // Initialize provider asynchronously without blocking. A misbehaving + // provider (hang, throw, exhaust resources) MUST NOT take down discovery + // or affect other providers — wrap in per-provider timeout + try/catch. _ = Task.Run(async () => { try { - await provider.InitializeProviderAsync().ConfigureAwait(false); - Debug.WriteLine($"[ProviderManager] Successfully initialized provider: {provider.Name}"); + using var cts = new System.Threading.CancellationTokenSource(ProviderInitializationTimeout); + var initTask = provider.InitializeProviderAsync(); + var winner = await Task.WhenAny(initTask, Task.Delay(ProviderInitializationTimeout, cts.Token)).ConfigureAwait(false); + if (winner != initTask) + { + Debug.WriteLine($"[ProviderManager] Initialization of provider '{provider.Name}' timed out after {ProviderInitializationTimeout.TotalSeconds:0}s and was abandoned. The provider may behave unpredictably."); + RhinoApp.WriteLine($"[SmartHopper] Provider '{provider.Name}' initialization timed out; functionality may be limited."); + } + else + { + await initTask.ConfigureAwait(false); + Debug.WriteLine($"[ProviderManager] Successfully initialized provider: {provider.Name}"); + } } catch (Exception ex) { @@ -449,6 +598,14 @@ private void RegisterProvider(IAIProvider provider, IAIProviderSettings settings }); } + /// + /// Per-provider initialization timeout, after which the provider's + /// is abandoned (it keeps + /// running but the manager no longer waits on it). Prevents one misbehaving + /// provider from stalling the entire host. + /// + private static readonly TimeSpan ProviderInitializationTimeout = TimeSpan.FromSeconds(30); + /// /// Gets all providers, optionally including untrusted ones. /// @@ -667,6 +824,83 @@ public bool IsProviderUnknown(string providerName) return false; } + /// + /// Returns the cryptographic classification recorded for the given provider, or + /// if the provider is not registered. + /// + /// The registered provider name. + public ProviderClassification GetProviderClassification(string providerName) + { + if (string.IsNullOrEmpty(providerName)) + { + return ProviderClassification.Invalid; + } + + return this._providerClassifications.TryGetValue(providerName, out var c) + ? c + : ProviderClassification.Invalid; + } + + /// + /// Returns true if the provider was loaded with a non-Official classification + /// (community / unsigned / third-party). Components can use this to display + /// warning badges on every AI component using that provider. + /// + /// The registered provider name. + public bool IsProviderCommunity(string providerName) + { + return this.GetProviderClassification(providerName) == ProviderClassification.Community; + } + + /// + /// Returns true if the provider's assembly is loaded without any + /// strong-name signature. + /// + /// The registered provider name. + public bool IsProviderUnsigned(string providerName) + { + if (string.IsNullOrEmpty(providerName)) + { + return false; + } + + if (this._providerAssemblies.TryGetValue(providerName, out var assembly)) + { + var asmName = assembly.GetName().Name; + return asmName != null && this._unsignedProviders.ContainsKey(asmName); + } + + return false; + } + + /// + /// Returns the persisted for the given + /// provider, or null if no decision has been recorded yet. + /// + /// The registered provider name. + public TrustedProviderRecord? GetProviderTrustRecord(string providerName) + { + if (string.IsNullOrEmpty(providerName)) + { + return null; + } + + string? key = providerName; + if (this._providerAssemblies.TryGetValue(providerName, out var assembly)) + { + key = assembly.GetName().Name ?? providerName; + } + + var settings = SmartHopperSettings.Instance; + if (settings.TrustedProviderRecords != null + && settings.TrustedProviderRecords.TryGetValue(key!, out var record)) + { + return record; + } + + return null; + } + /// /// Gets the default AI provider from settings, or the first available provider if not set. /// diff --git a/src/SmartHopper.Infrastructure/AIProviders/SmartHopperProviderTrustHost.cs b/src/SmartHopper.Infrastructure/AIProviders/SmartHopperProviderTrustHost.cs new file mode 100644 index 000000000..f680ef327 --- /dev/null +++ b/src/SmartHopper.Infrastructure/AIProviders/SmartHopperProviderTrustHost.cs @@ -0,0 +1,55 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.Hosting; + +namespace SmartHopper.Infrastructure.AIProviders +{ + /// + /// Host-side adapter wiring and + /// into the SDK's + /// abstraction. + /// + public sealed class SmartHopperProviderTrustHost : IProviderTrustHost + { + /// + public ProviderIntegrityCheckMode EffectiveIntegrityCheckMode + => SmartHopperSettings.Instance.EffectiveProviderIntegrityCheckMode; + + /// + public bool IsProviderMismatched(string providerName) + => ProviderManager.Instance.IsProviderMismatched(providerName); + + /// + public bool IsProviderUnavailable(string providerName) + => ProviderManager.Instance.IsProviderUnavailable(providerName); + + /// + public bool IsProviderUnknown(string providerName) + => ProviderManager.Instance.IsProviderUnknown(providerName); + + /// + public bool IsProviderCommunity(string providerName) + => ProviderManager.Instance.IsProviderCommunity(providerName); + + /// + public bool IsProviderUnsigned(string providerName) + => ProviderManager.Instance.IsProviderUnsigned(providerName); + } +} diff --git a/src/SmartHopper.Infrastructure/AITools/AITool.cs b/src/SmartHopper.Infrastructure/AITools/AITool.cs index e92ed08f4..e1a17d1ad 100644 --- a/src/SmartHopper.Infrastructure/AITools/AITool.cs +++ b/src/SmartHopper.Infrastructure/AITools/AITool.cs @@ -18,10 +18,10 @@ using System; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; namespace SmartHopper.Infrastructure.AITools { diff --git a/src/SmartHopper.Infrastructure/AITools/ToolManager.cs b/src/SmartHopper.Infrastructure/AITools/ToolManager.cs index 90e0d36c6..3494bd171 100644 --- a/src/SmartHopper.Infrastructure/AITools/ToolManager.cs +++ b/src/SmartHopper.Infrastructure/AITools/ToolManager.cs @@ -22,10 +22,10 @@ using System.Linq; using System.Reflection; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Infrastructure.AITools { @@ -117,7 +117,7 @@ public static async Task ExecuteTool(AIToolCall toolCall) try { var results = result?.Body?.Interactions? - .OfType() + .OfType() .ToList(); if (results != null && results.Count > 0) { diff --git a/src/SmartHopper.Infrastructure/Dialogs/ProviderVerificationDialog.cs b/src/SmartHopper.Infrastructure/Dialogs/ProviderVerificationDialog.cs index d3609f6e6..d40966478 100644 --- a/src/SmartHopper.Infrastructure/Dialogs/ProviderVerificationDialog.cs +++ b/src/SmartHopper.Infrastructure/Dialogs/ProviderVerificationDialog.cs @@ -25,6 +25,7 @@ using Rhino.UI; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Properties; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Infrastructure.Dialogs { diff --git a/src/SmartHopper.Infrastructure/Dialogs/StyledMessageDialog.cs b/src/SmartHopper.Infrastructure/Dialogs/StyledMessageDialog.cs index 4e59597c1..75416cc2c 100644 --- a/src/SmartHopper.Infrastructure/Dialogs/StyledMessageDialog.cs +++ b/src/SmartHopper.Infrastructure/Dialogs/StyledMessageDialog.cs @@ -36,7 +36,7 @@ namespace SmartHopper.Infrastructure.Dialogs /// Provides styled Eto.Forms dialogs for displaying info, warning, error messages, and confirmations with the SmartHopper logo. /// Uses DynamicLayout for responsive content that properly wraps and adapts to dialog size. /// - internal class StyledMessageDialog : Dialog + public class StyledMessageDialog : Dialog { private bool _result; private readonly Guid _linkedInstanceGuid = Guid.Empty; diff --git a/src/SmartHopper.Infrastructure/Initialization/SmartHopperInitializer.cs b/src/SmartHopper.Infrastructure/Initialization/SmartHopperInitializer.cs index b40e63343..1d884fe40 100644 --- a/src/SmartHopper.Infrastructure/Initialization/SmartHopperInitializer.cs +++ b/src/SmartHopper.Infrastructure/Initialization/SmartHopperInitializer.cs @@ -24,6 +24,9 @@ using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Settings; using SmartHopper.Infrastructure.Utils; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; +using SmartHopper.ProviderSdk.Utils; namespace SmartHopper.Infrastructure.Initialization { diff --git a/src/SmartHopper.Infrastructure/Settings/SmartHopperSettings.cs b/src/SmartHopper.Infrastructure/Settings/SmartHopperSettings.cs index 966825655..ef58b7e4b 100644 --- a/src/SmartHopper.Infrastructure/Settings/SmartHopperSettings.cs +++ b/src/SmartHopper.Infrastructure/Settings/SmartHopperSettings.cs @@ -26,6 +26,9 @@ using System.Text; using Newtonsoft.Json; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Hosting; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Infrastructure.Settings { @@ -80,6 +83,32 @@ public class SmartHopperSettings [JsonProperty] public ProviderIntegrityCheckMode ProviderIntegrityCheckMode { get; set; } + /// + /// Gets or sets a value indicating whether non-official providers (Community) + /// are even considered for loading. When false (default), community + /// providers are blocked at discovery time regardless of any user trust + /// recorded in . When true, they may load + /// subject to and per-provider trust. + /// + [JsonProperty] + public bool AllowCommunityProviders { get; set; } + + /// + /// Gets or sets a hard override that blocks any provider not classified as + /// Official, regardless of or per-provider + /// trust. Intended for locked-down installations. + /// + [JsonProperty] + public bool BlockNonOfficialProviders { get; set; } + + /// + /// Gets or sets the structured per-provider trust records (introduced in 2.x). + /// Replaces the legacy dictionary, which is still + /// read for migration purposes. + /// + [JsonProperty] + public Dictionary TrustedProviderRecords { get; set; } + /// /// Gets the effective provider integrity check mode, accounting for DEBUG builds. /// In DEBUG builds, this always returns Soft mode to allow local development. @@ -141,7 +170,10 @@ public SmartHopperSettings(int encryptionVersion = 1) this.DebounceTime = 1000; this.DefaultAIProvider = string.Empty; this.TrustedProviders = new Dictionary(); + this.TrustedProviderRecords = new Dictionary(); this.ProviderIntegrityCheckMode = ProviderIntegrityCheckMode.Soft; // Default to soft verification + this.AllowCommunityProviders = false; + this.BlockNonOfficialProviders = false; this.SmartHopperAssistant = new SmartHopperAssistantSettings(); this.EncryptionVersion = encryptionVersion; } @@ -918,6 +950,18 @@ public static SmartHopperSettings Load() Debug.WriteLine($"[Load] Migration failed: {migrationEx.Message}"); } + // Migrate legacy TrustedProviders to TrustedProviderRecords + // with Classification="Unknown" so the new schema is populated + // without losing the user's previous Allow/Deny decisions. + try + { + settings.MigrateTrustedProvidersSchema(); + } + catch (Exception trustMigrationEx) + { + Debug.WriteLine($"[Load] TrustedProviders schema migration failed: {trustMigrationEx.Message}"); + } + return settings; } } @@ -958,6 +1002,41 @@ public static SmartHopperSettings Load() return new SmartHopperSettings(encryptionVersion: 1); } + /// + /// Promote legacy boolean entries in into + /// structured objects so future code paths + /// can rely on the new schema. The legacy dictionary is preserved so older + /// SmartHopper versions reading the same settings file continue to function. + /// + public void MigrateTrustedProvidersSchema() + { + if (this.TrustedProviderRecords == null) + { + this.TrustedProviderRecords = new Dictionary(); + } + + if (this.TrustedProviders == null || this.TrustedProviders.Count == 0) + { + return; + } + + foreach (var (key, allowed) in this.TrustedProviders) + { + if (this.TrustedProviderRecords.ContainsKey(key)) + { + continue; + } + + this.TrustedProviderRecords[key] = new TrustedProviderRecord + { + Key = key, + Classification = "Unknown", + Allowed = allowed, + DecidedAt = DateTime.UtcNow, + }; + } + } + /// /// Saves the settings to disk. /// diff --git a/src/SmartHopper.Infrastructure/Settings/TrustedProviderRecord.cs b/src/SmartHopper.Infrastructure/Settings/TrustedProviderRecord.cs new file mode 100644 index 000000000..a3059a4e2 --- /dev/null +++ b/src/SmartHopper.Infrastructure/Settings/TrustedProviderRecord.cs @@ -0,0 +1,83 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System; +using Newtonsoft.Json; + +namespace SmartHopper.Infrastructure.Settings +{ + /// + /// Persisted record describing a per-provider trust decision. Replaces the legacy + /// Dictionary<string, bool> format keyed by assembly file name. + /// + /// + /// Legacy boolean entries continue to be read for backward compatibility: they are + /// promoted to with + /// set to "Unknown" and the original allow/deny + /// state preserved. Classification is filled in on next discovery. + /// + public sealed class TrustedProviderRecord + { + /// + /// The key used to identify this provider entry. Typically the assembly simple + /// name, optionally suffixed by SHA-256 hash for unsigned providers. + /// + [JsonProperty("key")] + public string Key { get; set; } = string.Empty; + + /// + /// Cryptographic classification recorded at decision time. Stored as a string + /// (e.g. "Official", "Community", "Unknown") so future + /// values added in newer SmartHopper versions don't break older settings files. + /// + [JsonProperty("classification")] + public string Classification { get; set; } = "Unknown"; + + /// + /// Whether the user permitted this provider to load. + /// + [JsonProperty("allowed")] + public bool Allowed { get; set; } + + /// + /// When the decision was made. + /// + [JsonProperty("decidedAt")] + public DateTime DecidedAt { get; set; } = DateTime.UtcNow; + + /// + /// SHA-256 hash of the assembly at decision time. For community providers, a + /// later load with a different hash invalidates the trust. + /// + [JsonProperty("hashAtDecision")] + public string? HashAtDecision { get; set; } + + /// + /// Authenticode signer SHA-1 thumbprint at decision time (Windows only). May be + /// null on macOS or for unsigned providers. + /// + [JsonProperty("signerThumbprintAtDecision")] + public string? SignerThumbprintAtDecision { get; set; } + + /// + /// Strong-name public key token at decision time. null for unsigned providers. + /// + [JsonProperty("strongNameTokenAtDecision")] + public string? StrongNameTokenAtDecision { get; set; } + } +} diff --git a/src/SmartHopper.Infrastructure/SmartHopper.Infrastructure.csproj b/src/SmartHopper.Infrastructure/SmartHopper.Infrastructure.csproj index 16e6cfb77..cea1757f6 100644 --- a/src/SmartHopper.Infrastructure/SmartHopper.Infrastructure.csproj +++ b/src/SmartHopper.Infrastructure/SmartHopper.Infrastructure.csproj @@ -30,6 +30,9 @@ $(SolutionDir)bin/$(SolutionVersion)/$(Configuration) + + + @@ -84,7 +87,7 @@ Run that script after generating or updating the signing key. --> - This value is automatically replaced by the build tooling before official builds. + 00240000048000009400000006020000002400005253413100040000010001003D2D5599128DE50EF9F60EDE984889FAE33652EAD2C4BF0EBEB943393782E22C0ADB35AA42B557FC549B455B1A0ECCC43131BDCB216DDED2189C7B981C69AAF0D23AB8909C2AA52C16CA04E577206C6B7A500F7496155DD6ABBFBEBF65395BB7166363A5E3F98D8C0A4FF50C7C4BD74A85A9E1D39208C7113ED8303C14F6F4C5 @@ -92,13 +95,11 @@ - - - - - - - + diff --git a/src/SmartHopper.Menu/Dialogs/AboutDialog.cs b/src/SmartHopper.Menu/Dialogs/AboutDialog.cs index ce86628c9..1b8ba2aca 100644 --- a/src/SmartHopper.Menu/Dialogs/AboutDialog.cs +++ b/src/SmartHopper.Menu/Dialogs/AboutDialog.cs @@ -25,6 +25,7 @@ using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Properties; using SmartHopper.Infrastructure.Utils; +using SmartHopper.ProviderSdk.Utils; namespace SmartHopper.Menu.Dialogs { diff --git a/src/SmartHopper.Menu/Dialogs/SettingsDialog.cs b/src/SmartHopper.Menu/Dialogs/SettingsDialog.cs index 44570e2d9..2cb25b8b5 100644 --- a/src/SmartHopper.Menu/Dialogs/SettingsDialog.cs +++ b/src/SmartHopper.Menu/Dialogs/SettingsDialog.cs @@ -28,6 +28,9 @@ using SmartHopper.Infrastructure.Settings; using SmartHopper.Menu.Dialogs.SettingsTabs; using SmartHopper.Menu.Dialogs.SettingsTabs.Models; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Hosting; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Menu.Dialogs { diff --git a/src/SmartHopper.Menu/Dialogs/SettingsTabs/AssistantSettingsPage.cs b/src/SmartHopper.Menu/Dialogs/SettingsTabs/AssistantSettingsPage.cs index 1b3bfab4c..727b9f5cd 100644 --- a/src/SmartHopper.Menu/Dialogs/SettingsTabs/AssistantSettingsPage.cs +++ b/src/SmartHopper.Menu/Dialogs/SettingsTabs/AssistantSettingsPage.cs @@ -20,6 +20,7 @@ using Eto.Forms; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Menu.Dialogs.SettingsTabs.Models; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Menu.Dialogs.SettingsTabs { diff --git a/src/SmartHopper.Menu/Dialogs/SettingsTabs/GeneralSettingsPage.cs b/src/SmartHopper.Menu/Dialogs/SettingsTabs/GeneralSettingsPage.cs index 5b10a9be6..aa715513c 100644 --- a/src/SmartHopper.Menu/Dialogs/SettingsTabs/GeneralSettingsPage.cs +++ b/src/SmartHopper.Menu/Dialogs/SettingsTabs/GeneralSettingsPage.cs @@ -20,6 +20,7 @@ using Eto.Forms; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Menu.Dialogs.SettingsTabs.Models; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Menu.Dialogs.SettingsTabs { diff --git a/src/SmartHopper.Menu/Dialogs/SettingsTabs/GenericProviderSettingsPage.cs b/src/SmartHopper.Menu/Dialogs/SettingsTabs/GenericProviderSettingsPage.cs index 4ed6f35ba..19d84bdb3 100644 --- a/src/SmartHopper.Menu/Dialogs/SettingsTabs/GenericProviderSettingsPage.cs +++ b/src/SmartHopper.Menu/Dialogs/SettingsTabs/GenericProviderSettingsPage.cs @@ -25,6 +25,8 @@ using Eto.Forms; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Menu.Dialogs.SettingsTabs { diff --git a/src/SmartHopper.Menu/Dialogs/SettingsTabs/ProvidersSettingsPage.cs b/src/SmartHopper.Menu/Dialogs/SettingsTabs/ProvidersSettingsPage.cs index d27d5b4c2..60266b1ae 100644 --- a/src/SmartHopper.Menu/Dialogs/SettingsTabs/ProvidersSettingsPage.cs +++ b/src/SmartHopper.Menu/Dialogs/SettingsTabs/ProvidersSettingsPage.cs @@ -22,10 +22,13 @@ using System.Linq; using Eto.Drawing; using Eto.Forms; -using SmartHopper.Infrastructure.AICall.Core; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Settings; using SmartHopper.Menu.Dialogs.SettingsTabs.Models; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Hosting; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Menu.Dialogs.SettingsTabs { diff --git a/src/SmartHopper.Menu/Items/VerifyProvidersMenuItem.cs b/src/SmartHopper.Menu/Items/VerifyProvidersMenuItem.cs index 9f5305709..05ff4cd3a 100644 --- a/src/SmartHopper.Menu/Items/VerifyProvidersMenuItem.cs +++ b/src/SmartHopper.Menu/Items/VerifyProvidersMenuItem.cs @@ -24,6 +24,8 @@ using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Utils; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Utils; namespace SmartHopper.Menu.Items { diff --git a/src/SmartHopper.Infrastructure/AICall/Batch/AIBatchTypes.cs b/src/SmartHopper.ProviderSdk/AICall/Batch/AIBatchTypes.cs similarity index 97% rename from src/SmartHopper.Infrastructure/AICall/Batch/AIBatchTypes.cs rename to src/SmartHopper.ProviderSdk/AICall/Batch/AIBatchTypes.cs index 5f4f17815..8e92c0e99 100644 --- a/src/SmartHopper.Infrastructure/AICall/Batch/AIBatchTypes.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Batch/AIBatchTypes.cs @@ -20,11 +20,11 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Batch +namespace SmartHopper.ProviderSdk.AICall.Batch { /// /// Possible states of a submitted batch job. @@ -187,7 +187,7 @@ public AIBatchStatus(string batchId, IReadOnlyDictionary result /// files, or multiple user-selected files in manual load) into accumulator /// collections with a first-wins policy on custom_id. /// - internal static class AIBatchStatusMerge + public static class AIBatchStatusMerge { /// /// Merges one parsed single-file into accumulator collections. diff --git a/src/SmartHopper.Infrastructure/AICall/Batch/IAIBatchProvider.cs b/src/SmartHopper.ProviderSdk/AICall/Batch/IAIBatchProvider.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/Batch/IAIBatchProvider.cs rename to src/SmartHopper.ProviderSdk/AICall/Batch/IAIBatchProvider.cs index 4626efb09..50a99d866 100644 --- a/src/SmartHopper.Infrastructure/AICall/Batch/IAIBatchProvider.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Batch/IAIBatchProvider.cs @@ -19,9 +19,9 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Requests; -namespace SmartHopper.Infrastructure.AICall.Batch +namespace SmartHopper.ProviderSdk.AICall.Batch { /// /// Optional interface implemented by AI providers that support asynchronous batch processing. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/AIRequestParameters.cs b/src/SmartHopper.ProviderSdk/AICall/Core/AIRequestParameters.cs similarity index 99% rename from src/SmartHopper.Infrastructure/AICall/Core/AIRequestParameters.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/AIRequestParameters.cs index c37dc973e..c0da4030d 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/AIRequestParameters.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/AIRequestParameters.cs @@ -20,7 +20,7 @@ using System.Collections.ObjectModel; using Newtonsoft.Json.Linq; -namespace SmartHopper.Infrastructure.AICall.Core +namespace SmartHopper.ProviderSdk.AICall.Core { /// /// Immutable per-request AI configuration. Providers read each property individually diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Base/AIAgent.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Base/AIAgent.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/Core/Base/AIAgent.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Base/AIAgent.cs index e60856aeb..98343b3e5 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Base/AIAgent.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Base/AIAgent.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.AICall.Core.Base +namespace SmartHopper.ProviderSdk.AICall.Core.Base { /// /// Specifies the originator of an AI interaction. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Base/AICallStatus.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Base/AICallStatus.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/Core/Base/AICallStatus.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Base/AICallStatus.cs index a86ea9142..384700165 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Base/AICallStatus.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Base/AICallStatus.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.AICall.Core.Base +namespace SmartHopper.ProviderSdk.AICall.Core.Base { /// /// Specifies the originator of an AI interaction. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Base/AIRequestKind.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Base/AIRequestKind.cs similarity index 95% rename from src/SmartHopper.Infrastructure/AICall/Core/Base/AIRequestKind.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Base/AIRequestKind.cs index eff3fb23e..58e6ab825 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Base/AIRequestKind.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Base/AIRequestKind.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.AICall.Core.Base +namespace SmartHopper.ProviderSdk.AICall.Core.Base { /// /// Distinguishes between normal generation requests and provider backoffice/metadata requests. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBody.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBody.cs similarity index 96% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBody.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBody.cs index 197770edc..bbeee9b22 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBody.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBody.cs @@ -18,11 +18,11 @@ using System; using System.Collections.Generic; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Immutable representation of an AI request body. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBodyBuilder.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBodyBuilder.cs similarity index 99% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBodyBuilder.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBodyBuilder.cs index 63142930b..dc2dc1528 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBodyBuilder.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBodyBuilder.cs @@ -21,12 +21,12 @@ using System.Diagnostics; using System.Linq; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Fluent builder for . Produces immutable instances without diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBodyExtensions.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBodyExtensions.cs similarity index 99% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBodyExtensions.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBodyExtensions.cs index 729b885fa..ce9267967 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIBodyExtensions.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIBodyExtensions.cs @@ -21,10 +21,10 @@ using System.Diagnostics; using System.Linq; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AIModels; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Extension helpers for immutable AI request bodies. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionAudio.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionAudio.cs similarity index 96% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionAudio.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionAudio.cs index 43747602f..4b807ac35 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionAudio.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionAudio.cs @@ -17,10 +17,10 @@ */ using System; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Utilities; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Utilities; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Represents an audio interaction for speech-to-text or text-to-speech operations. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionBase.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionBase.cs similarity index 89% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionBase.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionBase.cs index 1553886f6..8c551f591 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionBase.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionBase.cs @@ -17,10 +17,10 @@ */ using System; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Metrics; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Base class for all interactions, centralizing common properties and defaults. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionImage.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionImage.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionImage.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionImage.cs index 4f6e1b632..1c76a72bc 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionImage.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionImage.cs @@ -18,11 +18,11 @@ using System; using System.Collections.Generic; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Represents an AI image interaction — either a generated image result or an image input for vision. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionRuntimeMessage.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionRuntimeMessage.cs similarity index 96% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionRuntimeMessage.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionRuntimeMessage.cs index ab17ec896..6e39d866d 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionRuntimeMessage.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionRuntimeMessage.cs @@ -16,12 +16,12 @@ * along with this library; if not, see . */ -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Unified UI-only diagnostic interaction carrying a -shaped payload diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionText.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionText.cs similarity index 96% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionText.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionText.cs index 19bc58c64..3f8127692 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionText.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionText.cs @@ -17,11 +17,11 @@ */ using System.Globalization; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AICall.Utilities; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Utilities; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Represents an AI-generated text result with associated metadata. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionToolCall.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionToolCall.cs similarity index 96% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionToolCall.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionToolCall.cs index ae97b699d..fdbee49da 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionToolCall.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionToolCall.cs @@ -18,9 +18,9 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Base; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Represents an AI-generated tool call with associated metadata. @@ -100,7 +100,7 @@ public virtual string GetDedupKey() { var id = !string.IsNullOrEmpty(this.Id) ? this.Id : (this.Name ?? string.Empty); var argsStr = this.Arguments != null ? this.Arguments.ToString(Newtonsoft.Json.Formatting.None) : string.Empty; - var argsHash = !string.IsNullOrEmpty(argsStr) ? SmartHopper.Infrastructure.AICall.Utilities.HashUtility.ComputeShortHash(argsStr) : "none"; + var argsHash = !string.IsNullOrEmpty(argsStr) ? SmartHopper.ProviderSdk.AICall.Utilities.HashUtility.ComputeShortHash(argsStr) : "none"; if (!string.IsNullOrWhiteSpace(this.TurnId)) { diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionToolResult.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionToolResult.cs similarity index 95% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionToolResult.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionToolResult.cs index a7e3f72b9..f343d3d68 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/AIInteractionToolResult.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/AIInteractionToolResult.cs @@ -19,11 +19,11 @@ using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Utilities; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Utilities; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Represents an AI-generated tool result with associated metadata. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIInteraction.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIInteraction.cs similarity index 91% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIInteraction.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIInteraction.cs index 708954342..f0fcf85f6 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIInteraction.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIInteraction.cs @@ -24,10 +24,10 @@ */ using System; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Metrics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Metrics; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { public interface IAIInteraction { diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIKeyedInteraction.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIKeyedInteraction.cs similarity index 96% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIKeyedInteraction.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIKeyedInteraction.cs index 375f662d7..4da4a6afa 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIKeyedInteraction.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIKeyedInteraction.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Provides stable identity keys for chat rendering logic. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIRenderInteraction.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIRenderInteraction.cs similarity index 97% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIRenderInteraction.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIRenderInteraction.cs index 1eb780b3a..c2eb6adb6 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/IAIRenderInteraction.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/IAIRenderInteraction.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Defines how an interaction should be rendered into the WebChat HTML. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/SystemPromptBuilder.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/SystemPromptBuilder.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/Core/Interactions/SystemPromptBuilder.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Interactions/SystemPromptBuilder.cs index 20fec8a21..afe200774 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Interactions/SystemPromptBuilder.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Interactions/SystemPromptBuilder.cs @@ -20,9 +20,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using SmartHopper.Infrastructure.AIContext; +using SmartHopper.ProviderSdk.Hosting; -namespace SmartHopper.Infrastructure.AICall.Core.Interactions +namespace SmartHopper.ProviderSdk.AICall.Core.Interactions { /// /// Builder for composing system prompts from multiple sections. @@ -199,7 +199,7 @@ public string Build() var providerFilter = string.Join(" ", this._contextProviderFilters); Debug.WriteLine($"[SystemPromptBuilder] Requesting context with filter: '{providerFilter}'"); - var contextDict = AIContextManager.GetCurrentContext(providerFilter); + var contextDict = ProviderSdkHost.ContextProvider.GetCurrentContext(providerFilter); if (contextDict != null) { diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Requests/AIRequestBase.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Requests/AIRequestBase.cs similarity index 95% rename from src/SmartHopper.Infrastructure/AICall/Core/Requests/AIRequestBase.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Requests/AIRequestBase.cs index 3ebbe1e1c..0352d3108 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Requests/AIRequestBase.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Requests/AIRequestBase.cs @@ -20,14 +20,15 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; - -namespace SmartHopper.Infrastructure.AICall.Core.Requests +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Hosting; + +namespace SmartHopper.ProviderSdk.AICall.Core.Requests { /// /// Represents a fully-specified AI request that providers can execute, including @@ -57,7 +58,7 @@ public class AIRequestBase : IAIRequest public virtual string? Provider { get; set; } /// - public virtual IAIProvider ProviderInstance { get => ProviderManager.Instance.GetProvider(this.Provider); } + public virtual IAIProvider ProviderInstance { get => ProviderSdkHost.ProviderRegistry.GetProvider(this.Provider); } /// public virtual string Model { get => this.GetModelToUse(); set => this.model = value; } @@ -220,7 +221,7 @@ public virtual (bool IsValid, List Errors) IsValid() if (!string.IsNullOrWhiteSpace(provider)) { // 1) Provider-level toggle must allow streaming - var settings = ProviderManager.Instance.GetProviderSettings(provider); + var settings = ProviderSdkHost.ProviderRegistry.GetProviderSettings(provider); if (settings != null && settings.EnableStreaming == false) { messages.Add(new SHRuntimeMessage( @@ -233,7 +234,7 @@ public virtual (bool IsValid, List Errors) IsValid() // 2) Model must support streaming if (!string.IsNullOrWhiteSpace(modelUsed)) { - var supports = ModelManager.Instance.ModelSupportsStreaming(provider, modelUsed); + var supports = AIModelCapabilityRegistry.Instance.ModelSupportsStreaming(provider, modelUsed); if (!supports) { messages.Add(new SHRuntimeMessage( diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Requests/AIRequestCall.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Requests/AIRequestCall.cs similarity index 89% rename from src/SmartHopper.Infrastructure/AICall/Core/Requests/AIRequestCall.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Requests/AIRequestCall.cs index d7a6f55a1..7a535995d 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Requests/AIRequestCall.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Requests/AIRequestCall.cs @@ -24,18 +24,17 @@ using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.Execution; -using SmartHopper.Infrastructure.AICall.Policies; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Settings; -using SmartHopper.Infrastructure.Streaming; - -namespace SmartHopper.Infrastructure.AICall.Core.Requests +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Hosting; +using SmartHopper.ProviderSdk.Settings; +using SmartHopper.ProviderSdk.Streaming; + +namespace SmartHopper.ProviderSdk.AICall.Core.Requests { /// /// Represents a fully-specified AI request that providers can execute, including @@ -115,9 +114,10 @@ public override (bool IsValid, List Errors) IsValid() else { // Check for provider integrity verification warning - var effectiveMode = SmartHopperSettings.Instance.EffectiveProviderIntegrityCheckMode; + var trustHost = ProviderSdkHost.ProviderTrust; + var effectiveMode = trustHost.EffectiveIntegrityCheckMode; - if (ProviderManager.Instance.IsProviderMismatched(this.Provider)) + if (trustHost.IsProviderMismatched(this.Provider)) { var integrityMessage = $"Provider '{this.Provider}' failed SHA-256 integrity verification. " + "The provider's hash does not match the official published hash. " + @@ -131,7 +131,7 @@ public override (bool IsValid, List Errors) IsValid() } // Check for unavailable hash verification (network/repository issues) - if (ProviderManager.Instance.IsProviderUnavailable(this.Provider)) + if (trustHost.IsProviderUnavailable(this.Provider)) { // Hash repository was unavailable - add warning var unavailableMessage = $"Provider '{this.Provider}' could not be verified - hash check unavailable due to network issues. " + @@ -145,7 +145,7 @@ public override (bool IsValid, List Errors) IsValid() } // Check for unknown provider (not in hash manifest - custom/third-party) - if (ProviderManager.Instance.IsProviderUnknown(this.Provider)) + if (trustHost.IsProviderUnknown(this.Provider)) { // Provider not found in official hash manifest - add warning var unknownMessage = $"Provider '{this.Provider}' is not known - it may be a custom or third-party provider. " + @@ -158,6 +158,30 @@ public override (bool IsValid, List Errors) IsValid() unknownMessage)); Debug.WriteLine($"[AIRequestCall] Provider '{this.Provider}' is unknown - adding warning"); } + + // Surface community/unsigned warnings on every component using this provider. + if (trustHost.IsProviderCommunity(this.Provider)) + { + var communityMessage = $"Provider '{this.Provider}' is a community provider, not signed by SmartHopper. " + + "Use it only if you trust its source — community providers run with full plugin privileges."; + messages.Add(new SHRuntimeMessage( + SHRuntimeMessageSeverity.Warning, + SHRuntimeMessageOrigin.Validation, + SHMessageCode.UnknownProvider, + communityMessage)); + Debug.WriteLine($"[AIRequestCall] Provider '{this.Provider}' is community - adding warning"); + } + else if (trustHost.IsProviderUnsigned(this.Provider)) + { + var unsignedMessage = $"Provider '{this.Provider}' is unsigned. " + + "Use it only if you trust its source."; + messages.Add(new SHRuntimeMessage( + SHRuntimeMessageSeverity.Warning, + SHRuntimeMessageOrigin.Validation, + SHMessageCode.UnknownProvider, + unsignedMessage)); + Debug.WriteLine($"[AIRequestCall] Provider '{this.Provider}' is unsigned - adding warning"); + } } if (this.ProviderInstance == null) @@ -199,7 +223,7 @@ public override (bool IsValid, List Errors) IsValid() var requestedModel = this.RequestedModel; if (!string.IsNullOrWhiteSpace(this.Provider) && !string.IsNullOrWhiteSpace(requestedModel)) { - var requestedCaps = ModelManager.Instance.GetCapabilities(this.Provider, requestedModel); + var requestedCaps = AIModelCapabilityRegistry.Instance.GetCapabilities(this.Provider, requestedModel); if (requestedCaps == null) { messages.Add(new SHRuntimeMessage( @@ -308,7 +332,7 @@ public async Task Exec(bool stream = false, System.Threading.Cancellat cancellationToken.ThrowIfCancellationRequested(); // Always-on: run request policies before validation/provider call - await PolicyPipeline.Default.ApplyRequestPoliciesAsync(this).ConfigureAwait(false); + await ProviderSdkHost.PolicyPipeline.ApplyRequestPoliciesAsync(this).ConfigureAwait(false); // Validate early to avoid provider calls when request is invalid var (rqOk, rqErrors) = this.IsValid(); @@ -366,7 +390,7 @@ public async Task Exec(bool stream = false, System.Threading.Cancellat /* logging only */ } - await PolicyPipeline.Default.ApplyResponsePoliciesAsync(air).ConfigureAwait(false); + await ProviderSdkHost.PolicyPipeline.ApplyResponsePoliciesAsync(air).ConfigureAwait(false); try { Debug.WriteLine($"[AIRequest.Exec] after policies: interactions={air?.Body?.InteractionsCount ?? 0}, new={string.Join(",", air?.Body?.InteractionsNew ?? new System.Collections.Generic.List())}"); @@ -431,9 +455,16 @@ public async Task Exec(bool stream = false, System.Threading.Cancellat /// Aggregated AIReturn from the streaming results. private async Task ExecStreamingInternal(System.Threading.CancellationToken cancellationToken = default) { - // Get the streaming adapter from the provider - var executor = new DefaultProviderExecutor(); - var adapter = executor.TryGetStreamingAdapter(this); + // Get the streaming adapter directly from the provider instance. + IStreamingAdapter adapter = null; + try + { + adapter = this.ProviderInstance?.GetStreamingAdapter(); + } + catch (Exception ex) + { + Debug.WriteLine($"[AIRequestCall.ExecStreamingInternal] Error getting streaming adapter: {ex.Message}"); + } if (adapter == null) { diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Requests/IAIRequest.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Requests/IAIRequest.cs similarity index 89% rename from src/SmartHopper.Infrastructure/AICall/Core/Requests/IAIRequest.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Requests/IAIRequest.cs index 8684c4e91..348f9cca1 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Requests/IAIRequest.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Requests/IAIRequest.cs @@ -18,14 +18,14 @@ using System.Collections.Generic; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Core.Requests +namespace SmartHopper.ProviderSdk.AICall.Core.Requests { public interface IAIRequest { diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Returns/AIReturn.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Returns/AIReturn.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/Core/Returns/AIReturn.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Returns/AIReturn.cs index 6aba39254..a43c0e7df 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Returns/AIReturn.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Returns/AIReturn.cs @@ -21,13 +21,13 @@ using System.Diagnostics; using System.Linq; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Core.Returns +namespace SmartHopper.ProviderSdk.AICall.Core.Returns { /// /// Generic container for provider responses, carrying processed and raw results, diff --git a/src/SmartHopper.Infrastructure/AICall/Core/Returns/IAIReturn.cs b/src/SmartHopper.ProviderSdk/AICall/Core/Returns/IAIReturn.cs similarity index 93% rename from src/SmartHopper.Infrastructure/AICall/Core/Returns/IAIReturn.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/Returns/IAIReturn.cs index e957b7ace..3d6a0895b 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/Returns/IAIReturn.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/Returns/IAIReturn.cs @@ -17,13 +17,13 @@ */ using System.Collections.Generic; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Core.Returns +namespace SmartHopper.ProviderSdk.AICall.Core.Returns { /// /// Generic result type for AI evaluations, providing a standard interface between tools and components. diff --git a/src/SmartHopper.Infrastructure/AICall/Core/TimeoutDefaults.cs b/src/SmartHopper.ProviderSdk/AICall/Core/TimeoutDefaults.cs similarity index 97% rename from src/SmartHopper.Infrastructure/AICall/Core/TimeoutDefaults.cs rename to src/SmartHopper.ProviderSdk/AICall/Core/TimeoutDefaults.cs index 176808a78..2c6687e27 100644 --- a/src/SmartHopper.Infrastructure/AICall/Core/TimeoutDefaults.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Core/TimeoutDefaults.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.AICall.Core +namespace SmartHopper.ProviderSdk.AICall.Core { /// /// Centralized timeout defaults and bounds for AI request, tool, and provider HTTP layers. diff --git a/src/SmartHopper.Infrastructure/AICall/JsonSchemas/IJsonSchemaService.cs b/src/SmartHopper.ProviderSdk/AICall/JsonSchemas/IJsonSchemaService.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/JsonSchemas/IJsonSchemaService.cs rename to src/SmartHopper.ProviderSdk/AICall/JsonSchemas/IJsonSchemaService.cs index fcc7f3a2f..6f1f0173d 100644 --- a/src/SmartHopper.Infrastructure/AICall/JsonSchemas/IJsonSchemaService.cs +++ b/src/SmartHopper.ProviderSdk/AICall/JsonSchemas/IJsonSchemaService.cs @@ -18,7 +18,7 @@ using Newtonsoft.Json.Linq; -namespace SmartHopper.Infrastructure.AICall.JsonSchemas +namespace SmartHopper.ProviderSdk.AICall.JsonSchemas { /// /// Centralized service for handling JSON schema wrapping, unwrapping and validation. diff --git a/src/SmartHopper.Infrastructure/AICall/JsonSchemas/JsonSchemaService.cs b/src/SmartHopper.ProviderSdk/AICall/JsonSchemas/JsonSchemaService.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/JsonSchemas/JsonSchemaService.cs rename to src/SmartHopper.ProviderSdk/AICall/JsonSchemas/JsonSchemaService.cs index cfcb6ebf7..eea73c7c3 100644 --- a/src/SmartHopper.Infrastructure/AICall/JsonSchemas/JsonSchemaService.cs +++ b/src/SmartHopper.ProviderSdk/AICall/JsonSchemas/JsonSchemaService.cs @@ -20,7 +20,7 @@ using System.Threading; using Newtonsoft.Json.Linq; -namespace SmartHopper.Infrastructure.AICall.JsonSchemas +namespace SmartHopper.ProviderSdk.AICall.JsonSchemas { /// /// Default implementation of IJsonSchemaService. diff --git a/src/SmartHopper.Infrastructure/AICall/JsonSchemas/ProviderSchemaAdapters.cs b/src/SmartHopper.ProviderSdk/AICall/JsonSchemas/ProviderSchemaAdapters.cs similarity index 99% rename from src/SmartHopper.Infrastructure/AICall/JsonSchemas/ProviderSchemaAdapters.cs rename to src/SmartHopper.ProviderSdk/AICall/JsonSchemas/ProviderSchemaAdapters.cs index 50df0e918..cf6c0ae26 100644 --- a/src/SmartHopper.Infrastructure/AICall/JsonSchemas/ProviderSchemaAdapters.cs +++ b/src/SmartHopper.ProviderSdk/AICall/JsonSchemas/ProviderSchemaAdapters.cs @@ -20,7 +20,7 @@ using System.Collections.Concurrent; using Newtonsoft.Json.Linq; -namespace SmartHopper.Infrastructure.AICall.JsonSchemas +namespace SmartHopper.ProviderSdk.AICall.JsonSchemas { /// /// Adapter contract that allows each provider project to define how diff --git a/src/SmartHopper.Infrastructure/AICall/Metrics/AIMetrics.cs b/src/SmartHopper.ProviderSdk/AICall/Metrics/AIMetrics.cs similarity index 97% rename from src/SmartHopper.Infrastructure/AICall/Metrics/AIMetrics.cs rename to src/SmartHopper.ProviderSdk/AICall/Metrics/AIMetrics.cs index 9e6f45d23..3a9223bdb 100644 --- a/src/SmartHopper.Infrastructure/AICall/Metrics/AIMetrics.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Metrics/AIMetrics.cs @@ -18,11 +18,11 @@ using System.Collections.Generic; using System.Diagnostics; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Metrics +namespace SmartHopper.ProviderSdk.AICall.Metrics { public class AIMetrics { @@ -129,7 +129,7 @@ public double? ContextUsagePercent return null; } - var modelManager = ModelManager.Instance; + var modelManager = AIModelCapabilityRegistry.Instance; var capabilities = modelManager?.GetCapabilities(this.Provider, this.Model); var contextLimit = capabilities?.ContextLimit; diff --git a/src/SmartHopper.Infrastructure/AICall/Metrics/AIMetricsDomain.cs b/src/SmartHopper.ProviderSdk/AICall/Metrics/AIMetricsDomain.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AICall/Metrics/AIMetricsDomain.cs rename to src/SmartHopper.ProviderSdk/AICall/Metrics/AIMetricsDomain.cs index 225d5f051..5369784c5 100644 --- a/src/SmartHopper.Infrastructure/AICall/Metrics/AIMetricsDomain.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Metrics/AIMetricsDomain.cs @@ -20,7 +20,7 @@ using System; -namespace SmartHopper.Infrastructure.AICall.Metrics +namespace SmartHopper.ProviderSdk.AICall.Metrics { /// /// Correlation keys used to associate metrics across session/turn/request/tool boundaries. diff --git a/src/SmartHopper.Infrastructure/AICall/Utilities/HashUtility.cs b/src/SmartHopper.ProviderSdk/AICall/Utilities/HashUtility.cs similarity index 96% rename from src/SmartHopper.Infrastructure/AICall/Utilities/HashUtility.cs rename to src/SmartHopper.ProviderSdk/AICall/Utilities/HashUtility.cs index a135108f9..c85bc4cd4 100644 --- a/src/SmartHopper.Infrastructure/AICall/Utilities/HashUtility.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Utilities/HashUtility.cs @@ -20,7 +20,7 @@ using System.Security.Cryptography; using System.Text; -namespace SmartHopper.Infrastructure.AICall.Utilities +namespace SmartHopper.ProviderSdk.AICall.Utilities { /// /// Shared hashing utilities for generating consistent identifiers. diff --git a/src/SmartHopper.Infrastructure/AICall/Utilities/InteractionUtility.cs b/src/SmartHopper.ProviderSdk/AICall/Utilities/InteractionUtility.cs similarity index 94% rename from src/SmartHopper.Infrastructure/AICall/Utilities/InteractionUtility.cs rename to src/SmartHopper.ProviderSdk/AICall/Utilities/InteractionUtility.cs index 049dd73c3..80e7ec91e 100644 --- a/src/SmartHopper.Infrastructure/AICall/Utilities/InteractionUtility.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Utilities/InteractionUtility.cs @@ -18,9 +18,9 @@ using System; using System.Collections.Generic; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; -namespace SmartHopper.Infrastructure.AICall.Utilities +namespace SmartHopper.ProviderSdk.AICall.Utilities { /// /// Shared utilities for working with AI interactions. diff --git a/src/SmartHopper.Infrastructure/AICall/Utilities/RuntimeMessageUtility.cs b/src/SmartHopper.ProviderSdk/AICall/Utilities/RuntimeMessageUtility.cs similarity index 82% rename from src/SmartHopper.Infrastructure/AICall/Utilities/RuntimeMessageUtility.cs rename to src/SmartHopper.ProviderSdk/AICall/Utilities/RuntimeMessageUtility.cs index da0be8f1d..b1f202f9a 100644 --- a/src/SmartHopper.Infrastructure/AICall/Utilities/RuntimeMessageUtility.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Utilities/RuntimeMessageUtility.cs @@ -19,10 +19,9 @@ using System; using System.Collections.Generic; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Tools; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.Diagnostics; -namespace SmartHopper.Infrastructure.AICall.Utilities +namespace SmartHopper.ProviderSdk.AICall.Utilities { /// /// Shared utilities for working with SHRuntimeMessage collections. @@ -104,36 +103,6 @@ public static List ExtractMessages(JObject toolResult) return messages; } - /// - /// Extracts runtime messages from a envelope. - /// Combines diagnostics carried on the envelope with messages found inside - /// the underlying JSON payload. - /// - /// The envelope to extract messages from. - /// A list of extracted SHRuntimeMessage objects, or empty list if none found. - public static List ExtractMessages(ToolCallResult toolResult) - { - var messages = new List(); - if (toolResult == null) - { - return messages; - } - - if (toolResult.Messages != null) - { - foreach (var m in toolResult.Messages) - { - if (m != null) - { - messages.Add(m); - } - } - } - - messages.AddRange(ExtractMessages(toolResult.Result)); - return messages; - } - /// /// Helper to extract messages from a JArray. /// diff --git a/src/SmartHopper.Infrastructure/AICall/Utilities/TextStreamCoalescer.cs b/src/SmartHopper.ProviderSdk/AICall/Utilities/TextStreamCoalescer.cs similarity index 97% rename from src/SmartHopper.Infrastructure/AICall/Utilities/TextStreamCoalescer.cs rename to src/SmartHopper.ProviderSdk/AICall/Utilities/TextStreamCoalescer.cs index 810a000d3..f4270d3e9 100644 --- a/src/SmartHopper.Infrastructure/AICall/Utilities/TextStreamCoalescer.cs +++ b/src/SmartHopper.ProviderSdk/AICall/Utilities/TextStreamCoalescer.cs @@ -17,9 +17,9 @@ */ using System; -using SmartHopper.Infrastructure.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; -namespace SmartHopper.Infrastructure.AICall.Utilities +namespace SmartHopper.ProviderSdk.AICall.Utilities { /// /// Shared utility for coalescing streaming text deltas. diff --git a/src/SmartHopper.Infrastructure/AIModels/AICapability.cs b/src/SmartHopper.ProviderSdk/AIModels/AICapability.cs similarity index 99% rename from src/SmartHopper.Infrastructure/AIModels/AICapability.cs rename to src/SmartHopper.ProviderSdk/AIModels/AICapability.cs index d2df58712..9466cc129 100644 --- a/src/SmartHopper.Infrastructure/AIModels/AICapability.cs +++ b/src/SmartHopper.ProviderSdk/AIModels/AICapability.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Generic; -namespace SmartHopper.Infrastructure.AIModels +namespace SmartHopper.ProviderSdk.AIModels { /// /// Defines the capabilities that an AI model can support. diff --git a/src/SmartHopper.Infrastructure/AIModels/AIModelCapabilities.cs b/src/SmartHopper.ProviderSdk/AIModels/AIModelCapabilities.cs similarity index 99% rename from src/SmartHopper.Infrastructure/AIModels/AIModelCapabilities.cs rename to src/SmartHopper.ProviderSdk/AIModels/AIModelCapabilities.cs index 1fde2431e..112f91277 100644 --- a/src/SmartHopper.Infrastructure/AIModels/AIModelCapabilities.cs +++ b/src/SmartHopper.ProviderSdk/AIModels/AIModelCapabilities.cs @@ -20,7 +20,7 @@ using System.Collections.Generic; using System.Linq; -namespace SmartHopper.Infrastructure.AIModels +namespace SmartHopper.ProviderSdk.AIModels { /// /// Represents the capabilities and metadata of a specific AI model. diff --git a/src/SmartHopper.ProviderSdk/AIModels/AIModelCapabilityRegistry.cs b/src/SmartHopper.ProviderSdk/AIModels/AIModelCapabilityRegistry.cs new file mode 100644 index 000000000..20529c5d4 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/AIModels/AIModelCapabilityRegistry.cs @@ -0,0 +1,378 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; + +namespace SmartHopper.ProviderSdk.AIModels +{ + /// + /// Singleton registry of AI model capabilities keyed by "provider.model". + /// Lives in the Provider SDK so providers can register/query capabilities without + /// depending on the SmartHopper host. Thread-safe via ConcurrentDictionary and a + /// coarse-grained lock around mutating operations that span multiple models + /// (e.g. setting an exclusive default). + /// + public sealed class AIModelCapabilityRegistry + { + private static readonly Lazy _instance = + new Lazy(() => new AIModelCapabilityRegistry()); + + private readonly object _syncRoot = new object(); + + /// + /// Gets the process-wide singleton instance of the capability registry. + /// + public static AIModelCapabilityRegistry Instance => _instance.Value; + + /// + /// Initializes a new instance. Prefer ; the public + /// constructor exists primarily for unit-test scenarios. + /// + public AIModelCapabilityRegistry() + { + } + + /// + /// Gets the dictionary of model capabilities keyed by "provider.model". + /// Thread-safe: uses ConcurrentDictionary for reads/writes. + /// + public ConcurrentDictionary Models { get; } = new ConcurrentDictionary(); + + #region Capability lookup + + /// + /// Gets capabilities for a specific model. + /// Enforces exact name or alias matching only. Wildcard patterns are not supported. + /// + /// The provider name. + /// The model name. + /// Model capabilities or null if not found. + public AIModelCapabilities GetCapabilities(string provider, string model) + { + var key = $"{provider?.ToLowerInvariant()}.{model?.ToLowerInvariant()}"; + + // Try exact match first (fastest path) + if (this.Models.TryGetValue(key, out var capabilities)) + { + return capabilities; + } + + // Fallback: search by alias within the same provider + var providerLower = provider?.ToLowerInvariant(); + var modelLower = model?.ToLowerInvariant(); + var byAlias = this.Models.Values + .Where(m => m != null && m.Provider.Equals(providerLower, StringComparison.OrdinalIgnoreCase)) + .FirstOrDefault(m => m.Aliases != null && m.Aliases.Any(a => string.Equals(a, modelLower, StringComparison.OrdinalIgnoreCase))); + + return byAlias; + } + + /// + /// Returns true when at least one model is registered for the specified provider. + /// + public bool HasProviderCapabilities(string provider) + { + if (string.IsNullOrWhiteSpace(provider)) + { + return false; + } + + return this.Models.Keys.Any(key => key.StartsWith($"{provider}.", StringComparison.OrdinalIgnoreCase)); + } + + /// + /// Returns whether the specified provider/model pair supports provider-side streaming. + /// Unknown models are treated as not supporting streaming (safe fallback). + /// + public bool ModelSupportsStreaming(string provider, string model) + { + if (string.IsNullOrWhiteSpace(provider) || string.IsNullOrWhiteSpace(model)) + { + return false; + } + + var caps = this.GetCapabilities(provider, model); + return caps != null && caps.SupportsStreaming; + } + + #endregion + + #region Capability registration + + /// + /// Adds or updates capabilities for a specific model. + /// + public void SetCapabilities(AIModelCapabilities capabilities) + { + if (capabilities == null) return; + + var key = capabilities.GetKey(); + lock (this._syncRoot) + { + this.Models[key] = capabilities; + } + } + + /// + /// Convenience helper to register capabilities for a single (provider, model) pair. + /// + public void RegisterCapabilities( + string provider, + string modelName, + AICapability capabilities, + AICapability defaultFor = AICapability.None) + { + if (string.IsNullOrWhiteSpace(provider) || string.IsNullOrWhiteSpace(modelName)) + { + return; + } + + this.SetCapabilities(new AIModelCapabilities + { + Provider = provider.ToLowerInvariant(), + Model = modelName, + Capabilities = capabilities, + Default = defaultFor, + }); + } + + /// + /// Marks a model as the default for the given capabilities. When exclusive is true (default), + /// clears those capabilities from Default on other models of the same provider so that there is + /// at most one default per capability. + /// + public void SetDefault(string provider, string model, AICapability caps, bool exclusive = true) + { + if (string.IsNullOrWhiteSpace(provider) || string.IsNullOrWhiteSpace(model) || caps == AICapability.None) + { + return; + } + + var normalizedProvider = provider.ToLowerInvariant(); + + lock (this._syncRoot) + { + if (exclusive) + { + foreach (var m in this.GetProviderModels(normalizedProvider)) + { + if (!string.Equals(m.Model, model, StringComparison.Ordinal)) + { + var before = m.Default; + m.Default &= ~caps; + if (m.Default != before) + { + this.Models[m.GetKey()] = m; + } + } + } + } + + var target = this.GetCapabilities(normalizedProvider, model) ?? new AIModelCapabilities + { + Provider = normalizedProvider, + Model = model, + Capabilities = AICapability.None, + Default = AICapability.None, + }; + + target.Default |= caps; + this.Models[target.GetKey()] = target; + } + } + + #endregion + + #region Model listing and selection + + /// + /// Returns all registered models for a provider. + /// + public List GetProviderModels(string provider) + { + if (string.IsNullOrWhiteSpace(provider)) + { + return new List(); + } + + return this.Models.Values + .Where(m => m != null && string.Equals(m.Provider, provider, StringComparison.OrdinalIgnoreCase)) + .ToList(); + } + + /// + /// Gets all models that support the specified capabilities. + /// + public List FindModelsWithCapabilities(AICapability requiredCapabilities) + { + if (requiredCapabilities == AICapability.None) + { + return this.Models.Values.ToList(); + } + + return this.Models.Values + .Where(model => model.HasCapability(requiredCapabilities)) + .ToList(); + } + + /// + /// Gets the default model for a provider and specific capability. + /// + public string GetDefaultModel(string provider, AICapability requiredCapability = AICapability.Text2Text) + { + if (string.IsNullOrWhiteSpace(provider)) + { + return string.Empty; + } + + var providerModels = this.GetProviderModels(provider); + if (providerModels.Count == 0) + { + return string.Empty; + } + + var exact = providerModels + .Where(m => (m.Default & requiredCapability) == requiredCapability) + .OrderByDescending(m => m.Verified) + .ThenByDescending(m => m.Rank) + .ThenBy(m => m.Deprecated) + .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) + .FirstOrDefault(); + if (exact != null) + { + return exact.Model; + } + + var compatible = providerModels + .Where(m => m.Default != AICapability.None && m.HasCapability(requiredCapability)) + .OrderByDescending(m => m.Verified) + .ThenByDescending(m => m.Rank) + .ThenBy(m => m.Deprecated) + .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) + .FirstOrDefault(); + return compatible?.Model ?? string.Empty; + } + + /// + /// DO NOT CALL THIS DIRECTLY. USE AIProvider.SelectModel() INSTEAD. + /// Centralized model selection and fallback logic. + /// + public string SelectBestModel(string provider, string userModel, AICapability requiredCapability, string preferredDefault = null) + { + if (string.IsNullOrWhiteSpace(provider) || requiredCapability == AICapability.None) + { + Debug.WriteLine($"[AIModelCapabilityRegistry.SelectBestModel] Invalid args -> provider='{provider}', required='{requiredCapability.ToDetailedString()}'"); + return string.Empty; + } + + // If user specified a model, validate capability if known; allow unknown to pass + if (!string.IsNullOrWhiteSpace(userModel)) + { + var known = this.GetCapabilities(provider, userModel); + if (known == null) + { + return userModel; + } + + if (known.HasCapability(requiredCapability)) + { + return userModel; + } + } + + var candidates = this.GetProviderModels(provider) + .Where(m => m.HasCapability(requiredCapability)) + .ToList(); + + if (!string.IsNullOrWhiteSpace(preferredDefault)) + { + var preferredCaps = this.GetCapabilities(provider, preferredDefault); + if (preferredCaps != null && preferredCaps.HasCapability(requiredCapability)) + { + return preferredDefault; + } + } + + if (candidates.Count == 0) + { + return string.Empty; + } + + // 1) Defaults with exact capability + var defaultExact = candidates + .Where(m => (m.Default & requiredCapability) == requiredCapability) + .OrderByDescending(m => m.Verified) + .ThenByDescending(m => m.Rank) + .ThenBy(m => m.Deprecated) + .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) + .FirstOrDefault(); + if (defaultExact != null) + { + return defaultExact.Model; + } + + // 2) Other defaults that are compatible + var defaultCompatible = candidates + .Where(m => m.Default != AICapability.None) + .OrderByDescending(m => m.Verified) + .ThenByDescending(m => m.Rank) + .ThenBy(m => m.Deprecated) + .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) + .FirstOrDefault(); + if (defaultCompatible != null) + { + return defaultCompatible.Model; + } + + // 3) Any other registered model, ordered by quality + var best = candidates + .OrderByDescending(m => m.Verified) + .ThenByDescending(m => m.Rank) + .ThenBy(m => m.Deprecated) + .ThenBy(m => m.Model, StringComparer.OrdinalIgnoreCase) + .FirstOrDefault(); + return best?.Model ?? string.Empty; + } + + #endregion + + #region Capability validation + + /// + /// Validates whether a model registered for the given provider has the required capabilities. + /// Unknown (unregistered) models bypass validation and are treated as compatible — the request + /// layer is responsible for additional checks. + /// + public bool ValidateCapabilities(string provider, string model, AICapability requiredCapability) + { + var capabilities = this.GetCapabilities(provider, model); + if (capabilities == null) + { + return true; + } + + return capabilities.HasCapability(requiredCapability); + } + + #endregion + } +} diff --git a/src/SmartHopper.Infrastructure/AIModels/AIModelPricing.cs b/src/SmartHopper.ProviderSdk/AIModels/AIModelPricing.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AIModels/AIModelPricing.cs rename to src/SmartHopper.ProviderSdk/AIModels/AIModelPricing.cs index 579fa532f..e97011544 100644 --- a/src/SmartHopper.Infrastructure/AIModels/AIModelPricing.cs +++ b/src/SmartHopper.ProviderSdk/AIModels/AIModelPricing.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.AIModels +namespace SmartHopper.ProviderSdk.AIModels { /// /// Pricing information for a model, in USD per unit as reported by the source diff --git a/src/SmartHopper.Infrastructure/AIModels/IAIProviderModels.cs b/src/SmartHopper.ProviderSdk/AIModels/IAIProviderModels.cs similarity index 97% rename from src/SmartHopper.Infrastructure/AIModels/IAIProviderModels.cs rename to src/SmartHopper.ProviderSdk/AIModels/IAIProviderModels.cs index 72b0b5cce..9cd5eef12 100644 --- a/src/SmartHopper.Infrastructure/AIModels/IAIProviderModels.cs +++ b/src/SmartHopper.ProviderSdk/AIModels/IAIProviderModels.cs @@ -19,7 +19,7 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace SmartHopper.Infrastructure.AIModels +namespace SmartHopper.ProviderSdk.AIModels { /// /// Interface for AI provider model metadata retrieval. diff --git a/src/SmartHopper.Infrastructure/AIProviders/AIExtraDescriptor.cs b/src/SmartHopper.ProviderSdk/AIProviders/AIExtraDescriptor.cs similarity index 98% rename from src/SmartHopper.Infrastructure/AIProviders/AIExtraDescriptor.cs rename to src/SmartHopper.ProviderSdk/AIProviders/AIExtraDescriptor.cs index 743480d73..6f0775f03 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/AIExtraDescriptor.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/AIExtraDescriptor.cs @@ -18,7 +18,7 @@ using System; -namespace SmartHopper.Infrastructure.AIProviders +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Describes a single provider-specific extra parameter that can be surfaced diff --git a/src/SmartHopper.Infrastructure/AIProviders/AIProvider.cs b/src/SmartHopper.ProviderSdk/AIProviders/AIProvider.cs similarity index 95% rename from src/SmartHopper.Infrastructure/AIProviders/AIProvider.cs rename to src/SmartHopper.ProviderSdk/AIProviders/AIProvider.cs index 6e56427f5..b4b7faeba 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/AIProvider.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/AIProvider.cs @@ -29,20 +29,20 @@ using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.AITools; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Settings; -using SmartHopper.Infrastructure.Streaming; -using SmartHopper.Infrastructure.Utils; - -namespace SmartHopper.Infrastructure.AIProviders +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Hosting; +using SmartHopper.ProviderSdk.Settings; +using SmartHopper.ProviderSdk.Streaming; +using SmartHopper.ProviderSdk.Utils; + +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Base class for AI providers, encapsulating common logic. @@ -167,7 +167,7 @@ public virtual async Task InitializeProviderAsync() { // STEP 1: Register models FIRST to make them available for default value resolution // Prevent reloading capabilities if already initialized - if (!ModelManager.Instance.HasProviderCapabilities(this.Name)) + if (!AIModelCapabilityRegistry.Instance.HasProviderCapabilities(this.Name)) { Debug.WriteLine($"[{this.Name}] Registering model capabilities"); @@ -185,7 +185,7 @@ public virtual async Task InitializeProviderAsync() m.Provider = this.Name.ToLowerInvariant(); } - ModelManager.Instance.SetCapabilities(m); + AIModelCapabilityRegistry.Instance.SetCapabilities(m); Debug.WriteLine($"[{this.Name}] Registered model {m.Model} with capabilities {m.Capabilities.ToDetailedString()} and default {m.Default.ToDetailedString()}"); } } @@ -202,13 +202,11 @@ public virtual async Task InitializeProviderAsync() // Continue initialization even if model registration fails } - // STEP 2: Now load settings with models available for lazy default resolution - // Initialize the provider with its settings from SmartHopperSettings - var settingsDict = SmartHopperSettings.Instance.GetProviderSettings(this.Name); - if (settingsDict == null) - { - settingsDict = new Dictionary(); - } + // STEP 2: Now load settings with models available for lazy default resolution. + // Settings are retrieved through the host-injected per-provider settings store so + // the SDK does not depend on the host's SmartHopperSettings type. + var settingsStore = ProviderSdkHost.SettingsStoreFactory(this.Name); + var settingsDict = settingsStore?.GetAll() ?? new Dictionary(); // Load default values to a separate dictionary to prevent circular dependencies during retrieval this._defaultSettings = new Dictionary(); @@ -238,7 +236,9 @@ public virtual async Task InitializeProviderAsync() } // Apply all settings (stored + defaults) to the provider - this.RefreshCachedSettings(settingsDict); + this.RefreshCachedSettings(settingsDict is Dictionary concrete + ? concrete + : new Dictionary(settingsDict)); } /// @@ -446,7 +446,7 @@ public void RefreshCachedSettings(Dictionary settings) /// public virtual IEnumerable GetSettingDescriptors() { - var ui = ProviderManager.Instance.GetProviderSettings(this.Name); + var ui = ProviderSdkHost.ProviderRegistry.GetProviderSettings(this.Name); return ui != null ? ui.GetSettingDescriptors() : Enumerable.Empty(); } @@ -546,7 +546,7 @@ public string GetDefaultModel(AICapability requiredCapability = AICapability.Tex if (!string.IsNullOrWhiteSpace(modelFromSettings)) { - if (ModelManager.Instance.ValidateCapabilities(this.Name, modelFromSettings, requiredCapability)) + if (AIModelCapabilityRegistry.Instance.ValidateCapabilities(this.Name, modelFromSettings, requiredCapability)) { return modelFromSettings; } @@ -554,7 +554,7 @@ public string GetDefaultModel(AICapability requiredCapability = AICapability.Tex } // Else, try to get default model from ModelManager that matches the required capabilities - string modelFromProviderDefault = ModelManager.Instance.GetDefaultModel(this.Name, requiredCapability); + string modelFromProviderDefault = AIModelCapabilityRegistry.Instance.GetDefaultModel(this.Name, requiredCapability); if (!string.IsNullOrWhiteSpace(modelFromProviderDefault)) { @@ -571,7 +571,7 @@ public virtual string SelectModel(AICapability requiredCapability, string reques var preferredDefault = this.GetDefaultModel(requiredCapability, useSettings: true); // Delegate to centralized selection policy to avoid duplication - var selected = ModelManager.Instance.SelectBestModel(this.Name, requestedModel, requiredCapability, preferredDefault); + var selected = AIModelCapabilityRegistry.Instance.SelectBestModel(this.Name, requestedModel, requiredCapability, preferredDefault); return selected ?? string.Empty; } @@ -603,10 +603,9 @@ protected void SetSetting(string key, object value) this._injectedSettings[key] = value; - // Persist to the global settings with provider scoping - var settings = SmartHopper.Infrastructure.Settings.SmartHopperSettings.Instance; - settings.SetSetting(this.Name, key, value); - settings.Save(); + // Persist to the global settings via the host-injected per-provider store + var store = ProviderSdkHost.SettingsStoreFactory(this.Name); + store?.Set(key, value); Debug.WriteLine($"[{this.Name}] Setting '{key}' updated and persisted"); } @@ -666,8 +665,8 @@ protected JArray GetFormattedTools(string toolFilter) { try { - AIToolManager.DiscoverTools(); - var tools = AIToolManager.GetTools(); + ProviderSdkHost.ToolRegistry.DiscoverTools(); + var tools = ProviderSdkHost.ToolRegistry.GetTools(); if (tools.Count == 0) { Debug.WriteLine("No tools available."); diff --git a/src/SmartHopper.Infrastructure/AIProviders/AIProviderModels.cs b/src/SmartHopper.ProviderSdk/AIProviders/AIProviderModels.cs similarity index 95% rename from src/SmartHopper.Infrastructure/AIProviders/AIProviderModels.cs rename to src/SmartHopper.ProviderSdk/AIProviders/AIProviderModels.cs index 53b66897e..1b2f52063 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/AIProviderModels.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/AIProviderModels.cs @@ -19,9 +19,9 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AIModels; +using SmartHopper.ProviderSdk.AIModels; -namespace SmartHopper.Infrastructure.AIProviders +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Base class for AI provider model metadata retrieval. diff --git a/src/SmartHopper.Infrastructure/AIProviders/AIProviderSettings.cs b/src/SmartHopper.ProviderSdk/AIProviders/AIProviderSettings.cs similarity index 87% rename from src/SmartHopper.Infrastructure/AIProviders/AIProviderSettings.cs rename to src/SmartHopper.ProviderSdk/AIProviders/AIProviderSettings.cs index d68644efd..43d4f6021 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/AIProviderSettings.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/AIProviderSettings.cs @@ -19,9 +19,10 @@ using System; using System.Collections.Generic; using System.Linq; -using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.Hosting; +using SmartHopper.ProviderSdk.Settings; -namespace SmartHopper.Infrastructure.AIProviders +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Base class for provider settings, encapsulating common UI building and persistence logic. @@ -51,8 +52,9 @@ public virtual bool EnableStreaming { try { - // Try persisted value first - var value = SmartHopperSettings.Instance.GetSetting(this.Provider.Name, "EnableStreaming"); + // Try persisted value first via the host-injected settings store + var store = ProviderSdkHost.SettingsStoreFactory(this.Provider.Name); + var value = store?.Get("EnableStreaming"); if (value is bool b) { return b; diff --git a/src/SmartHopper.Infrastructure/AIProviders/AIProviderStreamingAdapter.cs b/src/SmartHopper.ProviderSdk/AIProviders/AIProviderStreamingAdapter.cs similarity index 99% rename from src/SmartHopper.Infrastructure/AIProviders/AIProviderStreamingAdapter.cs rename to src/SmartHopper.ProviderSdk/AIProviders/AIProviderStreamingAdapter.cs index a991bed42..ea7fe0daa 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/AIProviderStreamingAdapter.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/AIProviderStreamingAdapter.cs @@ -25,9 +25,9 @@ using System.Text; using System.Threading; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Requests; -namespace SmartHopper.Infrastructure.AIProviders +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Base class providing shared helpers for provider-specific streaming adapters. diff --git a/src/SmartHopper.Infrastructure/AIProviders/IAIProvider.cs b/src/SmartHopper.ProviderSdk/AIProviders/IAIProvider.cs similarity index 95% rename from src/SmartHopper.Infrastructure/AIProviders/IAIProvider.cs rename to src/SmartHopper.ProviderSdk/AIProviders/IAIProvider.cs index 4c6656f17..f8f00dbf6 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/IAIProvider.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/IAIProvider.cs @@ -21,14 +21,14 @@ using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; -using SmartHopper.Infrastructure.Settings; -using SmartHopper.Infrastructure.Streaming; - -namespace SmartHopper.Infrastructure.AIProviders +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.Settings; +using SmartHopper.ProviderSdk.Streaming; + +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Defines the contract for AI provider integrations (e.g., MistralAI, OpenAI, Anthropic, DeepSeek). diff --git a/src/SmartHopper.Infrastructure/AIProviders/IAIProviderFactory.cs b/src/SmartHopper.ProviderSdk/AIProviders/IAIProviderFactory.cs similarity index 96% rename from src/SmartHopper.Infrastructure/AIProviders/IAIProviderFactory.cs rename to src/SmartHopper.ProviderSdk/AIProviders/IAIProviderFactory.cs index 8252720d8..71c91eea8 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/IAIProviderFactory.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/IAIProviderFactory.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.AIProviders +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Interface for AI provider factories. diff --git a/src/SmartHopper.Infrastructure/AIProviders/IAIProviderSettings.cs b/src/SmartHopper.ProviderSdk/AIProviders/IAIProviderSettings.cs similarity index 95% rename from src/SmartHopper.Infrastructure/AIProviders/IAIProviderSettings.cs rename to src/SmartHopper.ProviderSdk/AIProviders/IAIProviderSettings.cs index f1b628994..379f95694 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/IAIProviderSettings.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/IAIProviderSettings.cs @@ -17,9 +17,9 @@ */ using System.Collections.Generic; -using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.Settings; -namespace SmartHopper.Infrastructure.AIProviders +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Interface for provider settings UI and validation. diff --git a/src/SmartHopper.Infrastructure/AIProviders/ProviderHttpStatusException.cs b/src/SmartHopper.ProviderSdk/AIProviders/ProviderHttpStatusException.cs similarity index 97% rename from src/SmartHopper.Infrastructure/AIProviders/ProviderHttpStatusException.cs rename to src/SmartHopper.ProviderSdk/AIProviders/ProviderHttpStatusException.cs index baf693709..7905d6f2c 100644 --- a/src/SmartHopper.Infrastructure/AIProviders/ProviderHttpStatusException.cs +++ b/src/SmartHopper.ProviderSdk/AIProviders/ProviderHttpStatusException.cs @@ -18,7 +18,7 @@ using System.Net.Http; -namespace SmartHopper.Infrastructure.AIProviders +namespace SmartHopper.ProviderSdk.AIProviders { /// /// Exception thrown by streaming adapters when the provider returns a non-success HTTP status, diff --git a/src/SmartHopper.Infrastructure/Diagnostics/SHRuntimeMessage.cs b/src/SmartHopper.ProviderSdk/Diagnostics/SHRuntimeMessage.cs similarity index 99% rename from src/SmartHopper.Infrastructure/Diagnostics/SHRuntimeMessage.cs rename to src/SmartHopper.ProviderSdk/Diagnostics/SHRuntimeMessage.cs index 1ea9c196a..d51cd8ac1 100644 --- a/src/SmartHopper.Infrastructure/Diagnostics/SHRuntimeMessage.cs +++ b/src/SmartHopper.ProviderSdk/Diagnostics/SHRuntimeMessage.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.Diagnostics +namespace SmartHopper.ProviderSdk.Diagnostics { /// /// Severity levels for SmartHopper runtime messages. diff --git a/src/SmartHopper.ProviderSdk/Hosting/IContextProviderHost.cs b/src/SmartHopper.ProviderSdk/Hosting/IContextProviderHost.cs new file mode 100644 index 000000000..87ab75c21 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IContextProviderHost.cs @@ -0,0 +1,50 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System.Collections.Generic; + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Surface that the SDK consumes to retrieve system-prompt context contributions + /// from the host's context manager (Grasshopper canvas state, user preferences, + /// document-scoped data, etc.). + /// + public interface IContextProviderHost + { + /// + /// Resolve the active context bag for the given provider filter expression. + /// Keys are provider/contributor identifiers and values are arbitrary text or + /// JSON fragments to be embedded in the system prompt. + /// + /// Optional space-separated list of contributor ids + /// to include. Pass null/empty to request the entire context bag. + IDictionary GetCurrentContext(string providerFilter = null); + } + + /// + /// No-op context provider that returns an empty dictionary. Used when SDK code runs + /// outside the SmartHopper host (e.g. unit tests). + /// + public sealed class NullContextProviderHost : IContextProviderHost + { + /// + public IDictionary GetCurrentContext(string providerFilter = null) + => new Dictionary(); + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/IPolicyPipelineHost.cs b/src/SmartHopper.ProviderSdk/Hosting/IPolicyPipelineHost.cs new file mode 100644 index 000000000..5b856a41c --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IPolicyPipelineHost.cs @@ -0,0 +1,58 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System.Threading.Tasks; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Surface that the SDK consumes to invoke the host's request and response policy + /// pipeline. The SmartHopper host registers its PolicyPipeline with + /// at startup so DTO-side execution paths + /// can apply policies without referencing host orchestration types directly. + /// + public interface IPolicyPipelineHost + { + /// + /// Apply all configured request-side policies to + /// before it leaves the host. + /// + Task ApplyRequestPoliciesAsync(AIRequestCall request); + + /// + /// Apply all configured response-side policies to + /// after the provider returns. + /// + Task ApplyResponsePoliciesAsync(AIReturn response); + } + + /// + /// Default no-op policy pipeline used when no host has been registered. Lets SDK + /// code execute end-to-end in tests and stand-alone tools without any orchestration. + /// + public sealed class NullPolicyPipelineHost : IPolicyPipelineHost + { + /// + public Task ApplyRequestPoliciesAsync(AIRequestCall request) => Task.CompletedTask; + + /// + public Task ApplyResponsePoliciesAsync(AIReturn response) => Task.CompletedTask; + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/IProviderDiagnostics.cs b/src/SmartHopper.ProviderSdk/Hosting/IProviderDiagnostics.cs new file mode 100644 index 000000000..145c6e81d --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IProviderDiagnostics.cs @@ -0,0 +1,46 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using SmartHopper.ProviderSdk.Diagnostics; + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Surface that providers use to emit user-visible runtime messages and metrics + /// without depending on host-side runtime-message UI. + /// + public interface IProviderDiagnostics + { + /// + /// Surface a runtime message to the user. The host decides where to render it + /// (component balloon, WebChat banner, status bar, etc.). + /// + void Report(string providerName, SHRuntimeMessage message); + } + + /// + /// No-op diagnostics sink used when SDK code runs without a host attached. + /// + public sealed class NullProviderDiagnostics : IProviderDiagnostics + { + /// + public void Report(string providerName, SHRuntimeMessage message) + { + } + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/IProviderHttpClientFactory.cs b/src/SmartHopper.ProviderSdk/Hosting/IProviderHttpClientFactory.cs new file mode 100644 index 000000000..736c7c868 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IProviderHttpClientFactory.cs @@ -0,0 +1,57 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System; +using System.Net.Http; + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Surface that providers use to obtain configured + /// instances. The host can centralize timeouts, proxies, and retry behavior here so + /// individual providers do not need to repeat the boilerplate. + /// + public interface IProviderHttpClientFactory + { + /// + /// Create or fetch an scoped to + /// with the given total request . + /// + HttpClient CreateClient(string providerName, TimeSpan timeout); + } + + /// + /// Default implementation that returns a fresh per call + /// with the requested timeout. The SmartHopper host swaps in a smarter + /// pooled/factory-based implementation at startup. + /// + public sealed class DefaultProviderHttpClientFactory : IProviderHttpClientFactory + { + /// + public HttpClient CreateClient(string providerName, TimeSpan timeout) + { + var client = new HttpClient(); + if (timeout > TimeSpan.Zero) + { + client.Timeout = timeout; + } + + return client; + } + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/IProviderLogger.cs b/src/SmartHopper.ProviderSdk/Hosting/IProviderLogger.cs new file mode 100644 index 000000000..210bf68d6 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IProviderLogger.cs @@ -0,0 +1,84 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System; +using System.Diagnostics; + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Severity classification for log messages emitted from SDK code. + /// + public enum ProviderLogLevel + { + /// Verbose tracing useful only when debugging the provider. + Trace, + + /// Routine informational messages. + Info, + + /// Recoverable anomalies the user should know about. + Warning, + + /// Unrecoverable failures within a single provider call. + Error, + } + + /// + /// Surface that providers use for log output without depending on Rhino's + /// RhinoApp.WriteLine directly. The host registers an implementation that + /// routes to its preferred logging sink. + /// + public interface IProviderLogger + { + /// + /// Log a message scoped to a provider id. + /// + void Log(ProviderLogLevel level, string providerName, string message); + + /// + /// Log an exception scoped to a provider id. + /// + void LogException(string providerName, Exception exception, string context = null); + } + + /// + /// Default logger that writes to . Suitable for tests and for + /// stand-alone tooling that does not have a richer sink available. + /// + public sealed class DebugProviderLogger : IProviderLogger + { + /// + public void Log(ProviderLogLevel level, string providerName, string message) + { + Debug.WriteLine($"[{level}][{providerName}] {message}"); + } + + /// + public void LogException(string providerName, Exception exception, string context = null) + { + if (exception == null) + { + return; + } + + var prefix = string.IsNullOrEmpty(context) ? string.Empty : context + ": "; + Debug.WriteLine($"[Error][{providerName}] {prefix}{exception.GetType().Name}: {exception.Message}"); + } + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/IProviderRegistryHost.cs b/src/SmartHopper.ProviderSdk/Hosting/IProviderRegistryHost.cs new file mode 100644 index 000000000..20286ae83 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IProviderRegistryHost.cs @@ -0,0 +1,54 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using SmartHopper.ProviderSdk.AIProviders; + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Surface that the SDK consumes to look up provider instances and their settings + /// objects without depending on the host's ProviderManager. The SmartHopper + /// host registers a real implementation with . + /// + public interface IProviderRegistryHost + { + /// + /// Resolve a registered provider by name, or null if the host has not loaded one. + /// + IAIProvider GetProvider(string providerName); + + /// + /// Resolve the live bound to the named provider, or + /// null when the provider is not registered. + /// + IAIProviderSettings GetProviderSettings(string providerName); + } + + /// + /// Null implementation that always returns null. Used when SDK code runs + /// outside a host (for example, unit tests covering pure DTO behavior). + /// + public sealed class NullProviderRegistryHost : IProviderRegistryHost + { + /// + public IAIProvider GetProvider(string providerName) => null; + + /// + public IAIProviderSettings GetProviderSettings(string providerName) => null; + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/IProviderSettingsStore.cs b/src/SmartHopper.ProviderSdk/Hosting/IProviderSettingsStore.cs new file mode 100644 index 000000000..5170cbfde --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IProviderSettingsStore.cs @@ -0,0 +1,119 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System.Collections.Generic; + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Per-provider settings store. The host scopes each instance to a single provider + /// id so a community provider cannot read or write secrets belonging to another + /// provider through this surface. + /// + public interface IProviderSettingsStore + { + /// + /// Provider id this store is scoped to. + /// + string ProviderName { get; } + + /// + /// Retrieve the full settings dictionary for this provider, or an empty dictionary + /// when none have been persisted yet. + /// + IDictionary GetAll(); + + /// + /// Persist the full settings dictionary for this provider. + /// + void SetAll(IDictionary settings); + + /// + /// Read a single setting by key. Returns when + /// the key is missing or the stored value is not assignable to . + /// + T Get(string key, T defaultValue = default); + + /// + /// Write a single setting value by key. + /// + void Set(string key, T value); + } + + /// + /// In-memory used when SDK code runs outside the + /// SmartHopper host (unit tests, sample provider self-checks, etc.). Per provider id. + /// + public sealed class InMemoryProviderSettingsStore : IProviderSettingsStore + { + private readonly Dictionary _storage = new Dictionary(); + + /// Initializes a new in-memory store scoped to . + public InMemoryProviderSettingsStore(string providerName) + { + this.ProviderName = providerName ?? string.Empty; + } + + /// + public string ProviderName { get; } + + /// + public IDictionary GetAll() => new Dictionary(this._storage); + + /// + public void SetAll(IDictionary settings) + { + this._storage.Clear(); + if (settings == null) + { + return; + } + + foreach (var kvp in settings) + { + this._storage[kvp.Key] = kvp.Value; + } + } + + /// + public T Get(string key, T defaultValue = default) + { + if (!this._storage.TryGetValue(key, out var value) || value == null) + { + return defaultValue; + } + + if (value is T typed) + { + return typed; + } + + try + { + return (T)System.Convert.ChangeType(value, typeof(T)); + } + catch + { + return defaultValue; + } + } + + /// + public void Set(string key, T value) => this._storage[key] = value; + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/IProviderTrustHost.cs b/src/SmartHopper.ProviderSdk/Hosting/IProviderTrustHost.cs new file mode 100644 index 000000000..9c5f57745 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IProviderTrustHost.cs @@ -0,0 +1,87 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Surface that the SDK consumes to reason about per-provider trust and integrity + /// state. Implemented by the SmartHopper host and registered with + /// at startup. + /// + public interface IProviderTrustHost + { + /// + /// Effective provider integrity check mode after applying environment overrides + /// (for example, forcing Soft in DEBUG builds). + /// + ProviderIntegrityCheckMode EffectiveIntegrityCheckMode { get; } + + /// + /// Returns true when the provider's local hash does not match the published manifest. + /// + bool IsProviderMismatched(string providerName); + + /// + /// Returns true when integrity verification could not be performed (manifest + /// unreachable, network issue, etc.). + /// + bool IsProviderUnavailable(string providerName); + + /// + /// Returns true when the provider has no entry in the official manifest + /// (custom/third-party provider). + /// + bool IsProviderUnknown(string providerName); + + /// + /// Returns true when the provider was classified as community / non-official. + /// + bool IsProviderCommunity(string providerName); + + /// + /// Returns true when the provider was loaded without any strong-name signature. + /// + bool IsProviderUnsigned(string providerName); + } + + /// + /// Default no-op implementation used when no host has registered a real trust host. + /// Treats every provider as official and reports Soft integrity mode so SDK + /// validation surfaces warnings rather than errors when running outside the host. + /// + public sealed class NullProviderTrustHost : IProviderTrustHost + { + /// + public ProviderIntegrityCheckMode EffectiveIntegrityCheckMode => ProviderIntegrityCheckMode.Soft; + + /// + public bool IsProviderMismatched(string providerName) => false; + + /// + public bool IsProviderUnavailable(string providerName) => false; + + /// + public bool IsProviderUnknown(string providerName) => false; + + /// + public bool IsProviderCommunity(string providerName) => false; + + /// + public bool IsProviderUnsigned(string providerName) => false; + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/IToolRegistryHost.cs b/src/SmartHopper.ProviderSdk/Hosting/IToolRegistryHost.cs new file mode 100644 index 000000000..376646792 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/IToolRegistryHost.cs @@ -0,0 +1,81 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System.Collections.Generic; + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Minimal projection of a tool exposed by the host's tool manager, scoped to the + /// fields a provider needs when formatting tools for an LLM request. + /// + public sealed class ProviderToolDefinition + { + /// Tool identifier (matches host-side AITool.Name). + public string Name { get; set; } + + /// Human-readable description supplied to the model. + public string Description { get; set; } + + /// Tool category (e.g. knowledge, script); free-form. + public string Category { get; set; } + + /// JSON schema fragment describing the tool's argument shape. + public string ParametersSchema { get; set; } + + /// Optional model-side hint. Free-form (e.g. required). + public string RequiredUse { get; set; } + } + + /// + /// Surface that the SDK consumes to enumerate tools registered with the host's tool + /// manager. The host registers an implementation with + /// ; SDK code calls + /// to trigger lazy discovery and + /// to read the current catalog. + /// + public interface IToolRegistryHost + { + /// + /// Trigger lazy discovery of tools. Idempotent; may be called more than once. + /// + void DiscoverTools(); + + /// + /// Return the current snapshot of registered tools keyed by tool name. + /// + IReadOnlyDictionary GetTools(); + } + + /// + /// Empty tool registry used when SDK code runs outside the SmartHopper host. + /// + public sealed class NullToolRegistryHost : IToolRegistryHost + { + private static readonly Dictionary Empty + = new Dictionary(); + + /// + public void DiscoverTools() + { + } + + /// + public IReadOnlyDictionary GetTools() => Empty; + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/ProviderIntegrityCheckMode.cs b/src/SmartHopper.ProviderSdk/Hosting/ProviderIntegrityCheckMode.cs new file mode 100644 index 000000000..a17e68154 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/ProviderIntegrityCheckMode.cs @@ -0,0 +1,46 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Provider integrity check mode defining how verification failures are handled by + /// the host trust pipeline. Lives in the SDK so that DTOs in SDK code paths can + /// reason about it without depending on the SmartHopper host. + /// + public enum ProviderIntegrityCheckMode + { + /// + /// Strict mode: blocks providers on hash mismatch, unavailable hash repository, + /// and unknown providers (not present in the official manifest). + /// + Strict, + + /// + /// Hard mode: blocks providers on hash mismatch and unknown providers, but + /// allows loading when the hash repository is unreachable. + /// + Hard, + + /// + /// Soft mode: surfaces warnings rather than blocking. Best suited for + /// development and third-party providers. + /// + Soft, + } +} diff --git a/src/SmartHopper.ProviderSdk/Hosting/ProviderSdkHost.cs b/src/SmartHopper.ProviderSdk/Hosting/ProviderSdkHost.cs new file mode 100644 index 000000000..4c593cdf0 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Hosting/ProviderSdkHost.cs @@ -0,0 +1,90 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +namespace SmartHopper.ProviderSdk.Hosting +{ + /// + /// Static composition root the SmartHopper host uses at startup to inject + /// host-side services into SDK code paths. Default null/no-op implementations are + /// provided so SDK code remains executable in unit tests and stand-alone tools. + /// + /// + /// + /// The host registers concrete implementations exactly once during plugin + /// initialization; SDK code reads the configured property each time it needs a + /// service so registration order does not matter. + /// + /// + /// This is a runtime extension point only — provider authors must not depend on + /// specific host implementations or rely on host registrations happening before + /// provider activation. + /// + /// + public static class ProviderSdkHost + { + /// + /// Per-provider trust/integrity status surface used by request validation. + /// + public static IProviderTrustHost ProviderTrust { get; set; } = new NullProviderTrustHost(); + + /// + /// Provider lookup surface used by DTOs and the AIProvider base class. + /// + public static IProviderRegistryHost ProviderRegistry { get; set; } = new NullProviderRegistryHost(); + + /// + /// Host policy pipeline invoked by SDK execution paths around request/response. + /// + public static IPolicyPipelineHost PolicyPipeline { get; set; } = new NullPolicyPipelineHost(); + + /// + /// Context bag provider used by SDK system-prompt assembly. + /// + public static IContextProviderHost ContextProvider { get; set; } = new NullContextProviderHost(); + + /// + /// Tool registry surface used when an SDK request formats tools for an LLM. + /// + public static IToolRegistryHost ToolRegistry { get; set; } = new NullToolRegistryHost(); + + /// + /// Diagnostics sink for user-visible runtime messages emitted from SDK code. + /// + public static IProviderDiagnostics Diagnostics { get; set; } = new NullProviderDiagnostics(); + + /// + /// Logger used by the AIProvider base class and SDK utilities. + /// + public static IProviderLogger Logger { get; set; } = new DebugProviderLogger(); + + /// + /// HTTP client factory used by the AIProvider base class. The host installs a + /// pooled factory at startup; tests can swap a mock factory here. + /// + public static IProviderHttpClientFactory HttpClientFactory { get; set; } = new DefaultProviderHttpClientFactory(); + + /// + /// Factory used by the AIProvider base class to obtain a per-provider settings + /// store scoped to a single provider id. The default returns an in-memory store + /// so tests can exercise SDK paths without a host attached; the SmartHopper host + /// replaces this with a real, persistence-backed factory at startup. + /// + public static System.Func SettingsStoreFactory { get; set; } + = providerName => new InMemoryProviderSettingsStore(providerName); + } +} diff --git a/src/SmartHopper.ProviderSdk/LICENSE b/src/SmartHopper.ProviderSdk/LICENSE new file mode 100644 index 000000000..535881452 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-2026 Marc Roca Musach + SmartHopper Community + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/SmartHopper.ProviderSdk/Metadata/AssemblyInfo.cs b/src/SmartHopper.ProviderSdk/Metadata/AssemblyInfo.cs new file mode 100644 index 000000000..631f70259 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Metadata/AssemblyInfo.cs @@ -0,0 +1,24 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using SmartHopper.ProviderSdk.Metadata; + +// Declare the SemVer of the contract surface exposed by SmartHopper.ProviderSdk. +// Providers declare BuiltAgainstSdk("1.0.0") and MinHostSdk("1.0.0") against this value. +// MAJOR is bumped on breaking provider-contract changes. +[assembly: SmartHopperProviderSdkVersion("1.0.0")] diff --git a/src/SmartHopper.ProviderSdk/Metadata/SdkCompatibility.cs b/src/SmartHopper.ProviderSdk/Metadata/SdkCompatibility.cs new file mode 100644 index 000000000..f1f7734f1 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Metadata/SdkCompatibility.cs @@ -0,0 +1,143 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System; +using System.Linq; +using System.Reflection; + +namespace SmartHopper.ProviderSdk.Metadata +{ + /// + /// Helpers for reading provider SDK version metadata and checking SemVer + /// compatibility between provider assemblies and the host's SDK copy. + /// + public static class SdkCompatibility + { + /// + /// The version of declared by + /// the currently loaded SmartHopper.ProviderSdk assembly. + /// + public static string HostSdkVersion { get; } = + typeof(SdkCompatibility).Assembly + .GetCustomAttributes() + .FirstOrDefault() + ?.Version + ?? "0.0.0"; + + /// + /// Outcome of a call. + /// + public enum CompatibilityResult + { + /// The provider is compatible with the host SDK. + Compatible, + + /// The provider's BuiltAgainstSdk MAJOR does not match the host SDK MAJOR. + MajorMismatch, + + /// The host SDK version is lower than the provider's declared MinHostSdk. + HostTooOld, + + /// The provider does not declare its BuiltAgainstSdk at all. + MissingMetadata, + } + + /// + /// Check whether the provider assembly is compatible with the host SDK based on + /// and . + /// + /// The loaded provider assembly to inspect. + /// A user-facing diagnostic on failure; empty on success. + public static CompatibilityResult Check(Assembly providerAssembly, out string diagnostic) + { + if (providerAssembly is null) + { + throw new ArgumentNullException(nameof(providerAssembly)); + } + + var builtAgainst = providerAssembly + .GetCustomAttributes() + .FirstOrDefault() + ?.Version; + var minHost = providerAssembly + .GetCustomAttributes() + .FirstOrDefault() + ?.Version; + + if (string.IsNullOrWhiteSpace(builtAgainst)) + { + diagnostic = $"Provider '{providerAssembly.GetName().Name}' does not declare [BuiltAgainstSdk]; SDK compatibility cannot be verified."; + return CompatibilityResult.MissingMetadata; + } + + if (GetMajor(builtAgainst) != GetMajor(HostSdkVersion)) + { + diagnostic = $"Provider '{providerAssembly.GetName().Name}' was built against SDK {builtAgainst}; host SDK is {HostSdkVersion}. Major versions must match."; + return CompatibilityResult.MajorMismatch; + } + + if (!string.IsNullOrWhiteSpace(minHost) && Compare(HostSdkVersion, minHost!) < 0) + { + diagnostic = $"Provider '{providerAssembly.GetName().Name}' requires host SDK >= {minHost}, but host SDK is {HostSdkVersion}."; + return CompatibilityResult.HostTooOld; + } + + diagnostic = string.Empty; + return CompatibilityResult.Compatible; + } + + private static int GetMajor(string semVer) + { + if (string.IsNullOrWhiteSpace(semVer)) + { + return 0; + } + + var idx = semVer.IndexOf('.'); + var head = idx > 0 ? semVer.Substring(0, idx) : semVer; + return int.TryParse(head, out var major) ? major : 0; + } + + private static int Compare(string a, string b) + { + int[] pa = Parse(a); + int[] pb = Parse(b); + for (int i = 0; i < 3; i++) + { + if (pa[i] != pb[i]) + { + return pa[i].CompareTo(pb[i]); + } + } + + return 0; + } + + private static int[] Parse(string v) + { + var parts = (v ?? string.Empty).Split('.', '-', '+'); + var result = new int[3]; + for (int i = 0; i < 3 && i < parts.Length; i++) + { + int.TryParse(parts[i], out result[i]); + } + + return result; + } + } +} diff --git a/src/SmartHopper.ProviderSdk/Metadata/SmartHopperProviderSdkVersionAttribute.cs b/src/SmartHopper.ProviderSdk/Metadata/SmartHopperProviderSdkVersionAttribute.cs new file mode 100644 index 000000000..089bfacbe --- /dev/null +++ b/src/SmartHopper.ProviderSdk/Metadata/SmartHopperProviderSdkVersionAttribute.cs @@ -0,0 +1,120 @@ +/* + * SmartHopper - AI-powered Grasshopper Plugin + * Copyright (C) 2024-2026 Marc Roca Musach + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +using System; + +namespace SmartHopper.ProviderSdk.Metadata +{ + /// + /// Identifies the SmartHopper Provider SDK version of an assembly. + /// + /// + /// Applied automatically to SmartHopper.ProviderSdk itself (the host queries + /// this attribute to determine which SDK version it ships with), and intended to be + /// applied by community provider authors via + /// and to declare compatibility ranges. + /// + /// + /// + /// SemVer is used: MAJOR bumps indicate a breaking provider contract change. + /// Providers are loaded only when BuiltAgainstSdk.MAJOR == HostSdk.MAJOR and + /// HostSdk >= provider.MinHostSdk. Mismatches classify the provider as + /// Invalid and block the load with a clear error. + /// + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class SmartHopperProviderSdkVersionAttribute : Attribute + { + /// + /// Gets the SemVer version string identifying the SDK contract. + /// + public string Version { get; } + + /// + /// Initializes a new instance of the class. + /// + /// A SemVer string such as "1.0.0". + public SmartHopperProviderSdkVersionAttribute(string version) + { + this.Version = version ?? throw new ArgumentNullException(nameof(version)); + } + } + + /// + /// Applied by provider authors to declare which SDK version their assembly was + /// compiled against. Combined with , it lets the + /// host reject providers built against an incompatible SDK MAJOR before any code + /// from the provider runs. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class BuiltAgainstSdkAttribute : Attribute + { + /// Gets the SDK version this provider was built against. + public string Version { get; } + + /// + /// Initializes a new instance of the class. + /// + /// A SemVer string such as "1.0.0". + public BuiltAgainstSdkAttribute(string version) + { + this.Version = version ?? throw new ArgumentNullException(nameof(version)); + } + } + + /// + /// Applied by provider authors to declare the minimum host SDK version they require. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class MinHostSdkAttribute : Attribute + { + /// Gets the minimum host SDK version this provider supports. + public string Version { get; } + + /// + /// Initializes a new instance of the class. + /// + /// A SemVer string such as "1.0.0". + public MinHostSdkAttribute(string version) + { + this.Version = version ?? throw new ArgumentNullException(nameof(version)); + } + } + + /// + /// Optional metadata applied by provider authors to declare a stable provider + /// identifier independent of the assembly name. Used during conflict resolution and + /// classification but is NOT a security boundary — names are easy to spoof; trust + /// decisions are still based on cryptographic checks. + /// + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] + public sealed class SmartHopperProviderIdAttribute : Attribute + { + /// Gets the provider identifier declared by the assembly. + public string ProviderId { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The provider identifier (e.g. "openai"). + public SmartHopperProviderIdAttribute(string providerId) + { + this.ProviderId = providerId ?? throw new ArgumentNullException(nameof(providerId)); + } + } +} diff --git a/src/SmartHopper.ProviderSdk/README.md b/src/SmartHopper.ProviderSdk/README.md new file mode 100644 index 000000000..b21630001 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/README.md @@ -0,0 +1,64 @@ +# SmartHopper.ProviderSdk + +Stable, MIT-licensed SDK for building third-party AI providers for [SmartHopper](https://github.com/architects-toolkit/SmartHopper). + +Community providers built against this SDK can compile on a clean machine without +the SmartHopper repository, produce a `SmartHopper.Providers..dll`, and drop +it into the SmartHopper provider folder. + +## License + +This SDK is licensed under the **MIT License** (see [LICENSE](LICENSE)). + +This is intentional: the SmartHopper host is licensed under **LGPLv3**, but the +SDK that providers link against is permissive so that closed-source community +providers can link to it without inheriting LGPL obligations on their own +assemblies. + +## What this package contains + +- Provider contracts: `IAIProvider`, `IAIProviderFactory`, `IAIProviderSettings`, `IAIProviderModels`. +- Provider base classes: `AIProvider`, `AIProvider`, `AIProviderSettings`, `AIProviderModels`, `AIProviderStreamingAdapter`. +- Request/response DTOs: `AICall.Core.Interactions`, `AICall.Core.Requests`, `AICall.Core.Returns`, `AICall.Core.Base`, `AICall.Metrics`. +- Model capability types: `AIModels.AICapability`, `AIModels.AIModelCapabilities`, `AIModels.AIModelPricing`, `AIExtraDescriptor`. +- Settings descriptors: `SettingDescriptor`, secret flags, validation result types. +- Streaming: `IStreamingAdapter` and provider-facing delta/result types. +- Host-injected abstractions a provider receives: `IProviderSettingsStore`, + `IProviderLogger`, `IProviderHttpClientFactory`, `IProviderDiagnostics`. +- Compatibility metadata: `SmartHopperProviderSdkVersionAttribute`, + `SmartHopperProviderIdAttribute`, `BuiltAgainstSdkAttribute`. + +## What this package does NOT contain + +The following remain in the SmartHopper host and are NOT exposed through the SDK: + +- `ProviderManager`, hash/signature verification, dialogs, settings persistence. +- Policy pipeline, conversation sessions, AICall validation pipeline, execution, + batch orchestration. +- Tool manager, tool registry, `IAIToolProvider` (tool DTOs in interactions are + included so providers can encode/decode tool calls in responses, but tool + registration is host-only). +- Rhino/Eto UI, WebChat, badges, runtime message UI. + +## Target frameworks + +- `net7.0-windows` +- `net7.0` + +## Getting started + +```bash +dotnet new classlib -n SmartHopper.Providers.MyProvider +dotnet add SmartHopper.Providers.MyProvider package SmartHopper.ProviderSdk +``` + +Then implement an `IAIProviderFactory` that returns your `AIProvider` +subclass. Build with target frameworks `net7.0-windows;net7.0` and drop the +resulting `SmartHopper.Providers.MyProvider.dll` into: + +- **App-local**: the same folder as `SmartHopper.Infrastructure.dll`, or +- **User-local**: `%AppData%\SmartHopper\Providers\` (Windows) / + `~/.config/SmartHopper/Providers/` (macOS). + +See [docs/Providers/ProviderSdk.md](https://github.com/architects-toolkit/SmartHopper/blob/main/docs/Providers/ProviderSdk.md) +in the SmartHopper repository for the full guide. diff --git a/src/SmartHopper.Infrastructure/Settings/SettingDescriptor.cs b/src/SmartHopper.ProviderSdk/Settings/SettingDescriptor.cs similarity index 99% rename from src/SmartHopper.Infrastructure/Settings/SettingDescriptor.cs rename to src/SmartHopper.ProviderSdk/Settings/SettingDescriptor.cs index cb144e71e..d6cf5f033 100644 --- a/src/SmartHopper.Infrastructure/Settings/SettingDescriptor.cs +++ b/src/SmartHopper.ProviderSdk/Settings/SettingDescriptor.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Generic; -namespace SmartHopper.Infrastructure.Settings +namespace SmartHopper.ProviderSdk.Settings { /// /// Wrapper for lazy evaluation of default values. diff --git a/src/SmartHopper.Infrastructure/Settings/SettingDescriptorControl.cs b/src/SmartHopper.ProviderSdk/Settings/SettingDescriptorControl.cs similarity index 96% rename from src/SmartHopper.Infrastructure/Settings/SettingDescriptorControl.cs rename to src/SmartHopper.ProviderSdk/Settings/SettingDescriptorControl.cs index 5b6899538..6c755d204 100644 --- a/src/SmartHopper.Infrastructure/Settings/SettingDescriptorControl.cs +++ b/src/SmartHopper.ProviderSdk/Settings/SettingDescriptorControl.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.Settings +namespace SmartHopper.ProviderSdk.Settings { /// /// Base class for UI control parameters for a setting descriptor. diff --git a/src/SmartHopper.ProviderSdk/SmartHopper.ProviderSdk.csproj b/src/SmartHopper.ProviderSdk/SmartHopper.ProviderSdk.csproj new file mode 100644 index 000000000..ad346f832 --- /dev/null +++ b/src/SmartHopper.ProviderSdk/SmartHopper.ProviderSdk.csproj @@ -0,0 +1,67 @@ + + + + + net7.0-windows;net7.0 + NU1701;NETSDK1086;SA1124;SA1200 + true + true + true + + + + SmartHopper Provider SDK + Stable, MIT-licensed SDK for building SmartHopper AI provider plugins (e.g. SmartHopper.Providers.OpenAI). Provides the contracts, base classes, request/response DTOs, model capability types, and host-injected abstractions a provider needs to talk to its API and describe its models. + SmartHopper.ProviderSdk + MIT + smarthopper;grasshopper;rhino;ai;provider;sdk + https://github.com/architects-toolkit/SmartHopper + git + true + true + snupkg + + + + $(SolutionDir)bin/$(SolutionVersion)/$(Configuration) + + + + + + + + true + $(DefineConstants);WINDOWS + + + + + + + + + + + + + + + + diff --git a/src/SmartHopper.Infrastructure/Streaming/IStreamingAdapter.cs b/src/SmartHopper.ProviderSdk/Streaming/IStreamingAdapter.cs similarity index 94% rename from src/SmartHopper.Infrastructure/Streaming/IStreamingAdapter.cs rename to src/SmartHopper.ProviderSdk/Streaming/IStreamingAdapter.cs index e982b74ae..37e790b72 100644 --- a/src/SmartHopper.Infrastructure/Streaming/IStreamingAdapter.cs +++ b/src/SmartHopper.ProviderSdk/Streaming/IStreamingAdapter.cs @@ -19,10 +19,10 @@ using System.Collections.Generic; using System.Threading; -namespace SmartHopper.Infrastructure.Streaming +namespace SmartHopper.ProviderSdk.Streaming { - using SmartHopper.Infrastructure.AICall.Core.Requests; - using SmartHopper.Infrastructure.AICall.Core.Returns; + using SmartHopper.ProviderSdk.AICall.Core.Requests; + using SmartHopper.ProviderSdk.AICall.Core.Returns; /// /// Defines the contract for provider-specific streaming adapters that yield incremental AIReturn deltas. diff --git a/src/SmartHopper.Infrastructure/Utilities/JsonFormatHelper.cs b/src/SmartHopper.ProviderSdk/Utilities/JsonFormatHelper.cs similarity index 99% rename from src/SmartHopper.Infrastructure/Utilities/JsonFormatHelper.cs rename to src/SmartHopper.ProviderSdk/Utilities/JsonFormatHelper.cs index 93f356644..11f012ea4 100644 --- a/src/SmartHopper.Infrastructure/Utilities/JsonFormatHelper.cs +++ b/src/SmartHopper.ProviderSdk/Utilities/JsonFormatHelper.cs @@ -23,7 +23,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace SmartHopper.Infrastructure.Utilities +namespace SmartHopper.ProviderSdk.Utilities { /// /// Centralized utility for consistent JSON formatting across all JSON components and tools. diff --git a/src/SmartHopper.Infrastructure/Utilities/JsonPathHelper.cs b/src/SmartHopper.ProviderSdk/Utilities/JsonPathHelper.cs similarity index 98% rename from src/SmartHopper.Infrastructure/Utilities/JsonPathHelper.cs rename to src/SmartHopper.ProviderSdk/Utilities/JsonPathHelper.cs index e560ec429..32d8cf2ba 100644 --- a/src/SmartHopper.Infrastructure/Utilities/JsonPathHelper.cs +++ b/src/SmartHopper.ProviderSdk/Utilities/JsonPathHelper.cs @@ -16,7 +16,7 @@ * along with this library; if not, see . */ -namespace SmartHopper.Infrastructure.Utilities +namespace SmartHopper.ProviderSdk.Utilities { /// /// Helper class for JSON path operations and error message formatting. diff --git a/src/SmartHopper.Infrastructure/Utils/Filter.cs b/src/SmartHopper.ProviderSdk/Utils/Filter.cs similarity index 98% rename from src/SmartHopper.Infrastructure/Utils/Filter.cs rename to src/SmartHopper.ProviderSdk/Utils/Filter.cs index 5d50e324b..5d060d8ec 100644 --- a/src/SmartHopper.Infrastructure/Utils/Filter.cs +++ b/src/SmartHopper.ProviderSdk/Utils/Filter.cs @@ -21,7 +21,7 @@ using System.Diagnostics; using System.Linq; -namespace SmartHopper.Infrastructure.Utils +namespace SmartHopper.ProviderSdk.Utils { /// /// Encapsulates include/exclude rules parsed from a filter string diff --git a/src/SmartHopper.Infrastructure/Utils/HttpHeadersHelper.cs b/src/SmartHopper.ProviderSdk/Utils/HttpHeadersHelper.cs similarity index 98% rename from src/SmartHopper.Infrastructure/Utils/HttpHeadersHelper.cs rename to src/SmartHopper.ProviderSdk/Utils/HttpHeadersHelper.cs index ab964b2cc..37f4e6e67 100644 --- a/src/SmartHopper.Infrastructure/Utils/HttpHeadersHelper.cs +++ b/src/SmartHopper.ProviderSdk/Utils/HttpHeadersHelper.cs @@ -20,7 +20,7 @@ using System.Collections.Generic; using System.Net.Http; -namespace SmartHopper.Infrastructure.Utils +namespace SmartHopper.ProviderSdk.Utils { /// /// Shared helper for applying request-scoped HTTP headers consistently across diff --git a/src/SmartHopper.Providers.Anthropic/AnthropicProvider.cs b/src/SmartHopper.Providers.Anthropic/AnthropicProvider.cs index e74e1c931..7140bd63d 100644 --- a/src/SmartHopper.Providers.Anthropic/AnthropicProvider.cs +++ b/src/SmartHopper.Providers.Anthropic/AnthropicProvider.cs @@ -29,20 +29,22 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.JsonSchemas; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Streaming; -using SmartHopper.Infrastructure.Utilities; using SmartHopper.Infrastructure.Utils; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Streaming; +using SmartHopper.ProviderSdk.Utilities; +using SmartHopper.ProviderSdk.Utils; namespace SmartHopper.Providers.Anthropic { @@ -1246,7 +1248,7 @@ private static bool SupportsStructuredOutputs(string model) return false; } - var caps = ModelManager.Instance.GetCapabilities("Anthropic", model); + var caps = AIModelCapabilityRegistry.Instance.GetCapabilities("Anthropic", model); return caps?.HasCapability(AICapability.Text2Json) == true; } diff --git a/src/SmartHopper.Providers.Anthropic/AnthropicProviderFactory.cs b/src/SmartHopper.Providers.Anthropic/AnthropicProviderFactory.cs index 4d77f1df2..ddd3a6e2d 100644 --- a/src/SmartHopper.Providers.Anthropic/AnthropicProviderFactory.cs +++ b/src/SmartHopper.Providers.Anthropic/AnthropicProviderFactory.cs @@ -17,6 +17,7 @@ */ using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.Anthropic { diff --git a/src/SmartHopper.Providers.Anthropic/AnthropicProviderModels.cs b/src/SmartHopper.Providers.Anthropic/AnthropicProviderModels.cs index e954f7fd7..ee6ecab78 100644 --- a/src/SmartHopper.Providers.Anthropic/AnthropicProviderModels.cs +++ b/src/SmartHopper.Providers.Anthropic/AnthropicProviderModels.cs @@ -21,10 +21,11 @@ using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.Anthropic { diff --git a/src/SmartHopper.Providers.Anthropic/AnthropicProviderSettings.cs b/src/SmartHopper.Providers.Anthropic/AnthropicProviderSettings.cs index 2ae937369..5d1af1e57 100644 --- a/src/SmartHopper.Providers.Anthropic/AnthropicProviderSettings.cs +++ b/src/SmartHopper.Providers.Anthropic/AnthropicProviderSettings.cs @@ -22,6 +22,8 @@ using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Providers.Anthropic { diff --git a/src/SmartHopper.Providers.DeepSeek/DeepSeekJsonSchemaAdapter.cs b/src/SmartHopper.Providers.DeepSeek/DeepSeekJsonSchemaAdapter.cs index 278a4fda1..a73a3d954 100644 --- a/src/SmartHopper.Providers.DeepSeek/DeepSeekJsonSchemaAdapter.cs +++ b/src/SmartHopper.Providers.DeepSeek/DeepSeekJsonSchemaAdapter.cs @@ -20,7 +20,7 @@ using System.Diagnostics; using System.Text.RegularExpressions; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; namespace SmartHopper.Providers.DeepSeek { diff --git a/src/SmartHopper.Providers.DeepSeek/DeepSeekProvider.cs b/src/SmartHopper.Providers.DeepSeek/DeepSeekProvider.cs index 7be164232..039e255f5 100644 --- a/src/SmartHopper.Providers.DeepSeek/DeepSeekProvider.cs +++ b/src/SmartHopper.Providers.DeepSeek/DeepSeekProvider.cs @@ -30,16 +30,17 @@ using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.JsonSchemas; -using SmartHopper.Infrastructure.AICall.Metrics; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Streaming; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Streaming; namespace SmartHopper.Providers.DeepSeek { diff --git a/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderFactory.cs b/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderFactory.cs index 5beb39dce..45ba7aa72 100644 --- a/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderFactory.cs +++ b/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderFactory.cs @@ -17,6 +17,7 @@ */ using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.DeepSeek { diff --git a/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderModels.cs b/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderModels.cs index fd742c399..a67eea208 100644 --- a/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderModels.cs +++ b/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderModels.cs @@ -19,8 +19,9 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.DeepSeek { diff --git a/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderSettings.cs b/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderSettings.cs index f5271f671..0868e309d 100644 --- a/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderSettings.cs +++ b/src/SmartHopper.Providers.DeepSeek/DeepSeekProviderSettings.cs @@ -22,6 +22,8 @@ using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Providers.DeepSeek { diff --git a/src/SmartHopper.Providers.Gemini/GeminiProvider.Batch.cs b/src/SmartHopper.Providers.Gemini/GeminiProvider.Batch.cs index 9f7de6013..5fe7c0497 100644 --- a/src/SmartHopper.Providers.Gemini/GeminiProvider.Batch.cs +++ b/src/SmartHopper.Providers.Gemini/GeminiProvider.Batch.cs @@ -24,12 +24,12 @@ using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Providers.Gemini { diff --git a/src/SmartHopper.Providers.Gemini/GeminiProvider.Decode.cs b/src/SmartHopper.Providers.Gemini/GeminiProvider.Decode.cs index 38a5f720e..cbb69b885 100644 --- a/src/SmartHopper.Providers.Gemini/GeminiProvider.Decode.cs +++ b/src/SmartHopper.Providers.Gemini/GeminiProvider.Decode.cs @@ -21,10 +21,10 @@ using System.Diagnostics; using System.Linq; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.Diagnostics; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.Diagnostics; namespace SmartHopper.Providers.Gemini { diff --git a/src/SmartHopper.Providers.Gemini/GeminiProvider.Streaming.cs b/src/SmartHopper.Providers.Gemini/GeminiProvider.Streaming.cs index 8aafb8a9b..0ef13988f 100644 --- a/src/SmartHopper.Providers.Gemini/GeminiProvider.Streaming.cs +++ b/src/SmartHopper.Providers.Gemini/GeminiProvider.Streaming.cs @@ -25,12 +25,13 @@ using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Streaming; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Streaming; namespace SmartHopper.Providers.Gemini { diff --git a/src/SmartHopper.Providers.Gemini/GeminiProvider.cs b/src/SmartHopper.Providers.Gemini/GeminiProvider.cs index 4667e30f7..29ce8b514 100644 --- a/src/SmartHopper.Providers.Gemini/GeminiProvider.cs +++ b/src/SmartHopper.Providers.Gemini/GeminiProvider.cs @@ -28,14 +28,15 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Providers.Gemini.Properties; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.Gemini { diff --git a/src/SmartHopper.Providers.Gemini/GeminiProviderFactory.cs b/src/SmartHopper.Providers.Gemini/GeminiProviderFactory.cs index 88759fa31..dea4407c8 100644 --- a/src/SmartHopper.Providers.Gemini/GeminiProviderFactory.cs +++ b/src/SmartHopper.Providers.Gemini/GeminiProviderFactory.cs @@ -19,6 +19,7 @@ using System; using System.Diagnostics; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.Gemini { diff --git a/src/SmartHopper.Providers.Gemini/GeminiProviderModels.cs b/src/SmartHopper.Providers.Gemini/GeminiProviderModels.cs index f6f08c635..19af2d0c3 100644 --- a/src/SmartHopper.Providers.Gemini/GeminiProviderModels.cs +++ b/src/SmartHopper.Providers.Gemini/GeminiProviderModels.cs @@ -21,11 +21,12 @@ using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.Gemini { diff --git a/src/SmartHopper.Providers.Gemini/GeminiProviderSettings.cs b/src/SmartHopper.Providers.Gemini/GeminiProviderSettings.cs index fa8d873ae..e5917b5ae 100644 --- a/src/SmartHopper.Providers.Gemini/GeminiProviderSettings.cs +++ b/src/SmartHopper.Providers.Gemini/GeminiProviderSettings.cs @@ -22,6 +22,8 @@ using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Providers.Gemini { diff --git a/src/SmartHopper.Providers.MistralAI/MistralAIJsonSchemaAdapter.cs b/src/SmartHopper.Providers.MistralAI/MistralAIJsonSchemaAdapter.cs index aa23d1496..20050f042 100644 --- a/src/SmartHopper.Providers.MistralAI/MistralAIJsonSchemaAdapter.cs +++ b/src/SmartHopper.Providers.MistralAI/MistralAIJsonSchemaAdapter.cs @@ -18,7 +18,7 @@ using System; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; namespace SmartHopper.Providers.MistralAI { diff --git a/src/SmartHopper.Providers.MistralAI/MistralAIProvider.cs b/src/SmartHopper.Providers.MistralAI/MistralAIProvider.cs index 80953b429..56499f00d 100644 --- a/src/SmartHopper.Providers.MistralAI/MistralAIProvider.cs +++ b/src/SmartHopper.Providers.MistralAI/MistralAIProvider.cs @@ -27,19 +27,20 @@ using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.JsonSchemas; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Streaming; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Streaming; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Providers.MistralAI { diff --git a/src/SmartHopper.Providers.MistralAI/MistralAIProviderFactory.cs b/src/SmartHopper.Providers.MistralAI/MistralAIProviderFactory.cs index 308d4575d..f30f7e2d0 100644 --- a/src/SmartHopper.Providers.MistralAI/MistralAIProviderFactory.cs +++ b/src/SmartHopper.Providers.MistralAI/MistralAIProviderFactory.cs @@ -17,6 +17,7 @@ */ using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.MistralAI { diff --git a/src/SmartHopper.Providers.MistralAI/MistralAIProviderModels.cs b/src/SmartHopper.Providers.MistralAI/MistralAIProviderModels.cs index 41dc8b2ad..c426aa573 100644 --- a/src/SmartHopper.Providers.MistralAI/MistralAIProviderModels.cs +++ b/src/SmartHopper.Providers.MistralAI/MistralAIProviderModels.cs @@ -22,10 +22,11 @@ using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.MistralAI { diff --git a/src/SmartHopper.Providers.MistralAI/MistralAIProviderSettings.cs b/src/SmartHopper.Providers.MistralAI/MistralAIProviderSettings.cs index 300edfa74..4fec21831 100644 --- a/src/SmartHopper.Providers.MistralAI/MistralAIProviderSettings.cs +++ b/src/SmartHopper.Providers.MistralAI/MistralAIProviderSettings.cs @@ -22,6 +22,8 @@ using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Providers.MistralAI { diff --git a/src/SmartHopper.Providers.OpenAI/OpenAIJsonSchemaAdapter.cs b/src/SmartHopper.Providers.OpenAI/OpenAIJsonSchemaAdapter.cs index b9d26775c..40cc6ac9b 100644 --- a/src/SmartHopper.Providers.OpenAI/OpenAIJsonSchemaAdapter.cs +++ b/src/SmartHopper.Providers.OpenAI/OpenAIJsonSchemaAdapter.cs @@ -18,7 +18,7 @@ using System; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; namespace SmartHopper.Providers.OpenAI { diff --git a/src/SmartHopper.Providers.OpenAI/OpenAIProvider.cs b/src/SmartHopper.Providers.OpenAI/OpenAIProvider.cs index 61c7885e6..4cfc8f854 100644 --- a/src/SmartHopper.Providers.OpenAI/OpenAIProvider.cs +++ b/src/SmartHopper.Providers.OpenAI/OpenAIProvider.cs @@ -28,19 +28,20 @@ using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Batch; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.JsonSchemas; -using SmartHopper.Infrastructure.AICall.Metrics; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Streaming; -using SmartHopper.Infrastructure.Utilities; +using SmartHopper.ProviderSdk.AICall.Batch; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Streaming; +using SmartHopper.ProviderSdk.Utilities; namespace SmartHopper.Providers.OpenAI { diff --git a/src/SmartHopper.Providers.OpenAI/OpenAIProviderFactory.cs b/src/SmartHopper.Providers.OpenAI/OpenAIProviderFactory.cs index cb0845e85..47eec1ee2 100644 --- a/src/SmartHopper.Providers.OpenAI/OpenAIProviderFactory.cs +++ b/src/SmartHopper.Providers.OpenAI/OpenAIProviderFactory.cs @@ -17,6 +17,7 @@ */ using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.OpenAI { diff --git a/src/SmartHopper.Providers.OpenAI/OpenAIProviderModels.cs b/src/SmartHopper.Providers.OpenAI/OpenAIProviderModels.cs index 27277f943..41b2a11c1 100644 --- a/src/SmartHopper.Providers.OpenAI/OpenAIProviderModels.cs +++ b/src/SmartHopper.Providers.OpenAI/OpenAIProviderModels.cs @@ -21,10 +21,11 @@ using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.OpenAI { diff --git a/src/SmartHopper.Providers.OpenAI/OpenAIProviderSettings.cs b/src/SmartHopper.Providers.OpenAI/OpenAIProviderSettings.cs index 5d5c9638b..58098091b 100644 --- a/src/SmartHopper.Providers.OpenAI/OpenAIProviderSettings.cs +++ b/src/SmartHopper.Providers.OpenAI/OpenAIProviderSettings.cs @@ -23,6 +23,8 @@ using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Providers.OpenAI { diff --git a/src/SmartHopper.Providers.OpenRouter/OpenRouterProvider.cs b/src/SmartHopper.Providers.OpenRouter/OpenRouterProvider.cs index 0e9cef12c..2847df538 100644 --- a/src/SmartHopper.Providers.OpenRouter/OpenRouterProvider.cs +++ b/src/SmartHopper.Providers.OpenRouter/OpenRouterProvider.cs @@ -28,16 +28,17 @@ using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core; -using SmartHopper.Infrastructure.AICall.Core.Base; -using SmartHopper.Infrastructure.AICall.Core.Interactions; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AICall.JsonSchemas; -using SmartHopper.Infrastructure.AICall.Metrics; using SmartHopper.Infrastructure.AIProviders; -using SmartHopper.Infrastructure.Diagnostics; -using SmartHopper.Infrastructure.Streaming; +using SmartHopper.ProviderSdk.AICall.Core; +using SmartHopper.ProviderSdk.AICall.Core.Base; +using SmartHopper.ProviderSdk.AICall.Core.Interactions; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AICall.JsonSchemas; +using SmartHopper.ProviderSdk.AICall.Metrics; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Diagnostics; +using SmartHopper.ProviderSdk.Streaming; namespace SmartHopper.Providers.OpenRouter { @@ -538,7 +539,7 @@ public override List Decode(JObject response) reasoning: string.IsNullOrWhiteSpace(reasoning) ? null : reasoning); // Extract metrics (tokens, model, finish reason) if present - var metrics = new Infrastructure.AICall.Metrics.AIMetrics + var metrics = new ProviderSdk.AICall.Metrics.AIMetrics { Provider = this.Name, Model = response["model"]?.ToString(), diff --git a/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderFactory.cs b/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderFactory.cs index 33eae21c8..b60b99353 100644 --- a/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderFactory.cs +++ b/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderFactory.cs @@ -17,6 +17,7 @@ */ using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.OpenRouter { diff --git a/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderModels.cs b/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderModels.cs index 859d1a2cf..57a81bcab 100644 --- a/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderModels.cs +++ b/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderModels.cs @@ -22,10 +22,11 @@ using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json.Linq; -using SmartHopper.Infrastructure.AICall.Core.Requests; -using SmartHopper.Infrastructure.AICall.Core.Returns; -using SmartHopper.Infrastructure.AIModels; using SmartHopper.Infrastructure.AIProviders; +using SmartHopper.ProviderSdk.AICall.Core.Requests; +using SmartHopper.ProviderSdk.AICall.Core.Returns; +using SmartHopper.ProviderSdk.AIModels; +using SmartHopper.ProviderSdk.AIProviders; namespace SmartHopper.Providers.OpenRouter { diff --git a/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderSettings.cs b/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderSettings.cs index 199c7eafc..c73b3a438 100644 --- a/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderSettings.cs +++ b/src/SmartHopper.Providers.OpenRouter/OpenRouterProviderSettings.cs @@ -23,6 +23,8 @@ using SmartHopper.Infrastructure.AIProviders; using SmartHopper.Infrastructure.Dialogs; using SmartHopper.Infrastructure.Settings; +using SmartHopper.ProviderSdk.AIProviders; +using SmartHopper.ProviderSdk.Settings; namespace SmartHopper.Providers.OpenRouter {