counterparts 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/CONSTITUTION.md +68 -0
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/docs/ELI5.md +84 -0
- package/docs/QUICKSTART.md +1258 -0
- package/docs/module-map.md +81 -0
- package/package.json +63 -0
- package/src/adapters/claude-code/CONTRACT.md +606 -0
- package/src/adapters/claude-code/INTERFACE-GAPS.md +655 -0
- package/src/adapters/claude-code/NOTES.md +1055 -0
- package/src/adapters/claude-code/bin/hook.ts +820 -0
- package/src/adapters/claude-code/bin/runner.ts +522 -0
- package/src/adapters/claude-code/config.ts +778 -0
- package/src/adapters/claude-code/credentials.ts +199 -0
- package/src/adapters/claude-code/doctor.ts +2557 -0
- package/src/adapters/claude-code/embed-client.ts +617 -0
- package/src/adapters/claude-code/hooks.ts +2240 -0
- package/src/adapters/claude-code/index.ts +224 -0
- package/src/adapters/claude-code/interpret-client.ts +395 -0
- package/src/adapters/claude-code/page-writer.ts +462 -0
- package/src/adapters/claude-code/primacy.ts +162 -0
- package/src/adapters/claude-code/spawn.ts +241 -0
- package/src/adapters/claude-code/standdown.ts +536 -0
- package/src/adapters/claude-code/transcript.ts +661 -0
- package/src/adapters/claude-code/vectors.ts +415 -0
- package/src/adapters/cli/CONTRACT.md +255 -0
- package/src/adapters/cli/INTERFACE-GAPS.md +350 -0
- package/src/adapters/cli/NOTES.md +936 -0
- package/src/adapters/cli/bin/counterparts.ts +74 -0
- package/src/adapters/cli/commands.ts +6095 -0
- package/src/adapters/cli/export.ts +766 -0
- package/src/adapters/cli/index.ts +103 -0
- package/src/adapters/cli/install.ts +670 -0
- package/src/adapters/cli/removal.ts +1186 -0
- package/src/adapters/cli/repair-dates.ts +659 -0
- package/src/adapters/cli/self-page.ts +229 -0
- package/src/adapters/cli/snapshot.ts +279 -0
- package/src/adapters/cli/start-fresh.ts +1228 -0
- package/src/adapters/config-path.ts +342 -0
- package/src/adapters/dashboard/CONTRACT.md +67 -0
- package/src/adapters/dashboard/INTERFACE-GAPS.md +139 -0
- package/src/adapters/dashboard/NOTES.md +474 -0
- package/src/adapters/dashboard/activity.ts +121 -0
- package/src/adapters/dashboard/ansi.ts +82 -0
- package/src/adapters/dashboard/bin/dashboard.ts +479 -0
- package/src/adapters/dashboard/browse.ts +298 -0
- package/src/adapters/dashboard/identity.ts +182 -0
- package/src/adapters/dashboard/index.ts +183 -0
- package/src/adapters/dashboard/layout.ts +149 -0
- package/src/adapters/dashboard/registries.ts +291 -0
- package/src/adapters/dashboard/resolve.ts +206 -0
- package/src/adapters/dashboard/source.ts +48 -0
- package/src/adapters/dashboard/status.ts +327 -0
- package/src/adapters/dashboard/stories.ts +194 -0
- package/src/adapters/dashboard/web/app.html +1731 -0
- package/src/adapters/dashboard/web/brain.html +463 -0
- package/src/adapters/dashboard/web/fired.ts +31 -0
- package/src/adapters/dashboard/web/flow.ts +457 -0
- package/src/adapters/dashboard/web/narrate.ts +1042 -0
- package/src/adapters/dashboard/web/reveal.ts +135 -0
- package/src/adapters/dashboard/web/server.ts +287 -0
- package/src/adapters/dashboard/web/views.ts +1744 -0
- package/src/adapters/expansions.ts +569 -0
- package/src/adapters/fired.ts +1580 -0
- package/src/adapters/mcp/CONTRACT.md +240 -0
- package/src/adapters/mcp/INTERFACE-GAPS.md +271 -0
- package/src/adapters/mcp/NOTES.md +205 -0
- package/src/adapters/mcp/bin/serve.ts +349 -0
- package/src/adapters/mcp/deliberate.ts +619 -0
- package/src/adapters/mcp/index.ts +101 -0
- package/src/adapters/mcp/protocol.ts +170 -0
- package/src/adapters/mcp/server.ts +1740 -0
- package/src/adapters/mcp/stdio.ts +56 -0
- package/src/adapters/mcp/tools.ts +779 -0
- package/src/adapters/scopes.ts +657 -0
- package/src/adapters/sessions.ts +402 -0
- package/src/adapters/snapshots.ts +1069 -0
- package/src/adapters/stance-env.ts +137 -0
- package/src/core/associate/CONTRACT.md +118 -0
- package/src/core/associate/INTERFACE-GAPS.md +173 -0
- package/src/core/associate/NOTES.md +194 -0
- package/src/core/associate/buffer.ts +66 -0
- package/src/core/associate/edges.ts +188 -0
- package/src/core/associate/index.ts +570 -0
- package/src/core/associate/pending.ts +383 -0
- package/src/core/associate/spread.ts +149 -0
- package/src/core/associate/tunables.ts +123 -0
- package/src/core/bridge.ts +272 -0
- package/src/core/briefing.ts +67 -0
- package/src/core/counterpart.ts +3855 -0
- package/src/core/encode/CONTRACT.md +151 -0
- package/src/core/encode/INTERFACE-GAPS.md +135 -0
- package/src/core/encode/NOTES.md +146 -0
- package/src/core/encode/aliases.ts +71 -0
- package/src/core/encode/battery.ts +284 -0
- package/src/core/encode/chunk.ts +265 -0
- package/src/core/encode/emotion.ts +119 -0
- package/src/core/encode/floor.ts +76 -0
- package/src/core/encode/index.ts +100 -0
- package/src/core/encode/precision.ts +162 -0
- package/src/core/encode/preselect.ts +269 -0
- package/src/core/encode/salience.ts +108 -0
- package/src/core/encode/secrets.ts +265 -0
- package/src/core/encode/tunables.ts +99 -0
- package/src/core/encode/types.ts +286 -0
- package/src/core/encode/words.ts +75 -0
- package/src/core/handoff/CONTRACT.md +199 -0
- package/src/core/handoff/INTERFACE-GAPS.md +166 -0
- package/src/core/handoff/NOTES.md +206 -0
- package/src/core/handoff/index.ts +957 -0
- package/src/core/mint.ts +279 -0
- package/src/core/observer.ts +28 -0
- package/src/core/physics/CONTRACT.md +341 -0
- package/src/core/physics/NOTES.md +155 -0
- package/src/core/physics/clock.ts +51 -0
- package/src/core/physics/index.ts +1054 -0
- package/src/core/prospective/CONTRACT.md +137 -0
- package/src/core/prospective/INTERFACE-GAPS.md +112 -0
- package/src/core/prospective/NOTES.md +160 -0
- package/src/core/prospective/derive.ts +188 -0
- package/src/core/prospective/index.ts +1030 -0
- package/src/core/prospective/tunables.ts +72 -0
- package/src/core/prospective/windows.ts +187 -0
- package/src/core/recall/CONTRACT.md +326 -0
- package/src/core/recall/INTERFACE-GAPS.md +163 -0
- package/src/core/recall/NOTES.md +472 -0
- package/src/core/recall/activate.ts +521 -0
- package/src/core/recall/cues.ts +275 -0
- package/src/core/recall/gate.ts +441 -0
- package/src/core/recall/index.ts +692 -0
- package/src/core/recall/probe.ts +239 -0
- package/src/core/recall/reference.ts +201 -0
- package/src/core/recall/render.ts +285 -0
- package/src/core/recall/session.ts +403 -0
- package/src/core/recall/tunables.ts +329 -0
- package/src/core/remember/CONTRACT.md +293 -0
- package/src/core/remember/INTERFACE-GAPS.md +189 -0
- package/src/core/remember/NOTES.md +373 -0
- package/src/core/remember/fallback.ts +452 -0
- package/src/core/remember/index.ts +103 -0
- package/src/core/remember/owner-strike-seam.ts +479 -0
- package/src/core/remember/proposals.ts +609 -0
- package/src/core/remember/spans.ts +1310 -0
- package/src/core/remember/tunables.ts +111 -0
- package/src/core/remember/updates.ts +198 -0
- package/src/core/retrieval.ts +96 -0
- package/src/core/revision.ts +441 -0
- package/src/core/schemas/CONTRACT.md +190 -0
- package/src/core/schemas/INTERFACE-GAPS.md +172 -0
- package/src/core/schemas/NOTES.md +260 -0
- package/src/core/schemas/aliases.ts +160 -0
- package/src/core/schemas/index.ts +1459 -0
- package/src/core/schemas/tunables.ts +44 -0
- package/src/core/schemas/types.ts +387 -0
- package/src/core/self/CONTRACT.md +459 -0
- package/src/core/self/INTERFACE-GAPS.md +284 -0
- package/src/core/self/NOTES.md +1057 -0
- package/src/core/self/briefing.ts +980 -0
- package/src/core/self/episodes.ts +483 -0
- package/src/core/self/freeze.ts +103 -0
- package/src/core/self/identity.ts +604 -0
- package/src/core/self/index.ts +2130 -0
- package/src/core/self/journal-file.ts +760 -0
- package/src/core/self/page.ts +404 -0
- package/src/core/self/tunables.ts +244 -0
- package/src/core/self/writer.ts +714 -0
- package/src/core/sleep/CONTRACT.md +298 -0
- package/src/core/sleep/INTERFACE-GAPS.md +262 -0
- package/src/core/sleep/NOTES.md +770 -0
- package/src/core/sleep/briefing.ts +86 -0
- package/src/core/sleep/consolidate.ts +241 -0
- package/src/core/sleep/cycle.ts +598 -0
- package/src/core/sleep/decay.ts +237 -0
- package/src/core/sleep/dedup.ts +373 -0
- package/src/core/sleep/index.ts +112 -0
- package/src/core/sleep/log.ts +116 -0
- package/src/core/sleep/markers.ts +164 -0
- package/src/core/sleep/prune.ts +170 -0
- package/src/core/sleep/strength-cache.ts +176 -0
- package/src/core/sleep/tunables.ts +135 -0
- package/src/core/sleep/types.ts +542 -0
- package/src/core/store/CONTRACT.md +446 -0
- package/src/core/store/NOTES.md +1068 -0
- package/src/core/store/cache.ts +709 -0
- package/src/core/store/db.ts +275 -0
- package/src/core/store/errors.ts +134 -0
- package/src/core/store/index.ts +2450 -0
- package/src/core/store/operational.ts +610 -0
- package/src/core/store/owner-op-seam.ts +428 -0
- package/src/core/store/paths.ts +494 -0
- package/src/core/store/prose.ts +165 -0
- package/src/core/store/render.ts +87 -0
- package/src/core/store/walk-seam.ts +78 -0
- package/src/core/types.ts +68 -0
- package/tools/install-loop/run.sh +1063 -0
|
@@ -0,0 +1,463 @@
|
|
|
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">
|
|
6
|
+
<title>counterparts — brain view</title>
|
|
7
|
+
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
|
8
|
+
<style>
|
|
9
|
+
/* The poster. Same glow theme, one job: make a stranger stop scrolling, and
|
|
10
|
+
then tell them the truth — that the mapping is a metaphor and the flow tab is
|
|
11
|
+
the architecture-true view. */
|
|
12
|
+
:root{--bg:#04070c;--ink:#c5cdd8;--dim:#8a95a3;--faint:#79848f;--cyan:#00e5ff;--purple:#b388ff;
|
|
13
|
+
--amber:#ffd740;--teal:#00bfa5;--red:#ff5252;--card:rgba(13,17,23,.84);--border:rgba(0,229,255,.14)}
|
|
14
|
+
*{margin:0;padding:0;box-sizing:border-box}
|
|
15
|
+
html,body{height:100%}
|
|
16
|
+
body{background:radial-gradient(1200px 800px at 50% 42%, #0a1220 0%, var(--bg) 62%);
|
|
17
|
+
color:var(--ink);font-family:'JetBrains Mono','SF Mono',ui-monospace,Menlo,Consolas,monospace;
|
|
18
|
+
font-size:13px;overflow:hidden}
|
|
19
|
+
body::after{content:'';position:fixed;inset:0;pointer-events:none;z-index:40;
|
|
20
|
+
background:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,.05) 2px,rgba(0,0,0,.05) 4px)}
|
|
21
|
+
body::before{content:'';position:fixed;inset:0;pointer-events:none;z-index:39;
|
|
22
|
+
box-shadow:inset 0 0 220px rgba(0,0,0,.75)}
|
|
23
|
+
#stage{position:fixed;inset:0;cursor:grab;display:block}
|
|
24
|
+
#stage.drag{cursor:grabbing}
|
|
25
|
+
header{position:fixed;top:0;left:0;right:0;z-index:50;display:flex;align-items:baseline;gap:16px;
|
|
26
|
+
padding:16px 22px;pointer-events:none;flex-wrap:wrap}
|
|
27
|
+
header a,header .badge{pointer-events:auto}
|
|
28
|
+
h1{font-size:20px;font-weight:300;letter-spacing:8px;text-transform:uppercase;color:var(--cyan);
|
|
29
|
+
text-shadow:0 0 20px rgba(0,229,255,.4),0 0 45px rgba(0,229,255,.12);white-space:nowrap}
|
|
30
|
+
.sub{color:var(--dim);font-size:11px}
|
|
31
|
+
.hright{margin-left:auto;display:flex;gap:14px;align-items:center}
|
|
32
|
+
.hright a{color:var(--dim);text-decoration:none;font-size:11px}
|
|
33
|
+
.hright a:hover{color:var(--cyan)}
|
|
34
|
+
.badge{font-size:9px;padding:1px 8px;border-radius:9px;border:1px solid var(--border);color:var(--dim);
|
|
35
|
+
letter-spacing:.5px;white-space:nowrap}
|
|
36
|
+
#legend{position:fixed;right:18px;top:64px;z-index:50;width:306px;background:var(--card);
|
|
37
|
+
border:1px solid var(--border);border-radius:6px;backdrop-filter:blur(3px);overflow:hidden;
|
|
38
|
+
max-height:calc(100vh - 130px);overflow-y:auto}
|
|
39
|
+
#legend h2{font-size:10px;letter-spacing:2px;text-transform:uppercase;color:var(--dim);padding:11px 14px 7px;font-weight:400}
|
|
40
|
+
.lg{display:grid;grid-template-columns:14px 1fr;gap:9px;padding:8px 14px;font-size:11px;cursor:pointer;
|
|
41
|
+
border-top:1px solid rgba(0,229,255,.05);align-items:start}
|
|
42
|
+
.lg:hover,.lg.on{background:rgba(0,229,255,.07)}
|
|
43
|
+
.lg .dot{width:9px;height:9px;border-radius:50%;margin-top:4px;box-shadow:0 0 8px currentColor}
|
|
44
|
+
.lg .nm{font-weight:600}
|
|
45
|
+
.lg .mech{color:var(--dim);font-size:10px;line-height:1.5}
|
|
46
|
+
#ticker{position:fixed;left:22px;bottom:18px;z-index:50;max-width:54%;background:var(--card);
|
|
47
|
+
border:1px solid var(--border);border-radius:6px;padding:10px 14px;font-size:11.5px;
|
|
48
|
+
backdrop-filter:blur(3px);line-height:1.6}
|
|
49
|
+
#ticker .t{color:var(--faint);margin-right:8px}
|
|
50
|
+
#ticker.amber{border-color:rgba(255,215,64,.4)}
|
|
51
|
+
#ticker.amber #tickmsg{color:var(--amber)}
|
|
52
|
+
#note{position:fixed;right:22px;bottom:16px;z-index:50;color:var(--dim);font-size:10px;
|
|
53
|
+
max-width:430px;text-align:right;line-height:1.7}
|
|
54
|
+
#note a{color:var(--dim)}
|
|
55
|
+
#fail{position:fixed;inset:0;display:none;z-index:60;align-items:center;justify-content:center;
|
|
56
|
+
text-align:center;padding:40px}
|
|
57
|
+
#fail.show{display:flex}
|
|
58
|
+
#fail .box{max-width:540px;border:1px dashed var(--border);border-radius:8px;padding:28px;
|
|
59
|
+
color:var(--dim);font-size:12px;line-height:1.8}
|
|
60
|
+
#fail .box b{color:var(--ink);font-weight:400}
|
|
61
|
+
@media(max-width:900px){#legend{display:none}#ticker{max-width:calc(100% - 44px)}#note{display:none}}
|
|
62
|
+
/* The poster's own chrome on a phone. The two links out of here were 13px tall
|
|
63
|
+
against a 44px minimum — never caught, because the visual loop did not shoot
|
|
64
|
+
this page at 390 at all until 2026-09-05. The subtitle goes, because a header
|
|
65
|
+
that wraps to three rows over a hologram is chrome eating the picture. */
|
|
66
|
+
@media(max-width:720px){
|
|
67
|
+
header{padding:10px 14px;gap:10px}
|
|
68
|
+
h1{font-size:16px;letter-spacing:5px}
|
|
69
|
+
header .sub{display:none}
|
|
70
|
+
.hright{gap:6px}
|
|
71
|
+
.hright a{min-height:44px;display:flex;align-items:center;padding:0 8px}
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
74
|
+
</head>
|
|
75
|
+
<body>
|
|
76
|
+
<canvas id="stage"></canvas>
|
|
77
|
+
<header>
|
|
78
|
+
<h1>counterparts</h1>
|
|
79
|
+
<span class="sub">brain view — the same machinery, mapped to a rough anatomy</span>
|
|
80
|
+
<div class="hright">
|
|
81
|
+
<span class="badge" title="it strengthens nothing and writes nothing">read-only · observer</span>
|
|
82
|
+
<a href="/#flow">flow</a><a href="/">dashboard</a>
|
|
83
|
+
</div>
|
|
84
|
+
</header>
|
|
85
|
+
<div id="legend"><h2>regions ≈ modules</h2></div>
|
|
86
|
+
<div id="ticker"><span class="t">…</span><span id="tickmsg">listening for events</span></div>
|
|
87
|
+
<div id="note">drag to rotate · scroll to zoom<br>
|
|
88
|
+
the mapping is a metaphor — the <a href="/#flow">flow tab</a> is the architecture-true view</div>
|
|
89
|
+
<div id="fail"><div class="box">
|
|
90
|
+
<b>The brain view needs three.js, and this machine cannot reach the CDN right now.</b><br><br>
|
|
91
|
+
Nothing else in the dashboard needs the network: every other page renders fully offline, from your own store.
|
|
92
|
+
<br><br><a href="/" style="color:var(--cyan)">back to the dashboard</a>
|
|
93
|
+
</div></div>
|
|
94
|
+
|
|
95
|
+
<script type="module">
|
|
96
|
+
"use strict";
|
|
97
|
+
/* Regions ≈ modules. The mapping is stated as a metaphor in the corner because
|
|
98
|
+
it is one: the flow tab is the architecture-true view, and this page says so
|
|
99
|
+
rather than letting a pretty picture imply more than it knows. */
|
|
100
|
+
const REGIONS = [
|
|
101
|
+
{ key:"cortex", name:"cortex", mech:"store — the three boxes: prose you can open, one small database, a cache that can always be rebuilt", col:[0.16,0.80,1.00], nodes:["store"] },
|
|
102
|
+
{ key:"prefrontal", name:"prefrontal cortex", mech:"self — identity, the episode journal, and the briefing the next session wakes into", col:[0.72,0.53,1.00], nodes:["self","wake"] },
|
|
103
|
+
{ key:"hippocampus",name:"hippocampus", mech:"remember — the authored door, where a lived session becomes a durable trace", col:[0.25,1.00,0.72], nodes:["remember","sweep","spans"] },
|
|
104
|
+
{ key:"amygdala", name:"amygdala", mech:"encode — salience tagging: what mattered, what was felt, what was new", col:[1.00,0.42,0.52], nodes:["encode"] },
|
|
105
|
+
{ key:"thalamus", name:"thalamus", mech:"recall — the gate: cues in, and rarely, one memory out loud", col:[1.00,0.80,0.32], nodes:["recall","session"] },
|
|
106
|
+
{ key:"cerebellum", name:"cerebellum", mech:"associate & schemas — what fires together wires together, and what that adds up to believing", col:[0.30,0.95,0.85], nodes:["associate","schemas"] },
|
|
107
|
+
{ key:"brainstem", name:"brainstem", mech:"sleep, physics & prospective — the clocks: decay, pruning, consolidation, and what is due", col:[0.55,0.66,0.85], nodes:["sleep","physics","prospective"] },
|
|
108
|
+
];
|
|
109
|
+
const OF_NODE = {};
|
|
110
|
+
REGIONS.forEach((r, i) => { for (const n of r.nodes) OF_NODE[n] = i; });
|
|
111
|
+
|
|
112
|
+
// ── legend ─────────────────────────────────────────────────────────────────
|
|
113
|
+
const legend = document.getElementById("legend");
|
|
114
|
+
const lgEls = [];
|
|
115
|
+
let locked = null;
|
|
116
|
+
REGIONS.forEach((r, i) => {
|
|
117
|
+
const el = document.createElement("div");
|
|
118
|
+
el.className = "lg";
|
|
119
|
+
const c = `rgb(${r.col.map((v) => Math.round(v * 255)).join(",")})`;
|
|
120
|
+
el.innerHTML = `<span class="dot" style="background:${c};color:${c}"></span>
|
|
121
|
+
<span><span class="nm" style="color:${c}">${r.name}</span><div class="mech">${r.mech}</div></span>`;
|
|
122
|
+
el.onclick = () => {
|
|
123
|
+
locked = locked === i ? null : i;
|
|
124
|
+
lgEls.forEach((e2, j) => e2.classList.toggle("on", locked === j));
|
|
125
|
+
};
|
|
126
|
+
legend.appendChild(el);
|
|
127
|
+
lgEls.push(el);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const ticker = document.getElementById("ticker");
|
|
131
|
+
const tickmsg = document.getElementById("tickmsg");
|
|
132
|
+
function say(text, tone, at) {
|
|
133
|
+
tickmsg.textContent = text;
|
|
134
|
+
ticker.classList.toggle("amber", tone === "amber");
|
|
135
|
+
ticker.querySelector(".t").textContent = at
|
|
136
|
+
? new Date(at).toTimeString().slice(0, 8)
|
|
137
|
+
: "…";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Mark the page ready whichever way it ends: the screenshot loop waits on this
|
|
141
|
+
* flag, and a hologram that failed to load is still a page worth capturing. */
|
|
142
|
+
function ready() { document.documentElement.dataset.loaded = "1"; }
|
|
143
|
+
|
|
144
|
+
// ── three.js, pinned, from the one CDN this project allows ─────────────────
|
|
145
|
+
let THREE;
|
|
146
|
+
try {
|
|
147
|
+
THREE = await import("https://cdn.jsdelivr.net/npm/three@0.169.0/build/three.module.js");
|
|
148
|
+
} catch (err) {
|
|
149
|
+
document.getElementById("fail").classList.add("show");
|
|
150
|
+
// Nothing to drag and nothing to zoom: the hint would be a lie.
|
|
151
|
+
document.getElementById("note").hidden = true;
|
|
152
|
+
say("the hologram needs the network; the rest of the dashboard does not", "calm", null);
|
|
153
|
+
ready();
|
|
154
|
+
// Deliberately NOT rethrown: an unhandled rejection here would be a page
|
|
155
|
+
// error on a page that is behaving exactly as designed.
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (THREE) {
|
|
159
|
+
const canvas = document.getElementById("stage");
|
|
160
|
+
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });
|
|
161
|
+
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
|
|
162
|
+
const scene = new THREE.Scene();
|
|
163
|
+
const camera = new THREE.PerspectiveCamera(45, 1, 0.1, 50);
|
|
164
|
+
camera.position.set(0, 0.18, 3.0);
|
|
165
|
+
const group = new THREE.Group();
|
|
166
|
+
group.position.y = 0.08;
|
|
167
|
+
scene.add(group);
|
|
168
|
+
|
|
169
|
+
// A deterministic generator: the poster looks the same every time it is shot.
|
|
170
|
+
const rand = (() => { let s = 20260904; return () => { s = (s * 1103515245 + 12345) & 0x7fffffff; return s / 0x7fffffff; }; })();
|
|
171
|
+
const pts = [], cols = [], regs = [];
|
|
172
|
+
function push(p, region, dim = 1) {
|
|
173
|
+
pts.push(p[0], p[1], p[2]);
|
|
174
|
+
const c = REGIONS[region].col;
|
|
175
|
+
cols.push(c[0] * dim, c[1] * dim, c[2] * dim);
|
|
176
|
+
regs.push(region);
|
|
177
|
+
}
|
|
178
|
+
function dir() {
|
|
179
|
+
const u = rand() * 2 - 1, ph = rand() * Math.PI * 2, r = Math.sqrt(1 - u * u);
|
|
180
|
+
return [r * Math.cos(ph), u, r * Math.sin(ph)];
|
|
181
|
+
}
|
|
182
|
+
const RID = {};
|
|
183
|
+
REGIONS.forEach((r, i) => { RID[r.key] = i; });
|
|
184
|
+
|
|
185
|
+
// cerebrum: a wrinkled ellipsoid shell, split by the longitudinal fissure
|
|
186
|
+
for (let i = 0; i < 11000; i++) {
|
|
187
|
+
const d = dir();
|
|
188
|
+
const th = Math.atan2(d[2], d[0]), ph = Math.asin(d[1]);
|
|
189
|
+
let r = 1 + 0.05 * Math.sin(th * 7 + 3 * Math.sin(ph * 4)) + 0.03 * Math.sin(th * 13 + ph * 9)
|
|
190
|
+
+ 0.018 * Math.sin(th * 23) * Math.sin(ph * 17);
|
|
191
|
+
r *= 0.985 + 0.05 * rand();
|
|
192
|
+
let x = d[0] * r * 1.02, y = d[1] * r * 0.86, z = d[2] * r * 1.28;
|
|
193
|
+
if (y < 0) { y *= 0.74; z *= 0.96; }
|
|
194
|
+
if (Math.abs(x) < 0.035 && y > -0.1) continue;
|
|
195
|
+
x += Math.sign(x) * 0.03;
|
|
196
|
+
if (y < -0.28 && z < -0.35) continue;
|
|
197
|
+
push([x, y, z], z > 0.78 ? RID.prefrontal : RID.cortex, 0.75 + 0.25 * rand());
|
|
198
|
+
}
|
|
199
|
+
// cerebellum: striated, rear underside
|
|
200
|
+
for (let i = 0; i < 2300; i++) {
|
|
201
|
+
const d = dir();
|
|
202
|
+
let r = 1 + 0.06 * Math.sin(Math.asin(d[1]) * 22);
|
|
203
|
+
r *= 0.97 + 0.06 * rand();
|
|
204
|
+
push([d[0] * r * 0.5, -0.58 + d[1] * r * 0.3, -0.82 + d[2] * r * 0.42], RID.cerebellum, 0.7 + 0.3 * rand());
|
|
205
|
+
}
|
|
206
|
+
// brainstem: a tapering column
|
|
207
|
+
for (let i = 0; i < 700; i++) {
|
|
208
|
+
const t = rand(), a = rand() * Math.PI * 2, rr = (0.17 - 0.06 * t) * Math.sqrt(rand());
|
|
209
|
+
push([Math.cos(a) * rr, -0.4 - 0.75 * t, -0.2 - 0.3 * t + Math.sin(a) * rr], RID.brainstem, 0.6 + 0.3 * rand());
|
|
210
|
+
}
|
|
211
|
+
// thalamus: two central lobes
|
|
212
|
+
for (const s of [-1, 1]) for (let i = 0; i < 430; i++) {
|
|
213
|
+
const d = dir();
|
|
214
|
+
push([s * 0.15 + d[0] * 0.13, -0.02 + d[1] * 0.11, 0.02 + d[2] * 0.16], RID.thalamus, 0.45 + 0.25 * rand());
|
|
215
|
+
}
|
|
216
|
+
// hippocampus: a curved arc through each medial temporal lobe
|
|
217
|
+
for (const s of [-1, 1]) for (let i = 0; i < 540; i++) {
|
|
218
|
+
const t = rand(), a = rand() * Math.PI * 2, rr = 0.055 * Math.sqrt(rand());
|
|
219
|
+
const cx = s * (0.3 + 0.12 * Math.sin(Math.PI * t)), cy = -0.2 - 0.26 * t * (1 - 0.35 * t), cz = -0.38 + 0.78 * t;
|
|
220
|
+
push([cx + Math.cos(a) * rr, cy + Math.sin(a) * rr * 0.8, cz + Math.sin(a + 1) * rr], RID.hippocampus, 0.75 + 0.25 * rand());
|
|
221
|
+
}
|
|
222
|
+
// amygdala: a small cluster at each hippocampal head
|
|
223
|
+
for (const s of [-1, 1]) for (let i = 0; i < 240; i++) {
|
|
224
|
+
const d = dir();
|
|
225
|
+
push([s * 0.42 + d[0] * 0.085, -0.42 + d[1] * 0.075, 0.42 + d[2] * 0.085], RID.amygdala, 0.75 + 0.25 * rand());
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const geo = new THREE.BufferGeometry();
|
|
229
|
+
geo.setAttribute("position", new THREE.Float32BufferAttribute(pts, 3));
|
|
230
|
+
geo.setAttribute("aColor", new THREE.Float32BufferAttribute(cols, 3));
|
|
231
|
+
geo.setAttribute("aRegion", new THREE.Float32BufferAttribute(regs, 1));
|
|
232
|
+
|
|
233
|
+
const regionVerts = REGIONS.map(() => []);
|
|
234
|
+
for (let i = 0; i < regs.length; i++) regionVerts[regs[i]].push(i);
|
|
235
|
+
const vAt = (i) => new THREE.Vector3(pts[i * 3], pts[i * 3 + 1], pts[i * 3 + 2]);
|
|
236
|
+
const randVert = (r) => vAt(regionVerts[r][Math.floor(rand() * regionVerts[r].length)]);
|
|
237
|
+
|
|
238
|
+
const uniforms = {
|
|
239
|
+
uTime: { value: 0 },
|
|
240
|
+
uGlow: { value: new Array(REGIONS.length).fill(0) },
|
|
241
|
+
uLock: { value: -1 },
|
|
242
|
+
uPx: { value: 1 },
|
|
243
|
+
};
|
|
244
|
+
const mat = new THREE.ShaderMaterial({
|
|
245
|
+
uniforms, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending,
|
|
246
|
+
vertexShader: `attribute vec3 aColor;attribute float aRegion;
|
|
247
|
+
uniform float uTime;uniform float uGlow[${REGIONS.length}];uniform float uLock;uniform float uPx;
|
|
248
|
+
varying vec3 vC;varying float vA;
|
|
249
|
+
void main(){
|
|
250
|
+
int r=int(aRegion+0.5);
|
|
251
|
+
float glow=uGlow[r];
|
|
252
|
+
float tw=0.82+0.18*sin(uTime*2.1+position.x*37.0+position.y*53.0+position.z*41.0);
|
|
253
|
+
float lockBoost=(uLock<-0.5)?1.0:(abs(uLock-aRegion)<0.5?1.9:0.30);
|
|
254
|
+
vC=aColor*(0.88+1.35*glow)*tw*lockBoost;
|
|
255
|
+
vA=(0.70+0.30*glow)*lockBoost;
|
|
256
|
+
vec4 mv=modelViewMatrix*vec4(position,1.0);
|
|
257
|
+
gl_PointSize=uPx*(2.7+2.2*glow)*(3.0/-mv.z);
|
|
258
|
+
gl_Position=projectionMatrix*mv;
|
|
259
|
+
}`,
|
|
260
|
+
fragmentShader: `varying vec3 vC;varying float vA;
|
|
261
|
+
void main(){
|
|
262
|
+
vec2 d=gl_PointCoord-vec2(0.5);
|
|
263
|
+
float a=smoothstep(0.5,0.08,length(d));
|
|
264
|
+
gl_FragColor=vec4(vC,a*vA);
|
|
265
|
+
}`,
|
|
266
|
+
});
|
|
267
|
+
group.add(new THREE.Points(geo, mat));
|
|
268
|
+
|
|
269
|
+
for (const [r, op] of [[1.45, 0.16], [1.15, 0.08], [1.75, 0.05]]) {
|
|
270
|
+
const ring = new THREE.Mesh(
|
|
271
|
+
new THREE.RingGeometry(r, r + 0.012, 90),
|
|
272
|
+
new THREE.MeshBasicMaterial({ color: 0x00e5ff, transparent: true, opacity: op,
|
|
273
|
+
side: THREE.DoubleSide, blending: THREE.AdditiveBlending, depthWrite: false }));
|
|
274
|
+
ring.rotation.x = -Math.PI / 2;
|
|
275
|
+
ring.position.y = -1.45;
|
|
276
|
+
scene.add(ring);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// ── arcs: one signal travelling between two regions ──────────────────────
|
|
280
|
+
const glowTex = (() => {
|
|
281
|
+
const c = document.createElement("canvas");
|
|
282
|
+
c.width = c.height = 64;
|
|
283
|
+
const g = c.getContext("2d"), gr = g.createRadialGradient(32, 32, 0, 32, 32, 32);
|
|
284
|
+
gr.addColorStop(0, "rgba(255,255,255,1)");
|
|
285
|
+
gr.addColorStop(0.25, "rgba(255,255,255,.6)");
|
|
286
|
+
gr.addColorStop(1, "rgba(255,255,255,0)");
|
|
287
|
+
g.fillStyle = gr;
|
|
288
|
+
g.fillRect(0, 0, 64, 64);
|
|
289
|
+
return new THREE.CanvasTexture(c);
|
|
290
|
+
})();
|
|
291
|
+
const arcs = [];
|
|
292
|
+
function spawnArc(fromR, toR) {
|
|
293
|
+
if (fromR === toR) return;
|
|
294
|
+
const p0 = randVert(fromR), p2 = randVert(toR);
|
|
295
|
+
const mid = p0.clone().add(p2).multiplyScalar(0.5).multiplyScalar(1.55 + 0.35 * rand());
|
|
296
|
+
const col = REGIONS[toR].col;
|
|
297
|
+
const color = new THREE.Color(col[0], col[1], col[2]);
|
|
298
|
+
const N = 42, arr = new Float32Array(N * 3);
|
|
299
|
+
const curve = new THREE.QuadraticBezierCurve3(p0, mid, p2);
|
|
300
|
+
curve.getPoints(N - 1).forEach((p, i) => { arr[i * 3] = p.x; arr[i * 3 + 1] = p.y; arr[i * 3 + 2] = p.z; });
|
|
301
|
+
const g2 = new THREE.BufferGeometry();
|
|
302
|
+
g2.setAttribute("position", new THREE.BufferAttribute(arr, 3));
|
|
303
|
+
g2.setDrawRange(0, 0);
|
|
304
|
+
const line = new THREE.Line(g2, new THREE.LineBasicMaterial({ color, transparent: true,
|
|
305
|
+
opacity: 0.55, blending: THREE.AdditiveBlending, depthWrite: false }));
|
|
306
|
+
const head = new THREE.Sprite(new THREE.SpriteMaterial({ map: glowTex, color, transparent: true,
|
|
307
|
+
blending: THREE.AdditiveBlending, depthWrite: false }));
|
|
308
|
+
head.scale.setScalar(0.15);
|
|
309
|
+
group.add(line); group.add(head);
|
|
310
|
+
arcs.push({ line, head, curve, born: performance.now(), dur: 1500, N });
|
|
311
|
+
}
|
|
312
|
+
function stepArcs(now) {
|
|
313
|
+
for (let i = arcs.length - 1; i >= 0; i--) {
|
|
314
|
+
const a = arcs[i], t = (now - a.born) / a.dur;
|
|
315
|
+
if (t >= 1.25) { group.remove(a.line); group.remove(a.head); a.line.geometry.dispose(); arcs.splice(i, 1); continue; }
|
|
316
|
+
const tt = Math.min(t, 1);
|
|
317
|
+
const headI = Math.floor(tt * (a.N - 1));
|
|
318
|
+
const tail = Math.max(0, headI - 14);
|
|
319
|
+
a.line.geometry.setDrawRange(tail, Math.max(1, headI - tail));
|
|
320
|
+
a.line.material.opacity = 0.55 * (t < 1 ? 1 : 1 - (t - 1) / 0.25);
|
|
321
|
+
a.head.material.opacity = t < 1 ? 1 : 1 - (t - 1) / 0.25;
|
|
322
|
+
a.head.position.copy(a.curve.getPoint(tt));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// ── live events: the ticker speaks the dashboard's own sentences ─────────
|
|
327
|
+
const glowTarget = new Array(REGIONS.length).fill(0);
|
|
328
|
+
let lastSeq = 0;
|
|
329
|
+
let booted = false;
|
|
330
|
+
function flashLegend(i) {
|
|
331
|
+
const el = lgEls[i];
|
|
332
|
+
if (!el) return;
|
|
333
|
+
el.style.background = "rgba(0,229,255,.13)";
|
|
334
|
+
setTimeout(() => { if (locked !== i) el.style.background = ""; }, 700);
|
|
335
|
+
}
|
|
336
|
+
let prevRegion = null;
|
|
337
|
+
function fire(e) {
|
|
338
|
+
const region = OF_NODE[e.node];
|
|
339
|
+
if (region === undefined) return;
|
|
340
|
+
glowTarget[region] = 1;
|
|
341
|
+
flashLegend(region);
|
|
342
|
+
if (prevRegion !== null) spawnArc(prevRegion, region);
|
|
343
|
+
prevRegion = region;
|
|
344
|
+
say(e.text, e.tone, e.at);
|
|
345
|
+
}
|
|
346
|
+
async function poll() {
|
|
347
|
+
try {
|
|
348
|
+
const res = await fetch(`/api/activity?limit=40&sinceSeq=${lastSeq}`, { headers: { accept: "application/json" } });
|
|
349
|
+
if (!res.ok) return;
|
|
350
|
+
const d = await res.json();
|
|
351
|
+
if (d.lastSeq <= lastSeq && booted) return;
|
|
352
|
+
const fresh = d.events.slice().reverse();
|
|
353
|
+
lastSeq = d.lastSeq;
|
|
354
|
+
const play = booted ? fresh : fresh.slice(-10);
|
|
355
|
+
play.forEach((e, i) => setTimeout(() => fire(e), i * (booted ? 500 : 380)));
|
|
356
|
+
if (!booted && fresh.length === 0) {
|
|
357
|
+
say("nothing has reached my durable log yet — this store has not lived a day", "calm", null);
|
|
358
|
+
}
|
|
359
|
+
booted = true;
|
|
360
|
+
} catch (err) { /* the next poll retries; a dashboard does not shout */ }
|
|
361
|
+
}
|
|
362
|
+
// Seed from the whole kept log so a cold open is not a dead stage, then
|
|
363
|
+
// switch to "only what is new" — the same rule the flow tab follows.
|
|
364
|
+
(async () => {
|
|
365
|
+
try {
|
|
366
|
+
const res = await fetch("/api/activity?limit=12", { headers: { accept: "application/json" } });
|
|
367
|
+
if (res.ok) {
|
|
368
|
+
const d = await res.json();
|
|
369
|
+
lastSeq = d.lastSeq;
|
|
370
|
+
const fresh = d.events.slice().reverse();
|
|
371
|
+
fresh.forEach((e, i) => setTimeout(() => fire(e), i * 380));
|
|
372
|
+
if (fresh.length === 0) say("nothing has reached my durable log yet — this store has not lived a day", "calm", null);
|
|
373
|
+
}
|
|
374
|
+
} catch (err) { /* offline: the stage still renders */ }
|
|
375
|
+
booted = true;
|
|
376
|
+
})();
|
|
377
|
+
setInterval(poll, 4000);
|
|
378
|
+
|
|
379
|
+
// ── interaction ─────────────────────────────────────────────────────────
|
|
380
|
+
let dragging = false, px = 0, py = 0, rotY = 0.6, rotX = 0.12, autoPause = 0;
|
|
381
|
+
canvas.addEventListener("pointerdown", (e) => { dragging = true; px = e.clientX; py = e.clientY; canvas.classList.add("drag"); });
|
|
382
|
+
addEventListener("pointerup", () => { dragging = false; canvas.classList.remove("drag"); });
|
|
383
|
+
addEventListener("pointermove", (e) => {
|
|
384
|
+
if (!dragging) return;
|
|
385
|
+
rotY += (e.clientX - px) * 0.005;
|
|
386
|
+
rotX += (e.clientY - py) * 0.004;
|
|
387
|
+
rotX = Math.max(-0.9, Math.min(0.9, rotX));
|
|
388
|
+
px = e.clientX; py = e.clientY;
|
|
389
|
+
autoPause = performance.now() + 2500;
|
|
390
|
+
});
|
|
391
|
+
addEventListener("wheel", (e) => {
|
|
392
|
+
// Zoom is a MULTIPLIER on the fitted distance, so a resize re-frames the
|
|
393
|
+
// silhouette without throwing away where the reader had zoomed to.
|
|
394
|
+
zoom = Math.max(0.55, Math.min(2.2, zoom + e.deltaY * 0.0009));
|
|
395
|
+
camera.position.z = baseZ * zoom;
|
|
396
|
+
}, { passive: true });
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* FRAME THE SILHOUETTE, NOT THE VIEWPORT.
|
|
400
|
+
*
|
|
401
|
+
* The camera used to sit at a fixed distance with a fixed vertical FOV, so
|
|
402
|
+
* the horizontal extent was whatever the aspect ratio happened to give: at
|
|
403
|
+
* 1920 the outer shell read as a brain, and at 1440 — the size the visual
|
|
404
|
+
* loop and the README actually use — it ran off frame and read as a
|
|
405
|
+
* jellyfish. Worse, the legend panel covers ~330px on the right, so the
|
|
406
|
+
* model was centred in the viewport and therefore off-centre in the space
|
|
407
|
+
* anyone can see.
|
|
408
|
+
*
|
|
409
|
+
* So: pull back far enough that the silhouette's own bounding box fits the
|
|
410
|
+
* FREE width (viewport minus the legend), and shift the frustum by half the
|
|
411
|
+
* legend so the brain sits in the middle of what is left.
|
|
412
|
+
*/
|
|
413
|
+
const HALF_X = 1.75;
|
|
414
|
+
const HALF_Y = 1.15;
|
|
415
|
+
// 1.05, not 1.12: measured against the 1920 framing the design review called
|
|
416
|
+
// "reads as a brain", this is the distance that reproduces it at 1440 and at
|
|
417
|
+
// 1024 instead of leaving a band of dark above the silhouette.
|
|
418
|
+
const MARGIN = 1.05;
|
|
419
|
+
let baseZ = 3.0;
|
|
420
|
+
let zoom = 1;
|
|
421
|
+
|
|
422
|
+
function resize() {
|
|
423
|
+
const w = innerWidth, h = innerHeight;
|
|
424
|
+
renderer.setSize(w, h);
|
|
425
|
+
const legend = w >= 900 ? 330 : 0;
|
|
426
|
+
const free = Math.max(300, w - legend);
|
|
427
|
+
camera.aspect = w / h;
|
|
428
|
+
const t = Math.tan(((camera.fov * Math.PI) / 180) / 2);
|
|
429
|
+
const zForY = (HALF_Y * MARGIN) / t;
|
|
430
|
+
const zForX = (HALF_X * MARGIN) / (t * (free / h));
|
|
431
|
+
baseZ = Math.max(2.4, Math.min(6.4, Math.max(zForY, zForX)));
|
|
432
|
+
camera.position.z = baseZ * zoom;
|
|
433
|
+
// Shift what the camera sees right, which moves the model left — out from
|
|
434
|
+
// under the legend.
|
|
435
|
+
if (legend > 0) camera.setViewOffset(w, h, legend / 2, 0, w, h);
|
|
436
|
+
else camera.clearViewOffset();
|
|
437
|
+
camera.updateProjectionMatrix();
|
|
438
|
+
uniforms.uPx.value = Math.min(devicePixelRatio, 2) * Math.min(1.4, w / 1100);
|
|
439
|
+
}
|
|
440
|
+
addEventListener("resize", resize);
|
|
441
|
+
resize();
|
|
442
|
+
|
|
443
|
+
function frame(now) {
|
|
444
|
+
uniforms.uTime.value = now / 1000;
|
|
445
|
+
if (now > autoPause) rotY += 0.0016;
|
|
446
|
+
group.rotation.y = rotY;
|
|
447
|
+
group.rotation.x = rotX;
|
|
448
|
+
for (let i = 0; i < REGIONS.length; i++) {
|
|
449
|
+
const cur = uniforms.uGlow.value[i];
|
|
450
|
+
uniforms.uGlow.value[i] = cur + (glowTarget[i] - cur) * 0.14;
|
|
451
|
+
glowTarget[i] *= 0.965;
|
|
452
|
+
}
|
|
453
|
+
uniforms.uLock.value = locked === null ? -1 : locked;
|
|
454
|
+
stepArcs(now);
|
|
455
|
+
renderer.render(scene, camera);
|
|
456
|
+
requestAnimationFrame(frame);
|
|
457
|
+
}
|
|
458
|
+
requestAnimationFrame(frame);
|
|
459
|
+
ready();
|
|
460
|
+
}
|
|
461
|
+
</script>
|
|
462
|
+
</body>
|
|
463
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The health tab's "what fired" panel.
|
|
3
|
+
*
|
|
4
|
+
* A file of its own, and deliberately thin: the reading itself lives in
|
|
5
|
+
* `adapters/fired.ts`, shared with `counterparts fired` and with doctor's
|
|
6
|
+
* `Fired` finding so the three surfaces cannot disagree about what "silent"
|
|
7
|
+
* means. All this does is hand the rows to the page in the shape it draws.
|
|
8
|
+
*
|
|
9
|
+
* It sits beside `views.ts` rather than inside it because `HealthView` is under
|
|
10
|
+
* an unmerged exploratory redesign on another branch, and a panel bolted into
|
|
11
|
+
* that interface would be a merge conflict in a file nobody wants one in. The
|
|
12
|
+
* route is its own (`/api/fired`), so the two pages can move independently.
|
|
13
|
+
*
|
|
14
|
+
* Read-only, like everything in this directory.
|
|
15
|
+
*/
|
|
16
|
+
import { STATE_MEANING, STATE_ORDER, firedReport } from "../../fired.js";
|
|
17
|
+
import type { FiredReport } from "../../fired.js";
|
|
18
|
+
import type { DashboardSource } from "../source.js";
|
|
19
|
+
|
|
20
|
+
export interface FiredPanel extends FiredReport {
|
|
21
|
+
/** The state vocabulary, in the order the panel draws its groups, with the
|
|
22
|
+
* one line each one means. On the payload so the page never restates it. */
|
|
23
|
+
readonly vocabulary: { state: string; meaning: string }[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function firedPanel(src: DashboardSource, today: string): FiredPanel {
|
|
27
|
+
return {
|
|
28
|
+
...firedReport(src.store, today),
|
|
29
|
+
vocabulary: STATE_ORDER.map((state) => ({ state, meaning: STATE_MEANING[state] })),
|
|
30
|
+
};
|
|
31
|
+
}
|