Initial commit: omnichannel-mcp — MCP-сервер управления платформой Omnichannel
ci / test (push) Successful in 2m22s
ci / lint (push) Successful in 4m31s

This commit is contained in:
Maksim Totmin
2026-10-07 20:13:23 +07:00
commit fdbd4a4fb6
54 changed files with 5672 additions and 0 deletions
+216
View File
@@ -0,0 +1,216 @@
package configserver
import "encoding/json"
// Типизированные модели ответов config_server v1.1.0. Используются и для
// разбора, и для отдачи модели — так схема ответа остаётся явной и стабильной.
// Application — краткая запись сервиса (GET /api/applications).
type Application struct {
ID int `json:"id"`
Name string `json:"name"`
HostIP string `json:"host_ip"`
Hostname string `json:"hostname"`
Path string `json:"path"`
Status string `json:"status"`
Active bool `json:"active"`
IsFront bool `json:"is_front"`
BuildFolder string `json:"build_folder"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
// ComposeVersionRef — ссылка на версию compose в детализации приложения.
type ComposeVersionRef struct {
ID int `json:"id"`
Version int `json:"version"`
IsCurrent bool `json:"is_current"`
CreatedAt string `json:"created_at"`
}
// MigrationLog — запись журнала миграций приложения.
type MigrationLog struct {
ID int `json:"id"`
Command string `json:"command"`
Status string `json:"status"`
Output string `json:"output"`
CreatedAt string `json:"created_at"`
}
// ApplicationDetail — расширенная детализация (GET /api/application/<id>).
type ApplicationDetail struct {
Application
CurrentCompose string `json:"current_compose"`
ComposeVersions []ComposeVersionRef `json:"compose_versions"`
EnvFiles []string `json:"env_files"`
CurrentEnvFiles map[string]string `json:"current_env_files"`
MigrationLogs []MigrationLog `json:"migration_logs"`
}
// RawConfig — текущие compose/env приложения (GET /api/get_config/<id>).
type RawConfig struct {
Compose string `json:"compose"`
Env string `json:"env"`
}
// ComposeVersion — конкретная версия compose (GET /api/compose_version/<id>).
type ComposeVersion struct {
ID int `json:"id"`
Version int `json:"version"`
Content string `json:"content"`
CreatedAt string `json:"created_at"`
IsCurrent bool `json:"is_current"`
}
// EnvVersion — конкретная версия env-файла (GET /api/env_version/<id>).
type EnvVersion struct {
ID int `json:"id"`
Filename string `json:"filename"`
Version int `json:"version"`
Content string `json:"content"`
CreatedAt string `json:"created_at"`
IsCurrent bool `json:"is_current"`
}
// Task — задача агента (GET /api/tasks, /api/task/<id>, /api/deployment/tasks).
type Task struct {
TaskID string `json:"task_id"`
ApplicationID int `json:"application_id"`
ApplicationName string `json:"application_name"`
TaskType string `json:"task_type"`
Command string `json:"command"`
Status string `json:"status"`
HostIP string `json:"host_ip"`
Payload json.RawMessage `json:"payload"`
Output string `json:"output"`
CreatedAt string `json:"created_at"`
CompletedAt string `json:"completed_at"`
}
// Stats — счётчики версий (GET /api/stats).
type Stats struct {
ComposeVersions int `json:"compose_versions"`
EnvVersions int `json:"env_versions"`
MigrationLogs int `json:"migration_logs"`
}
// ServiceInfo — сервис в карте серверов.
type ServiceInfo struct {
ID int `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Status string `json:"status"`
Active bool `json:"active"`
UpdatedAt string `json:"updated_at"`
}
// ServerNode — хост и его сервисы в карте (GET /api/service_map).
type ServerNode struct {
HostIP string `json:"host_ip"`
Hostname string `json:"hostname"`
TotalServices int `json:"total_services"`
ActiveServices int `json:"active_services"`
Services []ServiceInfo `json:"services"`
}
// ServiceMap — ответ GET /api/service_map.
type ServiceMap struct {
Servers []ServerNode `json:"servers"`
ServersCount int `json:"servers_count"`
ServicesCount int `json:"services_count"`
}
// DeploymentFiles — schema/manifest/prebuild_vars/ip_overrides.
type DeploymentFiles struct {
Schema string `json:"schema"`
Manifest string `json:"manifest"`
PrebuildVars string `json:"prebuild_vars"`
IPOverrides string `json:"ip_overrides"`
}
// ReleaseJob — статус фоновой загрузки релиза (GET /api/deployment/release_job).
type ReleaseJob struct {
Status string `json:"status"`
Phase string `json:"phase"`
ImagesPulled int `json:"images_pulled"`
ImagesTotal int `json:"images_total"`
Message string `json:"message"`
Output string `json:"output"`
Stderr string `json:"stderr"`
UpdatedAt string `json:"updated_at"`
}
// IPMatch — диагностика сопоставления IP схемы и агентов.
type IPMatch struct {
SchemaIPs []string `json:"schema_ips"`
AgentIPsInDB []string `json:"agent_ips_in_db"`
IPOverrides map[string]string `json:"ip_overrides"`
MatchedPairs map[string]string `json:"matched_pairs"`
UnmatchedSchemaIPs []string `json:"unmatched_schema_ips"`
}
// TaskAck — ответ операций жизненного цикла (deploy/restart/down/migrate/update_config).
type TaskAck struct {
Status string `json:"status"`
AppID int `json:"app_id"`
AppName string `json:"app_name"`
HostIP string `json:"host_ip"`
TaskID string `json:"task_id"`
LogID int `json:"log_id"`
Message string `json:"message"`
}
// ConfigAck — ответ установки compose/env.
type ConfigAck struct {
Status string `json:"status"`
AppID int `json:"app_id"`
Version int `json:"version"`
Filename string `json:"filename"`
}
// StatusAck — простой ответ {"status": "..."} c опциональным сообщением.
type StatusAck struct {
Status string `json:"status"`
Message string `json:"message"`
}
// FrontAck — ответ update_front.
type FrontAck struct {
Status string `json:"status"`
AppID int `json:"app_id"`
BuildFolder string `json:"build_folder"`
TaskID string `json:"task_id"`
Message string `json:"message"`
}
// CleanupAck — ответ cleanup_old_versions.
type CleanupAck struct {
Status string `json:"status"`
DeletedComposeVersions int `json:"deleted_compose_versions"`
DeletedEnvVersions int `json:"deleted_env_versions"`
DeletedMigrationLogs int `json:"deleted_migration_logs"`
Message string `json:"message"`
}
// SeedHostsAck — ответ seed_hosts.
type SeedHostsAck struct {
Status string `json:"status"`
Created int `json:"created"`
Updated int `json:"updated"`
IPs []string `json:"ips"`
}
// DownloadReleaseAck — ответ download_release (синхронный и фоновый).
type DownloadReleaseAck struct {
Status string `json:"status"`
LoadImages bool `json:"load_images"`
Message string `json:"message"`
DownloadedServices []string `json:"downloaded_services"`
SyncTaskIDs []string `json:"sync_task_ids"`
}
// StartServicesAck — ответ start_services.
type StartServicesAck struct {
Status string `json:"status"`
StartTaskIDs []string `json:"start_task_ids"`
}