oculon 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/dist/agent.d.ts +25 -1
- package/dist/agent.js +14 -4
- package/dist/analyst.d.ts +99 -0
- package/dist/analyst.js +335 -0
- package/dist/cli/main.js +1 -1
- package/dist/core/llm.d.ts +2 -0
- package/dist/core/llm.js +29 -0
- package/dist/mcp.d.ts +7 -0
- package/dist/mcp.js +47 -2
- package/dist/modules/contradictions.js +6 -4
- package/dist/modules/lynx.js +15 -9
- package/dist/modules/owl.js +4 -1
- package/dist/modules/personal.js +1 -1
- package/dist/web/ask.html +410 -0
- package/dist/web/assets/favicon-32.png +0 -0
- package/dist/web/assets/fx.js +25 -3
- 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/logo.svg +1 -0
- package/dist/web/assets/og-app.png +0 -0
- package/dist/web/assets/og-docs.png +0 -0
- package/dist/web/assets/og-mcp.png +0 -0
- package/dist/web/assets/og.png +0 -0
- package/dist/web/docs.html +13 -3
- package/dist/web/index.html +45 -10
- package/dist/web/landing.html +11 -5
- package/dist/web/legal.html +8 -4
- package/dist/web/manifest.webmanifest +31 -7
- package/dist/web/mcp.html +7 -3
- package/dist/web/server.js +118 -7
- package/dist/web/share.js +1 -1
- package/package.json +10 -10
package/dist/mcp.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export interface Tool {
|
|
|
10
10
|
inputSchema: Json;
|
|
11
11
|
run: (o: Oculon, a: Json) => Promise<unknown> | unknown;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Checks tool arguments against the tool's input schema before running it. A misspelled argument used
|
|
15
|
+
* to be dropped silently, so a scam check called with `text` instead of `message` ran on nothing and
|
|
16
|
+
* answered "no strong signs": the agent got a confident wrong answer instead of an error it can fix.
|
|
17
|
+
* Numeric strings are accepted for number fields and converted in place. Returns a message, or null.
|
|
18
|
+
*/
|
|
19
|
+
export declare function checkArgs(inputSchema: Json, args: Json): string | null;
|
|
13
20
|
export declare const TOOLS: Tool[];
|
|
14
21
|
interface Request {
|
|
15
22
|
jsonrpc: '2.0';
|
package/dist/mcp.js
CHANGED
|
@@ -7,11 +7,50 @@ import { createInterface } from 'node:readline';
|
|
|
7
7
|
import { Oculon, summarizeProvenance } from './index.js';
|
|
8
8
|
import { ONCHAIN_TOOLS, onchainEnabled } from './core/features.js';
|
|
9
9
|
import { availableKinds } from './modules/monitor.js';
|
|
10
|
-
export const SERVER_INFO = { name: 'oculon', version: '0.1.
|
|
10
|
+
export const SERVER_INFO = { name: 'oculon', version: '0.1.4' };
|
|
11
11
|
const SUPPORTED = ['2025-06-18', '2025-03-26', '2024-11-05'];
|
|
12
12
|
const str = (d) => ({ type: 'string', description: d });
|
|
13
13
|
const num = (d) => ({ type: 'number', description: d });
|
|
14
14
|
const schema = (props = {}, required = []) => ({ type: 'object', properties: props, required, additionalProperties: false });
|
|
15
|
+
/**
|
|
16
|
+
* Checks tool arguments against the tool's input schema before running it. A misspelled argument used
|
|
17
|
+
* to be dropped silently, so a scam check called with `text` instead of `message` ran on nothing and
|
|
18
|
+
* answered "no strong signs": the agent got a confident wrong answer instead of an error it can fix.
|
|
19
|
+
* Numeric strings are accepted for number fields and converted in place. Returns a message, or null.
|
|
20
|
+
*/
|
|
21
|
+
export function checkArgs(inputSchema, args) {
|
|
22
|
+
const props = (inputSchema.properties ?? {});
|
|
23
|
+
const required = (inputSchema.required ?? []);
|
|
24
|
+
const allowed = Object.keys(props);
|
|
25
|
+
if (inputSchema.additionalProperties === false) {
|
|
26
|
+
const unknown = Object.keys(args).filter((k) => !(k in props));
|
|
27
|
+
if (unknown.length)
|
|
28
|
+
return `unknown argument${unknown.length > 1 ? 's' : ''} ${unknown.map((k) => `"${k}"`).join(', ')}; this tool takes ${allowed.length ? allowed.map((k) => `"${k}"`).join(', ') : 'no arguments'}`;
|
|
29
|
+
}
|
|
30
|
+
for (const k of required) {
|
|
31
|
+
const v = args[k];
|
|
32
|
+
if (v === undefined || v === null || (typeof v === 'string' && !v.trim()))
|
|
33
|
+
return `missing required argument "${k}"`;
|
|
34
|
+
}
|
|
35
|
+
for (const [k, v] of Object.entries(args)) {
|
|
36
|
+
const p = props[k];
|
|
37
|
+
if (!p || v === undefined || v === null)
|
|
38
|
+
continue;
|
|
39
|
+
if (p.type === 'string' && typeof v !== 'string')
|
|
40
|
+
return `argument "${k}" must be a string`;
|
|
41
|
+
if (p.type === 'number' || p.type === 'integer') {
|
|
42
|
+
const n = typeof v === 'string' && v.trim() !== '' ? Number(v) : v;
|
|
43
|
+
if (typeof n !== 'number' || !Number.isFinite(n))
|
|
44
|
+
return `argument "${k}" must be a number`;
|
|
45
|
+
args[k] = n;
|
|
46
|
+
}
|
|
47
|
+
if (p.type === 'boolean' && typeof v !== 'boolean')
|
|
48
|
+
return `argument "${k}" must be true or false`;
|
|
49
|
+
if (Array.isArray(p.enum) && !p.enum.includes(v))
|
|
50
|
+
return `argument "${k}" must be one of ${p.enum.join(', ')}`;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
15
54
|
/** Module results go out as result + signals + a compact provenance summary (full per-request provenance is noisy). */
|
|
16
55
|
function compact(r) {
|
|
17
56
|
return { module: r.module, input: r.input, generatedAt: r.generatedAt, result: r.result, signals: r.signals, provenance: summarizeProvenance(r.provenance) };
|
|
@@ -600,8 +639,14 @@ export class McpServer {
|
|
|
600
639
|
const tool = (await this.allTools()).find((t) => t.name === name);
|
|
601
640
|
if (!tool)
|
|
602
641
|
return fail(-32602, `unknown tool: ${name}`);
|
|
642
|
+
const raw = msg.params?.arguments ?? {};
|
|
643
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
|
|
644
|
+
return reply({ content: [{ type: 'text', text: 'Error: arguments must be a JSON object' }], isError: true });
|
|
645
|
+
const bad = checkArgs(tool.inputSchema, raw);
|
|
646
|
+
if (bad)
|
|
647
|
+
return reply({ content: [{ type: 'text', text: `Error: ${bad}` }], isError: true });
|
|
603
648
|
try {
|
|
604
|
-
const args =
|
|
649
|
+
const args = raw;
|
|
605
650
|
if (this.opts.remote && name === 'oculon_monitor')
|
|
606
651
|
args.dry_run = true;
|
|
607
652
|
const out = await tool.run(this.o, args);
|
|
@@ -22,12 +22,14 @@ export async function contradictions(ctx, topicInput, opts = {}) {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
const pages = [];
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
// Pages are read in parallel: one at a time, a few slow sites pushed this past a minute and a half.
|
|
26
|
+
const picked = candidates.slice(0, opts.maxSources ?? 6);
|
|
27
|
+
const read = await Promise.all(picked.map((c) => readPage(ctx, c.url, 3500)));
|
|
28
|
+
read.forEach((p, i) => {
|
|
27
29
|
provenance.push(p.prov);
|
|
28
30
|
if (p.data && p.data.length > 400)
|
|
29
|
-
pages.push({ title:
|
|
30
|
-
}
|
|
31
|
+
pages.push({ title: picked[i].title, url: picked[i].url, text: p.data });
|
|
32
|
+
});
|
|
31
33
|
const result = { topic, sourcesRead: pages.map((p) => ({ title: p.title, url: p.url })), contradictions: [] };
|
|
32
34
|
if (pages.length < 2 || !availableProviders().length) {
|
|
33
35
|
if (!availableProviders().length)
|
package/dist/modules/lynx.js
CHANGED
|
@@ -39,7 +39,16 @@ async function pickSame(groups, fetchImpl) {
|
|
|
39
39
|
if (!availableProviders().length)
|
|
40
40
|
return null;
|
|
41
41
|
const out = groups.map(() => -1);
|
|
42
|
-
|
|
42
|
+
// Batches run three at a time: one after another they took over a minute for 40 markets.
|
|
43
|
+
const starts = [];
|
|
44
|
+
for (let s = 0; s < groups.length; s += 8)
|
|
45
|
+
starts.push(s);
|
|
46
|
+
let next = 0;
|
|
47
|
+
const worker = async () => { while (next < starts.length)
|
|
48
|
+
await runBatch(starts[next++]); };
|
|
49
|
+
await Promise.all([worker(), worker(), worker()]);
|
|
50
|
+
return out;
|
|
51
|
+
async function runBatch(start) {
|
|
43
52
|
const batch = groups.slice(start, start + 8);
|
|
44
53
|
try {
|
|
45
54
|
const r = await chat([
|
|
@@ -61,7 +70,6 @@ async function pickSame(groups, fetchImpl) {
|
|
|
61
70
|
// leave this batch unmatched
|
|
62
71
|
}
|
|
63
72
|
}
|
|
64
|
-
return out;
|
|
65
73
|
}
|
|
66
74
|
export async function lynx(ctx, opts = {}) {
|
|
67
75
|
const nowMs = ctx.now().getTime();
|
|
@@ -71,15 +79,13 @@ export async function lynx(ctx, opts = {}) {
|
|
|
71
79
|
const pool = (pm.data ?? []).filter((m) => !isSportsLine(m) && !isResolving(m, nowMs) && m.volume24h >= 20_000 && m.prices.length === 2).slice(0, opts.limit ?? 40);
|
|
72
80
|
// Per market: a loose shortlist from Kalshi, plus Manifold search results for the 12 highest-volume markets.
|
|
73
81
|
const groups = [];
|
|
82
|
+
const manifold = await Promise.all(pool.slice(0, 12).map((m) => { const term = searchTerm(m.question); return term ? manifoldSearch(ctx, term, 6) : null; }));
|
|
74
83
|
for (const [i, m] of pool.entries()) {
|
|
75
84
|
const options = ks.data ? shortlist(m.question, ks.data, 8) : [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
provenance.push(r.prov);
|
|
81
|
-
options.push(...(r.data ?? []));
|
|
82
|
-
}
|
|
85
|
+
const r = manifold[i];
|
|
86
|
+
if (r) {
|
|
87
|
+
provenance.push(r.prov);
|
|
88
|
+
options.push(...(r.data ?? []));
|
|
83
89
|
}
|
|
84
90
|
if (options.length)
|
|
85
91
|
groups.push({ pm: m, options });
|
package/dist/modules/owl.js
CHANGED
|
@@ -162,6 +162,9 @@ export async function owl(ctx, opts = {}) {
|
|
|
162
162
|
// Hacker News: front-page stories with unusual traction for their age.
|
|
163
163
|
if (hn.data) {
|
|
164
164
|
for (const s of hn.data) {
|
|
165
|
+
// Algolia sometimes returns hits without points or comment counts; those carry no traction signal.
|
|
166
|
+
if (!Number.isFinite(s.points) || !Number.isFinite(s.created_at_i))
|
|
167
|
+
continue;
|
|
165
168
|
const ageH = Math.max(1, (nowMs / 1000 - s.created_at_i) / 3600);
|
|
166
169
|
const velocity = s.points / ageH;
|
|
167
170
|
if (s.points < 150 && velocity < 40)
|
|
@@ -171,7 +174,7 @@ export async function owl(ctx, opts = {}) {
|
|
|
171
174
|
title: s.title,
|
|
172
175
|
url: hnItemUrl(s.objectID),
|
|
173
176
|
strength: clamp(Math.round(25 + 10 * Math.log2(Math.max(1, velocity))), 0, 85),
|
|
174
|
-
detail: `${s.points} points, ${s.num_comments} comments in ${ageH.toFixed(0)}h`,
|
|
177
|
+
detail: `${s.points} points, ${Number.isFinite(s.num_comments) ? s.num_comments : 0} comments in ${ageH.toFixed(0)}h`,
|
|
175
178
|
value: velocity,
|
|
176
179
|
}));
|
|
177
180
|
}
|
package/dist/modules/personal.js
CHANGED
|
@@ -84,7 +84,7 @@ export function emailStatus(ctx, owner) {
|
|
|
84
84
|
const EMAIL_RE = /^[^\s@<>"']{1,64}@[a-z0-9.-]+\.[a-z]{2,}$/i;
|
|
85
85
|
const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
86
86
|
function shell(title, body, footer) {
|
|
87
|
-
return `<!doctype html><html><body style="margin:0;background:#f4f6f6;padding:24px;font-family:-apple-system,Segoe UI,Helvetica,Arial,sans-serif;color:#111"><div style="max-width:560px;margin:0 auto;background:#fff;border:1px solid #e3e7e7;padding:28px"><div style="font:600 12px monospace;letter-spacing:.18em;color:#00838f"
|
|
87
|
+
return `<!doctype html><html><body style="margin:0;background:#f4f6f6;padding:24px;font-family:-apple-system,Segoe UI,Helvetica,Arial,sans-serif;color:#111"><div style="max-width:560px;margin:0 auto;background:#fff;border:1px solid #e3e7e7;padding:28px"><div style="font:600 12px monospace;letter-spacing:.18em;color:#00838f">OCULON</div><h1 style="font-size:20px;font-weight:600;margin:14px 0 16px">${title}</h1>${body}<p style="font-size:12px;color:#777;margin-top:28px;border-top:1px solid #eee;padding-top:14px">${footer}</p></div></body></html>`;
|
|
88
88
|
}
|
|
89
89
|
/** Saves the address and sends a confirmation link. Limited to one email per owner every 10 minutes. */
|
|
90
90
|
export async function requestEmail(ctx, owner, email, baseUrl) {
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
6
|
+
<meta name="theme-color" content="#000000">
|
|
7
|
+
<link rel="icon" type="image/png" href="/favicon.ico">
|
|
8
|
+
<link rel="apple-touch-icon" href="/assets/icon-192.png">
|
|
9
|
+
<title>Oculon Analyst</title>
|
|
10
|
+
<meta name="description" content="Ask a question; Oculon checks live public data, then answers with a brief: bottom line, confidence, cited findings, and a cross-examination by other models.">
|
|
11
|
+
<meta property="og:type" content="website"><meta property="og:site_name" content="Oculon"><meta property="og:title" content="Oculon Analyst"><meta property="og:description" content="Ask anything. It checks live public data first, then answers with a cited brief you can cross-examine."><meta property="og:image" content="https://oculon.live/assets/og.png?v=2"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="630"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:image" content="https://oculon.live/assets/og.png?v=2">
|
|
12
|
+
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
13
|
+
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
|
|
14
|
+
<style>
|
|
15
|
+
/* no sideways scrolling on phones: wide tables and code scroll inside their own boxes */
|
|
16
|
+
html,body{overflow-x:clip;max-width:100%}
|
|
17
|
+
.lm{display:inline-block;width:22px;height:22px;vertical-align:-4px;margin-right:12px}
|
|
18
|
+
:root{--bg:#000;--panel:rgba(5,9,10,.86);--line:#1c2629;--line2:#263438;--text:#f2f6f7;--soft:#c9d3d5;--mut:#8b9a9e;--dim:#56666a;--y:#00f0ff;--ok:#3ddc97;--warn:#ffc857;--bad:#ff5d6c;--sans:'Space Grotesk',system-ui,sans-serif;--mono:'Space Mono',ui-monospace,Consolas,monospace}
|
|
19
|
+
*{box-sizing:border-box}
|
|
20
|
+
body{margin:0;background:var(--bg);color:var(--text);font-family:var(--sans);-webkit-font-smoothing:antialiased;min-height:100vh}
|
|
21
|
+
a{color:inherit}
|
|
22
|
+
button{font:inherit;color:inherit}
|
|
23
|
+
#liquidbg{position:fixed;inset:0;width:100%;height:100%;z-index:0;pointer-events:none;opacity:.34}
|
|
24
|
+
header,main,.dock{position:relative;z-index:1}
|
|
25
|
+
header{position:sticky;top:0;z-index:20;background:#000;border-bottom:1px solid var(--line)}
|
|
26
|
+
header .in{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px clamp(16px,3vw,36px);max-width:1180px;margin:0 auto}
|
|
27
|
+
.logo{font-size:17px;font-weight:600;letter-spacing:.4em;text-decoration:none}
|
|
28
|
+
.logo span{color:var(--y);letter-spacing:.22em;font-weight:400;margin-left:8px}
|
|
29
|
+
header nav{display:flex;gap:20px;align-items:center;font-size:14px}
|
|
30
|
+
header nav a{text-decoration:none;color:var(--soft)}
|
|
31
|
+
header nav .btn{background:var(--y);color:#001418;padding:8px 13px;font-weight:600}
|
|
32
|
+
@media (max-width:560px){header nav .opt{display:none}}
|
|
33
|
+
.lbl{font:11.5px var(--mono);letter-spacing:.14em;text-transform:uppercase;color:var(--mut)}
|
|
34
|
+
main{max-width:880px;margin:0 auto;padding:40px clamp(16px,3vw,28px) 260px}
|
|
35
|
+
|
|
36
|
+
/* intro */
|
|
37
|
+
.intro h1{margin:14px 0 14px;font-size:clamp(36px,6.4vw,64px);font-weight:300;letter-spacing:-.04em;line-height:1.02}
|
|
38
|
+
.intro h1 em{font-style:normal;color:var(--y)}
|
|
39
|
+
.intro p{font-size:clamp(16px,2vw,19px);line-height:1.6;color:var(--soft);font-weight:300;max-width:660px;margin:0}
|
|
40
|
+
.how{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:30px 0 8px}
|
|
41
|
+
.how div{border:1px solid var(--line);background:var(--panel);padding:14px}
|
|
42
|
+
.how b{display:block;font:11px var(--mono);color:var(--y);letter-spacing:.12em;margin-bottom:6px}
|
|
43
|
+
.how span{font-size:14px;line-height:1.45;color:var(--soft)}
|
|
44
|
+
@media (max-width:720px){.how{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
45
|
+
.examples{display:flex;flex-wrap:wrap;gap:8px;margin-top:22px}
|
|
46
|
+
.chip{border:1px solid var(--line2);background:rgba(0,0,0,.55);padding:9px 12px;font-size:14px;color:var(--soft);cursor:pointer;text-align:left;line-height:1.35}
|
|
47
|
+
.chip:hover{border-color:var(--y);color:#fff}
|
|
48
|
+
|
|
49
|
+
/* thread */
|
|
50
|
+
.turn{margin-top:46px}
|
|
51
|
+
.q{display:flex;gap:12px;align-items:baseline;font-size:clamp(19px,2.6vw,24px);font-weight:400;line-height:1.35;letter-spacing:-.01em}
|
|
52
|
+
.q .lbl{flex:none;color:var(--y)}
|
|
53
|
+
.trace{margin-top:16px;border:1px solid var(--line);background:var(--panel);display:grid;grid-template-columns:118px minmax(0,1fr);gap:0}
|
|
54
|
+
.radar{border-right:1px solid var(--line);display:grid;place-items:center;padding:14px}
|
|
55
|
+
.radar svg{width:86px;height:86px}
|
|
56
|
+
.sweep{transform-origin:50px 50px;animation:sweep 2.4s linear infinite}
|
|
57
|
+
.trace.done .sweep{animation:none;opacity:0}
|
|
58
|
+
@keyframes sweep{to{transform:rotate(360deg)}}
|
|
59
|
+
.blip{fill:var(--y);opacity:0;animation:blip 1.6s ease-out forwards}
|
|
60
|
+
@keyframes blip{0%{opacity:1;r:4}100%{opacity:.55;r:2.2}}
|
|
61
|
+
.steps{list-style:none;margin:0;padding:10px 14px;min-width:0}
|
|
62
|
+
.steps li{display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:10px;align-items:baseline;padding:7px 0;border-bottom:1px dashed #152023;font-size:14px}
|
|
63
|
+
.steps li:last-child{border-bottom:0}
|
|
64
|
+
.steps .st{font:12px var(--mono);color:var(--mut)}
|
|
65
|
+
.steps .st.ok{color:var(--ok)}.steps .st.err{color:var(--bad)}
|
|
66
|
+
.steps .nm{color:#fff;overflow-wrap:anywhere}.steps .nm small{display:block;color:var(--dim);font:11.5px var(--mono);margin-top:2px;overflow-wrap:anywhere}
|
|
67
|
+
.steps .meta{font:11.5px var(--mono);color:var(--mut);white-space:nowrap}
|
|
68
|
+
.spin{display:inline-block;width:10px;height:10px;border:1.5px solid var(--y);border-right-color:transparent;border-radius:50%;animation:sp .8s linear infinite}
|
|
69
|
+
@keyframes sp{to{transform:rotate(360deg)}}
|
|
70
|
+
.thinking{padding:10px 14px;font:12px var(--mono);color:var(--mut)}
|
|
71
|
+
.thinking i{color:var(--y);font-style:normal}
|
|
72
|
+
@media (max-width:560px){.trace{grid-template-columns:1fr}.radar{border-right:0;border-bottom:1px solid var(--line);padding:10px}.radar svg{width:64px;height:64px}}
|
|
73
|
+
|
|
74
|
+
/* brief */
|
|
75
|
+
.brief{margin-top:14px;border:1px solid var(--line2);background:rgba(3,7,8,.92);position:relative}
|
|
76
|
+
.brief::before{content:'';position:absolute;left:-1px;top:-1px;width:56px;height:2px;background:var(--y)}
|
|
77
|
+
.bhead{display:flex;flex-wrap:wrap;gap:8px 16px;justify-content:space-between;padding:14px 20px;border-bottom:1px solid var(--line)}
|
|
78
|
+
.bbody{padding:20px}
|
|
79
|
+
.brief h2{margin:0 0 10px;font-size:clamp(22px,3.4vw,30px);font-weight:500;letter-spacing:-.02em;line-height:1.2}
|
|
80
|
+
.bl{font-size:clamp(17px,2.2vw,19px);line-height:1.6;color:var(--soft);margin:0}
|
|
81
|
+
.conf{display:grid;grid-template-columns:auto minmax(0,1fr);gap:6px 16px;align-items:center;margin:20px 0 4px;padding:14px 16px;border:1px solid var(--line);background:rgba(0,0,0,.5)}
|
|
82
|
+
.conf .num{font:700 30px var(--mono);line-height:1}
|
|
83
|
+
.conf .bar{height:6px;background:#11191b;position:relative;overflow:hidden}
|
|
84
|
+
.conf .bar i{position:absolute;inset:0 auto 0 0;width:0;transition:width 1s cubic-bezier(.2,.8,.2,1)}
|
|
85
|
+
.conf .why{grid-column:1/-1;font-size:14px;line-height:1.5;color:var(--mut);margin:4px 0 0}
|
|
86
|
+
.conf .lv{font:11.5px var(--mono);letter-spacing:.12em;text-transform:uppercase;margin-bottom:6px}
|
|
87
|
+
.sec{margin-top:22px}
|
|
88
|
+
.sec h3{font:11.5px var(--mono);letter-spacing:.14em;text-transform:uppercase;color:var(--mut);margin:0 0 10px;font-weight:400}
|
|
89
|
+
.findings{list-style:none;margin:0;padding:0;counter-reset:f}
|
|
90
|
+
.findings li{display:grid;grid-template-columns:30px minmax(0,1fr);gap:10px;padding:11px 0;border-top:1px solid #121b1d}
|
|
91
|
+
.findings li:first-child{border-top:0}
|
|
92
|
+
.findings .ix{font:12px var(--mono);color:var(--y);padding-top:3px}
|
|
93
|
+
.findings p{margin:0;font-size:16px;line-height:1.6;color:#e7eeef}
|
|
94
|
+
.cite{display:inline-block;font:11px var(--mono);color:var(--y);border:1px solid #0f3c40;background:#031416;padding:0 5px;margin-left:4px;cursor:pointer;vertical-align:1px;text-decoration:none}
|
|
95
|
+
.cite:hover{background:var(--y);color:#001418}
|
|
96
|
+
.verdicts{display:flex;flex-wrap:wrap;gap:6px;margin-top:7px}
|
|
97
|
+
.vd{font:11px var(--mono);padding:2px 7px;border:1px solid}
|
|
98
|
+
.vd.supported{color:var(--ok);border-color:#1d5a42}.vd.partly{color:var(--warn);border-color:#5d4a1c}.vd.unsupported{color:var(--bad);border-color:#5e2128}
|
|
99
|
+
.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}
|
|
100
|
+
.two>div{border:1px solid var(--line);padding:14px;background:rgba(0,0,0,.4)}
|
|
101
|
+
.two ul{margin:0;padding-left:18px}.two li,.two p{font-size:14.5px;line-height:1.55;color:var(--soft);margin:0 0 4px}
|
|
102
|
+
@media (max-width:640px){.two{grid-template-columns:1fr}}
|
|
103
|
+
.srcs{list-style:none;margin:0;padding:0}
|
|
104
|
+
.srcs li{display:grid;grid-template-columns:34px minmax(0,1fr) auto;gap:10px;align-items:baseline;padding:7px 6px;border-top:1px solid #121b1d;font-size:14px}
|
|
105
|
+
.srcs li.hl{background:#04262a;outline:1px solid var(--y)}
|
|
106
|
+
.srcs .n{font:12px var(--mono);color:var(--y)}
|
|
107
|
+
.srcs .t{overflow-wrap:anywhere;color:var(--soft)}.srcs .t a{color:#fff;text-decoration-color:var(--y);text-underline-offset:3px}
|
|
108
|
+
.srcs .t small{color:var(--dim);font:11.5px var(--mono);margin-left:6px}
|
|
109
|
+
.pill{font:10.5px var(--mono);letter-spacing:.08em;padding:1px 6px;border:1px solid var(--line2);color:var(--mut);white-space:nowrap}
|
|
110
|
+
.pill.LIVE{color:var(--ok);border-color:#1d5a42}.pill.CACHED{color:var(--y);border-color:#0f3c40}.pill.ERROR,.pill.UNAVAILABLE{color:var(--bad);border-color:#5e2128}
|
|
111
|
+
.more{background:none;border:0;color:var(--mut);font:12px var(--mono);cursor:pointer;padding:8px 6px}
|
|
112
|
+
.actions{display:flex;flex-wrap:wrap;gap:8px;padding:16px 20px;border-top:1px solid var(--line)}
|
|
113
|
+
.act{border:1px solid var(--line2);background:#000;padding:10px 14px;font-size:14px;cursor:pointer;color:#fff}
|
|
114
|
+
.act:hover{border-color:var(--y)}
|
|
115
|
+
.act.primary{background:var(--y);color:#001418;border-color:var(--y);font-weight:600}
|
|
116
|
+
.act[disabled]{opacity:.55;cursor:default}
|
|
117
|
+
.review{margin:0 20px 18px;border:1px solid var(--line);padding:14px 16px;background:rgba(0,0,0,.45)}
|
|
118
|
+
.review p{margin:4px 0;font-size:14.5px;line-height:1.55;color:var(--soft)}
|
|
119
|
+
.review b{color:#fff;font-weight:500}
|
|
120
|
+
.follow{display:flex;flex-wrap:wrap;gap:8px;padding:0 20px 20px}
|
|
121
|
+
.plan{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:12px 14px 4px}
|
|
122
|
+
.plan .lbl{color:var(--y);margin-right:4px}
|
|
123
|
+
.plan .part{display:inline-flex;align-items:baseline;gap:6px;border:1px solid var(--line2);padding:3px 8px;font-size:13px;color:var(--soft);line-height:1.35}
|
|
124
|
+
.plan .part b{font:11px var(--mono);color:var(--y)}
|
|
125
|
+
.details{margin-top:16px;padding:14px 16px;border-left:2px solid var(--y);background:rgba(0,240,255,.03)}
|
|
126
|
+
.details p,.details li{font-size:15.5px;line-height:1.65;color:#dfe8e9;margin:0 0 8px}
|
|
127
|
+
.details ul{margin:0 0 8px;padding-left:20px}
|
|
128
|
+
.details p:last-child,.details ul:last-child{margin-bottom:0}
|
|
129
|
+
.err{margin-top:14px;border:1px solid #5e2128;background:#140507;padding:14px 16px;color:#ffc9ce;font-size:15px;line-height:1.5}
|
|
130
|
+
|
|
131
|
+
/* dock */
|
|
132
|
+
.dock{position:fixed;left:0;right:0;bottom:0;z-index:30;background:linear-gradient(180deg,transparent,#000 22%);padding:26px clamp(12px,3vw,28px) calc(14px + env(safe-area-inset-bottom))}
|
|
133
|
+
.dock .in{max-width:880px;margin:0 auto}
|
|
134
|
+
.models{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin-bottom:8px;max-width:560px}
|
|
135
|
+
.model{border:1px solid var(--line2);background:rgba(0,0,0,.8);padding:7px 10px;cursor:pointer;text-align:left;line-height:1.2;min-width:0}
|
|
136
|
+
.model b{display:block;font-size:13.5px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
137
|
+
@media (max-width:480px){.model{padding:6px 8px}.model b{font-size:12.5px}.model small{font-size:9.5px}.dock{padding-top:18px}}
|
|
138
|
+
.model small{font:10.5px var(--mono);color:var(--mut);letter-spacing:.06em;text-transform:uppercase}
|
|
139
|
+
.model[aria-pressed="true"]{border-color:var(--y);background:#021a1d}
|
|
140
|
+
.model[aria-pressed="true"] small{color:var(--y)}
|
|
141
|
+
.box{display:flex;align-items:flex-end;gap:8px;border:1px solid var(--y);background:#020b0c;padding:8px 8px 8px 14px;box-shadow:0 0 0 4px rgba(0,240,255,.06)}
|
|
142
|
+
.box .pr{font:13px var(--mono);color:var(--y);padding-bottom:9px}
|
|
143
|
+
.box textarea{flex:1;min-width:0;resize:none;border:0;outline:0;background:transparent;color:#fff;font:16px/1.5 var(--sans);max-height:160px;padding:6px 0}
|
|
144
|
+
.box textarea::placeholder{color:var(--dim)}
|
|
145
|
+
.send{background:var(--y);color:#001418;border:0;padding:10px 16px;font-weight:600;cursor:pointer}
|
|
146
|
+
.send[disabled]{opacity:.5;cursor:default}
|
|
147
|
+
.dockfoot{display:flex;justify-content:space-between;gap:10px;margin-top:7px;font:11px var(--mono);color:var(--dim)}
|
|
148
|
+
.dockfoot button{background:none;border:0;color:var(--mut);font:11px var(--mono);cursor:pointer;padding:0}
|
|
149
|
+
</style>
|
|
150
|
+
</head>
|
|
151
|
+
<body>
|
|
152
|
+
<canvas id="liquidbg" aria-hidden="true"></canvas>
|
|
153
|
+
<header><div class="in"><a class="logo" href="/"><img class="lm" src="/assets/logo.svg" alt="" width="22" height="22">OCULON<span>ANALYST</span></a><nav><a class="opt" href="/docs">Docs</a><a class="opt" href="/mcp">MCP</a><a class="btn" href="/app">Open app</a></nav></div></header>
|
|
154
|
+
<main>
|
|
155
|
+
<section class="intro" id="intro">
|
|
156
|
+
<div class="lbl"><span style="color:var(--y)">●</span> Analyst desk · checks live public data before it answers</div>
|
|
157
|
+
<h1>Ask anything.<br>Get a <em>brief</em>, not a guess.</h1>
|
|
158
|
+
<p>About Oculon, about the world, or anything else. It splits your question into parts, checks each one against live sources (outages, vulnerabilities, quakes, flights, scams, papers, news) or searches and reads the web, then writes a brief: the bottom line, how sure it is, each finding with its source, and what it could not see. Then let other models cross-examine it.</p>
|
|
159
|
+
<div class="how">
|
|
160
|
+
<div><b>01 · CHECK</b><span>Live tools run first; you watch every source it touches.</span></div>
|
|
161
|
+
<div><b>02 · BRIEF</b><span>Bottom line, confidence 0-100 and numbered citations.</span></div>
|
|
162
|
+
<div><b>03 · CROSS-EXAMINE</b><span>Two other models judge each finding against the same evidence.</span></div>
|
|
163
|
+
<div><b>04 · WATCH</b><span>Turn any answer into a monitor that tells you when it changes.</span></div>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="examples" id="examples">
|
|
166
|
+
<button class="chip" type="button">Is there an internet outage in Iran right now?</button>
|
|
167
|
+
<button class="chip" type="button">Is paypa1-secure-login.top safe to open?</button>
|
|
168
|
+
<button class="chip" type="button">Any critical CVEs for nginx this month?</button>
|
|
169
|
+
<button class="chip" type="button">What is the travel risk for Bangkok this week?</button>
|
|
170
|
+
<button class="chip" type="button">Is this a scam: "Your package is on hold, pay the $1.99 customs fee today"</button>
|
|
171
|
+
<button class="chip" type="button">Were there strong earthquakes near Japan in the last 48 hours?</button>
|
|
172
|
+
<button class="chip" type="button">How do I connect Oculon to Claude, and what can it do there?</button>
|
|
173
|
+
<button class="chip" type="button">What caused the 2003 Northeast blackout, and could it happen again?</button>
|
|
174
|
+
</div>
|
|
175
|
+
</section>
|
|
176
|
+
<div id="thread"></div>
|
|
177
|
+
</main>
|
|
178
|
+
<div class="dock">
|
|
179
|
+
<div class="in">
|
|
180
|
+
<div class="models" id="models" role="group" aria-label="Model">
|
|
181
|
+
<button class="model" type="button" data-m="haiku" aria-pressed="true"><b>Haiku 5.5</b><small>fast</small></button>
|
|
182
|
+
<button class="model" type="button" data-m="opus" aria-pressed="false"><b>Opus 5.5</b><small>thorough</small></button>
|
|
183
|
+
<button class="model" type="button" data-m="gpt" aria-pressed="false"><b>GPT-6.2 Astra</b><small>second view</small></button>
|
|
184
|
+
</div>
|
|
185
|
+
<form class="box" id="form"><span class="pr">></span><textarea id="q" rows="1" maxlength="600" placeholder="Ask about an event, a link, a place, a vulnerability, a message…" aria-label="Your question"></textarea><button class="send" id="send" type="submit">Ask</button></form>
|
|
186
|
+
<div class="dockfoot"><span id="hint">Enter to ask · Shift+Enter for a new line</span><button type="button" id="clear">New session</button></div>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
<script src="/assets/fx.js"></script>
|
|
190
|
+
<script>
|
|
191
|
+
if (window.OculonFX) { try { OculonFX.liquid(document.getElementById('liquidbg'), { base: '#000000', mid: '#001a26', hi: '#00c8e0', intensity: 0.8, scale: 0.3 }); } catch {} }
|
|
192
|
+
const $ = (id) => document.getElementById(id);
|
|
193
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
194
|
+
const MODELS = { haiku: 'Claude Haiku 5.5', opus: 'Claude Opus 5.5', gpt: 'GPT-6.2 Astra' };
|
|
195
|
+
const store = { get(k, d) { try { const v = localStorage.getItem(k); return v ? JSON.parse(v) : d; } catch { return d; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch {} } };
|
|
196
|
+
let model = store.get('oculon.analyst.model', 'haiku');
|
|
197
|
+
let turns = store.get('oculon.analyst.turns', []);
|
|
198
|
+
let busy = false;
|
|
199
|
+
|
|
200
|
+
/* model picker */
|
|
201
|
+
const pick = (m) => { model = MODELS[m] ? m : 'haiku'; store.set('oculon.analyst.model', model); document.querySelectorAll('.model').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.m === model))); };
|
|
202
|
+
document.querySelectorAll('.model').forEach((b) => b.addEventListener('click', () => pick(b.dataset.m)));
|
|
203
|
+
pick(model);
|
|
204
|
+
|
|
205
|
+
/* composer */
|
|
206
|
+
const q = $('q');
|
|
207
|
+
const grow = () => { q.style.height = 'auto'; q.style.height = Math.min(160, q.scrollHeight) + 'px'; };
|
|
208
|
+
q.addEventListener('input', grow);
|
|
209
|
+
q.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); $('form').requestSubmit(); } });
|
|
210
|
+
$('form').addEventListener('submit', (e) => { e.preventDefault(); const text = q.value.trim(); if (text.length >= 3 && !busy) { q.value = ''; grow(); askQuestion(text); } });
|
|
211
|
+
$('examples').addEventListener('click', (e) => { const c = e.target.closest('.chip'); if (c && !busy) askQuestion(c.textContent.trim()); });
|
|
212
|
+
$('clear').addEventListener('click', () => { if (busy) return; turns = []; store.set('oculon.analyst.turns', turns); $('thread').innerHTML = ''; $('intro').hidden = false; scrollTo({ top: 0, behavior: 'smooth' }); });
|
|
213
|
+
|
|
214
|
+
/* radar: a sweep, and a blip for every source found */
|
|
215
|
+
const radarSvg = () => `<svg viewBox="0 0 100 100" aria-hidden="true"><defs><linearGradient id="sw" x1="0" x2="1"><stop offset="0" stop-color="#00f0ff" stop-opacity="0"/><stop offset="1" stop-color="#00f0ff" stop-opacity=".55"/></linearGradient></defs>
|
|
216
|
+
<circle cx="50" cy="50" r="46" fill="none" stroke="#1c2629"/><circle cx="50" cy="50" r="30" fill="none" stroke="#162023"/><circle cx="50" cy="50" r="14" fill="none" stroke="#162023"/>
|
|
217
|
+
<line x1="4" y1="50" x2="96" y2="50" stroke="#121a1c"/><line x1="50" y1="4" x2="50" y2="96" stroke="#121a1c"/>
|
|
218
|
+
<path class="sweep" d="M50 50 L50 4 A46 46 0 0 1 89.8 27 Z" fill="url(#sw)"/><g class="blips"></g><circle cx="50" cy="50" r="2" fill="#00f0ff"/></svg>`;
|
|
219
|
+
const addBlip = (svg, i) => { const a = (i * 137.5) * Math.PI / 180, r = 12 + ((i * 29) % 32); const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); c.setAttribute('cx', (50 + r * Math.cos(a)).toFixed(1)); c.setAttribute('cy', (50 + r * Math.sin(a)).toFixed(1)); c.setAttribute('r', '3'); c.setAttribute('class', 'blip'); svg.querySelector('.blips').appendChild(c); };
|
|
220
|
+
|
|
221
|
+
const level = (c) => c >= 75 ? ['High', 'var(--ok)'] : c >= 45 ? ['Moderate', 'var(--warn)'] : ['Low', 'var(--bad)'];
|
|
222
|
+
/* the analyst's plan: the parts it split the question into */
|
|
223
|
+
const planHtml = (parts) => parts && parts.length ? `<div class="plan"><span class="lbl">Plan</span>${parts.map((p, i) => `<span class="part"><b>${i + 1}</b>${esc(p)}</span>`).join('')}</div>` : '';
|
|
224
|
+
/* details: short paragraphs and "- " bullets, with [n] citations made clickable */
|
|
225
|
+
function detailsHtml(text) {
|
|
226
|
+
const cite = (s) => esc(s).replace(/\[(\d{1,3})\]/g, (_, n) => `<a class="cite" data-n="${n}" href="#">${n}</a>`);
|
|
227
|
+
const out = []; let list = [];
|
|
228
|
+
const flush = () => { if (list.length) { out.push(`<ul>${list.map((l) => `<li>${cite(l)}</li>`).join('')}</ul>`); list = []; } };
|
|
229
|
+
for (const line of String(text).split(/\n+/)) {
|
|
230
|
+
const l = line.trim(); if (!l) continue;
|
|
231
|
+
if (/^[-*•]\s+/.test(l) || /^\d+[.)]\s+/.test(l)) list.push(l.replace(/^([-*•]|\d+[.)])\s+/, ''));
|
|
232
|
+
else { flush(); out.push(`<p>${cite(l)}</p>`); }
|
|
233
|
+
}
|
|
234
|
+
flush();
|
|
235
|
+
return out.join('');
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* one brief */
|
|
239
|
+
function renderBrief(t) {
|
|
240
|
+
const b = t.brief, src = t.sources || [];
|
|
241
|
+
const [lv, color] = level(b.confidence);
|
|
242
|
+
const live = src.filter((s) => s.status === 'LIVE').length;
|
|
243
|
+
const cites = (ns) => (ns || []).map((n) => `<a class="cite" data-n="${n}" href="#">${n}</a>`).join('');
|
|
244
|
+
const srcRow = (s) => `<li data-n="${s.n}"><span class="n">[${s.n}]</span><span class="t">${s.url ? `<a href="${esc(s.url)}" target="_blank" rel="noopener">${esc(s.label)}</a>` : esc(s.label)}<small>${esc(s.kind === 'feed' ? 'data feed' : s.host || '')}</small></span>${s.status ? `<span class="pill ${esc(s.status)}">${esc(s.status)}</span>` : '<span></span>'}</li>`;
|
|
245
|
+
const cited = new Set(b.findings.flatMap((f) => f.sources));
|
|
246
|
+
const first = src.filter((s) => cited.has(s.n)), rest = src.filter((s) => !cited.has(s.n));
|
|
247
|
+
const others = Object.keys(MODELS).filter((m) => m !== t.model).map((m) => MODELS[m]).join(' + ');
|
|
248
|
+
return `<article class="brief" data-id="${esc(t.id)}">
|
|
249
|
+
<div class="bhead"><span class="lbl">Brief · ${esc(MODELS[t.model] || t.model)}</span><span class="lbl">${src.length} sources · ${live} live · ${Math.round((t.ms || 0) / 1000)}s</span></div>
|
|
250
|
+
<div class="bbody">
|
|
251
|
+
${b.headline ? `<h2>${esc(b.headline)}</h2>` : ''}
|
|
252
|
+
<p class="bl">${esc(b.bottomLine)}</p>
|
|
253
|
+
${b.details ? `<div class="details">${detailsHtml(b.details)}</div>` : ''}
|
|
254
|
+
<div class="conf"><div class="num" style="color:${color}">${b.confidence}</div><div><div class="lv" style="color:${color}">${lv} confidence</div><div class="bar"><i style="background:${color}" data-w="${b.confidence}"></i></div></div>${b.confidenceWhy ? `<p class="why">${esc(b.confidenceWhy)}</p>` : ''}</div>
|
|
255
|
+
${b.findings.length ? `<div class="sec"><h3>Findings</h3><ol class="findings">${b.findings.map((f, i) => `<li data-i="${i}"><span class="ix">${String(i + 1).padStart(2, '0')}</span><div><p>${esc(f.text)}${cites(f.sources)}</p><div class="verdicts"></div></div></li>`).join('')}</ol></div>` : ''}
|
|
256
|
+
${b.unknowns.length || b.changeMyMind ? `<div class="sec two">${b.unknowns.length ? `<div><h3 class="lbl" style="margin:0 0 8px">Not known yet</h3><ul>${b.unknowns.map((u) => `<li>${esc(u)}</li>`).join('')}</ul></div>` : ''}${b.changeMyMind ? `<div><h3 class="lbl" style="margin:0 0 8px">Would change this</h3><p>${esc(b.changeMyMind)}</p></div>` : ''}</div>` : ''}
|
|
257
|
+
${src.length ? `<div class="sec"><h3>Sources</h3><ol class="srcs">${first.map(srcRow).join('')}${rest.length ? `<li class="restwrap" style="display:block;border:0;padding:0"><button class="more" type="button">+ ${rest.length} more checked</button><ol class="srcs rest" hidden>${rest.map(srcRow).join('')}</ol></li>` : ''}</ol></div>` : ''}
|
|
258
|
+
</div>
|
|
259
|
+
<div class="actions">
|
|
260
|
+
${b.findings.length ? `<button class="act primary" type="button" data-act="review">Cross-examine with ${esc(others)}</button>` : ''}
|
|
261
|
+
${b.watch ? `<button class="act" type="button" data-act="watch" data-text="${esc(b.watch)}">Watch: ${esc(b.watch)}</button>` : ''}
|
|
262
|
+
<button class="act" type="button" data-act="copy">Copy brief</button>
|
|
263
|
+
</div>
|
|
264
|
+
<div class="reviewbox"></div>
|
|
265
|
+
${b.followUps.length ? `<div class="follow">${b.followUps.map((f) => `<button class="chip" type="button" data-follow>${esc(f)}</button>`).join('')}</div>` : ''}
|
|
266
|
+
</article>`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function renderReview(card, data) {
|
|
270
|
+
const lines = [];
|
|
271
|
+
for (const r of data.reviews) {
|
|
272
|
+
if (r.error) { lines.push(`<p><b>${esc(r.label)}</b>: could not review (${esc(r.error)})</p>`); continue; }
|
|
273
|
+
lines.push(`<p><b>${esc(r.label)}</b> ${r.bottomLine === 'agree' ? 'agrees with the bottom line' : r.bottomLine === 'disagree' ? 'disagrees with the bottom line' : 'partly agrees with the bottom line'}${r.missed ? `. Missed: ${esc(r.missed)}` : '.'}</p>`);
|
|
274
|
+
for (const f of r.findings) {
|
|
275
|
+
const box = card.querySelector(`.findings li[data-i="${f.i}"] .verdicts`);
|
|
276
|
+
if (box) box.insertAdjacentHTML('beforeend', `<span class="vd ${esc(f.verdict)}" title="${esc(f.note)}">${esc(r.label.replace(/^Claude /, ''))}: ${esc(f.verdict)}</span>`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const all = data.reviews.flatMap((r) => r.findings);
|
|
280
|
+
const ok = all.filter((f) => f.verdict === 'supported').length;
|
|
281
|
+
card.querySelector('.reviewbox').innerHTML = `<div class="review"><div class="lbl" style="margin-bottom:6px">Cross-examination · ${ok}/${all.length} finding checks supported</div>${lines.join('')}</div>`;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function wireCard(card, t) {
|
|
285
|
+
card.querySelectorAll('.bar i').forEach((i) => requestAnimationFrame(() => { i.style.width = i.dataset.w + '%'; }));
|
|
286
|
+
card.addEventListener('click', async (e) => {
|
|
287
|
+
const c = e.target.closest('.cite');
|
|
288
|
+
if (c) {
|
|
289
|
+
e.preventDefault();
|
|
290
|
+
const rest = card.querySelector('.rest'); const row = card.querySelector(`.srcs li[data-n="${c.dataset.n}"]`);
|
|
291
|
+
if (row && rest && rest.contains(row)) { rest.hidden = false; card.querySelector('.more')?.remove(); }
|
|
292
|
+
card.querySelectorAll('.srcs li.hl').forEach((x) => x.classList.remove('hl'));
|
|
293
|
+
if (row) { row.classList.add('hl'); row.scrollIntoView({ behavior: 'smooth', block: 'center' }); setTimeout(() => row.classList.remove('hl'), 2400); }
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (e.target.closest('.more')) { card.querySelector('.rest').hidden = false; e.target.closest('.more').remove(); return; }
|
|
297
|
+
const f = e.target.closest('[data-follow]');
|
|
298
|
+
if (f && !busy) { askQuestion(f.textContent.trim()); return; }
|
|
299
|
+
const a = e.target.closest('[data-act]');
|
|
300
|
+
if (!a || a.disabled) return;
|
|
301
|
+
if (a.dataset.act === 'copy') {
|
|
302
|
+
const b = t.brief;
|
|
303
|
+
const text = [b.headline, '', b.bottomLine, ...(b.details ? ['', b.details] : []), '', `Confidence: ${b.confidence}/100 (${b.confidenceWhy})`, '', ...b.findings.map((f, i) => `${i + 1}. ${f.text} [${f.sources.join(', ')}]`), '', 'Sources:', ...(t.sources || []).map((s) => `[${s.n}] ${s.label}${s.url ? ' ' + s.url : ''}`), '', 'Oculon Analyst'].join('\n');
|
|
304
|
+
try { await navigator.clipboard.writeText(text); a.textContent = 'Copied'; } catch { a.textContent = 'Copy failed'; }
|
|
305
|
+
setTimeout(() => { a.textContent = 'Copy brief'; }, 1600);
|
|
306
|
+
}
|
|
307
|
+
if (a.dataset.act === 'review') {
|
|
308
|
+
a.disabled = true; a.innerHTML = '<span class="spin"></span> Cross-examining…';
|
|
309
|
+
try {
|
|
310
|
+
const r = await fetch('/api/analyst/review', { method: 'POST', headers: { 'content-type': 'application/json', 'x-oculon': '1' }, body: JSON.stringify({ id: t.id }) });
|
|
311
|
+
const j = await r.json();
|
|
312
|
+
if (!r.ok) throw new Error(j.error || `HTTP ${r.status}`);
|
|
313
|
+
t.review = j; save(); renderReview(card, j); a.remove();
|
|
314
|
+
} catch (err) { a.disabled = false; a.textContent = 'Cross-examine again'; card.querySelector('.reviewbox').innerHTML = `<div class="review"><p>${esc(err.message)}</p></div>`; }
|
|
315
|
+
}
|
|
316
|
+
if (a.dataset.act === 'watch') {
|
|
317
|
+
a.disabled = true;
|
|
318
|
+
try {
|
|
319
|
+
const r = await fetch('/api/my/monitors', { method: 'POST', headers: { 'content-type': 'application/json', 'x-oculon': '1' }, body: JSON.stringify({ text: a.dataset.text }) });
|
|
320
|
+
const j = await r.json();
|
|
321
|
+
if (!r.ok) throw new Error(j.error || `HTTP ${r.status}`);
|
|
322
|
+
a.outerHTML = `<a class="act" href="/app#watch">Watching. Open your monitors →</a>`;
|
|
323
|
+
} catch (err) { a.disabled = false; a.textContent = `Could not watch: ${err.message}`; }
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function save() { store.set('oculon.analyst.turns', turns.slice(-20)); }
|
|
329
|
+
|
|
330
|
+
function renderTurn(t) {
|
|
331
|
+
const el = document.createElement('section');
|
|
332
|
+
el.className = 'turn';
|
|
333
|
+
el.innerHTML = `<div class="q"><span class="lbl">Q</span><span>${esc(t.question)}</span></div>
|
|
334
|
+
<div class="trace done"><div class="radar">${radarSvg()}</div><div>${planHtml(t.plan)}<ul class="steps">${(t.steps || []).map((s) => `<li><span class="st ${s.ok ? 'ok' : 'err'}">${s.ok ? '✓' : '✕'}</span><span class="nm">${esc(s.label)}</span><span class="meta">${(s.ms / 1000).toFixed(1)}s</span></li>`).join('') || '<li><span class="st">·</span><span class="nm">No tools were needed</span><span></span></li>'}</ul></div></div>
|
|
335
|
+
${renderBrief(t)}`;
|
|
336
|
+
$('thread').appendChild(el);
|
|
337
|
+
el.querySelectorAll('.radar svg').forEach((svg) => (t.sources || []).forEach((_, i) => i < 24 && addBlip(svg, i)));
|
|
338
|
+
const card = el.querySelector('.brief');
|
|
339
|
+
wireCard(card, t);
|
|
340
|
+
if (t.review) renderReview(card, t.review);
|
|
341
|
+
return el;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
async function askQuestion(question) {
|
|
345
|
+
busy = true; $('send').disabled = true; $('intro').hidden = true;
|
|
346
|
+
const el = document.createElement('section');
|
|
347
|
+
el.className = 'turn';
|
|
348
|
+
el.innerHTML = `<div class="q"><span class="lbl">Q</span><span>${esc(question)}</span></div><div class="trace"><div class="radar">${radarSvg()}</div><div><div class="planbox"></div><ul class="steps"></ul><div class="thinking"><span class="spin"></span> <i>${esc(MODELS[model])}</i> is reading the question and choosing sources…</div></div></div>`;
|
|
349
|
+
$('thread').appendChild(el);
|
|
350
|
+
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
351
|
+
const steps = el.querySelector('.steps'), svg = el.querySelector('.radar svg'), thinking = el.querySelector('.thinking');
|
|
352
|
+
let blips = 0;
|
|
353
|
+
let plan = null;
|
|
354
|
+
const history = turns.slice(-4).map((t) => ({ q: t.question, a: t.brief?.bottomLine || '' }));
|
|
355
|
+
const fail = (msg) => { el.querySelector('.trace').classList.add('done'); thinking.remove(); el.insertAdjacentHTML('beforeend', `<div class="err">${esc(msg)}</div>`); };
|
|
356
|
+
try {
|
|
357
|
+
const res = await fetch('/api/analyst', { method: 'POST', headers: { 'content-type': 'application/json', 'x-oculon': '1' }, body: JSON.stringify({ q: question, model, history }) });
|
|
358
|
+
if (!res.ok || !res.body) { let m = `HTTP ${res.status}`; try { m = (await res.json()).error || m; } catch {} throw new Error(m); }
|
|
359
|
+
const reader = res.body.getReader(); const dec = new TextDecoder(); let buf = ''; let done = false;
|
|
360
|
+
while (!done) {
|
|
361
|
+
const { value, done: end } = await reader.read();
|
|
362
|
+
if (end) break;
|
|
363
|
+
buf += dec.decode(value, { stream: true });
|
|
364
|
+
let k;
|
|
365
|
+
while ((k = buf.indexOf('\n\n')) >= 0) {
|
|
366
|
+
const chunk = buf.slice(0, k); buf = buf.slice(k + 2);
|
|
367
|
+
const line = chunk.split('\n').find((l) => l.startsWith('data: '));
|
|
368
|
+
if (!line) continue;
|
|
369
|
+
let ev; try { ev = JSON.parse(line.slice(6)); } catch { continue; }
|
|
370
|
+
if (ev.type === 'plan') {
|
|
371
|
+
plan = ev.parts;
|
|
372
|
+
el.querySelector('.planbox').innerHTML = planHtml(plan);
|
|
373
|
+
} else if (ev.type === 'step') {
|
|
374
|
+
thinking.innerHTML = `<span class="spin"></span> checking sources…`;
|
|
375
|
+
steps.insertAdjacentHTML('beforeend', `<li data-id="${esc(ev.id)}"><span class="st"><span class="spin"></span></span><span class="nm">${esc(ev.label)}<small>${esc(ev.args)}</small></span><span class="meta">…</span></li>`);
|
|
376
|
+
} else if (ev.type === 'stepdone') {
|
|
377
|
+
const li = steps.querySelector(`li[data-id="${CSS.escape(ev.id)}"]`);
|
|
378
|
+
if (li) {
|
|
379
|
+
const live = ev.sources.filter((s) => s.status === 'LIVE').length;
|
|
380
|
+
li.querySelector('.st').outerHTML = `<span class="st ${ev.ok ? 'ok' : 'err'}">${ev.ok ? '✓' : '✕'}</span>`;
|
|
381
|
+
li.querySelector('.meta').textContent = `${(ev.ms / 1000).toFixed(1)}s · ${ev.sources.length} src${live ? ` · ${live} live` : ''}`;
|
|
382
|
+
}
|
|
383
|
+
for (const _ of ev.sources) if (blips < 24) addBlip(svg, blips++);
|
|
384
|
+
thinking.innerHTML = `<span class="spin"></span> <i>${esc(MODELS[model])}</i> is weighing the evidence…`;
|
|
385
|
+
} else if (ev.type === 'brief') {
|
|
386
|
+
const t = { id: ev.id, question, model: ev.model, brief: ev.brief, sources: ev.sources, steps: ev.steps, ms: ev.ms, plan };
|
|
387
|
+
turns.push(t); save();
|
|
388
|
+
el.remove();
|
|
389
|
+
renderTurn(t).scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
390
|
+
done = true;
|
|
391
|
+
} else if (ev.type === 'error') {
|
|
392
|
+
fail(`The analyst could not finish: ${ev.message}`); done = true;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (!done) fail('The connection closed before the brief was ready. Try again.');
|
|
397
|
+
} catch (e) {
|
|
398
|
+
fail(e.message || 'Something went wrong.');
|
|
399
|
+
} finally {
|
|
400
|
+
busy = false; $('send').disabled = false; q.focus({ preventScroll: true });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/* restore this viewer's session */
|
|
405
|
+
if (turns.length) { $('intro').hidden = true; turns.forEach(renderTurn); }
|
|
406
|
+
const pre = new URLSearchParams(location.search).get('q');
|
|
407
|
+
if (pre) { history.replaceState(null, '', location.pathname); askQuestion(pre.slice(0, 600)); }
|
|
408
|
+
</script>
|
|
409
|
+
</body>
|
|
410
|
+
</html>
|
|
Binary file
|