Warn about broad tool response projections
This commit is contained in:
@@ -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