noverload-mcp 0.8.4 β 0.9.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/dist/index.js +39 -19
- package/dist/index.js.map +1 -1
- package/dist/tools/implementations/_archived/estimate-tokens.d.ts +3 -0
- package/dist/tools/implementations/_archived/estimate-tokens.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/estimate-tokens.js +54 -0
- package/dist/tools/implementations/_archived/estimate-tokens.js.map +1 -0
- package/dist/tools/implementations/_archived/expand-search.d.ts +3 -0
- package/dist/tools/implementations/_archived/expand-search.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/expand-search.js +400 -0
- package/dist/tools/implementations/_archived/expand-search.js.map +1 -0
- package/dist/tools/implementations/_archived/extract-insights.d.ts +3 -0
- package/dist/tools/implementations/_archived/extract-insights.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/extract-insights.js +130 -0
- package/dist/tools/implementations/_archived/extract-insights.js.map +1 -0
- package/dist/tools/implementations/_archived/find-connections.d.ts +3 -0
- package/dist/tools/implementations/_archived/find-connections.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/find-connections.js +106 -0
- package/dist/tools/implementations/_archived/find-connections.js.map +1 -0
- package/dist/tools/implementations/_archived/instructions.d.ts +3 -0
- package/dist/tools/implementations/_archived/instructions.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/instructions.js +88 -0
- package/dist/tools/implementations/_archived/instructions.js.map +1 -0
- package/dist/tools/implementations/_archived/knowledge-graph.d.ts +3 -0
- package/dist/tools/implementations/_archived/knowledge-graph.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/knowledge-graph.js +278 -0
- package/dist/tools/implementations/_archived/knowledge-graph.js.map +1 -0
- package/dist/tools/implementations/_archived/plan-query.d.ts +3 -0
- package/dist/tools/implementations/_archived/plan-query.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/plan-query.js +63 -0
- package/dist/tools/implementations/_archived/plan-query.js.map +1 -0
- package/dist/tools/implementations/_archived/raw-content.d.ts +3 -0
- package/dist/tools/implementations/_archived/raw-content.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/raw-content.js +210 -0
- package/dist/tools/implementations/_archived/raw-content.js.map +1 -0
- package/dist/tools/implementations/_archived/similar-content.d.ts +3 -0
- package/dist/tools/implementations/_archived/similar-content.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/similar-content.js +64 -0
- package/dist/tools/implementations/_archived/similar-content.js.map +1 -0
- package/dist/tools/implementations/_archived/smart-sections.d.ts +3 -0
- package/dist/tools/implementations/_archived/smart-sections.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/smart-sections.js +471 -0
- package/dist/tools/implementations/_archived/smart-sections.js.map +1 -0
- package/dist/tools/implementations/_archived/synthesize.d.ts +3 -0
- package/dist/tools/implementations/_archived/synthesize.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/synthesize.js +193 -0
- package/dist/tools/implementations/_archived/synthesize.js.map +1 -0
- package/dist/tools/implementations/_archived/timeline.d.ts +3 -0
- package/dist/tools/implementations/_archived/timeline.d.ts.map +1 -0
- package/dist/tools/implementations/_archived/timeline.js +191 -0
- package/dist/tools/implementations/_archived/timeline.js.map +1 -0
- package/dist/tools/index.d.ts +3 -15
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +31 -57
- package/dist/tools/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { extractTypedInsights } from "../helpers/insights.js";
|
|
3
|
+
export const extractInsightsTool = {
|
|
4
|
+
name: "extract_insights",
|
|
5
|
+
description: "Extract specific types of insights across multiple content sources. Finds patterns, contradictions, consensus, or evolution of ideas.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
query: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "What insights to extract (e.g., 'productivity tips', 'AI risks', 'investment strategies')",
|
|
12
|
+
},
|
|
13
|
+
insightType: {
|
|
14
|
+
type: "string",
|
|
15
|
+
enum: ["patterns", "contradictions", "consensus", "evolution", "actionable", "warnings"],
|
|
16
|
+
description: "Type of insights to extract",
|
|
17
|
+
default: "patterns",
|
|
18
|
+
},
|
|
19
|
+
maxSources: {
|
|
20
|
+
type: "number",
|
|
21
|
+
description: "Maximum number of sources to analyze",
|
|
22
|
+
default: 15,
|
|
23
|
+
},
|
|
24
|
+
minConfidence: {
|
|
25
|
+
type: "number",
|
|
26
|
+
description: "Minimum confidence score for insights (0-1)",
|
|
27
|
+
default: 0.7,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ["query"],
|
|
31
|
+
},
|
|
32
|
+
modifies: false,
|
|
33
|
+
handler: async (client, args) => {
|
|
34
|
+
const schema = z.object({
|
|
35
|
+
query: z.string(),
|
|
36
|
+
insightType: z.enum(["patterns", "contradictions", "consensus", "evolution", "actionable", "warnings"]).optional().default("patterns"),
|
|
37
|
+
maxSources: z.number().optional().default(15),
|
|
38
|
+
minConfidence: z.number().min(0).max(1).optional().default(0.7),
|
|
39
|
+
});
|
|
40
|
+
const params = schema.parse(args);
|
|
41
|
+
// Search for relevant content
|
|
42
|
+
const searchResults = await client.searchContent(params.query, {
|
|
43
|
+
limit: params.maxSources,
|
|
44
|
+
enableConceptExpansion: true,
|
|
45
|
+
});
|
|
46
|
+
if (!searchResults || searchResults.length === 0) {
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
text: `No content found for extracting insights about: "${params.query}"`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
data: null,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// Extract insights based on type
|
|
58
|
+
const insights = extractTypedInsights(searchResults, params.query, params.insightType, params.minConfidence);
|
|
59
|
+
let responseText = `# π‘ Insight Extraction: "${params.query}"\n`;
|
|
60
|
+
responseText += `**Type:** ${params.insightType} | **Sources:** ${searchResults.length} | **Min Confidence:** ${(params.minConfidence * 100).toFixed(0)}%\n\n`;
|
|
61
|
+
if (insights.length === 0) {
|
|
62
|
+
responseText += `No ${params.insightType} insights found with confidence >= ${params.minConfidence}.\n`;
|
|
63
|
+
responseText += `Try lowering the confidence threshold or using a different insight type.\n`;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// Display insights by type
|
|
67
|
+
switch (params.insightType) {
|
|
68
|
+
case "patterns":
|
|
69
|
+
responseText += `## π Recurring Patterns\n\n`;
|
|
70
|
+
insights.forEach((insight, idx) => {
|
|
71
|
+
responseText += `### Pattern ${idx + 1}: ${insight.pattern}\n`;
|
|
72
|
+
responseText += `**Frequency:** Appears in ${insight.frequency}/${searchResults.length} sources\n`;
|
|
73
|
+
responseText += `**Confidence:** ${(insight.confidence * 100).toFixed(0)}%\n`;
|
|
74
|
+
responseText += `**Examples:**\n`;
|
|
75
|
+
insight.examples.slice(0, 3).forEach((ex) => {
|
|
76
|
+
responseText += `- "${ex.text}" *(${ex.source})*\n`;
|
|
77
|
+
});
|
|
78
|
+
responseText += `\n`;
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
case "actionable":
|
|
82
|
+
responseText += `## π― Actionable Insights\n\n`;
|
|
83
|
+
insights.forEach((insight, idx) => {
|
|
84
|
+
responseText += `### ${idx + 1}. ${insight.action}\n`;
|
|
85
|
+
responseText += `**Why:** ${insight.reasoning}\n`;
|
|
86
|
+
responseText += `**Priority:** ${insight.priority}\n`;
|
|
87
|
+
responseText += `**Evidence from:** ${insight.sources.length} sources\n`;
|
|
88
|
+
if (insight.steps && insight.steps.length > 0) {
|
|
89
|
+
responseText += `**Steps:**\n`;
|
|
90
|
+
insight.steps.forEach((step, i) => {
|
|
91
|
+
responseText += `${i + 1}. ${step}\n`;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
responseText += `\n`;
|
|
95
|
+
});
|
|
96
|
+
break;
|
|
97
|
+
default:
|
|
98
|
+
responseText += `## Insights Found\n\n`;
|
|
99
|
+
insights.forEach((insight, idx) => {
|
|
100
|
+
responseText += `${idx + 1}. ${insight.text || insight.pattern || "Insight"}\n`;
|
|
101
|
+
if (insight.confidence) {
|
|
102
|
+
responseText += ` Confidence: ${(insight.confidence * 100).toFixed(0)}%\n`;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// Summary statistics
|
|
107
|
+
responseText += `\n## π Extraction Summary\n`;
|
|
108
|
+
responseText += `- **Total Insights:** ${insights.length}\n`;
|
|
109
|
+
responseText += `- **Average Confidence:** ${(insights.reduce((sum, i) => sum + i.confidence, 0) / insights.length * 100).toFixed(0)}%\n`;
|
|
110
|
+
responseText += `- **Sources Analyzed:** ${searchResults.length}\n`;
|
|
111
|
+
const contributingSources = new Set(insights.flatMap((i) => i.sources || []));
|
|
112
|
+
responseText += `- **Contributing Sources:** ${contributingSources.size}\n`;
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
content: [
|
|
116
|
+
{
|
|
117
|
+
type: "text",
|
|
118
|
+
text: responseText,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
data: {
|
|
122
|
+
query: params.query,
|
|
123
|
+
insightType: params.insightType,
|
|
124
|
+
insights,
|
|
125
|
+
sources: searchResults,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=extract-insights.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-insights.js","sourceRoot":"","sources":["../../../../src/tools/implementations/_archived/extract-insights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,CAAC,MAAM,mBAAmB,GAAS;IACvC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAA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B;aACF;YACD,IAAI,EAAE;gBACJ,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,QAAQ;gBACR,OAAO,EAAE,aAAa;aACvB;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-connections.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementations/_archived/find-connections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,eAAO,MAAM,mBAAmB,EAAE,IA+GjC,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { analyzeConnections, groupConnectionsByType, getConnectionTypeEmoji, calculateNetworkStats } from "../helpers/connections.js";
|
|
3
|
+
export const findConnectionsTool = {
|
|
4
|
+
name: "find_connections",
|
|
5
|
+
description: "Discover connections and relationships between different pieces of content. Identifies causal links, contradictions, and complementary information.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
contentIds: {
|
|
10
|
+
type: "array",
|
|
11
|
+
items: {
|
|
12
|
+
type: "string",
|
|
13
|
+
},
|
|
14
|
+
description: "Array of content IDs to find connections between",
|
|
15
|
+
},
|
|
16
|
+
connectionType: {
|
|
17
|
+
type: "string",
|
|
18
|
+
enum: ["all", "causal", "contradictory", "complementary", "sequential"],
|
|
19
|
+
description: "Type of connections to find",
|
|
20
|
+
default: "all",
|
|
21
|
+
},
|
|
22
|
+
depth: {
|
|
23
|
+
type: "number",
|
|
24
|
+
description: "How many levels deep to search for connections (1-3)",
|
|
25
|
+
default: 1,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["contentIds"],
|
|
29
|
+
},
|
|
30
|
+
modifies: false,
|
|
31
|
+
handler: async (client, args) => {
|
|
32
|
+
const schema = z.object({
|
|
33
|
+
contentIds: z.array(z.string()).min(2),
|
|
34
|
+
connectionType: z.enum(["all", "causal", "contradictory", "complementary", "sequential"]).optional().default("all"),
|
|
35
|
+
depth: z.number().min(1).max(3).optional().default(1),
|
|
36
|
+
});
|
|
37
|
+
const params = schema.parse(args);
|
|
38
|
+
// Fetch all content items
|
|
39
|
+
const contents = await client.batchGetContent(params.contentIds, false);
|
|
40
|
+
if (!contents.results || contents.results.length < 2) {
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: "text",
|
|
45
|
+
text: "Unable to find connections. Need at least 2 valid content items.",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
data: null,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Analyze connections between content
|
|
52
|
+
const connections = analyzeConnections(contents.results, params.connectionType);
|
|
53
|
+
let responseText = `# π Content Connections Analysis\n`;
|
|
54
|
+
responseText += `**Analyzing:** ${contents.results.length} pieces of content\n`;
|
|
55
|
+
responseText += `**Connection Type:** ${params.connectionType}\n`;
|
|
56
|
+
responseText += `**Connections Found:** ${connections.length}\n\n`;
|
|
57
|
+
if (connections.length === 0) {
|
|
58
|
+
responseText += `No ${params.connectionType} connections found between the provided content.\n`;
|
|
59
|
+
responseText += `Try using connectionType='all' for broader analysis.\n`;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Group connections by type
|
|
63
|
+
const byType = groupConnectionsByType(connections);
|
|
64
|
+
Object.entries(byType).forEach(([type, conns]) => {
|
|
65
|
+
responseText += `## ${getConnectionTypeEmoji(type)} ${type} Connections (${conns.length})\n\n`;
|
|
66
|
+
conns.slice(0, 5).forEach((conn) => {
|
|
67
|
+
responseText += `### ${conn.source1.title} βοΈ ${conn.source2.title}\n`;
|
|
68
|
+
responseText += `**Relationship:** ${conn.relationship}\n`;
|
|
69
|
+
responseText += `**Strength:** ${conn.strength.toFixed(2)}\n`;
|
|
70
|
+
if (conn.explanation) {
|
|
71
|
+
responseText += `**Why:** ${conn.explanation}\n`;
|
|
72
|
+
}
|
|
73
|
+
if (conn.sharedConcepts && conn.sharedConcepts.length > 0) {
|
|
74
|
+
responseText += `**Shared Concepts:** ${conn.sharedConcepts.join(', ')}\n`;
|
|
75
|
+
}
|
|
76
|
+
responseText += `\n`;
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
// Network summary
|
|
80
|
+
responseText += `## π Connection Network Summary\n`;
|
|
81
|
+
const networkStats = calculateNetworkStats(connections, contents.results);
|
|
82
|
+
responseText += `- **Most Connected:** ${networkStats.mostConnected.title} (${networkStats.mostConnected.connectionCount} connections)\n`;
|
|
83
|
+
responseText += `- **Central Theme:** ${networkStats.centralTheme}\n`;
|
|
84
|
+
responseText += `- **Network Density:** ${networkStats.density}\n`;
|
|
85
|
+
if (params.depth > 1) {
|
|
86
|
+
responseText += `\n## π Extended Connections (Depth ${params.depth})\n`;
|
|
87
|
+
responseText += `*Searching for indirect connections through related content...*\n`;
|
|
88
|
+
responseText += `Use find_similar_content on highly connected items to explore further.\n`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
content: [
|
|
93
|
+
{
|
|
94
|
+
type: "text",
|
|
95
|
+
text: responseText,
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
data: {
|
|
99
|
+
connections,
|
|
100
|
+
contents: contents.results,
|
|
101
|
+
networkStats: connections.length > 0 ? calculateNetworkStats(connections, contents.results) : null,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=find-connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-connections.js","sourceRoot":"","sources":["../../../../src/tools/implementations/_archived/find-connections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,qBAAq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C;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,YAAY;iBACnB;aACF;YACD,IAAI,EAAE;gBACJ,WAAW;gBACX,QAAQ,EAAE,QAAQ,CAAC,OAAO;gBAC1B,YAAY,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;aACnG;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementations/_archived/instructions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,eAAO,MAAM,mBAAmB,EAAE,IA2FjC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { generateLLMInstructions } from "../../llm-instructions.js";
|
|
3
|
+
export const getInstructionsTool = {
|
|
4
|
+
name: "get_instructions",
|
|
5
|
+
description: "Get instructions for optimal MCP usage, including capabilities, best practices, and example workflows",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
topic: {
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "Specific topic for instructions (optional)",
|
|
12
|
+
enum: ["search", "synthesis", "retrieval", "general"],
|
|
13
|
+
},
|
|
14
|
+
includeExamples: {
|
|
15
|
+
type: "boolean",
|
|
16
|
+
description: "Include workflow examples",
|
|
17
|
+
default: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
modifies: false,
|
|
22
|
+
handler: async (client, args) => {
|
|
23
|
+
const schema = z.object({
|
|
24
|
+
topic: z.enum(["search", "synthesis", "retrieval", "general"]).optional(),
|
|
25
|
+
includeExamples: z.boolean().optional().default(true),
|
|
26
|
+
});
|
|
27
|
+
const params = schema.parse(args);
|
|
28
|
+
const instructions = generateLLMInstructions();
|
|
29
|
+
let responseText = `# Noverload MCP Usage Instructions\n\n`;
|
|
30
|
+
responseText += `## Version: ${instructions.version}\n\n`;
|
|
31
|
+
if (!params.topic || params.topic === "general") {
|
|
32
|
+
// Show all capabilities
|
|
33
|
+
responseText += `## Capabilities Overview\n\n`;
|
|
34
|
+
for (const [key, capability] of Object.entries(instructions.capabilities)) {
|
|
35
|
+
responseText += `### ${key.charAt(0).toUpperCase() + key.slice(1)}\n`;
|
|
36
|
+
responseText += `${capability.description}\n\n`;
|
|
37
|
+
responseText += `**Strengths:**\n`;
|
|
38
|
+
capability.strengths.forEach((s) => responseText += `- ${s}\n`);
|
|
39
|
+
responseText += `\n**When to use:**\n`;
|
|
40
|
+
capability.whenToUse.forEach((w) => responseText += `- ${w}\n`);
|
|
41
|
+
responseText += `\n`;
|
|
42
|
+
}
|
|
43
|
+
responseText += `## Best Practices\n\n`;
|
|
44
|
+
for (const [scenario, practice] of Object.entries(instructions.bestPractices)) {
|
|
45
|
+
responseText += `**${scenario.replace(/([A-Z])/g, ' $1').toLowerCase()}:** ${practice}\n`;
|
|
46
|
+
}
|
|
47
|
+
responseText += `\n`;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// Show specific capability
|
|
51
|
+
const capability = instructions.capabilities[params.topic];
|
|
52
|
+
if (capability) {
|
|
53
|
+
responseText += `## ${params.topic.charAt(0).toUpperCase() + params.topic.slice(1)} Capability\n\n`;
|
|
54
|
+
responseText += `${capability.description}\n\n`;
|
|
55
|
+
responseText += `### Strengths\n`;
|
|
56
|
+
capability.strengths.forEach(s => responseText += `- ${s}\n`);
|
|
57
|
+
responseText += `\n### Limitations\n`;
|
|
58
|
+
capability.limitations.forEach(l => responseText += `- ${l}\n`);
|
|
59
|
+
responseText += `\n### When to Use\n`;
|
|
60
|
+
capability.whenToUse.forEach(w => responseText += `- ${w}\n`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (params.includeExamples && instructions.exampleWorkflows.length > 0) {
|
|
64
|
+
responseText += `\n## Example Workflows\n\n`;
|
|
65
|
+
instructions.exampleWorkflows.forEach((example, idx) => {
|
|
66
|
+
responseText += `### ${idx + 1}. ${example.scenario}\n`;
|
|
67
|
+
responseText += `**Steps:**\n`;
|
|
68
|
+
example.steps.forEach((step, i) => responseText += `${i + 1}. ${step}\n`);
|
|
69
|
+
responseText += `**Expected Outcome:** ${example.expectedOutcome}\n\n`;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
responseText += `## Token Management\n\n`;
|
|
73
|
+
responseText += `- Search results limit: ${instructions.tokenManagement.searchResultsLimit}\n`;
|
|
74
|
+
responseText += `- Use chunking: ${instructions.tokenManagement.useChunking ? 'Yes' : 'No'}\n`;
|
|
75
|
+
responseText += `- Get summaries first: ${instructions.tokenManagement.summaryFirst ? 'Yes' : 'No'}\n`;
|
|
76
|
+
responseText += `- Max content per query: ${instructions.tokenManagement.maxContentPerQuery.toLocaleString()} tokens\n`;
|
|
77
|
+
return {
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
type: "text",
|
|
81
|
+
text: responseText,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
data: instructions,
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../../../src/tools/implementations/_archived/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,CAAC,MAAM,mBAAmB,GAAS;IACvC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,uGAAuG;IACpH,WAAW,EAAE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AA4B,YAAY,CAAC,eAAe,CAAC,kBAAkB,CAAC,cAAc,EAAE,WAAW,CAAC;QAExH,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,YAAY;iBACnB;aACF;YACD,IAAI,EAAE,YAAY;SACnB,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-graph.d.ts","sourceRoot":"","sources":["../../../../src/tools/implementations/_archived/knowledge-graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,eAAO,MAAM,uBAAuB,EAAE,IAyTrC,CAAC"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const buildKnowledgeGraphTool = {
|
|
3
|
+
name: "build_knowledge_graph",
|
|
4
|
+
description: "Create a knowledge graph showing relationships between concepts, topics, and content in your saved knowledge base",
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
topic: {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "Central topic for the knowledge graph",
|
|
11
|
+
},
|
|
12
|
+
maxNodes: {
|
|
13
|
+
type: "number",
|
|
14
|
+
description: "Maximum number of nodes in the graph",
|
|
15
|
+
default: 20,
|
|
16
|
+
},
|
|
17
|
+
depth: {
|
|
18
|
+
type: "number",
|
|
19
|
+
description: "How many levels of connections to explore (1-3)",
|
|
20
|
+
default: 2,
|
|
21
|
+
},
|
|
22
|
+
includeStats: {
|
|
23
|
+
type: "boolean",
|
|
24
|
+
description: "Include statistics about connections",
|
|
25
|
+
default: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ["topic"],
|
|
29
|
+
},
|
|
30
|
+
modifies: false,
|
|
31
|
+
handler: async (client, args) => {
|
|
32
|
+
const schema = z.object({
|
|
33
|
+
topic: z.string(),
|
|
34
|
+
maxNodes: z.number().optional().default(20),
|
|
35
|
+
depth: z.number().min(1).max(3).optional().default(2),
|
|
36
|
+
includeStats: z.boolean().optional().default(true),
|
|
37
|
+
});
|
|
38
|
+
const params = schema.parse(args);
|
|
39
|
+
// Search for content related to the topic
|
|
40
|
+
const searchResults = await client.searchContent(params.topic, {
|
|
41
|
+
limit: params.maxNodes * 2, // Get extra for better graph
|
|
42
|
+
enableConceptExpansion: true,
|
|
43
|
+
});
|
|
44
|
+
if (!searchResults || searchResults.length === 0) {
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: "text",
|
|
49
|
+
text: `No content found for topic: "${params.topic}". Cannot build knowledge graph without saved content.`,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
data: null,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Build the graph structure
|
|
56
|
+
const nodes = new Map();
|
|
57
|
+
const edges = new Map();
|
|
58
|
+
// Add central topic node
|
|
59
|
+
nodes.set(params.topic.toLowerCase(), {
|
|
60
|
+
id: params.topic.toLowerCase(),
|
|
61
|
+
label: params.topic,
|
|
62
|
+
type: "central",
|
|
63
|
+
weight: searchResults.length,
|
|
64
|
+
});
|
|
65
|
+
// Process search results to extract concepts and relationships
|
|
66
|
+
searchResults.forEach((item) => {
|
|
67
|
+
// Add content as a node
|
|
68
|
+
const contentId = `content_${item.id}`;
|
|
69
|
+
nodes.set(contentId, {
|
|
70
|
+
id: contentId,
|
|
71
|
+
label: item.title || "Untitled",
|
|
72
|
+
type: "content",
|
|
73
|
+
contentType: item.contentType,
|
|
74
|
+
url: item.url,
|
|
75
|
+
weight: 1,
|
|
76
|
+
});
|
|
77
|
+
// Connect content to central topic
|
|
78
|
+
if (!edges.has(params.topic.toLowerCase())) {
|
|
79
|
+
edges.set(params.topic.toLowerCase(), new Set());
|
|
80
|
+
}
|
|
81
|
+
edges.get(params.topic.toLowerCase()).add(contentId);
|
|
82
|
+
// Extract and add concept nodes from tags and summary
|
|
83
|
+
if (item.tags && Array.isArray(item.tags)) {
|
|
84
|
+
item.tags.forEach((tag) => {
|
|
85
|
+
const tagId = `tag_${tag.toLowerCase()}`;
|
|
86
|
+
if (!nodes.has(tagId)) {
|
|
87
|
+
nodes.set(tagId, {
|
|
88
|
+
id: tagId,
|
|
89
|
+
label: tag,
|
|
90
|
+
type: "concept",
|
|
91
|
+
weight: 0,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// Increase weight for repeated concepts
|
|
95
|
+
nodes.get(tagId).weight++;
|
|
96
|
+
// Connect tag to content
|
|
97
|
+
if (!edges.has(contentId)) {
|
|
98
|
+
edges.set(contentId, new Set());
|
|
99
|
+
}
|
|
100
|
+
edges.get(contentId).add(tagId);
|
|
101
|
+
// Connect tag to central topic
|
|
102
|
+
edges.get(params.topic.toLowerCase()).add(tagId);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// Extract key concepts from summary if available
|
|
106
|
+
if (item.summary) {
|
|
107
|
+
const summary = typeof item.summary === 'string'
|
|
108
|
+
? item.summary
|
|
109
|
+
: item.summary.one_sentence || item.summary.text || "";
|
|
110
|
+
// Simple concept extraction (words that appear to be important)
|
|
111
|
+
const words = summary.toLowerCase().split(/\s+/);
|
|
112
|
+
const importantWords = words
|
|
113
|
+
.filter((w) => w.length > 6 && !['through', 'between', 'because', 'without'].includes(w))
|
|
114
|
+
.slice(0, 3);
|
|
115
|
+
importantWords.forEach((word) => {
|
|
116
|
+
const conceptId = `concept_${word}`;
|
|
117
|
+
if (!nodes.has(conceptId) && nodes.size < params.maxNodes) {
|
|
118
|
+
nodes.set(conceptId, {
|
|
119
|
+
id: conceptId,
|
|
120
|
+
label: word,
|
|
121
|
+
type: "derived",
|
|
122
|
+
weight: 1,
|
|
123
|
+
});
|
|
124
|
+
// Connect to content
|
|
125
|
+
if (!edges.has(contentId)) {
|
|
126
|
+
edges.set(contentId, new Set());
|
|
127
|
+
}
|
|
128
|
+
edges.get(contentId).add(conceptId);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
// For depth > 1, find second-level connections
|
|
134
|
+
if (params.depth > 1) {
|
|
135
|
+
const firstLevelNodes = Array.from(edges.get(params.topic.toLowerCase()) || []);
|
|
136
|
+
for (const nodeId of firstLevelNodes.slice(0, 10)) { // Limit for performance
|
|
137
|
+
if (nodeId.startsWith('tag_') || nodeId.startsWith('concept_')) {
|
|
138
|
+
// Find content that shares this concept
|
|
139
|
+
const concept = nodes.get(nodeId)?.label;
|
|
140
|
+
if (concept) {
|
|
141
|
+
const relatedResults = await client.searchContent(concept, {
|
|
142
|
+
limit: 5,
|
|
143
|
+
enableConceptExpansion: false,
|
|
144
|
+
});
|
|
145
|
+
relatedResults?.forEach((item) => {
|
|
146
|
+
const relatedId = `related_${item.id}`;
|
|
147
|
+
if (!nodes.has(relatedId) && nodes.size < params.maxNodes) {
|
|
148
|
+
nodes.set(relatedId, {
|
|
149
|
+
id: relatedId,
|
|
150
|
+
label: item.title || "Related Content",
|
|
151
|
+
type: "related",
|
|
152
|
+
contentType: item.contentType,
|
|
153
|
+
url: item.url,
|
|
154
|
+
weight: 1,
|
|
155
|
+
});
|
|
156
|
+
// Connect to the concept
|
|
157
|
+
if (!edges.has(nodeId)) {
|
|
158
|
+
edges.set(nodeId, new Set());
|
|
159
|
+
}
|
|
160
|
+
edges.get(nodeId).add(relatedId);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Format response
|
|
168
|
+
let responseText = `# πΈοΈ Knowledge Graph: "${params.topic}"\n`;
|
|
169
|
+
responseText += `**Nodes:** ${nodes.size} | **Depth:** ${params.depth}\n\n`;
|
|
170
|
+
// Node breakdown
|
|
171
|
+
const nodeTypes = new Map();
|
|
172
|
+
nodes.forEach(node => {
|
|
173
|
+
nodeTypes.set(node.type, (nodeTypes.get(node.type) || 0) + 1);
|
|
174
|
+
});
|
|
175
|
+
responseText += `## π Graph Structure\n`;
|
|
176
|
+
responseText += `- **Central Topic:** ${params.topic}\n`;
|
|
177
|
+
nodeTypes.forEach((count, type) => {
|
|
178
|
+
const typeEmoji = {
|
|
179
|
+
content: "π",
|
|
180
|
+
concept: "π‘",
|
|
181
|
+
derived: "π",
|
|
182
|
+
related: "π",
|
|
183
|
+
central: "π―",
|
|
184
|
+
};
|
|
185
|
+
responseText += `- **${typeEmoji[type] || "β’"} ${type}:** ${count} nodes\n`;
|
|
186
|
+
});
|
|
187
|
+
responseText += `\n`;
|
|
188
|
+
// Key concepts (highest weight nodes)
|
|
189
|
+
const conceptNodes = Array.from(nodes.values())
|
|
190
|
+
.filter(n => n.type === 'concept' || n.type === 'derived')
|
|
191
|
+
.sort((a, b) => b.weight - a.weight)
|
|
192
|
+
.slice(0, 10);
|
|
193
|
+
if (conceptNodes.length > 0) {
|
|
194
|
+
responseText += `## π‘ Key Concepts\n`;
|
|
195
|
+
conceptNodes.forEach((node, idx) => {
|
|
196
|
+
responseText += `${idx + 1}. **${node.label}** (strength: ${node.weight})\n`;
|
|
197
|
+
});
|
|
198
|
+
responseText += `\n`;
|
|
199
|
+
}
|
|
200
|
+
// Content clusters
|
|
201
|
+
const contentNodes = Array.from(nodes.values())
|
|
202
|
+
.filter(n => n.type === 'content')
|
|
203
|
+
.slice(0, 10);
|
|
204
|
+
if (contentNodes.length > 0) {
|
|
205
|
+
responseText += `## π Core Content\n`;
|
|
206
|
+
contentNodes.forEach((node, idx) => {
|
|
207
|
+
const typeIcons = {
|
|
208
|
+
youtube: "πΊ",
|
|
209
|
+
x_twitter: "π",
|
|
210
|
+
reddit: "π",
|
|
211
|
+
article: "π",
|
|
212
|
+
pdf: "π"
|
|
213
|
+
};
|
|
214
|
+
const icon = typeIcons[node.contentType] || "π";
|
|
215
|
+
responseText += `${idx + 1}. ${icon} [${node.label}](${node.url})\n`;
|
|
216
|
+
});
|
|
217
|
+
responseText += `\n`;
|
|
218
|
+
}
|
|
219
|
+
// Connection statistics
|
|
220
|
+
if (params.includeStats) {
|
|
221
|
+
responseText += `## π Connection Statistics\n`;
|
|
222
|
+
// Find most connected nodes
|
|
223
|
+
const connectionCounts = new Map();
|
|
224
|
+
edges.forEach((connections, nodeId) => {
|
|
225
|
+
connectionCounts.set(nodeId, connections.size);
|
|
226
|
+
});
|
|
227
|
+
const mostConnected = Array.from(connectionCounts.entries())
|
|
228
|
+
.sort((a, b) => b[1] - a[1])
|
|
229
|
+
.slice(0, 5);
|
|
230
|
+
responseText += `**Most Connected Nodes:**\n`;
|
|
231
|
+
mostConnected.forEach(([nodeId, count]) => {
|
|
232
|
+
const node = nodes.get(nodeId);
|
|
233
|
+
if (node) {
|
|
234
|
+
responseText += `- ${node.label}: ${count} connections\n`;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
responseText += `\n`;
|
|
238
|
+
// Graph density
|
|
239
|
+
const possibleEdges = nodes.size * (nodes.size - 1) / 2;
|
|
240
|
+
const actualEdges = Array.from(edges.values()).reduce((sum, set) => sum + set.size, 0);
|
|
241
|
+
const density = ((actualEdges / possibleEdges) * 100).toFixed(1);
|
|
242
|
+
responseText += `**Graph Metrics:**\n`;
|
|
243
|
+
responseText += `- Density: ${density}%\n`;
|
|
244
|
+
responseText += `- Average connections: ${(actualEdges / nodes.size).toFixed(1)}\n`;
|
|
245
|
+
responseText += `- Total edges: ${actualEdges}\n`;
|
|
246
|
+
}
|
|
247
|
+
// Visualization suggestion
|
|
248
|
+
responseText += `\n## π¨ Visualization\n`;
|
|
249
|
+
responseText += `The knowledge graph contains:\n`;
|
|
250
|
+
responseText += `- ${nodes.size} nodes representing concepts and content\n`;
|
|
251
|
+
responseText += `- ${Array.from(edges.values()).reduce((sum, set) => sum + set.size, 0)} edges showing relationships\n\n`;
|
|
252
|
+
responseText += `π‘ **Tip:** Use the graph data in the response to create visual representations with tools like D3.js or Graphviz.\n`;
|
|
253
|
+
// Convert to serializable format
|
|
254
|
+
const graphData = {
|
|
255
|
+
nodes: Array.from(nodes.values()),
|
|
256
|
+
edges: Array.from(edges.entries()).flatMap(([source, targets]) => Array.from(targets).map(target => ({ source, target }))),
|
|
257
|
+
};
|
|
258
|
+
return {
|
|
259
|
+
content: [
|
|
260
|
+
{
|
|
261
|
+
type: "text",
|
|
262
|
+
text: responseText,
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
data: {
|
|
266
|
+
topic: params.topic,
|
|
267
|
+
graph: graphData,
|
|
268
|
+
statistics: {
|
|
269
|
+
nodeCount: nodes.size,
|
|
270
|
+
edgeCount: graphData.edges.length,
|
|
271
|
+
nodeTypes: Object.fromEntries(nodeTypes),
|
|
272
|
+
depth: params.depth,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
//# sourceMappingURL=knowledge-graph.js.map
|