@elizaos/plugin-research 0.1.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 +400 -0
- package/dist/index.cjs +9366 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +9284 -0
- package/dist/index.js.map +1 -0
- package/package.json +80 -0
- package/src/__tests__/action-chaining.test.ts +532 -0
- package/src/__tests__/actions.test.ts +118 -0
- package/src/__tests__/cache-rate-limiter.test.ts +303 -0
- package/src/__tests__/content-extractors.test.ts +26 -0
- package/src/__tests__/deepresearch-bench-integration.test.ts +520 -0
- package/src/__tests__/deepresearch-bench-simplified.e2e.test.ts +290 -0
- package/src/__tests__/deepresearch-bench.e2e.test.ts +376 -0
- package/src/__tests__/e2e.test.ts +1870 -0
- package/src/__tests__/multi-benchmark-runner.ts +427 -0
- package/src/__tests__/providers.test.ts +156 -0
- package/src/__tests__/real-world.e2e.test.ts +788 -0
- package/src/__tests__/research-scenarios.test.ts +755 -0
- package/src/__tests__/research.e2e.test.ts +704 -0
- package/src/__tests__/research.test.ts +174 -0
- package/src/__tests__/search-providers.test.ts +174 -0
- package/src/__tests__/single-benchmark-runner.ts +735 -0
- package/src/__tests__/test-search-providers.ts +171 -0
- package/src/__tests__/verify-apis.test.ts +82 -0
- package/src/actions.ts +1677 -0
- package/src/benchmark/deepresearch-benchmark.ts +369 -0
- package/src/evaluation/research-evaluator.ts +444 -0
- package/src/examples/api-integration.md +498 -0
- package/src/examples/browserbase-integration.md +132 -0
- package/src/examples/debug-research-query.ts +162 -0
- package/src/examples/defi-code-scenarios.md +536 -0
- package/src/examples/defi-implementation-guide.md +454 -0
- package/src/examples/eliza-research-example.ts +142 -0
- package/src/examples/fix-renewable-energy-research.ts +209 -0
- package/src/examples/research-scenarios.md +408 -0
- package/src/examples/run-complete-renewable-research.ts +303 -0
- package/src/examples/run-deep-research.ts +352 -0
- package/src/examples/run-logged-research.ts +304 -0
- package/src/examples/run-real-research.ts +151 -0
- package/src/examples/save-research-output.ts +133 -0
- package/src/examples/test-file-logging.ts +199 -0
- package/src/examples/test-real-research.ts +67 -0
- package/src/examples/test-renewable-energy-research.ts +229 -0
- package/src/index.ts +28 -0
- package/src/integrations/cache.ts +128 -0
- package/src/integrations/content-extractors/firecrawl.ts +314 -0
- package/src/integrations/content-extractors/pdf-extractor.ts +350 -0
- package/src/integrations/content-extractors/playwright.ts +420 -0
- package/src/integrations/factory.ts +419 -0
- package/src/integrations/index.ts +18 -0
- package/src/integrations/rate-limiter.ts +181 -0
- package/src/integrations/search-providers/academic.ts +290 -0
- package/src/integrations/search-providers/exa.ts +205 -0
- package/src/integrations/search-providers/npm.ts +330 -0
- package/src/integrations/search-providers/pypi.ts +211 -0
- package/src/integrations/search-providers/serpapi.ts +277 -0
- package/src/integrations/search-providers/serper.ts +358 -0
- package/src/integrations/search-providers/stagehand-google.ts +87 -0
- package/src/integrations/search-providers/tavily.ts +187 -0
- package/src/processing/relevance-analyzer.ts +353 -0
- package/src/processing/research-logger.ts +450 -0
- package/src/processing/result-processor.ts +372 -0
- package/src/prompts/research-prompts.ts +419 -0
- package/src/providers/cacheProvider.ts +164 -0
- package/src/providers.ts +173 -0
- package/src/service.ts +2588 -0
- package/src/services/swe-bench.ts +286 -0
- package/src/strategies/research-strategies.ts +790 -0
- package/src/types/pdf-parse.d.ts +34 -0
- package/src/types.ts +551 -0
- package/src/verification/claim-verifier.ts +443 -0
package/src/providers.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Provider,
|
|
3
|
+
IAgentRuntime,
|
|
4
|
+
Memory,
|
|
5
|
+
State,
|
|
6
|
+
ProviderResult,
|
|
7
|
+
} from '@elizaos/core';
|
|
8
|
+
import { ResearchService } from './service';
|
|
9
|
+
import { ResearchStatus, ResearchPhase } from './types';
|
|
10
|
+
import { validateActionKeywords, validateActionRegex } from "@elizaos/core";
|
|
11
|
+
|
|
12
|
+
export const activeResearchProvider: Provider = {
|
|
13
|
+
name: 'active_research',
|
|
14
|
+
description: 'Provides information about active research projects',
|
|
15
|
+
|
|
16
|
+
dynamic: true,
|
|
17
|
+
relevanceKeywords: [
|
|
18
|
+
"active",
|
|
19
|
+
"research",
|
|
20
|
+
"activeresearchprovider",
|
|
21
|
+
"plugin",
|
|
22
|
+
"status",
|
|
23
|
+
"state",
|
|
24
|
+
"context",
|
|
25
|
+
"info",
|
|
26
|
+
"details",
|
|
27
|
+
"chat",
|
|
28
|
+
"conversation",
|
|
29
|
+
"agent",
|
|
30
|
+
"room",
|
|
31
|
+
"channel",
|
|
32
|
+
],
|
|
33
|
+
async get(runtime: IAgentRuntime, message: Memory, state: State): Promise<ProviderResult> { const __providerKeywords = ["active", "research", "activeresearchprovider", "plugin", "status", "state", "context", "info", "details", "chat", "conversation", "agent", "room", "channel"];
|
|
34
|
+
const __providerRegex = new RegExp(`\\b(${__providerKeywords.join("|")})\\b`, "i");
|
|
35
|
+
const __recentMessages = state?.recentMessagesData || [];
|
|
36
|
+
const __isRelevant =
|
|
37
|
+
validateActionKeywords(message, __recentMessages, __providerKeywords) ||
|
|
38
|
+
validateActionRegex(message, __recentMessages, __providerRegex);
|
|
39
|
+
if (!__isRelevant) {
|
|
40
|
+
return { text: "" };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const researchService = runtime.getService<ResearchService>('research');
|
|
45
|
+
if (!researchService) return { text: '' };
|
|
46
|
+
|
|
47
|
+
const activeProjects = await researchService.getActiveProjects();
|
|
48
|
+
if (activeProjects.length === 0) return { text: '' };
|
|
49
|
+
|
|
50
|
+
const projectInfo = activeProjects.map(project => {
|
|
51
|
+
const phaseProgress = Math.floor(
|
|
52
|
+
(Object.keys(ResearchPhase).indexOf(project.phase) / (Object.keys(ResearchPhase).length - 1)) * 100
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return `- Research on "${project.query}" (ID: ${project.id})
|
|
56
|
+
Status: ${project.status}
|
|
57
|
+
Phase: ${project.phase} (${phaseProgress}% complete)
|
|
58
|
+
Findings collected: ${project.findings.length}
|
|
59
|
+
Sources: ${project.sources.length}`;
|
|
60
|
+
}).join('\n\n');
|
|
61
|
+
|
|
62
|
+
return { text: `Active Research Projects:\n${projectInfo}` };
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const completedResearchProvider: Provider = {
|
|
67
|
+
name: 'completed_research',
|
|
68
|
+
description: 'Provides information about completed research projects with reports',
|
|
69
|
+
|
|
70
|
+
dynamic: true,
|
|
71
|
+
relevanceKeywords: [
|
|
72
|
+
"completed",
|
|
73
|
+
"research",
|
|
74
|
+
"completedresearchprovider",
|
|
75
|
+
"plugin",
|
|
76
|
+
"status",
|
|
77
|
+
"state",
|
|
78
|
+
"context",
|
|
79
|
+
"info",
|
|
80
|
+
"details",
|
|
81
|
+
"chat",
|
|
82
|
+
"conversation",
|
|
83
|
+
"agent",
|
|
84
|
+
"room",
|
|
85
|
+
"channel",
|
|
86
|
+
],
|
|
87
|
+
async get(runtime: IAgentRuntime, message: Memory, state: State): Promise<ProviderResult> { const __providerKeywords = ["completed", "research", "completedresearchprovider", "plugin", "status", "state", "context", "info", "details", "chat", "conversation", "agent", "room", "channel"];
|
|
88
|
+
const __providerRegex = new RegExp(`\\b(${__providerKeywords.join("|")})\\b`, "i");
|
|
89
|
+
const __recentMessages = state?.recentMessagesData || [];
|
|
90
|
+
const __isRelevant =
|
|
91
|
+
validateActionKeywords(message, __recentMessages, __providerKeywords) ||
|
|
92
|
+
validateActionRegex(message, __recentMessages, __providerRegex);
|
|
93
|
+
if (!__isRelevant) {
|
|
94
|
+
return { text: "" };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
const researchService = runtime.getService<ResearchService>('research');
|
|
99
|
+
if (!researchService) return { text: '' };
|
|
100
|
+
|
|
101
|
+
const allProjects = await researchService.getAllProjects();
|
|
102
|
+
const completedProjects = allProjects.filter(p => p.status === ResearchStatus.COMPLETED);
|
|
103
|
+
|
|
104
|
+
if (completedProjects.length === 0) return { text: '' };
|
|
105
|
+
|
|
106
|
+
const projectInfo = completedProjects
|
|
107
|
+
.slice(-5) // Show last 5 completed projects
|
|
108
|
+
.map(project => {
|
|
109
|
+
const reportSummary = project.report
|
|
110
|
+
? `Report available (${project.report.sections.length} sections)`
|
|
111
|
+
: 'Report generation pending';
|
|
112
|
+
|
|
113
|
+
return `- "${project.query}" (ID: ${project.id})
|
|
114
|
+
Completed: ${new Date(project.completedAt || project.updatedAt).toLocaleDateString()}
|
|
115
|
+
${reportSummary}
|
|
116
|
+
Findings: ${project.findings.length}, Sources: ${project.sources.length}`;
|
|
117
|
+
}).join('\n\n');
|
|
118
|
+
|
|
119
|
+
return { text: `Recently Completed Research:\n${projectInfo}` };
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const researchCapabilitiesProvider: Provider = {
|
|
124
|
+
name: 'research_capabilities',
|
|
125
|
+
description: 'Provides information about research service capabilities',
|
|
126
|
+
|
|
127
|
+
dynamic: true,
|
|
128
|
+
relevanceKeywords: [
|
|
129
|
+
"research",
|
|
130
|
+
"capabilities",
|
|
131
|
+
"researchcapabilitiesprovider",
|
|
132
|
+
"plugin",
|
|
133
|
+
"status",
|
|
134
|
+
"state",
|
|
135
|
+
"context",
|
|
136
|
+
"info",
|
|
137
|
+
"details",
|
|
138
|
+
"chat",
|
|
139
|
+
"conversation",
|
|
140
|
+
"agent",
|
|
141
|
+
"room",
|
|
142
|
+
"channel",
|
|
143
|
+
],
|
|
144
|
+
async get(runtime: IAgentRuntime, message: Memory, state: State): Promise<ProviderResult> { const __providerKeywords = ["research", "capabilities", "researchcapabilitiesprovider", "plugin", "status", "state", "context", "info", "details", "chat", "conversation", "agent", "room", "channel"];
|
|
145
|
+
const __providerRegex = new RegExp(`\\b(${__providerKeywords.join("|")})\\b`, "i");
|
|
146
|
+
const __recentMessages = state?.recentMessagesData || [];
|
|
147
|
+
const __isRelevant =
|
|
148
|
+
validateActionKeywords(message, __recentMessages, __providerKeywords) ||
|
|
149
|
+
validateActionRegex(message, __recentMessages, __providerRegex);
|
|
150
|
+
if (!__isRelevant) {
|
|
151
|
+
return { text: "" };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
const researchService = runtime.getService<ResearchService>('research');
|
|
156
|
+
|
|
157
|
+
// Always return capabilities info, even if service is not currently available
|
|
158
|
+
return { text: `Research Capabilities:
|
|
159
|
+
- Deep multi-phase internet research
|
|
160
|
+
- Automatic source collection and verification
|
|
161
|
+
- Intelligent analysis and synthesis
|
|
162
|
+
- Comprehensive report generation with citations
|
|
163
|
+
- Research phases: planning, searching, analyzing, synthesizing, reporting
|
|
164
|
+
- Can pause and resume research projects
|
|
165
|
+
- Supports multiple concurrent research projects` };
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export const researchProviders = [
|
|
170
|
+
activeResearchProvider,
|
|
171
|
+
completedResearchProvider,
|
|
172
|
+
researchCapabilitiesProvider,
|
|
173
|
+
];
|