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
package/dist/cli/main.js
ADDED
|
@@ -0,0 +1,1999 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `oculon` command-line interface. Zero dependencies: ANSI colors (honoring NO_COLOR and pipes),
|
|
3
|
+
* plain tables, and --json on every command for scripting.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, readFileSync, copyFileSync, mkdirSync } from 'node:fs';
|
|
6
|
+
import { dirname, join, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { oculonHome } from '../core/paths.js';
|
|
9
|
+
import { fmtTime } from '../modules/listen.js';
|
|
10
|
+
import { Oculon, summarizeProvenance } from '../index.js';
|
|
11
|
+
import { ONCHAIN_COMMANDS, ONCHAIN_PAUSED_MESSAGE, onchainEnabled } from '../core/features.js';
|
|
12
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const VERSION = (() => {
|
|
14
|
+
for (const p of [join(HERE, '..', '..', 'package.json'), join(HERE, '..', 'package.json')]) {
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(readFileSync(p, 'utf8')).version;
|
|
17
|
+
}
|
|
18
|
+
catch { }
|
|
19
|
+
}
|
|
20
|
+
return '0.0.0';
|
|
21
|
+
})();
|
|
22
|
+
/* ---------- tiny terminal toolkit ---------- */
|
|
23
|
+
const COLOR = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
24
|
+
const paint = (code) => (s) => (COLOR ? `\x1b[${code}m${s}\x1b[0m` : String(s));
|
|
25
|
+
const c = { bold: paint('1'), dim: paint('2'), red: paint('31'), green: paint('32'), yellow: paint('33'), blue: paint('34'), magenta: paint('35'), cyan: paint('36'), gray: paint('90') };
|
|
26
|
+
const out = (s = '') => process.stdout.write(`${s}\n`);
|
|
27
|
+
const score = (n) => {
|
|
28
|
+
const s = String(Math.round(n)).padStart(3);
|
|
29
|
+
return n >= 75 ? c.red(s) : n >= 55 ? c.yellow(s) : c.green(s);
|
|
30
|
+
};
|
|
31
|
+
const pct = (x) => (x == null ? 'n/a' : `${Math.round(x * 100)}%`);
|
|
32
|
+
const trunc = (s, n) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
|
|
33
|
+
function printSignals(signals, max = 10) {
|
|
34
|
+
for (const s of signals.slice(0, max)) {
|
|
35
|
+
out(` [${score(s.score)}] ${c.bold(s.title)} ${c.gray(s.module)}`);
|
|
36
|
+
for (const e of s.evidence.slice(0, 3))
|
|
37
|
+
out(` ${c.cyan(e.source)} ${trunc(e.text, 110)}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function printTranscript(t) {
|
|
41
|
+
out(c.bold(`\n${t.title ?? t.url}`) + c.dim(` ${fmtTime(t.durationSec)} · ${t.language ?? '?'} · ${t.words} words`));
|
|
42
|
+
if (t.summary)
|
|
43
|
+
out(`\n ${c.dim('machine summary')} ${t.summary}`);
|
|
44
|
+
if (t.topics.length)
|
|
45
|
+
out(` ${c.dim('topics')} ${t.topics.join(', ')}`);
|
|
46
|
+
if (t.mentions.length) {
|
|
47
|
+
out(c.bold('\n Mentions'));
|
|
48
|
+
for (const m of t.mentions)
|
|
49
|
+
out(` ${c.cyan(fmtTime(m.start))} ${trunc(m.text, 260)}`);
|
|
50
|
+
}
|
|
51
|
+
else if (t.opening.length) {
|
|
52
|
+
out(c.bold('\n Opening'));
|
|
53
|
+
for (const m of t.opening)
|
|
54
|
+
out(` ${c.cyan(fmtTime(m.start))} ${trunc(m.text, 200)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function printSources(r) {
|
|
58
|
+
const { sources, notes } = summarizeProvenance(r.provenance);
|
|
59
|
+
const parts = Object.entries(sources).map(([src, st]) => {
|
|
60
|
+
const bad = st.ERROR || st.UNAVAILABLE;
|
|
61
|
+
const label = Object.entries(st)
|
|
62
|
+
.map(([k, v]) => `${k.toLowerCase()}${v > 1 ? `×${v}` : ''}`)
|
|
63
|
+
.join(' ');
|
|
64
|
+
return `${bad ? c.yellow(src) : c.gray(src)} ${c.dim(label)}`;
|
|
65
|
+
});
|
|
66
|
+
out(`\n${c.dim('sources')} ${parts.join(c.dim(' · '))}`);
|
|
67
|
+
for (const n of notes.slice(0, 6))
|
|
68
|
+
out(c.dim(` ${trunc(n, 140)}`));
|
|
69
|
+
}
|
|
70
|
+
export function parseArgs(argv) {
|
|
71
|
+
const pos = [];
|
|
72
|
+
const flags = {};
|
|
73
|
+
for (let i = 0; i < argv.length; i++) {
|
|
74
|
+
const a = argv[i];
|
|
75
|
+
if (a.startsWith('--')) {
|
|
76
|
+
const [k, v] = a.slice(2).split('=', 2);
|
|
77
|
+
if (v !== undefined)
|
|
78
|
+
flags[k] = v;
|
|
79
|
+
else if (argv[i + 1] !== undefined && !argv[i + 1].startsWith('--') && !BOOLEAN.has(k))
|
|
80
|
+
flags[k] = argv[++i];
|
|
81
|
+
else
|
|
82
|
+
flags[k] = true;
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
pos.push(a);
|
|
86
|
+
}
|
|
87
|
+
return { pos, flags };
|
|
88
|
+
}
|
|
89
|
+
const BOOLEAN = new Set(['json', 'help', 'no-github', 'no-org', 'version', 'live', 'telegram', 'radar', 'deep', 'dry-run', 'all', 'public']);
|
|
90
|
+
/** Help without the paused on-chain commands (they come back with OCULON_ONCHAIN=1). */
|
|
91
|
+
function helpText() {
|
|
92
|
+
if (onchainEnabled())
|
|
93
|
+
return HELP;
|
|
94
|
+
return HELP.split('\n')
|
|
95
|
+
.filter((l) => !/oculon (rh|deployer|wallet|token|defi|protocol)\b|@robinhood|On-chain/.test(l))
|
|
96
|
+
.join('\n')
|
|
97
|
+
.replace(/\n{3,}/g, '\n\n');
|
|
98
|
+
}
|
|
99
|
+
const HELP = `${c.bold('oculon')} ${c.dim(`v${VERSION}`)} — OSINT intelligence engine for AI agents
|
|
100
|
+
|
|
101
|
+
${c.bold('Ask')}
|
|
102
|
+
oculon ask "<question>" AI agent answers using every Oculon tool (octopus)
|
|
103
|
+
|
|
104
|
+
${c.bold('Analysis')}
|
|
105
|
+
oculon narratives [run] storylines across days, new and growing ones flagged
|
|
106
|
+
oculon health <company> early-warning score 0-100 with each part explained
|
|
107
|
+
oculon impact [place] [--radius 50] people exposed to current M6+ quakes and severe storms
|
|
108
|
+
oculon contradictions <topic> conflicting facts across independent sources
|
|
109
|
+
oculon report [--days 7] [--out f] self-contained HTML report of the period
|
|
110
|
+
oculon plugin [list] | run <name.tool> [--args '{}'] local plugins
|
|
111
|
+
|
|
112
|
+
${c.bold('Markets, launches, history')}
|
|
113
|
+
oculon sanctions <wallet|IMO|name> OFAC sanctions screening (wallet also checks counterparties)
|
|
114
|
+
oculon markets [--gap 15] Polymarket vs Kalshi and Manifold on the same questions (lynx)
|
|
115
|
+
oculon launches <company> [--domain x.com] [--org handle] new models, apps, packages, hosts
|
|
116
|
+
oculon rewind <YYYY-MM-DD> time machine: what Oculon would have seen that day
|
|
117
|
+
oculon calibrate [--days 10] replay past days, measure which signals became news, tune the radar
|
|
118
|
+
|
|
119
|
+
${c.bold('Geofences')}
|
|
120
|
+
oculon fence add <name> <place> [--radius 100] [--kinds air,sea,quake,events]
|
|
121
|
+
oculon fence [list] | check | rm <id> report what is new inside each box
|
|
122
|
+
|
|
123
|
+
${c.bold('First to know')}
|
|
124
|
+
oculon scoops [check] lead time of Oculon signals vs first media coverage
|
|
125
|
+
|
|
126
|
+
${c.bold('Case files')}
|
|
127
|
+
oculon case new "<question>" deep investigation with sourced findings
|
|
128
|
+
oculon case [list] | show <id> | rerun <id> | watch <id> [off]
|
|
129
|
+
|
|
130
|
+
${c.bold('Watch & brief')}
|
|
131
|
+
oculon watch add <kind> <target> kinds: company domain plane topic lights air port news outage cve quake hazard url package travel
|
|
132
|
+
oculon watch [list] | run | rm <id> re-check targets, report only what changed (meerkat)
|
|
133
|
+
oculon brief [--refresh] today's brief from signals and watch changes
|
|
134
|
+
oculon sentinel <place> [--date d] [--compare d] [--radar] [--out f.png] 10 m satellite image, before/after
|
|
135
|
+
oculon fires <place> [--days 2] active fires and hotspots (NASA FIRMS)
|
|
136
|
+
oculon darkships <place> [--days 30] vessels that switched off AIS there (Global Fishing Watch)
|
|
137
|
+
oculon vessel <name|MMSI|IMO> flag history, owners, earlier names, sanctions
|
|
138
|
+
oculon cloud outages on AWS, Azure, Google Cloud, GitHub, Cloudflare, OpenAI...
|
|
139
|
+
oculon bgp [world|cc|ASN|IP] BGP hijacks, route leaks, DDoS targets; routing of a country, network or IP
|
|
140
|
+
oculon vulns [days] [--vendor x] newly exploited CVEs (CISA KEV), new critical CVEs, package advisories
|
|
141
|
+
oculon cve <CVE-id> CVSS, exploitation odds (EPSS), KEV status, affected packages and fixes
|
|
142
|
+
oculon pkg <ecosystem> <name> [ver] known vulnerabilities of a package (OSV.dev)
|
|
143
|
+
oculon regs [query] [--agency x] US Federal Register: executive orders, rules, tomorrow's documents
|
|
144
|
+
oculon defi TVL crashes, stablecoin depegs, hacks, fear and greed (DefiLlama)
|
|
145
|
+
oculon protocol <name> one DeFi protocol: TVL trend, drawdown, audits, hacks, warnings
|
|
146
|
+
oculon squawk aircraft squawking 7500 hijack / 7600 radio / 7700 emergency now
|
|
147
|
+
oculon filings "<phrase>" [--forms 8-K] [--days 30] SEC EDGAR full-text search
|
|
148
|
+
oculon edgar <ticker> a company's 8-K events in plain English (CEO exits, restatements...)
|
|
149
|
+
oculon blackout [days] internet outages and shutdowns (Cloudflare Radar, IODA)
|
|
150
|
+
oculon hazards [days] official orange/red disaster alerts (GDACS)
|
|
151
|
+
oculon podcast <subject> [--pick n] newest podcast episode about it, transcribed, timestamped quotes
|
|
152
|
+
oculon listen <media-url> [--about x] transcribe any audio/video file URL (Deepgram)
|
|
153
|
+
oculon exposure <domain> open ports, software and known CVEs on its servers
|
|
154
|
+
oculon social <subject> [--only x,reddit,tiktok,bluesky] posts right now, pace, most engaged
|
|
155
|
+
oculon calendar [days] earnings, macro releases, markets closing soon
|
|
156
|
+
oculon feedback [useful|noise <id>] votes that move each module's alert bar
|
|
157
|
+
|
|
158
|
+
${c.bold('Live')}
|
|
159
|
+
oculon live [--minutes 30] Wikipedia edit surges + Bluesky term surges in real time
|
|
160
|
+
|
|
161
|
+
${c.bold('Graph')}
|
|
162
|
+
oculon connect <A> to <B> how two things are linked (shortest path)
|
|
163
|
+
oculon resolve merge duplicates: org:nvidia = company:nvidia = nvidia.com
|
|
164
|
+
oculon quota today's API usage vs free-tier budgets
|
|
165
|
+
|
|
166
|
+
${c.bold('Radar')}
|
|
167
|
+
oculon radar what the world is suddenly paying attention to
|
|
168
|
+
oculon signals [--limit 20] latest signals from every module
|
|
169
|
+
|
|
170
|
+
${c.bold('On-chain')}
|
|
171
|
+
oculon wallet <address> portfolio, age, risk, Robinhood Chain (magpie)
|
|
172
|
+
oculon token <address> [--chain eth|base|arbitrum|bsc|polygon|robinhood] token risk check
|
|
173
|
+
oculon rh Robinhood Chain: activity, trending and new pools (heron)
|
|
174
|
+
oculon deployer <address> Robinhood Chain deployer reputation (serial launchers)
|
|
175
|
+
|
|
176
|
+
${c.bold('Earth & sky')}
|
|
177
|
+
oculon space geomagnetic storms and solar flares
|
|
178
|
+
oculon air <place> PM2.5 air quality near a place
|
|
179
|
+
|
|
180
|
+
${c.bold('Everyday checks')}
|
|
181
|
+
oculon scam "<message>" is this SMS, email or chat message a scam?
|
|
182
|
+
oculon url <link> is a link dangerous? Safe Browsing, URLhaus, urlscan, domain age
|
|
183
|
+
oculon factcheck "<claim>"|<url> fact check a claim or a news link
|
|
184
|
+
oculon audit [file|npm:name@ver ...] dependency health: vulnerabilities, deprecation, Scorecard
|
|
185
|
+
oculon travel <place> travel risk brief for the coming week
|
|
186
|
+
oculon monitor "<request>" watch anything in plain language, e.g. "outages in Iran"
|
|
187
|
+
oculon recall <VIN|"year make model"|product> vehicle and product recalls (NHTSA, CPSC, FDA)
|
|
188
|
+
oculon email <domain> can someone spoof email from this domain? with fixes
|
|
189
|
+
oculon papers "<topic>" research brief: most cited and newest papers
|
|
190
|
+
oculon country <name> country brief: economy, leaders, currency, advice, news
|
|
191
|
+
oculon airport <JFK|EGLL|name> airport weather, FAA delays and ground stops
|
|
192
|
+
|
|
193
|
+
${c.bold('Web')}
|
|
194
|
+
oculon search <query> web search
|
|
195
|
+
oculon read <url> readable text of a page
|
|
196
|
+
|
|
197
|
+
${c.bold('Investigate')}
|
|
198
|
+
oculon dossier <name> company / person / project dossier (hound)
|
|
199
|
+
oculon hype <topic> hype-cycle phase of a topic (cricket)
|
|
200
|
+
oculon footprint <domain> [--days] pre-release footprints of a domain (ferret)
|
|
201
|
+
oculon plane <registration|hex> track one aircraft (falcon)
|
|
202
|
+
oculon mil military air traffic worldwide (falcon)
|
|
203
|
+
oculon ships <place> [--seconds 30] live vessels near a port or strait (AIS)
|
|
204
|
+
oculon ship <mmsi> follow one ship
|
|
205
|
+
oculon events natural events from NASA (condor)
|
|
206
|
+
oculon lights <place> night lights vs baseline (blackouts) (condor)
|
|
207
|
+
oculon image <place> [--date] [--out file.png] satellite image (condor)
|
|
208
|
+
oculon entity <id> entity and neighbors, e.g. org:nvidia
|
|
209
|
+
|
|
210
|
+
${c.bold('Forecasts & proofs')}
|
|
211
|
+
oculon forecast <market-slug> --p 0.35 [--why "..."] record a forecast (raven)
|
|
212
|
+
oculon forecast auto | resolve | score | list
|
|
213
|
+
oculon proof stamp timestamp forecasts on Bitcoin (tortoise)
|
|
214
|
+
oculon proof verify <forecast-id> verify down to the Bitcoin block
|
|
215
|
+
|
|
216
|
+
${c.bold('Run')}
|
|
217
|
+
oculon serve [--port 4747] [--watch 15] [--telegram] [--live] [--host 0.0.0.0 --public] web app on 127.0.0.1; --public opens a read-only overview
|
|
218
|
+
oculon mcp MCP server on stdio (for Claude and other agents)
|
|
219
|
+
oculon telegram Telegram bot (TELEGRAM_BOT_TOKEN, TELEGRAM_ALLOWED_CHATS)
|
|
220
|
+
oculon doctor check setup and every data source
|
|
221
|
+
oculon tour what this install knows and what to try next
|
|
222
|
+
oculon gc [--days 14] drop old cached API responses, compact the database
|
|
223
|
+
|
|
224
|
+
Every command accepts ${c.bold('--json')}. Data lives in ${oculonHome()} (set OCULON_HOME to change).
|
|
225
|
+
Optional settings: OCULON_CONTACT (enables SEC EDGAR), GITHUB_TOKEN.`;
|
|
226
|
+
const need = (a, i, what) => {
|
|
227
|
+
const v = a.pos.slice(i).join(' ').trim();
|
|
228
|
+
if (!v)
|
|
229
|
+
throw new UsageError(`missing ${what}`);
|
|
230
|
+
return v;
|
|
231
|
+
};
|
|
232
|
+
class UsageError extends Error {
|
|
233
|
+
}
|
|
234
|
+
const json = (a) => a.flags.json === true;
|
|
235
|
+
const emit = (a, data, human) => (json(a) ? out(JSON.stringify(data, null, 2)) : human());
|
|
236
|
+
export const COMMANDS = {
|
|
237
|
+
async radar(o, a) {
|
|
238
|
+
const r = await o.radar();
|
|
239
|
+
emit(a, r, () => {
|
|
240
|
+
out(c.bold(`Radar · ${r.result.blips.length} anomalies, ${r.signals.length} signals`));
|
|
241
|
+
for (const f of r.result.fused.slice(0, 12)) {
|
|
242
|
+
out(` [${score(f.score)}] ${c.bold(trunc(f.title, 90))} ${c.gray(f.sources.join(' + '))}`);
|
|
243
|
+
if (f.linkedBy)
|
|
244
|
+
out(c.dim(` linked by AI (${trunc(f.linkedBy, 110)})`));
|
|
245
|
+
for (const b of f.blips.slice(0, 3))
|
|
246
|
+
out(` ${c.cyan(b.source)} ${f.linkedBy ? `${trunc(b.title, 40)}: ` : ''}${trunc(b.detail, 100)}`);
|
|
247
|
+
}
|
|
248
|
+
printSources(r);
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
async signals(o, a) {
|
|
252
|
+
const s = o.signals(Number(a.flags.limit ?? 20) || 20);
|
|
253
|
+
emit(a, s, () => (s.length ? printSignals(s, 50) : out('No signals yet. Run `oculon radar`.')));
|
|
254
|
+
},
|
|
255
|
+
async dossier(o, a) {
|
|
256
|
+
const r = await o.dossier(need(a, 1, 'name'), { ...(a.flags['no-github'] ? { github: false } : typeof a.flags.github === 'string' ? { github: a.flags.github } : {}), ...(a.flags.deep ? { deep: true } : {}) });
|
|
257
|
+
emit(a, r, () => {
|
|
258
|
+
const d = r.result;
|
|
259
|
+
out(c.bold(d.wikipedia?.title ?? d.query) + (d.wikipedia?.description ? c.dim(` — ${d.wikipedia.description}`) : ''));
|
|
260
|
+
if (d.wikipedia?.lastDayViews != null)
|
|
261
|
+
out(` Wikipedia readers yesterday ${d.wikipedia.lastDayViews.toLocaleString('en-US')}${d.wikipedia.spike ? ` (${d.wikipedia.spike.toFixed(1)}× usual)` : ''}`);
|
|
262
|
+
if (d.sec)
|
|
263
|
+
out(` SEC ${d.sec.company.name} (${d.sec.company.ticker}), ${d.sec.filings.length} recent filings`);
|
|
264
|
+
if (d.github)
|
|
265
|
+
out(` GitHub ${d.github.owner}: ${d.github.repos.length} new repos`);
|
|
266
|
+
for (const m of d.markets.slice(0, 5))
|
|
267
|
+
out(` ${c.cyan('market')} ${trunc(m.question, 80)} ${c.bold(pct(m.prices[0]))}${m.change1d ? c.dim(` ${m.change1d > 0 ? '+' : ''}${Math.round(m.change1d * 100)}pp 24h`) : ''}`);
|
|
268
|
+
const usd = (n) => (n >= 1e9 ? `$${(n / 1e9).toFixed(1)}B` : n >= 1e6 ? `$${(n / 1e6).toFixed(1)}M` : `$${Math.round(n / 1e3)}k`);
|
|
269
|
+
const rec = d.recommendations?.[0];
|
|
270
|
+
if (rec)
|
|
271
|
+
out(` analysts ${rec.period}: ${rec.strongBuy + rec.buy} buy · ${rec.hold} hold · ${rec.sell + rec.strongSell} sell`);
|
|
272
|
+
const ins = [...(d.insiderSentiment ?? [])].sort((p, q) => q.month.localeCompare(p.month))[0];
|
|
273
|
+
if (ins)
|
|
274
|
+
out(` insider sentiment ${ins.month}: ${ins.mspr >= 0 ? c.green(`+${ins.mspr.toFixed(0)}`) : c.red(ins.mspr.toFixed(0))} ${c.dim('(-100 all selling, +100 all buying)')}`);
|
|
275
|
+
if (d.metrics)
|
|
276
|
+
out(c.dim(` P/E ${d.metrics.peTTM?.toFixed(1) ?? '?'} · revenue growth ${d.metrics.revenueGrowthTTMYoy?.toFixed(1) ?? '?'}% · net margin ${d.metrics.netMarginTTM?.toFixed(1) ?? '?'}% · debt/equity ${d.metrics.debtToEquity?.toFixed(2) ?? '?'}`));
|
|
277
|
+
const eps = d.earnings?.[0];
|
|
278
|
+
if (eps?.surprisePct != null)
|
|
279
|
+
out(` last earnings ${eps.period}: EPS ${eps.actual} vs ${eps.estimate} est (${eps.surprisePct >= 0 ? '+' : ''}${eps.surprisePct.toFixed(1)}%)`);
|
|
280
|
+
if (d.peers?.length)
|
|
281
|
+
out(c.dim(` peers ${d.peers.slice(0, 8).join(', ')}`));
|
|
282
|
+
for (const e of (d.events ?? []).slice(0, 4))
|
|
283
|
+
out(` ${c.yellow('8-K')} ${c.gray(e.date)} ${trunc(e.summary, 100)}${e.officerDeparture ? c.red(` ${e.officerDeparture} leaving`) : ''}`);
|
|
284
|
+
if (d.fda)
|
|
285
|
+
out(` FDA recalls: drug ${d.fda.totals.drug ?? 0}, device ${d.fda.totals.device ?? 0}, food ${d.fda.totals.food ?? 0}${d.fda.newClassI.length ? c.red(` · ${d.fda.newClassI.length} new Class I`) : ''}`);
|
|
286
|
+
if (d.trials)
|
|
287
|
+
out(` clinical trials: ${d.trials.counts.recruiting} recruiting, ${d.trials.counts.active} active, ${d.trials.counts.terminated} terminated${d.trials.recentlyTerminated.length ? c.yellow(` · ${d.trials.recentlyTerminated.length} stopped recently`) : ''}`);
|
|
288
|
+
if (d.lobbying)
|
|
289
|
+
out(` lobbying ${usd(d.lobbying.totalUsd)} over ${d.lobbying.filings} filings`);
|
|
290
|
+
if (d.govContracts)
|
|
291
|
+
out(` federal contracts ${d.govContracts.awards} awards, ${usd(d.govContracts.totalUsd)}${d.govContracts.topAgencies[0] ? `, mostly ${d.govContracts.topAgencies[0].agency}` : ''}`);
|
|
292
|
+
if (d.visa)
|
|
293
|
+
out(` visa filings ${d.visa.applications}${d.visa.applications >= 500 ? '+' : ''}${d.visa.topTitles[0] ? `, top role ${d.visa.topTitles[0].title}` : ''}`);
|
|
294
|
+
if (d.patents)
|
|
295
|
+
out(` patents ${d.patents.count}${d.patents.count >= 250 ? '+' : ''} in the last year${d.patents.latest[0] ? c.dim(`, latest: ${trunc(d.patents.latest[0].title, 70)}`) : ''}`);
|
|
296
|
+
out(c.bold('\nTimeline'));
|
|
297
|
+
for (const t of d.timeline.slice(0, 15))
|
|
298
|
+
out(` ${c.gray(t.date.slice(0, 10))} ${c.cyan(t.source.padEnd(20))} ${trunc(t.text, 95)}`);
|
|
299
|
+
if (!d.timeline.length)
|
|
300
|
+
out(c.dim(' nothing in the window'));
|
|
301
|
+
if (r.signals.length) {
|
|
302
|
+
out(c.bold('\nSignals'));
|
|
303
|
+
printSignals(r.signals);
|
|
304
|
+
}
|
|
305
|
+
printSources(r);
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
async hype(o, a) {
|
|
309
|
+
const r = await o.hype(need(a, 1, 'topic'));
|
|
310
|
+
emit(a, r, () => {
|
|
311
|
+
const d = r.result;
|
|
312
|
+
out(`${c.bold(d.topic)} · ${c.bold(c.yellow(d.phase))}`);
|
|
313
|
+
out(c.dim(d.summary));
|
|
314
|
+
const bars = '▁▂▃▄▅▆▇█';
|
|
315
|
+
for (const ch of d.channels) {
|
|
316
|
+
const max = Math.max(...ch.weekly, 1e-9);
|
|
317
|
+
const spark = ch.weekly.map((v) => bars[Math.min(7, Math.floor((v / max) * 7.99))]).join('');
|
|
318
|
+
out(` ${ch.channel.padEnd(11)} ${(ch.trend?.phase ?? 'n/a').padEnd(9)} ${c.cyan(spark.padEnd(8))} ${c.dim(`${ch.source}, ${ch.unit}${ch.note ? `; ${ch.note}` : ''}`)}`);
|
|
319
|
+
}
|
|
320
|
+
printSources(r);
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
async footprint(o, a) {
|
|
324
|
+
const r = await o.footprint(need(a, 1, 'domain'), {
|
|
325
|
+
...(a.flags.days ? { days: Number(a.flags.days) } : {}),
|
|
326
|
+
...(a.flags['no-org'] ? { org: false } : typeof a.flags.org === 'string' ? { org: a.flags.org } : {}),
|
|
327
|
+
});
|
|
328
|
+
emit(a, r, () => {
|
|
329
|
+
const d = r.result;
|
|
330
|
+
out(c.bold(`${d.domain} · last ${d.windowDays} days: ${d.counts.subdomain} subdomains, ${d.counts.page} pages, ${d.counts.repo} repos${d.firstScan ? c.dim(' (first scan)') : ''}`));
|
|
331
|
+
for (const f of d.findings.slice(0, 25)) {
|
|
332
|
+
out(` [${score(f.score)}] ${c.cyan(f.kind.padEnd(9))} ${trunc(f.value, 80)} ${c.gray(f.firstSeen.slice(0, 10))}${f.newSinceLastScan ? c.green(' NEW') : ''}`);
|
|
333
|
+
if (f.reasons.length)
|
|
334
|
+
out(c.dim(` ${trunc(f.reasons.join('; '), 110)}`));
|
|
335
|
+
}
|
|
336
|
+
if (!d.findings.length)
|
|
337
|
+
out(c.dim(' nothing new in the window'));
|
|
338
|
+
printSources(r);
|
|
339
|
+
});
|
|
340
|
+
},
|
|
341
|
+
async plane(o, a) {
|
|
342
|
+
const r = await o.aircraft(need(a, 1, 'registration or hex'));
|
|
343
|
+
emit(a, r, () => {
|
|
344
|
+
const t = r.result;
|
|
345
|
+
out(c.bold(`${t.info?.registration ?? t.query}${t.hex ? c.dim(` (hex ${t.hex})`) : c.dim(' (not found)')}`));
|
|
346
|
+
if (t.info)
|
|
347
|
+
out(` ${[t.info.manufacturer, t.info.type].filter(Boolean).join(' ')}${t.info.owner ? `, owner ${c.bold(t.info.owner)}` : ''}`);
|
|
348
|
+
out(` status ${c.bold(t.status)}${t.state?.altFt != null && t.status === 'AIRBORNE' ? ` at ${t.state.altFt} ft, ${t.state.speedKt ?? '?'} kt` : ''}${t.state?.callsign ? `, callsign ${t.state.callsign}` : ''}`);
|
|
349
|
+
if (t.place)
|
|
350
|
+
out(` ${t.place.relation} ${t.place.airport} (${t.place.km} km)`);
|
|
351
|
+
if (t.previous)
|
|
352
|
+
out(c.dim(` previous check ${t.previous.at.slice(0, 16)}: ${t.previous.status}${t.previous.place ? ` ${t.previous.place.relation} ${t.previous.place.airport}` : ''}`));
|
|
353
|
+
if (t.change)
|
|
354
|
+
out(c.yellow(` ${t.change}`));
|
|
355
|
+
printSources(r);
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
async mil(o, a) {
|
|
359
|
+
const r = await o.military();
|
|
360
|
+
emit(a, r, () => {
|
|
361
|
+
const d = r.result;
|
|
362
|
+
out(c.bold(`Military air · ${d.withPosition} aircraft with position (${d.total} flagged)`) + (d.firstRuns ? c.dim(' baseline still building') : ''));
|
|
363
|
+
for (const g of d.regions.slice(0, 15)) {
|
|
364
|
+
out(` ${String(g.count).padStart(3)} ${g.label}${g.baselineMedian !== null ? c.dim(` (usual ~${g.baselineMedian})`) : ''}${g.notable.length ? ` ${c.red(g.notable.map((n) => `${n.type}/${n.role}`).join(', '))}` : ''}`);
|
|
365
|
+
}
|
|
366
|
+
if (r.signals.length) {
|
|
367
|
+
out(c.bold('\nSignals'));
|
|
368
|
+
printSignals(r.signals);
|
|
369
|
+
}
|
|
370
|
+
printSources(r);
|
|
371
|
+
});
|
|
372
|
+
},
|
|
373
|
+
async events(o, a) {
|
|
374
|
+
const r = await o.naturalEvents(Number(a.flags.days ?? 7) || 7);
|
|
375
|
+
emit(a, r, () => {
|
|
376
|
+
out(c.bold(`Natural events · ${r.result.events.length} open (NASA EONET)`));
|
|
377
|
+
for (const e of r.result.events.slice(0, 20))
|
|
378
|
+
out(` ${e.severity !== null ? `[${score(e.severity)}]` : ' '} ${c.cyan(e.category.padEnd(13))} ${e.title}${e.why ? c.dim(` ${e.why}`) : ''}`);
|
|
379
|
+
printSources(r);
|
|
380
|
+
});
|
|
381
|
+
},
|
|
382
|
+
async lights(o, a) {
|
|
383
|
+
const r = await o.nightLights(need(a, 1, 'place'));
|
|
384
|
+
emit(a, r, () => {
|
|
385
|
+
const l = r.result;
|
|
386
|
+
const col = l.verdict === 'DROP' ? c.red : l.verdict === 'RISE' ? c.yellow : c.green;
|
|
387
|
+
out(`${c.bold(l.place.name)}\n night lights ${col(c.bold(l.verdict))}${l.ratio ? ` (${l.ratio >= 1 ? '+' : ''}${Math.round((l.ratio - 1) * 100)}%)` : ''} · ${l.recent.length} recent nights vs ${l.baseline.length} baseline · newest ${l.latestDate ?? 'n/a'}`);
|
|
388
|
+
out(c.dim(` recent ${l.recent.map((d) => d.mean.toFixed(0)).join(' ')}`));
|
|
389
|
+
out(c.dim(` baseline ${l.baseline.map((d) => d.mean.toFixed(0)).join(' ')}`));
|
|
390
|
+
if (l.alternatives.length)
|
|
391
|
+
out(c.dim(` other matches: ${l.alternatives.slice(0, 3).join(' | ')}`));
|
|
392
|
+
printSources(r);
|
|
393
|
+
});
|
|
394
|
+
},
|
|
395
|
+
async image(o, a) {
|
|
396
|
+
const r = await o.satelliteImage(need(a, 1, 'place'), typeof a.flags.date === 'string' ? a.flags.date : undefined);
|
|
397
|
+
let file = r.result.file;
|
|
398
|
+
if (file && typeof a.flags.out === 'string') {
|
|
399
|
+
const dest = resolve(a.flags.out);
|
|
400
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
401
|
+
copyFileSync(file, dest);
|
|
402
|
+
file = dest;
|
|
403
|
+
}
|
|
404
|
+
emit(a, { ...r.result, file }, () => out(file ? `${c.bold(r.result.place.name)} · ${r.result.date}\n saved ${file}` : `No image for ${r.result.place.name} on ${r.result.date}.`));
|
|
405
|
+
},
|
|
406
|
+
async ask(o, a) {
|
|
407
|
+
const question = need(a, 1, 'question');
|
|
408
|
+
if (!json(a))
|
|
409
|
+
out(c.dim(`thinking about: ${question}`));
|
|
410
|
+
const r = await o.ask(question, { onStep: json(a) ? () => { } : (s) => out(c.dim(` → ${trunc(s, 120)}`)) });
|
|
411
|
+
emit(a, r, () => {
|
|
412
|
+
out(`\n${r.answer}\n`);
|
|
413
|
+
out(c.dim(`${r.steps.length} tool call(s) · model: ${[...new Set(r.providers)].join(', ')} · AI-written from the tool results above; check the cited sources`));
|
|
414
|
+
});
|
|
415
|
+
},
|
|
416
|
+
async wallet(o, a) {
|
|
417
|
+
const r = await o.wallet(need(a, 1, 'address'));
|
|
418
|
+
emit(a, r, () => {
|
|
419
|
+
const w = r.result;
|
|
420
|
+
out(c.bold(`${w.address} · ${w.kind}`) + (w.knownAs ? ` ${c.cyan(w.knownAs)}` : ''));
|
|
421
|
+
if (w.solana)
|
|
422
|
+
out(` ${w.solana.sol.toFixed(3)} SOL, ${w.solana.tokens} token accounts`);
|
|
423
|
+
if (w.portfolio) {
|
|
424
|
+
out(` portfolio ${c.bold(`$${Math.round(w.portfolio.totalUsd).toLocaleString('en-US')}`)}${w.portfolio.change1dPct != null ? c.dim(` (${w.portfolio.change1dPct >= 0 ? '+' : ''}${w.portfolio.change1dPct.toFixed(1)}% 24h)`) : ''}`);
|
|
425
|
+
for (const t of w.portfolio.top.slice(0, 6))
|
|
426
|
+
out(` ${t.symbol.padEnd(10)} $${Math.round(t.valueUsd).toLocaleString('en-US').padStart(12)} ${c.dim(t.chain)}`);
|
|
427
|
+
out(c.dim(' values as reported by Zerion; airdropped tokens can carry inflated prices'));
|
|
428
|
+
}
|
|
429
|
+
if (w.firstSeen)
|
|
430
|
+
out(` first transaction ${w.firstSeen.slice(0, 10)} (${w.ageDays} days ago) · ${w.recentTxs.length} recent txs`);
|
|
431
|
+
if (w.robinhood)
|
|
432
|
+
out(` Robinhood Chain: ${w.robinhood.balanceEth.toFixed(4)} ETH, ${w.robinhood.txCount} txs${w.robinhood.isContract ? ', contract' : ''}`);
|
|
433
|
+
if (w.counterparties.length)
|
|
434
|
+
out(` known counterparties: ${w.counterparties.slice(0, 5).map((x) => `${x.knownAs} ×${x.txs}`).join(c.dim(' · '))}`);
|
|
435
|
+
out(` risk: ${w.labels.length ? c.red(w.labels.join(', ')) : c.green('no GoPlus labels')}${w.riskScore != null ? ` · Webacy ${w.riskScore}` : ''}${w.riskIssues.length ? c.dim(` (${w.riskIssues.slice(0, 4).join(', ')})`) : ''}`);
|
|
436
|
+
printSources(r);
|
|
437
|
+
});
|
|
438
|
+
},
|
|
439
|
+
async ships(o, a) {
|
|
440
|
+
const secs = Number(a.flags.seconds ?? 30) || 30;
|
|
441
|
+
if (!json(a))
|
|
442
|
+
out(c.dim(`listening to AIS for ${secs}s…`));
|
|
443
|
+
const r = await o.ships(need(a, 1, 'place'), secs);
|
|
444
|
+
emit(a, r, () => {
|
|
445
|
+
const d = r.result;
|
|
446
|
+
out(`${c.bold(d.place.name)} · ${d.total} vessels in ${d.seconds}s · ${d.moving} moving · ${d.stationary} anchored/moored${d.baselineStationary !== null ? c.dim(` (usual ~${d.baselineStationary})`) : ''}`);
|
|
447
|
+
if (Object.keys(d.byType).length)
|
|
448
|
+
out(c.dim(` types: ${Object.entries(d.byType).sort((x, y) => y[1] - x[1]).map(([t, n]) => `${t} ${n}`).join(', ')}`));
|
|
449
|
+
for (const v of d.vessels.filter((x) => x.name).slice(0, 20))
|
|
450
|
+
out(` ${trunc(v.name ?? '', 24).padEnd(24)} ${String(v.mmsi).padEnd(10)} ${v.sog != null ? `${v.sog.toFixed(1)} kn`.padStart(8) : ' ?'} ${v.stationary ? c.yellow('stationary') : c.green('moving ')} ${c.dim(v.type)}${v.destination ? c.dim(` → ${v.destination}`) : ''}`);
|
|
451
|
+
if (r.signals.length)
|
|
452
|
+
printSignals(r.signals);
|
|
453
|
+
printSources(r);
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
async ship(o, a) {
|
|
457
|
+
const secs = Number(a.flags.seconds ?? 60) || 60;
|
|
458
|
+
if (!json(a))
|
|
459
|
+
out(c.dim(`following MMSI ${a.pos[1] ?? '?'} for up to ${secs}s…`));
|
|
460
|
+
const r = await o.ship(need(a, 1, 'MMSI'), secs);
|
|
461
|
+
emit(a, r, () => {
|
|
462
|
+
const v = r.result.vessel;
|
|
463
|
+
if (!v)
|
|
464
|
+
return out(`No report from MMSI ${r.result.mmsi} in ${r.result.seconds}s. ${c.dim(r.provenance[0]?.note ?? '')}`);
|
|
465
|
+
out(`${c.bold(v.name ?? String(v.mmsi))} · ${v.type} · ${v.sog ?? '?'} kn · ${v.lat.toFixed(4)}, ${v.lon.toFixed(4)} at ${v.lastSeen.slice(0, 16)}Z${v.destination ? ` · → ${v.destination}` : ''}`);
|
|
466
|
+
out(c.dim(` https://www.marinetraffic.com/en/ais/details/ships/mmsi:${v.mmsi}`));
|
|
467
|
+
});
|
|
468
|
+
},
|
|
469
|
+
async deployer(o, a) {
|
|
470
|
+
const r = await o.robinhoodDeployer(need(a, 1, 'token or deployer address'));
|
|
471
|
+
emit(a, r, () => {
|
|
472
|
+
const d = r.result;
|
|
473
|
+
const col = d.verdict === 'DANGER' ? c.red : d.verdict === 'CAUTION' ? c.yellow : d.verdict === 'OK' ? c.green : c.gray;
|
|
474
|
+
out(`${c.bold(`Deployer ${d.deployer}`)} · ${col(c.bold(d.verdict))}`);
|
|
475
|
+
out(` ${d.reasons.join('; ')} · ${d.contracts} contract(s) launched`);
|
|
476
|
+
for (const t of d.tokens.slice(0, 15))
|
|
477
|
+
out(` ${(t.symbol ?? '?').padEnd(12)} ${t.address} liq $${t.reserveUsd.toLocaleString('en-US').padStart(10)} ${t.dead ? c.red('dead') : c.green('alive')} ${c.dim(t.createdAt.slice(0, 10))}`);
|
|
478
|
+
printSources(r);
|
|
479
|
+
});
|
|
480
|
+
},
|
|
481
|
+
async rh(o, a) {
|
|
482
|
+
const r = await o.robinhood();
|
|
483
|
+
emit(a, r, () => {
|
|
484
|
+
const s = r.result.stats;
|
|
485
|
+
out(c.bold('Robinhood Chain') + (s ? c.dim(` · ${s.transactionsToday.toLocaleString('en-US')} txs today · ${s.addresses.toLocaleString('en-US')} addresses · gas ${s.gasAverage ?? '?'} gwei`) : ''));
|
|
486
|
+
out(c.bold('\nTrending pools'));
|
|
487
|
+
for (const t of r.result.trending.slice(0, 10))
|
|
488
|
+
out(` ${trunc(t.pool.name, 26).padEnd(26)} liq $${Math.round(t.pool.liquidityUsd).toLocaleString('en-US').padStart(10)} 24h ${String(t.pool.change24h?.toFixed(0) ?? '?').padStart(5)}%${t.flags.length ? ` ${c.yellow(t.flags.join('; '))}` : ''}`);
|
|
489
|
+
out(c.bold('\nNew pools'));
|
|
490
|
+
for (const f of r.result.fresh.slice(0, 12))
|
|
491
|
+
out(` ${trunc(f.pool.name, 26).padEnd(26)} ${f.ageHours.toFixed(1).padStart(5)}h liq $${Math.round(f.pool.liquidityUsd).toLocaleString('en-US').padStart(9)} buys/sells ${f.pool.buys24h}/${f.pool.sells24h}${f.flags.length ? ` ${c.red(f.flags.join('; '))}` : ''}`);
|
|
492
|
+
if (r.signals.length) {
|
|
493
|
+
out(c.bold('\nSignals'));
|
|
494
|
+
printSignals(r.signals);
|
|
495
|
+
}
|
|
496
|
+
printSources(r);
|
|
497
|
+
});
|
|
498
|
+
},
|
|
499
|
+
async token(o, a) {
|
|
500
|
+
if (a.flags.chain === 'robinhood') {
|
|
501
|
+
const r = await o.robinhoodToken(need(a, 1, 'token address').split(' ')[0]);
|
|
502
|
+
return emit(a, r, () => {
|
|
503
|
+
const t = r.result;
|
|
504
|
+
const col = t.verdict === 'DANGER' ? c.red : t.verdict === 'CAUTION' ? c.yellow : t.verdict === 'OK' ? c.green : c.gray;
|
|
505
|
+
out(`${c.bold(t.symbol ?? t.address)} on Robinhood Chain · ${col(c.bold(t.verdict))}`);
|
|
506
|
+
out(c.dim(` holders ${t.holders?.toLocaleString('en-US') ?? '?'} · verified ${t.verified ?? '?'} · top 10 hold ${t.top10Share != null ? `${Math.round(t.top10Share * 100)}%` : '?'}`));
|
|
507
|
+
out(c.dim(` deployer ${t.deployer.address} · ${t.deployer.otherTokens} other token(s), ${t.deployer.dead} dead`));
|
|
508
|
+
for (const why of t.reasons)
|
|
509
|
+
out(` - ${why}`);
|
|
510
|
+
for (const p of t.pools.slice(0, 4))
|
|
511
|
+
out(` ${c.cyan(trunc(p.pool.name, 24).padEnd(24))} liq $${Math.round(p.pool.liquidityUsd).toLocaleString('en-US')} · vol24h $${Math.round(p.pool.volume24h).toLocaleString('en-US')}`);
|
|
512
|
+
printSources(r);
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
const r = await o.token(need(a, 1, 'token address').split(' ')[0], typeof a.flags.chain === 'string' ? a.flags.chain : 'eth');
|
|
516
|
+
emit(a, r, () => {
|
|
517
|
+
const t = r.result;
|
|
518
|
+
const col = t.verdict === 'DANGER' ? c.red : t.verdict === 'CAUTION' ? c.yellow : t.verdict === 'OK' ? c.green : c.gray;
|
|
519
|
+
out(`${c.bold(t.security?.symbol || t.market?.symbol?.toUpperCase() || t.address)} on ${t.chain} · ${col(c.bold(t.verdict))}`);
|
|
520
|
+
for (const why of t.reasons)
|
|
521
|
+
out(` - ${why}`);
|
|
522
|
+
if (t.market)
|
|
523
|
+
out(` price $${t.market.priceUsd ?? '?'} · mcap ${t.market.marketCapUsd ? `$${Math.round(t.market.marketCapUsd).toLocaleString('en-US')}` : '?'}`);
|
|
524
|
+
if (t.security)
|
|
525
|
+
out(c.dim(` holders ${t.security.holders?.toLocaleString('en-US') ?? '?'} · buy tax ${t.security.buyTax ?? '?'} · sell tax ${t.security.sellTax ?? '?'}`));
|
|
526
|
+
for (const p of t.pairs.slice(0, 5))
|
|
527
|
+
out(` ${c.cyan(p.dex.padEnd(12))} ${p.pair.padEnd(14)} liq $${Math.round(p.liquidityUsd ?? 0).toLocaleString('en-US')} · vol24h $${Math.round(p.volume24h ?? 0).toLocaleString('en-US')}`);
|
|
528
|
+
printSources(r);
|
|
529
|
+
});
|
|
530
|
+
},
|
|
531
|
+
async space(o, a) {
|
|
532
|
+
const r = await o.spaceWeather();
|
|
533
|
+
emit(a, r, () => {
|
|
534
|
+
const s = r.result;
|
|
535
|
+
out(`${c.bold('Space weather')} · ${s.stormLevel === 'quiet' ? c.green('quiet') : c.yellow(s.stormLevel)} · Kp now ${s.kpNow ?? '?'}, max 24h ${s.kpMax24h ?? '?'}`);
|
|
536
|
+
if (s.strongestFlare)
|
|
537
|
+
out(` strongest flare (7d) ${c.bold(s.strongestFlare.maxClass)} at ${s.strongestFlare.maxTime.slice(0, 16)}Z · ${s.flares7d} flares`);
|
|
538
|
+
if (s.scales)
|
|
539
|
+
out(` NOAA scales now R${s.scales.now.r} S${s.scales.now.s} G${s.scales.now.g}${s.scales.days.length ? c.dim(` · next days G ${s.scales.days.map((d) => d.g).join('/')}, R1-R2 odds ${s.scales.days.map((d) => `${d.rMinorProb ?? '?'}%`).join('/')}`) : ''}`);
|
|
540
|
+
if (s.solarWind)
|
|
541
|
+
out(` solar wind ${s.solarWind.speedKmS ?? '?'} km/s · Bt ${s.solarWind.bt ?? '?'} nT · Bz ${s.solarWind.bz != null && s.solarWind.bz <= -10 ? c.red(`${s.solarWind.bz}`) : s.solarWind.bz ?? '?'} nT${c.dim(' (strongly negative Bz drives storms)')}`);
|
|
542
|
+
if (s.forecast?.expectedKpMax != null)
|
|
543
|
+
out(` 3-day forecast: max Kp ${s.forecast.expectedKpMax}${c.dim(` ${Object.entries(s.forecast.kpByDay).map(([d, k]) => `${d} ${k}`).join(', ')}`)}`);
|
|
544
|
+
for (const al of (s.alerts ?? []).slice(0, 6))
|
|
545
|
+
out(` ${al.kind === 'WARNING' || al.kind === 'ALERT' ? c.yellow(al.kind.toLowerCase().padEnd(7)) : c.dim(al.kind.toLowerCase().padEnd(7))} ${c.gray(al.issued.slice(0, 16).replace('T', ' '))} ${trunc(al.title, 90)}${al.scale ? ` ${c.bold(al.scale)}` : ''}`);
|
|
546
|
+
const toEarth = (s.cmes ?? []).filter((x) => x.earthArrival);
|
|
547
|
+
if (s.cmes?.length)
|
|
548
|
+
out(` CMEs (7d): ${s.cmes.length}${toEarth.length ? `, ${c.yellow(`${toEarth.length} modelled to reach Earth`)}` : ''}`);
|
|
549
|
+
for (const x of toEarth.slice(0, 4))
|
|
550
|
+
out(` ${c.gray(x.start.slice(0, 16).replace('T', ' '))} ${x.speedKmS ?? '?'} km/s → arrives ${x.earthArrival.slice(0, 16).replace('T', ' ')}${x.earthGlancing ? ' (glancing)' : ''}${x.kpPredicted ? `, model Kp ${x.kpPredicted}` : ''}`);
|
|
551
|
+
const neo = s.neo ?? [];
|
|
552
|
+
if (neo[0])
|
|
553
|
+
out(` closest asteroid pass: ${neo[0].name} ${neo[0].missLunar.toFixed(1)} lunar distances on ${neo[0].time} UTC, up to ${Math.round(neo[0].diameterM.max)} m${neo[0].hazardous ? c.yellow(' (potentially hazardous)') : ''}`);
|
|
554
|
+
if (r.signals.length)
|
|
555
|
+
printSignals(r.signals);
|
|
556
|
+
printSources(r);
|
|
557
|
+
});
|
|
558
|
+
},
|
|
559
|
+
async air(o, a) {
|
|
560
|
+
const r = await o.airQuality(need(a, 1, 'place'));
|
|
561
|
+
emit(a, r, () => {
|
|
562
|
+
const d = r.result;
|
|
563
|
+
out(`${c.bold(d.place.name)}\n PM2.5 median ${d.median != null ? c.bold(`${d.median.toFixed(0)} µg/m³`) : 'n/a'} · ${d.category ?? 'no fresh stations within 25 km'}`);
|
|
564
|
+
for (const s of d.stations)
|
|
565
|
+
out(` ${trunc(s.name, 40).padEnd(40)} ${String(s.value).padStart(6)} ${s.unit} ${c.dim(`${s.category}, ${s.time.slice(0, 16)}Z`)}`);
|
|
566
|
+
printSources(r);
|
|
567
|
+
});
|
|
568
|
+
},
|
|
569
|
+
async url(o, a) {
|
|
570
|
+
const r = await o.urlCheck(need(a, 1, 'link'));
|
|
571
|
+
emit(a, r, () => {
|
|
572
|
+
const d = r.result;
|
|
573
|
+
const tone = d.verdict === 'malicious' ? c.red : d.verdict === 'suspicious' ? c.yellow : c.green;
|
|
574
|
+
out(`${c.bold(d.host)} ${tone(d.verdict.toUpperCase())} ${c.dim(`risk ${d.risk}/100`)}`);
|
|
575
|
+
for (const x of d.reasons)
|
|
576
|
+
out(` - ${x}`);
|
|
577
|
+
if (d.domainInfo?.registered)
|
|
578
|
+
out(c.dim(` domain ${d.domain}: registered ${d.domainInfo.registered.slice(0, 10)}${d.domainInfo.registrar ? ` via ${d.domainInfo.registrar}` : ''}${d.domainInfo.expires ? `, expires ${d.domainInfo.expires.slice(0, 10)}` : ''}`));
|
|
579
|
+
if (d.scans?.count)
|
|
580
|
+
out(c.dim(` urlscan.io: ${d.scans.count} scan(s) since ${d.scans.firstSeen?.slice(0, 10)}${d.scans.countries.length ? `, hosted in ${d.scans.countries.join(', ')}` : ''}${d.scans.latest ? ` ${d.scans.latest}` : ''}`));
|
|
581
|
+
if (d.verdict === 'no known threats')
|
|
582
|
+
out(c.dim(' no source flags it; that is not a guarantee the page is safe'));
|
|
583
|
+
printSources(r);
|
|
584
|
+
});
|
|
585
|
+
},
|
|
586
|
+
async audit(o, a) {
|
|
587
|
+
const args = a.pos.slice(1);
|
|
588
|
+
let text;
|
|
589
|
+
if (!args.length) {
|
|
590
|
+
const guess = ['package.json', 'requirements.txt'].find((f) => existsSync(f));
|
|
591
|
+
if (!guess)
|
|
592
|
+
throw new UsageError('usage: oculon audit <package.json|requirements.txt> | oculon audit npm:express@4.17.1 pypi:requests');
|
|
593
|
+
text = readFileSync(guess, 'utf8');
|
|
594
|
+
}
|
|
595
|
+
else if (args.length === 1 && existsSync(args[0]))
|
|
596
|
+
text = readFileSync(args[0], 'utf8');
|
|
597
|
+
else
|
|
598
|
+
text = args.map((x) => (x.includes(':') ? x : `npm:${x}`)).join(' ');
|
|
599
|
+
if (!json(a))
|
|
600
|
+
out(c.dim('checking packages on deps.dev…'));
|
|
601
|
+
const r = await o.audit(text, a.flags.max ? { max: Number(a.flags.max) } : {});
|
|
602
|
+
emit(a, r, () => {
|
|
603
|
+
const s = r.result.summary;
|
|
604
|
+
out(`${c.bold(`${r.result.manifest}: ${s.checked} of ${s.total} packages checked`)} ${s.vulnerable ? c.red(`${s.vulnerable} vulnerable (${s.advisories} advisories)`) : c.green('no known vulnerabilities')}${s.deprecated ? ` ${c.yellow(`${s.deprecated} deprecated`)}` : ''}${s.stale ? ` ${s.stale} stale` : ''}`);
|
|
605
|
+
for (const p of r.result.packages) {
|
|
606
|
+
if (!p.flags.length && !a.flags.all)
|
|
607
|
+
continue;
|
|
608
|
+
const tone = p.risk >= 60 ? c.red : p.risk >= 30 ? c.yellow : (x) => x;
|
|
609
|
+
out(` ${tone(String(p.risk).padStart(3))} ${c.bold(`${p.name}@${p.version ?? '?'}`)}${p.dev ? c.dim(' (dev)') : ''}${p.project?.scorecard != null ? c.dim(` scorecard ${p.project.scorecard}`) : ''}`);
|
|
610
|
+
for (const f of p.flags)
|
|
611
|
+
out(` - ${f}`);
|
|
612
|
+
for (const x of p.advisories.slice(0, 3))
|
|
613
|
+
out(c.dim(` ${x.aliases[0] ?? x.id}${x.cvss ? ` CVSS ${x.cvss}` : ''}: ${trunc(x.title, 90)}`));
|
|
614
|
+
}
|
|
615
|
+
const clean = r.result.packages.filter((p) => !p.flags.length).length;
|
|
616
|
+
if (clean && !a.flags.all)
|
|
617
|
+
out(c.dim(` ${clean} package(s) with no flags (show them with --all)`));
|
|
618
|
+
for (const x of r.result.skipped)
|
|
619
|
+
out(c.dim(` skipped ${x}`));
|
|
620
|
+
printSources(r);
|
|
621
|
+
});
|
|
622
|
+
},
|
|
623
|
+
async factcheck(o, a) {
|
|
624
|
+
const claim = a.pos.slice(1).join(' ').trim();
|
|
625
|
+
if (!claim)
|
|
626
|
+
throw new UsageError('usage: oculon factcheck "<claim>" | oculon factcheck <news url>');
|
|
627
|
+
const r = await o.factCheck(claim);
|
|
628
|
+
emit(a, r, () => {
|
|
629
|
+
const d = r.result;
|
|
630
|
+
const tone = /false|misleading/.test(d.verdict) ? c.red : /true/.test(d.verdict) ? c.green : c.yellow;
|
|
631
|
+
out(`${c.bold(trunc(d.claim, 160))}\n ${tone(d.verdict.toUpperCase())}${d.confidence ? c.dim(` confidence ${d.confidence}%`) : ''} ${c.dim(d.method)}`);
|
|
632
|
+
if (d.summary)
|
|
633
|
+
out(` ${d.summary}`);
|
|
634
|
+
for (const e of [...d.factChecks, ...d.web].filter((e) => !d.cited.length || d.cited.includes(e.n)).slice(0, 8))
|
|
635
|
+
out(` [${e.n}] ${e.kind === 'fact-check' ? c.bold(e.publisher) : e.publisher}${e.rating ? ` "${e.rating}"` : ''}: ${trunc(e.title, 90)}\n ${c.cyan(e.url)}`);
|
|
636
|
+
printSources(r);
|
|
637
|
+
});
|
|
638
|
+
},
|
|
639
|
+
async travel(o, a) {
|
|
640
|
+
const r = await o.travel(a.pos.slice(1).join(' ') || need(a, 1, 'place'));
|
|
641
|
+
emit(a, r, () => {
|
|
642
|
+
const d = r.result;
|
|
643
|
+
const tone = d.level === 'severe' || d.level === 'high' ? c.red : d.level === 'moderate' ? c.yellow : c.green;
|
|
644
|
+
out(`${c.bold(d.place.name)}\n ${tone(`${d.level.toUpperCase()} risk`)}`);
|
|
645
|
+
for (const p of d.points)
|
|
646
|
+
out(` - ${p}`);
|
|
647
|
+
if (d.weather)
|
|
648
|
+
out(c.dim(` next days: ${d.weather.days.slice(0, 5).map((x) => `${x.date.slice(5)} ${x.summary} ${Math.round(x.tMin)}–${Math.round(x.tMax)}°C`).join(' · ')}`));
|
|
649
|
+
if (d.air?.pm25 != null)
|
|
650
|
+
out(c.dim(` air: PM2.5 ${d.air.pm25.toFixed(0)} µg/m³ (${d.air.category})`));
|
|
651
|
+
if (d.advisories.us)
|
|
652
|
+
out(c.dim(` ${d.advisories.us.url}`));
|
|
653
|
+
if (d.advisories.uk)
|
|
654
|
+
out(c.dim(` ${d.advisories.uk.url}`));
|
|
655
|
+
printSources(r);
|
|
656
|
+
});
|
|
657
|
+
},
|
|
658
|
+
async scam(o, a) {
|
|
659
|
+
let msg = a.pos.slice(1).join(' ').trim();
|
|
660
|
+
if (!msg && !process.stdin.isTTY)
|
|
661
|
+
msg = readFileSync(0, 'utf8');
|
|
662
|
+
if (!msg)
|
|
663
|
+
throw new UsageError('usage: oculon scam "<message text>" (or pipe the message in)');
|
|
664
|
+
const r = await o.scamCheck(msg);
|
|
665
|
+
emit(a, r, () => {
|
|
666
|
+
const d = r.result;
|
|
667
|
+
const tone = d.verdict === 'likely scam' ? c.red : d.verdict === 'suspicious' ? c.yellow : c.green;
|
|
668
|
+
out(`${tone(d.verdict.toUpperCase())} ${c.dim(`risk ${d.risk}/100`)}`);
|
|
669
|
+
if (d.explanation)
|
|
670
|
+
out(` ${d.explanation}`);
|
|
671
|
+
for (const x of d.reasons)
|
|
672
|
+
out(` - ${x}`);
|
|
673
|
+
for (const l of d.links)
|
|
674
|
+
out(c.dim(` link ${l.url}: ${l.verdict} (${l.risk})`));
|
|
675
|
+
for (const x of d.advice)
|
|
676
|
+
out(` → ${x}`);
|
|
677
|
+
printSources(r);
|
|
678
|
+
});
|
|
679
|
+
},
|
|
680
|
+
async recall(o, a) {
|
|
681
|
+
const q = a.pos.slice(1).join(' ').trim();
|
|
682
|
+
if (!q)
|
|
683
|
+
throw new UsageError('usage: oculon recall <VIN | "2018 Honda Accord" | product name>');
|
|
684
|
+
const r = await o.recall(q);
|
|
685
|
+
emit(a, r, () => {
|
|
686
|
+
const d = r.result;
|
|
687
|
+
const head = d.vehicle ? `${d.vehicle.year} ${d.vehicle.make} ${d.vehicle.model}${d.vehicle.vin ? c.dim(` (VIN ${d.vehicle.vin})`) : ''}` : d.query;
|
|
688
|
+
out(`${c.bold(head)} ${d.recalls.length ? c.yellow(`${d.recalls.length} recall(s)`) : c.green('no recalls found')}`);
|
|
689
|
+
for (const x of d.recalls.slice(0, 12)) {
|
|
690
|
+
const warn = x.parkIt ? c.red(' DO NOT DRIVE') : x.parkOutside ? c.red(' PARK OUTSIDE') : x.classification === 'Class I' ? c.red(' Class I') : '';
|
|
691
|
+
out(` ${c.dim(x.date ?? '')} ${x.source} ${x.id}${warn}\n ${trunc(x.title, 110)}\n ${c.dim(trunc(x.hazard, 160))}\n ${c.cyan(x.url)}`);
|
|
692
|
+
}
|
|
693
|
+
if (d.note)
|
|
694
|
+
out(c.dim(` ${d.note}`));
|
|
695
|
+
printSources(r);
|
|
696
|
+
});
|
|
697
|
+
},
|
|
698
|
+
async email(o, a) {
|
|
699
|
+
const r = await o.emailSecurity(need(a, 1, 'domain'));
|
|
700
|
+
emit(a, r, () => {
|
|
701
|
+
const d = r.result;
|
|
702
|
+
const tone = d.verdict === 'protected' ? c.green : d.verdict === 'partly protected' ? c.yellow : c.red;
|
|
703
|
+
out(`${c.bold(d.domain)} ${tone(d.verdict.toUpperCase())} ${c.dim(`score ${d.score}/100`)}`);
|
|
704
|
+
out(` SPF ${d.spf.record ? `${d.spf.all ?? 'no all'} · ${d.spf.lookups} lookups` : c.red('missing')}`);
|
|
705
|
+
out(` DMARC ${d.dmarc.record ? `p=${d.dmarc.policy}${d.dmarc.pct != null ? ` pct=${d.dmarc.pct}` : ''}${d.dmarc.reports ? ' · reports on' : ''}` : c.red('missing')}`);
|
|
706
|
+
out(` DKIM ${d.dkim.selectorsFound.length ? d.dkim.selectorsFound.join(', ') : c.dim('no common selector found')}`);
|
|
707
|
+
out(` extra MTA-STS ${d.mtaSts.mode ?? 'off'} · TLS-RPT ${d.tlsRpt ? 'on' : 'off'} · DNSSEC ${d.dnssec ? 'on' : 'off'} · CAA ${d.caa.length ? 'set' : 'none'} · MX ${d.mx.length ? d.mx.slice(0, 2).join(', ') : 'none'}`);
|
|
708
|
+
if (d.fixes.length)
|
|
709
|
+
out(`\n${c.bold('Fixes')}`);
|
|
710
|
+
d.fixes.forEach((f, i) => out(` ${i + 1}. ${f}`));
|
|
711
|
+
printSources(r);
|
|
712
|
+
});
|
|
713
|
+
},
|
|
714
|
+
async papers(o, a) {
|
|
715
|
+
const topic = a.pos.slice(1).join(' ').trim();
|
|
716
|
+
if (!topic)
|
|
717
|
+
throw new UsageError('usage: oculon papers "<topic>" [--years 3]');
|
|
718
|
+
const r = await o.papers(topic, a.flags.years ? { years: Number(a.flags.years) } : {});
|
|
719
|
+
emit(a, r, () => {
|
|
720
|
+
const d = r.result;
|
|
721
|
+
out(`${c.bold(d.topic)} ${c.dim(`${(d.totalWorks ?? 0).toLocaleString('en-US')} works${d.trend ? ` · field ${d.trend}` : ''}`)}`);
|
|
722
|
+
if (d.perYear.length)
|
|
723
|
+
out(c.dim(` per year: ${d.perYear.map((x) => `${x.year} ${x.count.toLocaleString('en-US')}`).join(' · ')}`));
|
|
724
|
+
if (d.overview)
|
|
725
|
+
out(`\n${d.overview}\n`);
|
|
726
|
+
const line = (p) => ` [${p.n}] ${c.bold(trunc(p.title, 100))}\n ${c.dim(`${p.year ?? '?'} · ${p.venue ?? 'n/a'} · ${p.citations} citations`)}${p.tldr ? `\n ${trunc(p.tldr, 160)}` : ''}\n ${c.cyan(p.openAccessUrl ?? p.url)}`;
|
|
727
|
+
if (d.mostCited.length)
|
|
728
|
+
out(c.bold('Most cited'));
|
|
729
|
+
d.mostCited.slice(0, 6).forEach((p) => out(line(p)));
|
|
730
|
+
if (d.newest.length)
|
|
731
|
+
out(c.bold('Newest'));
|
|
732
|
+
d.newest.slice(0, 4).forEach((p) => out(line(p)));
|
|
733
|
+
if (d.pubmed?.papers.length) {
|
|
734
|
+
out(c.bold(`PubMed (${d.pubmed.count.toLocaleString('en-US')} in 2 years)`));
|
|
735
|
+
d.pubmed.papers.slice(0, 4).forEach((p) => out(line(p)));
|
|
736
|
+
}
|
|
737
|
+
printSources(r);
|
|
738
|
+
});
|
|
739
|
+
},
|
|
740
|
+
async country(o, a) {
|
|
741
|
+
const r = await o.country(a.pos.slice(1).join(' ') || need(a, 1, 'country'));
|
|
742
|
+
emit(a, r, () => {
|
|
743
|
+
const d = r.result;
|
|
744
|
+
out(`${c.bold(d.name)} ${c.dim(`${d.region ?? ''} · ${d.incomeLevel ?? ''} · capital ${d.capital ?? 'n/a'}`)}`);
|
|
745
|
+
out(` head of state ${d.leaders.headOfState ?? 'n/a'}${d.leaders.headOfGovernment && d.leaders.headOfGovernment !== d.leaders.headOfState ? ` · government ${d.leaders.headOfGovernment}` : ''}`);
|
|
746
|
+
for (const i of d.indicators)
|
|
747
|
+
if (i.value != null)
|
|
748
|
+
out(` ${i.name.padEnd(15)} ${i.unit === 'USD' ? `$${i.value >= 1e9 ? `${(i.value / 1e9).toFixed(1)}B` : Math.round(i.value).toLocaleString('en-US')}` : i.unit === 'people' ? `${(i.value / 1e6).toFixed(1)}M` : `${i.value.toFixed(1)}%`} ${c.dim(i.year ?? '')}`);
|
|
749
|
+
const yrs = Object.keys(d.outlook.growth);
|
|
750
|
+
if (yrs.length)
|
|
751
|
+
out(` IMF outlook ${yrs.map((y) => `${y}: growth ${d.outlook.growth[y]}%, inflation ${d.outlook.inflation[y] ?? '?'}%`).join(' · ')}`);
|
|
752
|
+
if (d.currency.perUsd)
|
|
753
|
+
out(` 1 USD = ${d.currency.perUsd.toFixed(2)} ${d.currency.code}`);
|
|
754
|
+
if (d.advisories.us)
|
|
755
|
+
out(` US advisory level ${d.advisories.us.level}: ${d.advisories.us.text}`);
|
|
756
|
+
if (d.advisories.uk?.alerts.length)
|
|
757
|
+
out(` UK FCDO ${d.advisories.uk.alerts.join('; ')}`);
|
|
758
|
+
for (const x of d.outages)
|
|
759
|
+
out(c.yellow(` internet outage: ${x}`));
|
|
760
|
+
for (const h of d.hazards)
|
|
761
|
+
out(c.yellow(` ${h.level.toLowerCase()} alert: ${h.type} ${h.name}`));
|
|
762
|
+
if (d.headlines.length)
|
|
763
|
+
out(c.bold('Headlines'));
|
|
764
|
+
for (const h of d.headlines.slice(0, 5))
|
|
765
|
+
out(` ${trunc(h.title, 110)} ${c.dim(h.date.slice(0, 10))}`);
|
|
766
|
+
printSources(r);
|
|
767
|
+
});
|
|
768
|
+
},
|
|
769
|
+
async airport(o, a) {
|
|
770
|
+
const r = await o.airport(a.pos.slice(1).join(' ') || need(a, 1, 'airport'));
|
|
771
|
+
emit(a, r, () => {
|
|
772
|
+
const d = r.result;
|
|
773
|
+
const tone = d.verdict === 'normal' ? c.green : d.verdict === 'disrupted' ? c.red : c.yellow;
|
|
774
|
+
out(`${c.bold(d.airport.name)} ${tone(d.verdict.toUpperCase())}`);
|
|
775
|
+
for (const p of d.points)
|
|
776
|
+
out(` - ${p}`);
|
|
777
|
+
if (d.metar)
|
|
778
|
+
out(c.dim(` ${d.metar.raw}`));
|
|
779
|
+
if (d.taf)
|
|
780
|
+
out(c.dim(` ${trunc(d.taf.raw, 200)}`));
|
|
781
|
+
printSources(r);
|
|
782
|
+
});
|
|
783
|
+
},
|
|
784
|
+
async monitor(o, a) {
|
|
785
|
+
const text = a.pos.slice(1).join(' ').trim();
|
|
786
|
+
if (!text)
|
|
787
|
+
throw new UsageError('usage: oculon monitor "<what to watch>" e.g. "internet outages in Iran", "critical CVEs for nginx", "earthquakes above 6 near Tokyo"');
|
|
788
|
+
if (a.flags['dry-run']) {
|
|
789
|
+
const r = await o.monitorParse(text);
|
|
790
|
+
return emit(a, r, () => out(`would watch ${c.bold(r.kind)} ${r.target}: ${r.description} ${c.dim(`(${r.method})`)}`));
|
|
791
|
+
}
|
|
792
|
+
const r = await o.monitor(text);
|
|
793
|
+
emit(a, r, () => out(`${c.green('monitoring')} #${r.item.id} ${r.rule.kind} ${c.bold(r.rule.target)}\n ${r.rule.description}\n${c.dim(' checked with the watchlist (oculon watch run, or every cycle of serve --watch / telegram); the first check records a baseline')}`));
|
|
794
|
+
},
|
|
795
|
+
async search(o, a) {
|
|
796
|
+
const r = await o.webSearch(need(a, 1, 'query'), Number(a.flags.max ?? 8) || 8);
|
|
797
|
+
emit(a, r, () => {
|
|
798
|
+
for (const x of r.data ?? [])
|
|
799
|
+
out(` ${c.bold(trunc(x.title, 90))}\n ${c.cyan(x.url)}${x.date ? c.dim(` ${x.date.slice(0, 16)}`) : ''}\n ${c.dim(trunc(x.snippet.replace(/\s+/g, ' '), 160))}`);
|
|
800
|
+
if (!r.data)
|
|
801
|
+
out(`${r.prov.source}: ${r.prov.status} ${r.prov.note ?? ''}`);
|
|
802
|
+
});
|
|
803
|
+
},
|
|
804
|
+
async read(o, a) {
|
|
805
|
+
const r = await o.readPage(need(a, 1, 'url'));
|
|
806
|
+
emit(a, r, () => out(r.data ?? `${r.prov.source}: ${r.prov.status} ${r.prov.note ?? ''}`));
|
|
807
|
+
},
|
|
808
|
+
async narratives(o, a) {
|
|
809
|
+
if (a.pos[1] === 'run') {
|
|
810
|
+
if (!json(a))
|
|
811
|
+
out(c.dim('grouping new headlines into narratives…'));
|
|
812
|
+
const r = await o.narrativesRun();
|
|
813
|
+
if (json(a))
|
|
814
|
+
return out(JSON.stringify(r, null, 2));
|
|
815
|
+
out(c.dim(` ${r.result.added} headline(s) assigned, ${r.result.created.length} new narrative(s)`));
|
|
816
|
+
for (const p of r.provenance.filter((x) => x.status === 'ERROR'))
|
|
817
|
+
out(c.yellow(` ${p.note}`));
|
|
818
|
+
}
|
|
819
|
+
const list = await o.narratives(14);
|
|
820
|
+
emit(a, list, () => {
|
|
821
|
+
if (!list.length)
|
|
822
|
+
return out('No narratives yet. Run: oculon narratives run');
|
|
823
|
+
const bars = '▁▂▃▄▅▆▇█';
|
|
824
|
+
out(c.bold('Narratives · stories per day, last 7 days'));
|
|
825
|
+
for (const n of list.slice(0, 20)) {
|
|
826
|
+
const max = Math.max(...n.daily, 1);
|
|
827
|
+
out(` ${c.cyan(n.daily.map((v) => bars[Math.min(7, Math.floor((v / max) * 7.99))]).join(''))} ${String(n.total).padStart(3)} ${c.bold(trunc(n.name, 50))} ${c.dim(n.phase.toLowerCase())}`);
|
|
828
|
+
if (n.latest[0])
|
|
829
|
+
out(c.dim(` ${trunc(n.latest[0].title, 100)}`));
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
},
|
|
833
|
+
async health(o, a) {
|
|
834
|
+
const r = await o.health(need(a, 1, 'company'));
|
|
835
|
+
emit(a, r, () => {
|
|
836
|
+
const d = r.result;
|
|
837
|
+
const col = d.score >= 60 ? c.green : d.score >= 40 ? c.yellow : c.red;
|
|
838
|
+
out(`${c.bold(d.company)} health ${col(c.bold(`${d.score}/100`))}${d.change !== null ? c.dim(` (${d.change >= 0 ? '+' : ''}${d.change} vs 7-day average)`) : ''}`);
|
|
839
|
+
for (const p of d.parts)
|
|
840
|
+
out(` ${(p.points > 0 ? c.green : p.points < 0 ? c.red : c.dim)(String(p.points > 0 ? `+${p.points}` : p.points).padStart(4))} ${p.name.padEnd(10)} ${c.dim(p.why)}`);
|
|
841
|
+
if (d.history.length > 1)
|
|
842
|
+
out(c.dim(` history: ${d.history.map((h) => h.score).join(' → ')}`));
|
|
843
|
+
});
|
|
844
|
+
},
|
|
845
|
+
async impact(o, a) {
|
|
846
|
+
const place = a.pos.slice(1).join(' ').trim();
|
|
847
|
+
const r = await o.impact(place || undefined, Number(a.flags.radius ?? 50) || 50);
|
|
848
|
+
emit(a, r, () => {
|
|
849
|
+
if (!r.result.impacts.length)
|
|
850
|
+
return out('No M6+ earthquakes or severe storms right now. Name a place to estimate exposure: oculon impact Tokyo --radius 50');
|
|
851
|
+
for (const i of r.result.impacts) {
|
|
852
|
+
out(`${c.bold(i.event)} ${c.dim(`· ${i.radiusKm} km radius · ${i.when.slice(0, 16)}Z`)}`);
|
|
853
|
+
out(` people in listed settlements: ${c.bold(i.exposedPopulation.toLocaleString('en-US'))}${i.settlements.length ? '' : c.dim(' (no populated places found: likely open sea or remote area)')}`);
|
|
854
|
+
for (const s of i.settlements.slice(0, 6))
|
|
855
|
+
out(c.dim(` ${s.name.padEnd(28)} ${s.population.toLocaleString('en-US').padStart(12)} ${s.distanceKm} km`));
|
|
856
|
+
if (i.lights)
|
|
857
|
+
out(` night lights: ${i.lights.verdict}${i.lights.ratio ? ` (${Math.round((i.lights.ratio - 1) * 100)}%)` : ''} ${c.dim(i.lights.note)}`);
|
|
858
|
+
}
|
|
859
|
+
out(c.dim('\nExposure estimate from Wikidata settlement populations (places can overlap); not a casualty estimate.'));
|
|
860
|
+
printSources(r);
|
|
861
|
+
});
|
|
862
|
+
},
|
|
863
|
+
async contradictions(o, a) {
|
|
864
|
+
if (!json(a))
|
|
865
|
+
out(c.dim('reading independent sources and comparing their claims…'));
|
|
866
|
+
const r = await o.contradictions(need(a, 1, 'topic'));
|
|
867
|
+
emit(a, r, () => {
|
|
868
|
+
const d = r.result;
|
|
869
|
+
out(c.bold(`${d.topic} · ${d.sourcesRead.length} sources read · ${d.contradictions.length} contradiction(s)`));
|
|
870
|
+
for (const x of d.contradictions) {
|
|
871
|
+
out(` ${(x.severity === 'major' ? c.red : c.yellow)(x.severity.padEnd(5))} ${c.bold(x.about)}`);
|
|
872
|
+
out(` A: ${trunc(x.claimA, 140)} ${c.dim(x.sourceA)}`);
|
|
873
|
+
out(` B: ${trunc(x.claimB, 140)} ${c.dim(x.sourceB)}`);
|
|
874
|
+
}
|
|
875
|
+
if (!d.contradictions.length)
|
|
876
|
+
out(c.dim(' the sources agree on the facts they share'));
|
|
877
|
+
out(c.dim(` read: ${d.sourcesRead.map((s) => new URL(s.url).hostname.replace(/^www\./, '')).join(', ')}`));
|
|
878
|
+
});
|
|
879
|
+
},
|
|
880
|
+
async report(o, a) {
|
|
881
|
+
const r = await o.report(Number(a.flags.days ?? 7) || 7, typeof a.flags.out === 'string' ? resolve(a.flags.out) : undefined);
|
|
882
|
+
emit(a, { file: r.file, counts: r.counts }, () => out(`${c.bold('Report written')} ${r.file}\n${c.dim(` ${r.counts.signals} signals, ${r.counts.narratives} narratives, ${r.counts.cases} case files. Open it in a browser.`)}`));
|
|
883
|
+
},
|
|
884
|
+
async plugin(o, a) {
|
|
885
|
+
if (a.pos[1] === 'run') {
|
|
886
|
+
const ref = need(a, 2, 'plugin.tool');
|
|
887
|
+
let args = {};
|
|
888
|
+
if (typeof a.flags.args === 'string') {
|
|
889
|
+
try {
|
|
890
|
+
args = JSON.parse(a.flags.args);
|
|
891
|
+
}
|
|
892
|
+
catch {
|
|
893
|
+
throw new UsageError('--args must be JSON');
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
const r = await o.pluginRun(ref.split(' ')[0], args);
|
|
897
|
+
return out(JSON.stringify(r, null, 2));
|
|
898
|
+
}
|
|
899
|
+
const { plugins, errors } = await o.plugins();
|
|
900
|
+
const { pluginDir } = await import('../plugins.js');
|
|
901
|
+
emit(a, { dir: pluginDir(), plugins: plugins.map((p) => ({ name: p.name, description: p.description, tools: p.tools.map((t) => t.name) })), errors }, () => {
|
|
902
|
+
out(`${c.bold('Plugins')} ${c.dim(pluginDir())}`);
|
|
903
|
+
if (!plugins.length)
|
|
904
|
+
out(c.dim(' none installed. Copy examples/plugins/show-hn.mjs into that folder to try one.'));
|
|
905
|
+
for (const p of plugins)
|
|
906
|
+
out(` ${c.bold(p.name)} ${c.dim(p.description ?? '')}\n tools: ${p.tools.map((t) => `${p.name}.${t.name}`).join(', ')}`);
|
|
907
|
+
for (const e of errors)
|
|
908
|
+
out(c.red(` failed: ${e}`));
|
|
909
|
+
});
|
|
910
|
+
},
|
|
911
|
+
async calibrate(o, a) {
|
|
912
|
+
const { calibrate } = await import('../modules/calibrate.js');
|
|
913
|
+
const r = await calibrate(o.ctx, { days: Number(a.flags.days ?? 10) || 10, onDay: json(a) ? () => { } : (d) => out(c.dim(` replaying ${d}…`)) });
|
|
914
|
+
emit(a, r, () => {
|
|
915
|
+
const d = r.result;
|
|
916
|
+
out(c.bold(`\nCalibration · ${d.days} days replayed · ${d.samples} radar items · ${d.materialized} became news within 3 days`));
|
|
917
|
+
out(c.dim(' threshold flagged became news precision recall F1'));
|
|
918
|
+
for (const row of d.rows)
|
|
919
|
+
out(` ${String(row.threshold).padStart(9)} ${String(row.flagged).padStart(7)} ${String(row.hits).padStart(11)} ${String(row.precision ?? '-').padStart(9)} ${String(row.recall ?? '-').padStart(6)} ${String(row.f1 ?? '-').padStart(4)}${d.best?.threshold === row.threshold ? c.green(' <- chosen') : ''}`);
|
|
920
|
+
out(c.bold('\nBy source'));
|
|
921
|
+
for (const [k, v] of Object.entries(d.bySource).sort((x, y) => y[1].rate - x[1].rate))
|
|
922
|
+
out(` ${k.padEnd(14)} ${String(v.samples).padStart(4)} items · ${Math.round(v.rate * 100)}% became news`);
|
|
923
|
+
out(c.dim(`\nThe live radar now uses threshold ${d.best && d.best.flagged >= 10 ? d.best.threshold : '55 (not enough examples yet)'}.`));
|
|
924
|
+
});
|
|
925
|
+
},
|
|
926
|
+
async sanctions(o, a) {
|
|
927
|
+
const r = await o.sanctions(need(a, 1, 'wallet, IMO number or exact name'));
|
|
928
|
+
emit(a, r, () => {
|
|
929
|
+
const d = r.result;
|
|
930
|
+
const col = d.verdict === 'SANCTIONED' || d.verdict === 'LISTED_ELSEWHERE' ? c.red : d.verdict === 'EXPOSED' || d.verdict === 'PEP' ? c.yellow : d.verdict === 'CLEAR' ? c.green : c.gray;
|
|
931
|
+
out(`${c.bold(d.query)} · ${col(c.bold(d.verdict))} ${c.dim(`(OFAC SDN, ${d.listSize.toLocaleString('en-US')} entries${d.listDate ? `, list fetched ${d.listDate.slice(0, 10)}` : ''})`)}`);
|
|
932
|
+
for (const h of d.hits)
|
|
933
|
+
out(` ${c.red(h.kind.padEnd(12))} ${h.entry.name} [${h.entry.program}]${h.detail ? c.dim(` ${h.detail}`) : ''}`);
|
|
934
|
+
if (d.worldwide.length) {
|
|
935
|
+
out(c.bold('\n Worldwide (OpenSanctions)'));
|
|
936
|
+
for (const w of d.worldwide)
|
|
937
|
+
out(` ${w.score >= 0.9 ? c.red(w.score.toFixed(2)) : c.yellow(w.score.toFixed(2))} ${w.name} ${c.dim(`${w.schema}${w.countries.length ? ` · ${w.countries.join(',')}` : ''} · ${w.datasets} lists`)} ${w.topics.join(', ')}`);
|
|
938
|
+
const rel = d.worldwide[0]?.related ?? [];
|
|
939
|
+
if (rel.length) {
|
|
940
|
+
out(c.bold(`\n Connected to ${d.worldwide[0].name}`) + c.dim(` (${rel.filter((x) => x.sanctioned).length} of ${rel.length} sanctioned)`));
|
|
941
|
+
for (const x of rel.slice(0, 15))
|
|
942
|
+
out(` ${x.relation.padEnd(12)} ${x.sanctioned ? c.red(trunc(x.name, 60)) : trunc(x.name, 60)} ${c.dim(`${x.schema}${x.detail ? ` · ${x.detail}` : ''}`)}`);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
if (d.verdict === 'CLEAR')
|
|
946
|
+
out(c.dim(' OFAC: exact matches only; worldwide: matches scoring 0.7+. Not legal advice.'));
|
|
947
|
+
printSources(r);
|
|
948
|
+
});
|
|
949
|
+
},
|
|
950
|
+
async markets(o, a) {
|
|
951
|
+
if (!json(a))
|
|
952
|
+
out(c.dim('matching Polymarket with Kalshi and Manifold (an LLM confirms each pair)…'));
|
|
953
|
+
const r = await o.markets(a.flags.gap ? { minGapPp: Number(a.flags.gap) } : {});
|
|
954
|
+
emit(a, r, () => {
|
|
955
|
+
const d = r.result;
|
|
956
|
+
out(c.bold(`Market cross-check · ${d.checked} Polymarket markets · ${d.comparisons.length} matched · ${d.disagreements.length} disagreement(s)`));
|
|
957
|
+
for (const x of d.comparisons.slice(0, 15)) {
|
|
958
|
+
const gap = x.gapPp >= 15 ? c.red(`${x.gapPp}pp`) : `${x.gapPp}pp`;
|
|
959
|
+
out(` ${gap.padStart(6)} PM ${String(Math.round(x.polymarket.probability * 100)).padStart(3)}% vs ${x.other.venue} ${String(Math.round(x.other.probability * 100)).padStart(3)}% ${trunc(x.polymarket.question, 70)}${x.verified === 'unverified' ? c.dim(' (unverified match)') : ''}`);
|
|
960
|
+
out(c.dim(` ${x.other.venue}: ${trunc(x.other.question, 90)} ${x.other.url}`));
|
|
961
|
+
}
|
|
962
|
+
if (!d.comparisons.length)
|
|
963
|
+
out(c.dim(' no market on Kalshi or Manifold asks exactly the same question as the top Polymarket markets right now'));
|
|
964
|
+
printSources(r);
|
|
965
|
+
});
|
|
966
|
+
},
|
|
967
|
+
async launches(o, a) {
|
|
968
|
+
const company = need(a, 1, 'company');
|
|
969
|
+
const r = await o.launches(company, { ...(typeof a.flags.domain === 'string' ? { domain: a.flags.domain } : {}), ...(typeof a.flags.org === 'string' ? { org: a.flags.org } : {}), ...(a.flags.days ? { days: Number(a.flags.days) } : {}) });
|
|
970
|
+
emit(a, r, () => {
|
|
971
|
+
const d = r.result;
|
|
972
|
+
out(c.bold(`Launch radar · ${company} · ${d.items.length} item(s) in ${d.windowDays} days`) + (d.domain ? '' : c.dim(' (add --domain to include hostnames, pages and repos)')));
|
|
973
|
+
for (const i of d.items.slice(0, 30))
|
|
974
|
+
out(` ${c.gray(i.date.slice(0, 10))} ${(i.kind === 'app-update' ? c.dim : c.cyan)(i.kind.padEnd(10))} ${trunc(i.title, 70)}${i.detail ? c.dim(` ${trunc(i.detail, 60)}`) : ''}`);
|
|
975
|
+
printSources(r);
|
|
976
|
+
});
|
|
977
|
+
},
|
|
978
|
+
async rewind(o, a) {
|
|
979
|
+
const r = await o.rewind(need(a, 1, 'date (YYYY-MM-DD)'));
|
|
980
|
+
emit(a, r, () => {
|
|
981
|
+
const d = r.result;
|
|
982
|
+
out(c.bold(`Time machine · ${d.date}`));
|
|
983
|
+
for (const f of d.fused.filter((x) => x.sources.some((s) => s !== 'guardian')).slice(0, 12))
|
|
984
|
+
out(` [${score(f.score)}] ${c.bold(trunc(f.title, 80))} ${c.gray(f.sources.join(' + '))}`);
|
|
985
|
+
if (d.headlines.length) {
|
|
986
|
+
out(c.bold('\nThat day in the Guardian'));
|
|
987
|
+
for (const h of d.headlines.slice(0, 8))
|
|
988
|
+
out(` ${c.gray(h.time.slice(11, 16))} ${trunc(h.title, 100)}`);
|
|
989
|
+
}
|
|
990
|
+
out(c.dim(`\nOculon recorded ${d.oculonSignals.length} signal(s) that day.`));
|
|
991
|
+
printSources(r);
|
|
992
|
+
});
|
|
993
|
+
},
|
|
994
|
+
async fence(o, a) {
|
|
995
|
+
const sub = a.pos[1];
|
|
996
|
+
if (sub === 'add') {
|
|
997
|
+
const name = a.pos[2];
|
|
998
|
+
if (!name)
|
|
999
|
+
throw new UsageError('usage: oculon fence add <name> <place> [--radius 100] [--kinds air,sea,quake,events] | oculon fence add <name> --box s,w,n,e');
|
|
1000
|
+
const kinds = typeof a.flags.kinds === 'string' ? a.flags.kinds.split(',') : undefined;
|
|
1001
|
+
let f;
|
|
1002
|
+
if (typeof a.flags.box === 'string') {
|
|
1003
|
+
const b = a.flags.box.split(',').map(Number);
|
|
1004
|
+
f = o.fenceAdd(name, b, kinds);
|
|
1005
|
+
}
|
|
1006
|
+
else
|
|
1007
|
+
f = await o.fenceAddAround(name, need(a, 3, 'place'), Number(a.flags.radius ?? 100) || 100, kinds);
|
|
1008
|
+
return emit(a, f, () => out(`${c.green('fence')} #${f.id} ${c.bold(f.name)} [${f.south}, ${f.west}] → [${f.north}, ${f.east}] watching ${f.kinds.join(', ')}\n${c.dim(' the first check records a baseline; later checks report what is new inside')}`));
|
|
1009
|
+
}
|
|
1010
|
+
if (sub === 'rm') {
|
|
1011
|
+
const ok = o.fenceRemove(Number(a.pos[2]));
|
|
1012
|
+
return emit(a, { removed: ok }, () => out(ok ? `removed fence #${a.pos[2]}` : `no fence #${a.pos[2]}`));
|
|
1013
|
+
}
|
|
1014
|
+
if (sub === 'check') {
|
|
1015
|
+
if (!json(a))
|
|
1016
|
+
out(c.dim('checking fences (aircraft, vessels, quakes, events)…'));
|
|
1017
|
+
const r = await o.fenceCheck();
|
|
1018
|
+
return emit(a, r, () => {
|
|
1019
|
+
if (!r.checks.length)
|
|
1020
|
+
return out('No fences. Add one: oculon fence add hormuz "Strait of Hormuz" --radius 150');
|
|
1021
|
+
for (const x of r.checks) {
|
|
1022
|
+
const counts = c.dim(`(${x.counts.milAircraft} mil aircraft, ${x.counts.milVessels} mil vessels, ${x.counts.quakes} quakes, ${x.counts.events} events now)`);
|
|
1023
|
+
out(` #${x.fence.id} ${c.bold(x.fence.name)} ${x.baseline ? c.dim('baseline recorded') : x.changes.length ? c.yellow(`${x.changes.length} new`) : c.dim('nothing new')} ${counts}`);
|
|
1024
|
+
for (const ch of x.changes)
|
|
1025
|
+
out(` - ${ch}`);
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
const list = o.fenceList();
|
|
1030
|
+
emit(a, list, () => {
|
|
1031
|
+
if (!list.length)
|
|
1032
|
+
return out('No fences. Add one: oculon fence add hormuz "Strait of Hormuz" --radius 150');
|
|
1033
|
+
for (const f of list)
|
|
1034
|
+
out(` #${f.id} ${c.bold(f.name.padEnd(16))} [${f.south}, ${f.west}] → [${f.north}, ${f.east}] ${f.kinds.join(',')} ${c.dim(f.lastRun ? `checked ${f.lastRun.slice(0, 16)}Z` : 'not checked yet')}`);
|
|
1035
|
+
});
|
|
1036
|
+
},
|
|
1037
|
+
async scoops(o, a) {
|
|
1038
|
+
if (a.pos[1] === 'check') {
|
|
1039
|
+
if (!json(a))
|
|
1040
|
+
out(c.dim('checking strong signals against Guardian, NYT and GNews…'));
|
|
1041
|
+
const r = await o.scoopsCheck(Number(a.flags.max ?? 8) || 8);
|
|
1042
|
+
if (json(a))
|
|
1043
|
+
return out(JSON.stringify(r, null, 2));
|
|
1044
|
+
for (const s of r)
|
|
1045
|
+
out(` ${s.leadHours === null ? c.dim('no coverage yet') : s.leadHours > 0 ? c.green(`Oculon +${s.leadHours}h`) : c.yellow(`media first ${s.leadHours}h`)} ${trunc(s.subject, 70)}${s.mediaSource ? c.dim(` (${s.mediaSource})`) : ''}`);
|
|
1046
|
+
if (!r.length)
|
|
1047
|
+
out(c.dim(' nothing due: signals are checked once they are 6-72 hours old'));
|
|
1048
|
+
}
|
|
1049
|
+
const b = o.scoops();
|
|
1050
|
+
emit(a, b, () => {
|
|
1051
|
+
out(c.bold(`\nFirst to Know · ${b.checked} signals checked · ${b.covered} covered by media`));
|
|
1052
|
+
if (b.covered)
|
|
1053
|
+
out(` Oculon first ${c.green(String(b.oculonFirst))} · media first ${c.yellow(String(b.mediaFirst))} · median lead ${b.medianLeadHours !== null ? `${b.medianLeadHours > 0 ? '+' : ''}${b.medianLeadHours}h` : 'n/a'}`);
|
|
1054
|
+
for (const s of b.best.slice(0, 8))
|
|
1055
|
+
out(` ${c.green(`+${s.leadHours}h`.padStart(8))} ${trunc(s.subject, 70)} ${c.dim(`${s.mediaSource ?? ''} ${s.mediaUrl ?? ''}`)}`);
|
|
1056
|
+
if (b.pending.length)
|
|
1057
|
+
out(c.dim(` ${b.pending.length} signal(s) still without media coverage`));
|
|
1058
|
+
});
|
|
1059
|
+
},
|
|
1060
|
+
async case(o, a) {
|
|
1061
|
+
const sub = a.pos[1];
|
|
1062
|
+
if (sub === 'new' || sub === 'rerun') {
|
|
1063
|
+
const input = sub === 'new' ? { question: need(a, 2, 'question') } : { id: Number(a.pos[2]) };
|
|
1064
|
+
if (!json(a))
|
|
1065
|
+
out(c.dim(sub === 'new' ? `opening case: ${input.question}` : `re-investigating case #${a.pos[2]}`));
|
|
1066
|
+
const r = await o.caseInvestigate(input, { onStep: json(a) ? () => { } : (s) => out(c.dim(` → ${trunc(s, 120)}`)) });
|
|
1067
|
+
return emit(a, r, () => {
|
|
1068
|
+
out(`\n${r.case.markdown ?? ''}`);
|
|
1069
|
+
if (r.added.length)
|
|
1070
|
+
out(c.yellow(`\n${r.added.length} new finding(s) since the previous run`));
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
if (sub === 'watch') {
|
|
1074
|
+
const ok = await o.caseWatch(Number(a.pos[2]), a.pos[3] !== 'off');
|
|
1075
|
+
return emit(a, { ok }, () => out(ok ? `case #${a.pos[2]} watch ${a.pos[3] === 'off' ? 'off' : 'on (re-investigated daily, new findings become signals)'}` : `no case #${a.pos[2]}`));
|
|
1076
|
+
}
|
|
1077
|
+
if (sub === 'show') {
|
|
1078
|
+
const k = await o.caseGet(Number(a.pos[2]));
|
|
1079
|
+
return emit(a, k, () => out(k?.markdown ?? `no case #${a.pos[2]}`));
|
|
1080
|
+
}
|
|
1081
|
+
const list = await o.caseList();
|
|
1082
|
+
emit(a, list, () => {
|
|
1083
|
+
if (!list.length)
|
|
1084
|
+
return out('No cases yet. Open one: oculon case new "who is behind token 0x..?"');
|
|
1085
|
+
for (const k of list)
|
|
1086
|
+
out(` #${String(k.id).padEnd(3)} ${trunc(k.question, 70).padEnd(70)} ${c.dim(`${k.report?.confidence ?? '-'} · ${k.report?.findings.length ?? 0} findings · run ${k.runs}`)}${k.watch ? c.green(' watching') : ''}`);
|
|
1087
|
+
});
|
|
1088
|
+
},
|
|
1089
|
+
async watch(o, a) {
|
|
1090
|
+
const sub = a.pos[1];
|
|
1091
|
+
if (sub === 'add') {
|
|
1092
|
+
const kind = a.pos[2];
|
|
1093
|
+
const target = a.pos.slice(3).join(' ').trim();
|
|
1094
|
+
if (!kind || !target)
|
|
1095
|
+
throw new UsageError('usage: oculon watch add <kind> <target> [--label name] (or describe it: oculon monitor "...")');
|
|
1096
|
+
const item = o.watchAdd(kind, target, typeof a.flags.label === 'string' ? a.flags.label : undefined);
|
|
1097
|
+
return emit(a, item, () => out(`${c.green('watching')} #${item.id} ${item.kind} ${c.bold(item.target)}${item.label ? c.dim(` (${item.label})`) : ''}\n${c.dim(' the first `oculon watch run` records a baseline; later runs report changes')}`));
|
|
1098
|
+
}
|
|
1099
|
+
if (sub === 'rm' || sub === 'remove') {
|
|
1100
|
+
const id = Number(a.pos[2]);
|
|
1101
|
+
const ok = Number.isInteger(id) && o.watchRemove(id);
|
|
1102
|
+
return emit(a, { removed: ok }, () => out(ok ? `removed #${id}` : `no watch item #${a.pos[2]}`));
|
|
1103
|
+
}
|
|
1104
|
+
if (sub === 'run') {
|
|
1105
|
+
const r = await o.watchRun();
|
|
1106
|
+
return emit(a, r, () => {
|
|
1107
|
+
if (!r.runs.length)
|
|
1108
|
+
return out('Watchlist is empty. Add something: oculon watch add company Nvidia');
|
|
1109
|
+
for (const x of r.runs) {
|
|
1110
|
+
const head = ` #${x.item.id} ${x.item.kind.padEnd(8)} ${c.bold(x.item.label ?? x.item.target)}`;
|
|
1111
|
+
if (x.error)
|
|
1112
|
+
out(`${head} ${c.red(`error: ${trunc(x.error, 100)}`)}`);
|
|
1113
|
+
else if (x.baseline)
|
|
1114
|
+
out(`${head} ${c.dim('baseline recorded')}`);
|
|
1115
|
+
else if (!x.changes.length)
|
|
1116
|
+
out(`${head} ${c.dim('no change')}`);
|
|
1117
|
+
else {
|
|
1118
|
+
out(`${head} ${c.yellow(`${x.changes.length} change(s)`)}`);
|
|
1119
|
+
for (const ch of x.changes)
|
|
1120
|
+
out(` - ${trunc(ch, 140)}`);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
const list = o.watchList();
|
|
1126
|
+
emit(a, list, () => {
|
|
1127
|
+
if (!list.length)
|
|
1128
|
+
return out('Watchlist is empty. Add something: oculon watch add company Nvidia');
|
|
1129
|
+
for (const w of list)
|
|
1130
|
+
out(` #${String(w.id).padEnd(3)} ${w.kind.padEnd(8)} ${c.bold(w.target)}${w.label ? c.dim(` (${w.label})`) : ''} ${c.dim(w.lastRun ? `last run ${w.lastRun.slice(0, 16)}Z` : 'not run yet')}`);
|
|
1131
|
+
});
|
|
1132
|
+
},
|
|
1133
|
+
async gc(o, a) {
|
|
1134
|
+
const days = Number(a.flags.days ?? 14) || 14;
|
|
1135
|
+
const r = o.ctx.store.pruneCache(days, true);
|
|
1136
|
+
emit(a, r, () => out(`Removed ${r.removed} cached API response(s) older than ${days} days and compacted the database.`));
|
|
1137
|
+
},
|
|
1138
|
+
async tour(o, a) {
|
|
1139
|
+
// A quick look at what this install already knows, using stored data only (no API calls), then where to go next.
|
|
1140
|
+
const db = o.ctx.store.db;
|
|
1141
|
+
const count = (sql) => Number(db.prepare(sql).get().n);
|
|
1142
|
+
const stats = {
|
|
1143
|
+
signals: count('SELECT count(*) n FROM signals'),
|
|
1144
|
+
entities: count('SELECT count(*) n FROM entities'),
|
|
1145
|
+
links: count('SELECT count(*) n FROM edges'),
|
|
1146
|
+
watch: o.watchList().length,
|
|
1147
|
+
cases: count('SELECT count(*) n FROM cases'),
|
|
1148
|
+
forecasts: count('SELECT count(*) n FROM predictions'),
|
|
1149
|
+
};
|
|
1150
|
+
const top = o.signals(200).sort((x, y) => y.score - x.score).slice(0, 3);
|
|
1151
|
+
const pair = db
|
|
1152
|
+
.prepare("SELECT a.name AS a, b.name AS b FROM edges e JOIN entities a ON a.id = e.src JOIN entities b ON b.id = e.dst WHERE a.kind IN ('company','org') AND b.kind IN ('topic','repo','domain') LIMIT 1")
|
|
1153
|
+
.get();
|
|
1154
|
+
emit(a, { stats, top }, () => {
|
|
1155
|
+
out(`${c.bold('Oculon tour')} ${c.dim(`v${VERSION} · data in ${oculonHome()}`)}`);
|
|
1156
|
+
out(`\n ${stats.signals} signals · ${stats.entities} entities with ${stats.links} links · ${stats.watch} watched · ${stats.cases} cases · ${stats.forecasts} forecasts`);
|
|
1157
|
+
if (!stats.signals) {
|
|
1158
|
+
out(`\n ${c.bold('Start here')}`);
|
|
1159
|
+
out(` oculon doctor check keys and sources`);
|
|
1160
|
+
out(` oculon radar first scan of what the world is suddenly watching`);
|
|
1161
|
+
out(` oculon dossier Nvidia a full dossier on one company`);
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
out(`\n ${c.bold('Strongest stored signals')}`);
|
|
1165
|
+
printSignals(top, 3);
|
|
1166
|
+
out(`\n ${c.bold('Try next')}`);
|
|
1167
|
+
const tips = [
|
|
1168
|
+
['oculon ask "What changed for Nvidia this week?"', 'the agent answers using every tool'],
|
|
1169
|
+
['oculon calendar 7', "the week's earnings, macro releases and closing markets"],
|
|
1170
|
+
[pair ? `oculon connect "${pair.a}" to "${pair.b}"` : 'oculon connect <A> to <B>', 'how two things link in your graph'],
|
|
1171
|
+
['oculon case new "<question>"', 'a deep investigation with sourced findings'],
|
|
1172
|
+
['oculon watch add company <name>', 'get told when something changes'],
|
|
1173
|
+
['oculon serve --watch 15 --live', 'dashboard, schedule and live streams together'],
|
|
1174
|
+
];
|
|
1175
|
+
for (const [cmd, why] of tips)
|
|
1176
|
+
out(` ${c.cyan(cmd.padEnd(52))} ${c.dim(why)}`);
|
|
1177
|
+
});
|
|
1178
|
+
},
|
|
1179
|
+
async sentinel(o, a) {
|
|
1180
|
+
const r = await o.sentinel(need(a, 1, 'place'), {
|
|
1181
|
+
...(typeof a.flags.date === 'string' ? { date: a.flags.date } : {}),
|
|
1182
|
+
...(typeof a.flags.compare === 'string' ? { compareTo: a.flags.compare } : {}),
|
|
1183
|
+
...(a.flags.days ? { days: Number(a.flags.days) } : {}),
|
|
1184
|
+
kind: a.flags.radar ? 'radar' : 'optical',
|
|
1185
|
+
});
|
|
1186
|
+
const shots = r.result.shots.map((s, i) => {
|
|
1187
|
+
let file = s.file;
|
|
1188
|
+
if (file && typeof a.flags.out === 'string') {
|
|
1189
|
+
const dest = resolve(i === 0 ? a.flags.out : a.flags.out.replace(/(\.png)?$/i, '-before.png'));
|
|
1190
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
1191
|
+
copyFileSync(file, dest);
|
|
1192
|
+
file = dest;
|
|
1193
|
+
}
|
|
1194
|
+
return { ...s, file };
|
|
1195
|
+
});
|
|
1196
|
+
emit(a, { ...r, result: { shots } }, () => {
|
|
1197
|
+
out(c.bold(`${shots[0].place.name}`) + c.dim(` Sentinel-${shots[0].kind === 'radar' ? '1 radar' : '2 optical, 10 m'}`));
|
|
1198
|
+
for (const s of shots)
|
|
1199
|
+
out(s.file ? ` ${s.from} to ${s.to} saved ${s.file}` : c.yellow(` ${s.from} to ${s.to} no image (${r.provenance.at(-1)?.note ?? 'no data'})`));
|
|
1200
|
+
printSources(r);
|
|
1201
|
+
});
|
|
1202
|
+
},
|
|
1203
|
+
async fires(o, a) {
|
|
1204
|
+
const r = await o.fires(need(a, 1, 'place'), Number(a.flags.days ?? 2) || 2);
|
|
1205
|
+
emit(a, r, () => {
|
|
1206
|
+
const f = r.result;
|
|
1207
|
+
if (!f.place)
|
|
1208
|
+
return out(c.yellow('place not found'));
|
|
1209
|
+
out(c.bold(`Fires near ${f.place.name.split(',')[0]} · last ${f.days} day(s) · ${f.hotspots.length} hotspots`) + c.dim(` ${f.high} high confidence, ${f.totalFrp} MW total`));
|
|
1210
|
+
for (const cl of f.clusters.slice(0, 15))
|
|
1211
|
+
out(` ${String(cl.count).padStart(4)} hotspots ${String(cl.frp).padStart(6)} MW ${cl.lat.toFixed(3)}, ${cl.lon.toFixed(3)} ${c.gray(cl.last.slice(0, 16).replace('T', ' '))}`);
|
|
1212
|
+
if (!f.hotspots.length)
|
|
1213
|
+
out(c.dim(' none detected'));
|
|
1214
|
+
printSignals(r.signals);
|
|
1215
|
+
printSources(r);
|
|
1216
|
+
});
|
|
1217
|
+
},
|
|
1218
|
+
async darkships(o, a) {
|
|
1219
|
+
const r = await o.darkShips(need(a, 1, 'place'), Number(a.flags.days ?? 30) || 30);
|
|
1220
|
+
emit(a, r, () => {
|
|
1221
|
+
const d = r.result;
|
|
1222
|
+
if (!d.place)
|
|
1223
|
+
return out(c.yellow('place not found'));
|
|
1224
|
+
out(c.bold(`AIS switched off near ${d.place.name.split(',')[0]} · last ${d.days} days · ${d.total} vessel gaps`));
|
|
1225
|
+
for (const g of d.gaps.slice(0, 25))
|
|
1226
|
+
out(` ${c.gray(g.on.slice(0, 10))} ${c.bold(trunc(g.vessel, 28).padEnd(28))} ${(g.flag ?? '?').padEnd(4)} ${c.dim((g.type ?? '').padEnd(10))} dark ${String(g.hours).padStart(5)} h, moved ${g.km} km`);
|
|
1227
|
+
if (!d.total)
|
|
1228
|
+
out(c.dim(' none in Global Fishing Watch data (its gap model covers fishing and carrier vessels best)'));
|
|
1229
|
+
const vn = (v) => `${v.name}${v.flag ? ` (${v.flag})` : ''}${v.sanctioned ? c.red(' OFAC') : ''}`;
|
|
1230
|
+
if (d.encounters?.length) {
|
|
1231
|
+
out(`\n ${c.bold(`Ship-to-ship encounters · ${d.encounters.length}`)}${c.dim(' (possible transfers at sea)')}`);
|
|
1232
|
+
for (const e of d.encounters.slice(0, 12))
|
|
1233
|
+
out(` ${c.gray(e.start.slice(0, 10))} ${vn(e.a)} × ${vn(e.b)} ${c.dim(`${e.hours} h${e.kind ? `, ${e.kind}` : ''}`)}${e.gapLinked ? c.yellow(' one went dark') : ''}${e.potentialRisk ? c.yellow(' unauthorized') : ''}`);
|
|
1234
|
+
}
|
|
1235
|
+
if (d.loitering?.length)
|
|
1236
|
+
out(`\n ${c.bold(`Loitering · ${d.loitering.length}`)} ${c.dim(`${d.loitering.filter((x) => x.linked).length} by vessels that also went dark or met another ship`)}`);
|
|
1237
|
+
if (d.portVisits?.length) {
|
|
1238
|
+
out(`\n ${c.bold('Where those vessels went')}`);
|
|
1239
|
+
for (const p of d.portVisits.slice(0, 8))
|
|
1240
|
+
out(` ${c.gray(p.start.slice(0, 10))} ${vn(p.vessel)} → ${p.port ?? '?'}${p.portFlag ? ` (${p.portFlag})` : ''}`);
|
|
1241
|
+
}
|
|
1242
|
+
printSignals(r.signals);
|
|
1243
|
+
printSources(r);
|
|
1244
|
+
});
|
|
1245
|
+
},
|
|
1246
|
+
async vessel(o, a) {
|
|
1247
|
+
const r = await o.vessel(need(a, 1, 'vessel name, MMSI or IMO'));
|
|
1248
|
+
emit(a, r, () => {
|
|
1249
|
+
if (!r.result.length)
|
|
1250
|
+
return out('No vessel found.');
|
|
1251
|
+
for (const v of r.result) {
|
|
1252
|
+
out(`${c.bold(v.name ?? '?')} IMO ${v.imo ?? '?'} · MMSI ${v.mmsi ?? '?'} · flag ${v.flag ?? '?'} · ${v.types.join('/') || '?'}${v.sanctions ? ` OFAC ${v.sanctions === 'CLEAR' ? c.green(v.sanctions) : c.red(v.sanctions)}` : ''}`);
|
|
1253
|
+
out(c.dim(` AIS ${(v.firstSeen ?? '?').slice(0, 10)} to ${(v.lastSeen ?? '?').slice(0, 10)}${v.callsign ? ` · callsign ${v.callsign}` : ''}`));
|
|
1254
|
+
for (const ow of v.owners.slice(0, 4))
|
|
1255
|
+
out(` owner ${ow.name}${ow.flag ? ` (${ow.flag})` : ''}${ow.from ? c.dim(` ${ow.from.slice(0, 10)} to ${(ow.to ?? 'now').slice(0, 10)}`) : ''}`);
|
|
1256
|
+
if (v.earlierNames.length)
|
|
1257
|
+
out(` earlier names: ${v.earlierNames.join(', ')}`);
|
|
1258
|
+
if (v.history) {
|
|
1259
|
+
const h = v.history;
|
|
1260
|
+
out(` last ${h.days} days: ${h.gaps} AIS gaps, ${h.encounters} encounters, ${h.loitering} loitering, ${h.portVisits} port visits`);
|
|
1261
|
+
if (h.ports.length)
|
|
1262
|
+
out(` ports ${h.ports.slice(0, 6).map((p) => `${p.port}${p.flag ? ` (${p.flag})` : ''} ×${p.visits}`).join(', ')}`);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
printSources(r);
|
|
1266
|
+
});
|
|
1267
|
+
},
|
|
1268
|
+
async cloud(o, a) {
|
|
1269
|
+
const r = await o.cloud();
|
|
1270
|
+
emit(a, r, () => {
|
|
1271
|
+
const st = r.result;
|
|
1272
|
+
out(c.bold(`Service status · ${st.checked} platforms · ${st.incidents.length} open incidents`));
|
|
1273
|
+
for (const i of st.incidents.slice(0, 25)) {
|
|
1274
|
+
const col = i.impact === 'critical' || i.impact === 'major' ? c.red : i.impact === 'minor' ? c.yellow : c.gray;
|
|
1275
|
+
out(` ${col(i.impact.padEnd(8))} ${c.bold(i.service.padEnd(13))} ${trunc(i.title, 80)} ${c.dim(i.updated.slice(0, 16).replace('T', ' '))}`);
|
|
1276
|
+
}
|
|
1277
|
+
if (st.degraded.length)
|
|
1278
|
+
out(`\n ${c.dim('degraded:')} ${st.degraded.map((d) => `${d.service} (${d.description || d.indicator})`).join(', ')}`);
|
|
1279
|
+
if (!st.incidents.length && !st.degraded.length)
|
|
1280
|
+
out(c.green(' all checked platforms report no open incidents'));
|
|
1281
|
+
printSignals(r.signals);
|
|
1282
|
+
printSources(r);
|
|
1283
|
+
});
|
|
1284
|
+
},
|
|
1285
|
+
async bgp(o, a) {
|
|
1286
|
+
const r = await o.bgp(a.pos[1] ?? 'world', Number(a.flags.days ?? 2) || 2);
|
|
1287
|
+
emit(a, r, () => {
|
|
1288
|
+
const { country, asn, ip, incidents } = r.result;
|
|
1289
|
+
const printIncidents = () => {
|
|
1290
|
+
if (!incidents)
|
|
1291
|
+
return;
|
|
1292
|
+
if (incidents.attacks) {
|
|
1293
|
+
const fmt = (l) => l.slice(0, 6).map((x) => `${x.name} ${Math.round(x.share * 100)}%`).join(', ');
|
|
1294
|
+
out(`\n ${c.bold('DDoS targets, last 24h')} ${c.dim('(share of attack traffic Cloudflare saw)')}`);
|
|
1295
|
+
out(` application layer: ${fmt(incidents.attacks.layer7)}`);
|
|
1296
|
+
out(` network layer: ${fmt(incidents.attacks.layer3)}`);
|
|
1297
|
+
}
|
|
1298
|
+
const hj = incidents.hijacks.filter((h) => h.confidence >= 9 && !h.sameOrg).slice(0, 10);
|
|
1299
|
+
out(`\n ${c.bold(`BGP hijacks · ${incidents.hijacks.length} detected`)}${c.dim(', showing confidence 9+ between different organisations')}`);
|
|
1300
|
+
for (const h of hj)
|
|
1301
|
+
out(` ${h.ongoing ? c.red('ongoing') : c.dim('ended ')} ${c.gray(h.start.slice(0, 16).replace('T', ' '))} ${trunc(`${h.hijacker} took ${h.prefixes.slice(0, 2).join(', ')}${h.prefixes.length > 2 ? ` +${h.prefixes.length - 2}` : ''} from ${h.victims.slice(0, 2).join(', ') || '?'}`, 110)} ${c.dim(`${h.peers} peers`)}`);
|
|
1302
|
+
if (!hj.length)
|
|
1303
|
+
out(c.dim(' none with high confidence'));
|
|
1304
|
+
out(`\n ${c.bold(`Route leaks · ${incidents.leaks.length}`)}`);
|
|
1305
|
+
for (const l of incidents.leaks.slice(0, 8))
|
|
1306
|
+
out(` ${l.finished ? c.dim('ended ') : c.red('ongoing')} ${c.gray(l.start.slice(0, 16).replace('T', ' '))} ${trunc(`${l.leaker}: ${l.prefixes} prefixes from ${l.origins} networks via ${l.path.join(' > ')}`, 110)}`);
|
|
1307
|
+
};
|
|
1308
|
+
if (ip) {
|
|
1309
|
+
out(`${c.bold(ip.ip)} ${c.dim(ip.prefix ?? '')} ${ip.announced ? c.green('announced') : c.red('not announced')}`);
|
|
1310
|
+
out(` network ${ip.origins.map((x) => `${x.name} (${x.asn})`).join(', ') || '?'}`);
|
|
1311
|
+
out(` RPKI ${ip.rpki === 'valid' ? c.green('valid') : ip.rpki === 'invalid' ? c.red('INVALID (possible hijack or misconfiguration)') : c.dim(ip.rpki ?? 'unknown')}`);
|
|
1312
|
+
out(` location ${[ip.city, ip.country].filter(Boolean).join(', ') || '?'} · registry ${ip.registry ?? '?'}`);
|
|
1313
|
+
if (ip.abuse.length)
|
|
1314
|
+
out(` abuse contact ${ip.abuse.join(', ')}`);
|
|
1315
|
+
}
|
|
1316
|
+
else if (asn) {
|
|
1317
|
+
out(`${c.bold(asn.asn)} ${asn.name ?? ''}`);
|
|
1318
|
+
if (asn.visibilityV4 === null)
|
|
1319
|
+
out(c.dim(' RIPEstat routing status timed out (very large networks can take minutes)'));
|
|
1320
|
+
else {
|
|
1321
|
+
out(` visible to ${Math.round((asn.visibilityV4 ?? 0) * 100)}% of RIPE peers (IPv4), ${Math.round((asn.visibilityV6 ?? 0) * 100)}% (IPv6)`);
|
|
1322
|
+
out(` announces ${asn.prefixesV4} IPv4 and ${asn.prefixesV6} IPv6 prefixes · ${asn.neighbours} neighbours`);
|
|
1323
|
+
}
|
|
1324
|
+
printIncidents();
|
|
1325
|
+
}
|
|
1326
|
+
else if (!country && incidents) {
|
|
1327
|
+
out(c.bold('Global routing incidents'));
|
|
1328
|
+
printIncidents();
|
|
1329
|
+
}
|
|
1330
|
+
else if (country?.latest && country.baseline) {
|
|
1331
|
+
const ch = country.v4Change ?? 0;
|
|
1332
|
+
out(`${c.bold(country.country)} routing · ${country.latest.v4} IPv4 prefixes visible now vs ${country.baseline.v4} usual ${ch <= -0.05 ? c.red(`(${(ch * 100).toFixed(1)}%)`) : c.dim(`(${(ch * 100).toFixed(1)}%)`)}`);
|
|
1333
|
+
const max = Math.max(...country.series.map((s) => s.v4));
|
|
1334
|
+
const min = Math.min(...country.series.map((s) => s.v4));
|
|
1335
|
+
const bars = '▁▂▃▄▅▆▇█';
|
|
1336
|
+
out(` ${country.series.map((s) => bars[max === min ? 7 : Math.round(((s.v4 - min) / (max - min)) * 7)]).join('')} ${c.dim(`${min}–${max} over ${country.series.length} h`)}`);
|
|
1337
|
+
printIncidents();
|
|
1338
|
+
}
|
|
1339
|
+
else
|
|
1340
|
+
out('No routing data.');
|
|
1341
|
+
printSignals(r.signals);
|
|
1342
|
+
printSources(r);
|
|
1343
|
+
});
|
|
1344
|
+
},
|
|
1345
|
+
async vulns(o, a) {
|
|
1346
|
+
const r = await o.vulns({ days: Number(a.pos[1] ?? a.flags.days ?? 7) || 7, ...(typeof a.flags.vendor === 'string' ? { vendor: a.flags.vendor } : {}) });
|
|
1347
|
+
emit(a, r, () => {
|
|
1348
|
+
const v = r.result;
|
|
1349
|
+
out(c.bold(`Vulnerabilities ${v.window.from.slice(0, 10)} to ${v.window.to.slice(0, 10)}${v.vendor ? ` · ${v.vendor}` : ''}`) + c.dim(v.catalog ? ` CISA KEV ${v.catalog.count} entries, version ${v.catalog.version}` : ''));
|
|
1350
|
+
out(`\n ${c.bold(`Newly exploited in the wild (CISA KEV) · ${v.kev.length}`)}`);
|
|
1351
|
+
for (const k of v.kev.slice(0, 20))
|
|
1352
|
+
out(` ${c.gray(k.dateAdded)} ${c.red(k.cveID.padEnd(16))} ${trunc(k.vulnerabilityName, 80)}${k.knownRansomwareCampaignUse === 'Known' ? c.red(' ransomware') : ''}${k.epss != null ? c.dim(` EPSS ${k.epss.toFixed(2)}`) : ''}${k.daysToDue != null ? c.dim(k.daysToDue < 0 ? ` federal deadline passed ${-k.daysToDue}d ago` : ` federal deadline in ${k.daysToDue}d`) : ''}`);
|
|
1353
|
+
out(`\n ${c.bold(`New critical CVEs (NVD) · ${v.criticalCves.length}`)}`);
|
|
1354
|
+
for (const x of v.criticalCves.slice(0, 10))
|
|
1355
|
+
out(` ${c.gray(x.published.slice(0, 10))} ${x.id.padEnd(16)} ${x.cvss ?? '?'} ${c.dim(trunc(x.description, 90))}`);
|
|
1356
|
+
const adv = v.advisories ?? [];
|
|
1357
|
+
if (adv.length) {
|
|
1358
|
+
out(`\n ${c.bold(`Critical package advisories (GitHub) · ${adv.length}`)}`);
|
|
1359
|
+
for (const x of adv.slice(0, 10))
|
|
1360
|
+
out(` ${c.gray(x.published.slice(0, 10))} ${x.id} ${trunc(`${x.packages.map((p) => `${p.ecosystem}/${p.name}`).slice(0, 2).join(', ')}: ${x.summary}`, 90)}`);
|
|
1361
|
+
}
|
|
1362
|
+
printSignals(r.signals);
|
|
1363
|
+
printSources(r);
|
|
1364
|
+
});
|
|
1365
|
+
},
|
|
1366
|
+
async cve(o, a) {
|
|
1367
|
+
const r = await o.cve(need(a, 1, 'CVE id, e.g. CVE-2021-44228'));
|
|
1368
|
+
emit(a, r, () => {
|
|
1369
|
+
const d = r.result;
|
|
1370
|
+
out(`${c.bold(d.id)} ${d.cvss ? `${d.cvss.score >= 9 ? c.red(`${d.cvss.score} ${d.cvss.severity}`) : `${d.cvss.score} ${d.cvss.severity}`} ${c.dim(`CVSS ${d.cvss.version}`)}` : c.dim('no CVSS yet')}${d.kev ? c.red(' EXPLOITED IN THE WILD (CISA KEV)') : ''}`);
|
|
1371
|
+
out(` ${trunc(d.description, 300)}`);
|
|
1372
|
+
if (d.epss)
|
|
1373
|
+
out(` EPSS ${(d.epss.score * 100).toFixed(1)}% chance of exploitation in 30 days (percentile ${Math.round(d.epss.percentile * 100)})`);
|
|
1374
|
+
if (d.kev)
|
|
1375
|
+
out(` KEV since ${d.kev.dateAdded}, federal due date ${d.kev.dueDate}${d.kev.knownRansomwareCampaignUse === 'Known' ? ', used by ransomware' : ''}`);
|
|
1376
|
+
if (d.products.length)
|
|
1377
|
+
out(` products ${trunc(d.products.join(', '), 120)}`);
|
|
1378
|
+
for (const p of d.packages.slice(0, 8))
|
|
1379
|
+
out(` package ${p.ecosystem}/${p.name}${p.fixed.length ? ` fixed in ${p.fixed.join(', ')}` : c.yellow(' no fix listed')}`);
|
|
1380
|
+
if (d.cwes.length)
|
|
1381
|
+
out(c.dim(` ${d.cwes.join(', ')}`));
|
|
1382
|
+
printSignals(r.signals);
|
|
1383
|
+
printSources(r);
|
|
1384
|
+
});
|
|
1385
|
+
},
|
|
1386
|
+
async pkg(o, a) {
|
|
1387
|
+
const [eco, name, version] = [a.pos[1], a.pos[2], a.pos[3]];
|
|
1388
|
+
if (!eco || !name)
|
|
1389
|
+
throw new UsageError('usage: oculon pkg <ecosystem> <name> [version], e.g. oculon pkg npm lodash 4.17.15');
|
|
1390
|
+
const r = await o.packageVulns(eco, name, version);
|
|
1391
|
+
emit(a, r, () => {
|
|
1392
|
+
const p = r.result;
|
|
1393
|
+
out(c.bold(`${p.ecosystem}/${p.name}${p.version ? `@${p.version}` : ''} · ${p.vulns.length} known vulnerabilities`) + c.dim(' (OSV.dev)'));
|
|
1394
|
+
for (const v of p.vulns.slice(0, 25)) {
|
|
1395
|
+
const x = v;
|
|
1396
|
+
out(` ${x.exploited ? c.red('exploited') : ' '} ${x.id.padEnd(20)} ${trunc(x.summary ?? '', 70)}${x.fixed?.length ? c.dim(` fix ${x.fixed.join(', ')}`) : ''}`);
|
|
1397
|
+
}
|
|
1398
|
+
if (!p.vulns.length)
|
|
1399
|
+
out(c.green(' none known'));
|
|
1400
|
+
printSignals(r.signals);
|
|
1401
|
+
printSources(r);
|
|
1402
|
+
});
|
|
1403
|
+
},
|
|
1404
|
+
async regs(o, a) {
|
|
1405
|
+
const r = await o.regs({ days: Number(a.flags.days ?? 7) || 7, ...(a.pos[1] ? { query: a.pos.slice(1).join(' ') } : {}), ...(typeof a.flags.agency === 'string' ? { agency: a.flags.agency } : {}) });
|
|
1406
|
+
emit(a, r, () => {
|
|
1407
|
+
const g = r.result;
|
|
1408
|
+
out(c.bold(`US Federal Register ${g.window.from.slice(0, 10)} to ${g.window.to.slice(0, 10)}${g.query ? ` · "${g.query}"` : ''}${g.agency ? ` · ${g.agency}` : ''}`));
|
|
1409
|
+
if (g.executiveOrders.length) {
|
|
1410
|
+
out(`\n ${c.bold('Executive orders')}`);
|
|
1411
|
+
for (const d of g.executiveOrders.slice(0, 8))
|
|
1412
|
+
out(` ${c.gray(d.publicationDate)} ${c.red(`EO ${d.executiveOrder ?? ''}`)} ${trunc(d.title, 100)}`);
|
|
1413
|
+
}
|
|
1414
|
+
if (g.publicInspection.length) {
|
|
1415
|
+
out(`\n ${c.bold(`Public inspection (publishes next) · ${g.publicInspection.length}`)}`);
|
|
1416
|
+
for (const d of g.publicInspection.slice(0, 8))
|
|
1417
|
+
out(` ${c.gray(d.publicationDate)} ${c.dim(d.type.padEnd(14))} ${trunc(`${d.agencies[0] ?? ''}: ${d.title}`, 100)}`);
|
|
1418
|
+
}
|
|
1419
|
+
out(`\n ${c.bold(`Documents · ${g.documents.length}`)}`);
|
|
1420
|
+
for (const d of g.documents.slice(0, 20))
|
|
1421
|
+
out(` ${c.gray(d.publicationDate)} ${(d.significant ? c.yellow : c.dim)(d.type.padEnd(14))} ${trunc(`${d.agencies[0] ?? ''}: ${d.title}`, 100)}${d.effectiveOn ? c.dim(` effective ${d.effectiveOn}`) : ''}${d.commentsCloseOn ? c.dim(` comments close ${d.commentsCloseOn}`) : ''}`);
|
|
1422
|
+
printSignals(r.signals);
|
|
1423
|
+
printSources(r);
|
|
1424
|
+
});
|
|
1425
|
+
},
|
|
1426
|
+
async defi(o, a) {
|
|
1427
|
+
const r = await o.defi();
|
|
1428
|
+
emit(a, r, () => {
|
|
1429
|
+
const d = r.result;
|
|
1430
|
+
const usd = (n) => (n == null ? '?' : n >= 1e9 ? `$${(n / 1e9).toFixed(2)}B` : n >= 1e6 ? `$${(n / 1e6).toFixed(1)}M` : `$${Math.round(n / 1e3)}k`);
|
|
1431
|
+
const pct = (n) => (n == null ? '' : `${n >= 0 ? '+' : ''}${n.toFixed(1)}%`);
|
|
1432
|
+
const t = d.totals;
|
|
1433
|
+
out(c.bold(`DeFi risk radar`) + c.dim(` TVL ${usd(t.defiTvl)} ${pct(t.defiTvlChange1d)} 1d · stablecoins ${usd(t.stablecoinSupply)} · DEX volume ${usd(t.dexVolume24h)} · fees ${usd(t.fees24h)}`));
|
|
1434
|
+
if (d.fearGreed)
|
|
1435
|
+
out(` Fear & Greed ${d.fearGreed.value} ${d.fearGreed.label}${c.dim(`, 7d avg ${d.fearGreed.avg7d ?? '?'}, 30d avg ${d.fearGreed.avg30d ?? '?'}, ${d.fearGreed.trend}`)}`);
|
|
1436
|
+
out(`\n ${c.bold(`TVL crashes · ${d.tvlDrops.length}`)}`);
|
|
1437
|
+
for (const p of d.tvlDrops.slice(0, 12))
|
|
1438
|
+
out(` ${c.red(pct(p.change1d).padStart(7))} ${c.bold(trunc(p.name, 28).padEnd(28))} ${usd(p.prevTvl)} → ${usd(p.tvl)} ${c.dim(`${p.category}${p.vsMarketPct != null ? `, ${pct(p.vsMarketPct)} vs market` : ''}${p.flags.length ? `, ${p.flags.join(', ')}` : ''}`)}`);
|
|
1439
|
+
out(`\n ${c.bold(`Stablecoin depegs · ${d.depegs.length}`)}${d.supplyShocks.length ? c.dim(` · ${d.supplyShocks.length} supply shocks`) : ''}`);
|
|
1440
|
+
for (const s of [...d.depegs, ...d.supplyShocks].slice(0, 10))
|
|
1441
|
+
out(` ${s.symbol.padEnd(10)} $${s.price.toFixed(4)} ${Math.abs(s.offPct) >= 2 ? c.red(`${Math.abs(s.offPct).toFixed(1)}% off peg`) : c.dim(`${Math.abs(s.offPct).toFixed(1)}% off peg`)} ${c.dim(`supply ${usd(s.circulating)}${s.supplyChange1dPct != null ? ` (${pct(s.supplyChange1dPct)} 1d)` : ''}, ${s.mechanism}`)}`);
|
|
1442
|
+
if (d.hacks.length) {
|
|
1443
|
+
out(`\n ${c.bold(`Hacks, last 7 days · ${d.hacks.length}`)}`);
|
|
1444
|
+
for (const h of d.hacks.slice(0, 8))
|
|
1445
|
+
out(` ${c.gray(h.date.slice(0, 10))} ${c.red(usd(h.amount).padStart(8))} ${trunc(`${h.name}: ${h.technique || h.classification}`, 80)} ${c.dim(h.chains.join(', '))}`);
|
|
1446
|
+
}
|
|
1447
|
+
if (d.chains.moves.length)
|
|
1448
|
+
out(`\n ${c.dim('chain moves:')} ${d.chains.moves.slice(0, 6).map((m) => `${m.name} ${pct(m.changePct)}`).join(', ')}`);
|
|
1449
|
+
printSignals(r.signals);
|
|
1450
|
+
printSources(r);
|
|
1451
|
+
});
|
|
1452
|
+
},
|
|
1453
|
+
async protocol(o, a) {
|
|
1454
|
+
const r = await o.protocol(need(a, 1, 'protocol name, e.g. aave'));
|
|
1455
|
+
emit(a, r, () => {
|
|
1456
|
+
const p = r.result;
|
|
1457
|
+
if (!p)
|
|
1458
|
+
return out(c.yellow('protocol not found on DefiLlama'));
|
|
1459
|
+
const usd = (n) => (n == null ? '?' : n >= 1e9 ? `$${(n / 1e9).toFixed(2)}B` : n >= 1e6 ? `$${(n / 1e6).toFixed(1)}M` : `$${Math.round(n / 1e3)}k`);
|
|
1460
|
+
const pct = (n) => (n == null ? '?' : `${n >= 0 ? '+' : ''}${n.toFixed(1)}%`);
|
|
1461
|
+
out(`${c.bold(p.name)} ${c.dim(`${p.category} · ${p.url}`)}`);
|
|
1462
|
+
out(` TVL ${usd(p.tvl)} · 1d ${pct(p.change.d1)} · 7d ${pct(p.change.d7)} · 30d ${pct(p.change.d30)} · 1y ${pct(p.change.d365)}${p.ath && p.drawdownFromAthPct != null ? c.dim(` · ${Math.abs(p.drawdownFromAthPct).toFixed(1)}% below its high of ${usd(p.ath.tvl)} on ${p.ath.date}`) : ''}`);
|
|
1463
|
+
if (p.chains.length)
|
|
1464
|
+
out(` chains ${p.chains.slice(0, 6).map((x) => `${x.chain} ${usd(x.tvl)}`).join(', ')}`);
|
|
1465
|
+
out(` audits ${p.audits ?? '?'}${p.auditLinks.length ? c.dim(` ${p.auditLinks.slice(0, 2).join(' ')}`) : ''}${p.oracles.length ? ` · oracles ${p.oracles.join(', ')}` : ''}`);
|
|
1466
|
+
const extra = p;
|
|
1467
|
+
for (const h of extra.hacks ?? [])
|
|
1468
|
+
out(c.red(` hacked ${h.date.slice(0, 10)}: ${usd(h.amount)}${h.technique ? `, ${h.technique}` : ''}`));
|
|
1469
|
+
for (const w of extra.warnings ?? [])
|
|
1470
|
+
out(c.yellow(` warning: ${trunc(w, 120)}`));
|
|
1471
|
+
printSignals(r.signals);
|
|
1472
|
+
printSources(r);
|
|
1473
|
+
});
|
|
1474
|
+
},
|
|
1475
|
+
async squawk(o, a) {
|
|
1476
|
+
const r = await o.squawks();
|
|
1477
|
+
emit(a, r, () => {
|
|
1478
|
+
const s = r.result;
|
|
1479
|
+
out(c.bold(`Emergency squawks · ${s.total} aircraft`) + c.dim(` 7500 ${s.byCode['7500']} · 7700 ${s.byCode['7700']} · 7600 ${s.byCode['7600']} · ${s.ignored} ignored as ground or stale`));
|
|
1480
|
+
for (const x of s.aircraft)
|
|
1481
|
+
out(` ${x.code === '7500' ? c.red(x.code) : x.code === '7700' ? c.yellow(x.code) : x.code} ${c.bold((x.callsign ?? x.hex).padEnd(9))} ${(x.registration ?? '').padEnd(9)} ${(x.type ?? '').padEnd(5)} ${x.altFt ?? '?'} ft ${x.speedKt ?? '?'} kt ${x.nearestAirport ? `${x.nearestAirport.km} km from ${x.nearestAirport.name}` : `${x.lat?.toFixed(2)}, ${x.lon?.toFixed(2)}`}${x.emergency ? c.dim(` (${x.emergency})`) : ''}`);
|
|
1482
|
+
if (!s.total)
|
|
1483
|
+
out(c.green(' no aircraft squawking an emergency code right now'));
|
|
1484
|
+
printSignals(r.signals);
|
|
1485
|
+
printSources(r);
|
|
1486
|
+
});
|
|
1487
|
+
},
|
|
1488
|
+
async filings(o, a) {
|
|
1489
|
+
const q = need(a, 1, 'phrase, e.g. "cybersecurity incident"');
|
|
1490
|
+
const forms = typeof a.flags.forms === 'string' ? a.flags.forms.split(',') : undefined;
|
|
1491
|
+
const r = await o.filings(q, { days: Number(a.flags.days ?? 30) || 30, ...(forms ? { forms } : {}) });
|
|
1492
|
+
emit(a, r, () => {
|
|
1493
|
+
const f = r.result;
|
|
1494
|
+
out(c.bold(`SEC full-text search · ${f.query} · ${f.from} to ${f.to} · ${f.total}${f.totalIsLowerBound ? '+' : ''} filings`) + c.dim(f.forms.length ? ` forms ${f.forms.join(',')}` : ''));
|
|
1495
|
+
for (const h of f.hits.slice(0, 25))
|
|
1496
|
+
out(` ${c.gray(h.filed)} ${h.form.padEnd(6)} ${c.bold(trunc(`${h.company}${h.ticker ? ` (${h.ticker})` : ''}`, 40).padEnd(40))} ${c.dim(trunc(h.itemTitles.join('; '), 60))}`);
|
|
1497
|
+
if (f.topCompanies.length)
|
|
1498
|
+
out(`\n ${c.dim('most filings:')} ${f.topCompanies.slice(0, 6).map((x) => `${x.name} (${x.docs})`).join(', ')}`);
|
|
1499
|
+
printSources(r);
|
|
1500
|
+
});
|
|
1501
|
+
},
|
|
1502
|
+
async edgar(o, a) {
|
|
1503
|
+
const r = await o.secEvents(need(a, 1, 'ticker or CIK'), Number(a.flags.days ?? 90) || 90);
|
|
1504
|
+
emit(a, r, () => {
|
|
1505
|
+
const e = r.result;
|
|
1506
|
+
out(c.bold(`8-K events · ${e.company?.name ?? a.pos[1]} · last ${e.days} days · ${e.events.length}`));
|
|
1507
|
+
for (const x of e.events)
|
|
1508
|
+
out(` ${c.gray(x.date)} ${x.impact >= 70 ? c.red(String(x.impact).padStart(3)) : c.dim(String(x.impact).padStart(3))} ${trunc(x.summary, 110)}${x.officerDeparture ? c.red(` ${x.officerDeparture} leaving`) : ''}`);
|
|
1509
|
+
if (!e.events.length)
|
|
1510
|
+
out(c.dim(' no 8-K filings in the window'));
|
|
1511
|
+
printSignals(r.signals);
|
|
1512
|
+
printSources(r);
|
|
1513
|
+
});
|
|
1514
|
+
},
|
|
1515
|
+
async blackout(o, a) {
|
|
1516
|
+
const r = await o.blackout(Number(a.pos[1] ?? a.flags.days ?? 2) || 2);
|
|
1517
|
+
emit(a, r, () => {
|
|
1518
|
+
const b = r.result;
|
|
1519
|
+
out(c.bold(`Internet outages · last ${b.days} days · ${b.outages.length} events`));
|
|
1520
|
+
for (const x of b.outages.slice(0, 20)) {
|
|
1521
|
+
const where = `${x.country ?? '?'}${x.network ? ` · ${x.network}` : ''}`;
|
|
1522
|
+
out(` ${x.verified ? c.red('●') : c.yellow('○')} ${c.gray(x.start.slice(0, 16).replace('T', ' '))} ${c.bold(trunc(where, 60))}${x.cause ? c.dim(` ${x.cause}`) : ''}${x.end ? '' : c.red(' ongoing')}`);
|
|
1523
|
+
out(c.dim(` ${trunc(x.description, 110)}`));
|
|
1524
|
+
}
|
|
1525
|
+
for (const rt of b.routing)
|
|
1526
|
+
out(` ${c.dim('routing')} ${rt.country}: ${rt.v4Now} IPv4 prefixes visible vs ${rt.v4Baseline} usual ${rt.change <= -0.05 ? c.red(`(${(rt.change * 100).toFixed(1)}%)`) : c.dim(`(${(rt.change * 100).toFixed(1)}%)`)}`);
|
|
1527
|
+
if (b.ioda.length)
|
|
1528
|
+
out(`\n ${c.dim('IODA top countries by outage score:')} ${b.ioda.slice(0, 8).map((x) => `${x.name} (${x.events})`).join(', ')}`);
|
|
1529
|
+
out(c.dim(' ● confirmed or verified by Cloudflare ○ automatic anomaly'));
|
|
1530
|
+
printSignals(r.signals);
|
|
1531
|
+
printSources(r);
|
|
1532
|
+
});
|
|
1533
|
+
},
|
|
1534
|
+
async hazards(o, a) {
|
|
1535
|
+
const r = await o.hazards(Number(a.pos[1] ?? a.flags.days ?? 7) || 7);
|
|
1536
|
+
emit(a, r, () => {
|
|
1537
|
+
out(c.bold(`GDACS disaster alerts · ${r.result.length}`));
|
|
1538
|
+
for (const x of r.result.bulletins?.filter((x) => x.source !== 'NWS') ?? [])
|
|
1539
|
+
out(` ${/warning|advisory|watch|threat/i.test(x.category) ? c.red('tsunami') : c.dim('tsunami')} ${c.gray(x.issued.slice(0, 16).replace('T', ' '))} ${x.category}: ${trunc(x.title, 70)}`);
|
|
1540
|
+
const nws = r.result.bulletins?.filter((x) => x.source === 'NWS') ?? [];
|
|
1541
|
+
if (nws.length) {
|
|
1542
|
+
const counts = new Map();
|
|
1543
|
+
for (const x of nws)
|
|
1544
|
+
counts.set(x.title, (counts.get(x.title) ?? 0) + 1);
|
|
1545
|
+
out(` ${c.dim('US severe weather alerts:')} ${[...counts].sort((p, q) => q[1] - p[1]).slice(0, 6).map(([t, n]) => `${t} ×${n}`).join(', ')}`);
|
|
1546
|
+
}
|
|
1547
|
+
for (const h of r.result)
|
|
1548
|
+
out(` ${h.level === 'Red' ? c.red('RED ') : c.yellow('orange')} ${c.gray(h.to.slice(0, 10))} ${c.bold(trunc(h.name, 50))} ${c.dim(trunc(`${h.type}${h.countries ? ` · ${h.countries}` : ''}${h.severity ? ` · ${h.severity}` : ''}`, 90))}${h.current ? '' : c.dim(' (ended)')}`);
|
|
1549
|
+
printSources(r);
|
|
1550
|
+
});
|
|
1551
|
+
},
|
|
1552
|
+
async podcast(o, a) {
|
|
1553
|
+
const subject = need(a, 1, 'subject');
|
|
1554
|
+
const r = await o.podcast(subject, a.flags.pick !== undefined ? Number(a.flags.pick) : undefined);
|
|
1555
|
+
emit(a, r, () => {
|
|
1556
|
+
const { episodes, picked, transcript: t } = r.result;
|
|
1557
|
+
out(c.bold(`Podcasts about ${subject} · ${episodes.length} recent episodes`));
|
|
1558
|
+
for (const [i, e] of episodes.entries())
|
|
1559
|
+
out(` ${e === picked ? c.green('▶') : ' '} ${String(i).padStart(2)} ${c.gray(e.date.slice(0, 10))} ${trunc(`${e.show}: ${e.title}`, 100)}`);
|
|
1560
|
+
if (t)
|
|
1561
|
+
printTranscript(t);
|
|
1562
|
+
else if (picked)
|
|
1563
|
+
out(c.yellow(`\n could not transcribe: ${r.provenance.at(-1)?.note ?? 'error'}`));
|
|
1564
|
+
out(c.dim('\n pick another with --pick <n>'));
|
|
1565
|
+
printSources(r);
|
|
1566
|
+
});
|
|
1567
|
+
},
|
|
1568
|
+
async listen(o, a) {
|
|
1569
|
+
const url = need(a, 1, 'audio or video file URL').split(' ')[0];
|
|
1570
|
+
const r = await o.listen(url, typeof a.flags.about === 'string' ? a.flags.about : '');
|
|
1571
|
+
emit(a, r, () => {
|
|
1572
|
+
if (!r.result)
|
|
1573
|
+
out(c.yellow(`could not transcribe: ${r.provenance.at(-1)?.note ?? 'error'}`));
|
|
1574
|
+
else
|
|
1575
|
+
printTranscript(r.result);
|
|
1576
|
+
printSources(r);
|
|
1577
|
+
});
|
|
1578
|
+
},
|
|
1579
|
+
async exposure(o, a) {
|
|
1580
|
+
const r = await o.exposure(need(a, 1, 'domain'));
|
|
1581
|
+
emit(a, r, () => {
|
|
1582
|
+
const e = r.result;
|
|
1583
|
+
out(c.bold(`Exposure · ${e.domain}`) + c.dim(` ${e.hostsChecked} hosts checked, ${e.resolved} IPs`));
|
|
1584
|
+
for (const x of e.ips) {
|
|
1585
|
+
out(` ${x.ip.padEnd(16)} ${x.cdn ? c.dim(x.cdn.padEnd(18)) : c.yellow('direct'.padEnd(18))} ports ${x.ports.join(',') || '-'}${x.vulns.length ? c.red(` ${x.vulns.length} CVEs: ${x.vulns.slice(0, 4).join(', ')}`) : ''}`);
|
|
1586
|
+
if (x.exploited?.length && !x.cdn)
|
|
1587
|
+
out(c.red(` exploited in the wild (CISA KEV): ${x.exploited.slice(0, 6).join(', ')}`));
|
|
1588
|
+
if (x.network)
|
|
1589
|
+
out(c.dim(` ${trunc(`${x.network.origin ?? '?'}${x.network.country ? ` · ${x.network.country}` : ''}${x.network.rpki ? ` · RPKI ${x.network.rpki}` : ''}${x.network.abuse.length ? ` · abuse ${x.network.abuse[0]}` : ''}`, 100)}`));
|
|
1590
|
+
out(c.dim(` ${trunc(x.hosts.join(', '), 100)}`));
|
|
1591
|
+
}
|
|
1592
|
+
if (e.exploited?.length)
|
|
1593
|
+
out(c.red(`\n ${e.exploited.length} CVE(s) on direct machines are being exploited in the wild: ${e.exploited.slice(0, 8).join(', ')}`));
|
|
1594
|
+
if (e.unusualPorts.length)
|
|
1595
|
+
out(c.yellow(`\n non-web ports on direct machines: ${e.unusualPorts.slice(0, 10).map((p) => `${p.ip}:${p.port}`).join(', ')}`));
|
|
1596
|
+
out(c.dim('\n Ports and CVEs on CDN edges describe the CDN, not the company.'));
|
|
1597
|
+
printSignals(r.signals);
|
|
1598
|
+
printSources(r);
|
|
1599
|
+
});
|
|
1600
|
+
},
|
|
1601
|
+
async social(o, a) {
|
|
1602
|
+
const q = need(a, 1, 'subject');
|
|
1603
|
+
const platforms = typeof a.flags.only === 'string' ? a.flags.only.split(',') : undefined;
|
|
1604
|
+
const r = await o.pulse(q, platforms);
|
|
1605
|
+
emit(a, r, () => {
|
|
1606
|
+
const p = r.result;
|
|
1607
|
+
out(c.bold(`Social pulse · ${q} · ${p.posts} posts`) + c.dim(` ${Object.entries(p.byPlatform).map(([k, v]) => `${k} ${v}`).join(' · ')}`));
|
|
1608
|
+
if (p.acceleration != null)
|
|
1609
|
+
out(` Reddit pace, last 6h vs earlier: ${p.acceleration >= 3 ? c.red(`${p.acceleration.toFixed(1)}x`) : `${p.acceleration.toFixed(1)}x`}`);
|
|
1610
|
+
else
|
|
1611
|
+
out(c.dim(' Reddit pace: not measurable (newest posts span less than a day)'));
|
|
1612
|
+
out(c.bold('\nMost engaged'));
|
|
1613
|
+
for (const x of p.top)
|
|
1614
|
+
out(` ${c.cyan(x.platform.padEnd(7))} ${String(x.engagement).padStart(7)} ${c.gray(x.date.slice(0, 10))} ${trunc(`${x.author}: ${x.text.replace(/\s+/g, ' ')}`, 90)}`);
|
|
1615
|
+
out(c.bold('\nLatest'));
|
|
1616
|
+
for (const x of p.latest.slice(0, 5))
|
|
1617
|
+
out(` ${c.cyan(x.platform.padEnd(7))} ${c.gray(x.date.slice(0, 16).replace('T', ' '))} ${trunc(`${x.author}: ${x.text.replace(/\s+/g, ' ')}`, 90)}`);
|
|
1618
|
+
printSources(r);
|
|
1619
|
+
});
|
|
1620
|
+
},
|
|
1621
|
+
async calendar(o, a) {
|
|
1622
|
+
const r = await o.calendar(Number(a.pos[1] ?? a.flags.days ?? 14) || 14);
|
|
1623
|
+
emit(a, r, () => {
|
|
1624
|
+
out(c.bold(`Catalysts ${r.result.from} to ${r.result.to} · ${r.result.items.length} items`) + c.dim(' (★ = watched company or open forecast)'));
|
|
1625
|
+
let day = '';
|
|
1626
|
+
for (const i of r.result.items) {
|
|
1627
|
+
if (i.date !== day)
|
|
1628
|
+
out(`\n ${c.bold(i.date)}`), (day = i.date);
|
|
1629
|
+
const kind = i.kind === 'earnings' ? c.cyan('earnings') : i.kind === 'macro' ? c.yellow('macro ') : i.kind === 'ipo' ? c.green('ipo ') : i.kind === 'regulation' ? c.magenta('rule ') : c.blue('market ');
|
|
1630
|
+
out(` ${i.watched ? c.yellow('★') : ' '} ${kind} ${trunc(i.title, 80)}${i.detail ? c.dim(` ${trunc(i.detail, 70)}`) : ''}`);
|
|
1631
|
+
}
|
|
1632
|
+
printSources(r);
|
|
1633
|
+
});
|
|
1634
|
+
},
|
|
1635
|
+
async connect(o, a) {
|
|
1636
|
+
const text = need(a, 1, 'two things, e.g. oculon connect Nvidia to "Jensen Huang"');
|
|
1637
|
+
const [x, y] = text.split(/\s+(?:to|and|->)\s+/i);
|
|
1638
|
+
if (!x || !y)
|
|
1639
|
+
throw new UsageError('write it as: oculon connect <A> to <B>');
|
|
1640
|
+
const r = o.connect(x, y, Number(a.flags.depth ?? 6) || 6);
|
|
1641
|
+
emit(a, r, () => {
|
|
1642
|
+
if (!r.path)
|
|
1643
|
+
return out(`${c.yellow('no connection')}: ${r.note ?? ''} ${c.dim(`(${r.explored} nodes explored)`)}`);
|
|
1644
|
+
out(c.bold(`${x} → ${y}: ${r.path.length - 1} hop(s)`));
|
|
1645
|
+
for (const [i, s] of r.path.entries()) {
|
|
1646
|
+
const via = s.via ? c.dim(`${s.via.direction === 'out' ? '──' : '<─'}${s.via.rel}${s.via.direction === 'out' ? '─>' : '──'} `) : '';
|
|
1647
|
+
out(` ${i === 0 ? ' ' : ' '}${via}${c.bold(trunc(s.name, 80))} ${c.gray(s.kind)}${s.via ? c.dim(` via ${s.via.source}`) : ''}`);
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
},
|
|
1651
|
+
async resolve(o, a) {
|
|
1652
|
+
const r = o.resolveEntities();
|
|
1653
|
+
emit(a, r, () => {
|
|
1654
|
+
out(c.bold(`Entity resolution · ${r.checked} named entities checked, ${r.linked.length} new same_as link(s)`));
|
|
1655
|
+
for (const l of r.linked)
|
|
1656
|
+
out(` ${l.a} ${c.dim('=')} ${l.b} ${c.dim(`(${l.why})`)}`);
|
|
1657
|
+
});
|
|
1658
|
+
},
|
|
1659
|
+
async feedback(o, a) {
|
|
1660
|
+
const sub = a.pos[1];
|
|
1661
|
+
if (sub === 'useful' || sub === 'noise') {
|
|
1662
|
+
const r = o.feedback(need(a, 2, 'signal id'), sub);
|
|
1663
|
+
if (!r)
|
|
1664
|
+
throw new Error('no stored signal with that id (see `oculon signals --json`)');
|
|
1665
|
+
return emit(a, r, () => out(`Marked ${sub}: ${r.title} ${c.gray(r.module)}`));
|
|
1666
|
+
}
|
|
1667
|
+
const st = o.feedbackStats();
|
|
1668
|
+
const base = Number(process.env.TELEGRAM_ALERT_MIN_SCORE ?? 70);
|
|
1669
|
+
emit(a, st, () => {
|
|
1670
|
+
if (!st.length)
|
|
1671
|
+
return out('No votes yet. Tap Useful or Noise under a Telegram alert, or run `oculon feedback useful|noise <signal-id>`.');
|
|
1672
|
+
out(c.bold(`Feedback · base alert bar ${base}`));
|
|
1673
|
+
for (const m of st)
|
|
1674
|
+
out(` ${m.module.padEnd(12)} ${c.green(`${m.useful} useful`)} ${c.red(`${m.noise} noise`)} ${c.dim('→')} alert bar ${c.bold(base + m.shift)}`);
|
|
1675
|
+
});
|
|
1676
|
+
},
|
|
1677
|
+
async live(o, a) {
|
|
1678
|
+
const minutes = Number(a.flags.minutes ?? 30) || 30;
|
|
1679
|
+
const log = (m) => out(c.dim(`${new Date().toISOString().slice(11, 19)} ${m}`));
|
|
1680
|
+
out(`${c.bold('Live streams')} Wikipedia edits + Bluesky posts for ${minutes} min ${c.dim('(Bluesky surges need ~20 min of history first; Ctrl+C to stop)')}`);
|
|
1681
|
+
const m = await o.live({ log, onSignals: (s) => printSignals(s, 5) });
|
|
1682
|
+
const status = setInterval(() => log(`seen ${m.stats.wikiEdits} wiki edits, ${m.stats.posts} posts, ${m.stats.signals} signal(s)`), 5 * 60_000);
|
|
1683
|
+
await new Promise((r) => setTimeout(r, minutes * 60_000));
|
|
1684
|
+
clearInterval(status);
|
|
1685
|
+
m.stop();
|
|
1686
|
+
emit(a, m.stats, () => out(c.bold(`Done: ${m.stats.wikiEdits} wiki edits, ${m.stats.posts} posts, ${m.stats.signals} signal(s).`)));
|
|
1687
|
+
},
|
|
1688
|
+
async brief(o, a) {
|
|
1689
|
+
const b = await o.brief({ refresh: a.flags.refresh === true || a.flags.refresh === 'true', ...(typeof a.flags.lang === 'string' ? { lang: a.flags.lang } : {}) });
|
|
1690
|
+
emit(a, b, () => out(b.markdown));
|
|
1691
|
+
},
|
|
1692
|
+
async quota(o, a) {
|
|
1693
|
+
const q = o.quota();
|
|
1694
|
+
emit(a, q, () => {
|
|
1695
|
+
if (!q.length)
|
|
1696
|
+
return out('No metered API calls today.');
|
|
1697
|
+
out(c.bold(`API usage today (UTC)`));
|
|
1698
|
+
for (const r of q)
|
|
1699
|
+
out(` ${r.source.padEnd(18)} ${String(r.used).padStart(6)}${r.budget ? ` / ${r.budget}${r.used >= r.budget ? c.red(' reached') : r.used >= r.budget * 0.8 ? c.yellow(' near limit') : ''}` : c.dim(' (no budget)')}`);
|
|
1700
|
+
});
|
|
1701
|
+
},
|
|
1702
|
+
async entity(o, a) {
|
|
1703
|
+
const e = o.entity(need(a, 1, 'entity id'));
|
|
1704
|
+
emit(a, e, () => {
|
|
1705
|
+
if (!e.entity)
|
|
1706
|
+
return out(`No entity ${a.pos[1]}. Ids look like org:nvidia, domain:openai.com, aircraft:a835af.`);
|
|
1707
|
+
out(c.bold(`${e.entity.kind}: ${e.entity.name}`));
|
|
1708
|
+
for (const n of e.neighbors.slice(0, 40))
|
|
1709
|
+
out(` ${n.direction === 'out' ? '→' : '←'} ${c.cyan(n.rel.padEnd(16))} ${n.kind}: ${trunc(n.name, 90)}`);
|
|
1710
|
+
});
|
|
1711
|
+
},
|
|
1712
|
+
async forecast(o, a) {
|
|
1713
|
+
const sub = a.pos[1];
|
|
1714
|
+
if (sub === 'auto') {
|
|
1715
|
+
const r = await o.autoForecast();
|
|
1716
|
+
return emit(a, r, () => {
|
|
1717
|
+
out(c.bold(`Auto forecasts · ${r.result.created.length} new`));
|
|
1718
|
+
for (const p of r.result.created)
|
|
1719
|
+
out(` ${c.gray(p.id)} ${p.question}\n "${p.outcome}" model ${c.bold(pct(p.pModel))} vs market ${pct(p.pMarket)} ${c.dim(p.rationale)}`);
|
|
1720
|
+
for (const s of r.result.skipped)
|
|
1721
|
+
out(c.dim(` skipped: ${s}`));
|
|
1722
|
+
if (!r.result.created.length && !r.result.skipped.length)
|
|
1723
|
+
out(c.dim(' no market swing was corroborated by another source right now'));
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
if (sub === 'resolve') {
|
|
1727
|
+
const r = await o.resolveForecasts();
|
|
1728
|
+
return emit(a, r, () => {
|
|
1729
|
+
out(c.bold(`Checked ${r.result.checked} open forecasts, ${r.result.resolved.length} resolved`));
|
|
1730
|
+
for (const p of r.result.resolved)
|
|
1731
|
+
out(` ${p.question}: ${p.result ? 'YES' : 'NO'} · brier ${p.brierModel?.toFixed(3)} vs market ${p.brierMarket?.toFixed(3)}`);
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
if (sub === 'score') {
|
|
1735
|
+
const s = o.scoreboard();
|
|
1736
|
+
return emit(a, s, () => {
|
|
1737
|
+
out(c.bold(`Track record · ${s.total} forecasts, ${s.open} open, ${s.resolved} resolved`));
|
|
1738
|
+
out(` Brier model ${s.brierModel?.toFixed(4) ?? 'n/a'} vs market ${s.brierMarket?.toFixed(4) ?? 'n/a'} ${c.dim('(lower is better)')}`);
|
|
1739
|
+
out(` skill vs market ${s.skill == null ? c.dim('n/a until something resolves') : c.bold(pct(s.skill))} · beat the market ${s.beatMarket}/${s.resolved}`);
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
if (sub === 'list') {
|
|
1743
|
+
const list = o.forecasts('all', 100);
|
|
1744
|
+
return emit(a, list, () => {
|
|
1745
|
+
for (const p of list)
|
|
1746
|
+
out(` ${c.gray(p.id)} ${pct(p.pModel).padStart(4)} vs ${pct(p.pMarket).padStart(4)} ${p.batchId ? c.green('stamped') : c.dim('unstamped')} ${p.result == null ? 'open' : `resolved ${p.result ? 'YES' : 'NO'}`} ${trunc(p.question, 70)}`);
|
|
1747
|
+
if (!list.length)
|
|
1748
|
+
out(c.dim(' no forecasts yet'));
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
const slug = need(a, 1, 'market slug (or auto | resolve | score | list)');
|
|
1752
|
+
const p = Number(a.flags.p);
|
|
1753
|
+
if (!Number.isFinite(p))
|
|
1754
|
+
throw new UsageError('missing --p <probability between 0 and 1>');
|
|
1755
|
+
const r = await o.forecast(slug, p, typeof a.flags.why === 'string' ? a.flags.why : '');
|
|
1756
|
+
emit(a, r, () => out(`${c.bold('Recorded')} ${c.gray(r.result.id)}\n ${r.result.question}\n "${r.result.outcome}" you ${c.bold(pct(r.result.pModel))} vs market ${pct(r.result.pMarket)}\n run \`oculon proof stamp\` to timestamp it on Bitcoin`));
|
|
1757
|
+
},
|
|
1758
|
+
async proof(o, a) {
|
|
1759
|
+
const sub = a.pos[1];
|
|
1760
|
+
if (sub === 'stamp') {
|
|
1761
|
+
const r = await o.stampProofs();
|
|
1762
|
+
return emit(a, r, () => {
|
|
1763
|
+
const b = r.result.batch;
|
|
1764
|
+
if (!b)
|
|
1765
|
+
return out(r.result.reason ?? 'nothing stamped');
|
|
1766
|
+
out(`${c.bold(`Stamped ${b.size} forecast(s)`)} in ${c.gray(b.id)}\n merkle root ${b.root}\n calendars ${b.receipts.map((x) => x.calendar.replace('https://', '')).join(', ')}\n ${c.dim('Bitcoin confirmation usually takes a few hours; then run `oculon proof verify <id>`.')}`);
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
if (sub === 'verify') {
|
|
1770
|
+
const r = await o.verifyProof(need(a, 2, 'forecast id'));
|
|
1771
|
+
return emit(a, r, () => {
|
|
1772
|
+
const v = r.result;
|
|
1773
|
+
const col = v.status === 'VERIFIED' ? c.green : v.status === 'PENDING' ? c.yellow : c.red;
|
|
1774
|
+
out(`${c.bold(v.predictionId)} ${col(c.bold(v.status))}`);
|
|
1775
|
+
for (const s of v.steps)
|
|
1776
|
+
out(` - ${s}`);
|
|
1777
|
+
if (v.bitcoin)
|
|
1778
|
+
out(c.green(` anchored in Bitcoin block ${v.bitcoin.height} (${v.bitcoin.time})`));
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
throw new UsageError('usage: oculon proof stamp | oculon proof verify <forecast-id>');
|
|
1782
|
+
},
|
|
1783
|
+
async serve(o, a) {
|
|
1784
|
+
const { createWebServer } = await import('../web/server.js');
|
|
1785
|
+
const port = Number(a.flags.port ?? process.env.PORT ?? 4747);
|
|
1786
|
+
// --host 0.0.0.0 (or HOST) exposes the server beyond this machine; --public (or OCULON_PUBLIC=1) is then required
|
|
1787
|
+
// so only the overview, docs and a read-only API are open. The dashboard needs OCULON_ADMIN_TOKEN.
|
|
1788
|
+
const host = String(a.flags.host ?? process.env.HOST ?? '127.0.0.1');
|
|
1789
|
+
const publicMode = Boolean(a.flags.public) || process.env.OCULON_PUBLIC === '1';
|
|
1790
|
+
if (host !== '127.0.0.1' && host !== 'localhost' && !publicMode) {
|
|
1791
|
+
throw new UsageError('serving beyond localhost needs --public (or OCULON_PUBLIC=1), so private data and paid APIs stay locked');
|
|
1792
|
+
}
|
|
1793
|
+
const log = (m) => out(c.dim(`${new Date().toISOString().slice(11, 19)} ${m}`));
|
|
1794
|
+
// --telegram runs the bot in the same process; the dashboard's schedule then feeds its alerts and brief.
|
|
1795
|
+
let bot = null;
|
|
1796
|
+
if (a.flags.telegram || process.env.OCULON_TELEGRAM === '1') {
|
|
1797
|
+
const { TelegramBot } = await import('../telegram.js');
|
|
1798
|
+
bot = new TelegramBot({
|
|
1799
|
+
token: process.env.TELEGRAM_BOT_TOKEN ?? '',
|
|
1800
|
+
allowedChats: (process.env.TELEGRAM_ALLOWED_CHATS ?? '').split(',').map((s) => s.trim()).filter(Boolean),
|
|
1801
|
+
alertMinScore: Number(process.env.TELEGRAM_ALERT_MIN_SCORE ?? 70),
|
|
1802
|
+
watchMinutes: 0,
|
|
1803
|
+
oculon: o,
|
|
1804
|
+
log: (m) => log(`telegram ${m}`),
|
|
1805
|
+
});
|
|
1806
|
+
void bot.start().catch((e) => log(`telegram stopped: ${e.message}`));
|
|
1807
|
+
}
|
|
1808
|
+
createWebServer({
|
|
1809
|
+
port,
|
|
1810
|
+
host,
|
|
1811
|
+
publicMode,
|
|
1812
|
+
oculon: o,
|
|
1813
|
+
watchMinutes: Number(a.flags.watch ?? 0),
|
|
1814
|
+
log,
|
|
1815
|
+
...(bot
|
|
1816
|
+
? {
|
|
1817
|
+
onSignals: async (s) => {
|
|
1818
|
+
const n = await bot.pushAlerts(s);
|
|
1819
|
+
if (n)
|
|
1820
|
+
log(`telegram alerts sent: ${n}`);
|
|
1821
|
+
},
|
|
1822
|
+
onBrief: async (md) => {
|
|
1823
|
+
await bot.pushBrief(md);
|
|
1824
|
+
},
|
|
1825
|
+
onReport: async (file) => {
|
|
1826
|
+
await bot.pushReport(file, 'Weekly Oculon report');
|
|
1827
|
+
},
|
|
1828
|
+
onPersonal: async (d) => {
|
|
1829
|
+
const n = await bot.pushPersonal(d);
|
|
1830
|
+
if (n)
|
|
1831
|
+
log(`telegram monitor messages: ${n}`);
|
|
1832
|
+
},
|
|
1833
|
+
}
|
|
1834
|
+
: {}),
|
|
1835
|
+
});
|
|
1836
|
+
if (a.flags.live) {
|
|
1837
|
+
await o.live({
|
|
1838
|
+
log,
|
|
1839
|
+
...(bot
|
|
1840
|
+
? {
|
|
1841
|
+
onSignals: async (s) => {
|
|
1842
|
+
const n = await bot.pushAlerts(s);
|
|
1843
|
+
if (n)
|
|
1844
|
+
log(`telegram alerts sent: ${n}`);
|
|
1845
|
+
},
|
|
1846
|
+
}
|
|
1847
|
+
: {}),
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
out(`${c.bold('Oculon dashboard')} http://${host}:${port}${publicMode ? c.dim(' (public mode)') : ''}${a.flags.watch ? c.dim(` (schedule every ${a.flags.watch} min)`) : ''}${bot ? c.dim(' + Telegram bot') : ''}${a.flags.live ? c.dim(' + live streams') : ''}`);
|
|
1851
|
+
await new Promise(() => { });
|
|
1852
|
+
},
|
|
1853
|
+
async doctor(o, a) {
|
|
1854
|
+
const checks = [];
|
|
1855
|
+
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
1856
|
+
checks.push({ name: 'node', ok: major > 22 || (major === 22 && minor >= 13), detail: `v${process.versions.node} (needs 22.13+)` });
|
|
1857
|
+
checks.push({ name: 'database', ok: true, detail: process.env.OCULON_DB || join(oculonHome(), 'oculon.db') });
|
|
1858
|
+
checks.push({ name: 'OCULON_CONTACT', ok: Boolean(process.env.OCULON_CONTACT), detail: process.env.OCULON_CONTACT ? 'set (SEC EDGAR enabled)' : 'not set (SEC EDGAR off, optional)' });
|
|
1859
|
+
checks.push({ name: 'GITHUB_TOKEN', ok: Boolean(process.env.GITHUB_TOKEN), detail: process.env.GITHUB_TOKEN ? 'set' : 'not set (60 requests/hour, optional)' });
|
|
1860
|
+
const KEYS = [
|
|
1861
|
+
['LLM (ask)', ['GROQ_API_KEY', 'GEMINI_API_KEY', 'MISTRAL_API_KEY', 'NVIDIA_API_KEY', 'OPENROUTER_API_KEY']],
|
|
1862
|
+
['web search', ['TAVILY_API_KEY', 'EXA_API_KEY', 'JINA_API_KEY', 'FIRECRAWL_API_KEY']],
|
|
1863
|
+
['news', ['GNEWS_API_KEY', 'GUARDIAN_API_KEY', 'NYT_API_KEY']],
|
|
1864
|
+
['markets', ['FINNHUB_API_KEY', 'FRED_API_KEY', 'COINGECKO_API_KEY']],
|
|
1865
|
+
['on-chain', ['ZERION_API_KEY', 'ETHERSCAN_API_KEY', 'WEBACY_API_KEY', 'HELIUS_API_KEY', 'ROBINHOOD_PUBLIC_RPC_URL']],
|
|
1866
|
+
['companies', ['ADZUNA_APP_KEY', 'COURTLISTENER_TOKEN', 'COMPANIES_HOUSE_API_KEY', 'BRANDFETCH_API_KEY']],
|
|
1867
|
+
['web security', ['URLSCAN_API_KEY', 'SAFE_BROWSING_KEY', 'ABUSECH_AUTH_KEY']],
|
|
1868
|
+
['fact checks', ['GOOGLE_API_KEY']],
|
|
1869
|
+
['social/research', ['YOUTUBE_API_KEY', 'BLUESKY_APP_PASSWORD', 'OPENALEX_API_KEY']],
|
|
1870
|
+
['air quality', ['OPENAQ_API_KEY']],
|
|
1871
|
+
];
|
|
1872
|
+
for (const [group, names] of KEYS) {
|
|
1873
|
+
const set = names.filter((n) => process.env[n]?.trim());
|
|
1874
|
+
checks.push({ name: group, ok: set.length > 0, detail: `${set.length}/${names.length} keys set${set.length < names.length ? ` (missing: ${names.filter((n) => !set.includes(n)).join(', ')})` : ''}` });
|
|
1875
|
+
}
|
|
1876
|
+
const probes = [
|
|
1877
|
+
['wikimedia', 'https://wikimedia.org/api/rest_v1/metrics/pageviews/top/en.wikipedia/all-access/2026/01/01'],
|
|
1878
|
+
['hackernews', 'https://hn.algolia.com/api/v1/search?tags=front_page&hitsPerPage=1'],
|
|
1879
|
+
['polymarket', 'https://gamma-api.polymarket.com/markets?limit=1'],
|
|
1880
|
+
['gdelt', 'https://api.gdeltproject.org/api/v2/doc/doc?query=test&mode=artlist&maxrecords=1&format=json'],
|
|
1881
|
+
['crt.sh', 'https://crt.sh/?q=example.com&output=json'],
|
|
1882
|
+
['github', 'https://api.github.com/rate_limit'],
|
|
1883
|
+
['arxiv', 'https://export.arxiv.org/api/query?search_query=all:test&max_results=1'],
|
|
1884
|
+
['adsb.lol', 'https://api.adsb.lol/v2/hex/000000'],
|
|
1885
|
+
['nasa-eonet', 'https://eonet.gsfc.nasa.gov/api/v3/events?limit=1'],
|
|
1886
|
+
['nasa-gibs', 'https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0'],
|
|
1887
|
+
['usgs', 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_hour.geojson'],
|
|
1888
|
+
['opentimestamps', 'https://a.pool.opentimestamps.org/'],
|
|
1889
|
+
['blockstream', 'https://blockstream.info/api/blocks/tip/height'],
|
|
1890
|
+
['nominatim', 'https://nominatim.openstreetmap.org/status'],
|
|
1891
|
+
];
|
|
1892
|
+
const t0 = Date.now();
|
|
1893
|
+
const results = await Promise.all(probes.map(async ([name, url]) => {
|
|
1894
|
+
const s = Date.now();
|
|
1895
|
+
try {
|
|
1896
|
+
const res = await fetch(url, { method: 'GET', headers: { 'user-agent': 'Oculon doctor' }, signal: AbortSignal.timeout(20_000) });
|
|
1897
|
+
await res.body?.cancel();
|
|
1898
|
+
return { name, ok: res.status < 500 && res.status !== 429, detail: `HTTP ${res.status} in ${Date.now() - s} ms` };
|
|
1899
|
+
}
|
|
1900
|
+
catch (e) {
|
|
1901
|
+
return { name, ok: false, detail: e.name === 'TimeoutError' ? 'timeout' : e.message };
|
|
1902
|
+
}
|
|
1903
|
+
}));
|
|
1904
|
+
checks.push(...results);
|
|
1905
|
+
void o;
|
|
1906
|
+
emit(a, checks, () => {
|
|
1907
|
+
out(c.bold(`oculon doctor · v${VERSION}`));
|
|
1908
|
+
for (const ch of checks)
|
|
1909
|
+
out(` ${ch.ok ? c.green('ok ') : c.yellow('warn')} ${ch.name.padEnd(16)} ${c.dim(ch.detail)}`);
|
|
1910
|
+
out(c.dim(`\n${checks.filter((x) => !x.ok).length} warning(s), probes took ${Date.now() - t0} ms`));
|
|
1911
|
+
});
|
|
1912
|
+
},
|
|
1913
|
+
};
|
|
1914
|
+
/** Nearest command name by edit distance, when it is close enough to be a typo. */
|
|
1915
|
+
export function closest(word, options) {
|
|
1916
|
+
const d = (x, y) => {
|
|
1917
|
+
const row = Array.from({ length: y.length + 1 }, (_, i) => i);
|
|
1918
|
+
for (let i = 1; i <= x.length; i++) {
|
|
1919
|
+
let prev = row[0];
|
|
1920
|
+
row[0] = i;
|
|
1921
|
+
for (let j = 1; j <= y.length; j++) {
|
|
1922
|
+
const tmp = row[j];
|
|
1923
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + (x[i - 1] === y[j - 1] ? 0 : 1));
|
|
1924
|
+
prev = tmp;
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
return row[y.length];
|
|
1928
|
+
};
|
|
1929
|
+
let best = null;
|
|
1930
|
+
let bestD = Infinity;
|
|
1931
|
+
for (const o of options) {
|
|
1932
|
+
const dist = o.startsWith(word) && word.length >= 3 ? 0.5 : d(word.toLowerCase(), o);
|
|
1933
|
+
if (dist < bestD)
|
|
1934
|
+
(best = o), (bestD = dist);
|
|
1935
|
+
}
|
|
1936
|
+
return bestD <= Math.max(1, Math.floor(word.length / 3)) ? best : null;
|
|
1937
|
+
}
|
|
1938
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
1939
|
+
const a = parseArgs(argv);
|
|
1940
|
+
const cmd = a.pos[0];
|
|
1941
|
+
if (a.flags.version || cmd === 'version')
|
|
1942
|
+
return out(VERSION), 0;
|
|
1943
|
+
// `oculon help calendar` or `oculon calendar --help`: just the matching lines.
|
|
1944
|
+
const topic = cmd === 'help' ? a.pos[1] : a.flags.help ? cmd : undefined;
|
|
1945
|
+
if (topic) {
|
|
1946
|
+
const lines = HELP.split('\n').filter((l) => new RegExp(`oculon ${topic}\\b`).test(l));
|
|
1947
|
+
out(lines.length ? lines.join('\n') : `No help for "${topic}".\n\n${HELP}`);
|
|
1948
|
+
return 0;
|
|
1949
|
+
}
|
|
1950
|
+
if (!cmd || a.flags.help || cmd === 'help')
|
|
1951
|
+
return out(helpText()), 0;
|
|
1952
|
+
if (existsSync('.env'))
|
|
1953
|
+
process.loadEnvFile('.env');
|
|
1954
|
+
if (cmd === 'mcp') {
|
|
1955
|
+
const { serveStdio } = await import('../mcp.js');
|
|
1956
|
+
serveStdio();
|
|
1957
|
+
return new Promise(() => { });
|
|
1958
|
+
}
|
|
1959
|
+
if (cmd === 'telegram') {
|
|
1960
|
+
const { TelegramBot } = await import('../telegram.js');
|
|
1961
|
+
const bot = new TelegramBot({
|
|
1962
|
+
token: process.env.TELEGRAM_BOT_TOKEN ?? '',
|
|
1963
|
+
allowedChats: (process.env.TELEGRAM_ALLOWED_CHATS ?? '').split(',').map((s) => s.trim()).filter(Boolean),
|
|
1964
|
+
alertMinScore: Number(process.env.TELEGRAM_ALERT_MIN_SCORE ?? 70),
|
|
1965
|
+
watchMinutes: Number(process.env.TELEGRAM_WATCH_MINUTES ?? 15),
|
|
1966
|
+
log: (m) => out(c.dim(`${new Date().toISOString().slice(11, 19)} ${m}`)),
|
|
1967
|
+
});
|
|
1968
|
+
await bot.start();
|
|
1969
|
+
return 0;
|
|
1970
|
+
}
|
|
1971
|
+
if (ONCHAIN_COMMANDS.has(cmd) && !onchainEnabled()) {
|
|
1972
|
+
out(c.dim(ONCHAIN_PAUSED_MESSAGE));
|
|
1973
|
+
return 1;
|
|
1974
|
+
}
|
|
1975
|
+
const run = COMMANDS[cmd];
|
|
1976
|
+
if (!run) {
|
|
1977
|
+
const near = closest(cmd, [...Object.keys(COMMANDS), 'mcp', 'telegram', 'help', 'version']);
|
|
1978
|
+
out(`${c.red('Unknown command')}: ${cmd}${near ? `. Did you mean ${c.bold(`oculon ${near}`)}?` : ''}`);
|
|
1979
|
+
out(c.dim('Run `oculon help` for every command, or `oculon tour` to get started.'));
|
|
1980
|
+
return 2;
|
|
1981
|
+
}
|
|
1982
|
+
const o = new Oculon();
|
|
1983
|
+
try {
|
|
1984
|
+
await run(o, a);
|
|
1985
|
+
return 0;
|
|
1986
|
+
}
|
|
1987
|
+
catch (e) {
|
|
1988
|
+
if (e instanceof UsageError) {
|
|
1989
|
+
out(`${c.red('usage')}: ${e.message}. See \`oculon help\`.`);
|
|
1990
|
+
return 2;
|
|
1991
|
+
}
|
|
1992
|
+
out(`${c.red('error')}: ${e.message}`);
|
|
1993
|
+
return 1;
|
|
1994
|
+
}
|
|
1995
|
+
finally {
|
|
1996
|
+
if (cmd !== 'serve')
|
|
1997
|
+
o.close();
|
|
1998
|
+
}
|
|
1999
|
+
}
|