Warn about broad tool response projections
This commit is contained in:
@@ -194,6 +194,9 @@
|
||||
createOperation: function(workspaceId, payload) {
|
||||
return post('/workspaces/' + encodeURIComponent(workspaceId) + '/operations', payload);
|
||||
},
|
||||
analyzeOperationQuality: function(workspaceId, payload) {
|
||||
return post('/workspaces/' + encodeURIComponent(workspaceId) + '/operations/analyze-quality', payload);
|
||||
},
|
||||
updateOperation: function(workspaceId, operationId, payload) {
|
||||
return patch('/workspaces/' + encodeURIComponent(workspaceId) + '/operations/' + encodeURIComponent(operationId), payload);
|
||||
},
|
||||
|
||||
+29
-1
@@ -638,6 +638,7 @@ var TRANSLATIONS = {
|
||||
'wizard.busy.output_sample': 'Saving output example…',
|
||||
'wizard.busy.generate': 'Rebuilding settings…',
|
||||
'wizard.busy.test': 'Running test…',
|
||||
'wizard.busy.quality': 'Checking quality…',
|
||||
'wizard.busy.export_yaml': 'Exporting YAML…',
|
||||
'wizard.busy.import_yaml': 'Importing YAML…',
|
||||
'wizard.busy.publish': 'Publishing operation…',
|
||||
@@ -664,6 +665,19 @@ var TRANSLATIONS = {
|
||||
'wizard.test.response_copied_body': 'The latest test response was copied into the output example.',
|
||||
'wizard.agent_preview.copied': 'Schema copied',
|
||||
'wizard.agent_preview.copied_body': 'The MCP tool schema was copied to the clipboard.',
|
||||
'wizard.quality.title': 'Tool quality check',
|
||||
'wizard.quality.subtitle': 'Check the name, description, schemas and the result visible to the agent.',
|
||||
'wizard.quality.action': 'Check quality',
|
||||
'wizard.quality.empty': 'Quality check has not run yet.',
|
||||
'wizard.quality.no_findings': 'No issues found.',
|
||||
'wizard.quality.checked_title': 'Quality check completed',
|
||||
'wizard.quality.checked_body': 'Review the recommendations before publishing.',
|
||||
'wizard.quality.blocked_title': 'Quality check found blocking issues',
|
||||
'wizard.quality.blocked_body': 'Fix error-level findings before publishing.',
|
||||
'wizard.quality.blocking_error': 'Fix blocking quality findings before publishing.',
|
||||
'wizard.quality.severity_error': 'Error',
|
||||
'wizard.quality.severity_warning': 'Warning',
|
||||
'wizard.quality.severity_info': 'Info',
|
||||
'wizard.boolean.yes': 'yes',
|
||||
'wizard.boolean.no': 'no',
|
||||
'wizard.yaml.exported': 'YAML exported',
|
||||
@@ -1436,11 +1450,12 @@ var TRANSLATIONS = {
|
||||
'wizard.busy.output_sample': 'Сохранение выходного примера…',
|
||||
'wizard.busy.generate': 'Пересборка настроек…',
|
||||
'wizard.busy.test': 'Запуск теста…',
|
||||
'wizard.busy.quality': 'Проверка качества…',
|
||||
'wizard.busy.export_yaml': 'Экспорт YAML…',
|
||||
'wizard.busy.import_yaml': 'Импорт YAML…',
|
||||
'wizard.busy.publish': 'Публикация операции…',
|
||||
'wizard.busy.descriptor': 'Загрузка descriptor set…',
|
||||
'wizard.busy.wsdl': 'Inspection WSDL…',
|
||||
'wizard.busy.wsdl': 'Проверка WSDL…',
|
||||
'wizard.sample.input_saved': 'Входной пример сохранен',
|
||||
'wizard.sample.input_saved_body': 'Входной пример сохранен для этой операции.',
|
||||
'wizard.sample.output_saved': 'Выходной пример сохранен',
|
||||
@@ -1462,6 +1477,19 @@ var TRANSLATIONS = {
|
||||
'wizard.test.response_copied_body': 'Последний тестовый ответ скопирован в выходной пример.',
|
||||
'wizard.agent_preview.copied': 'Схема скопирована',
|
||||
'wizard.agent_preview.copied_body': 'Схема MCP инструмента скопирована в буфер обмена.',
|
||||
'wizard.quality.title': 'Проверка качества инструмента',
|
||||
'wizard.quality.subtitle': 'Проверьте имя, описание, схемы и результат, который увидит агент.',
|
||||
'wizard.quality.action': 'Проверить качество',
|
||||
'wizard.quality.empty': 'Проверка еще не запускалась.',
|
||||
'wizard.quality.no_findings': 'Замечаний нет.',
|
||||
'wizard.quality.checked_title': 'Проверка качества завершена',
|
||||
'wizard.quality.checked_body': 'Посмотрите рекомендации перед публикацией.',
|
||||
'wizard.quality.blocked_title': 'Проверка нашла блокирующие ошибки',
|
||||
'wizard.quality.blocked_body': 'Исправьте замечания уровня «Ошибка» перед публикацией.',
|
||||
'wizard.quality.blocking_error': 'Исправьте блокирующие замечания качества перед публикацией.',
|
||||
'wizard.quality.severity_error': 'Ошибка',
|
||||
'wizard.quality.severity_warning': 'Предупреждение',
|
||||
'wizard.quality.severity_info': 'Информация',
|
||||
'wizard.boolean.yes': 'да',
|
||||
'wizard.boolean.no': 'нет',
|
||||
'wizard.yaml.exported': 'YAML экспортирован',
|
||||
|
||||
@@ -98,6 +98,7 @@ function bindWizardLiveActions() {
|
||||
bindLiveAction('wizard-upload-output-sample', tKey('wizard.busy.output_sample'), uploadOutputSampleFromWizard);
|
||||
bindLiveAction('wizard-generate-draft', tKey('wizard.busy.generate'), generateDraftFromWizard);
|
||||
bindLiveAction('wizard-run-test', tKey('wizard.busy.test'), runWizardTest);
|
||||
bindLiveAction('wizard-run-quality', tKey('wizard.busy.quality'), analyzeWizardQuality);
|
||||
bindClick('wizard-copy-test-response', copyTestResponseToOutputSample);
|
||||
bindClick('wizard-copy-agent-preview', copyAgentFacingPreview);
|
||||
bindLiveAction('wizard-export-yaml', tKey('wizard.busy.export_yaml'), exportWizardYaml);
|
||||
@@ -398,6 +399,74 @@ function copyAgentFacingPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
function severityLabel(severity) {
|
||||
if (severity === 'error') return tKey('wizard.quality.severity_error');
|
||||
if (severity === 'warning') return tKey('wizard.quality.severity_warning');
|
||||
return tKey('wizard.quality.severity_info');
|
||||
}
|
||||
|
||||
function renderQualityFindings(report) {
|
||||
var empty = document.getElementById('wizard-quality-empty');
|
||||
var list = document.getElementById('wizard-quality-findings');
|
||||
if (!empty || !list) return;
|
||||
|
||||
list.replaceChildren();
|
||||
var findings = report && Array.isArray(report.findings) ? report.findings : [];
|
||||
if (!findings.length) {
|
||||
empty.textContent = tKey('wizard.quality.no_findings');
|
||||
empty.hidden = false;
|
||||
list.hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
empty.hidden = true;
|
||||
list.hidden = false;
|
||||
findings.forEach(function(finding) {
|
||||
var item = document.createElement('div');
|
||||
item.className = 'quality-finding ' + (finding.severity || 'info');
|
||||
item.dataset.code = finding.code || '';
|
||||
|
||||
var title = document.createElement('div');
|
||||
title.className = 'quality-finding-title';
|
||||
title.textContent = severityLabel(finding.severity) + ': ' + (finding.message || finding.code || '');
|
||||
item.appendChild(title);
|
||||
|
||||
if (finding.suggested_action) {
|
||||
var action = document.createElement('div');
|
||||
action.className = 'quality-finding-action';
|
||||
action.textContent = finding.suggested_action;
|
||||
item.appendChild(action);
|
||||
}
|
||||
|
||||
if (finding.field_path) {
|
||||
var path = document.createElement('div');
|
||||
path.className = 'quality-finding-path';
|
||||
path.textContent = finding.field_path;
|
||||
item.appendChild(path);
|
||||
}
|
||||
|
||||
list.appendChild(item);
|
||||
});
|
||||
}
|
||||
|
||||
async function analyzeWizardQuality() {
|
||||
if (!wizardWorkspaceId) {
|
||||
throw new Error(tKey('wizard.error.no_workspace'));
|
||||
}
|
||||
|
||||
var report = await window.CrankApi.analyzeOperationQuality(
|
||||
wizardWorkspaceId,
|
||||
collectWizardPayload()
|
||||
);
|
||||
renderQualityFindings(report);
|
||||
showWizardLiveStatus(
|
||||
report.blocking ? tKey('wizard.quality.blocked_title') : tKey('wizard.quality.checked_title'),
|
||||
report.blocking ? tKey('wizard.quality.blocked_body') : tKey('wizard.quality.checked_body'),
|
||||
!!report.blocking
|
||||
);
|
||||
return report;
|
||||
}
|
||||
|
||||
async function exportWizardYaml() {
|
||||
await persistCurrentDraft(true);
|
||||
var yaml = await window.CrankApi.exportOperation(wizardWorkspaceId, wizardEditId, {
|
||||
@@ -423,6 +492,10 @@ async function importWizardYaml() {
|
||||
}
|
||||
|
||||
async function publishWizardOperation() {
|
||||
var report = await analyzeWizardQuality();
|
||||
if (report.blocking) {
|
||||
throw new Error(tKey('wizard.quality.blocking_error'));
|
||||
}
|
||||
await persistCurrentDraft(true);
|
||||
var published = await window.CrankApi.publishOperation(
|
||||
wizardWorkspaceId,
|
||||
|
||||
Reference in New Issue
Block a user