@4da/mcp-server 3.2.0
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 +135 -0
- package/dist/db.d.ts +64 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +578 -0
- package/dist/db.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +422 -0
- package/dist/index.js.map +1 -0
- package/dist/llm.d.ts +144 -0
- package/dist/llm.d.ts.map +1 -0
- package/dist/llm.js +447 -0
- package/dist/llm.js.map +1 -0
- package/dist/output-manager.d.ts +156 -0
- package/dist/output-manager.d.ts.map +1 -0
- package/dist/output-manager.js +156 -0
- package/dist/output-manager.js.map +1 -0
- package/dist/schema-registry.d.ts +46 -0
- package/dist/schema-registry.d.ts.map +1 -0
- package/dist/schema-registry.js +133 -0
- package/dist/schema-registry.js.map +1 -0
- package/dist/schemas/config-validator.json +18 -0
- package/dist/schemas/context-analysis.json +25 -0
- package/dist/schemas/daily-briefing.json +34 -0
- package/dist/schemas/explain-relevance.json +19 -0
- package/dist/schemas/get-actionable-signals.json +29 -0
- package/dist/schemas/get-context.json +17 -0
- package/dist/schemas/get-relevant-content.json +26 -0
- package/dist/schemas/llm-status.json +13 -0
- package/dist/schemas/record-feedback.json +24 -0
- package/dist/schemas/score-autopsy.json +30 -0
- package/dist/schemas/source-health.json +17 -0
- package/dist/schemas/topic-connections.json +34 -0
- package/dist/schemas/trend-analysis.json +29 -0
- package/dist/tools/attention-report.d.ts +39 -0
- package/dist/tools/attention-report.d.ts.map +1 -0
- package/dist/tools/attention-report.js +72 -0
- package/dist/tools/attention-report.js.map +1 -0
- package/dist/tools/config-validator.d.ts +59 -0
- package/dist/tools/config-validator.d.ts.map +1 -0
- package/dist/tools/config-validator.js +375 -0
- package/dist/tools/config-validator.js.map +1 -0
- package/dist/tools/context-analysis.d.ts +108 -0
- package/dist/tools/context-analysis.d.ts.map +1 -0
- package/dist/tools/context-analysis.js +300 -0
- package/dist/tools/context-analysis.js.map +1 -0
- package/dist/tools/daily-briefing.d.ts +103 -0
- package/dist/tools/daily-briefing.d.ts.map +1 -0
- package/dist/tools/daily-briefing.js +278 -0
- package/dist/tools/daily-briefing.js.map +1 -0
- package/dist/tools/explain-relevance.d.ts +36 -0
- package/dist/tools/explain-relevance.d.ts.map +1 -0
- package/dist/tools/explain-relevance.js +50 -0
- package/dist/tools/explain-relevance.js.map +1 -0
- package/dist/tools/export-context.d.ts +43 -0
- package/dist/tools/export-context.d.ts.map +1 -0
- package/dist/tools/export-context.js +104 -0
- package/dist/tools/export-context.js.map +1 -0
- package/dist/tools/get-actionable-signals.d.ts +65 -0
- package/dist/tools/get-actionable-signals.d.ts.map +1 -0
- package/dist/tools/get-actionable-signals.js +268 -0
- package/dist/tools/get-actionable-signals.js.map +1 -0
- package/dist/tools/get-context.d.ts +34 -0
- package/dist/tools/get-context.d.ts.map +1 -0
- package/dist/tools/get-context.js +43 -0
- package/dist/tools/get-context.js.map +1 -0
- package/dist/tools/get-relevant-content.d.ts +44 -0
- package/dist/tools/get-relevant-content.d.ts.map +1 -0
- package/dist/tools/get-relevant-content.js +56 -0
- package/dist/tools/get-relevant-content.js.map +1 -0
- package/dist/tools/index.d.ts +40 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +44 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/knowledge-gaps.d.ts +36 -0
- package/dist/tools/knowledge-gaps.d.ts.map +1 -0
- package/dist/tools/knowledge-gaps.js +76 -0
- package/dist/tools/knowledge-gaps.js.map +1 -0
- package/dist/tools/llm-status.d.ts +45 -0
- package/dist/tools/llm-status.d.ts.map +1 -0
- package/dist/tools/llm-status.js +92 -0
- package/dist/tools/llm-status.js.map +1 -0
- package/dist/tools/project-health.d.ts +41 -0
- package/dist/tools/project-health.d.ts.map +1 -0
- package/dist/tools/project-health.js +71 -0
- package/dist/tools/project-health.js.map +1 -0
- package/dist/tools/record-feedback.d.ts +39 -0
- package/dist/tools/record-feedback.d.ts.map +1 -0
- package/dist/tools/record-feedback.js +60 -0
- package/dist/tools/record-feedback.js.map +1 -0
- package/dist/tools/reverse-mentions.d.ts +38 -0
- package/dist/tools/reverse-mentions.d.ts.map +1 -0
- package/dist/tools/reverse-mentions.js +57 -0
- package/dist/tools/reverse-mentions.js.map +1 -0
- package/dist/tools/score-autopsy.d.ts +93 -0
- package/dist/tools/score-autopsy.d.ts.map +1 -0
- package/dist/tools/score-autopsy.js +288 -0
- package/dist/tools/score-autopsy.js.map +1 -0
- package/dist/tools/semantic-shifts.d.ts +37 -0
- package/dist/tools/semantic-shifts.d.ts.map +1 -0
- package/dist/tools/semantic-shifts.js +73 -0
- package/dist/tools/semantic-shifts.js.map +1 -0
- package/dist/tools/signal-chains.d.ts +45 -0
- package/dist/tools/signal-chains.d.ts.map +1 -0
- package/dist/tools/signal-chains.js +60 -0
- package/dist/tools/signal-chains.js.map +1 -0
- package/dist/tools/source-health.d.ts +64 -0
- package/dist/tools/source-health.d.ts.map +1 -0
- package/dist/tools/source-health.js +176 -0
- package/dist/tools/source-health.js.map +1 -0
- package/dist/tools/topic-connections.d.ts +112 -0
- package/dist/tools/topic-connections.d.ts.map +1 -0
- package/dist/tools/topic-connections.js +318 -0
- package/dist/tools/topic-connections.js.map +1 -0
- package/dist/tools/trend-analysis.d.ts +105 -0
- package/dist/tools/trend-analysis.d.ts.map +1 -0
- package/dist/tools/trend-analysis.js +295 -0
- package/dist/tools/trend-analysis.js.map +1 -0
- package/dist/types.d.ts +163 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daily Briefing Tool
|
|
3
|
+
*
|
|
4
|
+
* Generate an executive summary of 4DA's discoveries.
|
|
5
|
+
* This is a SUPERPOWER - it synthesizes noise into actionable intelligence.
|
|
6
|
+
*
|
|
7
|
+
* With synthesize=true, uses LLM to generate genuine insights.
|
|
8
|
+
*/
|
|
9
|
+
import { getLLMConfig, canSynthesize, synthesize, SYNTHESIS_PROMPTS } from "../llm.js";
|
|
10
|
+
import { createDailyBriefingCompact } from "../output-manager.js";
|
|
11
|
+
export const dailyBriefingTool = {
|
|
12
|
+
name: "daily_briefing",
|
|
13
|
+
description: `Generate an executive briefing from 4DA's recent discoveries.
|
|
14
|
+
|
|
15
|
+
With synthesize=true (recommended), uses AI to generate genuine insights tailored to your context.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
- TL;DR summary (AI-generated when synthesize=true)
|
|
19
|
+
- Key themes with item counts
|
|
20
|
+
- Notable high-scoring items
|
|
21
|
+
- Actionable recommendations
|
|
22
|
+
- Trend highlights
|
|
23
|
+
- AI synthesis (when enabled)
|
|
24
|
+
|
|
25
|
+
Use this for your daily/weekly content review.`,
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
hours: {
|
|
30
|
+
type: "number",
|
|
31
|
+
description: "Hours to look back (default: 24)",
|
|
32
|
+
},
|
|
33
|
+
min_score: {
|
|
34
|
+
type: "number",
|
|
35
|
+
description: "Minimum relevance score (default: 0.5)",
|
|
36
|
+
},
|
|
37
|
+
max_items: {
|
|
38
|
+
type: "number",
|
|
39
|
+
description: "Maximum items to analyze (default: 50)",
|
|
40
|
+
},
|
|
41
|
+
format: {
|
|
42
|
+
type: "string",
|
|
43
|
+
enum: ["full", "brief", "actionable"],
|
|
44
|
+
description: "Output format (default: full)",
|
|
45
|
+
},
|
|
46
|
+
synthesize: {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description: "Use AI to generate genuine insights (default: true if LLM configured)",
|
|
49
|
+
},
|
|
50
|
+
compact: {
|
|
51
|
+
type: "boolean",
|
|
52
|
+
description: "Return compact result with file reference (default: true for ~80% token reduction)",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
export async function executeDailyBriefing(db, params) {
|
|
58
|
+
const useCompact = params.compact !== false; // Default to compact=true
|
|
59
|
+
const { hours = 24, min_score = 0.5, max_items = 50, format = "full" } = params;
|
|
60
|
+
// Check LLM availability
|
|
61
|
+
const dbInstance = db.db;
|
|
62
|
+
const llmConfig = getLLMConfig(dbInstance);
|
|
63
|
+
const shouldSynthesize = params.synthesize ?? canSynthesize(llmConfig);
|
|
64
|
+
// Get relevant items
|
|
65
|
+
const items = db.getRelevantContent(min_score, undefined, max_items, hours);
|
|
66
|
+
const context = db.getUserContext(true, true);
|
|
67
|
+
// Calculate basic stats
|
|
68
|
+
const avgScore = items.length > 0
|
|
69
|
+
? items.reduce((sum, i) => sum + i.relevance_score, 0) / items.length
|
|
70
|
+
: 0;
|
|
71
|
+
// Extract themes
|
|
72
|
+
const themes = extractThemes(items, context);
|
|
73
|
+
// Identify notable items
|
|
74
|
+
const notableItems = items
|
|
75
|
+
.filter(i => i.relevance_score >= 0.7)
|
|
76
|
+
.slice(0, 5)
|
|
77
|
+
.map(i => ({
|
|
78
|
+
id: i.id,
|
|
79
|
+
title: i.title,
|
|
80
|
+
url: i.url,
|
|
81
|
+
source: i.source_type,
|
|
82
|
+
score: i.relevance_score,
|
|
83
|
+
why_notable: i.relevance_score >= 0.85
|
|
84
|
+
? "Exceptionally high relevance"
|
|
85
|
+
: "Strong match to your interests",
|
|
86
|
+
}));
|
|
87
|
+
// Generate recommendations
|
|
88
|
+
const recommendations = generateRecommendations(themes, items, context);
|
|
89
|
+
// Get trends (simplified)
|
|
90
|
+
const trends = {
|
|
91
|
+
rising: themes
|
|
92
|
+
.filter(t => t.item_count >= 3)
|
|
93
|
+
.slice(0, 3)
|
|
94
|
+
.map(t => t.name),
|
|
95
|
+
falling: [],
|
|
96
|
+
};
|
|
97
|
+
// Generate TL;DR
|
|
98
|
+
const tldr = generateTldr(items.length, themes, avgScore, notableItems.length);
|
|
99
|
+
const endDate = new Date();
|
|
100
|
+
const startDate = new Date(endDate.getTime() - hours * 60 * 60 * 1000);
|
|
101
|
+
const result = {
|
|
102
|
+
period: {
|
|
103
|
+
start: startDate.toISOString(),
|
|
104
|
+
end: endDate.toISOString(),
|
|
105
|
+
hours,
|
|
106
|
+
},
|
|
107
|
+
summary: {
|
|
108
|
+
total_items_analyzed: items.length,
|
|
109
|
+
high_relevance_count: items.filter(i => i.relevance_score >= 0.7).length,
|
|
110
|
+
avg_score: Math.round(avgScore * 100) / 100,
|
|
111
|
+
tldr,
|
|
112
|
+
},
|
|
113
|
+
themes: format === "brief" ? themes.slice(0, 3) : themes,
|
|
114
|
+
notable_items: notableItems,
|
|
115
|
+
recommendations: format === "actionable" ? recommendations : recommendations.slice(0, 3),
|
|
116
|
+
trends,
|
|
117
|
+
};
|
|
118
|
+
// AI Synthesis - the actual superpower
|
|
119
|
+
if (shouldSynthesize && canSynthesize(llmConfig)) {
|
|
120
|
+
try {
|
|
121
|
+
const briefingData = {
|
|
122
|
+
period: result.period,
|
|
123
|
+
summary: result.summary,
|
|
124
|
+
themes: result.themes.slice(0, 5),
|
|
125
|
+
notable_items: result.notable_items,
|
|
126
|
+
trends: result.trends,
|
|
127
|
+
};
|
|
128
|
+
const contextData = {
|
|
129
|
+
interests: context.interests.slice(0, 10),
|
|
130
|
+
tech_stack: context.tech_stack,
|
|
131
|
+
role: context.role,
|
|
132
|
+
};
|
|
133
|
+
const synthesis = await synthesize(llmConfig, {
|
|
134
|
+
system: SYNTHESIS_PROMPTS.dailyBriefing.system,
|
|
135
|
+
prompt: SYNTHESIS_PROMPTS.dailyBriefing.buildPrompt(briefingData, contextData),
|
|
136
|
+
max_tokens: 400,
|
|
137
|
+
complexity: SYNTHESIS_PROMPTS.dailyBriefing.complexity,
|
|
138
|
+
});
|
|
139
|
+
// Parse the synthesis into structured output
|
|
140
|
+
const lines = synthesis.synthesis.split("\n").filter(l => l.trim());
|
|
141
|
+
const keyInsight = lines[0] || "";
|
|
142
|
+
const actionItem = lines.find(l => l.toLowerCase().includes("action") || l.toLowerCase().includes("should")) || lines[1] || "";
|
|
143
|
+
result.ai_synthesis = {
|
|
144
|
+
executive_brief: synthesis.synthesis,
|
|
145
|
+
key_insight: keyInsight,
|
|
146
|
+
action_item: actionItem,
|
|
147
|
+
model_used: synthesis.model_used,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
// Synthesis failed - continue without it
|
|
152
|
+
console.error("AI synthesis failed:", error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Return compact or full result based on parameter
|
|
156
|
+
if (useCompact) {
|
|
157
|
+
return createDailyBriefingCompact(result);
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
function extractThemes(items, context) {
|
|
162
|
+
// Define theme patterns
|
|
163
|
+
const themePatterns = [
|
|
164
|
+
{ name: "AI & Machine Learning", keywords: ["ai", "llm", "gpt", "claude", "machine learning", "neural", "embedding"] },
|
|
165
|
+
{ name: "Rust Ecosystem", keywords: ["rust", "cargo", "tokio", "async", "wasm"] },
|
|
166
|
+
{ name: "TypeScript & Frontend", keywords: ["typescript", "javascript", "react", "vue", "frontend"] },
|
|
167
|
+
{ name: "Databases & Storage", keywords: ["database", "sql", "sqlite", "postgres", "redis", "storage"] },
|
|
168
|
+
{ name: "Security", keywords: ["security", "vulnerability", "auth", "encryption", "cve"] },
|
|
169
|
+
{ name: "Infrastructure", keywords: ["docker", "kubernetes", "cloud", "aws", "devops"] },
|
|
170
|
+
{ name: "Developer Tools", keywords: ["ide", "editor", "cli", "terminal", "git", "testing"] },
|
|
171
|
+
];
|
|
172
|
+
// Pre-compute lowercased text for each item ONCE
|
|
173
|
+
const itemsWithText = items.map(item => ({
|
|
174
|
+
...item,
|
|
175
|
+
textLower: (item.title + " " + item.content).toLowerCase(),
|
|
176
|
+
}));
|
|
177
|
+
const themes = [];
|
|
178
|
+
for (const pattern of themePatterns) {
|
|
179
|
+
const matchingItems = itemsWithText.filter(item => pattern.keywords.some(kw => item.textLower.includes(kw)));
|
|
180
|
+
if (matchingItems.length > 0) {
|
|
181
|
+
const avgScore = matchingItems.reduce((sum, i) => sum + i.relevance_score, 0) / matchingItems.length;
|
|
182
|
+
themes.push({
|
|
183
|
+
name: pattern.name,
|
|
184
|
+
item_count: matchingItems.length,
|
|
185
|
+
avg_score: Math.round(avgScore * 100) / 100,
|
|
186
|
+
top_items: matchingItems
|
|
187
|
+
.sort((a, b) => b.relevance_score - a.relevance_score)
|
|
188
|
+
.slice(0, 3)
|
|
189
|
+
.map(i => ({
|
|
190
|
+
title: i.title,
|
|
191
|
+
score: i.relevance_score,
|
|
192
|
+
url: i.url,
|
|
193
|
+
})),
|
|
194
|
+
insight: generateThemeInsight(pattern.name, matchingItems.length, avgScore),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return themes.sort((a, b) => b.avg_score - a.avg_score);
|
|
199
|
+
}
|
|
200
|
+
function generateThemeInsight(name, count, avgScore) {
|
|
201
|
+
if (count >= 5 && avgScore >= 0.7) {
|
|
202
|
+
return `Strong activity in ${name} - this is clearly relevant to your work`;
|
|
203
|
+
}
|
|
204
|
+
else if (count >= 3) {
|
|
205
|
+
return `Moderate activity in ${name} - worth keeping an eye on`;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return `Some mentions of ${name} - peripheral to your main focus`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function generateRecommendations(themes, items, context) {
|
|
212
|
+
const recommendations = [];
|
|
213
|
+
// High relevance items exist
|
|
214
|
+
const highRelevance = items.filter(i => i.relevance_score >= 0.8);
|
|
215
|
+
if (highRelevance.length > 0) {
|
|
216
|
+
recommendations.push({
|
|
217
|
+
priority: "high",
|
|
218
|
+
action: `Review the ${highRelevance.length} high-relevance items`,
|
|
219
|
+
reasoning: "These items scored >80% relevance and directly match your interests",
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
// Strong theme detected
|
|
223
|
+
const topTheme = themes[0];
|
|
224
|
+
if (topTheme && topTheme.item_count >= 5) {
|
|
225
|
+
recommendations.push({
|
|
226
|
+
priority: "medium",
|
|
227
|
+
action: `Deep dive into "${topTheme.name}" content`,
|
|
228
|
+
reasoning: `${topTheme.item_count} items cluster around this theme with avg ${Math.round(topTheme.avg_score * 100)}% relevance`,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
// Low overall volume
|
|
232
|
+
if (items.length < 5) {
|
|
233
|
+
recommendations.push({
|
|
234
|
+
priority: "low",
|
|
235
|
+
action: "Check source connectivity",
|
|
236
|
+
reasoning: "Low item count may indicate source fetch issues",
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
// Add generic recommendation if empty
|
|
240
|
+
if (recommendations.length === 0) {
|
|
241
|
+
recommendations.push({
|
|
242
|
+
priority: "low",
|
|
243
|
+
action: "Continue monitoring - no urgent actions needed",
|
|
244
|
+
reasoning: "Content flow is normal with no standout items",
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return recommendations;
|
|
248
|
+
}
|
|
249
|
+
function generateTldr(totalItems, themes, avgScore, notableCount) {
|
|
250
|
+
const parts = [];
|
|
251
|
+
// Volume
|
|
252
|
+
if (totalItems > 20) {
|
|
253
|
+
parts.push(`Busy period with ${totalItems} relevant items.`);
|
|
254
|
+
}
|
|
255
|
+
else if (totalItems > 5) {
|
|
256
|
+
parts.push(`Moderate activity with ${totalItems} relevant items.`);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
parts.push(`Quiet period with only ${totalItems} relevant items.`);
|
|
260
|
+
}
|
|
261
|
+
// Top theme
|
|
262
|
+
if (themes.length > 0) {
|
|
263
|
+
parts.push(`Top theme: ${themes[0].name} (${themes[0].item_count} items).`);
|
|
264
|
+
}
|
|
265
|
+
// Notable items
|
|
266
|
+
if (notableCount > 0) {
|
|
267
|
+
parts.push(`${notableCount} items scored exceptionally high - review recommended.`);
|
|
268
|
+
}
|
|
269
|
+
// Quality
|
|
270
|
+
if (avgScore >= 0.7) {
|
|
271
|
+
parts.push("Quality is high - good signal-to-noise ratio.");
|
|
272
|
+
}
|
|
273
|
+
else if (avgScore >= 0.5) {
|
|
274
|
+
parts.push("Decent relevance overall.");
|
|
275
|
+
}
|
|
276
|
+
return parts.join(" ");
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=daily-briefing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daily-briefing.js","sourceRoot":"","sources":["../../src/tools/daily-briefing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAiD,MAAM,sBAAsB,CAAC;AAEjH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;;;;;;;;;;;;+CAYgC;IAC7C,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kCAAkC;aAChD;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wCAAwC;aACtD;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wCAAwC;aACtD;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC;gBACrC,WAAW,EAAE,+BAA+B;aAC7C;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,uEAAuE;aACrF;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,oFAAoF;aAClG;SACF;KACF;CACF,C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AC;QAC3B,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* explain_relevance tool
|
|
3
|
+
*
|
|
4
|
+
* Explain why an item was considered relevant.
|
|
5
|
+
*/
|
|
6
|
+
import type { FourDADatabase } from "../db.js";
|
|
7
|
+
import type { ExplainRelevanceParams, RelevanceExplanation } from "../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Tool definition for MCP registration
|
|
10
|
+
*/
|
|
11
|
+
export declare const explainRelevanceTool: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: "object";
|
|
16
|
+
properties: {
|
|
17
|
+
item_id: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
source_type: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
enum: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
required: string[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Execute the explain_relevance tool
|
|
32
|
+
*/
|
|
33
|
+
export declare function executeExplainRelevance(db: FourDADatabase, params: ExplainRelevanceParams): RelevanceExplanation | {
|
|
34
|
+
error: string;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=explain-relevance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain-relevance.d.ts","sourceRoot":"","sources":["../../src/tools/explain-relevance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;CAyBhC,CAAC;AAEF;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,sBAAsB,GAC7B,oBAAoB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAc1C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* explain_relevance tool
|
|
3
|
+
*
|
|
4
|
+
* Explain why an item was considered relevant.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Tool definition for MCP registration
|
|
8
|
+
*/
|
|
9
|
+
export const explainRelevanceTool = {
|
|
10
|
+
name: "explain_relevance",
|
|
11
|
+
description: `Explain why a content item was considered relevant.
|
|
12
|
+
|
|
13
|
+
Provides a detailed breakdown of:
|
|
14
|
+
- Score components (static match, ACE context, learned preferences, penalties)
|
|
15
|
+
- Matching context elements (interests, tech, topics, affinities)
|
|
16
|
+
- Human-readable explanation
|
|
17
|
+
|
|
18
|
+
Use this to understand how 4DA scored a particular item.`,
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
item_id: {
|
|
23
|
+
type: "number",
|
|
24
|
+
description: "The database ID of the item to explain",
|
|
25
|
+
},
|
|
26
|
+
source_type: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: 'The source type: "hackernews", "arxiv", or "reddit"',
|
|
29
|
+
enum: ["hackernews", "arxiv", "reddit"],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
required: ["item_id", "source_type"],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Execute the explain_relevance tool
|
|
37
|
+
*/
|
|
38
|
+
export function executeExplainRelevance(db, params) {
|
|
39
|
+
if (!params.item_id || !params.source_type) {
|
|
40
|
+
return { error: "item_id and source_type are required" };
|
|
41
|
+
}
|
|
42
|
+
const explanation = db.explainRelevance(params.item_id, params.source_type);
|
|
43
|
+
if (!explanation) {
|
|
44
|
+
return {
|
|
45
|
+
error: `Item ${params.item_id} of type ${params.source_type} not found`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return explanation;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=explain-relevance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain-relevance.js","sourceRoot":"","sources":["../../src/tools/explain-relevance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE;;;;;;;yDAO0C;IACvD,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wCAAwC;aACtD;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qDAAqD;gBAClE,IAAI,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,CAAC;aACxC;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;KACrC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,EAAkB,EAClB,MAA8B;IAE9B,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC3C,OAAO,EAAE,KAAK,EAAE,sCAAsC,EAAE,CAAC;IAC3D,CAAC;IAED,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAE5E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;YACL,KAAK,EAAE,QAAQ,MAAM,CAAC,OAAO,YAAY,MAAM,CAAC,WAAW,YAAY;SACxE,CAAC;IACJ,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* export_context_packet tool
|
|
3
|
+
*
|
|
4
|
+
* Generate a context packet for handoff to another session or AI agent.
|
|
5
|
+
*/
|
|
6
|
+
import type { FourDADatabase } from "../db.js";
|
|
7
|
+
export interface ExportContextParams {
|
|
8
|
+
include_signals?: boolean;
|
|
9
|
+
include_saved?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const exportContextPacketTool: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: "object";
|
|
16
|
+
properties: {
|
|
17
|
+
include_signals: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
include_saved: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
default: boolean;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare function executeExportContextPacket(db: FourDADatabase, params: ExportContextParams): {
|
|
31
|
+
generated_at: string;
|
|
32
|
+
version: string;
|
|
33
|
+
active_context: {
|
|
34
|
+
detected_tech: any[];
|
|
35
|
+
active_topics: any[];
|
|
36
|
+
interests: any[];
|
|
37
|
+
exclusions: any[];
|
|
38
|
+
};
|
|
39
|
+
open_signals: any[];
|
|
40
|
+
saved_items: any[];
|
|
41
|
+
summary: string;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=export-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-context.d.ts","sourceRoot":"","sources":["../../src/tools/export-context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,mBAAmB;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;CAkBnC,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,mBAAmB;;;;;;;;;;;;EAqF5B"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* export_context_packet tool
|
|
3
|
+
*
|
|
4
|
+
* Generate a context packet for handoff to another session or AI agent.
|
|
5
|
+
*/
|
|
6
|
+
export const exportContextPacketTool = {
|
|
7
|
+
name: "export_context_packet",
|
|
8
|
+
description: `Generate a portable context packet capturing current work state, open signals, saved items, and active context. Use this to hand off context to another session or AI agent.`,
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
include_signals: {
|
|
13
|
+
type: "boolean",
|
|
14
|
+
description: "Include open signals. Default: true",
|
|
15
|
+
default: true,
|
|
16
|
+
},
|
|
17
|
+
include_saved: {
|
|
18
|
+
type: "boolean",
|
|
19
|
+
description: "Include saved items. Default: true",
|
|
20
|
+
default: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export function executeExportContextPacket(db, params) {
|
|
26
|
+
const rawDb = db.getRawDb();
|
|
27
|
+
const includeSignals = params.include_signals ?? true;
|
|
28
|
+
const includeSaved = params.include_saved ?? true;
|
|
29
|
+
// Get interests
|
|
30
|
+
const interests = rawDb
|
|
31
|
+
.prepare("SELECT topic FROM interests ORDER BY weight DESC LIMIT 20")
|
|
32
|
+
.all()
|
|
33
|
+
.map((r) => r.topic);
|
|
34
|
+
// Get exclusions
|
|
35
|
+
const exclusions = rawDb
|
|
36
|
+
.prepare("SELECT topic FROM exclusions")
|
|
37
|
+
.all()
|
|
38
|
+
.map((r) => r.topic);
|
|
39
|
+
// Get detected tech from ACE
|
|
40
|
+
const detectedTech = rawDb
|
|
41
|
+
.prepare("SELECT DISTINCT name FROM detected_tech ORDER BY confidence DESC LIMIT 15")
|
|
42
|
+
.all()
|
|
43
|
+
.map((r) => r.name);
|
|
44
|
+
// Get active topics
|
|
45
|
+
const activeTopics = rawDb
|
|
46
|
+
.prepare("SELECT DISTINCT topic FROM active_topics ORDER BY last_seen DESC LIMIT 10")
|
|
47
|
+
.all()
|
|
48
|
+
.map((r) => r.topic);
|
|
49
|
+
// Get open signals from temporal events (signals are computed at runtime, not stored in source_items)
|
|
50
|
+
let openSignals = [];
|
|
51
|
+
if (includeSignals) {
|
|
52
|
+
try {
|
|
53
|
+
openSignals = rawDb
|
|
54
|
+
.prepare(`SELECT id, subject as title, data, created_at
|
|
55
|
+
FROM temporal_events
|
|
56
|
+
WHERE event_type = 'signal_emitted'
|
|
57
|
+
ORDER BY created_at DESC LIMIT 20`)
|
|
58
|
+
.all()
|
|
59
|
+
.map((row) => {
|
|
60
|
+
const data = JSON.parse(row.data || '{}');
|
|
61
|
+
return {
|
|
62
|
+
id: row.id,
|
|
63
|
+
title: row.title,
|
|
64
|
+
signal_type: data.signal_type || 'unknown',
|
|
65
|
+
priority: data.priority || 'medium',
|
|
66
|
+
source_type: data.source_type || 'unknown',
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// temporal_events may not have signal data yet
|
|
72
|
+
openSignals = rawDb
|
|
73
|
+
.prepare(`SELECT id, title, url, source_type
|
|
74
|
+
FROM source_items
|
|
75
|
+
ORDER BY created_at DESC LIMIT 20`)
|
|
76
|
+
.all();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Get saved items
|
|
80
|
+
let savedItems = [];
|
|
81
|
+
if (includeSaved) {
|
|
82
|
+
savedItems = rawDb
|
|
83
|
+
.prepare(`SELECT si.id, si.title, si.url, si.source_type, i.timestamp as saved_at
|
|
84
|
+
FROM interactions i
|
|
85
|
+
JOIN source_items si ON i.source_item_id = si.id
|
|
86
|
+
WHERE i.action = 'save'
|
|
87
|
+
ORDER BY i.timestamp DESC LIMIT 20`)
|
|
88
|
+
.all();
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
generated_at: new Date().toISOString(),
|
|
92
|
+
version: "1.0.0",
|
|
93
|
+
active_context: {
|
|
94
|
+
detected_tech: detectedTech,
|
|
95
|
+
active_topics: activeTopics,
|
|
96
|
+
interests,
|
|
97
|
+
exclusions,
|
|
98
|
+
},
|
|
99
|
+
open_signals: openSignals,
|
|
100
|
+
saved_items: savedItems,
|
|
101
|
+
summary: `${interests.length} interests, ${detectedTech.length} detected tech, ${openSignals.length} open signals, ${savedItems.length} saved items`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=export-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-context.js","sourceRoot":"","sources":["../../src/tools/export-context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,8KAA8K;IAC3L,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,eAAe,EAAE;gBACf,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,qCAAqC;gBAClD,OAAO,EAAE,IAAI;aACd;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,oCAAoC;gBACjD,OAAO,EAAE,IAAI;aACd;SACF;KACF;CACF,CAAC;AAEF,MAAM,UAAU,0BAA0B,CACxC,EAAkB,EAClB,MAA2B;IAE3B,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,IAAI,IAAI,CAAC;IACtD,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,IAAI,IAAI,CAAC;IAElD,gBAAgB;IAChB,MAAM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AC;YACJ,CAAC,CAAC,CAAC;QACP,CAAC;QAAC,MAAM,CAAC;YACP,+CAA+C;YAC/C,WAAW,GAAG,KAAK;iBAChB,OAAO,CAAC;;4CAE2B,CAAC;iBACpC,GAAG,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IAED,kBAAkB;IAClB,IAAI,UAAU,GAAU,EAAE,CAAC;IAC3B,IAAI,YAAY,EAAE,CAAC;QACjB,UAAU,GAAG,KAAK;aACf,OAAO,CAAC;;;;2CAI4B,CAAC;aACrC,GAAG,EAAE,CAAC;IACX,CAAC;IAED,OAAO;QACL,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACtC,OAAO,EAAE,OAAO;QAChB,cAAc,EAAE;YACd,aAAa,EAAE,YAAY;YAC3B,aAAa,EAAE,YAAY;YAC3B,SAAS;YACT,UAAU;SACX;QACD,YAAY,EAAE,WAAW;QACzB,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,GAAG,SAAS,CAAC,MAAM,eAAe,YAAY,CAAC,MAAM,mBAAmB,WAAW,CAAC,MAAM,kBAAkB,UAAU,CAAC,MAAM,cAAc;KACrJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get_actionable_signals tool
|
|
3
|
+
*
|
|
4
|
+
* Classifies source items into actionable signal types (security alerts,
|
|
5
|
+
* breaking changes, tool discoveries, etc.) with priority levels.
|
|
6
|
+
* Cross-references against the user's ACE-detected tech stack.
|
|
7
|
+
*/
|
|
8
|
+
import type { FourDADatabase } from "../db.js";
|
|
9
|
+
type SignalType = "security_alert" | "breaking_change" | "tool_discovery" | "tech_trend" | "learning" | "competitive_intel";
|
|
10
|
+
type SignalPriority = "critical" | "high" | "medium" | "low";
|
|
11
|
+
interface ClassifiedSignal {
|
|
12
|
+
id: number;
|
|
13
|
+
title: string;
|
|
14
|
+
url: string | null;
|
|
15
|
+
source_type: string;
|
|
16
|
+
relevance_score: number;
|
|
17
|
+
signal_type: SignalType;
|
|
18
|
+
signal_priority: SignalPriority;
|
|
19
|
+
action: string;
|
|
20
|
+
triggers: string[];
|
|
21
|
+
confidence: number;
|
|
22
|
+
discovered_ago: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const getActionableSignalsTool: {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: "object";
|
|
29
|
+
properties: {
|
|
30
|
+
priority_filter: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
enum: string[];
|
|
34
|
+
};
|
|
35
|
+
signal_type: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
enum: string[];
|
|
39
|
+
};
|
|
40
|
+
limit: {
|
|
41
|
+
type: string;
|
|
42
|
+
description: string;
|
|
43
|
+
default: number;
|
|
44
|
+
};
|
|
45
|
+
since_hours: {
|
|
46
|
+
type: string;
|
|
47
|
+
description: string;
|
|
48
|
+
default: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export interface GetActionableSignalsParams {
|
|
54
|
+
priority_filter?: SignalPriority;
|
|
55
|
+
signal_type?: SignalType;
|
|
56
|
+
limit?: number;
|
|
57
|
+
since_hours?: number;
|
|
58
|
+
}
|
|
59
|
+
export declare function executeGetActionableSignals(db: FourDADatabase, params: GetActionableSignalsParams): {
|
|
60
|
+
signals: ClassifiedSignal[];
|
|
61
|
+
total: number;
|
|
62
|
+
summary: Record<string, number>;
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=get-actionable-signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-actionable-signals.d.ts","sourceRoot":"","sources":["../../src/tools/get-actionable-signals.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM/C,KAAK,UAAU,GACX,gBAAgB,GAChB,iBAAiB,GACjB,gBAAgB,GAChB,YAAY,GACZ,UAAU,GACV,mBAAmB,CAAC;AAExB,KAAK,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAQ7D,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,UAAU,CAAC;IACxB,eAAe,EAAE,cAAc,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AA6MD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCpC,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,0BAA0B,GACjC;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA6DjF"}
|