akemon 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.js +14 -7
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -164,22 +164,29 @@ async function autoRoute(task, selfName, relayHttp) {
|
|
|
164
164
|
if (candidates.length === 0) {
|
|
165
165
|
return "[auto] No available agents to route to.";
|
|
166
166
|
}
|
|
167
|
-
//
|
|
167
|
+
// Value-based scoring: quality / price (cost-benefit analysis)
|
|
168
168
|
const taskWords = task.toLowerCase().split(/\s+/).filter((w) => w.length >= 2);
|
|
169
169
|
const scored = candidates.map((a) => {
|
|
170
|
-
let
|
|
170
|
+
let quality = 0;
|
|
171
171
|
const desc = (a.description || "").toLowerCase();
|
|
172
172
|
const tags = (a.tags || []).map((t) => t.toLowerCase());
|
|
173
|
+
// Relevance: keyword match
|
|
173
174
|
for (const word of taskWords) {
|
|
174
175
|
if (tags.some((t) => t.includes(word)))
|
|
175
|
-
|
|
176
|
+
quality += 100;
|
|
176
177
|
if (desc.includes(word))
|
|
177
|
-
|
|
178
|
+
quality += 50;
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
// Track record
|
|
181
|
+
quality += (a.success_rate || 0) * 100;
|
|
182
|
+
quality += (a.level || 1) * 10;
|
|
183
|
+
// Value = quality / cost (prefer cheaper agents when quality is similar)
|
|
184
|
+
const price = a.price || 1;
|
|
185
|
+
const value = quality / price;
|
|
186
|
+
return { name: a.name, engine: a.engine, price, quality, value };
|
|
187
|
+
}).sort((a, b) => b.value - a.value);
|
|
181
188
|
const target = scored[0];
|
|
182
|
-
console.log(`[auto] Routing to ${target.name} (
|
|
189
|
+
console.log(`[auto] Routing to ${target.name} (quality=${target.quality}, price=${target.price}, value=${target.value.toFixed(1)})`);
|
|
183
190
|
try {
|
|
184
191
|
const result = await callAgent(target.name, task);
|
|
185
192
|
return `[auto → ${target.name}]\n\n${result}`;
|