@itachisol/plugin-x402-swarms 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/LICENSE +21 -0
- package/README.md +323 -0
- package/dist/actions/delegateToSwarm.d.ts +8 -0
- package/dist/actions/delegateToSwarm.d.ts.map +1 -0
- package/dist/actions/delegateToSwarm.js +296 -0
- package/dist/actions/delegateToSwarm.js.map +1 -0
- package/dist/actions/delegateToSwarmWithPayment.d.ts +8 -0
- package/dist/actions/delegateToSwarmWithPayment.d.ts.map +1 -0
- package/dist/actions/delegateToSwarmWithPayment.js +323 -0
- package/dist/actions/delegateToSwarmWithPayment.js.map +1 -0
- package/dist/actions/discoverServices.d.ts +3 -0
- package/dist/actions/discoverServices.d.ts.map +1 -0
- package/dist/actions/discoverServices.js +63 -0
- package/dist/actions/discoverServices.js.map +1 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +6 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/payForService.d.ts +3 -0
- package/dist/actions/payForService.d.ts.map +1 -0
- package/dist/actions/payForService.js +115 -0
- package/dist/actions/payForService.js.map +1 -0
- package/dist/actions/runSwarmAgent.d.ts +7 -0
- package/dist/actions/runSwarmAgent.d.ts.map +1 -0
- package/dist/actions/runSwarmAgent.js +131 -0
- package/dist/actions/runSwarmAgent.js.map +1 -0
- package/dist/client/index.d.ts +512 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +469 -0
- package/dist/client/index.js.map +1 -0
- package/dist/evaluators/paymentEvaluator.d.ts +7 -0
- package/dist/evaluators/paymentEvaluator.d.ts.map +1 -0
- package/dist/evaluators/paymentEvaluator.js +104 -0
- package/dist/evaluators/paymentEvaluator.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/marketing/index.d.ts +7 -0
- package/dist/marketing/index.d.ts.map +1 -0
- package/dist/marketing/index.js +7 -0
- package/dist/marketing/index.js.map +1 -0
- package/dist/marketing/milestoneAgent.d.ts +54 -0
- package/dist/marketing/milestoneAgent.d.ts.map +1 -0
- package/dist/marketing/milestoneAgent.js +121 -0
- package/dist/marketing/milestoneAgent.js.map +1 -0
- package/dist/marketing/tweetTemplates.d.ts +32 -0
- package/dist/marketing/tweetTemplates.d.ts.map +1 -0
- package/dist/marketing/tweetTemplates.js +60 -0
- package/dist/marketing/tweetTemplates.js.map +1 -0
- package/dist/marketing/xMonitor.d.ts +51 -0
- package/dist/marketing/xMonitor.d.ts.map +1 -0
- package/dist/marketing/xMonitor.js +141 -0
- package/dist/marketing/xMonitor.js.map +1 -0
- package/dist/providers/x402Provider.d.ts +7 -0
- package/dist/providers/x402Provider.d.ts.map +1 -0
- package/dist/providers/x402Provider.js +72 -0
- package/dist/providers/x402Provider.js.map +1 -0
- package/dist/providers/x402ServerProvider.d.ts +7 -0
- package/dist/providers/x402ServerProvider.d.ts.map +1 -0
- package/dist/providers/x402ServerProvider.js +48 -0
- package/dist/providers/x402ServerProvider.js.map +1 -0
- package/dist/routes/advancedRoutes.d.ts +5 -0
- package/dist/routes/advancedRoutes.d.ts.map +1 -0
- package/dist/routes/advancedRoutes.js +869 -0
- package/dist/routes/advancedRoutes.js.map +1 -0
- package/dist/routes/batchRoutes.d.ts +13 -0
- package/dist/routes/batchRoutes.d.ts.map +1 -0
- package/dist/routes/batchRoutes.js +496 -0
- package/dist/routes/batchRoutes.js.map +1 -0
- package/dist/routes/codeAuditRoutes.d.ts +6 -0
- package/dist/routes/codeAuditRoutes.d.ts.map +1 -0
- package/dist/routes/codeAuditRoutes.js +415 -0
- package/dist/routes/codeAuditRoutes.js.map +1 -0
- package/dist/routes/contentRoutes.d.ts +5 -0
- package/dist/routes/contentRoutes.d.ts.map +1 -0
- package/dist/routes/contentRoutes.js +370 -0
- package/dist/routes/contentRoutes.js.map +1 -0
- package/dist/routes/cryptoAnalysisRoutes.d.ts +5 -0
- package/dist/routes/cryptoAnalysisRoutes.d.ts.map +1 -0
- package/dist/routes/cryptoAnalysisRoutes.js +641 -0
- package/dist/routes/cryptoAnalysisRoutes.js.map +1 -0
- package/dist/routes/cryptoRoutes.d.ts +5 -0
- package/dist/routes/cryptoRoutes.d.ts.map +1 -0
- package/dist/routes/cryptoRoutes.js +1225 -0
- package/dist/routes/cryptoRoutes.js.map +1 -0
- package/dist/routes/heliusDataRoutes.d.ts +14 -0
- package/dist/routes/heliusDataRoutes.d.ts.map +1 -0
- package/dist/routes/heliusDataRoutes.js +388 -0
- package/dist/routes/heliusDataRoutes.js.map +1 -0
- package/dist/routes/taskRoutes.d.ts +5 -0
- package/dist/routes/taskRoutes.d.ts.map +1 -0
- package/dist/routes/taskRoutes.js +574 -0
- package/dist/routes/taskRoutes.js.map +1 -0
- package/dist/routes/tradingRoutes.d.ts +5 -0
- package/dist/routes/tradingRoutes.d.ts.map +1 -0
- package/dist/routes/tradingRoutes.js +500 -0
- package/dist/routes/tradingRoutes.js.map +1 -0
- package/dist/routes/walletAnalyzerRoutes.d.ts +12 -0
- package/dist/routes/walletAnalyzerRoutes.d.ts.map +1 -0
- package/dist/routes/walletAnalyzerRoutes.js +316 -0
- package/dist/routes/walletAnalyzerRoutes.js.map +1 -0
- package/dist/routes/x402Routes.d.ts +9 -0
- package/dist/routes/x402Routes.d.ts.map +1 -0
- package/dist/routes/x402Routes.js +474 -0
- package/dist/routes/x402Routes.js.map +1 -0
- package/dist/schemas/budgetState.d.ts +250 -0
- package/dist/schemas/budgetState.d.ts.map +1 -0
- package/dist/schemas/budgetState.js +20 -0
- package/dist/schemas/budgetState.js.map +1 -0
- package/dist/schemas/endpointScores.d.ts +182 -0
- package/dist/schemas/endpointScores.d.ts.map +1 -0
- package/dist/schemas/endpointScores.js +17 -0
- package/dist/schemas/endpointScores.js.map +1 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +4 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/paymentHistory.d.ts +284 -0
- package/dist/schemas/paymentHistory.d.ts.map +1 -0
- package/dist/schemas/paymentHistory.js +24 -0
- package/dist/schemas/paymentHistory.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/x402Gate.d.ts +56 -0
- package/dist/server/x402Gate.d.ts.map +1 -0
- package/dist/server/x402Gate.js +240 -0
- package/dist/server/x402Gate.js.map +1 -0
- package/dist/server/x402ServerService.d.ts +30 -0
- package/dist/server/x402ServerService.d.ts.map +1 -0
- package/dist/server/x402ServerService.js +79 -0
- package/dist/server/x402ServerService.js.map +1 -0
- package/dist/services/paymentMemoryService.d.ts +73 -0
- package/dist/services/paymentMemoryService.d.ts.map +1 -0
- package/dist/services/paymentMemoryService.js +247 -0
- package/dist/services/paymentMemoryService.js.map +1 -0
- package/dist/services/swarmsService.d.ts +66 -0
- package/dist/services/swarmsService.d.ts.map +1 -0
- package/dist/services/swarmsService.js +102 -0
- package/dist/services/swarmsService.js.map +1 -0
- package/dist/services/x402WalletService.d.ts +57 -0
- package/dist/services/x402WalletService.d.ts.map +1 -0
- package/dist/services/x402WalletService.js +258 -0
- package/dist/services/x402WalletService.js.map +1 -0
- package/dist/templates/index.d.ts +24 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +51 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/swarmTemplates.d.ts +22 -0
- package/dist/templates/swarmTemplates.d.ts.map +1 -0
- package/dist/templates/swarmTemplates.js +225 -0
- package/dist/templates/swarmTemplates.js.map +1 -0
- package/dist/types.d.ts +197 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/cache.d.ts +17 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +32 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/llm.d.ts +16 -0
- package/dist/utils/llm.d.ts.map +1 -0
- package/dist/utils/llm.js +32 -0
- package/dist/utils/llm.js.map +1 -0
- package/dist/utils/reportStore.d.ts +45 -0
- package/dist/utils/reportStore.d.ts.map +1 -0
- package/dist/utils/reportStore.js +164 -0
- package/dist/utils/reportStore.js.map +1 -0
- package/dist/utils/taskQueue.d.ts +54 -0
- package/dist/utils/taskQueue.d.ts.map +1 -0
- package/dist/utils/taskQueue.js +124 -0
- package/dist/utils/taskQueue.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResearchPipeline — Sequential chain: Researcher → FactChecker → Writer
|
|
3
|
+
* Use for: research tasks, report writing, investigation, summarization
|
|
4
|
+
*/
|
|
5
|
+
export const researchPipelineTemplate = {
|
|
6
|
+
id: "research-pipeline",
|
|
7
|
+
name: "ResearchPipeline",
|
|
8
|
+
description: "Research, fact-check, and write a report on a topic",
|
|
9
|
+
swarmType: "SequentialWorkflow",
|
|
10
|
+
triggerPatterns: [
|
|
11
|
+
/\bresearch\b/i,
|
|
12
|
+
/\breport\b/i,
|
|
13
|
+
/\bwrite\s.*\babout\b/i,
|
|
14
|
+
/\bsummar(y|ize)\b/i,
|
|
15
|
+
/\binvestigat/i,
|
|
16
|
+
/\bdeep\s*dive\b/i,
|
|
17
|
+
],
|
|
18
|
+
triggerExamples: [
|
|
19
|
+
"research X",
|
|
20
|
+
"write a report on X",
|
|
21
|
+
"investigate X and summarize findings",
|
|
22
|
+
"deep dive into X",
|
|
23
|
+
],
|
|
24
|
+
agents: [
|
|
25
|
+
{
|
|
26
|
+
agent_name: "Researcher",
|
|
27
|
+
system_prompt: "You are a thorough researcher. Gather comprehensive information about the topic. Identify key facts, data points, and sources. Be exhaustive in your coverage. Structure your findings clearly with headings.",
|
|
28
|
+
model_name: "gpt-4o-mini",
|
|
29
|
+
role: "worker",
|
|
30
|
+
max_loops: 1,
|
|
31
|
+
max_tokens: 4096,
|
|
32
|
+
temperature: 0.7,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
agent_name: "FactChecker",
|
|
36
|
+
system_prompt: "You are a meticulous fact-checker. Review the research provided by the previous agent. Verify claims, flag unsubstantiated assertions, correct errors, and rate confidence levels for each key finding. Mark each claim as [VERIFIED], [UNVERIFIED], or [DISPUTED].",
|
|
37
|
+
model_name: "gpt-4o-mini",
|
|
38
|
+
role: "worker",
|
|
39
|
+
max_loops: 1,
|
|
40
|
+
max_tokens: 4096,
|
|
41
|
+
temperature: 0.2,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
agent_name: "Writer",
|
|
45
|
+
system_prompt: "You are a skilled writer. Take the verified research and produce a clear, well-structured report. Include an executive summary, key findings, and recommendations. Use the fact-checker's confidence ratings to qualify claims appropriately. Write in a professional, concise style.",
|
|
46
|
+
model_name: "gpt-4o",
|
|
47
|
+
role: "worker",
|
|
48
|
+
max_loops: 1,
|
|
49
|
+
max_tokens: 8192,
|
|
50
|
+
temperature: 0.5,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
maxLoops: 1,
|
|
54
|
+
rules: "Each agent builds on the previous agent's output. The Researcher gathers raw information, the FactChecker verifies it, and the Writer produces the final deliverable.",
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* AnalysisPanel — MixtureOfAgents: 3 domain experts + 1 synthesizer
|
|
58
|
+
* Use for: multi-perspective analysis, evaluation, assessment
|
|
59
|
+
*/
|
|
60
|
+
export const analysisPanelTemplate = {
|
|
61
|
+
id: "analysis-panel",
|
|
62
|
+
name: "AnalysisPanel",
|
|
63
|
+
description: "Analyze a topic from multiple expert perspectives and synthesize",
|
|
64
|
+
swarmType: "MixtureOfAgents",
|
|
65
|
+
triggerPatterns: [
|
|
66
|
+
/\banalyz/i,
|
|
67
|
+
/\bperspective/i,
|
|
68
|
+
/\bmulti.*angle/i,
|
|
69
|
+
/\bassess\b/i,
|
|
70
|
+
/\bevaluat/i,
|
|
71
|
+
],
|
|
72
|
+
triggerExamples: [
|
|
73
|
+
"analyze X from multiple perspectives",
|
|
74
|
+
"give me a multi-angle assessment of X",
|
|
75
|
+
"evaluate X comprehensively",
|
|
76
|
+
],
|
|
77
|
+
agents: [
|
|
78
|
+
{
|
|
79
|
+
agent_name: "TechnicalExpert",
|
|
80
|
+
system_prompt: "You are a technical expert. Analyze the topic from a technical/engineering perspective. Focus on feasibility, implementation details, technical risks, architecture, and scalability. Be specific about technical tradeoffs.",
|
|
81
|
+
model_name: "gpt-4o-mini",
|
|
82
|
+
role: "worker",
|
|
83
|
+
max_loops: 1,
|
|
84
|
+
max_tokens: 4096,
|
|
85
|
+
temperature: 0.4,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
agent_name: "EconomicExpert",
|
|
89
|
+
system_prompt: "You are an economic analyst. Analyze the topic from an economic/financial perspective. Focus on costs, ROI, market dynamics, incentive structures, competitive landscape, and revenue potential. Quantify where possible.",
|
|
90
|
+
model_name: "gpt-4o-mini",
|
|
91
|
+
role: "worker",
|
|
92
|
+
max_loops: 1,
|
|
93
|
+
max_tokens: 4096,
|
|
94
|
+
temperature: 0.4,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
agent_name: "RiskExpert",
|
|
98
|
+
system_prompt: "You are a risk management specialist. Analyze the topic from a risk perspective. Identify threats, vulnerabilities, worst-case scenarios, regulatory concerns, and mitigation strategies. Rate each risk as Critical/High/Medium/Low.",
|
|
99
|
+
model_name: "gpt-4o-mini",
|
|
100
|
+
role: "worker",
|
|
101
|
+
max_loops: 1,
|
|
102
|
+
max_tokens: 4096,
|
|
103
|
+
temperature: 0.3,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
agent_name: "Synthesizer",
|
|
107
|
+
system_prompt: "You are an expert synthesizer. You receive analyses from three domain experts (Technical, Economic, Risk). Synthesize their findings into a unified assessment. Highlight areas of agreement, disagreement, and uncertainty. Provide a clear overall recommendation with confidence level.",
|
|
108
|
+
model_name: "gpt-4o",
|
|
109
|
+
role: "worker",
|
|
110
|
+
max_loops: 1,
|
|
111
|
+
max_tokens: 8192,
|
|
112
|
+
temperature: 0.5,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
maxLoops: 1,
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* CodeReview — ConcurrentWorkflow: 3 parallel reviewers
|
|
119
|
+
* Use for: code review, smart contract audit, security check
|
|
120
|
+
*/
|
|
121
|
+
export const codeReviewTemplate = {
|
|
122
|
+
id: "code-review",
|
|
123
|
+
name: "CodeReview",
|
|
124
|
+
description: "Review or audit code for security, performance, and style",
|
|
125
|
+
swarmType: "ConcurrentWorkflow",
|
|
126
|
+
triggerPatterns: [
|
|
127
|
+
/\breview\s.*code/i,
|
|
128
|
+
/\bcode\s.*review/i,
|
|
129
|
+
/\baudit\b/i,
|
|
130
|
+
/\bsecurity\s.*check/i,
|
|
131
|
+
/\bcontract\b.*\b(review|audit|check)/i,
|
|
132
|
+
/\bvulnerabilit/i,
|
|
133
|
+
],
|
|
134
|
+
triggerExamples: [
|
|
135
|
+
"review this code",
|
|
136
|
+
"audit this smart contract",
|
|
137
|
+
"security check on this contract",
|
|
138
|
+
"check for vulnerabilities",
|
|
139
|
+
],
|
|
140
|
+
agents: [
|
|
141
|
+
{
|
|
142
|
+
agent_name: "SecurityAuditor",
|
|
143
|
+
system_prompt: "You are a security auditor. Perform a thorough security review focusing on: vulnerabilities (reentrancy, overflow, access control, front-running, injection), authentication/authorization flaws, data exposure risks. Rate each finding as Critical/High/Medium/Low/Info. Provide specific line references and remediation steps.",
|
|
144
|
+
model_name: "gpt-4o",
|
|
145
|
+
role: "worker",
|
|
146
|
+
max_loops: 1,
|
|
147
|
+
max_tokens: 4096,
|
|
148
|
+
temperature: 0.2,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
agent_name: "PerformanceReviewer",
|
|
152
|
+
system_prompt: "You are a performance engineer. Review the code for: gas optimization (if Solidity), computational efficiency, unnecessary allocations, N+1 patterns, caching opportunities, storage patterns. Suggest concrete improvements with estimated impact.",
|
|
153
|
+
model_name: "gpt-4o-mini",
|
|
154
|
+
role: "worker",
|
|
155
|
+
max_loops: 1,
|
|
156
|
+
max_tokens: 4096,
|
|
157
|
+
temperature: 0.3,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
agent_name: "StyleChecker",
|
|
161
|
+
system_prompt: "You are a code quality reviewer. Review for: naming conventions, documentation quality, code organization, DRY violations, error handling patterns, test coverage gaps, adherence to language-specific best practices and style guides. Suggest improvements for maintainability.",
|
|
162
|
+
model_name: "gpt-4o-mini",
|
|
163
|
+
role: "worker",
|
|
164
|
+
max_loops: 1,
|
|
165
|
+
max_tokens: 4096,
|
|
166
|
+
temperature: 0.3,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
maxLoops: 1,
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* DebateAndDecide — MajorityVoting: Proponent + Opponent + Judge
|
|
173
|
+
* Use for: decision-making, pros/cons analysis, should-I questions
|
|
174
|
+
*/
|
|
175
|
+
export const debateAndDecideTemplate = {
|
|
176
|
+
id: "debate-and-decide",
|
|
177
|
+
name: "DebateAndDecide",
|
|
178
|
+
description: "Debate pros and cons of a decision and reach a verdict",
|
|
179
|
+
swarmType: "MajorityVoting",
|
|
180
|
+
triggerPatterns: [
|
|
181
|
+
/\bshould\s+(i|we)\b/i,
|
|
182
|
+
/\bdebate\b/i,
|
|
183
|
+
/\bpros?\s*(and|&|vs)\s*cons?\b/i,
|
|
184
|
+
/\bdecide\b/i,
|
|
185
|
+
/\bweigh\b.*\b(option|choice|decision)/i,
|
|
186
|
+
/\bworth\s+(it|doing|investing)/i,
|
|
187
|
+
],
|
|
188
|
+
triggerExamples: [
|
|
189
|
+
"should I do X?",
|
|
190
|
+
"debate whether X is a good idea",
|
|
191
|
+
"weigh the pros and cons of X",
|
|
192
|
+
"is X worth it?",
|
|
193
|
+
],
|
|
194
|
+
agents: [
|
|
195
|
+
{
|
|
196
|
+
agent_name: "Proponent",
|
|
197
|
+
system_prompt: "You are arguing IN FAVOR of the proposition. Present the strongest possible case with evidence, data, and reasoning. Be persuasive but honest. Acknowledge weaknesses only to preemptively address them. Structure your argument clearly with numbered points.",
|
|
198
|
+
model_name: "gpt-4o-mini",
|
|
199
|
+
role: "worker",
|
|
200
|
+
max_loops: 1,
|
|
201
|
+
max_tokens: 4096,
|
|
202
|
+
temperature: 0.6,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
agent_name: "Opponent",
|
|
206
|
+
system_prompt: "You are arguing AGAINST the proposition. Present the strongest counterarguments with evidence, data, and reasoning. Play devil's advocate thoroughly. Identify hidden risks, unstated assumptions, and potential failure modes. Structure your argument clearly with numbered points.",
|
|
207
|
+
model_name: "gpt-4o-mini",
|
|
208
|
+
role: "worker",
|
|
209
|
+
max_loops: 1,
|
|
210
|
+
max_tokens: 4096,
|
|
211
|
+
temperature: 0.6,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
agent_name: "Judge",
|
|
215
|
+
system_prompt: "You are an impartial judge. Evaluate both the Proponent's and Opponent's arguments. Weigh the evidence, identify the stronger position, and deliver a clear verdict. Structure your response as: 1) Summary of Pro arguments, 2) Summary of Con arguments, 3) Analysis of key disagreements, 4) Verdict with confidence percentage, 5) Recommended action.",
|
|
216
|
+
model_name: "gpt-4o",
|
|
217
|
+
role: "worker",
|
|
218
|
+
max_loops: 1,
|
|
219
|
+
max_tokens: 4096,
|
|
220
|
+
temperature: 0.3,
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
maxLoops: 1,
|
|
224
|
+
};
|
|
225
|
+
//# sourceMappingURL=swarmTemplates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swarmTemplates.js","sourceRoot":"","sources":["../../src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E,CAAC;YACZ,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,GAAG;SACjB;QACD;YACE,UAAU,EAAE,OAAO;YACnB,aAAa,EACX,4VAA4V;YAC9V,UAAU,EAAE,QAAQ;YACpB,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,GAAG;SACjB;KACF;IACD,QAAQ,EAAE,CAAC;CACZ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { type UUID } from "@elizaos/core";
|
|
2
|
+
export interface X402PaymentConfig {
|
|
3
|
+
networkId: "base-mainnet" | "base-sepolia" | "ethereum-mainnet" | "solana-mainnet" | "polygon-mainnet" | "arbitrum-mainnet";
|
|
4
|
+
receiveAddress: string;
|
|
5
|
+
maxAutoPayUsd: number;
|
|
6
|
+
/** Solana private key (base58) for Dexter payments */
|
|
7
|
+
solanaPrivateKey?: string;
|
|
8
|
+
/** EVM private key (hex) for Base/Polygon/Arbitrum payments */
|
|
9
|
+
evmPrivateKey?: string;
|
|
10
|
+
/** Access Pass tier (e.g. "1h", "24h") for time-limited unlimited access */
|
|
11
|
+
accessPassTier?: string;
|
|
12
|
+
/** Max spend for Access Pass purchase (e.g. "2.00") */
|
|
13
|
+
accessPassMaxSpend?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface X402ServiceListing {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
endpoint: string;
|
|
20
|
+
priceUsd: number;
|
|
21
|
+
category: "ai" | "data" | "compute" | "oracle" | "swarm" | "defi" | "social";
|
|
22
|
+
network: string;
|
|
23
|
+
payToAddress: string;
|
|
24
|
+
qualityScore?: number | null;
|
|
25
|
+
verified?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface PaymentRecord {
|
|
28
|
+
id: UUID;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
endpoint: string;
|
|
31
|
+
amountUsd: number;
|
|
32
|
+
txHash: string;
|
|
33
|
+
network?: string;
|
|
34
|
+
payer?: string;
|
|
35
|
+
status: "pending" | "confirmed" | "failed";
|
|
36
|
+
agentId: string;
|
|
37
|
+
}
|
|
38
|
+
export interface SwarmTaskRequest {
|
|
39
|
+
taskId: string;
|
|
40
|
+
agentName: string;
|
|
41
|
+
prompt: string;
|
|
42
|
+
paymentRequired: boolean;
|
|
43
|
+
estimatedCostUsd?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface SwarmTaskResult {
|
|
46
|
+
taskId: string;
|
|
47
|
+
output: string;
|
|
48
|
+
tokensUsed: number;
|
|
49
|
+
costUsd: number;
|
|
50
|
+
completedAt: number;
|
|
51
|
+
}
|
|
52
|
+
export interface SwarmAPIResponse {
|
|
53
|
+
id?: string;
|
|
54
|
+
output?: string;
|
|
55
|
+
response?: string;
|
|
56
|
+
text?: string;
|
|
57
|
+
agent_name?: string;
|
|
58
|
+
tokens_used?: number;
|
|
59
|
+
status?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface X402SwarmsPluginConfig {
|
|
62
|
+
payment: X402PaymentConfig;
|
|
63
|
+
autoPayThresholdUsd?: number;
|
|
64
|
+
enableServiceRegistration?: boolean;
|
|
65
|
+
swarmServicePort?: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Pre-built swarm template — maps user intent to a specific swarm
|
|
69
|
+
* architecture, agent configuration, and execution parameters.
|
|
70
|
+
*/
|
|
71
|
+
export interface SwarmTemplate {
|
|
72
|
+
/** Unique identifier, e.g. "research-pipeline" */
|
|
73
|
+
id: string;
|
|
74
|
+
/** Human-readable name, e.g. "ResearchPipeline" */
|
|
75
|
+
name: string;
|
|
76
|
+
/** One-line description for LLM classification */
|
|
77
|
+
description: string;
|
|
78
|
+
/** Which swarm architecture to use */
|
|
79
|
+
swarmType: string;
|
|
80
|
+
/** Regex patterns for fast keyword pre-filter */
|
|
81
|
+
triggerPatterns: RegExp[];
|
|
82
|
+
/** Example phrases that trigger this template (used in LLM classification prompt) */
|
|
83
|
+
triggerExamples: string[];
|
|
84
|
+
/** Fully specified agent configurations */
|
|
85
|
+
agents: Array<{
|
|
86
|
+
agent_name: string;
|
|
87
|
+
system_prompt?: string | null;
|
|
88
|
+
model_name?: string | null;
|
|
89
|
+
role?: string | null;
|
|
90
|
+
max_loops?: number | null;
|
|
91
|
+
max_tokens?: number | null;
|
|
92
|
+
temperature?: number | null;
|
|
93
|
+
}>;
|
|
94
|
+
/** Max loops for the swarm (default 1) */
|
|
95
|
+
maxLoops?: number;
|
|
96
|
+
/** Swarm-level rules injected into all agents */
|
|
97
|
+
rules?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A single x402 data fetch — records what was paid for and what was received.
|
|
101
|
+
*/
|
|
102
|
+
export interface X402DataFetch {
|
|
103
|
+
serviceName: string;
|
|
104
|
+
endpoint: string;
|
|
105
|
+
amountUsd: number;
|
|
106
|
+
txHash: string;
|
|
107
|
+
network?: string;
|
|
108
|
+
data: string;
|
|
109
|
+
fetchedAt: number;
|
|
110
|
+
phase: "prefetch" | "swarm-requested";
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Result of a swarm run with x402-funded data.
|
|
114
|
+
*/
|
|
115
|
+
export interface SwarmWithPaymentResult {
|
|
116
|
+
swarmOutput: string;
|
|
117
|
+
swarmJobId: string;
|
|
118
|
+
swarmType: string;
|
|
119
|
+
executionTime: number;
|
|
120
|
+
dataFetches: X402DataFetch[];
|
|
121
|
+
totalX402Spend: number;
|
|
122
|
+
rounds: number;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Server-side x402 endpoint definition for selling services.
|
|
126
|
+
*/
|
|
127
|
+
export interface X402ServiceEndpoint {
|
|
128
|
+
name: string;
|
|
129
|
+
description: string;
|
|
130
|
+
path: string;
|
|
131
|
+
method: "GET" | "POST";
|
|
132
|
+
priceUsd: string;
|
|
133
|
+
free?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Revenue record for an incoming x402 payment.
|
|
137
|
+
*/
|
|
138
|
+
export interface X402RevenueRecord {
|
|
139
|
+
endpoint: string;
|
|
140
|
+
amountUsd: number;
|
|
141
|
+
txHash: string;
|
|
142
|
+
network: string;
|
|
143
|
+
payer: string;
|
|
144
|
+
timestamp: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Persistent payment history record (stored in DB).
|
|
148
|
+
*/
|
|
149
|
+
export interface PaymentHistoryRecord {
|
|
150
|
+
id: string;
|
|
151
|
+
agentId: string;
|
|
152
|
+
endpoint: string;
|
|
153
|
+
domain: string;
|
|
154
|
+
method: string;
|
|
155
|
+
amountUsd: number;
|
|
156
|
+
txHash: string;
|
|
157
|
+
network?: string;
|
|
158
|
+
payer?: string;
|
|
159
|
+
status: "pending" | "confirmed" | "failed";
|
|
160
|
+
responseStatus?: number;
|
|
161
|
+
responseTimeMs?: number;
|
|
162
|
+
qualityScore?: number;
|
|
163
|
+
qualityReason?: string;
|
|
164
|
+
responsePreview?: string;
|
|
165
|
+
createdAt: number;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Aggregate endpoint quality score (materialized in DB).
|
|
169
|
+
*/
|
|
170
|
+
export interface EndpointScore {
|
|
171
|
+
agentId: string;
|
|
172
|
+
domain: string;
|
|
173
|
+
totalCalls: number;
|
|
174
|
+
totalSpentUsd: number;
|
|
175
|
+
avgQualityScore: number;
|
|
176
|
+
avgResponseTimeMs: number;
|
|
177
|
+
errorCount: number;
|
|
178
|
+
lastCallAt: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Cross-session budget state (persisted in DB).
|
|
182
|
+
*/
|
|
183
|
+
export interface BudgetState {
|
|
184
|
+
agentId: string;
|
|
185
|
+
dailySpentUsd: number;
|
|
186
|
+
dailyResetAt: number;
|
|
187
|
+
weeklySpentUsd: number;
|
|
188
|
+
weeklyResetAt: number;
|
|
189
|
+
monthlySpentUsd: number;
|
|
190
|
+
monthlyResetAt: number;
|
|
191
|
+
lifetimeSpentUsd: number;
|
|
192
|
+
lifetimePayments: number;
|
|
193
|
+
dailyBudgetUsd: number;
|
|
194
|
+
weeklyBudgetUsd: number;
|
|
195
|
+
monthlyBudgetUsd: number;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,MAAM,WAAW,iBAAiB;IAChC,SAAS,EACL,cAAc,GACd,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,iBAAiB,GACjB,kBAAkB,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACp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AC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple in-memory TTL cache.
|
|
3
|
+
*
|
|
4
|
+
* Entries expire after `ttlMs` milliseconds and are lazily evicted on read.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TTLCache<T> {
|
|
7
|
+
private ttlMs;
|
|
8
|
+
private cache;
|
|
9
|
+
constructor(ttlMs?: number);
|
|
10
|
+
/** Return cached value or `undefined` if missing / expired. */
|
|
11
|
+
get(key: string): T | undefined;
|
|
12
|
+
/** Store a value with the configured TTL. */
|
|
13
|
+
set(key: string, value: T): void;
|
|
14
|
+
/** Drop all entries. */
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/utils/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,QAAQ,CAAC,CAAC;IAGT,OAAO,CAAC,KAAK;IAFzB,OAAO,CAAC,KAAK,CAAsD;gBAE/C,KAAK,GAAE,MAAe;IAE1C,+DAA+D;IAC/D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAU/B,6CAA6C;IAC7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIhC,wBAAwB;IACxB,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple in-memory TTL cache.
|
|
3
|
+
*
|
|
4
|
+
* Entries expire after `ttlMs` milliseconds and are lazily evicted on read.
|
|
5
|
+
*/
|
|
6
|
+
export class TTLCache {
|
|
7
|
+
ttlMs;
|
|
8
|
+
cache = new Map();
|
|
9
|
+
constructor(ttlMs = 30_000) {
|
|
10
|
+
this.ttlMs = ttlMs;
|
|
11
|
+
}
|
|
12
|
+
/** Return cached value or `undefined` if missing / expired. */
|
|
13
|
+
get(key) {
|
|
14
|
+
const entry = this.cache.get(key);
|
|
15
|
+
if (!entry)
|
|
16
|
+
return undefined;
|
|
17
|
+
if (Date.now() > entry.expiresAt) {
|
|
18
|
+
this.cache.delete(key);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return entry.value;
|
|
22
|
+
}
|
|
23
|
+
/** Store a value with the configured TTL. */
|
|
24
|
+
set(key, value) {
|
|
25
|
+
this.cache.set(key, { value, expiresAt: Date.now() + this.ttlMs });
|
|
26
|
+
}
|
|
27
|
+
/** Drop all entries. */
|
|
28
|
+
clear() {
|
|
29
|
+
this.cache.clear();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/utils/cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IAGC;IAFZ,KAAK,GAAG,IAAI,GAAG,EAA2C,CAAC;IAEnE,YAAoB,QAAgB,MAAM;QAAtB,UAAK,GAAL,KAAK,CAAiB;IAAG,CAAC;IAE9C,+DAA+D;IAC/D,GAAG,CAAC,GAAW;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,6CAA6C;IAC7C,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,wBAAwB;IACxB,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Direct OpenAI call for single-agent tasks.
|
|
3
|
+
* Skips Swarms API overhead — uses our own OPENAI_API_KEY.
|
|
4
|
+
*
|
|
5
|
+
* Rule: One agent, one prompt → Direct OpenAI.
|
|
6
|
+
* Multiple agents coordinating → Swarms.
|
|
7
|
+
*/
|
|
8
|
+
export declare function callOpenAI(options: {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
model?: string;
|
|
11
|
+
systemPrompt: string;
|
|
12
|
+
userPrompt: string;
|
|
13
|
+
maxTokens?: number;
|
|
14
|
+
temperature?: number;
|
|
15
|
+
}): Promise<string>;
|
|
16
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/utils/llm.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BlB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Direct OpenAI call for single-agent tasks.
|
|
3
|
+
* Skips Swarms API overhead — uses our own OPENAI_API_KEY.
|
|
4
|
+
*
|
|
5
|
+
* Rule: One agent, one prompt → Direct OpenAI.
|
|
6
|
+
* Multiple agents coordinating → Swarms.
|
|
7
|
+
*/
|
|
8
|
+
export async function callOpenAI(options) {
|
|
9
|
+
const response = await fetch("https://api.openai.com/v1/chat/completions", {
|
|
10
|
+
method: "POST",
|
|
11
|
+
headers: {
|
|
12
|
+
"Content-Type": "application/json",
|
|
13
|
+
"Authorization": `Bearer ${options.apiKey}`,
|
|
14
|
+
},
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
model: options.model ?? "gpt-4o-mini",
|
|
17
|
+
messages: [
|
|
18
|
+
{ role: "system", content: options.systemPrompt },
|
|
19
|
+
{ role: "user", content: options.userPrompt },
|
|
20
|
+
],
|
|
21
|
+
max_tokens: options.maxTokens ?? 4096,
|
|
22
|
+
temperature: options.temperature ?? 0.3,
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
const error = await response.text();
|
|
27
|
+
throw new Error(`OpenAI API error (${response.status}): ${error}`);
|
|
28
|
+
}
|
|
29
|
+
const data = await response.json();
|
|
30
|
+
return data.choices?.[0]?.message?.content ?? "";
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=llm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/utils/llm.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAOhC;IACC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,4CAA4C,EAAE;QACzE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,eAAe,EAAE,UAAU,OAAO,CAAC,MAAM,EAAE;SAC5C;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,aAAa;YACrC,QAAQ,EAAE;gBACR,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,YAAY,EAAE;gBACjD,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE;aAC9C;YACD,UAAU,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;YACrC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,GAAG;SACxC,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,CAAC,MAAM,MAAM,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAE/B,CAAC;IACF,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report store — persistent JSONL-backed Map for audit/risk/review reports.
|
|
3
|
+
*
|
|
4
|
+
* Accessed by:
|
|
5
|
+
* - src/routes/cryptoRoutes.ts (save after audit)
|
|
6
|
+
* - server.ts (render report page + badge)
|
|
7
|
+
*
|
|
8
|
+
* Storage strategy:
|
|
9
|
+
* - In-memory Map (capped at 1000) for fast reads
|
|
10
|
+
* - Append-only JSONL file (data/reports.jsonl) for persistence across restarts
|
|
11
|
+
* - On module load: restore in-memory Map from disk
|
|
12
|
+
* - On getReport(): check in-memory first, fall back to scanning JSONL file
|
|
13
|
+
*/
|
|
14
|
+
export interface AuditReport {
|
|
15
|
+
id: string;
|
|
16
|
+
type: "contract-audit" | "token-risk" | "code-review" | "code-audit" | "research-report" | "investment-dd";
|
|
17
|
+
createdAt: string;
|
|
18
|
+
input: {
|
|
19
|
+
code?: string;
|
|
20
|
+
mint?: string;
|
|
21
|
+
language?: string;
|
|
22
|
+
chain?: string;
|
|
23
|
+
};
|
|
24
|
+
result: unknown;
|
|
25
|
+
riskScore: number | null;
|
|
26
|
+
paid: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Save a report and return its unique ID.
|
|
30
|
+
*/
|
|
31
|
+
export declare function saveReport(report: Omit<AuditReport, "id">): string;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieve a report by ID, or null if not found.
|
|
34
|
+
* Checks in-memory first, then falls back to scanning the JSONL file.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getReport(id: string): AuditReport | null;
|
|
37
|
+
/**
|
|
38
|
+
* Get the N most recent reports (newest first).
|
|
39
|
+
*/
|
|
40
|
+
export declare function getRecentReports(limit?: number): AuditReport[];
|
|
41
|
+
/**
|
|
42
|
+
* Total number of stored reports.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getReportCount(): number;
|
|
45
|
+
//# sourceMappingURL=reportStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportStore.d.ts","sourceRoot":"","sources":["../../src/utils/reportStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,iBAAiB,GAAG,eAAe,CAAC;IAC3G,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,OAAO,CAAC;CACf;AAmGD;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,GAC9B,MAAM,CAgBR;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAMxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,SAAK,GAAG,WAAW,EAAE,CAQ1D;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|