ui: trim community premium frontend ballast

This commit is contained in:
github-ops
2026-05-14 16:19:58 +00:00
parent f50c8fb327
commit 23962f98e3
14 changed files with 90 additions and 2083 deletions
+3 -1
View File
@@ -12,6 +12,8 @@ test('agents page shows demo cards and edit drawer opens', async ({ page }) => {
await page.getByRole('button', { name: localized('New agent', 'Новый агент') }).click();
await expect(page.locator('.drawer-title')).toHaveText(localized('New agent', 'Новый агент'));
await expect(page.locator('.drawer-subtitle')).toContainText(localized('static agent-key boundary', 'статических ключах агента'));
await expect(page.locator('.form-hint')).toContainText(localized('Keep the slug stable', 'Сохраняйте slug стабильным'));
await expect(page.locator('[data-i18n="agents.drawer.slug_hint"]')).toContainText(
localized('Keep the slug stable', 'Сохраняйте slug стабильным')
);
await expect(page.locator('.drawer')).toContainText(/mcp/i);
});
+1 -1
View File
@@ -14,7 +14,7 @@ test('api keys page opens create key flow', async ({ page }) => {
await page.goto('/api-keys');
await expect(page.locator('.page-title')).toHaveText(localized('Agent Keys', 'Ключи агентов'));
await expect(page.locator('[data-testid="machine-access-summary"]')).toContainText(
localized('static AI-agent keys', 'статические ключи AI-агентов')
localized('static agent keys', 'статические ключи')
);
await expect(page.locator('#machine-access-note')).toContainText(
localized('commercial edition', 'коммерческую редакцию')
+3 -562
View File
@@ -1,16 +1,7 @@
const { expect } = require('@playwright/test');
const fs = require('fs');
const path = require('path');
const { execFileSync } = require('child_process');
const ADMIN_EMAIL = process.env.CRANK_E2E_ADMIN_EMAIL || 'owner@crank.local';
const ADMIN_PASSWORD = process.env.CRANK_E2E_ADMIN_PASSWORD || 'change-me-admin-password';
const MCP_PORT = Number(process.env.CRANK_E2E_MCP_PORT || 3302);
const STREAM_FIXTURE_PORT = Number(process.env.CRANK_E2E_STREAM_FIXTURE_PORT || 3310);
const GRPC_FIXTURE_BIND = process.env.CRANK_E2E_GRPC_FIXTURE_BIND || '127.0.0.1:3311';
const REPO_ROOT = path.resolve(__dirname, '../../../..');
let cachedEchoDescriptorSetB64 = null;
function localized(en, ru) {
return new RegExp(`(?:${en}|${ru})`, 'i');
@@ -74,577 +65,27 @@ async function getCurrentWorkspace(page) {
return membership ? membership.workspace : null;
}
async function createOperation(page, workspaceId, payload) {
return browserJson(page, 'POST', `/api/admin/workspaces/${encodeURIComponent(workspaceId)}/operations`, payload);
}
async function publishOperation(page, workspaceId, operationId, version = 1) {
return browserJson(
page,
'POST',
`/api/admin/workspaces/${encodeURIComponent(workspaceId)}/operations/${encodeURIComponent(operationId)}/publish`,
{ version },
);
}
async function createPlatformApiKey(page, workspaceId, agentId, name, scopes) {
return browserJson(
page,
'POST',
`/api/admin/workspaces/${encodeURIComponent(workspaceId)}/agents/${encodeURIComponent(agentId)}/platform-api-keys`,
{ name, scopes },
);
}
async function createAgent(page, workspaceId, payload) {
return browserJson(page, 'POST', `/api/admin/workspaces/${encodeURIComponent(workspaceId)}/agents`, payload);
}
async function saveAgentBindings(page, workspaceId, agentId, bindings) {
return browserJson(
page,
'POST',
`/api/admin/workspaces/${encodeURIComponent(workspaceId)}/agents/${encodeURIComponent(agentId)}/bindings`,
bindings,
`/api/admin/workspaces/${encodeURIComponent(workspaceId)}/agents`,
payload,
);
}
async function publishAgent(page, workspaceId, agentId, version = 1) {
return browserJson(
page,
'POST',
`/api/admin/workspaces/${encodeURIComponent(workspaceId)}/agents/${encodeURIComponent(agentId)}/publish`,
{ version },
);
}
function schemaObject(fields) {
return {
type: 'object',
required: true,
fields: fields || {},
};
}
function schemaString(required = true) {
return {
type: 'string',
required,
};
}
function uniqueName(prefix) {
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
}
function findEchoDescriptorSetB64() {
if (cachedEchoDescriptorSetB64) {
return cachedEchoDescriptorSetB64;
}
const escapedRoot = REPO_ROOT.replace(/'/g, "'\\''");
const descriptorPath = execFileSync(
'bash',
['-lc', `find '${escapedRoot}/target/debug/build' -path '*/out/echo_descriptor.bin' -print -quit`],
{ encoding: 'utf8' },
).trim();
if (!descriptorPath) {
throw new Error('echo_descriptor.bin was not found under target/debug/build');
}
cachedEchoDescriptorSetB64 = fs.readFileSync(descriptorPath).toString('base64');
return cachedEchoDescriptorSetB64;
}
function buildRestWindowOperationPayload(name) {
return {
name,
display_name: 'Playwright Window Logs',
category: 'streaming',
protocol: 'rest',
target: {
kind: 'rest',
base_url: `http://127.0.0.1:${STREAM_FIXTURE_PORT}`,
method: 'GET',
path_template: '/sse/logs',
static_headers: {},
},
input_schema: schemaObject({
window: schemaString(false),
}),
output_schema: schemaObject({}),
input_mapping: {
rules: [
{
source: '$.mcp.window',
target: '$.request.query.window',
required: false,
default_value: 'recent',
},
],
},
output_mapping: { rules: [] },
execution_config: {
timeout_ms: 1000,
headers: {},
streaming: {
mode: 'window',
transport_behavior: 'server_stream',
window_duration_ms: 1000,
upstream_timeout_ms: 1000,
max_items: 3,
max_bytes: 16384,
aggregation_mode: 'summary_plus_samples',
items_path: '$.items',
done_path: '$.done',
redacted_paths: [],
truncate_item_fields: false,
drop_duplicates: false,
tool_family: {},
},
},
tool_description: {
title: 'Playwright Window Logs',
description: 'Collects a bounded SSE log window from the local fixture.',
tags: ['playwright', 'streaming', 'window'],
examples: [{ input: {} }],
},
};
}
function buildWebsocketWindowOperationPayload(name, overrides = {}) {
const streaming = Object.assign({
mode: 'window',
transport_behavior: 'server_stream',
window_duration_ms: 1000,
upstream_timeout_ms: 1000,
max_items: 3,
max_bytes: 16384,
aggregation_mode: 'summary_plus_samples',
items_path: '$.items',
done_path: '$.done',
redacted_paths: [],
truncate_item_fields: false,
drop_duplicates: false,
tool_family: {},
}, overrides.streaming || {});
const websocketOptions = Object.assign({
heartbeat_interval_ms: 250,
reconnect_max_attempts: 1,
reconnect_backoff_ms: 10,
}, overrides.websocketOptions || {});
return {
name,
display_name: 'Playwright WebSocket Window',
category: 'streaming',
protocol: 'websocket',
target: {
kind: 'websocket',
url: `ws://127.0.0.1:${STREAM_FIXTURE_PORT}/events`,
subprotocols: [],
subscribe_message_template: null,
unsubscribe_message_template: null,
static_headers: {},
},
input_schema: schemaObject({
topic: schemaString(false),
}),
output_schema: schemaObject({}),
input_mapping: {
rules: [
{
source: '$.mcp.topic',
target: '$.request.body.topic',
required: false,
default_value: 'telemetry',
},
],
},
output_mapping: { rules: [] },
execution_config: {
timeout_ms: 1000,
headers: {},
protocol_options: {
websocket: websocketOptions,
},
streaming,
},
tool_description: {
title: 'Playwright WebSocket Window',
description: 'Collects a bounded WebSocket event window from the local fixture.',
tags: ['playwright', 'streaming', 'websocket', 'window'],
examples: [{ input: {} }],
},
};
}
const SOAP_TEST_WSDL = `<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="urn:crm"
targetNamespace="urn:crm">
<binding name="LeadBinding" type="tns:LeadPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="CreateLead">
<soap:operation soapAction="urn:createLead"/>
</operation>
</binding>
<service name="LeadService">
<port name="LeadPort" binding="tns:LeadBinding">
<soap:address location="http://127.0.0.1:${STREAM_FIXTURE_PORT}/soap/leads"/>
</port>
</service>
</definitions>`;
function buildSoapOperationPayload(name) {
return {
name,
display_name: 'Playwright SOAP Lead',
category: 'sales',
protocol: 'soap',
target: {
kind: 'soap',
wsdl_ref: 'sample_wsdl_pending',
service_name: 'Service',
port_name: 'Port',
operation_name: 'Operation',
endpoint_override: `http://127.0.0.1:${STREAM_FIXTURE_PORT}/soap/leads`,
soap_version: 'soap_11',
soap_action: 'urn:createLead',
binding_style: 'document_literal',
headers: [],
metadata: {
input_part_names: ['CreateLeadRequest'],
output_part_names: ['CreateLeadResponse'],
namespaces: ['urn:crm'],
},
},
input_schema: schemaObject({
email: schemaString(true),
}),
output_schema: schemaObject({
id: schemaString(true),
}),
input_mapping: {
rules: [
{
source: '$.mcp.email',
target: '$.request.body.email',
required: true,
},
],
},
output_mapping: {
rules: [
{
source: '$.response.body.id',
target: '$.output.id',
required: true,
},
],
},
execution_config: {
timeout_ms: 1000,
headers: {},
},
tool_description: {
title: 'Playwright SOAP Lead',
description: 'Creates a lead through the local SOAP fixture.',
tags: ['playwright', 'soap'],
examples: [{ input: { email: 'user@example.com' } }],
},
};
}
function buildGrpcSessionOperationPayload(name) {
return {
name,
display_name: 'Playwright gRPC Session',
category: 'streaming',
protocol: 'grpc',
target: {
kind: 'grpc',
server_addr: `http://${GRPC_FIXTURE_BIND}`,
package: 'echo',
service: 'EchoService',
method: 'ServerEcho',
descriptor_ref: 'desc_echo_playwright',
descriptor_set_b64: findEchoDescriptorSetB64(),
},
input_schema: schemaObject({
message: schemaString(true),
}),
output_schema: schemaObject({}),
input_mapping: {
rules: [
{
source: '$.mcp.message',
target: '$.request.grpc.message',
required: true,
},
],
},
output_mapping: { rules: [] },
execution_config: {
timeout_ms: 1000,
headers: {},
streaming: {
mode: 'session',
transport_behavior: 'server_stream',
window_duration_ms: 1000,
poll_interval_ms: 250,
upstream_timeout_ms: 1000,
idle_timeout_ms: 5000,
max_session_lifetime_ms: 60000,
max_items: 1,
max_bytes: 16384,
aggregation_mode: 'summary_plus_samples',
items_path: '$.items',
done_path: '$.done',
redacted_paths: [],
truncate_item_fields: false,
drop_duplicates: false,
tool_family: {
start_tool_name: `${name}_start`,
poll_tool_name: `${name}_poll`,
stop_tool_name: `${name}_stop`,
},
},
},
tool_description: {
title: 'Playwright gRPC Session',
description: 'Streams gRPC echo messages through a bounded MCP session tool family.',
tags: ['playwright', 'streaming', 'session', 'grpc'],
examples: [{ input: { message: 'hello' } }],
},
};
}
function buildRestAsyncJobOperationPayload(name) {
return {
name,
display_name: 'Playwright Async Lead',
category: 'streaming',
protocol: 'rest',
target: {
kind: 'rest',
base_url: `http://127.0.0.1:${STREAM_FIXTURE_PORT}`,
method: 'POST',
path_template: '/crm/leads',
static_headers: {},
},
input_schema: schemaObject({
email: schemaString(true),
}),
output_schema: schemaObject({
id: schemaString(true),
}),
input_mapping: {
rules: [
{
source: '$.mcp.email',
target: '$.request.body.email',
required: true,
},
],
},
output_mapping: {
rules: [
{
source: '$.response.body.id',
target: '$.output.id',
required: true,
},
],
},
execution_config: {
timeout_ms: 2000,
headers: {},
streaming: {
mode: 'async_job',
transport_behavior: 'deferred_result',
poll_interval_ms: 250,
upstream_timeout_ms: 2000,
max_session_lifetime_ms: 300000,
max_bytes: 16384,
aggregation_mode: 'summary_only',
redacted_paths: [],
truncate_item_fields: false,
drop_duplicates: false,
tool_family: {
start_tool_name: `${name}_start`,
status_tool_name: `${name}_status`,
result_tool_name: `${name}_result`,
cancel_tool_name: `${name}_cancel`,
},
},
},
tool_description: {
title: 'Playwright Async Lead',
description: 'Creates a lead through the async job MCP tool family.',
tags: ['playwright', 'streaming', 'async_job'],
examples: [{ input: { email: 'user@example.com' } }],
},
};
}
async function setupPublishedAgent(page, { operationPayload, agentSlug, toolName, toolTitle, toolDescription }) {
const workspace = await getCurrentWorkspace(page);
if (!workspace) {
throw new Error('current workspace was not resolved');
}
const createdOperation = await createOperation(page, workspace.id, operationPayload);
await publishOperation(page, workspace.id, createdOperation.operation_id, createdOperation.version);
const createdAgent = await createAgent(page, workspace.id, {
slug: agentSlug,
display_name: toolTitle,
description: toolDescription,
instructions: {},
tool_selection_policy: {},
});
await saveAgentBindings(page, workspace.id, createdAgent.agent_id, [
{
operation_id: createdOperation.operation_id,
operation_version: createdOperation.version,
tool_name: toolName,
tool_title: toolTitle,
tool_description_override: toolDescription,
enabled: true,
},
]);
await publishAgent(page, workspace.id, createdAgent.agent_id, createdAgent.version);
const key = await createPlatformApiKey(
page,
workspace.id,
createdAgent.agent_id,
uniqueName('playwright_key'),
['read', 'write']
);
return {
workspace,
operationId: createdOperation.operation_id,
agentId: createdAgent.agent_id,
apiKeySecret: key.secret,
};
}
function mcpUrl(workspaceSlug, agentSlug) {
return `http://127.0.0.1:${MCP_PORT}/v1/${workspaceSlug}/${agentSlug}`;
}
async function initializeMcpSession({ workspaceSlug, agentSlug, apiKey }) {
const response = await fetch(mcpUrl(workspaceSlug, agentSlug), {
method: 'POST',
headers: {
Accept: 'application/json, text/event-stream',
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2025-11-25',
},
}),
});
if (!response.ok) {
throw new Error(`initialize failed: ${response.status} ${await response.text()}`);
}
const sessionId = response.headers.get('MCP-Session-Id');
if (!sessionId) {
throw new Error('initialize response did not include MCP-Session-Id');
}
const initialized = await fetch(mcpUrl(workspaceSlug, agentSlug), {
method: 'POST',
headers: {
Accept: 'application/json, text/event-stream',
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
'MCP-Session-Id': sessionId,
'MCP-Protocol-Version': '2025-11-25',
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'notifications/initialized',
params: {},
}),
});
if (initialized.status !== 202) {
throw new Error(`initialized notification failed: ${initialized.status} ${await initialized.text()}`);
}
return {
sessionId,
workspaceSlug,
agentSlug,
apiKey,
};
}
async function mcpToolCall(session, toolName, argumentsValue) {
const response = await fetch(mcpUrl(session.workspaceSlug, session.agentSlug), {
method: 'POST',
headers: {
Accept: 'application/json, text/event-stream',
Authorization: `Bearer ${session.apiKey}`,
'Content-Type': 'application/json',
'MCP-Session-Id': session.sessionId,
'MCP-Protocol-Version': '2025-11-25',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: Date.now(),
method: 'tools/call',
params: {
name: toolName,
arguments: argumentsValue || {},
},
}),
});
const payload = await response.json();
if (!response.ok || payload.error) {
throw new Error(`tools/call failed for ${toolName}: ${JSON.stringify(payload)}`);
}
return payload.result.structuredContent;
}
module.exports = {
ADMIN_EMAIL,
ADMIN_PASSWORD,
SOAP_TEST_WSDL,
browserJson,
buildGrpcSessionOperationPayload,
buildRestAsyncJobOperationPayload,
buildRestWindowOperationPayload,
buildSoapOperationPayload,
buildWebsocketWindowOperationPayload,
createAgent,
createOperation,
createPlatformApiKey,
getCurrentWorkspace,
getSession,
initializeMcpSession,
login,
localized,
mcpToolCall,
publishAgent,
publishOperation,
saveAgentBindings,
setupPublishedAgent,
login,
uniqueName,
};
+1 -1
View File
@@ -12,5 +12,5 @@ test('logs and usage pages show seeded data', async ({ page }) => {
await page.goto('/usage');
await expect(page.locator('.page-title')).toHaveText(localized('Usage', 'Использование'));
await expect(page.locator('#chart-bars .chart-col')).toHaveCount(7);
await expect(page.locator('#usage-tbody tr')).toHaveCount(3);
await expect(page.locator('#usage-tbody tr')).toHaveCount(1);
});
+4 -2
View File
@@ -19,7 +19,9 @@ test('community wizard hides premium protocols and explains edition scope', asyn
await expect(page.locator('[data-testid="wizard-protocol-grpc"]')).toBeHidden();
await expect(page.locator('[data-testid="wizard-protocol-websocket"]')).toBeHidden();
await expect(page.locator('[data-testid="wizard-protocol-soap"]')).toBeHidden();
await expect(page.locator('#wizard-edition-protocol-note')).toContainText(localized('Commercial editions unlock', 'коммерческих редакциях'));
await expect(page.locator('#wizard-edition-protocol-note')).toContainText(
localized('Commercial editions unlock', 'коммерческих редакциях')
);
await page.locator('[data-testid="wizard-protocol-rest"]').click();
await page.locator('#btn-continue').click();
@@ -28,5 +30,5 @@ test('community wizard hides premium protocols and explains edition scope', asyn
await page.locator('#btn-continue').click();
await expect(page.locator('#wizard-streaming-config-card')).toBeHidden();
await expect(page.locator('#wizard-streaming-capability-note')).toContainText(localized('commercial edition', 'коммерческую редакцию'));
await expect(page.locator('#wizard-streaming-capability-note')).toHaveCount(0);
});