Warn about confusing agent tool catalogs
Deploy / deploy (push) Successful in 1m34s
CI / Rust Checks (push) Successful in 5m3s
CI / UI Checks (push) Successful in 5s
CI / Deployment Manifests (push) Successful in 3s
CI / Frontend E2E (push) Successful in 4m44s

This commit is contained in:
github-ops
2026-06-20 21:09:45 +00:00
parent ce773e6196
commit 7099faad2b
6 changed files with 218 additions and 6 deletions
+51
View File
@@ -195,6 +195,35 @@ document.addEventListener('alpine:init', function() {
return this.tKey(this.isCommunityBuild ? 'agents.drawer.operations_sub_community' : 'agents.drawer.operations_sub');
},
get selectedOperations() {
var selected = this.form.selectedOps;
return this.operations.filter(function(operation) {
return selected.includes(operation.id);
});
},
get agentToolFindings() {
var findings = [];
var selected = this.selectedOperations;
if (selected.length > 8) {
findings.push(this.tKey('agents.drawer.finding.too_many_tools'));
}
for (var leftIndex = 0; leftIndex < selected.length; leftIndex += 1) {
for (var rightIndex = leftIndex + 1; rightIndex < selected.length; rightIndex += 1) {
if (this.operationsLookSimilar(selected[leftIndex], selected[rightIndex])) {
findings.push(this.tfKey('agents.drawer.finding.similar_tools', {
left: selected[leftIndex].display_name || selected[leftIndex].name,
right: selected[rightIndex].display_name || selected[rightIndex].name,
}));
return findings;
}
}
}
return findings;
},
get filteredOps() {
var query = this.opSearch.toLowerCase().trim();
if (!query) return this.operations;
@@ -267,6 +296,28 @@ document.addEventListener('alpine:init', function() {
return this.form.selectedOps.includes(operationId);
},
operationsLookSimilar(left, right) {
var leftTokens = this.operationTokens(left);
var rightTokens = this.operationTokens(right);
if (!leftTokens.length || !rightTokens.length) return false;
var shared = leftTokens.filter(function(token) { return rightTokens.includes(token); }).length;
var smaller = Math.min(leftTokens.length, rightTokens.length);
return shared >= 2 && (shared / smaller) >= 0.6;
},
operationTokens(operation) {
var text = [
operation.name || '',
operation.display_name || '',
].join(' ').toLowerCase();
var tokens = [];
text.split(/[^a-z0-9а-яё]+/i).forEach(function(token) {
if (token.length < 3 || tokens.includes(token)) return;
tokens.push(token);
});
return tokens;
},
async saveAgent() {
var self = this;
if (