Forge
markdown4405de34
1# Intercom Service
2
3Reference transport для командного Intercom ([ADR 0144](../../docs/adr/0144-intercom-team-transport-cide-sync-and-reference-service.md)): append-only events, SSE, OAuth (GitHub + generic OIDC), JWT.
4
5Часть репозитория **cascade-ide** — `host/intercom-service/`. Сборка вместе с IDE: `CascadeIDE.slnx`.
6
7## Стек
8
9- ASP.NET Minimal API (.NET 10)
10- **EF Core** — `IntercomDbContext`; **v1 default:** [WitDatabase](https://github.com/dmitrat/WitDatabase) (`data/intercom.witdb`, `UseWitDb`)
11- **v1.1+ ops:** тот же контекст, другой провайдер EF (Postgres, SQL Server, …) — connection string из конфига ([ADR 0144 §3.1](../../docs/adr/0144-intercom-team-transport-cide-sync-and-reference-service.md))
12- GitHub / OIDC → JWT для API/SSE
13
14## Запуск (dev)
15
16```powershell
17cd host/intercom-service/src/IntercomService
18dotnet run
19```
20
21Слушает `http://127.0.0.1:5080` (см. `Properties/launchSettings.json`).
22
23### Publish (exe, без SDK на целевой машине)
24
25```powershell
26# из корня cascade-ide
27.\scripts\intercom\publish-intercom-service.ps1 -Configuration Release -SelfContained
28# → artifacts/intercom-service/IntercomService.exe
29```
30
31Скрипты `scripts/deploy/publish-release.ps1` и `publish-debug.ps1` вызывают publish intercom и копируют в `<Target>/tools/intercom-service/`.
32
33В CIDE (`defaults-settings.toml`): `base_url = "http://127.0.0.1:5080"`, `local_server_path = "tools/intercom-service/IntercomService.exe"` (относительно CascadeIDE.exe). Если exe ещё нет — fallback `artifacts/` или `dotnet run`.
34
35### GitHub OAuth App
36
371. GitHub → Settings → Developer settings → OAuth App.
382. Homepage: `http://127.0.0.1:5080`
393. Callback: `http://127.0.0.1:5080/api/v1/auth/callback/github`
404. **User Secrets** (рекомендуется; переживает `publish-debug`, в git не попадает):
41
42```powershell
43# из корня cascade-ide
44.\scripts\intercom\set-intercom-github-user-secrets.ps1 -ClientId "<id>" -ClientSecret "<secret>"
45# или однократная миграция со старого appsettings.Development.local.json:
46.\scripts\intercom\set-intercom-github-user-secrets.ps1 -FromLocalFile
47```
48
49Секреты: `%APPDATA%\Microsoft\UserSecrets\7f3c8a2e-4b1d-4f9a-9c2e-1a8b4d6e0f31\secrets.json`.
50Подхватываются при `ASPNETCORE_ENVIRONMENT=Development` (CIDE выставляет при `intercom server start`).
51
52### Dev bootstrap (без GitHub)
53
54В Development задан `DevAuth:TeamToken` — Bearer для curl/тестов:
55
56```http
57Authorization: Bearer dev-intercom-local-change-me
58```
59
60## Пилот с Tailscale
61
621. Запусти сервис на машине с постоянным IP в tailnet.
632. В `appsettings` укажи `Intercom:PublicBaseUrl` = `http://100.x.x.x:5080` (для OAuth callback).
643. Коллега в CIDE: `base_url` = тот же URL; Connect Intercom (GitHub).
65
66## API (кратко)
67
68| Метод | Путь |
69|-------|------|
70| GET | `/health` |
71| GET | `/api/v1/auth/login?provider=github&team_id=…&redirect_uri=…` |
72| GET | `/api/v1/auth/callback/github` |
73| POST | `/api/v1/auth/token` |
74| GET | `/api/v1/teams/{teamId}/topics` |
75| POST | `/api/v1/topics/{topicId}/events` |
76| GET | `/api/v1/teams/{teamId}/stream` (SSE) |
77
78Wire: [wire/intercom-wire](../../wire/intercom-wire/README.md) · HTTP profile: [openapi.yaml](../../wire/intercom-wire/profiles/reference-http-v1/openapi.yaml) · ADR [0146](../../docs/adr/0146-intercom-wire-canonical-protocol-package.md).
79
80## Тесты
81
82```powershell
83dotnet test CascadeIDE.slnx --filter "FullyQualifiedName~IntercomService"
84```
85
View only · write via MCP/CIDE