| 1 | using CascadeIDE.Services; |
| 2 | |
| 3 | namespace CascadeIDE.Models; |
| 4 | |
| 5 | /// <summary>Federated team transport (ADR 0144). TOML: <c>[intercom.transport]</c>.</summary> |
| 6 | public sealed class IntercomTransportSettings |
| 7 | { |
| 8 | /// <summary>Локальный reference server (совпадает с <c>launchSettings</c> intercom-service).</summary> |
| 9 | public const string DefaultBaseUrl = "http://127.0.0.1:5080"; |
| 10 | |
| 11 | /// <summary>Относительно каталога CascadeIDE.exe (после <c>publish-*</c>).</summary> |
| 12 | public const string DefaultLocalServerRelativePath = "tools/intercom-service/IntercomService.exe"; |
| 13 | |
| 14 | /// <summary>Включить FederatedSync (нужны <c>base_url</c> и team id).</summary> |
| 15 | public bool Enabled { get; set; } |
| 16 | |
| 17 | /// <summary>Базовый URL reference Intercom service, без завершающего <c>/</c>.</summary> |
| 18 | public string BaseUrl { get; set; } = DefaultBaseUrl; |
| 19 | |
| 20 | /// <summary>TOML: <c>base_url_env</c> (ADR 0149).</summary> |
| 21 | public string BaseUrlEnv { get; set; } = ""; |
| 22 | |
| 23 | /// <summary>Путь к <c>IntercomService.exe</c> (TOML: <c>local_server_path</c>), относительный или абсолютный.</summary> |
| 24 | public string LocalServerPath { get; set; } = DefaultLocalServerRelativePath; |
| 25 | |
| 26 | /// <summary>TOML: <c>local_server_path_env</c> (ADR 0149).</summary> |
| 27 | public string LocalServerPathEnv { get; set; } = ""; |
| 28 | |
| 29 | /// <summary>Last selected <c>team_id</c> (кэш, не SSOT).</summary> |
| 30 | public string TeamId { get; set; } = ""; |
| 31 | |
| 32 | /// <summary>Topic на сервере; пусто — topic <c>general</c> после bootstrap.</summary> |
| 33 | public string DefaultTopicId { get; set; } = ""; |
| 34 | |
| 35 | /// <summary>OAuth provider для Connect (<c>provider_id</c> из <c>/auth/providers</c>).</summary> |
| 36 | public string OAuthProvider { get; set; } = "github"; |
| 37 | |
| 38 | /// <summary>Опциональный invite token для join (ADR 0147 §2.1).</summary> |
| 39 | public string InviteToken { get; set; } = ""; |
| 40 | |
| 41 | /// <summary>DEV: shared team Bearer вместо JWT (только локальная разработка).</summary> |
| 42 | public string DevTeamToken { get; set; } = ""; |
| 43 | |
| 44 | /// <summary>Local hint per normalized repo URL. TOML: <c>[intercom.transport.workspace_hints."…"]</c>.</summary> |
| 45 | public Dictionary<string, IntercomWorkspaceHintEntry> WorkspaceHints { get; set; } = new(StringComparer.OrdinalIgnoreCase); |
| 46 | |
| 47 | /// <summary>Начальная задержка переподключения SSE, мс.</summary> |
| 48 | public int SseReconnectBackoffMs { get; set; } = 1000; |
| 49 | |
| 50 | /// <summary>При первом human send в Channel — предложить Connect (OAuth), если ещё не подключено.</summary> |
| 51 | public bool AutoConnectOnSend { get; set; } = true; |
| 52 | |
| 53 | /// <summary>Синхронизировать ответы ассистента в Channel (<c>sender_role: agent</c>).</summary> |
| 54 | public bool SyncAgentChannelMessages { get; set; } = true; |
| 55 | |
| 56 | /// <summary>Выбранный provisioned agent <c>member_id</c> для fan-out (ADR 0147 §3–4).</summary> |
| 57 | public string SelectedAgentMemberId { get; set; } = ""; |
| 58 | |
| 59 | /// <summary>Кэш display name выбранного агента (не SSOT).</summary> |
| 60 | public string SelectedAgentDisplayName { get; set; } = ""; |
| 61 | |
| 62 | public bool IsConfigured => |
| 63 | Enabled |
| 64 | && !string.IsNullOrWhiteSpace(ResolveBaseUrl()); |
| 65 | |
| 66 | public string ResolveBaseUrl() => |
| 67 | SettingsEnvResolver.Resolve(BaseUrl, BaseUrlEnv); |
| 68 | |
| 69 | public string ResolveLocalServerPath() => |
| 70 | SettingsEnvResolver.Resolve(LocalServerPath, LocalServerPathEnv); |
| 71 | } |
| 72 | |