moltbot-scan 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 +473 -0
- package/dist/analysis/llm.d.ts +10 -0
- package/dist/analysis/llm.d.ts.map +1 -0
- package/dist/analysis/llm.js +106 -0
- package/dist/analysis/llm.js.map +1 -0
- package/dist/analysis/patterns.d.ts +19 -0
- package/dist/analysis/patterns.d.ts.map +1 -0
- package/dist/analysis/patterns.js +177 -0
- package/dist/analysis/patterns.js.map +1 -0
- package/dist/analysis/rules.d.ts +6 -0
- package/dist/analysis/rules.d.ts.map +1 -0
- package/dist/analysis/rules.js +55 -0
- package/dist/analysis/rules.js.map +1 -0
- package/dist/analyzers/index.d.ts +5 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +22 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +84 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/demo.d.ts +4 -0
- package/dist/core/demo.d.ts.map +1 -0
- package/dist/core/demo.js +231 -0
- package/dist/core/demo.js.map +1 -0
- package/dist/core/reporter.d.ts +5 -0
- package/dist/core/reporter.d.ts.map +1 -0
- package/dist/core/reporter.js +371 -0
- package/dist/core/reporter.js.map +1 -0
- package/dist/core/scanner.d.ts +9 -0
- package/dist/core/scanner.d.ts.map +1 -0
- package/dist/core/scanner.js +103 -0
- package/dist/core/scanner.js.map +1 -0
- package/dist/core/scorer.d.ts +22 -0
- package/dist/core/scorer.d.ts.map +1 -0
- package/dist/core/scorer.js +269 -0
- package/dist/core/scorer.js.map +1 -0
- package/dist/data/batch-scan.d.ts +9 -0
- package/dist/data/batch-scan.d.ts.map +1 -0
- package/dist/data/batch-scan.js +277 -0
- package/dist/data/batch-scan.js.map +1 -0
- package/dist/data/moltbook.d.ts +13 -0
- package/dist/data/moltbook.d.ts.map +1 -0
- package/dist/data/moltbook.js +91 -0
- package/dist/data/moltbook.js.map +1 -0
- package/dist/data/scraper.d.ts +13 -0
- package/dist/data/scraper.d.ts.map +1 -0
- package/dist/data/scraper.js +85 -0
- package/dist/data/scraper.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/express.d.ts +17 -0
- package/dist/middleware/express.d.ts.map +1 -0
- package/dist/middleware/express.js +46 -0
- package/dist/middleware/express.js.map +1 -0
- package/dist/middleware/generic.d.ts +7 -0
- package/dist/middleware/generic.d.ts.map +1 -0
- package/dist/middleware/generic.js +21 -0
- package/dist/middleware/generic.js.map +1 -0
- package/dist/middleware/index.d.ts +4 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +8 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/sdk/scanner.d.ts +9 -0
- package/dist/sdk/scanner.d.ts.map +1 -0
- package/dist/sdk/scanner.js +92 -0
- package/dist/sdk/scanner.js.map +1 -0
- package/dist/types/index.d.ts +136 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/web/public/index.html +848 -0
- package/dist/web/server.d.ts +3 -0
- package/dist/web/server.d.ts.map +1 -0
- package/dist/web/server.js +74 -0
- package/dist/web/server.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TrustReport } from '../types/index.js';
|
|
2
|
+
export declare function formatCLIReport(report: TrustReport, verbose?: boolean): string;
|
|
3
|
+
export declare function formatJSONReport(report: TrustReport): string;
|
|
4
|
+
export declare function formatHTMLReport(report: TrustReport): string;
|
|
5
|
+
//# sourceMappingURL=reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../src/core/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAuB5D,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,UAAQ,GAAG,MAAM,CAsE5E;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAE5D;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAgR5D"}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCLIReport = formatCLIReport;
|
|
4
|
+
exports.formatJSONReport = formatJSONReport;
|
|
5
|
+
exports.formatHTMLReport = formatHTMLReport;
|
|
6
|
+
// ─── Color / Emoji Helpers ──────────────────────────────────────
|
|
7
|
+
const LEVEL_DISPLAY = {
|
|
8
|
+
HIGH_TRUST: { label: 'HIGH TRUST', color: '\x1b[32m', emoji: '\u2705' },
|
|
9
|
+
MODERATE: { label: 'MODERATE', color: '\x1b[33m', emoji: '\u26a0\ufe0f' },
|
|
10
|
+
LOW_TRUST: { label: 'LOW TRUST', color: '\x1b[38;5;208m', emoji: '\u26a0\ufe0f' },
|
|
11
|
+
UNTRUSTED: { label: 'UNTRUSTED', color: '\x1b[31m', emoji: '\u274c' },
|
|
12
|
+
};
|
|
13
|
+
const SEVERITY_EMOJI = {
|
|
14
|
+
HIGH: '\u26a0\ufe0f HIGH',
|
|
15
|
+
MEDIUM: '\u26a0\ufe0f MEDIUM',
|
|
16
|
+
LOW: '\u2139\ufe0f LOW',
|
|
17
|
+
};
|
|
18
|
+
const RESET = '\x1b[0m';
|
|
19
|
+
const BOLD = '\x1b[1m';
|
|
20
|
+
const DIM = '\x1b[2m';
|
|
21
|
+
// ─── CLI Report ─────────────────────────────────────────────────
|
|
22
|
+
function formatCLIReport(report, verbose = false) {
|
|
23
|
+
const display = LEVEL_DISPLAY[report.level];
|
|
24
|
+
const width = 48;
|
|
25
|
+
const hr = '\u2550'.repeat(width);
|
|
26
|
+
const _thinHr = '\u2500'.repeat(width); // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
27
|
+
const lines = [];
|
|
28
|
+
// Header
|
|
29
|
+
lines.push(`\u2554${hr}\u2557`);
|
|
30
|
+
lines.push(`\u2551 ${BOLD}AgentShield Trust Report: ${report.agentName}${RESET}${padRight('', width - 28 - report.agentName.length)}\u2551`);
|
|
31
|
+
lines.push(`\u2560${hr}\u2563`);
|
|
32
|
+
// Score
|
|
33
|
+
lines.push(`\u2551 Trust Score: ${display.color}${BOLD}${report.score}/100 ${display.emoji} ${display.label}${RESET}${padRight('', width - 30 - display.label.length - String(report.score).length)}\u2551`);
|
|
34
|
+
lines.push(`\u2551 Account Age: ${report.metadata.accountAge} days${padRight('', width - 18 - String(report.metadata.accountAge).length)}\u2551`);
|
|
35
|
+
lines.push(`\u2551 Posts: ${report.metadata.postCount}${padRight('', width - 16 - String(report.metadata.postCount).length)}\u2551`);
|
|
36
|
+
lines.push(`\u2551 Verified: ${report.metadata.verified ? '\u2705 Yes' : '\u274c No (unclaimed)'}${padRight('', width - (report.metadata.verified ? 20 : 28))}\u2551`);
|
|
37
|
+
lines.push(`\u2551 Karma: ${report.metadata.karma}${padRight('', width - 16 - String(report.metadata.karma).length)}\u2551`);
|
|
38
|
+
// Findings
|
|
39
|
+
if (report.findings.length > 0) {
|
|
40
|
+
lines.push(`\u2560${hr}\u2563`);
|
|
41
|
+
lines.push(`\u2551 ${BOLD}\ud83d\udd0d FINDINGS${RESET}${padRight('', width - 13)}\u2551`);
|
|
42
|
+
lines.push(`\u2551${padRight('', width)}\u2551`);
|
|
43
|
+
const maxFindings = verbose ? report.findings.length : Math.min(report.findings.length, 5);
|
|
44
|
+
for (let i = 0; i < maxFindings; i++) {
|
|
45
|
+
const f = report.findings[i];
|
|
46
|
+
const emoji = SEVERITY_EMOJI[f.severity] || f.severity;
|
|
47
|
+
const msg = ` ${emoji}: ${f.message}`;
|
|
48
|
+
const truncated = msg.length > width - 2 ? msg.slice(0, width - 5) + '...' : msg;
|
|
49
|
+
lines.push(`\u2551${truncated}${padRight('', width - stripAnsi(truncated).length)}\u2551`);
|
|
50
|
+
if (verbose && f.details) {
|
|
51
|
+
const detail = ` ${f.details}`;
|
|
52
|
+
const detailTruncated = detail.length > width - 2 ? detail.slice(0, width - 5) + '...' : detail;
|
|
53
|
+
lines.push(`\u2551${DIM}${detailTruncated}${RESET}${padRight('', width - detailTruncated.length)}\u2551`);
|
|
54
|
+
}
|
|
55
|
+
lines.push(`\u2551${padRight('', width)}\u2551`);
|
|
56
|
+
}
|
|
57
|
+
if (!verbose && report.findings.length > 5) {
|
|
58
|
+
lines.push(`\u2551 ${DIM}... and ${report.findings.length - 5} more (use -v for details)${RESET}${padRight('', width - 40 - String(report.findings.length - 5).length)}\u2551`);
|
|
59
|
+
lines.push(`\u2551${padRight('', width)}\u2551`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Patterns
|
|
63
|
+
lines.push(`\u2551 \ud83d\udcca Behavioral Pattern: ${BOLD}${report.behavioralPattern}${RESET}${padRight('', width - 27 - report.behavioralPattern.length)}\u2551`);
|
|
64
|
+
lines.push(`\u2551 \ud83d\udcca Content Risk: ${BOLD}${report.contentRisk}${RESET}${padRight('', width - 20 - report.contentRisk.length)}\u2551`);
|
|
65
|
+
// Score breakdown
|
|
66
|
+
if (verbose) {
|
|
67
|
+
lines.push(`\u2560${hr}\u2563`);
|
|
68
|
+
lines.push(`\u2551 ${BOLD}SCORE BREAKDOWN${RESET}${padRight('', width - 17)}\u2551`);
|
|
69
|
+
lines.push(`\u2551 Identity: ${report.breakdown.identity}/20${padRight('', width - 18 - String(report.breakdown.identity).length)}\u2551`);
|
|
70
|
+
lines.push(`\u2551 Behavior: ${report.breakdown.behavior}/30${padRight('', width - 18 - String(report.breakdown.behavior).length)}\u2551`);
|
|
71
|
+
lines.push(`\u2551 Content: ${report.breakdown.content}/35${padRight('', width - 18 - String(report.breakdown.content).length)}\u2551`);
|
|
72
|
+
lines.push(`\u2551 Community: ${report.breakdown.community}/15${padRight('', width - 18 - String(report.breakdown.community).length)}\u2551`);
|
|
73
|
+
}
|
|
74
|
+
// Footer
|
|
75
|
+
lines.push(`\u255a${hr}\u255d`);
|
|
76
|
+
return lines.join('\n');
|
|
77
|
+
}
|
|
78
|
+
// ─── JSON Report ────────────────────────────────────────────────
|
|
79
|
+
function formatJSONReport(report) {
|
|
80
|
+
return JSON.stringify(report, null, 2);
|
|
81
|
+
}
|
|
82
|
+
// ─── HTML Report (Mac theme) ────────────────────────────────────
|
|
83
|
+
function formatHTMLReport(report) {
|
|
84
|
+
const display = LEVEL_DISPLAY[report.level];
|
|
85
|
+
const levelColor = {
|
|
86
|
+
HIGH_TRUST: '#34C759',
|
|
87
|
+
MODERATE: '#FF9F0A',
|
|
88
|
+
LOW_TRUST: '#FF6B35',
|
|
89
|
+
UNTRUSTED: '#FF3B30',
|
|
90
|
+
}[report.level];
|
|
91
|
+
const scorePercent = report.score;
|
|
92
|
+
return `<!DOCTYPE html>
|
|
93
|
+
<html lang="en">
|
|
94
|
+
<head>
|
|
95
|
+
<meta charset="UTF-8">
|
|
96
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
97
|
+
<title>AgentShield Report: ${report.agentName}</title>
|
|
98
|
+
<style>
|
|
99
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
100
|
+
body {
|
|
101
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
|
|
102
|
+
background: #1C1C1E;
|
|
103
|
+
color: #F2F2F7;
|
|
104
|
+
min-height: 100vh;
|
|
105
|
+
padding: 40px 20px;
|
|
106
|
+
-webkit-font-smoothing: antialiased;
|
|
107
|
+
}
|
|
108
|
+
.container { max-width: 680px; margin: 0 auto; }
|
|
109
|
+
.card {
|
|
110
|
+
background: #2C2C2E;
|
|
111
|
+
border-radius: 16px;
|
|
112
|
+
padding: 28px;
|
|
113
|
+
margin-bottom: 16px;
|
|
114
|
+
border: 1px solid #3A3A3C;
|
|
115
|
+
backdrop-filter: blur(20px);
|
|
116
|
+
-webkit-backdrop-filter: blur(20px);
|
|
117
|
+
}
|
|
118
|
+
.header {
|
|
119
|
+
text-align: center;
|
|
120
|
+
margin-bottom: 32px;
|
|
121
|
+
}
|
|
122
|
+
.header h1 {
|
|
123
|
+
font-size: 28px;
|
|
124
|
+
font-weight: 700;
|
|
125
|
+
letter-spacing: -0.5px;
|
|
126
|
+
margin-bottom: 4px;
|
|
127
|
+
}
|
|
128
|
+
.header .subtitle {
|
|
129
|
+
color: #8E8E93;
|
|
130
|
+
font-size: 15px;
|
|
131
|
+
font-weight: 400;
|
|
132
|
+
}
|
|
133
|
+
.score-ring {
|
|
134
|
+
width: 160px; height: 160px;
|
|
135
|
+
margin: 24px auto;
|
|
136
|
+
position: relative;
|
|
137
|
+
}
|
|
138
|
+
.score-ring svg { transform: rotate(-90deg); }
|
|
139
|
+
.score-ring .value {
|
|
140
|
+
position: absolute;
|
|
141
|
+
top: 50%; left: 50%;
|
|
142
|
+
transform: translate(-50%, -50%);
|
|
143
|
+
font-size: 42px;
|
|
144
|
+
font-weight: 700;
|
|
145
|
+
letter-spacing: -1px;
|
|
146
|
+
}
|
|
147
|
+
.score-ring .label {
|
|
148
|
+
position: absolute;
|
|
149
|
+
bottom: 18px; left: 50%;
|
|
150
|
+
transform: translateX(-50%);
|
|
151
|
+
font-size: 11px;
|
|
152
|
+
font-weight: 600;
|
|
153
|
+
letter-spacing: 1px;
|
|
154
|
+
text-transform: uppercase;
|
|
155
|
+
color: ${levelColor};
|
|
156
|
+
}
|
|
157
|
+
.meta-grid {
|
|
158
|
+
display: grid;
|
|
159
|
+
grid-template-columns: 1fr 1fr;
|
|
160
|
+
gap: 12px;
|
|
161
|
+
margin-top: 20px;
|
|
162
|
+
}
|
|
163
|
+
.meta-item {
|
|
164
|
+
background: #3A3A3C;
|
|
165
|
+
border-radius: 12px;
|
|
166
|
+
padding: 14px 16px;
|
|
167
|
+
}
|
|
168
|
+
.meta-item .meta-label {
|
|
169
|
+
font-size: 12px;
|
|
170
|
+
color: #8E8E93;
|
|
171
|
+
font-weight: 500;
|
|
172
|
+
text-transform: uppercase;
|
|
173
|
+
letter-spacing: 0.5px;
|
|
174
|
+
margin-bottom: 4px;
|
|
175
|
+
}
|
|
176
|
+
.meta-item .meta-value {
|
|
177
|
+
font-size: 20px;
|
|
178
|
+
font-weight: 600;
|
|
179
|
+
}
|
|
180
|
+
.section-title {
|
|
181
|
+
font-size: 13px;
|
|
182
|
+
font-weight: 600;
|
|
183
|
+
color: #8E8E93;
|
|
184
|
+
text-transform: uppercase;
|
|
185
|
+
letter-spacing: 0.8px;
|
|
186
|
+
margin-bottom: 12px;
|
|
187
|
+
}
|
|
188
|
+
.finding {
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: flex-start;
|
|
191
|
+
gap: 10px;
|
|
192
|
+
padding: 12px 0;
|
|
193
|
+
border-bottom: 1px solid #3A3A3C;
|
|
194
|
+
}
|
|
195
|
+
.finding:last-child { border-bottom: none; }
|
|
196
|
+
.finding .badge {
|
|
197
|
+
font-size: 11px;
|
|
198
|
+
font-weight: 600;
|
|
199
|
+
padding: 3px 8px;
|
|
200
|
+
border-radius: 6px;
|
|
201
|
+
white-space: nowrap;
|
|
202
|
+
flex-shrink: 0;
|
|
203
|
+
}
|
|
204
|
+
.badge-high { background: rgba(255,59,48,0.2); color: #FF453A; }
|
|
205
|
+
.badge-medium { background: rgba(255,159,10,0.2); color: #FF9F0A; }
|
|
206
|
+
.badge-low { background: rgba(142,142,147,0.2); color: #8E8E93; }
|
|
207
|
+
.finding .text { font-size: 14px; line-height: 1.4; }
|
|
208
|
+
.finding .detail { font-size: 12px; color: #8E8E93; margin-top: 2px; }
|
|
209
|
+
.breakdown-bar {
|
|
210
|
+
display: flex;
|
|
211
|
+
align-items: center;
|
|
212
|
+
gap: 12px;
|
|
213
|
+
padding: 10px 0;
|
|
214
|
+
}
|
|
215
|
+
.breakdown-bar .name {
|
|
216
|
+
width: 90px;
|
|
217
|
+
font-size: 13px;
|
|
218
|
+
color: #8E8E93;
|
|
219
|
+
}
|
|
220
|
+
.breakdown-bar .track {
|
|
221
|
+
flex: 1;
|
|
222
|
+
height: 8px;
|
|
223
|
+
background: #3A3A3C;
|
|
224
|
+
border-radius: 4px;
|
|
225
|
+
overflow: hidden;
|
|
226
|
+
}
|
|
227
|
+
.breakdown-bar .fill {
|
|
228
|
+
height: 100%;
|
|
229
|
+
border-radius: 4px;
|
|
230
|
+
background: ${levelColor};
|
|
231
|
+
transition: width 0.6s ease;
|
|
232
|
+
}
|
|
233
|
+
.breakdown-bar .val {
|
|
234
|
+
width: 50px;
|
|
235
|
+
text-align: right;
|
|
236
|
+
font-size: 14px;
|
|
237
|
+
font-weight: 600;
|
|
238
|
+
font-variant-numeric: tabular-nums;
|
|
239
|
+
}
|
|
240
|
+
.pattern-badges {
|
|
241
|
+
display: flex;
|
|
242
|
+
gap: 8px;
|
|
243
|
+
flex-wrap: wrap;
|
|
244
|
+
margin-top: 4px;
|
|
245
|
+
}
|
|
246
|
+
.pattern-badge {
|
|
247
|
+
font-size: 13px;
|
|
248
|
+
font-weight: 500;
|
|
249
|
+
padding: 6px 14px;
|
|
250
|
+
border-radius: 20px;
|
|
251
|
+
background: #3A3A3C;
|
|
252
|
+
}
|
|
253
|
+
.footer {
|
|
254
|
+
text-align: center;
|
|
255
|
+
margin-top: 24px;
|
|
256
|
+
font-size: 12px;
|
|
257
|
+
color: #48484A;
|
|
258
|
+
}
|
|
259
|
+
</style>
|
|
260
|
+
</head>
|
|
261
|
+
<body>
|
|
262
|
+
<div class="container">
|
|
263
|
+
|
|
264
|
+
<div class="header">
|
|
265
|
+
<h1>\ud83d\udee1\ufe0f AgentShield</h1>
|
|
266
|
+
<div class="subtitle">Trust Report for ${report.agentName}</div>
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<div class="card" style="text-align:center;">
|
|
270
|
+
<div class="score-ring">
|
|
271
|
+
<svg width="160" height="160" viewBox="0 0 160 160">
|
|
272
|
+
<circle cx="80" cy="80" r="70" fill="none" stroke="#3A3A3C" stroke-width="10"/>
|
|
273
|
+
<circle cx="80" cy="80" r="70" fill="none" stroke="${levelColor}" stroke-width="10"
|
|
274
|
+
stroke-dasharray="${(scorePercent / 100) * 440} 440"
|
|
275
|
+
stroke-linecap="round"/>
|
|
276
|
+
</svg>
|
|
277
|
+
<div class="value" style="color:${levelColor}">${report.score}</div>
|
|
278
|
+
<div class="label">${display.label}</div>
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<div class="meta-grid">
|
|
282
|
+
<div class="meta-item">
|
|
283
|
+
<div class="meta-label">Account Age</div>
|
|
284
|
+
<div class="meta-value">${report.metadata.accountAge}d</div>
|
|
285
|
+
</div>
|
|
286
|
+
<div class="meta-item">
|
|
287
|
+
<div class="meta-label">Posts</div>
|
|
288
|
+
<div class="meta-value">${report.metadata.postCount}</div>
|
|
289
|
+
</div>
|
|
290
|
+
<div class="meta-item">
|
|
291
|
+
<div class="meta-label">Verified</div>
|
|
292
|
+
<div class="meta-value">${report.metadata.verified ? '\u2705 Yes' : '\u274c No'}</div>
|
|
293
|
+
</div>
|
|
294
|
+
<div class="meta-item">
|
|
295
|
+
<div class="meta-label">Karma</div>
|
|
296
|
+
<div class="meta-value">${report.metadata.karma}</div>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
${report.findings.length > 0 ? `
|
|
302
|
+
<div class="card">
|
|
303
|
+
<div class="section-title">Findings</div>
|
|
304
|
+
${report.findings.map(f => `
|
|
305
|
+
<div class="finding">
|
|
306
|
+
<span class="badge badge-${f.severity.toLowerCase()}">${f.severity}</span>
|
|
307
|
+
<div>
|
|
308
|
+
<div class="text">${escapeHtml(f.message)}</div>
|
|
309
|
+
${f.details ? `<div class="detail">${escapeHtml(f.details)}</div>` : ''}
|
|
310
|
+
</div>
|
|
311
|
+
</div>`).join('')}
|
|
312
|
+
</div>` : ''}
|
|
313
|
+
|
|
314
|
+
<div class="card">
|
|
315
|
+
<div class="section-title">Score Breakdown</div>
|
|
316
|
+
<div class="breakdown-bar">
|
|
317
|
+
<div class="name">Identity</div>
|
|
318
|
+
<div class="track"><div class="fill" style="width:${(report.breakdown.identity / 20) * 100}%"></div></div>
|
|
319
|
+
<div class="val">${report.breakdown.identity}/20</div>
|
|
320
|
+
</div>
|
|
321
|
+
<div class="breakdown-bar">
|
|
322
|
+
<div class="name">Behavior</div>
|
|
323
|
+
<div class="track"><div class="fill" style="width:${(report.breakdown.behavior / 30) * 100}%"></div></div>
|
|
324
|
+
<div class="val">${report.breakdown.behavior}/30</div>
|
|
325
|
+
</div>
|
|
326
|
+
<div class="breakdown-bar">
|
|
327
|
+
<div class="name">Content</div>
|
|
328
|
+
<div class="track"><div class="fill" style="width:${(report.breakdown.content / 35) * 100}%"></div></div>
|
|
329
|
+
<div class="val">${report.breakdown.content}/35</div>
|
|
330
|
+
</div>
|
|
331
|
+
<div class="breakdown-bar">
|
|
332
|
+
<div class="name">Community</div>
|
|
333
|
+
<div class="track"><div class="fill" style="width:${(report.breakdown.community / 15) * 100}%"></div></div>
|
|
334
|
+
<div class="val">${report.breakdown.community}/15</div>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
|
|
338
|
+
<div class="card">
|
|
339
|
+
<div class="section-title">Analysis</div>
|
|
340
|
+
<div class="pattern-badges">
|
|
341
|
+
<span class="pattern-badge">\ud83d\udcca Behavioral: ${report.behavioralPattern}</span>
|
|
342
|
+
<span class="pattern-badge">\ud83d\udee1\ufe0f Content Risk: ${report.contentRisk}</span>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
|
|
346
|
+
<div class="footer">
|
|
347
|
+
Scanned at ${report.metadata.scannedAt} • AgentShield v0.1.0
|
|
348
|
+
</div>
|
|
349
|
+
|
|
350
|
+
</div>
|
|
351
|
+
</body>
|
|
352
|
+
</html>`;
|
|
353
|
+
}
|
|
354
|
+
// ─── Helpers ────────────────────────────────────────────────────
|
|
355
|
+
function padRight(str, len) {
|
|
356
|
+
if (len <= 0)
|
|
357
|
+
return '';
|
|
358
|
+
return str + ' '.repeat(len);
|
|
359
|
+
}
|
|
360
|
+
function stripAnsi(str) {
|
|
361
|
+
// eslint-disable-next-line no-control-regex
|
|
362
|
+
return str.replace(/\x1b\[[0-9;]*m/g, '');
|
|
363
|
+
}
|
|
364
|
+
function escapeHtml(str) {
|
|
365
|
+
return str
|
|
366
|
+
.replace(/&/g, '&')
|
|
367
|
+
.replace(/</g, '<')
|
|
368
|
+
.replace(/>/g, '>')
|
|
369
|
+
.replace(/"/g, '"');
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=reporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../src/core/reporter.ts"],"names":[],"mappings":";;AAuBA,0CAsEC;AAID,4CAEC;AAID,4CAgRC;AArXD,mEAAmE;AAEnE,MAAM,aAAa,GAAwE;IACzF,UAAU,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE;IACvE,QAAQ,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE;IACzE,SAAS,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,EAAE;IACjF,SAAS,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE;CACtE,CAAC;AAEF,MAAM,cAAc,GAA2B;IAC7C,IAAI,EAAE,mBAAmB;IACzB,MAAM,EAAE,qBAAqB;IA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AAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TrustReport, ScanOptions } from '../types/index.js';
|
|
2
|
+
export declare class Scanner {
|
|
3
|
+
private client;
|
|
4
|
+
private scraper;
|
|
5
|
+
private llm;
|
|
6
|
+
constructor();
|
|
7
|
+
scan(agentName: string, opts?: Partial<ScanOptions>): Promise<TrustReport>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/core/scanner.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,WAAW,EAAE,WAAW,EAEzB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,GAAG,CAAc;;IAQnB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;CAqGjF"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scanner = void 0;
|
|
4
|
+
const moltbook_js_1 = require("../data/moltbook.js");
|
|
5
|
+
const scraper_js_1 = require("../data/scraper.js");
|
|
6
|
+
const rules_js_1 = require("../analysis/rules.js");
|
|
7
|
+
const llm_js_1 = require("../analysis/llm.js");
|
|
8
|
+
const scorer_js_1 = require("./scorer.js");
|
|
9
|
+
const index_js_1 = require("../types/index.js");
|
|
10
|
+
class Scanner {
|
|
11
|
+
client;
|
|
12
|
+
scraper;
|
|
13
|
+
llm;
|
|
14
|
+
constructor() {
|
|
15
|
+
this.client = new moltbook_js_1.MoltbookClient();
|
|
16
|
+
this.scraper = new scraper_js_1.MoltbookScraper();
|
|
17
|
+
this.llm = new llm_js_1.LLMAnalyzer();
|
|
18
|
+
}
|
|
19
|
+
async scan(agentName, opts) {
|
|
20
|
+
const options = { ...index_js_1.DEFAULT_SCAN_OPTIONS, ...opts };
|
|
21
|
+
const name = agentName.replace(/^@/, '');
|
|
22
|
+
// 1. Fetch agent profile
|
|
23
|
+
let profile;
|
|
24
|
+
let posts;
|
|
25
|
+
try {
|
|
26
|
+
profile = await this.client.getAgentProfile(name);
|
|
27
|
+
posts = await this.client.getAgentPosts(name, options.maxPosts);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// Fallback to scraper if API fails
|
|
31
|
+
if (this.scraper.isAvailable) {
|
|
32
|
+
const scraped = await this.scraper.scrapeAgent(name);
|
|
33
|
+
if (!scraped.profile) {
|
|
34
|
+
throw new Error(`Agent @${name} not found on Moltbook`);
|
|
35
|
+
}
|
|
36
|
+
profile = scraped.profile;
|
|
37
|
+
posts = scraped.posts;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw new Error(`Failed to fetch agent @${name}: ${error instanceof Error ? error.message : 'unknown error'}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// 2. Analyze all post content
|
|
44
|
+
const analyses = [];
|
|
45
|
+
for (const post of posts) {
|
|
46
|
+
const content = `${post.title} ${post.body}`.trim();
|
|
47
|
+
if (!content)
|
|
48
|
+
continue;
|
|
49
|
+
const analysis = (0, rules_js_1.analyzeContent)(content, post.id);
|
|
50
|
+
// Deep LLM analysis for suspicious content
|
|
51
|
+
if (!options.skipLLM && (0, rules_js_1.needsLLMAnalysis)(analysis) && this.llm.isAvailable) {
|
|
52
|
+
analysis.llmResult = await this.llm.analyze(content);
|
|
53
|
+
}
|
|
54
|
+
analyses.push(analysis);
|
|
55
|
+
}
|
|
56
|
+
// 3. Calculate scores across all four dimensions
|
|
57
|
+
const identityResult = (0, scorer_js_1.scoreIdentity)(profile);
|
|
58
|
+
const behaviorResult = (0, scorer_js_1.scoreBehavior)(profile, posts);
|
|
59
|
+
const contentResult = (0, scorer_js_1.scoreContentRisk)(posts, analyses);
|
|
60
|
+
const communityResult = (0, scorer_js_1.scoreCommunity)(profile, posts);
|
|
61
|
+
// 4. Calculate total score
|
|
62
|
+
const totalScore = identityResult.score +
|
|
63
|
+
behaviorResult.score +
|
|
64
|
+
contentResult.score +
|
|
65
|
+
communityResult.score;
|
|
66
|
+
// 5. Merge all findings
|
|
67
|
+
const allFindings = [
|
|
68
|
+
...contentResult.findings,
|
|
69
|
+
...behaviorResult.findings,
|
|
70
|
+
...identityResult.findings,
|
|
71
|
+
...communityResult.findings,
|
|
72
|
+
];
|
|
73
|
+
// Sort findings by severity
|
|
74
|
+
const severityOrder = { HIGH: 0, MEDIUM: 1, LOW: 2 };
|
|
75
|
+
allFindings.sort((a, b) => (severityOrder[a.severity] ?? 3) - (severityOrder[b.severity] ?? 3));
|
|
76
|
+
// 6. Build report
|
|
77
|
+
const daysSinceCreation = Math.max(0, Math.floor((Date.now() - new Date(profile.created_at).getTime()) / (1000 * 60 * 60 * 24)));
|
|
78
|
+
return {
|
|
79
|
+
agentName: `@${name}`,
|
|
80
|
+
score: totalScore,
|
|
81
|
+
level: (0, scorer_js_1.calculateTrustLevel)(totalScore),
|
|
82
|
+
breakdown: {
|
|
83
|
+
identity: identityResult.score,
|
|
84
|
+
behavior: behaviorResult.score,
|
|
85
|
+
content: contentResult.score,
|
|
86
|
+
community: communityResult.score,
|
|
87
|
+
},
|
|
88
|
+
findings: allFindings,
|
|
89
|
+
behavioralPattern: behaviorResult.pattern,
|
|
90
|
+
contentRisk: contentResult.risk,
|
|
91
|
+
metadata: {
|
|
92
|
+
accountAge: daysSinceCreation,
|
|
93
|
+
postCount: posts.length,
|
|
94
|
+
verified: profile.verified,
|
|
95
|
+
claimed: profile.claimed,
|
|
96
|
+
karma: profile.karma,
|
|
97
|
+
scannedAt: new Date().toISOString(),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.Scanner = Scanner;
|
|
103
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../src/core/scanner.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,mDAAqD;AACrD,mDAAwE;AACxE,+CAAiD;AACjD,2CAMqB;AACrB,gDAG2B;AAE3B,MAAa,OAAO;IACV,MAAM,CAAiB;IACvB,OAAO,CAAkB;IACzB,GAAG,CAAc;IAEzB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,4BAAc,EAAE,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,IAAI,4BAAe,EAAE,CAAC;QACrC,IAAI,CAAC,GAAG,GAAG,IAAI,oBAAW,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,IAA2B;QACvD,MAAM,OAAO,GAAG,EAAE,GAAG,+BAAoB,EAAE,GAAG,IAAI,EAAE,CAAC;QACrD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAEzC,yBAAyB;QACzB,IAAI,OAAqB,CAAC;QAC1B,IAAI,KAAa,CAAC;QAElB,IAAI,CAAC;YACH,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YAClD,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,mCAAmC;YACnC,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;gBAC7B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAA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B,QAAQ,EAAE,cAAc,CAAC,KAAK;gBAC9B,OAAO,EAAE,aAAa,CAAC,KAAK;gBAC5B,SAAS,EAAE,eAAe,CAAC,KAAK;aACjC;YACD,QAAQ,EAAE,WAAW;YACrB,iBAAiB,EAAE,cAAc,CAAC,OAAO;YACzC,WAAW,EAAE,aAAa,CAAC,IAAI;YAC/B,QAAQ,EAAE;gBACR,UAAU,EAAE,iBAAiB;gBAC7B,SAAS,EAAE,KAAK,CAAC,MAAM;gBACvB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC;SACF,CAAC;IACJ,CAAC;CACF;AAhHD,0BAgHC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AgentProfile, Post, ContentAnalysis, ScoreBreakdown, TrustLevel, Finding } from '../types/index.js';
|
|
2
|
+
export declare function scoreIdentity(agent: AgentProfile): {
|
|
3
|
+
score: number;
|
|
4
|
+
findings: Finding[];
|
|
5
|
+
};
|
|
6
|
+
export declare function scoreBehavior(agent: AgentProfile, posts: Post[]): {
|
|
7
|
+
score: number;
|
|
8
|
+
findings: Finding[];
|
|
9
|
+
pattern: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function scoreContentRisk(posts: Post[], analyses: ContentAnalysis[]): {
|
|
12
|
+
score: number;
|
|
13
|
+
findings: Finding[];
|
|
14
|
+
risk: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function scoreCommunity(agent: AgentProfile, posts: Post[]): {
|
|
17
|
+
score: number;
|
|
18
|
+
findings: Finding[];
|
|
19
|
+
};
|
|
20
|
+
export declare function calculateTrustLevel(totalScore: number): TrustLevel;
|
|
21
|
+
export declare function calculateBreakdown(identity: number, behavior: number, content: number, community: number): ScoreBreakdown;
|
|
22
|
+
//# sourceMappingURL=scorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorer.d.ts","sourceRoot":"","sources":["../../src/core/scorer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAAE,IAAI,EAAE,eAAe,EACnC,cAAc,EAAE,UAAU,EAAE,OAAO,EACpC,MAAM,mBAAmB,CAAC;AAmC3B,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAqCzF;AAID,wBAAgB,aAAa,CAC3B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,IAAI,EAAE,GACZ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAyEzD;AAID,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,IAAI,EAAE,EACb,QAAQ,EAAE,eAAe,EAAE,GAC1B;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAwFtD;AAID,wBAAgB,cAAc,CAC5B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,IAAI,EAAE,GACZ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CA2BxC;AAID,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAKlE;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,cAAc,CAEhB"}
|