Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f27fd035bc | ||
|
|
cad54635a8 |
No files matched your search
@@ -19,12 +19,39 @@ jobs:
|
|||||||
tag: ${{ steps.release.outputs.tag }}
|
tag: ${{ steps.release.outputs.tag }}
|
||||||
bump: ${{ steps.release.outputs.bump }}
|
bump: ${{ steps.release.outputs.bump }}
|
||||||
release_url: ${{ steps.release.outputs.release_url }}
|
release_url: ${{ steps.release.outputs.release_url }}
|
||||||
|
backend_reuse_version: ${{ steps.changes.outputs.backend_reuse_version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Check if the released backend can be reused
|
||||||
|
id: changes
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
EVENT_NAME: ${{ gitea.event_name }}
|
||||||
|
BEFORE_SHA: ${{ gitea.event.before }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [[ "$EVENT_NAME" != push || ! "$BEFORE_SHA" =~ ^[0-9a-f]{40}$ ]] ||
|
||||||
|
! git merge-base --is-ancestor "$BEFORE_SHA" HEAD 2>/dev/null; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# Compare with a published release, including changes from any failed earlier run.
|
||||||
|
BASE_TAG=$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*' "$BEFORE_SHA" 2>/dev/null || true)
|
||||||
|
if [[ ! "$BASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || git diff --quiet "$BASE_TAG" HEAD --; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if git diff --quiet --no-renames "$BASE_TAG" HEAD -- . \
|
||||||
|
':(exclude)app/**' ':(exclude)components/**' ':(exclude)lib/**' ':(exclude)shared/**' \
|
||||||
|
':(exclude)entities/**' ':(exclude)public/**' ':(exclude)hooks/**' ':(exclude)tests/e2e/**' \
|
||||||
|
':(exclude)Dockerfile.frontend' ':(exclude)next.config.ts' ':(exclude)tsconfig.json' \
|
||||||
|
':(exclude)postcss.config.mjs' ':(exclude)eslint.config.mjs' ':(exclude)components.json' \
|
||||||
|
':(exclude,top,glob)playwright*.config.ts'; then
|
||||||
|
echo "backend_reuse_version=${BASE_TAG#v}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Test release version calculation
|
- name: Test release version calculation
|
||||||
run: node --test .ci/scripts/compute-release.test.mjs
|
run: node --test .ci/scripts/compute-release.test.mjs
|
||||||
|
|
||||||
@@ -42,17 +69,21 @@ jobs:
|
|||||||
test -f .ci/release/release-manifest.json
|
test -f .ci/release/release-manifest.json
|
||||||
|
|
||||||
backend-test:
|
backend-test:
|
||||||
|
needs: prepare-release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
if: needs.prepare-release.outputs.backend_reuse_version == ''
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node 22
|
- name: Setup Node 22
|
||||||
|
if: needs.prepare-release.outputs.backend_reuse_version == ''
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 22
|
||||||
|
|
||||||
- name: Start PostgreSQL 18
|
- name: Start PostgreSQL 18
|
||||||
|
if: needs.prepare-release.outputs.backend_reuse_version == ''
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -93,6 +124,7 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
- name: Install and test backend
|
- name: Install and test backend
|
||||||
|
if: needs.prepare-release.outputs.backend_reuse_version == ''
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
REQUIRE_TEST_POSTGRES: "1"
|
REQUIRE_TEST_POSTGRES: "1"
|
||||||
@@ -112,7 +144,7 @@ jobs:
|
|||||||
npm run test --prefix backend
|
npm run test --prefix backend
|
||||||
|
|
||||||
- name: Stop PostgreSQL
|
- name: Stop PostgreSQL
|
||||||
if: always()
|
if: always() && needs.prepare-release.outputs.backend_reuse_version == ''
|
||||||
shell: bash
|
shell: bash
|
||||||
run: docker rm -f "${PG_CONTAINER:-}" 2>/dev/null || true
|
run: docker rm -f "${PG_CONTAINER:-}" 2>/dev/null || true
|
||||||
|
|
||||||
@@ -123,6 +155,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
if: needs.prepare-release.outputs.backend_reuse_version == ''
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Configure backend image name
|
- name: Configure backend image name
|
||||||
@@ -135,6 +168,7 @@ jobs:
|
|||||||
echo "IMAGE_NAME=${{ env.REGISTRY }}/${owner}/${stem}-backend" >> "${GITHUB_ENV}"
|
echo "IMAGE_NAME=${{ env.REGISTRY }}/${owner}/${stem}-backend" >> "${GITHUB_ENV}"
|
||||||
|
|
||||||
- name: Prepare backend build context
|
- name: Prepare backend build context
|
||||||
|
if: needs.prepare-release.outputs.backend_reuse_version == ''
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -174,6 +208,7 @@ jobs:
|
|||||||
password: ${{ secrets.ACTIONS_PAT }}
|
password: ${{ secrets.ACTIONS_PAT }}
|
||||||
|
|
||||||
- name: Build and push backend image
|
- name: Build and push backend image
|
||||||
|
if: needs.prepare-release.outputs.backend_reuse_version == ''
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .ci/docker/backend
|
context: .ci/docker/backend
|
||||||
@@ -195,6 +230,18 @@ jobs:
|
|||||||
org.opencontainers.image.revision=${{ gitea.sha }}
|
org.opencontainers.image.revision=${{ gitea.sha }}
|
||||||
org.opencontainers.image.created=${{ gitea.event.head_commit.timestamp }}
|
org.opencontainers.image.created=${{ gitea.event.head_commit.timestamp }}
|
||||||
|
|
||||||
|
- name: Tag the existing backend image for this release
|
||||||
|
if: needs.prepare-release.outputs.backend_reuse_version != ''
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
BACKEND_VERSION: ${{ needs.prepare-release.outputs.backend_reuse_version }}
|
||||||
|
RELEASE_VERSION: ${{ needs.prepare-release.outputs.version }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
docker buildx imagetools create --prefer-index=false \
|
||||||
|
--tag "$IMAGE_NAME:$GITHUB_SHA" --tag "$IMAGE_NAME:$RELEASE_VERSION" \
|
||||||
|
"$IMAGE_NAME:$BACKEND_VERSION"
|
||||||
|
|
||||||
frontend-image:
|
frontend-image:
|
||||||
needs: prepare-release
|
needs: prepare-release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } f
|
|||||||
|
|
||||||
const errorText = (error: unknown) => error instanceof Error ? error.message : "Не удалось выполнить запрос"
|
const errorText = (error: unknown) => error instanceof Error ? error.message : "Не удалось выполнить запрос"
|
||||||
const modeLabels = { observer: "Наблюдатель", approval: "С подтверждением", autonomous: "Автономный" }
|
const modeLabels = { observer: "Наблюдатель", approval: "С подтверждением", autonomous: "Автономный" }
|
||||||
|
const operationSectionLabels: Record<string, string> = {
|
||||||
|
backups: "Резервные копии", certificates: "Сертификаты", filters: "Фильтры маршрутизации", firewall: "Межсетевой экран",
|
||||||
|
ipsec: "IPsec", logs: "Журналы", mcp: "Управление MCP", network: "Сеть и маршрутизация", "recursive-routes": "Рекурсивные маршруты",
|
||||||
|
servers: "Серверы", settings: "Настройки", traffic: "Трафик", uptime: "Доступность", users: "Пользователи", wireguard: "WireGuard",
|
||||||
|
}
|
||||||
const tabs = { overview: "Обзор", connections: "Подключения", permissions: "Разрешения", devices: "Интерфейсы", requests: "Обращения", plans: "Планы и операции", routing: "Route AI", settings: "Настройки" }
|
const tabs = { overview: "Обзор", connections: "Подключения", permissions: "Разрешения", devices: "Интерфейсы", requests: "Обращения", plans: "Планы и операции", routing: "Route AI", settings: "Настройки" }
|
||||||
type Tab = keyof typeof tabs
|
type Tab = keyof typeof tabs
|
||||||
type RecordRow = Record<string, unknown>
|
type RecordRow = Record<string, unknown>
|
||||||
@@ -162,7 +167,19 @@ function ConnectionForm({ api, operations, editing, close, created }: { api: Mcp
|
|||||||
const [limits, setLimits] = useState(editing?.policy.limits ?? { callsPerMinute: 60, concurrentReads: 4, mutationsPerHour: 10, serversPerPlan: 5, objectsPerPlan: 100 })
|
const [limits, setLimits] = useState(editing?.policy.limits ?? { callsPerMinute: 60, concurrentReads: 4, mutationsPerHour: 10, serversPerPlan: 5, objectsPerPlan: 100 })
|
||||||
const permissions = getClaims()?.permissions ?? []
|
const permissions = getClaims()?.permissions ?? []
|
||||||
const eligible = operations.filter(operation => operation.implementation === "available" && operation.requiredPermissions.every(permission => hasPermission(permissions, permission)))
|
const eligible = operations.filter(operation => operation.implementation === "available" && operation.requiredPermissions.every(permission => hasPermission(permissions, permission)))
|
||||||
const toggle = (id: string) => setSelected(ids => ids.includes(id) ? ids.filter(value => value !== id) : [...ids, id])
|
const selectedIds = new Set(selected)
|
||||||
|
const bySection = new Map<string, McpOperationDescriptor[]>()
|
||||||
|
for (const operation of eligible) {
|
||||||
|
const group = bySection.get(operation.section)
|
||||||
|
if (group) group.push(operation)
|
||||||
|
else bySection.set(operation.section, [operation])
|
||||||
|
}
|
||||||
|
const groups = [...bySection]
|
||||||
|
.sort(([left], [right]) => (operationSectionLabels[left] ?? left).localeCompare(operationSectionLabels[right] ?? right, "ru"))
|
||||||
|
const selectOperations = (operations: McpOperationDescriptor[], checked: boolean) => {
|
||||||
|
const groupIds = new Set(operations.map(operation => operation.id))
|
||||||
|
setSelected(ids => checked ? [...new Set([...ids, ...groupIds])] : ids.filter(id => !groupIds.has(id)))
|
||||||
|
}
|
||||||
const save = async () => {
|
const save = async () => {
|
||||||
setBusy(true); setError("")
|
setBusy(true); setError("")
|
||||||
try {
|
try {
|
||||||
@@ -173,7 +190,32 @@ function ConnectionForm({ api, operations, editing, close, created }: { api: Mcp
|
|||||||
}
|
}
|
||||||
return <Dialog open onOpenChange={open => { if (!open && !busy) close() }}><DialogContent className="max-h-[90dvh] overflow-y-auto sm:max-w-3xl"><DialogHeader><DialogTitle>{editing ? "Изменить разрешения" : "Новое подключение"}</DialogTitle><DialogDescription>Шаг {step} из 4 · доступ ограничивается правами текущего владельца.</DialogDescription></DialogHeader><ErrorMessage message={error} />
|
return <Dialog open onOpenChange={open => { if (!open && !busy) close() }}><DialogContent className="max-h-[90dvh] overflow-y-auto sm:max-w-3xl"><DialogHeader><DialogTitle>{editing ? "Изменить разрешения" : "Новое подключение"}</DialogTitle><DialogDescription>Шаг {step} из 4 · доступ ограничивается правами текущего владельца.</DialogDescription></DialogHeader><ErrorMessage message={error} />
|
||||||
{step === 1 && <><Field label="Название"><Input value={name} onChange={event => setName(event.target.value)} placeholder="Агент диагностики" /></Field><Field label="Срок действия (UTC)"><Input type="datetime-local" value={expires} onChange={event => setExpires(event.target.value)} /></Field><NativeSelect label="Режим управления" value={mode} onChange={value => setMode(value as typeof mode)}>{Object.entries(modeLabels).map(([value, title]) => <option key={value} value={value}>{title}</option>)}</NativeSelect></>}
|
{step === 1 && <><Field label="Название"><Input value={name} onChange={event => setName(event.target.value)} placeholder="Агент диагностики" /></Field><Field label="Срок действия (UTC)"><Input type="datetime-local" value={expires} onChange={event => setExpires(event.target.value)} /></Field><NativeSelect label="Режим управления" value={mode} onChange={value => setMode(value as typeof mode)}>{Object.entries(modeLabels).map(([value, title]) => <option key={value} value={value}>{title}</option>)}</NativeSelect></>}
|
||||||
{step === 2 && <><Field label="ID разрешённых серверов через запятую"><Input value={serverText} onChange={event => setServerText(event.target.value)} placeholder="1, 2" /></Field><Choice label="Разрешить выбранные глобальные операции" checked={global} onChange={setGlobal} /><div className="grid max-h-80 gap-2 overflow-y-auto sm:grid-cols-2">{eligible.map(operation => <Choice key={operation.id} label={operation.title} checked={selected.includes(operation.id)} onChange={() => toggle(operation.id)} />)}</div><p className="text-xs text-muted-foreground">Новые инструменты не добавляются в доступ автоматически. Для применения планов выберите также инструменты просмотра и применения.</p></>}
|
{step === 2 && <>
|
||||||
|
<Field label="ID разрешённых серверов через запятую"><Input value={serverText} onChange={event => setServerText(event.target.value)} placeholder="1, 2" /></Field>
|
||||||
|
<Choice label="Разрешить выбранные глобальные операции" checked={global} onChange={setGlobal} />
|
||||||
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
|
<Button variant="outline" size="sm" disabled={!eligible.length} onClick={() => setSelected(eligible.map(operation => operation.id))}>Выбрать все операции</Button>
|
||||||
|
<Button variant="ghost" size="sm" disabled={!selected.length} onClick={() => setSelected([])}>Снять все</Button>
|
||||||
|
<span className="text-sm text-muted-foreground" role="status">Выбрано {selected.length}</span>
|
||||||
|
</div>
|
||||||
|
<div className="max-h-80 space-y-2 overflow-y-auto">
|
||||||
|
{groups.map(([section, items]) => {
|
||||||
|
const title = operationSectionLabels[section] ?? section
|
||||||
|
const count = items.filter(operation => selectedIds.has(operation.id)).length
|
||||||
|
return <div key={section} className="grid grid-cols-[auto_minmax(0,1fr)] items-start gap-3 rounded-md border p-3">
|
||||||
|
<Checkbox aria-label={`Все операции группы «${title}»`} className="mt-0.5" checked={count === items.length} indeterminate={count > 0 && count < items.length} onCheckedChange={checked => selectOperations(items, checked)} />
|
||||||
|
<details>
|
||||||
|
<summary className="cursor-pointer text-sm font-medium">{title} <span className="ms-1 font-normal text-muted-foreground">{count} / {items.length}</span></summary>
|
||||||
|
<div className="mt-3 grid gap-3 sm:grid-cols-2">
|
||||||
|
{items.map(operation => <Choice key={operation.id} label={operation.title} checked={selectedIds.has(operation.id)} onChange={checked => selectOperations([operation], checked)} />)}
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
})}
|
||||||
|
{!eligible.length && <p className="text-sm text-muted-foreground">Нет доступных операций.</p>}
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-muted-foreground">Выбор операций учитывает права владельца. Режим, список серверов и глобальный доступ задаются отдельно. Новые инструменты нужно добавлять вручную. Для применения планов выберите также инструменты просмотра и применения.</p>
|
||||||
|
</>}
|
||||||
{step === 3 && <><div className="grid gap-3 sm:grid-cols-2">{Object.entries(limits).map(([key, value]) => <Field key={key} label={({ callsPerMinute: "Вызовов в минуту", concurrentReads: "Одновременных чтений", mutationsPerHour: "Изменений в час", serversPerPlan: "Серверов на план", objectsPerPlan: "Объектов на план" } as Record<string, string>)[key]}><Input type="number" min={1} value={value} onChange={event => setLimits(current => ({ ...current, [key]: Number(event.target.value) }))} /></Field>)}</div><NativeSelect label="Опасные действия" value={danger} onChange={value => setDanger(value as typeof danger)}><option value="approval">Всегда подтверждать</option><option value="explicit-allow">Автономно для явно выбранных действий</option></NativeSelect>{danger === "explicit-allow" && eligible.filter(operation => operation.risk === "dangerous" && selected.includes(operation.id)).map(operation => <Choice key={operation.id} label={operation.title} checked={dangerIds.includes(operation.id)} onChange={checked => setDangerIds(ids => checked ? [...ids, operation.id] : ids.filter(id => id !== operation.id))} />)}</>}
|
{step === 3 && <><div className="grid gap-3 sm:grid-cols-2">{Object.entries(limits).map(([key, value]) => <Field key={key} label={({ callsPerMinute: "Вызовов в минуту", concurrentReads: "Одновременных чтений", mutationsPerHour: "Изменений в час", serversPerPlan: "Серверов на план", objectsPerPlan: "Объектов на план" } as Record<string, string>)[key]}><Input type="number" min={1} value={value} onChange={event => setLimits(current => ({ ...current, [key]: Number(event.target.value) }))} /></Field>)}</div><NativeSelect label="Опасные действия" value={danger} onChange={value => setDanger(value as typeof danger)}><option value="approval">Всегда подтверждать</option><option value="explicit-allow">Автономно для явно выбранных действий</option></NativeSelect>{danger === "explicit-allow" && eligible.filter(operation => operation.risk === "dangerous" && selected.includes(operation.id)).map(operation => <Choice key={operation.id} label={operation.title} checked={dangerIds.includes(operation.id)} onChange={checked => setDangerIds(ids => checked ? [...ids, operation.id] : ids.filter(id => id !== operation.id))} />)}</>}
|
||||||
{step === 4 && <div className="space-y-3 text-sm"><p><strong>{name || "Без названия"}</strong> · {modeLabels[mode]}</p><p>Серверы: {serverText || "не выбраны"}. Операций: {selected.length}. Глобальный доступ: {global ? "да" : "нет"}.</p><p>Защита объектов продолжает действовать независимо от автономных разрешений.</p><p>После сохранения проверьте конкретное действие в симуляторе на вкладке «Разрешения».</p></div>}
|
{step === 4 && <div className="space-y-3 text-sm"><p><strong>{name || "Без названия"}</strong> · {modeLabels[mode]}</p><p>Серверы: {serverText || "не выбраны"}. Операций: {selected.length}. Глобальный доступ: {global ? "да" : "нет"}.</p><p>Защита объектов продолжает действовать независимо от автономных разрешений.</p><p>После сохранения проверьте конкретное действие в симуляторе на вкладке «Разрешения».</p></div>}
|
||||||
<div className="flex flex-wrap justify-between gap-2"><Button variant="outline" disabled={busy} onClick={() => step > 1 ? setStep(step - 1) : close()}>{step > 1 ? "Назад" : "Отмена"}</Button>{step < 4 ? <Button onClick={() => setStep(step + 1)}>Далее</Button> : <Button disabled={busy} onClick={() => { void save() }}>{busy ? "Сохранение…" : "Сохранить доступ"}</Button>}</div>
|
<div className="flex flex-wrap justify-between gap-2"><Button variant="outline" disabled={busy} onClick={() => step > 1 ? setStep(step - 1) : close()}>{step > 1 ? "Назад" : "Отмена"}</Button>{step < 4 ? <Button onClick={() => setStep(step + 1)}>Далее</Button> : <Button disabled={busy} onClick={() => { void save() }}>{busy ? "Сохранение…" : "Сохранить доступ"}</Button>}</div>
|
||||||
@@ -798,5 +840,5 @@ function McpWorkspaceContent({ backendUrl, live }: { backendUrl: string; live: b
|
|||||||
const [operations, setOperations] = useState<McpOperationDescriptor[]>([]), [error, setError] = useState("")
|
const [operations, setOperations] = useState<McpOperationDescriptor[]>([]), [error, setError] = useState("")
|
||||||
useEffect(() => { if (!live) return; const controller = new AbortController(); void api.catalog(controller.signal).then(catalog => setOperations(catalog.operations), failure => { if (!controller.signal.aborted) setError(errorText(failure)) }); return () => controller.abort() }, [api, live])
|
useEffect(() => { if (!live) return; const controller = new AbortController(); void api.catalog(controller.signal).then(catalog => setOperations(catalog.operations), failure => { if (!controller.signal.aborted) setError(errorText(failure)) }); return () => controller.abort() }, [api, live])
|
||||||
const changeTab = (value: unknown) => { const next = String(value); const url = new URL(window.location.href); url.searchParams.set("tab", next); window.history.replaceState(null, "", url.pathname + url.search) }
|
const changeTab = (value: unknown) => { const next = String(value); const url = new URL(window.location.href); url.searchParams.set("tab", next); window.history.replaceState(null, "", url.pathname + url.search) }
|
||||||
return <><PageHeader crumbs={[{ label: "MCP" }]} /><main className="flex min-w-0 flex-1 flex-col gap-5 p-4 md:p-6"><div className="flex items-center gap-3"><BotIcon className="size-7 text-muted-foreground" /><div><h1 className="text-xl font-semibold">MCP</h1><p className="text-sm text-muted-foreground">Доступ нейросетей, разрешения и контроль изменений</p></div></div>{!live ? <Panel title="Подключите backend"><p>Для выдачи реального AI-доступа выберите режим «Живые» и настройте авторизацию портала.</p></Panel> : <><ErrorMessage message={error} />{oauthRequestId && <Consent key={oauthRequestId} api={api} id={oauthRequestId} />}<Tabs value={tab} onValueChange={changeTab}><div className="overflow-x-auto pb-1"><TabsList variant="line">{Object.entries(tabs).filter(([key]) => key !== "settings" || can("mm:mcp:admin")).map(([key, title]) => <TabsTrigger key={key} value={key}>{title}</TabsTrigger>)}</TabsList></div><TabsContent value="overview"><Overview api={api} /></TabsContent><TabsContent value="connections"><div className="flex flex-col gap-4"><Connections api={api} operations={operations} />{can("mm:mcp:admin") && <AccessTools api={api} />}</div></TabsContent><TabsContent value="permissions"><Permissions api={api} operations={operations} /></TabsContent><TabsContent value="devices"><DeviceManagement api={api} /></TabsContent><TabsContent value="routing"><div className="flex flex-col gap-4"><RoutingProfiles api={api} /><RoutePathVerification api={api} /></div></TabsContent><TabsContent value="requests"><Records api={api} kind="requests" /></TabsContent><TabsContent value="plans"><div className="flex flex-col gap-4"><Records api={api} kind="plans" /><Records api={api} kind="operations" />{admin && <OperationRecovery key={recoveryId} api={api} operationId={recoveryId} />}<Records api={api} kind="drift" /></div></TabsContent>{can("mm:mcp:admin") && <TabsContent value="settings"><div className="flex flex-col gap-4"><Settings api={api} /><RestCoverage api={api} /><ManagementChannels api={api} />{can("mm:settings:admin") && <DatabaseRestore api={api} />}</div></TabsContent>}</Tabs></>}</main></>
|
return <><PageHeader crumbs={[{ label: "MCP" }]} /><div className="flex min-h-0 min-w-0 flex-1 flex-col gap-5 overflow-y-auto p-4 md:p-6"><div className="flex items-center gap-3"><BotIcon className="size-7 text-muted-foreground" /><div><h1 className="text-xl font-semibold">MCP</h1><p className="text-sm text-muted-foreground">Доступ нейросетей, разрешения и контроль изменений</p></div></div>{!live ? <Panel title="Подключите backend"><p>Для выдачи реального AI-доступа выберите режим «Живые» и настройте авторизацию портала.</p></Panel> : <><ErrorMessage message={error} />{oauthRequestId && <Consent key={oauthRequestId} api={api} id={oauthRequestId} />}<Tabs value={tab} onValueChange={changeTab}><div className="overflow-x-auto pb-1"><TabsList variant="line">{Object.entries(tabs).filter(([key]) => key !== "settings" || can("mm:mcp:admin")).map(([key, title]) => <TabsTrigger key={key} value={key}>{title}</TabsTrigger>)}</TabsList></div><TabsContent value="overview"><Overview api={api} /></TabsContent><TabsContent value="connections"><div className="flex flex-col gap-4"><Connections api={api} operations={operations} />{can("mm:mcp:admin") && <AccessTools api={api} />}</div></TabsContent><TabsContent value="permissions"><Permissions api={api} operations={operations} /></TabsContent><TabsContent value="devices"><DeviceManagement api={api} /></TabsContent><TabsContent value="routing"><div className="flex flex-col gap-4"><RoutingProfiles api={api} /><RoutePathVerification api={api} /></div></TabsContent><TabsContent value="requests"><Records api={api} kind="requests" /></TabsContent><TabsContent value="plans"><div className="flex flex-col gap-4"><Records api={api} kind="plans" /><Records api={api} kind="operations" />{admin && <OperationRecovery key={recoveryId} api={api} operationId={recoveryId} />}<Records api={api} kind="drift" /></div></TabsContent>{can("mm:mcp:admin") && <TabsContent value="settings"><div className="flex flex-col gap-4"><Settings api={api} /><RestCoverage api={api} /><ManagementChannels api={api} />{can("mm:settings:admin") && <DatabaseRestore api={api} />}</div></TabsContent>}</Tabs></>}</div></>
|
||||||
}
|
}
|
||||||
@@ -292,6 +292,9 @@ test('synthetic: OAuth approval becomes unavailable when the selected connection
|
|||||||
|
|
||||||
test('synthetic: issue only selected server/read permission and hide one-time token', async ({ page }) => {
|
test('synthetic: issue only selected server/read permission and hide one-time token', async ({ page }) => {
|
||||||
const state = await setup(page, ['mm:mcp:admin', 'mm:servers:read'])
|
const state = await setup(page, ['mm:mcp:admin', 'mm:servers:read'])
|
||||||
|
const logStatus = { ...read, id: 'logs.status', toolName: 'mm_logs_status', title: 'Статус журналов' }
|
||||||
|
const capabilities = { ...read, id: 'capabilities.read', toolName: 'mm_capabilities_get', title: 'Доступные возможности', section: 'mcp', requiredPermissions: [] }
|
||||||
|
await page.route('**/api/mcp/catalog', route => route.fulfill({ json: { stage: 'runtime', executionAvailable: true, operations: [read, logStatus, capabilities, forbidden] } }))
|
||||||
await page.goto('/mcp?tab=connections')
|
await page.goto('/mcp?tab=connections')
|
||||||
await page.getByRole('button', { name: 'Выдать доступ', exact: true }).click()
|
await page.getByRole('button', { name: 'Выдать доступ', exact: true }).click()
|
||||||
const dialog = page.getByRole('dialog')
|
const dialog = page.getByRole('dialog')
|
||||||
@@ -299,6 +302,20 @@ test('synthetic: issue only selected server/read permission and hide one-time to
|
|||||||
await dialog.getByRole('button', { name: 'Далее', exact: true }).click()
|
await dialog.getByRole('button', { name: 'Далее', exact: true }).click()
|
||||||
await expect(dialog.getByRole('checkbox', { name: forbidden.title, exact: true })).toHaveCount(0)
|
await expect(dialog.getByRole('checkbox', { name: forbidden.title, exact: true })).toHaveCount(0)
|
||||||
await dialog.getByLabel('ID разрешённых серверов через запятую').fill('1')
|
await dialog.getByLabel('ID разрешённых серверов через запятую').fill('1')
|
||||||
|
await dialog.getByRole('button', { name: 'Выбрать все операции' }).click()
|
||||||
|
await expect(dialog.getByRole('status')).toHaveText('Выбрано 3')
|
||||||
|
await dialog.getByRole('button', { name: 'Снять все' }).click()
|
||||||
|
await expect(dialog.getByRole('status')).toHaveText('Выбрано 0')
|
||||||
|
const logsGroup = dialog.getByRole('checkbox', { name: 'Все операции группы «Журналы»' })
|
||||||
|
await logsGroup.check()
|
||||||
|
await expect(dialog.getByRole('status')).toHaveText('Выбрано 2')
|
||||||
|
await dialog.locator('summary').filter({ hasText: 'Журналы' }).click()
|
||||||
|
await expect(dialog.getByRole('checkbox', { name: read.title, exact: true })).toBeChecked()
|
||||||
|
await dialog.getByRole('checkbox', { name: logStatus.title, exact: true }).uncheck()
|
||||||
|
await expect(logsGroup).toHaveAttribute('aria-checked', 'mixed')
|
||||||
|
await logsGroup.check()
|
||||||
|
await logsGroup.uncheck()
|
||||||
|
await expect(dialog.getByRole('status')).toHaveText('Выбрано 0')
|
||||||
await dialog.getByRole('checkbox', { name: read.title, exact: true }).check()
|
await dialog.getByRole('checkbox', { name: read.title, exact: true }).check()
|
||||||
await dialog.getByRole('button', { name: 'Далее', exact: true }).click()
|
await dialog.getByRole('button', { name: 'Далее', exact: true }).click()
|
||||||
await dialog.getByRole('button', { name: 'Далее', exact: true }).click()
|
await dialog.getByRole('button', { name: 'Далее', exact: true }).click()
|
||||||
|
|||||||
@@ -40,6 +40,20 @@ async function setup(page: Page, fail = false) {
|
|||||||
return calls
|
return calls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("MCP: настройки прокручиваются до восстановления базы", async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1100, height: 640 })
|
||||||
|
await setup(page)
|
||||||
|
await page.goto("/mcp?tab=settings")
|
||||||
|
|
||||||
|
const restoreHeading = page.getByRole("heading", { name: "Восстановление БД через MCP" })
|
||||||
|
await expect(restoreHeading).toBeAttached()
|
||||||
|
await expect(restoreHeading).not.toBeInViewport()
|
||||||
|
await page.mouse.move(700, 400)
|
||||||
|
await page.mouse.wheel(0, 3000)
|
||||||
|
await expect(restoreHeading).toBeInViewport()
|
||||||
|
await expect(page.getByRole("navigation", { name: "Путь страницы" })).toBeInViewport()
|
||||||
|
})
|
||||||
|
|
||||||
test("MCP приостанавливает опрос по сигналу скрытия документа и возобновляет при показе", async ({ page }) => {
|
test("MCP приостанавливает опрос по сигналу скрытия документа и возобновляет при показе", async ({ page }) => {
|
||||||
const calls = await setup(page)
|
const calls = await setup(page)
|
||||||
const overviewCalls = () => calls.filter(call => call === "GET /api/mcp/overview").length
|
const overviewCalls = () => calls.filter(call => call === "GET /api/mcp/overview").length
|
||||||
@@ -401,6 +415,7 @@ test("MCP: доступ, проверка подключения, выдача
|
|||||||
await page.getByLabel("Название", { exact: true }).fill("Новый AI клиент")
|
await page.getByLabel("Название", { exact: true }).fill("Новый AI клиент")
|
||||||
await page.getByRole("button", { name: "Далее", exact: true }).click()
|
await page.getByRole("button", { name: "Далее", exact: true }).click()
|
||||||
await page.getByLabel("ID разрешённых серверов через запятую").fill("1")
|
await page.getByLabel("ID разрешённых серверов через запятую").fill("1")
|
||||||
|
await page.locator("summary").filter({ hasText: "Журналы" }).click()
|
||||||
await page.getByRole("checkbox", { name: "Поиск логов", exact: true }).check()
|
await page.getByRole("checkbox", { name: "Поиск логов", exact: true }).check()
|
||||||
await page.getByRole("button", { name: "Далее", exact: true }).click()
|
await page.getByRole("button", { name: "Далее", exact: true }).click()
|
||||||
await page.getByRole("button", { name: "Далее", exact: true }).click()
|
await page.getByRole("button", { name: "Далее", exact: true }).click()
|
||||||
|
|||||||
Reference in new issue
Block a user