oculon 0.0.0-stage → 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 +344 -2
- package/dist/agent.d.ts +47 -0
- package/dist/agent.js +104 -0
- package/dist/cases.d.ts +68 -0
- package/dist/cases.js +158 -0
- package/dist/cli/main.d.ts +12 -0
- package/dist/cli/main.js +1999 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +15 -0
- package/dist/core/context.d.ts +19 -0
- package/dist/core/context.js +19 -0
- package/dist/core/features.d.ts +22 -0
- package/dist/core/features.js +28 -0
- package/dist/core/graph.d.ts +38 -0
- package/dist/core/graph.js +81 -0
- package/dist/core/http.d.ts +42 -0
- package/dist/core/http.js +266 -0
- package/dist/core/keys.d.ts +8 -0
- package/dist/core/keys.js +22 -0
- package/dist/core/llm.d.ts +93 -0
- package/dist/core/llm.js +180 -0
- package/dist/core/merkle.d.ts +15 -0
- package/dist/core/merkle.js +46 -0
- package/dist/core/paths.d.ts +2 -0
- package/dist/core/paths.js +6 -0
- package/dist/core/png.d.ts +17 -0
- package/dist/core/png.js +101 -0
- package/dist/core/quota.d.ts +15 -0
- package/dist/core/quota.js +90 -0
- package/dist/core/stats.d.ts +24 -0
- package/dist/core/stats.js +67 -0
- package/dist/core/store.d.ts +20 -0
- package/dist/core/store.js +213 -0
- package/dist/core/text.d.ts +9 -0
- package/dist/core/text.js +30 -0
- package/dist/core/types.d.ts +38 -0
- package/dist/core/types.js +1 -0
- package/dist/index.d.ts +342 -0
- package/dist/index.js +495 -0
- package/dist/live.d.ts +53 -0
- package/dist/live.js +236 -0
- package/dist/mcp.d.ts +43 -0
- package/dist/mcp.js +651 -0
- package/dist/modules/airport.d.ts +60 -0
- package/dist/modules/airport.js +111 -0
- package/dist/modules/audit.d.ts +73 -0
- package/dist/modules/audit.js +211 -0
- package/dist/modules/bgp.d.ts +147 -0
- package/dist/modules/bgp.js +206 -0
- package/dist/modules/blackout.d.ts +41 -0
- package/dist/modules/blackout.js +98 -0
- package/dist/modules/brief.d.ts +26 -0
- package/dist/modules/brief.js +99 -0
- package/dist/modules/calendar.d.ts +27 -0
- package/dist/modules/calendar.js +145 -0
- package/dist/modules/calibrate.d.ts +46 -0
- package/dist/modules/calibrate.js +92 -0
- package/dist/modules/cloud.d.ts +32 -0
- package/dist/modules/cloud.js +94 -0
- package/dist/modules/condor.d.ts +66 -0
- package/dist/modules/condor.js +214 -0
- package/dist/modules/connect.d.ts +47 -0
- package/dist/modules/connect.js +114 -0
- package/dist/modules/contradictions.d.ts +27 -0
- package/dist/modules/contradictions.js +76 -0
- package/dist/modules/country.d.ts +82 -0
- package/dist/modules/country.js +136 -0
- package/dist/modules/cricket.d.ts +34 -0
- package/dist/modules/cricket.js +166 -0
- package/dist/modules/darkships.d.ts +219 -0
- package/dist/modules/darkships.js +400 -0
- package/dist/modules/defi.d.ts +237 -0
- package/dist/modules/defi.js +512 -0
- package/dist/modules/emailsec.d.ts +47 -0
- package/dist/modules/emailsec.js +146 -0
- package/dist/modules/exposure.d.ts +43 -0
- package/dist/modules/exposure.js +89 -0
- package/dist/modules/factcheck.d.ts +39 -0
- package/dist/modules/factcheck.js +127 -0
- package/dist/modules/falcon.d.ts +58 -0
- package/dist/modules/falcon.js +219 -0
- package/dist/modules/feedback.d.ts +24 -0
- package/dist/modules/feedback.js +37 -0
- package/dist/modules/fence.d.ts +52 -0
- package/dist/modules/fence.js +128 -0
- package/dist/modules/ferret.d.ts +47 -0
- package/dist/modules/ferret.js +220 -0
- package/dist/modules/filings.d.ts +86 -0
- package/dist/modules/filings.js +166 -0
- package/dist/modules/fires.d.ts +56 -0
- package/dist/modules/fires.js +150 -0
- package/dist/modules/hazards.d.ts +37 -0
- package/dist/modules/hazards.js +83 -0
- package/dist/modules/health.d.ts +24 -0
- package/dist/modules/health.js +82 -0
- package/dist/modules/heron.d.ts +68 -0
- package/dist/modules/heron.js +184 -0
- package/dist/modules/hound.d.ts +100 -0
- package/dist/modules/hound.js +301 -0
- package/dist/modules/impact.d.ts +39 -0
- package/dist/modules/impact.js +63 -0
- package/dist/modules/launches.d.ts +24 -0
- package/dist/modules/launches.js +61 -0
- package/dist/modules/listen.d.ts +48 -0
- package/dist/modules/listen.js +125 -0
- package/dist/modules/lynx.d.ts +43 -0
- package/dist/modules/lynx.js +127 -0
- package/dist/modules/magpie.d.ts +70 -0
- package/dist/modules/magpie.js +174 -0
- package/dist/modules/meerkat.d.ts +42 -0
- package/dist/modules/meerkat.js +293 -0
- package/dist/modules/monitor.d.ts +27 -0
- package/dist/modules/monitor.js +105 -0
- package/dist/modules/narratives.d.ts +33 -0
- package/dist/modules/narratives.js +136 -0
- package/dist/modules/owl.d.ts +71 -0
- package/dist/modules/owl.js +290 -0
- package/dist/modules/papers.d.ts +46 -0
- package/dist/modules/papers.js +135 -0
- package/dist/modules/personal.d.ts +54 -0
- package/dist/modules/personal.js +153 -0
- package/dist/modules/pulse.d.ts +19 -0
- package/dist/modules/pulse.js +59 -0
- package/dist/modules/raven.d.ts +80 -0
- package/dist/modules/raven.js +147 -0
- package/dist/modules/recall.d.ts +44 -0
- package/dist/modules/recall.js +123 -0
- package/dist/modules/regs.d.ts +88 -0
- package/dist/modules/regs.js +142 -0
- package/dist/modules/rewind.d.ts +22 -0
- package/dist/modules/rewind.js +68 -0
- package/dist/modules/sanctions.d.ts +62 -0
- package/dist/modules/sanctions.js +173 -0
- package/dist/modules/scam.d.ts +43 -0
- package/dist/modules/scam.js +111 -0
- package/dist/modules/scoop.d.ts +31 -0
- package/dist/modules/scoop.js +74 -0
- package/dist/modules/ships.d.ts +33 -0
- package/dist/modules/ships.js +113 -0
- package/dist/modules/sky.d.ts +47 -0
- package/dist/modules/sky.js +183 -0
- package/dist/modules/squawk.d.ts +46 -0
- package/dist/modules/squawk.js +106 -0
- package/dist/modules/tortoise.d.ts +40 -0
- package/dist/modules/tortoise.js +104 -0
- package/dist/modules/travel.d.ts +94 -0
- package/dist/modules/travel.js +241 -0
- package/dist/modules/urlcheck.d.ts +63 -0
- package/dist/modules/urlcheck.js +223 -0
- package/dist/modules/vulns.d.ts +142 -0
- package/dist/modules/vulns.js +276 -0
- package/dist/plugins.d.ts +41 -0
- package/dist/plugins.js +70 -0
- package/dist/report.d.ts +12 -0
- package/dist/report.js +90 -0
- package/dist/scheduler.d.ts +22 -0
- package/dist/scheduler.js +139 -0
- package/dist/sources/aircraft.d.ts +76 -0
- package/dist/sources/aircraft.js +107 -0
- package/dist/sources/airports.d.ts +28 -0
- package/dist/sources/airports.js +100 -0
- package/dist/sources/ais.d.ts +32 -0
- package/dist/sources/ais.js +111 -0
- package/dist/sources/apify.d.ts +28 -0
- package/dist/sources/apify.js +80 -0
- package/dist/sources/arxiv.d.ts +13 -0
- package/dist/sources/arxiv.js +27 -0
- package/dist/sources/certs.d.ts +12 -0
- package/dist/sources/certs.js +23 -0
- package/dist/sources/corp.d.ts +46 -0
- package/dist/sources/corp.js +60 -0
- package/dist/sources/earth.d.ts +39 -0
- package/dist/sources/earth.js +76 -0
- package/dist/sources/fda.d.ts +77 -0
- package/dist/sources/fda.js +121 -0
- package/dist/sources/finance.d.ts +181 -0
- package/dist/sources/finance.js +270 -0
- package/dist/sources/gdelt.d.ts +19 -0
- package/dist/sources/gdelt.js +33 -0
- package/dist/sources/github.d.ts +17 -0
- package/dist/sources/github.js +33 -0
- package/dist/sources/hackernews.d.ts +20 -0
- package/dist/sources/hackernews.js +37 -0
- package/dist/sources/labels.d.ts +21 -0
- package/dist/sources/labels.js +87 -0
- package/dist/sources/launch.d.ts +16 -0
- package/dist/sources/launch.js +41 -0
- package/dist/sources/ofac.d.ts +29 -0
- package/dist/sources/ofac.js +86 -0
- package/dist/sources/onchain.d.ts +77 -0
- package/dist/sources/onchain.js +189 -0
- package/dist/sources/opentimestamps.d.ts +44 -0
- package/dist/sources/opentimestamps.js +131 -0
- package/dist/sources/polymarket.d.ts +36 -0
- package/dist/sources/polymarket.js +70 -0
- package/dist/sources/predict.d.ts +18 -0
- package/dist/sources/predict.js +59 -0
- package/dist/sources/press.d.ts +30 -0
- package/dist/sources/press.js +111 -0
- package/dist/sources/resend.d.ts +14 -0
- package/dist/sources/resend.js +29 -0
- package/dist/sources/robinhood.d.ts +109 -0
- package/dist/sources/robinhood.js +129 -0
- package/dist/sources/sec.d.ts +67 -0
- package/dist/sources/sec.js +129 -0
- package/dist/sources/sentinel.d.ts +13 -0
- package/dist/sources/sentinel.js +63 -0
- package/dist/sources/signatures.d.ts +14 -0
- package/dist/sources/signatures.js +103 -0
- package/dist/sources/social.d.ts +22 -0
- package/dist/sources/social.js +56 -0
- package/dist/sources/space.d.ts +160 -0
- package/dist/sources/space.js +230 -0
- package/dist/sources/usgs.d.ts +17 -0
- package/dist/sources/usgs.js +24 -0
- package/dist/sources/wayback.d.ts +10 -0
- package/dist/sources/wayback.js +28 -0
- package/dist/sources/websec.d.ts +19 -0
- package/dist/sources/websec.js +40 -0
- package/dist/sources/wikidata.d.ts +11 -0
- package/dist/sources/wikidata.js +30 -0
- package/dist/sources/wikimedia.d.ts +28 -0
- package/dist/sources/wikimedia.js +52 -0
- package/dist/telegram.d.ts +104 -0
- package/dist/telegram.js +927 -0
- package/dist/web/assets/favicon-32.png +0 -0
- package/dist/web/assets/fx.js +178 -0
- package/dist/web/assets/icon-192.png +0 -0
- package/dist/web/assets/icon-512.png +0 -0
- package/dist/web/assets/icon-maskable-512.png +0 -0
- package/dist/web/assets/night-americas.jpg +0 -0
- package/dist/web/assets/night-emea.jpg +0 -0
- package/dist/web/assets/og.png +0 -0
- package/dist/web/assets/redsea-bm.jpg +0 -0
- package/dist/web/docs.html +263 -0
- package/dist/web/index.html +1828 -0
- package/dist/web/insights.d.ts +100 -0
- package/dist/web/insights.js +134 -0
- package/dist/web/landing.html +1143 -0
- package/dist/web/legal.html +176 -0
- package/dist/web/manifest.webmanifest +20 -0
- package/dist/web/mcp.html +104 -0
- package/dist/web/mcphttp.d.ts +10 -0
- package/dist/web/mcphttp.js +67 -0
- package/dist/web/openapi.d.ts +1 -0
- package/dist/web/openapi.js +51 -0
- package/dist/web/public.d.ts +45 -0
- package/dist/web/public.js +135 -0
- package/dist/web/server.d.ts +69 -0
- package/dist/web/server.js +750 -0
- package/dist/web/share.d.ts +35 -0
- package/dist/web/share.js +132 -0
- package/dist/web/sw.js +28 -0
- package/package.json +60 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { enc } from '../core/context.js';
|
|
2
|
+
const GD = 'https://api.gdeltproject.org/api/v2/doc/doc';
|
|
3
|
+
const GDELT_LIMIT = /^Please limit requests/i;
|
|
4
|
+
export function gdeltQuery(q) {
|
|
5
|
+
const t = q.trim();
|
|
6
|
+
return /\s/.test(t) && !t.startsWith('"') ? `"${t}"` : t;
|
|
7
|
+
}
|
|
8
|
+
/** Daily share of global news coverage mentioning the query. */
|
|
9
|
+
export async function coverageTimeline(ctx, query, days = 56) {
|
|
10
|
+
const url = `${GD}?query=${enc(gdeltQuery(query))}&mode=timelinevol×pan=${days}d&timelinesmooth=0&format=json`;
|
|
11
|
+
const r = await ctx.http.get(url, {
|
|
12
|
+
source: 'gdelt',
|
|
13
|
+
ttlSec: 3 * 3600,
|
|
14
|
+
timeoutMs: 30_000,
|
|
15
|
+
rateLimitText: GDELT_LIMIT,
|
|
16
|
+
});
|
|
17
|
+
const raw = r.data?.timeline?.[0]?.data;
|
|
18
|
+
if (!raw)
|
|
19
|
+
return { data: null, prov: r.data && r.prov.status !== 'ERROR' ? { ...r.prov, status: 'UNAVAILABLE' } : r.prov };
|
|
20
|
+
// Collapse to one value per day (GDELT may return sub-daily points).
|
|
21
|
+
const byDay = new Map();
|
|
22
|
+
for (const p of raw) {
|
|
23
|
+
const d = p.date.slice(0, 8);
|
|
24
|
+
byDay.set(d, [...(byDay.get(d) ?? []), p.value]);
|
|
25
|
+
}
|
|
26
|
+
const data = [...byDay].map(([date, vs]) => ({ date, value: vs.reduce((a, b) => a + b, 0) / vs.length }));
|
|
27
|
+
return { data, prov: r.prov };
|
|
28
|
+
}
|
|
29
|
+
export async function latestArticles(ctx, query, max = 10) {
|
|
30
|
+
const url = `${GD}?query=${enc(gdeltQuery(query))}&mode=artlist&maxrecords=${max}&sort=datedesc×pan=3d&format=json`;
|
|
31
|
+
const r = await ctx.http.get(url, { source: 'gdelt', ttlSec: 1800, timeoutMs: 30_000, rateLimitText: GDELT_LIMIT });
|
|
32
|
+
return { data: r.data ? (r.data.articles ?? []) : null, prov: r.prov };
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Ctx } from '../core/context.js';
|
|
2
|
+
import type { Sourced } from '../core/types.js';
|
|
3
|
+
export interface Repo {
|
|
4
|
+
name: string;
|
|
5
|
+
full_name: string;
|
|
6
|
+
html_url: string;
|
|
7
|
+
description: string | null;
|
|
8
|
+
created_at: string;
|
|
9
|
+
pushed_at: string;
|
|
10
|
+
stargazers_count: number;
|
|
11
|
+
language: string | null;
|
|
12
|
+
fork: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Most recently created public repos of an org (falls back to a user account). */
|
|
15
|
+
export declare function recentRepos(ctx: Ctx, owner: string): Promise<Sourced<Repo[]>>;
|
|
16
|
+
/** Number of repositories matching a search query (e.g. `"ai agent" created:2026-10-01..2026-10-28`). */
|
|
17
|
+
export declare function repoCount(ctx: Ctx, query: string): Promise<Sourced<number>>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { enc } from '../core/context.js';
|
|
2
|
+
function headers() {
|
|
3
|
+
const h = { accept: 'application/vnd.github+json', 'x-github-api-version': '2022-11-28' };
|
|
4
|
+
const token = process.env.GITHUB_TOKEN?.trim();
|
|
5
|
+
if (token)
|
|
6
|
+
h.authorization = `Bearer ${token}`;
|
|
7
|
+
return h;
|
|
8
|
+
}
|
|
9
|
+
/** Most recently created public repos of an org (falls back to a user account). */
|
|
10
|
+
export async function recentRepos(ctx, owner) {
|
|
11
|
+
const q = 'sort=created&direction=desc&per_page=50';
|
|
12
|
+
const org = await ctx.http.get(`https://api.github.com/orgs/${enc(owner)}/repos?${q}`, {
|
|
13
|
+
source: 'github',
|
|
14
|
+
ttlSec: 3 * 3600,
|
|
15
|
+
headers: headers(),
|
|
16
|
+
});
|
|
17
|
+
if (org.prov.status !== 'UNAVAILABLE')
|
|
18
|
+
return org;
|
|
19
|
+
return ctx.http.get(`https://api.github.com/users/${enc(owner)}/repos?${q}`, {
|
|
20
|
+
source: 'github',
|
|
21
|
+
ttlSec: 3 * 3600,
|
|
22
|
+
headers: headers(),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Number of repositories matching a search query (e.g. `"ai agent" created:2026-10-01..2026-10-28`). */
|
|
26
|
+
export async function repoCount(ctx, query) {
|
|
27
|
+
const r = await ctx.http.get(`https://api.github.com/search/repositories?q=${enc(query)}&per_page=1`, {
|
|
28
|
+
source: 'github-search',
|
|
29
|
+
ttlSec: 6 * 3600,
|
|
30
|
+
headers: headers(),
|
|
31
|
+
});
|
|
32
|
+
return { data: r.data?.total_count ?? null, prov: r.prov };
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Ctx } from '../core/context.js';
|
|
2
|
+
import type { Provenance, Sourced } from '../core/types.js';
|
|
3
|
+
export interface HnStory {
|
|
4
|
+
objectID: string;
|
|
5
|
+
title: string;
|
|
6
|
+
url: string | null;
|
|
7
|
+
points: number;
|
|
8
|
+
num_comments: number;
|
|
9
|
+
created_at_i: number;
|
|
10
|
+
}
|
|
11
|
+
/** Story counts per week for `weeks` weeks, oldest first. Null if any bucket failed. */
|
|
12
|
+
export declare function weeklyStoryCounts(ctx: Ctx, query: string, weeks?: number): Promise<{
|
|
13
|
+
data: number[] | null;
|
|
14
|
+
provs: Provenance[];
|
|
15
|
+
}>;
|
|
16
|
+
/** Stories currently on the HN front page. */
|
|
17
|
+
export declare function frontPage(ctx: Ctx): Promise<Sourced<HnStory[]>>;
|
|
18
|
+
/** Most relevant/popular stories mentioning the query in the last `days` days. */
|
|
19
|
+
export declare function recentMentions(ctx: Ctx, query: string, days?: number, max?: number): Promise<Sourced<HnStory[]>>;
|
|
20
|
+
export declare const hnItemUrl: (id: string) => string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DAY_MS, enc } from '../core/context.js';
|
|
2
|
+
const HN = 'https://hn.algolia.com/api/v1';
|
|
3
|
+
async function countBetween(ctx, query, from, to) {
|
|
4
|
+
const url = `${HN}/search?query=${enc(query)}&tags=story&hitsPerPage=0&numericFilters=${enc(`created_at_i>${from},created_at_i<=${to}`)}`;
|
|
5
|
+
const r = await ctx.http.get(url, { source: 'hackernews', ttlSec: 3 * 3600 });
|
|
6
|
+
return { data: r.data?.nbHits ?? null, prov: r.prov };
|
|
7
|
+
}
|
|
8
|
+
/** Story counts per week for `weeks` weeks, oldest first. Null if any bucket failed. */
|
|
9
|
+
export async function weeklyStoryCounts(ctx, query, weeks = 8) {
|
|
10
|
+
// Align bucket edges to whole hours so the cache key stays stable within a run.
|
|
11
|
+
const nowSec = Math.floor(ctx.now().getTime() / 3_600_000) * 3600;
|
|
12
|
+
const weekSec = (7 * DAY_MS) / 1000;
|
|
13
|
+
const results = await Promise.all(Array.from({ length: weeks }, (_, i) => {
|
|
14
|
+
const to = nowSec - (weeks - 1 - i) * weekSec;
|
|
15
|
+
return countBetween(ctx, query, to - weekSec, to);
|
|
16
|
+
}));
|
|
17
|
+
const provs = results.map((r) => r.prov);
|
|
18
|
+
if (results.some((r) => r.data === null))
|
|
19
|
+
return { data: null, provs };
|
|
20
|
+
return { data: results.map((r) => r.data), provs };
|
|
21
|
+
}
|
|
22
|
+
/** Stories currently on the HN front page. */
|
|
23
|
+
export async function frontPage(ctx) {
|
|
24
|
+
const r = await ctx.http.get(`${HN}/search?tags=front_page&hitsPerPage=50`, {
|
|
25
|
+
source: 'hackernews',
|
|
26
|
+
ttlSec: 600,
|
|
27
|
+
});
|
|
28
|
+
return { data: r.data?.hits ?? null, prov: r.prov };
|
|
29
|
+
}
|
|
30
|
+
/** Most relevant/popular stories mentioning the query in the last `days` days. */
|
|
31
|
+
export async function recentMentions(ctx, query, days = 14, max = 20) {
|
|
32
|
+
const since = Math.floor((ctx.now().getTime() - days * DAY_MS) / 3_600_000) * 3600;
|
|
33
|
+
const url = `${HN}/search?query=${enc(query)}&tags=story&hitsPerPage=${max}&numericFilters=${enc(`created_at_i>${since}`)}`;
|
|
34
|
+
const r = await ctx.http.get(url, { source: 'hackernews', ttlSec: 1800 });
|
|
35
|
+
return { data: r.data?.hits ?? null, prov: r.prov };
|
|
36
|
+
}
|
|
37
|
+
export const hnItemUrl = (id) => `https://news.ycombinator.com/item?id=${id}`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open address labels: the eth-labels dataset (MIT, github.com/dawsbot/eth-labels), about 100k addresses
|
|
3
|
+
* across EVM chains tagged by exchange, protocol, bridge, scam and so on. Downloaded once and indexed into the
|
|
4
|
+
* local database; refreshed when older than 14 days. Lookups are offline and free.
|
|
5
|
+
*/
|
|
6
|
+
import type { Ctx } from '../core/context.js';
|
|
7
|
+
import type { Provenance } from '../core/types.js';
|
|
8
|
+
export interface AddressLabel {
|
|
9
|
+
chainId: number;
|
|
10
|
+
label: string;
|
|
11
|
+
nameTag: string;
|
|
12
|
+
}
|
|
13
|
+
/** Minimal CSV line parser for quoted fields. */
|
|
14
|
+
export declare function parseCsvLine(line: string): string[];
|
|
15
|
+
/** Load rows from CSV text into the table. Returns the number stored. */
|
|
16
|
+
export declare function loadLabels(ctx: Ctx, csv: string): number;
|
|
17
|
+
/** Make sure the dataset is present and fresh; downloads about 12 MB at most every 14 days. */
|
|
18
|
+
export declare function ensureLabels(ctx: Ctx): Promise<Provenance>;
|
|
19
|
+
export declare function labelsFor(ctx: Ctx, address: string): AddressLabel[];
|
|
20
|
+
/** Short human tag, e.g. "Binance 14 (binance)". */
|
|
21
|
+
export declare function describeLabels(ls: AddressLabel[]): string | null;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const URL_CSV = 'https://raw.githubusercontent.com/dawsbot/eth-labels/HEAD/data/csv/accounts.csv';
|
|
2
|
+
const REFRESH_MS = 14 * 86_400_000;
|
|
3
|
+
/** Minimal CSV line parser for quoted fields. */
|
|
4
|
+
export function parseCsvLine(line) {
|
|
5
|
+
const out = [];
|
|
6
|
+
let cur = '';
|
|
7
|
+
let q = false;
|
|
8
|
+
for (let i = 0; i < line.length; i++) {
|
|
9
|
+
const ch = line[i];
|
|
10
|
+
if (q) {
|
|
11
|
+
if (ch === '"' && line[i + 1] === '"')
|
|
12
|
+
(cur += '"'), i++;
|
|
13
|
+
else if (ch === '"')
|
|
14
|
+
q = false;
|
|
15
|
+
else
|
|
16
|
+
cur += ch;
|
|
17
|
+
}
|
|
18
|
+
else if (ch === '"')
|
|
19
|
+
q = true;
|
|
20
|
+
else if (ch === ',')
|
|
21
|
+
out.push(cur), (cur = '');
|
|
22
|
+
else
|
|
23
|
+
cur += ch;
|
|
24
|
+
}
|
|
25
|
+
out.push(cur);
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
function ensureTable(ctx) {
|
|
29
|
+
ctx.store.db.exec(`CREATE TABLE IF NOT EXISTS address_labels (
|
|
30
|
+
address TEXT NOT NULL, chain_id INTEGER NOT NULL, label TEXT NOT NULL, name_tag TEXT NOT NULL,
|
|
31
|
+
PRIMARY KEY (address, chain_id, label)
|
|
32
|
+
)`);
|
|
33
|
+
}
|
|
34
|
+
/** Load rows from CSV text into the table. Returns the number stored. */
|
|
35
|
+
export function loadLabels(ctx, csv) {
|
|
36
|
+
ensureTable(ctx);
|
|
37
|
+
const db = ctx.store.db;
|
|
38
|
+
const ins = db.prepare('INSERT OR REPLACE INTO address_labels (address, chain_id, label, name_tag) VALUES (?, ?, ?, ?)');
|
|
39
|
+
let n = 0;
|
|
40
|
+
db.exec('BEGIN');
|
|
41
|
+
try {
|
|
42
|
+
db.exec('DELETE FROM address_labels');
|
|
43
|
+
for (const line of csv.split('\n').slice(1)) {
|
|
44
|
+
if (!line.trim())
|
|
45
|
+
continue;
|
|
46
|
+
const [address, chainId, label, nameTag] = parseCsvLine(line.trim());
|
|
47
|
+
if (!address || !/^0x[0-9a-fA-F]{40}$/.test(address))
|
|
48
|
+
continue;
|
|
49
|
+
ins.run(address.toLowerCase(), Number(chainId) || 1, label ?? '', nameTag ?? '');
|
|
50
|
+
n++;
|
|
51
|
+
}
|
|
52
|
+
db.exec('COMMIT');
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
db.exec('ROLLBACK');
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
58
|
+
ctx.store.cachePut('derived:eth-labels:loaded', String(n), ctx.now().getTime());
|
|
59
|
+
return n;
|
|
60
|
+
}
|
|
61
|
+
/** Make sure the dataset is present and fresh; downloads about 12 MB at most every 14 days. */
|
|
62
|
+
export async function ensureLabels(ctx) {
|
|
63
|
+
ensureTable(ctx);
|
|
64
|
+
const loaded = ctx.store.cacheGet('derived:eth-labels:loaded');
|
|
65
|
+
const nowIso = ctx.now().toISOString();
|
|
66
|
+
if (loaded && ctx.now().getTime() - loaded.fetchedAt < REFRESH_MS)
|
|
67
|
+
return { source: 'eth-labels', url: URL_CSV, status: 'CACHED', fetchedAt: new Date(loaded.fetchedAt).toISOString(), note: `${loaded.body} labeled addresses` };
|
|
68
|
+
const r = await ctx.http.get(URL_CSV, { source: 'eth-labels', as: 'text', ttlSec: 0, timeoutMs: 120_000 });
|
|
69
|
+
if (!r.data)
|
|
70
|
+
return loaded ? { ...r.prov, status: 'CACHED', note: 'refresh failed; using the stored copy' } : r.prov;
|
|
71
|
+
const n = loadLabels(ctx, r.data);
|
|
72
|
+
// The raw CSV is in the table now; no need to keep it in the HTTP cache too.
|
|
73
|
+
ctx.store.db.prepare('DELETE FROM cache WHERE key = ?').run(URL_CSV);
|
|
74
|
+
return { ...r.prov, note: `${n} labeled addresses`, fetchedAt: nowIso };
|
|
75
|
+
}
|
|
76
|
+
export function labelsFor(ctx, address) {
|
|
77
|
+
ensureTable(ctx);
|
|
78
|
+
return ctx.store.db.prepare('SELECT chain_id, label, name_tag FROM address_labels WHERE address = ? ORDER BY chain_id').all(address.toLowerCase()).map((r) => ({ chainId: r.chain_id, label: r.label, nameTag: r.name_tag }));
|
|
79
|
+
}
|
|
80
|
+
/** Short human tag, e.g. "Binance 14 (binance)". */
|
|
81
|
+
export function describeLabels(ls) {
|
|
82
|
+
if (!ls.length)
|
|
83
|
+
return null;
|
|
84
|
+
const tag = ls.find((l) => l.nameTag)?.nameTag;
|
|
85
|
+
const kinds = [...new Set(ls.map((l) => l.label))].slice(0, 3).join(', ');
|
|
86
|
+
return tag ? `${tag} (${kinds})` : kinds;
|
|
87
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Launch footprints beyond the web: Hugging Face models, App Store apps, npm packages. All keyless. */
|
|
2
|
+
import { type Ctx } from '../core/context.js';
|
|
3
|
+
import type { Sourced } from '../core/types.js';
|
|
4
|
+
export interface LaunchItem {
|
|
5
|
+
kind: 'model' | 'dataset' | 'space' | 'app' | 'app-update' | 'package';
|
|
6
|
+
title: string;
|
|
7
|
+
date: string;
|
|
8
|
+
url: string;
|
|
9
|
+
detail?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Newest Hugging Face models, datasets and Spaces of an org. */
|
|
12
|
+
export declare function huggingFace(ctx: Ctx, org: string, limit?: number): Promise<Sourced<LaunchItem[]>>;
|
|
13
|
+
/** iOS apps whose developer name matches the company: new releases and fresh updates. */
|
|
14
|
+
export declare function appStore(ctx: Ctx, company: string): Promise<Sourced<LaunchItem[]>>;
|
|
15
|
+
/** npm packages published under the org's scope (@org/...), with their creation dates. */
|
|
16
|
+
export declare function npmScope(ctx: Ctx, org: string, limit?: number): Promise<Sourced<LaunchItem[]>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Launch footprints beyond the web: Hugging Face models, App Store apps, npm packages. All keyless. */
|
|
2
|
+
import { enc } from '../core/context.js';
|
|
3
|
+
/** Newest Hugging Face models, datasets and Spaces of an org. */
|
|
4
|
+
export async function huggingFace(ctx, org, limit = 15) {
|
|
5
|
+
const kinds = [
|
|
6
|
+
['models', 'model'],
|
|
7
|
+
['datasets', 'dataset'],
|
|
8
|
+
['spaces', 'space'],
|
|
9
|
+
];
|
|
10
|
+
const results = await Promise.all(kinds.map(([path]) => ctx.http.get(`https://huggingface.co/api/${path}?author=${enc(org)}&sort=createdAt&direction=-1&limit=${limit}`, { source: 'huggingface', ttlSec: 3 * 3600 })));
|
|
11
|
+
const first = results.find((r) => r.data) ?? results[0];
|
|
12
|
+
if (results.every((r) => !r.data))
|
|
13
|
+
return { data: null, prov: first.prov };
|
|
14
|
+
const data = results.flatMap((r, i) => (r.data ?? []).filter((x) => x.createdAt).map((x) => ({ kind: kinds[i][1], title: x.id, date: x.createdAt, url: `https://huggingface.co/${kinds[i][0] === 'models' ? '' : `${kinds[i][0]}/`}${x.id}` })));
|
|
15
|
+
return { data, prov: first.prov };
|
|
16
|
+
}
|
|
17
|
+
/** iOS apps whose developer name matches the company: new releases and fresh updates. */
|
|
18
|
+
export async function appStore(ctx, company) {
|
|
19
|
+
const r = await ctx.http.get(`https://itunes.apple.com/search?term=${enc(company)}&entity=software&limit=50`, { source: 'itunes', ttlSec: 6 * 3600 });
|
|
20
|
+
const name = company.toLowerCase();
|
|
21
|
+
const mine = (r.data?.results ?? []).filter((a) => a.artistName.toLowerCase().includes(name));
|
|
22
|
+
const data = [];
|
|
23
|
+
for (const a of mine) {
|
|
24
|
+
data.push({ kind: 'app', title: a.trackName, date: a.releaseDate, url: a.trackViewUrl, detail: `by ${a.artistName}` });
|
|
25
|
+
if (a.currentVersionReleaseDate && a.currentVersionReleaseDate !== a.releaseDate) {
|
|
26
|
+
data.push({ kind: 'app-update', title: `${a.trackName} ${a.version ?? ''}`.trim(), date: a.currentVersionReleaseDate, url: a.trackViewUrl, ...(a.releaseNotes ? { detail: a.releaseNotes.replace(/\s+/g, ' ').slice(0, 160) } : {}) });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return { data: r.data ? data : null, prov: r.prov };
|
|
30
|
+
}
|
|
31
|
+
/** npm packages published under the org's scope (@org/...), with their creation dates. */
|
|
32
|
+
export async function npmScope(ctx, org, limit = 25) {
|
|
33
|
+
const r = await ctx.http.get(`https://registry.npmjs.org/-/v1/search?text=${enc(`@${org}`)}&size=${limit}`, { source: 'npm', ttlSec: 3 * 3600 });
|
|
34
|
+
const pkgs = (r.data?.objects ?? []).map((o) => o.package).filter((p) => p.name.startsWith(`@${org.toLowerCase()}/`));
|
|
35
|
+
const docs = await Promise.all(pkgs.slice(0, 12).map((p) => ctx.http.get(`https://registry.npmjs.org/${enc(p.name).replace('%40', '@')}`, { source: 'npm', ttlSec: 24 * 3600, keep: (d) => ({ time: { created: d?.time?.created } }) })));
|
|
36
|
+
const data = pkgs.slice(0, 12).flatMap((p, i) => {
|
|
37
|
+
const created = docs[i]?.data?.time?.created;
|
|
38
|
+
return created ? [{ kind: 'package', title: p.name, date: created, url: p.links?.npm ?? `https://www.npmjs.com/package/${p.name}`, ...(p.description ? { detail: p.description.slice(0, 140) } : {}) }] : [];
|
|
39
|
+
});
|
|
40
|
+
return { data: r.data ? data : null, prov: r.prov };
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* US Treasury OFAC Specially Designated Nationals list (public domain). Downloaded as CSV, parsed once a day,
|
|
3
|
+
* and indexed by digital-currency address, vessel IMO number and normalized name.
|
|
4
|
+
*/
|
|
5
|
+
import type { Ctx } from '../core/context.js';
|
|
6
|
+
import type { Provenance } from '../core/types.js';
|
|
7
|
+
export interface SdnEntry {
|
|
8
|
+
uid: string;
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
program: string;
|
|
12
|
+
remarks: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SdnIndex {
|
|
15
|
+
entries: SdnEntry[];
|
|
16
|
+
byAddress: Map<string, SdnEntry>;
|
|
17
|
+
byImo: Map<string, SdnEntry>;
|
|
18
|
+
byName: Map<string, SdnEntry>;
|
|
19
|
+
fetchedAt: string;
|
|
20
|
+
}
|
|
21
|
+
/** CSV line parser for the SDN file (quoted fields, "-0-" means empty). */
|
|
22
|
+
export declare function parseSdnCsv(csv: string): SdnEntry[];
|
|
23
|
+
export declare const normName: (s: string) => string;
|
|
24
|
+
export declare function buildIndex(entries: SdnEntry[], fetchedAt: string): SdnIndex;
|
|
25
|
+
/** The SDN index, refreshed at most once a day. */
|
|
26
|
+
export declare function sdn(ctx: Ctx): Promise<{
|
|
27
|
+
data: SdnIndex | null;
|
|
28
|
+
prov: Provenance;
|
|
29
|
+
}>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const URL_SDN = 'https://www.treasury.gov/ofac/downloads/sdn.csv';
|
|
2
|
+
const DERIVED = 'derived:ofac-sdn:v1';
|
|
3
|
+
let memo = null;
|
|
4
|
+
/** CSV line parser for the SDN file (quoted fields, "-0-" means empty). */
|
|
5
|
+
export function parseSdnCsv(csv) {
|
|
6
|
+
const out = [];
|
|
7
|
+
for (const line of csv.split(/\r?\n/)) {
|
|
8
|
+
if (!line.trim())
|
|
9
|
+
continue;
|
|
10
|
+
const f = [];
|
|
11
|
+
let cur = '';
|
|
12
|
+
let q = false;
|
|
13
|
+
for (let i = 0; i < line.length; i++) {
|
|
14
|
+
const c = line[i];
|
|
15
|
+
if (q) {
|
|
16
|
+
if (c === '"' && line[i + 1] === '"') {
|
|
17
|
+
cur += '"';
|
|
18
|
+
i++;
|
|
19
|
+
}
|
|
20
|
+
else if (c === '"')
|
|
21
|
+
q = false;
|
|
22
|
+
else
|
|
23
|
+
cur += c;
|
|
24
|
+
}
|
|
25
|
+
else if (c === '"')
|
|
26
|
+
q = true;
|
|
27
|
+
else if (c === ',') {
|
|
28
|
+
f.push(cur);
|
|
29
|
+
cur = '';
|
|
30
|
+
}
|
|
31
|
+
else
|
|
32
|
+
cur += c;
|
|
33
|
+
}
|
|
34
|
+
f.push(cur);
|
|
35
|
+
const v = (i) => (f[i] ?? '').trim().replace(/^-0-$/, '');
|
|
36
|
+
if (!v(0) || !v(1))
|
|
37
|
+
continue;
|
|
38
|
+
out.push({ uid: v(0), name: v(1), type: v(2) || 'entity', program: v(3), remarks: v(11) });
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
export const normName = (s) => s
|
|
43
|
+
.toUpperCase()
|
|
44
|
+
.normalize('NFKD')
|
|
45
|
+
.replace(/[^A-Z0-9 ]/g, ' ')
|
|
46
|
+
.replace(/\b(LTD|LLC|INC|CO|CORP|CORPORATION|COMPANY|LIMITED|SA|JSC|OOO|PJSC|GMBH|FZE|FZCO)\b/g, '')
|
|
47
|
+
.replace(/\s+/g, ' ')
|
|
48
|
+
.trim();
|
|
49
|
+
export function buildIndex(entries, fetchedAt) {
|
|
50
|
+
const byAddress = new Map();
|
|
51
|
+
const byImo = new Map();
|
|
52
|
+
const byName = new Map();
|
|
53
|
+
for (const e of entries) {
|
|
54
|
+
for (const m of e.remarks.matchAll(/Digital Currency Address - [A-Z0-9]+ ([A-Za-z0-9]+)/g))
|
|
55
|
+
byAddress.set(m[1].toLowerCase(), e);
|
|
56
|
+
for (const m of e.remarks.matchAll(/IMO (\d{7})/g))
|
|
57
|
+
byImo.set(m[1], e);
|
|
58
|
+
byName.set(normName(e.name), e);
|
|
59
|
+
for (const m of e.remarks.matchAll(/a\.k\.a\. '([^']+)'/g))
|
|
60
|
+
byName.set(normName(m[1]), e);
|
|
61
|
+
}
|
|
62
|
+
return { entries, byAddress, byImo, byName, fetchedAt };
|
|
63
|
+
}
|
|
64
|
+
/** The SDN index, refreshed at most once a day. */
|
|
65
|
+
export async function sdn(ctx) {
|
|
66
|
+
if (memo && Date.now() - Date.parse(memo.fetchedAt) < 86_400_000)
|
|
67
|
+
return { data: memo, prov: { source: 'ofac', url: URL_SDN, status: 'CACHED', fetchedAt: memo.fetchedAt } };
|
|
68
|
+
const cached = ctx.store.cacheGet(DERIVED);
|
|
69
|
+
if (cached && Date.now() - cached.fetchedAt < 86_400_000) {
|
|
70
|
+
memo = buildIndex(JSON.parse(cached.body), new Date(cached.fetchedAt).toISOString());
|
|
71
|
+
return { data: memo, prov: { source: 'ofac', url: URL_SDN, status: 'CACHED', fetchedAt: memo.fetchedAt } };
|
|
72
|
+
}
|
|
73
|
+
const r = await ctx.http.get(URL_SDN, { source: 'ofac', as: 'text', ttlSec: 0, timeoutMs: 90_000 });
|
|
74
|
+
ctx.store.db.prepare('DELETE FROM cache WHERE key = ?').run(URL_SDN);
|
|
75
|
+
if (!r.data) {
|
|
76
|
+
if (cached) {
|
|
77
|
+
memo = buildIndex(JSON.parse(cached.body), new Date(cached.fetchedAt).toISOString());
|
|
78
|
+
return { data: memo, prov: { ...r.prov, status: 'CACHED', note: 'stale sanctions list' } };
|
|
79
|
+
}
|
|
80
|
+
return { data: null, prov: r.prov };
|
|
81
|
+
}
|
|
82
|
+
const entries = parseSdnCsv(r.data);
|
|
83
|
+
ctx.store.cachePut(DERIVED, JSON.stringify(entries));
|
|
84
|
+
memo = buildIndex(entries, new Date().toISOString());
|
|
85
|
+
return { data: memo, prov: r.prov };
|
|
86
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-chain sources: Zerion (portfolio), Etherscan v2 (transactions, multi-chain), GoPlus (token/address security),
|
|
3
|
+
* (public endpoints; GoPlus keys are not needed for these calls), Webacy (address risk), DexScreener (pairs, keyless), Helius (Solana), Robinhood Chain RPC + Blockscout.
|
|
4
|
+
*/
|
|
5
|
+
import { type Ctx } from '../core/context.js';
|
|
6
|
+
import type { Sourced } from '../core/types.js';
|
|
7
|
+
export declare const isEvmAddress: (s: string) => boolean;
|
|
8
|
+
export declare const isSolanaAddress: (s: string) => boolean;
|
|
9
|
+
export declare const CHAINS: Record<string, {
|
|
10
|
+
id: number;
|
|
11
|
+
goplus: string | null;
|
|
12
|
+
coingecko: string | null;
|
|
13
|
+
label: string;
|
|
14
|
+
}>;
|
|
15
|
+
export interface Portfolio {
|
|
16
|
+
totalUsd: number;
|
|
17
|
+
change1dPct: number | null;
|
|
18
|
+
byChain: Record<string, number>;
|
|
19
|
+
top: {
|
|
20
|
+
name: string;
|
|
21
|
+
symbol: string;
|
|
22
|
+
chain: string;
|
|
23
|
+
valueUsd: number;
|
|
24
|
+
}[];
|
|
25
|
+
}
|
|
26
|
+
export declare function zerionPortfolio(ctx: Ctx, address: string): Promise<Sourced<Portfolio>>;
|
|
27
|
+
export interface Tx {
|
|
28
|
+
hash: string;
|
|
29
|
+
time: string;
|
|
30
|
+
from: string;
|
|
31
|
+
to: string;
|
|
32
|
+
valueEth: number;
|
|
33
|
+
method: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function etherscanTxs(ctx: Ctx, address: string, chainId?: number, sort?: 'asc' | 'desc', n?: number): Promise<Sourced<Tx[]>>;
|
|
36
|
+
export interface TokenRisk {
|
|
37
|
+
name: string;
|
|
38
|
+
symbol: string;
|
|
39
|
+
flags: string[];
|
|
40
|
+
buyTax: number | null;
|
|
41
|
+
sellTax: number | null;
|
|
42
|
+
holders: number | null;
|
|
43
|
+
ownerPercent: number | null;
|
|
44
|
+
inDex: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function tokenSecurity(ctx: Ctx, chain: string, address: string): Promise<Sourced<TokenRisk>>;
|
|
47
|
+
/** GoPlus malicious-address labels (phishing, sanctioned, stealing attack, ...). */
|
|
48
|
+
export declare function addressSecurity(ctx: Ctx, address: string, chainId?: string): Promise<Sourced<string[]>>;
|
|
49
|
+
export declare function webacyRisk(ctx: Ctx, address: string, chain?: string): Promise<Sourced<{
|
|
50
|
+
score: number | null;
|
|
51
|
+
issues: string[];
|
|
52
|
+
}>>;
|
|
53
|
+
export interface Pair {
|
|
54
|
+
chain: string;
|
|
55
|
+
dex: string;
|
|
56
|
+
pair: string;
|
|
57
|
+
priceUsd: number | null;
|
|
58
|
+
liquidityUsd: number | null;
|
|
59
|
+
volume24h: number | null;
|
|
60
|
+
change24h: number | null;
|
|
61
|
+
createdAt: string | null;
|
|
62
|
+
url: string;
|
|
63
|
+
}
|
|
64
|
+
/** DexScreener chain ids for our chain names. */
|
|
65
|
+
export declare const DEX_CHAIN: Record<string, string>;
|
|
66
|
+
/** Pairs for a token on one chain only (same contract addresses exist on forks such as PulseChain). */
|
|
67
|
+
export declare function dexPairs(ctx: Ctx, token: string, chain?: string): Promise<Sourced<Pair[]>>;
|
|
68
|
+
/** Native balance and transaction count on Robinhood Chain (public RPC). */
|
|
69
|
+
export declare function robinhoodAccount(ctx: Ctx, address: string): Promise<Sourced<{
|
|
70
|
+
balanceEth: number;
|
|
71
|
+
txCount: number;
|
|
72
|
+
isContract: boolean;
|
|
73
|
+
}>>;
|
|
74
|
+
export declare function solanaAccount(ctx: Ctx, address: string): Promise<Sourced<{
|
|
75
|
+
sol: number;
|
|
76
|
+
tokens: number;
|
|
77
|
+
}>>;
|