nodebench-mcp 2.30.0 → 2.31.1
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/README.md +7 -0
- package/dist/db.js +69 -0
- package/dist/db.js.map +1 -1
- package/dist/engine/contextBridge.d.ts +67 -0
- package/dist/engine/contextBridge.js +392 -0
- package/dist/engine/contextBridge.js.map +1 -0
- package/dist/engine/server.js +77 -0
- package/dist/engine/server.js.map +1 -1
- package/dist/engine/session.d.ts +2 -0
- package/dist/engine/session.js.map +1 -1
- package/dist/index.js +83 -6
- package/dist/index.js.map +1 -1
- package/dist/sandboxApi.d.ts +20 -0
- package/dist/sandboxApi.js +99 -0
- package/dist/sandboxApi.js.map +1 -0
- package/dist/tools/contextSandboxTools.d.ts +15 -0
- package/dist/tools/contextSandboxTools.js +469 -0
- package/dist/tools/contextSandboxTools.js.map +1 -0
- package/dist/tools/contextTools.d.ts +11 -0
- package/dist/tools/contextTools.js +175 -0
- package/dist/tools/contextTools.js.map +1 -0
- package/dist/tools/progressiveDiscoveryTools.js +3 -3
- package/dist/tools/progressiveDiscoveryTools.js.map +1 -1
- package/dist/tools/researchOptimizerTools.d.ts +17 -0
- package/dist/tools/researchOptimizerTools.js +454 -0
- package/dist/tools/researchOptimizerTools.js.map +1 -0
- package/dist/tools/scraplingTools.d.ts +15 -0
- package/dist/tools/scraplingTools.js +278 -0
- package/dist/tools/scraplingTools.js.map +1 -0
- package/dist/tools/thompsonProtocolTools.d.ts +73 -0
- package/dist/tools/thompsonProtocolTools.js +916 -0
- package/dist/tools/thompsonProtocolTools.js.map +1 -0
- package/dist/tools/toolRegistry.js +435 -0
- package/dist/tools/toolRegistry.js.map +1 -1
- package/dist/toolsetRegistry.js +10 -0
- package/dist/toolsetRegistry.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Research Optimizer Tools
|
|
3
|
+
*
|
|
4
|
+
* Deterministic multi-criteria decision analysis (MCDM) tools for
|
|
5
|
+
* research-heavy optimization workflows. Designed for travel, purchasing,
|
|
6
|
+
* investment, and any scenario where an agent needs to:
|
|
7
|
+
*
|
|
8
|
+
* 1. Merge parallel sub-agent research results into a unified dataset
|
|
9
|
+
* 2. Score options against weighted criteria (deterministic, not LLM)
|
|
10
|
+
* 3. Generate side-by-side comparison tables with normalized values
|
|
11
|
+
*
|
|
12
|
+
* These tools bridge the gap between raw web research (web_search, fetch_url,
|
|
13
|
+
* extract_structured_data) and actionable recommendations. They are the
|
|
14
|
+
* "optimization layer" that sits on top of parallel research agents.
|
|
15
|
+
*/
|
|
16
|
+
import { getDb, genId } from "../db.js";
|
|
17
|
+
// ── Helpers ─────────────────────────────────────────────────────────────
|
|
18
|
+
function normalizeMinMax(values, direction) {
|
|
19
|
+
const min = Math.min(...values);
|
|
20
|
+
const max = Math.max(...values);
|
|
21
|
+
if (max === min)
|
|
22
|
+
return values.map(() => 1); // all equal → perfect score
|
|
23
|
+
return values.map((v) => direction === "maximize"
|
|
24
|
+
? (v - min) / (max - min)
|
|
25
|
+
: (max - v) / (max - min));
|
|
26
|
+
}
|
|
27
|
+
function classifyCpp(cpp) {
|
|
28
|
+
if (cpp < 1.25)
|
|
29
|
+
return "poor";
|
|
30
|
+
if (cpp < 1.8)
|
|
31
|
+
return "acceptable";
|
|
32
|
+
if (cpp < 2.5)
|
|
33
|
+
return "good";
|
|
34
|
+
return "excellent";
|
|
35
|
+
}
|
|
36
|
+
// ── DB Schema ───────────────────────────────────────────────────────────
|
|
37
|
+
function ensureTables() {
|
|
38
|
+
const db = getDb();
|
|
39
|
+
db.exec(`
|
|
40
|
+
CREATE TABLE IF NOT EXISTS research_merges (
|
|
41
|
+
id TEXT PRIMARY KEY,
|
|
42
|
+
sources TEXT NOT NULL,
|
|
43
|
+
fields TEXT NOT NULL,
|
|
44
|
+
record_count INTEGER NOT NULL,
|
|
45
|
+
conflict_count INTEGER NOT NULL,
|
|
46
|
+
data TEXT NOT NULL,
|
|
47
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
48
|
+
);
|
|
49
|
+
CREATE TABLE IF NOT EXISTS research_scores (
|
|
50
|
+
id TEXT PRIMARY KEY,
|
|
51
|
+
merge_id TEXT,
|
|
52
|
+
criteria TEXT NOT NULL,
|
|
53
|
+
options TEXT NOT NULL,
|
|
54
|
+
ranked_results TEXT NOT NULL,
|
|
55
|
+
strategy_label TEXT,
|
|
56
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
57
|
+
);
|
|
58
|
+
`);
|
|
59
|
+
}
|
|
60
|
+
// ── Tool 1: merge_research_results ──────────────────────────────────────
|
|
61
|
+
const mergeResearchResults = {
|
|
62
|
+
name: "merge_research_results",
|
|
63
|
+
description: "Merge parallel sub-agent research results into a unified dataset. Takes arrays of records from multiple sources (e.g., Hotel Discovery Agent, Price Agent, Crowd Agent), aligns them by a join key, detects conflicts, and persists the merged dataset. Designed for coordinator agents aggregating parallel research.",
|
|
64
|
+
inputSchema: {
|
|
65
|
+
type: "object",
|
|
66
|
+
properties: {
|
|
67
|
+
sources: {
|
|
68
|
+
type: "array",
|
|
69
|
+
items: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: {
|
|
72
|
+
agent_name: { type: "string", description: "Name of the source agent (e.g., 'HotelDiscoveryAgent')" },
|
|
73
|
+
records: {
|
|
74
|
+
type: "array",
|
|
75
|
+
items: { type: "object" },
|
|
76
|
+
description: "Array of record objects from this agent",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
required: ["agent_name", "records"],
|
|
80
|
+
},
|
|
81
|
+
description: "Array of { agent_name, records[] } from each parallel sub-agent",
|
|
82
|
+
},
|
|
83
|
+
join_key: {
|
|
84
|
+
type: "string",
|
|
85
|
+
description: "Field name to join records across sources (e.g., 'hotel_name')",
|
|
86
|
+
},
|
|
87
|
+
conflict_resolution: {
|
|
88
|
+
type: "string",
|
|
89
|
+
enum: ["first_wins", "last_wins", "prefer_numeric", "keep_all"],
|
|
90
|
+
description: "How to resolve conflicting values for the same field. Default: prefer_numeric",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
required: ["sources", "join_key"],
|
|
94
|
+
},
|
|
95
|
+
handler: async (args) => {
|
|
96
|
+
ensureTables();
|
|
97
|
+
const db = getDb();
|
|
98
|
+
const resolution = args.conflict_resolution ?? "prefer_numeric";
|
|
99
|
+
// Build a map of join_key → merged record
|
|
100
|
+
const merged = new Map();
|
|
101
|
+
const conflicts = [];
|
|
102
|
+
const allFields = new Set();
|
|
103
|
+
for (const source of args.sources) {
|
|
104
|
+
for (const record of source.records) {
|
|
105
|
+
const key = String(record[args.join_key] ?? "").toLowerCase().trim();
|
|
106
|
+
if (!key)
|
|
107
|
+
continue;
|
|
108
|
+
const existing = merged.get(key) ?? { [args.join_key]: record[args.join_key], _sources: [] };
|
|
109
|
+
existing._sources.push(source.agent_name);
|
|
110
|
+
for (const [field, value] of Object.entries(record)) {
|
|
111
|
+
if (field === args.join_key)
|
|
112
|
+
continue;
|
|
113
|
+
allFields.add(field);
|
|
114
|
+
if (field in existing && existing[field] !== value) {
|
|
115
|
+
// Conflict detected
|
|
116
|
+
const oldVal = existing[field];
|
|
117
|
+
let resolved;
|
|
118
|
+
switch (resolution) {
|
|
119
|
+
case "first_wins":
|
|
120
|
+
resolved = oldVal;
|
|
121
|
+
break;
|
|
122
|
+
case "last_wins":
|
|
123
|
+
resolved = value;
|
|
124
|
+
break;
|
|
125
|
+
case "prefer_numeric":
|
|
126
|
+
resolved = typeof value === "number" ? value : (typeof oldVal === "number" ? oldVal : value);
|
|
127
|
+
break;
|
|
128
|
+
case "keep_all":
|
|
129
|
+
resolved = Array.isArray(oldVal) ? [...oldVal, value] : [oldVal, value];
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
resolved = value;
|
|
133
|
+
}
|
|
134
|
+
conflicts.push({ field: `${key}.${field}`, values: [oldVal, value], resolution: `${resolution} → ${JSON.stringify(resolved)}` });
|
|
135
|
+
existing[field] = resolved;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
existing[field] = value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
merged.set(key, existing);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const records = Array.from(merged.values());
|
|
145
|
+
const mergeId = genId("merge");
|
|
146
|
+
const result = {
|
|
147
|
+
mergeId,
|
|
148
|
+
sources: args.sources.map((s) => s.agent_name),
|
|
149
|
+
fields: [args.join_key, ...allFields],
|
|
150
|
+
records,
|
|
151
|
+
conflicts,
|
|
152
|
+
timestamp: new Date().toISOString(),
|
|
153
|
+
};
|
|
154
|
+
// Persist
|
|
155
|
+
db.prepare(`INSERT INTO research_merges (id, sources, fields, record_count, conflict_count, data) VALUES (?, ?, ?, ?, ?, ?)`).run(mergeId, JSON.stringify(result.sources), JSON.stringify(result.fields), records.length, conflicts.length, JSON.stringify(result));
|
|
156
|
+
return {
|
|
157
|
+
content: [
|
|
158
|
+
{
|
|
159
|
+
type: "text",
|
|
160
|
+
text: JSON.stringify({
|
|
161
|
+
mergeId,
|
|
162
|
+
recordCount: records.length,
|
|
163
|
+
fields: result.fields,
|
|
164
|
+
conflictCount: conflicts.length,
|
|
165
|
+
conflicts: conflicts.slice(0, 10),
|
|
166
|
+
sample: records.slice(0, 3),
|
|
167
|
+
_hint: "Use multi_criteria_score with this mergeId to rank options, or compare_options for a side-by-side table.",
|
|
168
|
+
}, null, 2),
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
// ── Tool 2: multi_criteria_score ────────────────────────────────────────
|
|
175
|
+
const multiCriteriaScore = {
|
|
176
|
+
name: "multi_criteria_score",
|
|
177
|
+
description: "Deterministic weighted multi-criteria decision analysis (MCDM). Takes options with numeric values per criterion, normalizes using min-max scaling, applies directional weights, and returns ranked results. No LLM involved — purely mathematical. Use for travel booking optimization, investment comparison, vendor selection, or any multi-attribute decision. Supports custom classification thresholds (e.g., points-per-cent valuation tiers).",
|
|
178
|
+
inputSchema: {
|
|
179
|
+
type: "object",
|
|
180
|
+
properties: {
|
|
181
|
+
criteria: {
|
|
182
|
+
type: "array",
|
|
183
|
+
items: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: {
|
|
186
|
+
name: { type: "string", description: "Criterion name (e.g., 'cpp_value', 'distance_score')" },
|
|
187
|
+
weight: { type: "number", description: "Weight 0-1. All weights should sum to 1." },
|
|
188
|
+
direction: { type: "string", enum: ["maximize", "minimize"], description: "Whether higher is better (maximize) or lower is better (minimize)" },
|
|
189
|
+
},
|
|
190
|
+
required: ["name", "weight", "direction"],
|
|
191
|
+
},
|
|
192
|
+
description: "Array of criteria with weights and optimization direction",
|
|
193
|
+
},
|
|
194
|
+
options: {
|
|
195
|
+
type: "array",
|
|
196
|
+
items: {
|
|
197
|
+
type: "object",
|
|
198
|
+
properties: {
|
|
199
|
+
name: { type: "string", description: "Option name (e.g., 'Hyatt House Anaheim')" },
|
|
200
|
+
values: { type: "object", description: "Map of criterion_name → numeric value" },
|
|
201
|
+
metadata: { type: "object", description: "Optional extra data to carry through (e.g., booking_method, chain)" },
|
|
202
|
+
},
|
|
203
|
+
required: ["name", "values"],
|
|
204
|
+
},
|
|
205
|
+
description: "Array of options to score",
|
|
206
|
+
},
|
|
207
|
+
merge_id: {
|
|
208
|
+
type: "string",
|
|
209
|
+
description: "Optional merge_id from merge_research_results to auto-load options",
|
|
210
|
+
},
|
|
211
|
+
strategy_label: {
|
|
212
|
+
type: "string",
|
|
213
|
+
description: "Optional label for this scoring run (e.g., 'Disneyland Hotel Optimization Q1 2026')",
|
|
214
|
+
},
|
|
215
|
+
classify_field: {
|
|
216
|
+
type: "string",
|
|
217
|
+
description: "Optional field to classify using built-in thresholds (e.g., 'cpp_value' for cents-per-point tiers)",
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
required: ["criteria", "options"],
|
|
221
|
+
},
|
|
222
|
+
handler: async (args) => {
|
|
223
|
+
ensureTables();
|
|
224
|
+
const db = getDb();
|
|
225
|
+
// Validate weights sum to ~1
|
|
226
|
+
const weightSum = args.criteria.reduce((s, c) => s + c.weight, 0);
|
|
227
|
+
if (Math.abs(weightSum - 1.0) > 0.05) {
|
|
228
|
+
return {
|
|
229
|
+
content: [{
|
|
230
|
+
type: "text",
|
|
231
|
+
text: JSON.stringify({
|
|
232
|
+
error: `Weights sum to ${weightSum.toFixed(3)}, expected ~1.0. Adjust weights so they sum to 1.`,
|
|
233
|
+
criteria: args.criteria.map((c) => `${c.name}: ${c.weight}`),
|
|
234
|
+
}),
|
|
235
|
+
}],
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
// Load from merge if specified
|
|
239
|
+
let options = args.options;
|
|
240
|
+
if (args.merge_id && (!options || options.length === 0)) {
|
|
241
|
+
const row = db.prepare(`SELECT data FROM research_merges WHERE id = ?`).get(args.merge_id);
|
|
242
|
+
if (row) {
|
|
243
|
+
const merged = JSON.parse(row.data);
|
|
244
|
+
options = merged.records.map((r) => ({
|
|
245
|
+
name: String(r[merged.fields[0]] ?? "unknown"),
|
|
246
|
+
values: Object.fromEntries(Object.entries(r).filter(([k, v]) => typeof v === "number").map(([k, v]) => [k, v])),
|
|
247
|
+
metadata: r,
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (!options || options.length === 0) {
|
|
252
|
+
return { content: [{ type: "text", text: JSON.stringify({ error: "No options provided and merge_id yielded no records." }) }] };
|
|
253
|
+
}
|
|
254
|
+
// Normalize per criterion
|
|
255
|
+
const criterionNorms = {};
|
|
256
|
+
for (const criterion of args.criteria) {
|
|
257
|
+
const rawValues = options.map((o) => o.values[criterion.name] ?? 0);
|
|
258
|
+
criterionNorms[criterion.name] = normalizeMinMax(rawValues, criterion.direction);
|
|
259
|
+
}
|
|
260
|
+
// Score each option
|
|
261
|
+
const scored = options.map((option, i) => {
|
|
262
|
+
let totalScore = 0;
|
|
263
|
+
const criterionScores = {};
|
|
264
|
+
for (const criterion of args.criteria) {
|
|
265
|
+
const raw = option.values[criterion.name] ?? 0;
|
|
266
|
+
const normalized = criterionNorms[criterion.name][i];
|
|
267
|
+
const weighted = normalized * criterion.weight;
|
|
268
|
+
totalScore += weighted;
|
|
269
|
+
criterionScores[criterion.name] = { raw, normalized: Math.round(normalized * 1000) / 1000, weighted: Math.round(weighted * 1000) / 1000 };
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
rank: 0,
|
|
273
|
+
name: option.name,
|
|
274
|
+
totalScore: Math.round(totalScore * 1000) / 1000,
|
|
275
|
+
criterionScores,
|
|
276
|
+
metadata: option.metadata,
|
|
277
|
+
};
|
|
278
|
+
});
|
|
279
|
+
// Rank
|
|
280
|
+
scored.sort((a, b) => b.totalScore - a.totalScore);
|
|
281
|
+
scored.forEach((s, i) => (s.rank = i + 1));
|
|
282
|
+
// Optional classification
|
|
283
|
+
let classifications;
|
|
284
|
+
if (args.classify_field) {
|
|
285
|
+
classifications = {};
|
|
286
|
+
for (const s of scored) {
|
|
287
|
+
const raw = s.criterionScores[args.classify_field]?.raw ?? 0;
|
|
288
|
+
if (args.classify_field === "cpp_value" || args.classify_field.includes("cpp")) {
|
|
289
|
+
classifications[s.name] = classifyCpp(raw);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
// Generic tier
|
|
293
|
+
const norm = s.criterionScores[args.classify_field]?.normalized ?? 0;
|
|
294
|
+
classifications[s.name] = norm >= 0.75 ? "excellent" : norm >= 0.5 ? "good" : norm >= 0.25 ? "acceptable" : "poor";
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// Persist
|
|
299
|
+
const scoreId = genId("score");
|
|
300
|
+
db.prepare(`INSERT INTO research_scores (id, merge_id, criteria, options, ranked_results, strategy_label) VALUES (?, ?, ?, ?, ?, ?)`).run(scoreId, args.merge_id ?? null, JSON.stringify(args.criteria), JSON.stringify(options.map((o) => o.name)), JSON.stringify(scored), args.strategy_label ?? null);
|
|
301
|
+
return {
|
|
302
|
+
content: [{
|
|
303
|
+
type: "text",
|
|
304
|
+
text: JSON.stringify({
|
|
305
|
+
scoreId,
|
|
306
|
+
strategyLabel: args.strategy_label,
|
|
307
|
+
topRecommendation: scored[0],
|
|
308
|
+
alternatives: scored.slice(1, 3),
|
|
309
|
+
fullRanking: scored,
|
|
310
|
+
classifications,
|
|
311
|
+
criteriaUsed: args.criteria,
|
|
312
|
+
_hint: "Use compare_options for a formatted side-by-side comparison table.",
|
|
313
|
+
}, null, 2),
|
|
314
|
+
}],
|
|
315
|
+
};
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
// ── Tool 3: compare_options ─────────────────────────────────────────────
|
|
319
|
+
const compareOptions = {
|
|
320
|
+
name: "compare_options",
|
|
321
|
+
description: "Generate a formatted side-by-side comparison table from scored research results. Takes either raw options or a score_id from multi_criteria_score. Outputs markdown table with normalized bars, rank badges, and decision explanation. Perfect for presenting final recommendations to users.",
|
|
322
|
+
inputSchema: {
|
|
323
|
+
type: "object",
|
|
324
|
+
properties: {
|
|
325
|
+
score_id: {
|
|
326
|
+
type: "string",
|
|
327
|
+
description: "Score ID from multi_criteria_score to load ranked results",
|
|
328
|
+
},
|
|
329
|
+
options: {
|
|
330
|
+
type: "array",
|
|
331
|
+
items: {
|
|
332
|
+
type: "object",
|
|
333
|
+
properties: {
|
|
334
|
+
name: { type: "string" },
|
|
335
|
+
attributes: { type: "object", description: "Map of attribute_name → display value (string or number)" },
|
|
336
|
+
},
|
|
337
|
+
required: ["name", "attributes"],
|
|
338
|
+
},
|
|
339
|
+
description: "Manual options (alternative to score_id)",
|
|
340
|
+
},
|
|
341
|
+
title: {
|
|
342
|
+
type: "string",
|
|
343
|
+
description: "Report title (e.g., 'Disneyland Hotel Optimization Report')",
|
|
344
|
+
},
|
|
345
|
+
highlight_fields: {
|
|
346
|
+
type: "array",
|
|
347
|
+
items: { type: "string" },
|
|
348
|
+
description: "Fields to highlight in the comparison (shown first)",
|
|
349
|
+
},
|
|
350
|
+
format: {
|
|
351
|
+
type: "string",
|
|
352
|
+
enum: ["markdown", "json"],
|
|
353
|
+
description: "Output format. Default: markdown",
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
required: [],
|
|
357
|
+
},
|
|
358
|
+
handler: async (args) => {
|
|
359
|
+
ensureTables();
|
|
360
|
+
const db = getDb();
|
|
361
|
+
const format = args.format ?? "markdown";
|
|
362
|
+
let options = [];
|
|
363
|
+
// Load from score_id
|
|
364
|
+
if (args.score_id) {
|
|
365
|
+
const row = db.prepare(`SELECT ranked_results, strategy_label FROM research_scores WHERE id = ?`).get(args.score_id);
|
|
366
|
+
if (row) {
|
|
367
|
+
const scored = JSON.parse(row.ranked_results);
|
|
368
|
+
options = scored.map((s) => ({
|
|
369
|
+
name: s.name,
|
|
370
|
+
rank: s.rank,
|
|
371
|
+
score: s.totalScore,
|
|
372
|
+
attributes: {
|
|
373
|
+
...Object.fromEntries(Object.entries(s.criterionScores).map(([k, v]) => [k, `${v.raw} (${Math.round(v.normalized * 100)}%)`])),
|
|
374
|
+
...(s.metadata ?? {}),
|
|
375
|
+
},
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// Use manual options if provided
|
|
380
|
+
if (args.options && args.options.length > 0) {
|
|
381
|
+
options = args.options.map((o, i) => ({ ...o, rank: i + 1 }));
|
|
382
|
+
}
|
|
383
|
+
if (options.length === 0) {
|
|
384
|
+
return { content: [{ type: "text", text: JSON.stringify({ error: "No options provided and score_id yielded no results." }) }] };
|
|
385
|
+
}
|
|
386
|
+
if (format === "json") {
|
|
387
|
+
return {
|
|
388
|
+
content: [{
|
|
389
|
+
type: "text",
|
|
390
|
+
text: JSON.stringify({ title: args.title ?? "Comparison", options }, null, 2),
|
|
391
|
+
}],
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
// Build markdown table
|
|
395
|
+
const title = args.title ?? "Option Comparison";
|
|
396
|
+
const allKeys = new Set();
|
|
397
|
+
for (const o of options) {
|
|
398
|
+
for (const k of Object.keys(o.attributes)) {
|
|
399
|
+
if (!k.startsWith("_"))
|
|
400
|
+
allKeys.add(k);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// Order: highlight fields first, then rest alphabetically
|
|
404
|
+
const highlighted = new Set(args.highlight_fields ?? []);
|
|
405
|
+
const orderedKeys = [
|
|
406
|
+
...(args.highlight_fields ?? []).filter((k) => allKeys.has(k)),
|
|
407
|
+
...[...allKeys].filter((k) => !highlighted.has(k)).sort(),
|
|
408
|
+
];
|
|
409
|
+
let md = `# ${title}\n\n`;
|
|
410
|
+
// Rank badges
|
|
411
|
+
const badges = ["🥇", "🥈", "🥉"];
|
|
412
|
+
for (const o of options.slice(0, 3)) {
|
|
413
|
+
const badge = badges[(o.rank ?? 1) - 1] ?? "";
|
|
414
|
+
md += `${badge} **#${o.rank ?? "?"} ${o.name}**${o.score ? ` — Score: ${o.score}` : ""}\n`;
|
|
415
|
+
}
|
|
416
|
+
md += "\n";
|
|
417
|
+
// Table
|
|
418
|
+
const header = ["Attribute", ...options.map((o) => o.name)];
|
|
419
|
+
md += `| ${header.join(" | ")} |\n`;
|
|
420
|
+
md += `| ${header.map(() => "---").join(" | ")} |\n`;
|
|
421
|
+
for (const key of orderedKeys) {
|
|
422
|
+
const cells = options.map((o) => {
|
|
423
|
+
const val = o.attributes[key];
|
|
424
|
+
return val != null ? String(val) : "—";
|
|
425
|
+
});
|
|
426
|
+
md += `| **${key}** | ${cells.join(" | ")} |\n`;
|
|
427
|
+
}
|
|
428
|
+
// Decision explanation
|
|
429
|
+
if (options.length >= 2) {
|
|
430
|
+
const top = options[0];
|
|
431
|
+
const second = options[1];
|
|
432
|
+
md += `\n## Decision\n\n`;
|
|
433
|
+
md += `**${top.name}** ranks #1`;
|
|
434
|
+
if (top.score && second.score) {
|
|
435
|
+
const margin = ((top.score - second.score) / second.score * 100).toFixed(1);
|
|
436
|
+
md += ` with a ${margin}% score advantage over ${second.name}`;
|
|
437
|
+
}
|
|
438
|
+
md += ".\n";
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
content: [{
|
|
442
|
+
type: "text",
|
|
443
|
+
text: md,
|
|
444
|
+
}],
|
|
445
|
+
};
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
// ── Export ───────────────────────────────────────────────────────────────
|
|
449
|
+
export const researchOptimizerTools = [
|
|
450
|
+
mergeResearchResults,
|
|
451
|
+
multiCriteriaScore,
|
|
452
|
+
compareOptions,
|
|
453
|
+
];
|
|
454
|
+
//# sourceMappingURL=researchOptimizerTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"researchOptimizerTools.js","sourceRoot":"","sources":["../../src/tools/researchOptimizerTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAkCxC,2EAA2E;AAE3E,SAAS,eAAe,CACtB,MAAgB,EAChB,SAAkC;IAElC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;IAChC,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,4BAA4B;IACzE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACtB,SAAS,KAAK,UAAU;QACtB,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;QACzB,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAC5B,CAAC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T,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,4EAA4E;AAE5E,MAAM,CAAC,MAAM,sBAAsB,GAAc;IAC/C,oBAAoB;IACpB,kBAAkB;IAClB,cAAc;CACf,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrapling tools — Adaptive web scraping via Scrapling Python bridge server.
|
|
3
|
+
*
|
|
4
|
+
* Calls the scrapling_bridge FastAPI server over HTTP (port 8008).
|
|
5
|
+
* Requires SCRAPLING_SERVER_URL env var (default: http://localhost:8008).
|
|
6
|
+
*
|
|
7
|
+
* Tiers:
|
|
8
|
+
* http — Basic HTTP fetch with stealthy headers
|
|
9
|
+
* stealth — Anti-bot bypass (Cloudflare, TLS fingerprinting)
|
|
10
|
+
* dynamic — Full browser rendering (Playwright)
|
|
11
|
+
*
|
|
12
|
+
* Note: Web scraping should comply with target site ToS. User responsibility.
|
|
13
|
+
*/
|
|
14
|
+
import type { McpTool } from "../types.js";
|
|
15
|
+
export declare const scraplingTools: McpTool[];
|