recker 1.0.15 → 1.0.17-next.9570ed5
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 +86 -97
- package/dist/ai/providers/anthropic.d.ts.map +1 -1
- package/dist/ai/providers/anthropic.js +4 -1
- package/dist/ai/providers/base.d.ts.map +1 -1
- package/dist/ai/providers/base.js +7 -2
- package/dist/ai/rate-limiter.d.ts.map +1 -1
- package/dist/ai/rate-limiter.js +4 -1
- package/dist/bench/generator.d.ts.map +1 -1
- package/dist/bench/generator.js +8 -3
- package/dist/bench/stats.d.ts +15 -1
- package/dist/bench/stats.d.ts.map +1 -1
- package/dist/bench/stats.js +117 -5
- package/dist/cache/memory-storage.d.ts.map +1 -1
- package/dist/cache/memory-storage.js +3 -2
- package/dist/cli/handler.js +14 -14
- package/dist/cli/index.js +602 -48
- package/dist/cli/presets.js +5 -5
- package/dist/cli/tui/ai-chat.js +10 -10
- package/dist/cli/tui/load-dashboard.d.ts.map +1 -1
- package/dist/cli/tui/load-dashboard.js +127 -32
- package/dist/cli/tui/scroll-buffer.d.ts +43 -0
- package/dist/cli/tui/scroll-buffer.d.ts.map +1 -0
- package/dist/cli/tui/scroll-buffer.js +162 -0
- package/dist/cli/tui/search-panel.d.ts +41 -0
- package/dist/cli/tui/search-panel.d.ts.map +1 -0
- package/dist/cli/tui/search-panel.js +420 -0
- package/dist/cli/tui/shell.d.ts +14 -0
- package/dist/cli/tui/shell.d.ts.map +1 -1
- package/dist/cli/tui/shell.js +424 -46
- package/dist/cli/tui/websocket.js +17 -17
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +3 -2
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +18 -26
- package/dist/core/errors.d.ts +109 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +214 -1
- package/dist/core/request-promise.d.ts.map +1 -1
- package/dist/core/request-promise.js +5 -6
- package/dist/core/response.d.ts.map +1 -1
- package/dist/core/response.js +5 -6
- package/dist/dns/index.d.ts +1 -0
- package/dist/dns/index.d.ts.map +1 -1
- package/dist/dns/index.js +1 -0
- package/dist/dns/propagation.d.ts +21 -0
- package/dist/dns/propagation.d.ts.map +1 -0
- package/dist/dns/propagation.js +169 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +10 -11
- package/dist/mcp/embeddings-loader.d.ts +18 -0
- package/dist/mcp/embeddings-loader.d.ts.map +1 -0
- package/dist/mcp/embeddings-loader.js +162 -0
- package/dist/mcp/geoip-loader.d.ts +11 -0
- package/dist/mcp/geoip-loader.d.ts.map +1 -0
- package/dist/mcp/geoip-loader.js +107 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/ip-intel.d.ts +28 -0
- package/dist/mcp/ip-intel.d.ts.map +1 -0
- package/dist/mcp/ip-intel.js +209 -0
- package/dist/mcp/search/hybrid-search.d.ts.map +1 -1
- package/dist/mcp/search/hybrid-search.js +59 -38
- package/dist/mcp/search/math.d.ts.map +1 -1
- package/dist/mcp/search/math.js +5 -1
- package/dist/mcp/server.d.ts +6 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +122 -2
- package/dist/plugins/compression.js +4 -2
- package/dist/plugins/har-player.d.ts.map +1 -1
- package/dist/plugins/har-player.js +8 -11
- package/dist/plugins/odata.d.ts.map +1 -1
- package/dist/plugins/odata.js +5 -2
- package/dist/presets/index.d.ts +2 -0
- package/dist/presets/index.d.ts.map +1 -1
- package/dist/presets/index.js +2 -0
- package/dist/presets/mailgun.d.ts +8 -0
- package/dist/presets/mailgun.d.ts.map +1 -0
- package/dist/presets/mailgun.js +20 -0
- package/dist/presets/registry.d.ts.map +1 -1
- package/dist/presets/registry.js +20 -0
- package/dist/presets/sinch.d.ts +10 -0
- package/dist/presets/sinch.d.ts.map +1 -0
- package/dist/presets/sinch.js +39 -0
- package/dist/protocols/ftp.d.ts.map +1 -1
- package/dist/protocols/ftp.js +69 -16
- package/dist/protocols/sftp.d.ts.map +1 -1
- package/dist/protocols/sftp.js +13 -3
- package/dist/protocols/telnet.d.ts.map +1 -1
- package/dist/protocols/telnet.js +25 -6
- package/dist/recker.d.ts +47 -0
- package/dist/recker.d.ts.map +1 -0
- package/dist/recker.js +99 -0
- package/dist/transport/base-udp.d.ts.map +1 -1
- package/dist/transport/base-udp.js +7 -4
- package/dist/transport/udp-response.d.ts.map +1 -1
- package/dist/transport/udp-response.js +10 -3
- package/dist/transport/udp.d.ts.map +1 -1
- package/dist/transport/udp.js +5 -1
- package/dist/transport/undici.d.ts.map +1 -1
- package/dist/transport/undici.js +75 -63
- package/dist/utils/agent-manager.d.ts +1 -0
- package/dist/utils/agent-manager.d.ts.map +1 -1
- package/dist/utils/agent-manager.js +11 -0
- package/dist/utils/client-pool.d.ts.map +1 -1
- package/dist/utils/client-pool.js +4 -1
- package/dist/utils/colors.d.ts +16 -0
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/colors.js +16 -0
- package/dist/utils/dns-toolkit.d.ts +88 -1
- package/dist/utils/dns-toolkit.d.ts.map +1 -1
- package/dist/utils/dns-toolkit.js +704 -6
- package/dist/utils/doh.d.ts.map +1 -1
- package/dist/utils/doh.js +13 -16
- package/dist/utils/download.d.ts.map +1 -1
- package/dist/utils/download.js +10 -11
- package/dist/utils/rdap.d.ts +9 -0
- package/dist/utils/rdap.d.ts.map +1 -1
- package/dist/utils/rdap.js +78 -9
- package/dist/utils/security-grader.d.ts +47 -0
- package/dist/utils/security-grader.d.ts.map +1 -0
- package/dist/utils/security-grader.js +637 -0
- package/dist/utils/sparkline.d.ts +18 -0
- package/dist/utils/sparkline.d.ts.map +1 -0
- package/dist/utils/sparkline.js +55 -0
- package/dist/utils/sse.d.ts.map +1 -1
- package/dist/utils/sse.js +5 -6
- package/dist/utils/system-metrics.d.ts +26 -0
- package/dist/utils/system-metrics.d.ts.map +1 -0
- package/dist/utils/system-metrics.js +81 -0
- package/dist/utils/tls-inspector.d.ts +6 -0
- package/dist/utils/tls-inspector.d.ts.map +1 -1
- package/dist/utils/tls-inspector.js +35 -1
- package/dist/webrtc/index.d.ts.map +1 -1
- package/dist/webrtc/index.js +21 -7
- package/dist/websocket/client.d.ts.map +1 -1
- package/dist/websocket/client.js +13 -16
- package/package.json +4 -3
- package/dist/mcp/data/embeddings.json +0 -1
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Client } from '../core/client.js';
|
|
2
|
+
import pc from '../utils/colors.js';
|
|
3
|
+
const PROVIDERS = [
|
|
4
|
+
{ id: 'google', name: 'Google DNS', url: 'https://dns.google/resolve', location: 'Global' },
|
|
5
|
+
{ id: 'cloudflare', name: 'Cloudflare', url: 'https://cloudflare-dns.com/dns-query', location: 'Global' },
|
|
6
|
+
{ id: 'nextdns', name: 'NextDNS', url: 'https://dns.nextdns.io/dns-query', location: 'Global' },
|
|
7
|
+
];
|
|
8
|
+
const TYPE_MAP = {
|
|
9
|
+
'A': '1',
|
|
10
|
+
'AAAA': '28',
|
|
11
|
+
'CNAME': '5',
|
|
12
|
+
'MX': '15',
|
|
13
|
+
'NS': '2',
|
|
14
|
+
'TXT': '16',
|
|
15
|
+
'PTR': '12',
|
|
16
|
+
'SRV': '33',
|
|
17
|
+
'SOA': '6',
|
|
18
|
+
'CAA': '257'
|
|
19
|
+
};
|
|
20
|
+
const TYPE_ID_MAP = Object.entries(TYPE_MAP).reduce((acc, [k, v]) => {
|
|
21
|
+
acc[Number(v)] = k;
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
const DNS_STATUS_MAP = {
|
|
25
|
+
0: 'NoError',
|
|
26
|
+
1: 'FormErr',
|
|
27
|
+
2: 'ServFail',
|
|
28
|
+
3: 'NXDomain',
|
|
29
|
+
4: 'NotImp',
|
|
30
|
+
5: 'Refused',
|
|
31
|
+
6: 'YXDomain',
|
|
32
|
+
7: 'YXRRSet',
|
|
33
|
+
8: 'NXRRSet',
|
|
34
|
+
9: 'NotAuth',
|
|
35
|
+
10: 'NotZone'
|
|
36
|
+
};
|
|
37
|
+
export function getTypeName(typeId) {
|
|
38
|
+
return TYPE_ID_MAP[typeId] || `TYPE${typeId}`;
|
|
39
|
+
}
|
|
40
|
+
export async function checkPropagation(domainInput, type = 'A') {
|
|
41
|
+
const domain = domainInput.replace(/^https?:\/\//, '').split('/')[0].split('?')[0];
|
|
42
|
+
const typeId = TYPE_MAP[type.toUpperCase()] || type;
|
|
43
|
+
const client = new Client({
|
|
44
|
+
baseUrl: 'http://localhost',
|
|
45
|
+
http2: true,
|
|
46
|
+
timeout: 5000,
|
|
47
|
+
});
|
|
48
|
+
const queries = PROVIDERS.map(async (provider) => {
|
|
49
|
+
const start = performance.now();
|
|
50
|
+
try {
|
|
51
|
+
const url = new URL(provider.url);
|
|
52
|
+
url.searchParams.set('name', domain);
|
|
53
|
+
url.searchParams.set('type', typeId);
|
|
54
|
+
const json = await client.get(url.toString(), {
|
|
55
|
+
headers: { 'Accept': 'application/dns-json' }
|
|
56
|
+
}).json();
|
|
57
|
+
const duration = performance.now() - start;
|
|
58
|
+
return processJsonResponse(json, provider, duration);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
const duration = performance.now() - start;
|
|
62
|
+
let errorMessage;
|
|
63
|
+
if (err.name === 'TimeoutError' || err.name === 'AbortError' || err.code === 'UND_ERR_ABORTED') {
|
|
64
|
+
errorMessage = `Timeout (>${client.defaultTimeout || 5000}ms)`;
|
|
65
|
+
}
|
|
66
|
+
else if (err.name === 'HttpError') {
|
|
67
|
+
errorMessage = `HTTP ${err.status} ${err.statusText}`;
|
|
68
|
+
}
|
|
69
|
+
else if (err.name === 'NetworkError') {
|
|
70
|
+
errorMessage = `Network error: ${err.code || err.message}`;
|
|
71
|
+
}
|
|
72
|
+
else if (err.name === 'ParseError') {
|
|
73
|
+
errorMessage = `Parse error: ${err.message}`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
errorMessage = err.message || 'Unknown error';
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
id: provider.id,
|
|
80
|
+
provider: provider.name,
|
|
81
|
+
status: 'error',
|
|
82
|
+
records: [],
|
|
83
|
+
rawRecords: [],
|
|
84
|
+
latency: duration,
|
|
85
|
+
error: errorMessage,
|
|
86
|
+
location: provider.location
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return Promise.all(queries);
|
|
91
|
+
}
|
|
92
|
+
function processJsonResponse(json, provider, duration) {
|
|
93
|
+
if (json.Status !== 0) {
|
|
94
|
+
const errorName = DNS_STATUS_MAP[json.Status] || `Code ${json.Status}`;
|
|
95
|
+
return {
|
|
96
|
+
id: provider.id,
|
|
97
|
+
provider: provider.name,
|
|
98
|
+
status: 'error',
|
|
99
|
+
records: [],
|
|
100
|
+
rawRecords: [],
|
|
101
|
+
latency: duration,
|
|
102
|
+
error: errorName,
|
|
103
|
+
location: provider.location
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const answers = (json.Answer || []);
|
|
107
|
+
const records = answers.map(r => r.data);
|
|
108
|
+
const minTTL = answers.length ? Math.min(...answers.map(r => r.TTL)) : undefined;
|
|
109
|
+
return {
|
|
110
|
+
id: provider.id,
|
|
111
|
+
provider: provider.name,
|
|
112
|
+
status: 'ok',
|
|
113
|
+
records,
|
|
114
|
+
rawRecords: answers,
|
|
115
|
+
latency: duration,
|
|
116
|
+
location: provider.location,
|
|
117
|
+
minTTL
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export function formatPropagationReport(results, domain, type) {
|
|
121
|
+
let output = '';
|
|
122
|
+
const displayDomain = domain.replace(/^https?:\/\//, '').split('/')[0];
|
|
123
|
+
output += `\n${pc.bold(pc.cyan('🌍 Global DNS Propagation Check'))}\n`;
|
|
124
|
+
output += `${pc.gray('Domain:')} ${pc.white(displayDomain)} ${pc.gray('Type:')} ${pc.white(type.toUpperCase())}\n\n`;
|
|
125
|
+
const consensus = {};
|
|
126
|
+
results.forEach(res => {
|
|
127
|
+
const key = res.status === 'ok' ? res.records.sort().join(', ') : `Error: ${res.error}`;
|
|
128
|
+
consensus[key] = (consensus[key] || 0) + 1;
|
|
129
|
+
const statusIcon = res.status === 'ok' ? pc.green('✔') : pc.red('✖');
|
|
130
|
+
const latencyColor = res.latency < 50 ? pc.green : res.latency < 200 ? pc.yellow : pc.red;
|
|
131
|
+
const latencyText = latencyColor(`${Math.round(res.latency)}ms`.padStart(6));
|
|
132
|
+
const providerName = pc.bold(res.provider.padEnd(12));
|
|
133
|
+
const ttlText = res.minTTL !== undefined ? pc.gray(`[TTL ${res.minTTL}s]`) : '';
|
|
134
|
+
let recordsText = '';
|
|
135
|
+
if (res.status === 'ok') {
|
|
136
|
+
if (res.records.length === 0) {
|
|
137
|
+
recordsText = pc.yellow('(No records)');
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
recordsText = res.records.join(', ');
|
|
141
|
+
if (recordsText.length > 50)
|
|
142
|
+
recordsText = recordsText.substring(0, 47) + '...';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
recordsText = pc.red(res.error || 'Unknown Error');
|
|
147
|
+
}
|
|
148
|
+
output += ` ${statusIcon} ${providerName} ${latencyText} ${recordsText} ${ttlText}\n`;
|
|
149
|
+
});
|
|
150
|
+
output += '\n';
|
|
151
|
+
const okResults = results.filter(r => r.status === 'ok');
|
|
152
|
+
const errorResults = results.filter(r => r.status === 'error');
|
|
153
|
+
const distinctAnswers = Object.keys(consensus);
|
|
154
|
+
if (errorResults.length === results.length) {
|
|
155
|
+
output += pc.red('❌ All providers returned errors.\n');
|
|
156
|
+
}
|
|
157
|
+
else if (okResults.length === results.length && distinctAnswers.length === 1) {
|
|
158
|
+
output += pc.green('✅ All providers agree. Propagation is complete.\n');
|
|
159
|
+
}
|
|
160
|
+
else if (distinctAnswers.length > 1) {
|
|
161
|
+
if (errorResults.length > 0) {
|
|
162
|
+
output += pc.yellow(`⚠ ${okResults.length}/${results.length} providers responded. Some errors occurred.\n`);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
output += pc.yellow('⚠ Inconsistent results (propagation in progress or split-horizon DNS).\n');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return output;
|
|
169
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -58,10 +58,13 @@ export * from './constants/http-status.js';
|
|
|
58
58
|
export * from './utils/env-proxy.js';
|
|
59
59
|
export * from './utils/charset.js';
|
|
60
60
|
export * from './utils/client-pool.js';
|
|
61
|
+
export * from './utils/security-grader.js';
|
|
61
62
|
export * as presets from './presets/index.js';
|
|
62
63
|
export * as testing from './testing/index.js';
|
|
63
64
|
export * as protocols from './protocols/index.js';
|
|
64
65
|
export * from './mcp/client.js';
|
|
65
66
|
export * from './mcp/contract.js';
|
|
66
67
|
export { Client as Recker } from './core/client.js';
|
|
68
|
+
export { get, post, put, patch, del, del as delete, head, options, whois, whoisAvailable, dns, dnsSecurity, ws, recker, } from './recker.js';
|
|
69
|
+
export { default } from './recker.js';
|
|
67
70
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,C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E,EACF,MAAM,GACP,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -58,9 +58,12 @@ export * from './constants/http-status.js';
|
|
|
58
58
|
export * from './utils/env-proxy.js';
|
|
59
59
|
export * from './utils/charset.js';
|
|
60
60
|
export * from './utils/client-pool.js';
|
|
61
|
+
export * from './utils/security-grader.js';
|
|
61
62
|
export * as presets from './presets/index.js';
|
|
62
63
|
export * as testing from './testing/index.js';
|
|
63
64
|
export * as protocols from './protocols/index.js';
|
|
64
65
|
export * from './mcp/client.js';
|
|
65
66
|
export * from './mcp/contract.js';
|
|
66
67
|
export { Client as Recker } from './core/client.js';
|
|
68
|
+
export { get, post, put, patch, del, del as delete, head, options, whois, whoisAvailable, dns, dnsSecurity, ws, recker, } from './recker.js';
|
|
69
|
+
export { default } from './recker.js';
|
package/dist/mcp/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,OAAO,KAAK,EAGV,aAAa,EACb,OAAO,EAEP,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAYjB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE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CAAC,UAAU,CAAC,CAAgB;IACnC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAC,CAAkB;IAExC,SAAgB,OAAO,EAAE,wBAAwB,CAAC;gBAEtC,OAAO,EAAE,gBAAgB;IAoC/B,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAuBjC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IASjC,SAAgB,KAAK;oBACH,OAAO,CAAC,OAAO,EAAE,CAAC;qBAKf,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAAO,CAAC,aAAa,CAAC;oBAQhE,MAAM,KAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;MAIvD;IAEF,SAAgB,SAAS;oBACP,OAAO,CAAC,WAAW,EAAE,CAAC;oBAKpB,MAAM,KAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;yBAOjC,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;2BAIpB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;MAG/C;IAEF,SAAgB,OAAO;oBACL,OAAO,CAAC,SAAS,EAAE,CAAC;oBAKlB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;MAOtF;IAEI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,aAAa,IAAI,aAAa,GAAG,SAAS;IAI1C,WAAW,IAAI,OAAO;YAIR,OAAO;YA2CP,UAAU;IAkBxB,OAAO,CAAC,cAAc;CAgCvB;AAYD,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAEpE"}
|
package/dist/mcp/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { createClient } from '../core/client.js';
|
|
3
|
-
import {
|
|
3
|
+
import { StateError, ProtocolError } from '../core/errors.js';
|
|
4
4
|
import { consoleLogger } from '../types/logger.js';
|
|
5
5
|
export class MCPClient extends EventEmitter {
|
|
6
6
|
client;
|
|
@@ -128,11 +128,10 @@ export class MCPClient extends EventEmitter {
|
|
|
128
128
|
}
|
|
129
129
|
async request(method, params) {
|
|
130
130
|
if (!this.initialized && method !== 'initialize') {
|
|
131
|
-
throw new
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
]);
|
|
131
|
+
throw new StateError('MCP client not initialized. Call connect() first.', {
|
|
132
|
+
expectedState: 'connected',
|
|
133
|
+
actualState: 'disconnected',
|
|
134
|
+
});
|
|
136
135
|
}
|
|
137
136
|
const request = {
|
|
138
137
|
jsonrpc: '2.0',
|
|
@@ -146,11 +145,11 @@ export class MCPClient extends EventEmitter {
|
|
|
146
145
|
.json();
|
|
147
146
|
this.emit('response', response);
|
|
148
147
|
if (response.error) {
|
|
149
|
-
const error = new
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
const error = new ProtocolError(response.error.message, {
|
|
149
|
+
protocol: 'mcp',
|
|
150
|
+
code: response.error.code,
|
|
151
|
+
retriable: false,
|
|
152
|
+
});
|
|
154
153
|
error.code = response.error.code;
|
|
155
154
|
error.data = response.error.data;
|
|
156
155
|
throw error;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EmbeddingsData } from './search/types.js';
|
|
2
|
+
declare function getPackageVersion(): string;
|
|
3
|
+
export declare function getEmbeddingsCachePath(version?: string): string;
|
|
4
|
+
export declare function hasLocalEmbeddings(version?: string): boolean;
|
|
5
|
+
export declare function loadLocalEmbeddings(version?: string): EmbeddingsData | null;
|
|
6
|
+
export declare function saveLocalEmbeddings(data: EmbeddingsData, version?: string): void;
|
|
7
|
+
export declare function downloadEmbeddings(version?: string): Promise<EmbeddingsData>;
|
|
8
|
+
export declare function loadBundledEmbeddings(): Promise<EmbeddingsData | null>;
|
|
9
|
+
export interface LoadEmbeddingsOptions {
|
|
10
|
+
forceDownload?: boolean;
|
|
11
|
+
version?: string;
|
|
12
|
+
offline?: boolean;
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function loadEmbeddings(options?: LoadEmbeddingsOptions): Promise<EmbeddingsData | null>;
|
|
16
|
+
export declare function clearEmbeddingsCache(version?: string): void;
|
|
17
|
+
export { getPackageVersion };
|
|
18
|
+
//# sourceMappingURL=embeddings-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings-loader.d.ts","sourceRoot":"","sources":["../../src/mcp/embeddings-loader.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAgCxD,iBAAS,iBAAiB,IAAI,MAAM,CAKnC;AAyBD,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAI/D;AAKD,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAE5D;AAKD,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAa3E;AAKD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAUhF;AAKD,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CA4BlF;AAKD,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAsB5E;AAED,MAAM,WAAW,qBAAqB;IAEpC,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAsBD,wBAAsB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAsCxG;AAKD,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAW3D;AAKD,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { DownloadError } from '../core/errors.js';
|
|
5
|
+
function getPackageVersionFromPkg() {
|
|
6
|
+
try {
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const paths = [
|
|
9
|
+
join(__dirname, '..', '..', 'package.json'),
|
|
10
|
+
join(__dirname, '..', '..', '..', 'package.json'),
|
|
11
|
+
join(process.cwd(), 'package.json'),
|
|
12
|
+
];
|
|
13
|
+
for (const pkgPath of paths) {
|
|
14
|
+
if (existsSync(pkgPath)) {
|
|
15
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
16
|
+
if (pkg.name === 'recker') {
|
|
17
|
+
return pkg.version;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
}
|
|
24
|
+
return '1.0.15';
|
|
25
|
+
}
|
|
26
|
+
let _packageVersion = null;
|
|
27
|
+
function getPackageVersion() {
|
|
28
|
+
if (!_packageVersion) {
|
|
29
|
+
_packageVersion = getPackageVersionFromPkg();
|
|
30
|
+
}
|
|
31
|
+
return _packageVersion;
|
|
32
|
+
}
|
|
33
|
+
const GITHUB_RELEASE_URL = 'https://github.com/forattini-dev/recker/releases/download';
|
|
34
|
+
function getCacheDir() {
|
|
35
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
36
|
+
if (homeDir) {
|
|
37
|
+
return join(homeDir, '.cache', 'recker');
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
41
|
+
return join(__dirname, '..', '..', 'node_modules', '.cache', 'recker');
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return join(process.cwd(), 'node_modules', '.cache', 'recker');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function getEmbeddingsCachePath(version) {
|
|
48
|
+
const cacheDir = getCacheDir();
|
|
49
|
+
const ver = version || getPackageVersion();
|
|
50
|
+
return join(cacheDir, `embeddings-${ver}.json`);
|
|
51
|
+
}
|
|
52
|
+
export function hasLocalEmbeddings(version) {
|
|
53
|
+
return existsSync(getEmbeddingsCachePath(version));
|
|
54
|
+
}
|
|
55
|
+
export function loadLocalEmbeddings(version) {
|
|
56
|
+
const cachePath = getEmbeddingsCachePath(version);
|
|
57
|
+
if (!existsSync(cachePath)) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const data = readFileSync(cachePath, 'utf-8');
|
|
62
|
+
return JSON.parse(data);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function saveLocalEmbeddings(data, version) {
|
|
69
|
+
const cachePath = getEmbeddingsCachePath(version);
|
|
70
|
+
const cacheDir = dirname(cachePath);
|
|
71
|
+
if (!existsSync(cacheDir)) {
|
|
72
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
writeFileSync(cachePath, JSON.stringify(data));
|
|
75
|
+
}
|
|
76
|
+
export async function downloadEmbeddings(version) {
|
|
77
|
+
const ver = version || getPackageVersion();
|
|
78
|
+
const url = `${GITHUB_RELEASE_URL}/v${ver}/embeddings.json`;
|
|
79
|
+
try {
|
|
80
|
+
const response = await fetch(url);
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
throw new DownloadError(`Failed to download embeddings: ${response.status} ${response.statusText}`, {
|
|
83
|
+
url,
|
|
84
|
+
statusCode: response.status,
|
|
85
|
+
retriable: response.status >= 500,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const data = await response.json();
|
|
89
|
+
saveLocalEmbeddings(data, ver);
|
|
90
|
+
return data;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error instanceof DownloadError)
|
|
94
|
+
throw error;
|
|
95
|
+
throw new DownloadError(`Failed to download embeddings from ${url}: ${error}`, {
|
|
96
|
+
url,
|
|
97
|
+
retriable: true,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export async function loadBundledEmbeddings() {
|
|
102
|
+
try {
|
|
103
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
104
|
+
const bundledPath = join(__dirname, 'data', 'embeddings.json');
|
|
105
|
+
if (existsSync(bundledPath)) {
|
|
106
|
+
const data = readFileSync(bundledPath, 'utf-8');
|
|
107
|
+
return JSON.parse(data);
|
|
108
|
+
}
|
|
109
|
+
const srcPath = join(__dirname, '..', 'mcp', 'data', 'embeddings.json');
|
|
110
|
+
if (existsSync(srcPath)) {
|
|
111
|
+
const data = readFileSync(srcPath, 'utf-8');
|
|
112
|
+
return JSON.parse(data);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
export async function loadEmbeddings(options = {}) {
|
|
120
|
+
const { forceDownload = false, version, offline = false, debug = false } = options;
|
|
121
|
+
const log = (msg) => {
|
|
122
|
+
if (debug)
|
|
123
|
+
console.log(`[embeddings-loader] ${msg}`);
|
|
124
|
+
};
|
|
125
|
+
if (!forceDownload) {
|
|
126
|
+
const cached = loadLocalEmbeddings(version);
|
|
127
|
+
if (cached) {
|
|
128
|
+
log(`Loaded from cache: ${getEmbeddingsCachePath(version)}`);
|
|
129
|
+
return cached;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const bundled = await loadBundledEmbeddings();
|
|
133
|
+
if (bundled) {
|
|
134
|
+
log('Loaded bundled embeddings');
|
|
135
|
+
return bundled;
|
|
136
|
+
}
|
|
137
|
+
if (!offline) {
|
|
138
|
+
try {
|
|
139
|
+
log(`Downloading embeddings v${version || getPackageVersion()}...`);
|
|
140
|
+
const downloaded = await downloadEmbeddings(version);
|
|
141
|
+
log(`Downloaded and cached: ${downloaded.documents?.length || 0} documents`);
|
|
142
|
+
return downloaded;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
log(`Download failed: ${error}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
log('No embeddings available');
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
export function clearEmbeddingsCache(version) {
|
|
152
|
+
const cachePath = getEmbeddingsCachePath(version);
|
|
153
|
+
try {
|
|
154
|
+
const fs = require('fs');
|
|
155
|
+
if (fs.existsSync(cachePath)) {
|
|
156
|
+
fs.unlinkSync(cachePath);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export { getPackageVersion };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function getGeoIPDatabasePath(): string;
|
|
2
|
+
export declare function hasLocalGeoIPDatabase(): boolean;
|
|
3
|
+
export declare function downloadGeoIPDatabase(): Promise<string>;
|
|
4
|
+
export interface LoadGeoIPOptions {
|
|
5
|
+
forceDownload?: boolean;
|
|
6
|
+
offline?: boolean;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function ensureGeoIPDatabase(options?: LoadGeoIPOptions): Promise<string | null>;
|
|
10
|
+
export declare function clearGeoIPCache(): void;
|
|
11
|
+
//# sourceMappingURL=geoip-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geoip-loader.d.ts","sourceRoot":"","sources":["../../src/mcp/geoip-loader.ts"],"names":[],"mappings":"AA4CA,wBAAgB,oBAAoB,IAAI,MAAM,CAG7C;AAKD,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAKD,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAiD7D;AAED,MAAM,WAAW,gBAAgB;IAE/B,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAuBD,wBAAsB,mBAAmB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoChG;AAKD,wBAAgB,eAAe,IAAI,IAAI,CAUtC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, createWriteStream, unlinkSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { createGunzip } from 'zlib';
|
|
5
|
+
import { pipeline } from 'stream/promises';
|
|
6
|
+
import { Readable } from 'stream';
|
|
7
|
+
import { DownloadError } from '../core/errors.js';
|
|
8
|
+
const GEOLITE2_CDN_URL = 'https://cdn.jsdelivr.net/npm/geolite2-city/GeoLite2-City.mmdb.gz';
|
|
9
|
+
const DB_FILENAME = 'GeoLite2-City.mmdb';
|
|
10
|
+
function getCacheDir() {
|
|
11
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
12
|
+
if (homeDir) {
|
|
13
|
+
return join(homeDir, '.cache', 'recker');
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
return join(__dirname, '..', '..', 'node_modules', '.cache', 'recker');
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return join(process.cwd(), 'node_modules', '.cache', 'recker');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function getGeoIPDatabasePath() {
|
|
24
|
+
const cacheDir = getCacheDir();
|
|
25
|
+
return join(cacheDir, DB_FILENAME);
|
|
26
|
+
}
|
|
27
|
+
export function hasLocalGeoIPDatabase() {
|
|
28
|
+
return existsSync(getGeoIPDatabasePath());
|
|
29
|
+
}
|
|
30
|
+
export async function downloadGeoIPDatabase() {
|
|
31
|
+
const dbPath = getGeoIPDatabasePath();
|
|
32
|
+
const cacheDir = dirname(dbPath);
|
|
33
|
+
if (!existsSync(cacheDir)) {
|
|
34
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetch(GEOLITE2_CDN_URL);
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new DownloadError(`Failed to download GeoLite2 database: ${response.status} ${response.statusText}`, {
|
|
40
|
+
url: GEOLITE2_CDN_URL,
|
|
41
|
+
statusCode: response.status,
|
|
42
|
+
retriable: response.status >= 500,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (!response.body) {
|
|
46
|
+
throw new DownloadError('No response body received', {
|
|
47
|
+
url: GEOLITE2_CDN_URL,
|
|
48
|
+
retriable: true,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const tempPath = dbPath + '.tmp';
|
|
52
|
+
const gunzip = createGunzip();
|
|
53
|
+
const writeStream = createWriteStream(tempPath);
|
|
54
|
+
const nodeStream = Readable.fromWeb(response.body);
|
|
55
|
+
await pipeline(nodeStream, gunzip, writeStream);
|
|
56
|
+
const fs = await import('fs/promises');
|
|
57
|
+
await fs.rename(tempPath, dbPath);
|
|
58
|
+
return dbPath;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error instanceof DownloadError)
|
|
62
|
+
throw error;
|
|
63
|
+
throw new DownloadError(`Failed to download GeoLite2 database: ${error}`, {
|
|
64
|
+
url: GEOLITE2_CDN_URL,
|
|
65
|
+
retriable: true,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export async function ensureGeoIPDatabase(options = {}) {
|
|
70
|
+
const { forceDownload = false, offline = false, debug = false } = options;
|
|
71
|
+
const log = (msg) => {
|
|
72
|
+
if (debug)
|
|
73
|
+
console.log(`[geoip-loader] ${msg}`);
|
|
74
|
+
};
|
|
75
|
+
const dbPath = getGeoIPDatabasePath();
|
|
76
|
+
if (!forceDownload && hasLocalGeoIPDatabase()) {
|
|
77
|
+
log(`Using cached database: ${dbPath}`);
|
|
78
|
+
return dbPath;
|
|
79
|
+
}
|
|
80
|
+
if (!offline) {
|
|
81
|
+
try {
|
|
82
|
+
log('Downloading GeoLite2-City database...');
|
|
83
|
+
const downloaded = await downloadGeoIPDatabase();
|
|
84
|
+
log(`Downloaded and cached: ${downloaded}`);
|
|
85
|
+
return downloaded;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
log(`Download failed: ${error}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (hasLocalGeoIPDatabase()) {
|
|
92
|
+
log(`Using stale cached database: ${dbPath}`);
|
|
93
|
+
return dbPath;
|
|
94
|
+
}
|
|
95
|
+
log('No GeoIP database available');
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
export function clearGeoIPCache() {
|
|
99
|
+
const dbPath = getGeoIPDatabasePath();
|
|
100
|
+
try {
|
|
101
|
+
if (existsSync(dbPath)) {
|
|
102
|
+
unlinkSync(dbPath);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
}
|
|
107
|
+
}
|
package/dist/mcp/index.d.ts
CHANGED
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAKA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAKA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface IpInfo {
|
|
2
|
+
ip: string;
|
|
3
|
+
hostname?: string;
|
|
4
|
+
city?: string;
|
|
5
|
+
region?: string;
|
|
6
|
+
country?: string;
|
|
7
|
+
countryCode?: string;
|
|
8
|
+
continent?: string;
|
|
9
|
+
loc?: string;
|
|
10
|
+
org?: string;
|
|
11
|
+
asn?: number;
|
|
12
|
+
timezone?: string;
|
|
13
|
+
postal?: string;
|
|
14
|
+
accuracy?: number;
|
|
15
|
+
bogon?: boolean;
|
|
16
|
+
bogonType?: string;
|
|
17
|
+
isIPv6?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function isIPv6(ip: string): boolean;
|
|
20
|
+
export declare function isBogon(ip: string): {
|
|
21
|
+
isBogon: boolean;
|
|
22
|
+
type?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function isValidIP(ip: string): boolean;
|
|
25
|
+
export declare function getIpInfo(ip: string): Promise<IpInfo>;
|
|
26
|
+
export declare function isGeoIPAvailable(): boolean;
|
|
27
|
+
export { getGeoIPDatabasePath } from './geoip-loader.js';
|
|
28
|
+
//# sourceMappingURL=ip-intel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip-intel.d.ts","sourceRoot":"","sources":["../../src/mcp/ip-intel.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAyID,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE1C;AAKD,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAKvE;AAKD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAoB7C;AAsCD,wBAAsB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAqD3D;AAKD,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAKD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|