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.
Files changed (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +344 -2
  3. package/dist/agent.d.ts +47 -0
  4. package/dist/agent.js +104 -0
  5. package/dist/cases.d.ts +68 -0
  6. package/dist/cases.js +158 -0
  7. package/dist/cli/main.d.ts +12 -0
  8. package/dist/cli/main.js +1999 -0
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.js +15 -0
  11. package/dist/core/context.d.ts +19 -0
  12. package/dist/core/context.js +19 -0
  13. package/dist/core/features.d.ts +22 -0
  14. package/dist/core/features.js +28 -0
  15. package/dist/core/graph.d.ts +38 -0
  16. package/dist/core/graph.js +81 -0
  17. package/dist/core/http.d.ts +42 -0
  18. package/dist/core/http.js +266 -0
  19. package/dist/core/keys.d.ts +8 -0
  20. package/dist/core/keys.js +22 -0
  21. package/dist/core/llm.d.ts +93 -0
  22. package/dist/core/llm.js +180 -0
  23. package/dist/core/merkle.d.ts +15 -0
  24. package/dist/core/merkle.js +46 -0
  25. package/dist/core/paths.d.ts +2 -0
  26. package/dist/core/paths.js +6 -0
  27. package/dist/core/png.d.ts +17 -0
  28. package/dist/core/png.js +101 -0
  29. package/dist/core/quota.d.ts +15 -0
  30. package/dist/core/quota.js +90 -0
  31. package/dist/core/stats.d.ts +24 -0
  32. package/dist/core/stats.js +67 -0
  33. package/dist/core/store.d.ts +20 -0
  34. package/dist/core/store.js +213 -0
  35. package/dist/core/text.d.ts +9 -0
  36. package/dist/core/text.js +30 -0
  37. package/dist/core/types.d.ts +38 -0
  38. package/dist/core/types.js +1 -0
  39. package/dist/index.d.ts +342 -0
  40. package/dist/index.js +495 -0
  41. package/dist/live.d.ts +53 -0
  42. package/dist/live.js +236 -0
  43. package/dist/mcp.d.ts +43 -0
  44. package/dist/mcp.js +651 -0
  45. package/dist/modules/airport.d.ts +60 -0
  46. package/dist/modules/airport.js +111 -0
  47. package/dist/modules/audit.d.ts +73 -0
  48. package/dist/modules/audit.js +211 -0
  49. package/dist/modules/bgp.d.ts +147 -0
  50. package/dist/modules/bgp.js +206 -0
  51. package/dist/modules/blackout.d.ts +41 -0
  52. package/dist/modules/blackout.js +98 -0
  53. package/dist/modules/brief.d.ts +26 -0
  54. package/dist/modules/brief.js +99 -0
  55. package/dist/modules/calendar.d.ts +27 -0
  56. package/dist/modules/calendar.js +145 -0
  57. package/dist/modules/calibrate.d.ts +46 -0
  58. package/dist/modules/calibrate.js +92 -0
  59. package/dist/modules/cloud.d.ts +32 -0
  60. package/dist/modules/cloud.js +94 -0
  61. package/dist/modules/condor.d.ts +66 -0
  62. package/dist/modules/condor.js +214 -0
  63. package/dist/modules/connect.d.ts +47 -0
  64. package/dist/modules/connect.js +114 -0
  65. package/dist/modules/contradictions.d.ts +27 -0
  66. package/dist/modules/contradictions.js +76 -0
  67. package/dist/modules/country.d.ts +82 -0
  68. package/dist/modules/country.js +136 -0
  69. package/dist/modules/cricket.d.ts +34 -0
  70. package/dist/modules/cricket.js +166 -0
  71. package/dist/modules/darkships.d.ts +219 -0
  72. package/dist/modules/darkships.js +400 -0
  73. package/dist/modules/defi.d.ts +237 -0
  74. package/dist/modules/defi.js +512 -0
  75. package/dist/modules/emailsec.d.ts +47 -0
  76. package/dist/modules/emailsec.js +146 -0
  77. package/dist/modules/exposure.d.ts +43 -0
  78. package/dist/modules/exposure.js +89 -0
  79. package/dist/modules/factcheck.d.ts +39 -0
  80. package/dist/modules/factcheck.js +127 -0
  81. package/dist/modules/falcon.d.ts +58 -0
  82. package/dist/modules/falcon.js +219 -0
  83. package/dist/modules/feedback.d.ts +24 -0
  84. package/dist/modules/feedback.js +37 -0
  85. package/dist/modules/fence.d.ts +52 -0
  86. package/dist/modules/fence.js +128 -0
  87. package/dist/modules/ferret.d.ts +47 -0
  88. package/dist/modules/ferret.js +220 -0
  89. package/dist/modules/filings.d.ts +86 -0
  90. package/dist/modules/filings.js +166 -0
  91. package/dist/modules/fires.d.ts +56 -0
  92. package/dist/modules/fires.js +150 -0
  93. package/dist/modules/hazards.d.ts +37 -0
  94. package/dist/modules/hazards.js +83 -0
  95. package/dist/modules/health.d.ts +24 -0
  96. package/dist/modules/health.js +82 -0
  97. package/dist/modules/heron.d.ts +68 -0
  98. package/dist/modules/heron.js +184 -0
  99. package/dist/modules/hound.d.ts +100 -0
  100. package/dist/modules/hound.js +301 -0
  101. package/dist/modules/impact.d.ts +39 -0
  102. package/dist/modules/impact.js +63 -0
  103. package/dist/modules/launches.d.ts +24 -0
  104. package/dist/modules/launches.js +61 -0
  105. package/dist/modules/listen.d.ts +48 -0
  106. package/dist/modules/listen.js +125 -0
  107. package/dist/modules/lynx.d.ts +43 -0
  108. package/dist/modules/lynx.js +127 -0
  109. package/dist/modules/magpie.d.ts +70 -0
  110. package/dist/modules/magpie.js +174 -0
  111. package/dist/modules/meerkat.d.ts +42 -0
  112. package/dist/modules/meerkat.js +293 -0
  113. package/dist/modules/monitor.d.ts +27 -0
  114. package/dist/modules/monitor.js +105 -0
  115. package/dist/modules/narratives.d.ts +33 -0
  116. package/dist/modules/narratives.js +136 -0
  117. package/dist/modules/owl.d.ts +71 -0
  118. package/dist/modules/owl.js +290 -0
  119. package/dist/modules/papers.d.ts +46 -0
  120. package/dist/modules/papers.js +135 -0
  121. package/dist/modules/personal.d.ts +54 -0
  122. package/dist/modules/personal.js +153 -0
  123. package/dist/modules/pulse.d.ts +19 -0
  124. package/dist/modules/pulse.js +59 -0
  125. package/dist/modules/raven.d.ts +80 -0
  126. package/dist/modules/raven.js +147 -0
  127. package/dist/modules/recall.d.ts +44 -0
  128. package/dist/modules/recall.js +123 -0
  129. package/dist/modules/regs.d.ts +88 -0
  130. package/dist/modules/regs.js +142 -0
  131. package/dist/modules/rewind.d.ts +22 -0
  132. package/dist/modules/rewind.js +68 -0
  133. package/dist/modules/sanctions.d.ts +62 -0
  134. package/dist/modules/sanctions.js +173 -0
  135. package/dist/modules/scam.d.ts +43 -0
  136. package/dist/modules/scam.js +111 -0
  137. package/dist/modules/scoop.d.ts +31 -0
  138. package/dist/modules/scoop.js +74 -0
  139. package/dist/modules/ships.d.ts +33 -0
  140. package/dist/modules/ships.js +113 -0
  141. package/dist/modules/sky.d.ts +47 -0
  142. package/dist/modules/sky.js +183 -0
  143. package/dist/modules/squawk.d.ts +46 -0
  144. package/dist/modules/squawk.js +106 -0
  145. package/dist/modules/tortoise.d.ts +40 -0
  146. package/dist/modules/tortoise.js +104 -0
  147. package/dist/modules/travel.d.ts +94 -0
  148. package/dist/modules/travel.js +241 -0
  149. package/dist/modules/urlcheck.d.ts +63 -0
  150. package/dist/modules/urlcheck.js +223 -0
  151. package/dist/modules/vulns.d.ts +142 -0
  152. package/dist/modules/vulns.js +276 -0
  153. package/dist/plugins.d.ts +41 -0
  154. package/dist/plugins.js +70 -0
  155. package/dist/report.d.ts +12 -0
  156. package/dist/report.js +90 -0
  157. package/dist/scheduler.d.ts +22 -0
  158. package/dist/scheduler.js +139 -0
  159. package/dist/sources/aircraft.d.ts +76 -0
  160. package/dist/sources/aircraft.js +107 -0
  161. package/dist/sources/airports.d.ts +28 -0
  162. package/dist/sources/airports.js +100 -0
  163. package/dist/sources/ais.d.ts +32 -0
  164. package/dist/sources/ais.js +111 -0
  165. package/dist/sources/apify.d.ts +28 -0
  166. package/dist/sources/apify.js +80 -0
  167. package/dist/sources/arxiv.d.ts +13 -0
  168. package/dist/sources/arxiv.js +27 -0
  169. package/dist/sources/certs.d.ts +12 -0
  170. package/dist/sources/certs.js +23 -0
  171. package/dist/sources/corp.d.ts +46 -0
  172. package/dist/sources/corp.js +60 -0
  173. package/dist/sources/earth.d.ts +39 -0
  174. package/dist/sources/earth.js +76 -0
  175. package/dist/sources/fda.d.ts +77 -0
  176. package/dist/sources/fda.js +121 -0
  177. package/dist/sources/finance.d.ts +181 -0
  178. package/dist/sources/finance.js +270 -0
  179. package/dist/sources/gdelt.d.ts +19 -0
  180. package/dist/sources/gdelt.js +33 -0
  181. package/dist/sources/github.d.ts +17 -0
  182. package/dist/sources/github.js +33 -0
  183. package/dist/sources/hackernews.d.ts +20 -0
  184. package/dist/sources/hackernews.js +37 -0
  185. package/dist/sources/labels.d.ts +21 -0
  186. package/dist/sources/labels.js +87 -0
  187. package/dist/sources/launch.d.ts +16 -0
  188. package/dist/sources/launch.js +41 -0
  189. package/dist/sources/ofac.d.ts +29 -0
  190. package/dist/sources/ofac.js +86 -0
  191. package/dist/sources/onchain.d.ts +77 -0
  192. package/dist/sources/onchain.js +189 -0
  193. package/dist/sources/opentimestamps.d.ts +44 -0
  194. package/dist/sources/opentimestamps.js +131 -0
  195. package/dist/sources/polymarket.d.ts +36 -0
  196. package/dist/sources/polymarket.js +70 -0
  197. package/dist/sources/predict.d.ts +18 -0
  198. package/dist/sources/predict.js +59 -0
  199. package/dist/sources/press.d.ts +30 -0
  200. package/dist/sources/press.js +111 -0
  201. package/dist/sources/resend.d.ts +14 -0
  202. package/dist/sources/resend.js +29 -0
  203. package/dist/sources/robinhood.d.ts +109 -0
  204. package/dist/sources/robinhood.js +129 -0
  205. package/dist/sources/sec.d.ts +67 -0
  206. package/dist/sources/sec.js +129 -0
  207. package/dist/sources/sentinel.d.ts +13 -0
  208. package/dist/sources/sentinel.js +63 -0
  209. package/dist/sources/signatures.d.ts +14 -0
  210. package/dist/sources/signatures.js +103 -0
  211. package/dist/sources/social.d.ts +22 -0
  212. package/dist/sources/social.js +56 -0
  213. package/dist/sources/space.d.ts +160 -0
  214. package/dist/sources/space.js +230 -0
  215. package/dist/sources/usgs.d.ts +17 -0
  216. package/dist/sources/usgs.js +24 -0
  217. package/dist/sources/wayback.d.ts +10 -0
  218. package/dist/sources/wayback.js +28 -0
  219. package/dist/sources/websec.d.ts +19 -0
  220. package/dist/sources/websec.js +40 -0
  221. package/dist/sources/wikidata.d.ts +11 -0
  222. package/dist/sources/wikidata.js +30 -0
  223. package/dist/sources/wikimedia.d.ts +28 -0
  224. package/dist/sources/wikimedia.js +52 -0
  225. package/dist/telegram.d.ts +104 -0
  226. package/dist/telegram.js +927 -0
  227. package/dist/web/assets/favicon-32.png +0 -0
  228. package/dist/web/assets/fx.js +178 -0
  229. package/dist/web/assets/icon-192.png +0 -0
  230. package/dist/web/assets/icon-512.png +0 -0
  231. package/dist/web/assets/icon-maskable-512.png +0 -0
  232. package/dist/web/assets/night-americas.jpg +0 -0
  233. package/dist/web/assets/night-emea.jpg +0 -0
  234. package/dist/web/assets/og.png +0 -0
  235. package/dist/web/assets/redsea-bm.jpg +0 -0
  236. package/dist/web/docs.html +263 -0
  237. package/dist/web/index.html +1828 -0
  238. package/dist/web/insights.d.ts +100 -0
  239. package/dist/web/insights.js +134 -0
  240. package/dist/web/landing.html +1143 -0
  241. package/dist/web/legal.html +176 -0
  242. package/dist/web/manifest.webmanifest +20 -0
  243. package/dist/web/mcp.html +104 -0
  244. package/dist/web/mcphttp.d.ts +10 -0
  245. package/dist/web/mcphttp.js +67 -0
  246. package/dist/web/openapi.d.ts +1 -0
  247. package/dist/web/openapi.js +51 -0
  248. package/dist/web/public.d.ts +45 -0
  249. package/dist/web/public.js +135 -0
  250. package/dist/web/server.d.ts +69 -0
  251. package/dist/web/server.js +750 -0
  252. package/dist/web/share.d.ts +35 -0
  253. package/dist/web/share.js +132 -0
  254. package/dist/web/sw.js +28 -0
  255. package/package.json +60 -4
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Ferret: finds footprints of things that are not announced yet.
3
+ * New hostnames in Certificate Transparency logs, pages that only recently appeared in the
4
+ * Wayback Machine, hosts seen in urlscan.io scans, freshly created public GitHub repos, and Google Safe Browsing
5
+ * verdicts on everything new.
6
+ */
7
+ import { DAY_MS } from '../core/context.js';
8
+ import { entityId } from '../core/graph.js';
9
+ import { clamp } from '../core/stats.js';
10
+ import { signalId } from '../core/text.js';
11
+ import { certspotter, crtsh } from '../sources/certs.js';
12
+ import { recentRepos } from '../sources/github.js';
13
+ import { captures, normalizePath } from '../sources/wayback.js';
14
+ import { safeBrowsing, urlscan } from '../sources/websec.js';
15
+ const HOT = [
16
+ [/\b(beta|preview|alpha|early|waitlist|preorder|pre-order)\b/, 25, 'pre-release word'],
17
+ [/\b(labs?|research|experimental|exp|next|future|sandbox|playground)\b/, 18, 'experimental area'],
18
+ [/\b(launch|announce|reveal|event|keynote|invite)\b/, 18, 'launch word'],
19
+ [/\b(device|hardware|glasses|watch|car|robot|phone|wearable|chip)\b/, 20, 'hardware word'],
20
+ [/\b(agent|agents|assistant|copilot|ai|gpt|model|voice|vision|video)\b/, 12, 'AI product word'],
21
+ [/\b(pay|wallet|card|checkout|store|shop|marketplace|ads|commerce)\b/, 12, 'commerce word'],
22
+ [/\b(app|studio|platform|pro|plus|max|enterprise|business|team|edu)\b/, 8, 'product word'],
23
+ [/\b(v\d+|\d+\.\d+|gen\d+)\b/, 10, 'version marker'],
24
+ ];
25
+ const NOISE = [
26
+ /^(www|mail|smtp|imap|pop|mx\d*|webmail|autodiscover|autoconfig|cpanel|whm|ftp|ns\d*|mta-sts|_dmarc|lyncdiscover|sip|enterpriseenrollment|enterpriseregistration)\./,
27
+ /\b[0-9a-f]{10,}\b/,
28
+ /\b(static|cdn|assets|img|images|media|cache|edge|lb|origin|status|metrics|monitoring|grafana|prometheus|sentry|analytics|tracking|email|em\d*|click|links?|bounce|unsubscribe)\b/,
29
+ ];
30
+ const PAGE_NOISE = /\/(tag|tags|category|author|page|feed|search|login|signin|signup|cart|legal|privacy|terms|cookie|cookies|sitemap|wp-|cdn-cgi)(\/|$)|\/\d{4}\/\d{2}\//;
31
+ function tokens(value) {
32
+ return value.toLowerCase().replace(/[._/\-]+/g, ' ');
33
+ }
34
+ export function scoreName(kind, value, firstSeenMs, nowMs, windowDays) {
35
+ const reasons = [];
36
+ let score = kind === 'repo' ? 30 : kind === 'subdomain' ? 25 : 15;
37
+ const t = ` ${tokens(value)} `;
38
+ for (const [re, w, why] of HOT) {
39
+ const m = re.exec(t);
40
+ if (m) {
41
+ score += w;
42
+ reasons.push(`${why}: "${m[0].trim()}"`);
43
+ }
44
+ }
45
+ const ageDays = (nowMs - firstSeenMs) / DAY_MS;
46
+ const recency = clamp(1 - ageDays / windowDays, 0, 1);
47
+ score += Math.round(recency * 20);
48
+ if (recency > 0.8)
49
+ reasons.push('first seen in the last few days');
50
+ return { score: clamp(score, 0, 100), reasons };
51
+ }
52
+ export function isNoiseHost(host) {
53
+ return NOISE.some((re) => re.test(host));
54
+ }
55
+ /** First time each hostname under `domain` appeared on any certificate. */
56
+ export function firstSeenHosts(entries, domain) {
57
+ const first = new Map();
58
+ const d = domain.toLowerCase();
59
+ for (const e of entries) {
60
+ const t = Date.parse(e.notBefore);
61
+ if (!Number.isFinite(t))
62
+ continue;
63
+ for (const raw of e.names) {
64
+ const host = raw.toLowerCase().replace(/^\*\./, '').replace(/\.$/, '');
65
+ if (host === d || !host.endsWith(`.${d}`))
66
+ continue;
67
+ const prev = first.get(host);
68
+ if (prev === undefined || t < prev)
69
+ first.set(host, t);
70
+ }
71
+ }
72
+ return first;
73
+ }
74
+ function tsToMs(ts) {
75
+ const iso = `${ts.slice(0, 4)}-${ts.slice(4, 6)}-${ts.slice(6, 8)}T${ts.slice(8, 10) || '00'}:${ts.slice(10, 12) || '00'}:00Z`;
76
+ return Date.parse(iso);
77
+ }
78
+ export async function ferret(ctx, domainInput, opts = {}) {
79
+ const domain = domainInput.trim().toLowerCase().replace(/^https?:\/\//, '').replace(/\/.*$/, '').replace(/^www\./, '');
80
+ const days = opts.days ?? 30;
81
+ const nowMs = ctx.now().getTime();
82
+ const since = nowMs - days * DAY_MS;
83
+ const provenance = [];
84
+ const domainId = entityId('domain', domain);
85
+ const firstScan = !(ctx.graph.get(domainId)?.attrs.lastScan);
86
+ const org = opts.org === false ? null : (opts.org ?? domain.split('.')[0]);
87
+ const [certsPrimary, recentCaps, olderCaps, repos, scans] = await Promise.all([
88
+ crtsh(ctx, domain),
89
+ captures(ctx, domain, days, 0),
90
+ captures(ctx, domain, 400, days + 1),
91
+ org ? recentRepos(ctx, org) : Promise.resolve(null),
92
+ urlscan(ctx, domain, 100),
93
+ ]);
94
+ provenance.push(scans.prov);
95
+ let certs = certsPrimary;
96
+ provenance.push(certsPrimary.prov);
97
+ if (!certsPrimary.data) {
98
+ certs = await certspotter(ctx, domain);
99
+ provenance.push(certs.prov);
100
+ }
101
+ provenance.push(recentCaps.prov, olderCaps.prov);
102
+ if (repos)
103
+ provenance.push(repos.prov);
104
+ const raw = [];
105
+ // Subdomains first seen inside the window.
106
+ if (certs.data) {
107
+ for (const [host, t] of firstSeenHosts(certs.data, domain)) {
108
+ if (t < since || isNoiseHost(host))
109
+ continue;
110
+ raw.push({ kind: 'subdomain', value: host, firstSeen: new Date(t).toISOString(), source: certs.prov.source, url: `https://crt.sh/?q=${host}` });
111
+ }
112
+ }
113
+ // Pages captured recently that never showed up in the previous ~year.
114
+ if (recentCaps.data && olderCaps.data) {
115
+ const older = new Set(olderCaps.data.map((c) => normalizePath(c.url)).filter(Boolean));
116
+ const seen = new Set();
117
+ for (const c of recentCaps.data) {
118
+ const p = normalizePath(c.url);
119
+ if (!p || older.has(p) || seen.has(p) || p.endsWith(`${domain}/`) || PAGE_NOISE.test(p))
120
+ continue;
121
+ seen.add(p);
122
+ const t = tsToMs(c.timestamp);
123
+ raw.push({ kind: 'page', value: p, firstSeen: new Date(t).toISOString(), source: 'wayback', url: `https://web.archive.org/web/${c.timestamp}/${c.url}` });
124
+ }
125
+ }
126
+ // Hostnames that urlscan.io users scanned but that never appeared on a certificate we saw
127
+ // (often wildcard-covered hosts, which CT logs cannot reveal).
128
+ if (scans.data) {
129
+ const certHosts = new Set(certs.data ? firstSeenHosts(certs.data, domain).keys() : []);
130
+ const known = new Set(raw.filter((f) => f.kind === 'subdomain').map((f) => f.value));
131
+ const firstScanAt = new Map();
132
+ for (const s of scans.data) {
133
+ const host = s.host.replace(/^www\./, '');
134
+ const t = Date.parse(s.time);
135
+ if (!host.endsWith(`.${domain}`) || certHosts.has(host) || known.has(host) || isNoiseHost(host) || !Number.isFinite(t))
136
+ continue;
137
+ const prev = firstScanAt.get(host);
138
+ if (!prev || t < prev.t)
139
+ firstScanAt.set(host, { t, url: s.screenshot });
140
+ }
141
+ for (const [host, { t, url }] of firstScanAt) {
142
+ if (t < since)
143
+ continue;
144
+ raw.push({ kind: 'subdomain', value: host, firstSeen: new Date(t).toISOString(), source: 'urlscan', url });
145
+ }
146
+ }
147
+ // Public repos created inside the window.
148
+ if (repos?.data) {
149
+ for (const r of repos.data) {
150
+ const t = Date.parse(r.created_at);
151
+ if (r.fork || t < since)
152
+ continue;
153
+ raw.push({
154
+ kind: 'repo',
155
+ value: `${r.full_name}${r.description ? ` — ${r.description}` : ''}`,
156
+ firstSeen: r.created_at,
157
+ source: 'github',
158
+ url: r.html_url,
159
+ });
160
+ }
161
+ }
162
+ ctx.graph.upsert('domain', domain);
163
+ const findings = raw.map((f) => {
164
+ const kindForId = f.kind === 'subdomain' ? 'subdomain' : f.kind === 'repo' ? 'repo' : 'url';
165
+ const name = f.kind === 'repo' ? f.value.split(' — ')[0] : f.value;
166
+ const id = entityId(kindForId, name);
167
+ const existed = ctx.graph.has(id);
168
+ ctx.graph.upsert(kindForId, name, { firstSeen: f.firstSeen, source: f.source, url: f.url });
169
+ ctx.graph.link(domainId, id, f.kind === 'repo' ? 'owns_repo' : f.kind === 'subdomain' ? 'has_subdomain' : 'has_page', f.source);
170
+ const { score, reasons } = scoreName(f.kind, f.value, Date.parse(f.firstSeen), nowMs, days);
171
+ const newSinceLastScan = !firstScan && !existed;
172
+ return {
173
+ ...f,
174
+ score: clamp(score + (newSinceLastScan ? 10 : 0), 0, 100),
175
+ reasons: newSinceLastScan ? [...reasons, 'new since your last scan'] : reasons,
176
+ newSinceLastScan,
177
+ };
178
+ });
179
+ // Google Safe Browsing over the domain and every new host/page: a flagged new subdomain is a strong signal
180
+ // (compromise, or a lookalike phishing page riding on the brand).
181
+ const toCheck = [`https://${domain}/`, ...findings.filter((f) => f.kind !== 'repo').map((f) => (f.kind === 'subdomain' ? `https://${f.value}/` : `https://${f.value}`))];
182
+ const sb = await safeBrowsing(ctx, toCheck);
183
+ provenance.push(sb.prov);
184
+ const flagged = sb.data ?? [];
185
+ for (const f of findings) {
186
+ const hit = flagged.find((x) => x.url.includes(f.value));
187
+ if (hit) {
188
+ f.score = clamp(f.score + 30, 0, 100);
189
+ f.reasons.push(`flagged by Google Safe Browsing: ${hit.threat}`);
190
+ }
191
+ }
192
+ findings.sort((a, b) => b.score - a.score || b.firstSeen.localeCompare(a.firstSeen));
193
+ const limited = findings.slice(0, opts.limit ?? 100);
194
+ ctx.graph.upsert('domain', domain, { lastScan: new Date(nowMs).toISOString() });
195
+ const createdAt = new Date(nowMs).toISOString();
196
+ const signals = limited
197
+ .filter((f) => f.score >= 60)
198
+ .slice(0, 10)
199
+ .map((f) => ({
200
+ id: signalId('ferret', domain, f.kind, f.value),
201
+ module: 'ferret',
202
+ title: `${domain}: new ${f.kind} ${f.value.split(' — ')[0]}`,
203
+ score: f.score,
204
+ entity: domainId,
205
+ evidence: [{ source: f.source, text: `${f.kind} first seen ${f.firstSeen.slice(0, 10)}; ${f.reasons.join(', ') || 'recent'}`, url: f.url }],
206
+ createdAt,
207
+ }));
208
+ signals.forEach((s) => ctx.graph.saveSignal(s));
209
+ const counts = { subdomain: 0, page: 0, repo: 0 };
210
+ for (const f of findings)
211
+ counts[f.kind]++;
212
+ return {
213
+ module: 'ferret',
214
+ input: domain,
215
+ generatedAt: createdAt,
216
+ result: { domain, flagged, windowDays: days, firstScan, findings: limited, counts },
217
+ signals,
218
+ provenance,
219
+ };
220
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Filings: what companies are telling the SEC.
3
+ * filings(): EDGAR full-text search across every filer (efts.sec.gov, the index behind sec.gov/edgar/search),
4
+ * e.g. every 8-K mentioning "cybersecurity incident" in the last 30 days.
5
+ * recentEvents(): one company's recent 8-Ks with the item codes decoded into plain English. High-impact items
6
+ * (bankruptcy, cybersecurity incident, restatement, delisting, CEO/CFO departure) become signals.
7
+ * Needs OCULON_CONTACT (SEC requires contact details in the User-Agent). Requests stay sequential and few,
8
+ * far under SEC's 10 requests/second fair-access limit.
9
+ */
10
+ import { type Ctx } from '../core/context.js';
11
+ import type { Evidence, ModuleResult, Provenance } from '../core/types.js';
12
+ import { type Company, type Filing, type FullTextHit } from '../sources/sec.js';
13
+ /** Form 8-K items (SEC General Instructions B) with an impact weight 0-100 for signals. */
14
+ export declare const EIGHT_K_ITEMS: Record<string, {
15
+ title: string;
16
+ impact: number;
17
+ }>;
18
+ /** Items that raise a signal on their own. 5.02 only does when the CEO or CFO is leaving. */
19
+ export declare const HIGH_IMPACT_ITEMS: Set<string>;
20
+ export declare const decodeItem: (code: string) => string;
21
+ export interface DecodedItem {
22
+ code: string;
23
+ title: string;
24
+ impact: number;
25
+ }
26
+ export interface CorporateEvent {
27
+ date: string;
28
+ form: string;
29
+ items: DecodedItem[];
30
+ url: string;
31
+ /** For item 5.02: which top officer the filing says is leaving, read from the filing text. */
32
+ officerDeparture: 'CEO' | 'CFO' | 'CEO and CFO' | null;
33
+ /** Highest item impact, raised to 80 for a CEO/CFO departure. */
34
+ impact: number;
35
+ summary: string;
36
+ }
37
+ export interface RecentEvents {
38
+ company: Company | null;
39
+ days: number;
40
+ events: CorporateEvent[];
41
+ }
42
+ /** Which of CEO/CFO a 5.02 text says is leaving (a sentence naming the role and a departure verb). */
43
+ export declare function officerLeaving(text: string): CorporateEvent['officerDeparture'];
44
+ /**
45
+ * Turn submissions-feed filings into decoded 8-K events (newest first as given). Reads the text of up to
46
+ * `read502` item-5.02 filings to tell a CEO/CFO departure from a routine board change.
47
+ */
48
+ export declare function decodeEvents(ctx: Ctx, list: Filing[], o: {
49
+ since: number;
50
+ read502?: number;
51
+ provenance?: Provenance[];
52
+ }): Promise<CorporateEvent[]>;
53
+ /** Evidence lines for an event's high-impact items; empty when nothing in it is high impact. */
54
+ export declare function eventEvidence(e: CorporateEvent): Evidence[];
55
+ export interface EventOptions {
56
+ days?: number;
57
+ /** Read the text of up to this many 5.02 filings to see whether the CEO or CFO is leaving. Default 3. */
58
+ read502?: number;
59
+ }
60
+ export declare function recentEvents(ctx: Ctx, tickerOrCik: string | number, opts?: EventOptions): Promise<ModuleResult<RecentEvents>>;
61
+ export interface FilingsOptions {
62
+ /** Form types, e.g. ['8-K']. Default: all forms. */
63
+ forms?: string[];
64
+ /** Look-back window in days. Default 30. */
65
+ days?: number;
66
+ /** Limit to one company by CIK. */
67
+ cik?: number;
68
+ }
69
+ export interface FilingsResult {
70
+ query: string;
71
+ from: string;
72
+ to: string;
73
+ forms: string[];
74
+ total: number;
75
+ totalIsLowerBound: boolean;
76
+ hits: (FullTextHit & {
77
+ itemTitles: string[];
78
+ })[];
79
+ topCompanies: {
80
+ name: string;
81
+ docs: number;
82
+ }[];
83
+ }
84
+ /** A multi-word query without quotes or operators is searched as an exact phrase. */
85
+ export declare function phraseQuery(q: string): string;
86
+ export declare function filings(ctx: Ctx, query: string, opts?: FilingsOptions): Promise<ModuleResult<FilingsResult>>;
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Filings: what companies are telling the SEC.
3
+ * filings(): EDGAR full-text search across every filer (efts.sec.gov, the index behind sec.gov/edgar/search),
4
+ * e.g. every 8-K mentioning "cybersecurity incident" in the last 30 days.
5
+ * recentEvents(): one company's recent 8-Ks with the item codes decoded into plain English. High-impact items
6
+ * (bankruptcy, cybersecurity incident, restatement, delisting, CEO/CFO departure) become signals.
7
+ * Needs OCULON_CONTACT (SEC requires contact details in the User-Agent). Requests stay sequential and few,
8
+ * far under SEC's 10 requests/second fair-access limit.
9
+ */
10
+ import { DAY_MS } from '../core/context.js';
11
+ import { clamp } from '../core/stats.js';
12
+ import { signalId } from '../core/text.js';
13
+ import { companies, filingText, fullTextSearch, matchCompany, recentFilings } from '../sources/sec.js';
14
+ /** Form 8-K items (SEC General Instructions B) with an impact weight 0-100 for signals. */
15
+ export const EIGHT_K_ITEMS = {
16
+ '1.01': { title: 'Entered a material definitive agreement', impact: 35 },
17
+ '1.02': { title: 'Terminated a material definitive agreement', impact: 50 },
18
+ '1.03': { title: 'Bankruptcy or receivership', impact: 95 },
19
+ '1.04': { title: 'Mine safety: shutdown or pattern of violations', impact: 55 },
20
+ '1.05': { title: 'Material cybersecurity incident', impact: 85 },
21
+ '2.01': { title: 'Completed an acquisition or disposition of assets', impact: 45 },
22
+ '2.02': { title: 'Results of operations (earnings release)', impact: 15 },
23
+ '2.03': { title: 'New direct financial obligation (debt or off-balance-sheet arrangement)', impact: 30 },
24
+ '2.04': { title: 'Triggering event accelerated a financial obligation (e.g. debt default)', impact: 70 },
25
+ '2.05': { title: 'Exit or disposal costs (restructuring, layoffs, closures)', impact: 60 },
26
+ '2.06': { title: 'Material impairment', impact: 60 },
27
+ '3.01': { title: 'Delisting notice or failure to meet a listing standard', impact: 75 },
28
+ '3.02': { title: 'Unregistered sale of equity securities', impact: 30 },
29
+ '3.03': { title: 'Material modification to rights of security holders', impact: 45 },
30
+ '4.01': { title: 'Changed certifying accountant (auditor change)', impact: 60 },
31
+ '4.02': { title: 'Non-reliance on previously issued financial statements (restatement)', impact: 85 },
32
+ '5.01': { title: 'Change in control of the company', impact: 70 },
33
+ '5.02': { title: 'Director or officer departure, election or appointment; compensation', impact: 40 },
34
+ '5.03': { title: 'Amended articles or bylaws; fiscal year change', impact: 15 },
35
+ '5.04': { title: 'Temporary suspension of trading under employee benefit plans', impact: 25 },
36
+ '5.05': { title: 'Amended or waived code of ethics', impact: 35 },
37
+ '5.06': { title: 'Change in shell company status', impact: 40 },
38
+ '5.07': { title: 'Shareholder vote results', impact: 10 },
39
+ '5.08': { title: 'Shareholder director nominations', impact: 15 },
40
+ '6.01': { title: 'ABS informational and computational material', impact: 5 },
41
+ '6.02': { title: 'Change of ABS servicer or trustee', impact: 15 },
42
+ '6.03': { title: 'Change in ABS credit enhancement', impact: 20 },
43
+ '6.04': { title: 'Failure to make a required ABS distribution', impact: 60 },
44
+ '6.05': { title: 'Securities Act updating disclosure (ABS)', impact: 10 },
45
+ '7.01': { title: 'Regulation FD disclosure', impact: 10 },
46
+ '8.01': { title: 'Other events', impact: 15 },
47
+ '9.01': { title: 'Financial statements and exhibits', impact: 0 },
48
+ };
49
+ /** Items that raise a signal on their own. 5.02 only does when the CEO or CFO is leaving. */
50
+ export const HIGH_IMPACT_ITEMS = new Set(['1.03', '1.05', '2.04', '3.01', '4.02', '5.01', '6.04']);
51
+ export const decodeItem = (code) => EIGHT_K_ITEMS[code]?.title ?? `Item ${code}`;
52
+ const OFFICER = { CEO: /chief executive officer|\bCEO\b/i, CFO: /chief financial officer|principal financial officer|\bCFO\b/i };
53
+ const LEAVING = /\b(resign\w*|retire\w*|depart\w*|step(?:s|ped)? down|terminat\w*|separat\w*|will (?:leave|cease)|no longer serve|transition(?:ing)? (?:out|from))\b/i;
54
+ /** Which of CEO/CFO a 5.02 text says is leaving (a sentence naming the role and a departure verb). */
55
+ export function officerLeaving(text) {
56
+ const sentences = text.split(/(?<=[.;])\s+/).filter((s) => LEAVING.test(s));
57
+ const ceo = sentences.some((s) => OFFICER.CEO.test(s));
58
+ const cfo = sentences.some((s) => OFFICER.CFO.test(s));
59
+ return ceo && cfo ? 'CEO and CFO' : ceo ? 'CEO' : cfo ? 'CFO' : null;
60
+ }
61
+ /**
62
+ * Turn submissions-feed filings into decoded 8-K events (newest first as given). Reads the text of up to
63
+ * `read502` item-5.02 filings to tell a CEO/CFO departure from a routine board change.
64
+ */
65
+ export async function decodeEvents(ctx, list, o) {
66
+ let reads = o.read502 ?? 3;
67
+ const events = [];
68
+ for (const x of list.filter((f) => /^8-K/.test(f.form) && Date.parse(f.date) >= o.since)) {
69
+ const items = (x.items ?? []).map((code) => ({ code, title: decodeItem(code), impact: EIGHT_K_ITEMS[code]?.impact ?? 10 }));
70
+ let officerDeparture = null;
71
+ if (items.some((i) => i.code === '5.02') && reads > 0) {
72
+ reads--;
73
+ const t = await filingText(ctx, x.url);
74
+ o.provenance?.push(t.prov);
75
+ if (t.data)
76
+ officerDeparture = officerLeaving(t.data);
77
+ }
78
+ const impact = Math.max(0, ...items.map((i) => i.impact), officerDeparture ? 80 : 0);
79
+ const shown = items.filter((i) => i.code !== '9.01' && !(i.code === '5.02' && officerDeparture));
80
+ const summary = [officerDeparture ? `${officerDeparture} departure` : '', ...shown.map((i) => i.title)].filter(Boolean).join('; ') || x.description;
81
+ events.push({ date: x.date, form: x.form, items, url: x.url, officerDeparture, impact, summary });
82
+ }
83
+ return events;
84
+ }
85
+ /** Evidence lines for an event's high-impact items; empty when nothing in it is high impact. */
86
+ export function eventEvidence(e) {
87
+ return [
88
+ ...e.items.filter((i) => HIGH_IMPACT_ITEMS.has(i.code)).map((i) => ({ source: 'sec-edgar', text: `${e.form} item ${i.code}: ${i.title}`, url: e.url, value: i.impact })),
89
+ ...(e.officerDeparture ? [{ source: 'sec-edgar', text: `${e.form} item 5.02: ${e.officerDeparture} departure`, url: e.url, value: 80 }] : []),
90
+ ];
91
+ }
92
+ async function resolveCompany(ctx, tickerOrCik, provenance) {
93
+ const raw = String(tickerOrCik).trim();
94
+ if (/^\d{1,10}$/.test(raw))
95
+ return { cik: Number(raw), ticker: '', name: `CIK ${Number(raw)}` };
96
+ const list = await companies(ctx);
97
+ provenance.push(list.prov);
98
+ return list.data ? matchCompany(list.data, raw) : null;
99
+ }
100
+ export async function recentEvents(ctx, tickerOrCik, opts = {}) {
101
+ const days = opts.days ?? 90;
102
+ const now = ctx.now();
103
+ const nowIso = now.toISOString();
104
+ const provenance = [];
105
+ const company = await resolveCompany(ctx, tickerOrCik, provenance);
106
+ const base = { module: 'filings', input: String(tickerOrCik), generatedAt: nowIso };
107
+ if (!company)
108
+ return { ...base, result: { company: null, days, events: [] }, signals: [], provenance };
109
+ const f = await recentFilings(ctx, company.cik, 300);
110
+ provenance.push(f.prov);
111
+ const events = await decodeEvents(ctx, f.data ?? [], { since: now.getTime() - days * DAY_MS, read502: opts.read502 ?? 3, provenance });
112
+ const signals = [];
113
+ const id = ctx.graph.upsert('company', company.name, { cik: company.cik, ...(company.ticker ? { ticker: company.ticker } : {}) });
114
+ for (const e of events) {
115
+ const evidence = eventEvidence(e);
116
+ if (!evidence.length)
117
+ continue;
118
+ const ageDays = (now.getTime() - Date.parse(`${e.date}T00:00:00Z`)) / DAY_MS;
119
+ signals.push({
120
+ id: signalId('filings', String(company.cik), e.url),
121
+ module: 'filings',
122
+ title: `${company.ticker || company.name}: ${e.summary} (${e.form}, ${e.date})`,
123
+ // Fresh filings score higher; a 90-day-old one is context, not news.
124
+ score: clamp(Math.round(e.impact - Math.min(30, ageDays / 3)), 0, 100),
125
+ entity: id,
126
+ evidence,
127
+ createdAt: nowIso,
128
+ });
129
+ }
130
+ signals.forEach((s) => ctx.graph.saveSignal(s));
131
+ return { ...base, result: { company, days, events }, signals, provenance };
132
+ }
133
+ /** A multi-word query without quotes or operators is searched as an exact phrase. */
134
+ export function phraseQuery(q) {
135
+ const t = q.trim();
136
+ if (/["()]|\b(AND|OR|NOT)\b/.test(t) || !/\s/.test(t))
137
+ return t;
138
+ return `"${t}"`;
139
+ }
140
+ export async function filings(ctx, query, opts = {}) {
141
+ const days = opts.days ?? 30;
142
+ const now = ctx.now();
143
+ const to = now.toISOString().slice(0, 10);
144
+ const from = new Date(now.getTime() - days * DAY_MS).toISOString().slice(0, 10);
145
+ const q = phraseQuery(query);
146
+ const forms = opts.forms ?? [];
147
+ const r = await fullTextSearch(ctx, q, { forms, from, to, ...(opts.cik ? { cik: opts.cik } : {}) });
148
+ const d = r.data;
149
+ return {
150
+ module: 'filings',
151
+ input: query,
152
+ generatedAt: now.toISOString(),
153
+ result: {
154
+ query: q,
155
+ from,
156
+ to,
157
+ forms,
158
+ total: d?.total ?? 0,
159
+ totalIsLowerBound: d?.totalIsLowerBound ?? false,
160
+ hits: (d?.hits ?? []).map((h) => ({ ...h, itemTitles: h.items.filter((c) => c !== '9.01').map(decodeItem) })),
161
+ topCompanies: d?.topCompanies ?? [],
162
+ },
163
+ signals: [],
164
+ provenance: [r.prov],
165
+ };
166
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Fires: active fire and thermal hotspots near a place from NASA FIRMS (free MAP_KEY), seen by the VIIRS
3
+ * instruments on NOAA-21, NOAA-20 and Suomi NPP and by MODIS on Terra and Aqua, within about three hours of the
4
+ * pass. Products whose feed has stopped are skipped using FIRMS' data_availability list; MODIS detections that
5
+ * duplicate a VIIRS detection of the same pass are dropped. Besides wildfires this catches industrial fires,
6
+ * refinery flares and strikes on infrastructure.
7
+ */
8
+ import type { Ctx } from '../core/context.js';
9
+ import type { ModuleResult } from '../core/types.js';
10
+ import { type Place } from '../sources/earth.js';
11
+ export interface Hotspot {
12
+ lat: number;
13
+ lon: number;
14
+ time: string;
15
+ satellite: string;
16
+ confidence: 'low' | 'nominal' | 'high';
17
+ /** Fire radiative power, MW. */
18
+ frp: number;
19
+ daynight: 'D' | 'N';
20
+ /** FIRMS product the detection came from, e.g. VIIRS_NOAA21_NRT, MODIS_NRT. */
21
+ product?: string;
22
+ }
23
+ /** FIRMS near-real-time products, best first: VIIRS (375 m) before MODIS (1 km). */
24
+ export declare const FIRMS_PRODUCTS: Record<string, string>;
25
+ export interface Fires {
26
+ place: Place | null;
27
+ days: number;
28
+ hotspots: Hotspot[];
29
+ high: number;
30
+ totalFrp: number;
31
+ /** Groups of hotspots within about 3 km, largest first. */
32
+ clusters: {
33
+ lat: number;
34
+ lon: number;
35
+ count: number;
36
+ frp: number;
37
+ last: string;
38
+ }[];
39
+ }
40
+ export declare function parseFirmsCsv(csv: string, satellite: string): Hotspot[];
41
+ /**
42
+ * Merge detections from several FIRMS products: exact duplicates dropped, and a MODIS (1 km at nadir, up to ~2 km
43
+ * off-nadir) detection dropped when a VIIRS (375 m) detection lies within `km` and `minutes` of it, since both saw
44
+ * the same fire on the same pass.
45
+ */
46
+ export declare function dedupeHotspots(hs: Hotspot[], km?: number, minutes?: number): Hotspot[];
47
+ /** FIRMS products with near-real-time data up to `sinceDay` (YYYY-MM-DD), from the data_availability endpoint. */
48
+ export declare function parseAvailability(csv: string, sinceDay: string): string[];
49
+ export declare function clusterHotspots(hs: Hotspot[], km?: number): Fires['clusters'];
50
+ /**
51
+ * `opts.products` overrides the FIRMS products queried (default: every VIIRS NRT product with current data plus
52
+ * MODIS_NRT; add LANDSAT_NRT for 30 m detections over the US and Canada, which carry no FRP).
53
+ */
54
+ export declare function fires(ctx: Ctx, placeQuery: string, days?: number, opts?: {
55
+ products?: string[];
56
+ }): Promise<ModuleResult<Fires>>;