oculon 0.1.5 → 0.1.7

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.
Files changed (58) hide show
  1. package/README.md +72 -4
  2. package/dist/cli/main.js +184 -0
  3. package/dist/core/calls.d.ts +63 -0
  4. package/dist/core/calls.js +120 -0
  5. package/dist/core/evm.d.ts +20 -0
  6. package/dist/core/evm.js +165 -0
  7. package/dist/core/http.d.ts +11 -0
  8. package/dist/core/http.js +113 -30
  9. package/dist/core/pdf.d.ts +51 -0
  10. package/dist/core/pdf.js +211 -0
  11. package/dist/core/quota.js +3 -0
  12. package/dist/core/verdict.d.ts +30 -0
  13. package/dist/core/verdict.js +164 -0
  14. package/dist/index.d.ts +38 -0
  15. package/dist/index.js +54 -0
  16. package/dist/mcp.d.ts +1 -0
  17. package/dist/mcp.js +159 -5
  18. package/dist/modules/address.d.ts +32 -0
  19. package/dist/modules/address.js +91 -0
  20. package/dist/modules/checks.d.ts +59 -0
  21. package/dist/modules/checks.js +134 -0
  22. package/dist/modules/doc.d.ts +61 -0
  23. package/dist/modules/doc.js +715 -0
  24. package/dist/modules/headers.d.ts +50 -0
  25. package/dist/modules/headers.js +108 -0
  26. package/dist/modules/honeypot.d.ts +36 -0
  27. package/dist/modules/honeypot.js +53 -0
  28. package/dist/modules/iban.d.ts +30 -0
  29. package/dist/modules/iban.js +82 -0
  30. package/dist/modules/lookalike.d.ts +34 -0
  31. package/dist/modules/lookalike.js +122 -0
  32. package/dist/modules/personal.d.ts +1 -1
  33. package/dist/modules/personal.js +14 -4
  34. package/dist/modules/utility.d.ts +147 -0
  35. package/dist/modules/utility.js +403 -0
  36. package/dist/report-pdf.d.ts +7 -0
  37. package/dist/report-pdf.js +81 -0
  38. package/dist/telegram.d.ts +2 -0
  39. package/dist/telegram.js +43 -6
  40. package/dist/web/assets/logo-200.png +0 -0
  41. package/dist/web/burns.d.ts +21 -0
  42. package/dist/web/burns.js +53 -0
  43. package/dist/web/card.d.ts +28 -0
  44. package/dist/web/card.js +75 -0
  45. package/dist/web/index.html +76 -4
  46. package/dist/web/landing.html +1 -1
  47. package/dist/web/legal.html +1 -1
  48. package/dist/web/mcp.html +1 -1
  49. package/dist/web/openapi.js +6 -0
  50. package/dist/web/pages.d.ts +24 -0
  51. package/dist/web/pages.js +139 -0
  52. package/dist/web/public.js +7 -1
  53. package/dist/web/server.d.ts +17 -0
  54. package/dist/web/server.js +207 -7
  55. package/dist/web/token.html +98 -0
  56. package/dist/web/token.json +9 -0
  57. package/dist/web/utility.html +251 -0
  58. package/package.json +1 -1
@@ -79,6 +79,9 @@ export const DAILY_BUDGET = {
79
79
  threatfox: 2000,
80
80
  'ransomware-live': 1000,
81
81
  'pwned-passwords': 20_000,
82
+ 'honeypot-is': 1500, // keyless, be gentle
83
+ 'mempool-space': 3000,
84
+ 'solana-rpc': 3000, // public RPC, rate limited per IP
82
85
  hibp: 200,
83
86
  gleif: 3000,
84
87
  vies: 1000,
@@ -0,0 +1,30 @@
1
+ /**
2
+ * One plain verdict from any check result: what it says, how bad, and why. Used by the verdict cards in AI chat
3
+ * apps, PDF reports, "seen before" changes and brief mode, so every check gets them without its own code.
4
+ * Results differ per module; this reads the fields they share (verdict, risk, level, reasons, flags, warnings).
5
+ */
6
+ export type Tone = 'bad' | 'warn' | 'ok' | 'info';
7
+ export interface Verdict {
8
+ /** What was checked, as shown to people. */
9
+ title: string;
10
+ verdict: string | null;
11
+ tone: Tone;
12
+ risk: number | null;
13
+ points: string[];
14
+ sources: {
15
+ live: number;
16
+ cached: number;
17
+ failed: number;
18
+ names: string[];
19
+ };
20
+ }
21
+ export declare function toneOf(verdict: string | null, risk: number | null): Tone;
22
+ /** The verdict of a module result (or the compact form the API returns). */
23
+ export declare function verdictOf(out: unknown, label?: string): Verdict;
24
+ /** What changed between two verdicts of the same target, in plain words. Empty when nothing did. */
25
+ export declare function verdictChanges(before: Verdict, now: Verdict): string[];
26
+ /**
27
+ * Brief mode: a short answer for agents. Verdict, risk, top points, which sources answered, and the check id
28
+ * for the full result. Results without a verdict are trimmed instead (first items of long lists, no long text).
29
+ */
30
+ export declare function briefOf(out: unknown, extra?: Record<string, unknown>): Record<string, unknown>;
@@ -0,0 +1,164 @@
1
+ /**
2
+ * One plain verdict from any check result: what it says, how bad, and why. Used by the verdict cards in AI chat
3
+ * apps, PDF reports, "seen before" changes and brief mode, so every check gets them without its own code.
4
+ * Results differ per module; this reads the fields they share (verdict, risk, level, reasons, flags, warnings).
5
+ */
6
+ const BAD = /\b(likely scam|scam|malicious|danger|dangerous|spoof|spoofed|high|critical|not valid|invalid|leaked|likely edited|edited|sanction|sanctioned|honeypot|cannot sell|vulnerable|exploited|unprotected|not protected|fake|fraud)\b/i;
7
+ const WARN = /\b(suspicious|caution|medium|moderate|partly|warn|warning|signs of|unknown|unverified|elevated|risky|check)\b/i;
8
+ const OK = /\b(ok|safe|valid|protected|clean|low|no known|not found|none found|no signs|legit|genuine|active|operational|no recalls)\b/i;
9
+ export function toneOf(verdict, risk) {
10
+ if (verdict) {
11
+ // "no signs of editing", "no known threats": a negated finding is good news, whatever words follow.
12
+ if (/^(no|nothing|none)\b|\b(not found|none found)\b/i.test(verdict.trim()))
13
+ return 'ok';
14
+ if (BAD.test(verdict) && !/\bno\b|not (a )?scam/i.test(verdict))
15
+ return 'bad';
16
+ if (WARN.test(verdict))
17
+ return 'warn';
18
+ if (OK.test(verdict))
19
+ return 'ok';
20
+ }
21
+ if (risk !== null)
22
+ return risk >= 70 ? 'bad' : risk >= 35 ? 'warn' : 'ok';
23
+ return 'info';
24
+ }
25
+ const text = (v) => {
26
+ if (typeof v === 'string')
27
+ return v.trim() || null;
28
+ if (v && typeof v === 'object') {
29
+ const o = v;
30
+ for (const k of ['text', 'title', 'reason', 'message', 'detail', 'name'])
31
+ if (typeof o[k] === 'string' && o[k].trim())
32
+ return o[k].trim();
33
+ }
34
+ return null;
35
+ };
36
+ function pickVerdict(x) {
37
+ for (const k of ['verdict', 'status', 'level', 'grade', 'assessment']) {
38
+ const v = x[k];
39
+ if (typeof v === 'string' && v.trim() && v.length < 60)
40
+ return k === 'level' && !/risk/i.test(v) ? `${v} risk` : v.trim();
41
+ }
42
+ if (typeof x.risk === 'string' && x.risk.length < 30)
43
+ return `${x.risk} risk`;
44
+ if (typeof x.valid === 'boolean')
45
+ return x.valid ? 'valid' : 'not valid';
46
+ return null;
47
+ }
48
+ function pickRisk(x) {
49
+ for (const k of ['risk', 'riskScore', 'score']) {
50
+ const v = x[k];
51
+ if (typeof v === 'number' && Number.isFinite(v) && v >= 0 && v <= 100)
52
+ return Math.round(v);
53
+ }
54
+ return null;
55
+ }
56
+ function pickPoints(x) {
57
+ for (const k of ['reasons', 'flags', 'warnings', 'findings', 'points', 'issues']) {
58
+ const arr = x[k];
59
+ if (Array.isArray(arr) && arr.length) {
60
+ const pts = arr.map(text).filter((t) => Boolean(t));
61
+ if (pts.length)
62
+ return pts.slice(0, 12);
63
+ }
64
+ }
65
+ return [];
66
+ }
67
+ function sourcesOf(out) {
68
+ const s = { live: 0, cached: 0, failed: 0, names: [] };
69
+ const prov = out?.provenance;
70
+ if (Array.isArray(prov)) {
71
+ for (const p of prov) {
72
+ if (p.status === 'LIVE')
73
+ s.live++;
74
+ else if (p.status === 'CACHED')
75
+ s.cached++;
76
+ else
77
+ s.failed++;
78
+ if (!s.names.includes(p.source))
79
+ s.names.push(p.source);
80
+ }
81
+ }
82
+ else if (prov && typeof prov === 'object' && prov.sources) {
83
+ // The compact { sources: { name: { LIVE: n } } } summary used by the web API and MCP.
84
+ for (const [name, counts] of Object.entries(prov.sources)) {
85
+ s.names.push(name);
86
+ s.live += counts.LIVE ?? 0;
87
+ s.cached += counts.CACHED ?? 0;
88
+ s.failed += (counts.ERROR ?? 0) + (counts.UNAVAILABLE ?? 0);
89
+ }
90
+ }
91
+ return s;
92
+ }
93
+ /** The verdict of a module result (or the compact form the API returns). */
94
+ export function verdictOf(out, label) {
95
+ const o = (out ?? {});
96
+ const x = (o.result && typeof o.result === 'object' && !Array.isArray(o.result) ? o.result : o);
97
+ const verdict = pickVerdict(x);
98
+ const risk = pickRisk(x);
99
+ let points = pickPoints(x);
100
+ if (!points.length && Array.isArray(o.signals))
101
+ points = o.signals.map((s) => text(s)).filter((t) => Boolean(t)).slice(0, 8);
102
+ const title = label ?? (typeof o.input === 'string' && o.input ? o.input : typeof x.input === 'string' ? x.input : '');
103
+ return { title: title.slice(0, 160), verdict, tone: toneOf(verdict, risk), risk, points, sources: sourcesOf(o) };
104
+ }
105
+ /** What changed between two verdicts of the same target, in plain words. Empty when nothing did. */
106
+ export function verdictChanges(before, now) {
107
+ const out = [];
108
+ if ((before.verdict ?? '') !== (now.verdict ?? ''))
109
+ out.push(`verdict: ${before.verdict ?? 'none'} -> ${now.verdict ?? 'none'}`);
110
+ if (before.risk !== now.risk && before.risk !== null && now.risk !== null)
111
+ out.push(`risk ${before.risk} -> ${now.risk}`);
112
+ const was = new Set(before.points), is = new Set(now.points);
113
+ for (const p of now.points)
114
+ if (!was.has(p))
115
+ out.push(`new: ${p}`);
116
+ for (const p of before.points)
117
+ if (!is.has(p))
118
+ out.push(`gone: ${p}`);
119
+ return out.slice(0, 12);
120
+ }
121
+ /**
122
+ * Brief mode: a short answer for agents. Verdict, risk, top points, which sources answered, and the check id
123
+ * for the full result. Results without a verdict are trimmed instead (first items of long lists, no long text).
124
+ */
125
+ export function briefOf(out, extra = {}) {
126
+ const v = verdictOf(out);
127
+ if (v.verdict || v.risk !== null) {
128
+ return {
129
+ ...(v.title ? { target: v.title } : {}),
130
+ verdict: v.verdict,
131
+ ...(v.risk !== null ? { risk: v.risk } : {}),
132
+ points: v.points.slice(0, 5),
133
+ sources: `${v.sources.live} live, ${v.sources.cached} cached, ${v.sources.failed} failed${v.sources.names.length ? ` (${v.sources.names.slice(0, 8).join(', ')})` : ''}`,
134
+ ...extra,
135
+ };
136
+ }
137
+ return { ...trim(out, 0), ...extra };
138
+ }
139
+ function trim(v, depth) {
140
+ if (typeof v === 'string')
141
+ return v.length > 280 ? `${v.slice(0, 277)}...` : v;
142
+ if (Array.isArray(v)) {
143
+ const head = v.slice(0, 5).map((x) => trim(x, depth + 1));
144
+ return v.length > 5 ? [...head, `(${v.length - 5} more)`] : head;
145
+ }
146
+ if (v && typeof v === 'object') {
147
+ if (depth > 3)
148
+ return '(...)';
149
+ const o = {};
150
+ for (const [k, x] of Object.entries(v)) {
151
+ if (k === 'provenance' && x && typeof x === 'object' && !Array.isArray(x)) {
152
+ o.sources = Object.keys(x.sources ?? {}).join(', ');
153
+ continue;
154
+ }
155
+ if (k === 'provenance' && Array.isArray(x)) {
156
+ o.sources = [...new Set(x.map((p) => p.source))].join(', ');
157
+ continue;
158
+ }
159
+ o[k] = trim(x, depth + 1);
160
+ }
161
+ return o;
162
+ }
163
+ return v;
164
+ }
package/dist/index.d.ts CHANGED
@@ -250,6 +250,44 @@ export declare class Oculon {
250
250
  phoneCheck(number: string, opts?: {
251
251
  country?: string;
252
252
  }): Promise<ModuleResult<import("./modules/phone.js").PhoneCheck>>;
253
+ /** IBAN check, offline: country, length, mod-97 check digits, bank code, and a warning when the account country differs from the supplier's. */
254
+ ibanCheck(iban: string, opts?: {
255
+ country?: string;
256
+ }): Promise<ModuleResult<import("./modules/iban.js").IbanCheck>>;
257
+ /** Raw email headers: SPF, DKIM and DMARC results, the delivery path, the origin IP and spoofing signs. */
258
+ headerCheck(rawHeaders: string): Promise<ModuleResult<import("./modules/headers.js").HeaderReport>>;
259
+ /** Was this invoice, bank statement or screenshot edited? PDF, JPEG or PNG bytes; IBANs in the text are checked. */
260
+ docCheck(file: Buffer, name?: string): Promise<ModuleResult<import("./modules/doc.js").DocResult>>;
261
+ /** Run a check and keep it: returns the value plus a check id, a replay link and what changed since the last check of the same target. */
262
+ recordCheck<T>(kind: string, target: string, run: () => Promise<T>, opts?: {
263
+ label?: string;
264
+ }): Promise<{
265
+ value: T;
266
+ check: import("./modules/checks.js").CheckMeta;
267
+ }>;
268
+ /** A stored check: verdict, every source call it made (the replay log) and the full result. */
269
+ check(id: string): import("./modules/checks.js").CheckRecord | null;
270
+ /** Earlier checks of the same target as check `id`, newest first. */
271
+ checkHistory(id: string, limit?: number): {
272
+ id: string;
273
+ at: string;
274
+ verdict: string | null;
275
+ risk: number | null;
276
+ }[];
277
+ /** One stored check as a PDF report. */
278
+ checkPdf(id: string, baseUrl?: string): Buffer<ArrayBufferLike> | null;
279
+ /** Which sources are up, slow or down: live calls of the last `hours`. */
280
+ sourceStatus(hours?: number): import("./core/calls.js").SourceStatus[];
281
+ /** Lookalike domains of a brand that exist in DNS, and new certificates naming the brand (crt.sh). */
282
+ lookalikes(domain: string): Promise<ModuleResult<import("./modules/lookalike.js").LookalikeReport>>;
283
+ /** Can this token be sold? Buy and sell simulation with taxes (honeypot.is): Ethereum, BNB Chain, Base. */
284
+ honeypotCheck(address: string, opts?: {
285
+ chain?: string;
286
+ }): Promise<ModuleResult<import("./modules/honeypot.js").HoneypotReport>>;
287
+ /** Crypto address without keys: chain from format, OFAC sanctions, balance and activity from free explorers. */
288
+ addressCheck(address: string, opts?: {
289
+ network?: string;
290
+ }): Promise<ModuleResult<import("./modules/address.js").AddressReport>>;
253
291
  /** Satellites: launches of the last 30 days, or one object's orbit, owner and status (CelesTrak). */
254
292
  satellites(query?: string): Promise<ModuleResult<import("./modules/satellites.js").SatResult>>;
255
293
  /** Airport status: METAR and TAF, FAA delays and ground stops (US), emergency squawks nearby. */
package/dist/index.js CHANGED
@@ -69,6 +69,15 @@ import { ransomware } from './modules/ransomware.js';
69
69
  import { companyCheck } from './modules/company.js';
70
70
  import { breaches, passwordCheck, pwnedRange } from './modules/breach.js';
71
71
  import { phoneCheck } from './modules/phone.js';
72
+ import { ibanCheck } from './modules/iban.js';
73
+ import { headerCheck } from './modules/headers.js';
74
+ import { docCheck } from './modules/doc.js';
75
+ import { checkHistory, getCheck, recordCheck } from './modules/checks.js';
76
+ import { sourceStatus } from './core/calls.js';
77
+ import { reportPdf } from './report-pdf.js';
78
+ import { lookalikes } from './modules/lookalike.js';
79
+ import { honeypotCheck } from './modules/honeypot.js';
80
+ import { addressCheck } from './modules/address.js';
72
81
  import { satellites } from './modules/satellites.js';
73
82
  export class Oculon {
74
83
  ctx;
@@ -391,6 +400,51 @@ export class Oculon {
391
400
  phoneCheck(number, opts = {}) {
392
401
  return phoneCheck(this.ctx, number, opts);
393
402
  }
403
+ /** IBAN check, offline: country, length, mod-97 check digits, bank code, and a warning when the account country differs from the supplier's. */
404
+ ibanCheck(iban, opts = {}) {
405
+ return ibanCheck(this.ctx, iban, opts);
406
+ }
407
+ /** Raw email headers: SPF, DKIM and DMARC results, the delivery path, the origin IP and spoofing signs. */
408
+ headerCheck(rawHeaders) {
409
+ return headerCheck(this.ctx, rawHeaders);
410
+ }
411
+ /** Was this invoice, bank statement or screenshot edited? PDF, JPEG or PNG bytes; IBANs in the text are checked. */
412
+ docCheck(file, name) {
413
+ return docCheck(this.ctx, file, name);
414
+ }
415
+ /** Run a check and keep it: returns the value plus a check id, a replay link and what changed since the last check of the same target. */
416
+ recordCheck(kind, target, run, opts = {}) {
417
+ return recordCheck(this.ctx, kind, target, run, opts);
418
+ }
419
+ /** A stored check: verdict, every source call it made (the replay log) and the full result. */
420
+ check(id) {
421
+ return getCheck(this.ctx, id);
422
+ }
423
+ /** Earlier checks of the same target as check `id`, newest first. */
424
+ checkHistory(id, limit = 10) {
425
+ return checkHistory(this.ctx, id, limit);
426
+ }
427
+ /** One stored check as a PDF report. */
428
+ checkPdf(id, baseUrl) {
429
+ const c = getCheck(this.ctx, id);
430
+ return c ? reportPdf(c, checkHistory(this.ctx, id), baseUrl) : null;
431
+ }
432
+ /** Which sources are up, slow or down: live calls of the last `hours`. */
433
+ sourceStatus(hours = 24) {
434
+ return sourceStatus(this.ctx.store, hours);
435
+ }
436
+ /** Lookalike domains of a brand that exist in DNS, and new certificates naming the brand (crt.sh). */
437
+ lookalikes(domain) {
438
+ return lookalikes(this.ctx, domain);
439
+ }
440
+ /** Can this token be sold? Buy and sell simulation with taxes (honeypot.is): Ethereum, BNB Chain, Base. */
441
+ honeypotCheck(address, opts = {}) {
442
+ return honeypotCheck(this.ctx, address, opts);
443
+ }
444
+ /** Crypto address without keys: chain from format, OFAC sanctions, balance and activity from free explorers. */
445
+ addressCheck(address, opts = {}) {
446
+ return addressCheck(this.ctx, address, opts);
447
+ }
394
448
  /** Satellites: launches of the last 30 days, or one object's orbit, owner and status (CelesTrak). */
395
449
  satellites(query = '') {
396
450
  return satellites(this.ctx, query);
package/dist/mcp.d.ts CHANGED
@@ -36,6 +36,7 @@ export declare class McpServer {
36
36
  */
37
37
  constructor(makeOculon?: () => Oculon, opts?: {
38
38
  remote?: boolean;
39
+ baseUrl?: string;
39
40
  });
40
41
  private get o();
41
42
  private pluginTools;
package/dist/mcp.js CHANGED
@@ -2,12 +2,17 @@
2
2
  * Oculon MCP server over stdio (JSON-RPC 2.0, one message per line). No dependencies.
3
3
  * Lets Claude and other MCP clients call every Oculon module as a tool.
4
4
  */
5
+ import { createHash } from 'node:crypto';
5
6
  import { readFileSync } from 'node:fs';
6
7
  import { createInterface } from 'node:readline';
7
8
  import { Oculon, summarizeProvenance } from './index.js';
8
9
  import { ONCHAIN_TOOLS, onchainEnabled } from './core/features.js';
9
10
  import { availableKinds } from './modules/monitor.js';
10
- export const SERVER_INFO = { name: 'oculon', version: '0.1.5' };
11
+ import { CHECK_TOOLS } from './modules/checks.js';
12
+ import { DOC_MAX_BYTES } from './modules/doc.js';
13
+ import { briefOf, verdictOf } from './core/verdict.js';
14
+ import { CARD_HTML, CARD_URI, CARD_URI_OPENAI, MCP_APP_MIME, SKYBRIDGE_MIME } from './web/card.js';
15
+ export const SERVER_INFO = { name: 'oculon', version: '0.1.7' };
11
16
  const SUPPORTED = ['2025-06-18', '2025-03-26', '2024-11-05'];
12
17
  const str = (d) => ({ type: 'string', description: d });
13
18
  const num = (d) => ({ type: 'number', description: d });
@@ -55,6 +60,51 @@ export function checkArgs(inputSchema, args) {
55
60
  function compact(r) {
56
61
  return { module: r.module, input: r.input, generatedAt: r.generatedAt, result: r.result, signals: r.signals, provenance: summarizeProvenance(r.provenance) };
57
62
  }
63
+ /** File bytes for the document check: base64, or an https URL on a public host. */
64
+ async function docBytes(o, a) {
65
+ if (a.data) {
66
+ const b64 = String(a.data).replace(/^data:[^;]+;base64,/, '').replace(/\s+/g, '');
67
+ if (b64.length > Math.ceil(DOC_MAX_BYTES / 3) * 4 + 4)
68
+ throw new Error('the file is larger than 10 MB');
69
+ return Buffer.from(b64, 'base64');
70
+ }
71
+ if (!a.url)
72
+ throw new Error('give the file as data (base64) or url');
73
+ let u;
74
+ try {
75
+ u = new URL(String(a.url));
76
+ }
77
+ catch {
78
+ throw new Error('not a valid URL');
79
+ }
80
+ // Public https hosts only: no addresses, no internal names.
81
+ if (u.protocol !== 'https:' || /^(\d+\.){3}\d+$|^\[|^localhost$|\.(local|internal|localhost|lan|home|corp)$/i.test(u.hostname) || !u.hostname.includes('.'))
82
+ throw new Error('only https links to public hosts are fetched');
83
+ const r = await o.ctx.http.getBytes(u.href, { source: 'doc-download', timeoutMs: 30_000, retries: 0 });
84
+ if (!r.data)
85
+ throw new Error(`could not download the file (${r.prov.note ?? r.prov.status})`);
86
+ if (r.data.length > DOC_MAX_BYTES)
87
+ throw new Error('the file is larger than 10 MB');
88
+ return r.data;
89
+ }
90
+ /** The verdict card data a chat app renders next to a check result. */
91
+ function cardOf(kind, out, check, baseUrl) {
92
+ const v = verdictOf(out);
93
+ return {
94
+ kind,
95
+ title: v.title,
96
+ verdict: v.verdict,
97
+ tone: v.tone,
98
+ risk: v.risk,
99
+ points: v.points.slice(0, 6),
100
+ sources: `${v.sources.live} live, ${v.sources.cached} cached, ${v.sources.failed} failed`,
101
+ seenBefore: check.seenBefore ? { at: check.seenBefore.at, changes: check.seenBefore.changes } : null,
102
+ links: { replay: baseUrl ? baseUrl + check.replay : null, report: baseUrl ? baseUrl + check.report : null },
103
+ checkId: check.id,
104
+ };
105
+ }
106
+ /** Tool definitions with UI templates for the chat apps that render them (MCP Apps, ChatGPT apps). */
107
+ const UI_META = { ui: { resourceUri: CARD_URI }, 'ui/resourceUri': CARD_URI, 'openai/outputTemplate': CARD_URI_OPENAI, 'openai/toolInvocation/invoking': 'Checking sources', 'openai/toolInvocation/invoked': 'Checked', 'openai/widgetAccessible': false };
58
108
  export const TOOLS = [
59
109
  {
60
110
  name: 'oculon_radar',
@@ -297,6 +347,62 @@ export const TOOLS = [
297
347
  inputSchema: schema({ number: str('Phone number'), country: str('ISO country code for a national number, e.g. "US"') }, ['number']),
298
348
  run: async (o, a) => compact(await o.phoneCheck(String(a.number), a.country ? { country: String(a.country) } : {})),
299
349
  },
350
+ {
351
+ name: 'oculon_iban_check',
352
+ description: 'Check an IBAN before paying an invoice, fully offline: country, length, ISO 13616 mod-97 check digits and the bank code. Pass the supplier country to flag an account held in another country, a common sign of invoice fraud. A valid IBAN does not prove who owns the account.',
353
+ inputSchema: schema({ iban: str('The IBAN, spaces allowed'), country: str('Optional: the supplier\'s ISO country code, e.g. "NL"') }, ['iban']),
354
+ run: async (o, a) => compact(await o.ibanCheck(String(a.iban), a.country ? { country: String(a.country) } : {})),
355
+ },
356
+ {
357
+ name: 'oculon_email_headers',
358
+ description: 'Analyze the raw headers of a suspicious email: SPF, DKIM and DMARC results recorded by the receiving server, the Received path, the origin IP and its country, and spoofing signs (From differs from the envelope sender, Reply-To elsewhere, a display name posing as an address). Returns a verdict and risk.',
359
+ inputSchema: schema({ headers: str('The raw message headers, as shown by "Show original"') }, ['headers']),
360
+ run: async (o, a) => compact(await o.headerCheck(String(a.headers))),
361
+ },
362
+ {
363
+ name: 'oculon_lookalike_domains',
364
+ description: 'Find lookalike domains of a brand that a phisher could use: typos, swapped letters, homoglyphs, extra words and other endings that exist in DNS (with mail servers), plus certificates issued in the last 90 days for any name containing the brand (Certificate Transparency).',
365
+ inputSchema: schema({ domain: str('The real domain, e.g. "example.com"') }, ['domain']),
366
+ run: async (o, a) => compact(await o.lookalikes(String(a.domain))),
367
+ },
368
+ {
369
+ name: 'oculon_honeypot_check',
370
+ description: 'Can this token be sold? Simulates a buy and a sell on the token\'s main pool and replays recent holders\' sells (honeypot.is): honeypot verdict, buy and sell tax, holders who could not sell, unpublished or upgradeable contracts. Chains: eth, bsc, base.',
371
+ inputSchema: schema({ address: str('Token contract address (0x...)'), chain: str('eth, bsc or base (default eth)') }, ['address']),
372
+ run: async (o, a) => compact(await o.honeypotCheck(String(a.address), a.chain ? { chain: String(a.chain) } : {})),
373
+ },
374
+ {
375
+ name: 'oculon_address_check',
376
+ description: 'Check a crypto address before sending funds, without API keys: chain from the address format (Bitcoin, EVM, Solana, Tron), US OFAC sanctions, and balance, transaction count and labels from free explorers (mempool.space, Blockscout, Solana RPC). Flags unused addresses and contracts posing as wallets.',
377
+ inputSchema: schema({ address: str('Crypto address'), network: str('Optional for 0x addresses: "robinhood" for Robinhood Chain, default Ethereum') }, ['address']),
378
+ run: async (o, a) => compact(await o.addressCheck(String(a.address), a.network ? { network: String(a.network) } : {})),
379
+ },
380
+ {
381
+ name: 'oculon_doc_check',
382
+ description: 'Was this invoice, bank statement or payment screenshot edited? Reads a PDF, JPEG or PNG: the programs that made and saved it (online PDF editors, image editors), creation vs modification date, how many times it was saved, fonts embedded twice, white boxes over text, annotations, dangerous parts (JavaScript, launch actions), and checks every IBAN in its text. Screenshots are read with a free AI vision model when a key is set. A clean result is not proof the document is genuine.',
383
+ inputSchema: schema({ data: str('The file as base64 (max 10 MB)'), url: str('Or an https URL of the file'), name: str('File name, for display') }),
384
+ run: async (o, a) => {
385
+ const file = await docBytes(o, a);
386
+ return compact(await o.docCheck(file, a.name ? String(a.name) : a.url ? String(a.url).split('/').pop().split('?')[0] : 'document'));
387
+ },
388
+ },
389
+ {
390
+ name: 'oculon_replay',
391
+ description: 'Replay log of an earlier check by its check id: the verdict, what changed since the check before it, and every source called in order with status and time.',
392
+ inputSchema: schema({ id: str('Check id, as returned in check.id') }, ['id']),
393
+ run: (o, a) => {
394
+ const c = o.check(String(a.id));
395
+ if (!c)
396
+ throw new Error('no such check (ids are kept for 90 days)');
397
+ return { id: c.id, kind: c.kind, target: c.label, checkedAt: c.createdAt, durationMs: c.durationMs, verdict: c.verdict, seenBefore: c.seenBefore, calls: c.calls, history: o.checkHistory(c.id) };
398
+ },
399
+ },
400
+ {
401
+ name: 'oculon_status',
402
+ description: 'Which Oculon sources are up, slow, degraded or down, from real calls in the last hours: success rate, median time, last error, and sources being skipped (a mirror or cached data answers instead).',
403
+ inputSchema: schema({ hours: num('Window in hours (default 24, max 48)') }),
404
+ run: (o, a) => ({ hours: Math.min(48, Number(a.hours ?? 24) || 24), sources: o.sourceStatus(Math.min(48, Number(a.hours ?? 24) || 24)) }),
405
+ },
300
406
  {
301
407
  name: 'oculon_satellites',
302
408
  description: 'Satellites from CelesTrak. Leave query empty for everything launched in the last 30 days, grouped by launch. Or pass a satellite name ("ISS", "starlink-1007") or NORAD catalog number for its orbit (perigee, apogee, period, inclination, regime), owner, launch date and status.',
@@ -674,15 +780,37 @@ export class McpServer {
674
780
  const asked = String(msg.params?.protocolVersion ?? '');
675
781
  return reply({
676
782
  protocolVersion: SUPPORTED.includes(asked) ? asked : SUPPORTED[0],
677
- capabilities: { tools: { listChanged: false } },
783
+ capabilities: { tools: { listChanged: false }, resources: { listChanged: false } },
678
784
  serverInfo: SERVER_INFO,
679
- instructions: 'Oculon is an OSINT engine. Every result includes provenance (LIVE/CACHED/UNAVAILABLE/ERROR per source). Report data as given; do not present ERROR or UNAVAILABLE sources as findings.',
785
+ instructions: 'Oculon is an OSINT engine. Every result includes provenance (LIVE/CACHED/UNAVAILABLE/ERROR per source). Report data as given; do not present ERROR or UNAVAILABLE sources as findings. Pass brief: true to any tool for a short answer. Check tools return check.id; oculon_replay shows every source call of a check.',
680
786
  });
681
787
  }
682
788
  case 'ping':
683
789
  return reply({});
684
790
  case 'tools/list':
685
- return reply({ tools: (await this.allTools()).map(({ name, description, inputSchema }) => ({ name, description, inputSchema })) });
791
+ return reply({
792
+ tools: (await this.allTools()).map(({ name, description, inputSchema }) => ({
793
+ name,
794
+ description,
795
+ inputSchema: { ...inputSchema, properties: { ...(inputSchema.properties ?? {}), brief: { type: 'boolean', description: 'Short answer for agents: verdict, risk, top reasons, sources and check id (fewer tokens)' } } },
796
+ ...(CHECK_TOOLS[name] ? { _meta: UI_META } : {}),
797
+ })),
798
+ });
799
+ case 'resources/list':
800
+ return reply({ resources: [
801
+ { uri: CARD_URI, name: 'Oculon verdict card', mimeType: MCP_APP_MIME, description: 'Verdict, risk, reasons and sources of a check' },
802
+ { uri: CARD_URI_OPENAI, name: 'Oculon verdict card (ChatGPT)', mimeType: SKYBRIDGE_MIME, description: 'Verdict, risk, reasons and sources of a check' },
803
+ ] });
804
+ case 'resources/templates/list':
805
+ return reply({ resourceTemplates: [] });
806
+ case 'resources/read': {
807
+ const uri = String(msg.params?.uri ?? '');
808
+ if (uri !== CARD_URI && uri !== CARD_URI_OPENAI)
809
+ return fail(-32002, `resource not found: ${uri}`);
810
+ const base = this.opts.baseUrl;
811
+ const domains = base && /^https:/.test(base) ? [base] : [];
812
+ return reply({ contents: [{ uri, mimeType: uri === CARD_URI ? MCP_APP_MIME : SKYBRIDGE_MIME, text: CARD_HTML, _meta: { ui: { csp: { connectDomains: [], resourceDomains: [] }, prefersBorder: false }, 'openai/widgetDescription': 'Oculon verdict for the check above, with its reasons and sources.', 'openai/widgetPrefersBorder': false, 'openai/widgetCSP': { connect_domains: [], resource_domains: [] }, ...(domains.length ? { 'openai/widgetDomain': domains[0] } : {}) } }] });
813
+ }
686
814
  case 'tools/call': {
687
815
  const name = String(msg.params?.name ?? '');
688
816
  const tool = (await this.allTools()).find((t) => t.name === name);
@@ -691,6 +819,8 @@ export class McpServer {
691
819
  const raw = msg.params?.arguments ?? {};
692
820
  if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
693
821
  return reply({ content: [{ type: 'text', text: 'Error: arguments must be a JSON object' }], isError: true });
822
+ const brief = raw.brief === true;
823
+ delete raw.brief;
694
824
  const bad = checkArgs(tool.inputSchema, raw);
695
825
  if (bad)
696
826
  return reply({ content: [{ type: 'text', text: `Error: ${bad}` }], isError: true });
@@ -698,7 +828,31 @@ export class McpServer {
698
828
  const args = raw;
699
829
  if (this.opts.remote && name === 'oculon_monitor')
700
830
  args.dry_run = true;
701
- const out = await tool.run(this.o, args);
831
+ const ck = CHECK_TOOLS[name];
832
+ let out;
833
+ let check = null;
834
+ if (ck) {
835
+ // Checks are kept: a check id, a replay log, and what changed since the last check of the same thing.
836
+ const target = name === 'oculon_doc_check' ? String(args.url ?? '') || createHash('sha256').update(String(args.data ?? '')).digest('hex') : String(args[ck.arg] ?? '');
837
+ const label = name === 'oculon_doc_check' ? String(args.name ?? args.url ?? 'document').slice(0, 90) : undefined;
838
+ const r = await this.o.recordCheck(ck.kind, target, async () => tool.run(this.o, args), label ? { label } : {});
839
+ out = r.value;
840
+ check = r.check;
841
+ const base = this.opts.baseUrl;
842
+ const meta = { id: check.id, seenBefore: check.seenBefore, replay: base ? base + check.replay : `oculon replay ${check.id}`, report: base ? base + check.report : `oculon replay ${check.id} --pdf report.pdf` };
843
+ if (out && typeof out === 'object')
844
+ out = { ...out, check: meta };
845
+ }
846
+ else {
847
+ out = await tool.run(this.o, args);
848
+ }
849
+ if (brief && !(out && typeof out === 'object' && '__image' in out)) {
850
+ const c = out?.check;
851
+ out = briefOf(out, c ? { check: { id: c.id, replay: c.replay, ...(c.seenBefore ? { changedSinceLast: c.seenBefore.changes } : {}) } } : {});
852
+ }
853
+ if (check) {
854
+ return reply({ content: [{ type: 'text', text: JSON.stringify(out) }], structuredContent: cardOf(ck.kind, out, check, this.opts.baseUrl), _meta: { 'openai/outputTemplate': CARD_URI_OPENAI } });
855
+ }
702
856
  if (out && typeof out === 'object' && '__image' in out) {
703
857
  const { __image, meta } = out;
704
858
  const content = [{ type: 'text', text: JSON.stringify(meta) }];
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Crypto address check without API keys: which chain the address belongs to (from its format), whether it is
3
+ * on the US OFAC sanctions list, and its age, balance and activity from free explorers (mempool.space for
4
+ * Bitcoin, Blockscout for Ethereum and Robinhood Chain, the public Solana RPC). Useful before you send
5
+ * funds to an address someone gave you in a chat.
6
+ */
7
+ import type { Ctx } from '../core/context.js';
8
+ import type { ModuleResult } from '../core/types.js';
9
+ export interface AddressReport {
10
+ address: string;
11
+ chain: 'bitcoin' | 'evm' | 'solana' | 'tron' | 'unknown';
12
+ format: string;
13
+ network: string | null;
14
+ activity: {
15
+ txCount: number | null;
16
+ balance: string | null;
17
+ firstSeen: string | null;
18
+ isContract: boolean | null;
19
+ label: string | null;
20
+ } | null;
21
+ sanctioned: boolean | null;
22
+ sanctionHits: string[];
23
+ warnings: string[];
24
+ advice: string[];
25
+ }
26
+ export declare function detectChain(a: string): {
27
+ chain: AddressReport['chain'];
28
+ format: string;
29
+ };
30
+ export declare function addressCheck(ctx: Ctx, input: string, opts?: {
31
+ network?: string;
32
+ }): Promise<ModuleResult<AddressReport>>;