counterparts 0.3.0 → 0.3.2
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/CHANGELOG.md +76 -0
- package/docs/module-map.md +2 -0
- package/package.json +2 -1
- package/src/adapters/claude-code/CONTRACT.md +2 -1
- package/src/adapters/claude-code/NOTES.md +90 -2
- package/src/adapters/claude-code/bin/hook.ts +17 -2
- package/src/adapters/claude-code/bin/runner.ts +4 -1
- package/src/adapters/claude-code/config.ts +23 -0
- package/src/adapters/claude-code/doctor.ts +148 -26
- package/src/adapters/claude-code/hooks.ts +37 -12
- package/src/adapters/claude-code/index.ts +2 -0
- package/src/adapters/claude-code/standdown.ts +12 -1
- package/src/adapters/claude-code/transcript.ts +79 -6
- package/src/adapters/cli/INTERFACE-GAPS.md +4 -0
- package/src/adapters/cli/commands.ts +209 -61
- package/src/adapters/cli/export.ts +27 -3
- package/src/adapters/cli/help.ts +22 -8
- package/src/adapters/cli/install.ts +3 -5
- package/src/adapters/cli/mechanisms.ts +295 -0
- package/src/adapters/cli/repair-dates.ts +3 -1
- package/src/adapters/cli/snapshot.ts +4 -27
- package/src/adapters/dashboard/CONTRACT.md +13 -9
- package/src/adapters/dashboard/INTERFACE-GAPS.md +4 -0
- package/src/adapters/dashboard/NOTES.md +3 -2
- package/src/adapters/dashboard/activity.ts +2 -1
- package/src/adapters/dashboard/bin/dashboard.ts +18 -3
- package/src/adapters/dashboard/upgrade.ts +23 -0
- package/src/adapters/dashboard/web/README.md +153 -0
- package/src/adapters/dashboard/web/actions.ts +631 -0
- package/src/adapters/dashboard/web/app.html +40 -1703
- package/src/adapters/dashboard/web/app.js +55 -0
- package/src/adapters/dashboard/web/mechanisms/association/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/association/panel.js +17 -0
- package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +23 -0
- package/src/adapters/dashboard/web/mechanisms/decay/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/decay/panel.js +45 -0
- package/src/adapters/dashboard/web/mechanisms/emotional/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/index.js +60 -0
- package/src/adapters/dashboard/web/mechanisms/interference/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/picture.js +28 -0
- package/src/adapters/dashboard/web/mechanisms/prospective/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/reconsolidation/panel.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/regions.js +30 -0
- package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/retrieval/panel.js +20 -0
- package/src/adapters/dashboard/web/mechanisms/salience/index.js +15 -0
- package/src/adapters/dashboard/web/mechanisms/salience/panel.js +14 -0
- package/src/adapters/dashboard/web/mechanisms/schema/index.js +15 -0
- package/src/adapters/dashboard/web/narrate.ts +10 -10
- package/src/adapters/dashboard/web/pages/flow/flow.css +38 -0
- package/src/adapters/dashboard/web/pages/flow/index.js +117 -0
- package/src/adapters/dashboard/web/pages/flow/sections/blind.js +12 -0
- package/src/adapters/dashboard/web/pages/flow/sections/detail.js +45 -0
- package/src/adapters/dashboard/web/pages/flow/sections/diagram.js +291 -0
- package/src/adapters/dashboard/web/pages/flow/sections/feed.js +11 -0
- package/src/adapters/dashboard/web/pages/flow/sections/fired.js +41 -0
- package/src/adapters/dashboard/web/pages/flow/sections/heatmap.js +25 -0
- package/src/adapters/dashboard/web/pages/flow/sections/records.js +24 -0
- package/src/adapters/dashboard/web/pages/flow/sections/symmetry.js +17 -0
- package/src/adapters/dashboard/web/pages/flow/state.js +3 -0
- package/src/adapters/dashboard/web/pages/health/health.css +93 -0
- package/src/adapters/dashboard/web/pages/health/index.js +41 -0
- package/src/adapters/dashboard/web/pages/health/sections/archive.js +84 -0
- package/src/adapters/dashboard/web/pages/health/sections/checks.js +172 -0
- package/src/adapters/dashboard/web/pages/health/sections/cycle.js +37 -0
- package/src/adapters/dashboard/web/pages/health/sections/verify.js +54 -0
- package/src/adapters/dashboard/web/pages/home/brain.js +375 -0
- package/src/adapters/dashboard/web/pages/home/home.css +134 -0
- package/src/adapters/dashboard/web/pages/home/index.js +84 -0
- package/src/adapters/dashboard/web/pages/home/sections/explorer.js +206 -0
- package/src/adapters/dashboard/web/pages/home/sections/hero.js +22 -0
- package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +25 -0
- package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +13 -0
- package/src/adapters/dashboard/web/pages/home/sections/tiles.js +52 -0
- package/src/adapters/dashboard/web/pages/memories/index.js +75 -0
- package/src/adapters/dashboard/web/pages/memories/memories.css +143 -0
- package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +178 -0
- package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +42 -0
- package/src/adapters/dashboard/web/pages/memories/sections/list.js +114 -0
- package/src/adapters/dashboard/web/pages/memories/sections/search.js +102 -0
- package/src/adapters/dashboard/web/pages/memories/sections/tools.js +155 -0
- package/src/adapters/dashboard/web/pages/memories/state.js +22 -0
- package/src/adapters/dashboard/web/pages/self/diff.js +79 -0
- package/src/adapters/dashboard/web/pages/self/index.js +43 -0
- package/src/adapters/dashboard/web/pages/self/markdown.js +61 -0
- package/src/adapters/dashboard/web/pages/self/sections/journal.js +32 -0
- package/src/adapters/dashboard/web/pages/self/sections/page.js +149 -0
- package/src/adapters/dashboard/web/pages/self/sections/settling.js +150 -0
- package/src/adapters/dashboard/web/pages/self/sections/stories.js +47 -0
- package/src/adapters/dashboard/web/pages/self/sections/wake.js +74 -0
- package/src/adapters/dashboard/web/pages/self/self.css +182 -0
- package/src/adapters/dashboard/web/server.ts +305 -28
- package/src/adapters/dashboard/web/shared/absence.js +14 -0
- package/src/adapters/dashboard/web/shared/actions.js +48 -0
- package/src/adapters/dashboard/web/shared/api.js +17 -0
- package/src/adapters/dashboard/web/shared/base.css +34 -0
- package/src/adapters/dashboard/web/shared/canvas.js +68 -0
- package/src/adapters/dashboard/web/shared/colors.js +6 -0
- package/src/adapters/dashboard/web/shared/dom.js +4 -0
- package/src/adapters/dashboard/web/shared/event-modal.js +25 -0
- package/src/adapters/dashboard/web/shared/fonts/OFL-courier-prime.txt +93 -0
- package/src/adapters/dashboard/web/shared/fonts/OFL-outfit.txt +93 -0
- package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-400.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/fonts/courier-prime-latin-700.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/fonts/outfit-latin-wght.woff2 +0 -0
- package/src/adapters/dashboard/web/shared/format.js +31 -0
- package/src/adapters/dashboard/web/shared/layout.css +32 -0
- package/src/adapters/dashboard/web/shared/memory-modal.js +124 -0
- package/src/adapters/dashboard/web/shared/modal.css +24 -0
- package/src/adapters/dashboard/web/shared/modal.js +22 -0
- package/src/adapters/dashboard/web/shared/state.js +12 -0
- package/src/adapters/dashboard/web/shared/tip.css +4 -0
- package/src/adapters/dashboard/web/shared/tip.js +12 -0
- package/src/adapters/dashboard/web/shared/tokens.css +50 -0
- package/src/adapters/dashboard/web/shared/type.css +52 -0
- package/src/adapters/dashboard/web/shared/utilities.css +5 -0
- package/src/adapters/dashboard/web/shared/vendor/MIT-three.txt +21 -0
- package/src/adapters/dashboard/web/shared/vendor/three.module.min.js +6 -0
- package/src/adapters/dashboard/web/shared/widgets/bar.css +9 -0
- package/src/adapters/dashboard/web/shared/widgets/card.css +6 -0
- package/src/adapters/dashboard/web/shared/widgets/chapters.js +15 -0
- package/src/adapters/dashboard/web/shared/widgets/chart.css +4 -0
- package/src/adapters/dashboard/web/shared/widgets/confirm.css +31 -0
- package/src/adapters/dashboard/web/shared/widgets/confirm.js +52 -0
- package/src/adapters/dashboard/web/shared/widgets/feed.css +13 -0
- package/src/adapters/dashboard/web/shared/widgets/feed.js +41 -0
- package/src/adapters/dashboard/web/shared/widgets/light.css +4 -0
- package/src/adapters/dashboard/web/shared/widgets/light.js +15 -0
- package/src/adapters/dashboard/web/shared/widgets/rows.css +7 -0
- package/src/adapters/dashboard/web/shared/widgets/table.css +17 -0
- package/src/adapters/dashboard/web/shared/widgets/tiles.css +14 -0
- package/src/adapters/dashboard/web/shell/pages.js +15 -0
- package/src/adapters/dashboard/web/shell/pulse.js +86 -0
- package/src/adapters/dashboard/web/shell/tabs.js +49 -0
- package/src/adapters/dashboard/web/static.ts +76 -0
- package/src/adapters/dashboard/web/views/activity.ts +80 -0
- package/src/adapters/dashboard/web/views/archive-words.ts +57 -0
- package/src/adapters/dashboard/web/views/flow-view.ts +217 -0
- package/src/adapters/dashboard/web/views/health.ts +328 -0
- package/src/adapters/dashboard/web/views/mechanism-panel.ts +370 -0
- package/src/adapters/dashboard/web/views/mechanisms.ts +302 -0
- package/src/adapters/dashboard/web/views/memories.ts +342 -0
- package/src/adapters/dashboard/web/views/memory.ts +210 -0
- package/src/adapters/dashboard/web/views/meta.ts +64 -0
- package/src/adapters/dashboard/web/views/mind.ts +729 -0
- package/src/adapters/dashboard/web/views/overview.ts +282 -0
- package/src/adapters/dashboard/web/views/pulse.ts +19 -0
- package/src/adapters/dashboard/web/views/rows.ts +207 -0
- package/src/adapters/dashboard/web/views/search.ts +62 -0
- package/src/adapters/dashboard/web/views/shared.ts +161 -0
- package/src/adapters/dashboard/web/views.ts +34 -1724
- package/src/adapters/fired.ts +138 -31
- package/src/adapters/mcp/INTERFACE-GAPS.md +4 -1
- package/src/adapters/mcp/NOTES.md +43 -0
- package/src/adapters/mcp/bin/serve.ts +9 -1
- package/src/adapters/mcp/index.ts +7 -0
- package/src/adapters/mcp/server.ts +167 -6
- package/src/adapters/mcp/tools.ts +42 -0
- package/src/adapters/mcp/write-up.ts +1 -1
- package/src/adapters/sessions.ts +18 -1
- package/src/adapters/snapshots.ts +71 -39
- package/src/core/associate/INTERFACE-GAPS.md +8 -0
- package/src/core/counterpart.ts +86 -7
- package/src/core/encode/INTERFACE-GAPS.md +12 -0
- package/src/core/feelings-wheel.ts +218 -0
- package/src/core/handoff/INTERFACE-GAPS.md +2 -0
- package/src/core/mint.ts +14 -2
- package/src/core/prospective/INTERFACE-GAPS.md +14 -0
- package/src/core/prospective/windows.ts +10 -48
- package/src/core/recall/INTERFACE-GAPS.md +6 -0
- package/src/core/remember/INTERFACE-GAPS.md +10 -0
- package/src/core/schemas/INTERFACE-GAPS.md +8 -0
- package/src/core/schemas/NOTES.md +118 -1
- package/src/core/schemas/index.ts +330 -40
- package/src/core/schemas/tunables.ts +23 -0
- package/src/core/schemas/types.ts +64 -1
- package/src/core/self/CONTRACT.md +3 -0
- package/src/core/self/INTERFACE-GAPS.md +10 -0
- package/src/core/self/NOTES.md +33 -2
- package/src/core/self/calendar.ts +7 -78
- package/src/core/self/episodes.ts +52 -12
- package/src/core/self/index.ts +40 -12
- package/src/core/self/writer.ts +22 -22
- package/src/core/sleep/NOTES.md +36 -0
- package/src/core/sleep/cycle.ts +38 -3
- package/src/core/sleep/fade.ts +76 -0
- package/src/core/sleep/index.ts +4 -1
- package/src/core/sleep/prune.ts +8 -1
- package/src/core/sleep/tunables.ts +5 -0
- package/src/core/sleep/types.ts +24 -0
- package/src/core/store/CONTRACT.md +36 -7
- package/src/core/store/NOTES.md +197 -0
- package/src/core/store/errors.ts +22 -0
- package/src/core/store/feelings.ts +182 -0
- package/src/core/store/index.ts +339 -45
- package/src/core/store/operational.ts +240 -22
- package/src/core/store/owner-op-seam.ts +13 -3
- package/src/core/store/paths.ts +15 -1
- package/src/core/store/pre-migration.ts +258 -0
- package/src/core/store/prose.ts +8 -1
- package/src/core/store/render.ts +3 -0
- package/src/core/time.ts +374 -0
- package/src/core/types.ts +13 -0
- package/src/adapters/dashboard/web/brain.html +0 -463
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
.bar{display:grid;grid-template-columns:92px 1fr auto;gap:11px;align-items:center;margin:8px 0;font-size:11.5px}
|
|
2
|
+
.bar .track{display:block;height:9px;background:var(--deep);border-radius:5px;overflow:hidden;
|
|
3
|
+
border:1px solid rgba(0,229,255,.06)}
|
|
4
|
+
.bar .fill{display:block;height:100%;border-radius:5px;background:var(--cyan);box-shadow:0 0 9px rgba(0,229,255,.35)}
|
|
5
|
+
.bar .n{text-align:right;color:var(--dim);font-variant-numeric:tabular-nums;white-space:nowrap;min-width:44px}
|
|
6
|
+
.bar .lab{color:var(--ink)}
|
|
7
|
+
.bar .lab.none{color:var(--dim)}
|
|
8
|
+
.gloss{color:var(--faint);font-size:10.5px;margin:-2px 0 8px 103px}
|
|
9
|
+
@media(max-width:520px){.bar{grid-template-columns:78px 1fr 40px}.gloss{margin-left:0}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
.card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);margin-bottom:8px;
|
|
2
|
+
overflow:hidden;transition:border-color .3s,box-shadow .3s}
|
|
3
|
+
.pad{padding:14px 16px}
|
|
4
|
+
.empty{color:var(--dim);font-size:11.5px;padding:13px 15px;border:1px dashed var(--glow);
|
|
5
|
+
border-radius:var(--radius);margin-bottom:8px;line-height:1.65}
|
|
6
|
+
.empty b{color:var(--amber);font-weight:400}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* The journal's chapters as clickable rows. The overview and the mind page
|
|
2
|
+
both show them, under their own headings. */
|
|
3
|
+
import { absenceLine } from "../absence.js";
|
|
4
|
+
import { esc } from "../dom.js";
|
|
5
|
+
|
|
6
|
+
export function chapterRows(chapters, absent) {
|
|
7
|
+
return absent
|
|
8
|
+
? absenceLine(absent, "no chapter has been written")
|
|
9
|
+
: chapters.map((c) =>
|
|
10
|
+
'<div class="r click" onclick="openMemory(\'' + c.id + '\')"><span style="color:var(--cyan)">' +
|
|
11
|
+
esc(c.title) + "</span>" +
|
|
12
|
+
'<div style="color:var(--dim);margin-top:4px">' + esc(c.opening) + "</div>" +
|
|
13
|
+
'<div class="meta"><span>lived day ' + c.day + "</span><span>" + c.bytes + " bytes</span></div></div>"
|
|
14
|
+
).join("");
|
|
15
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
.chart{padding:12px 14px 6px;position:relative}
|
|
2
|
+
.chart canvas{width:100%;display:block}
|
|
3
|
+
.legend{display:flex;gap:14px;font-size:10px;color:var(--dim);padding:2px 15px 12px;flex-wrap:wrap}
|
|
4
|
+
.legend .chip{display:inline-block;width:8px;height:8px;border-radius:4px;margin-right:5px;vertical-align:-1px}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* The typed confirmation (widgets/confirm.js) and the console's answer as the
|
|
2
|
+
page shows it (shared/actions.js). Above the overlay card on purpose. */
|
|
3
|
+
.confirm-back{position:fixed;inset:0;background:rgba(3,6,11,.85);z-index:300;display:flex;
|
|
4
|
+
align-items:flex-start;justify-content:center;padding:12vh 16px}
|
|
5
|
+
.confirm{background:var(--card);border:1px solid var(--red);border-radius:8px;max-width:640px;width:100%;
|
|
6
|
+
max-height:76vh;overflow-y:auto;padding:18px 22px}
|
|
7
|
+
.confirm h3{font-size:13px;color:var(--red);font-weight:400;letter-spacing:1px;margin-bottom:10px}
|
|
8
|
+
.confirm-body{font-size:11px;line-height:1.6;margin-bottom:12px}
|
|
9
|
+
.confirm-label{display:block;font-size:11px;color:var(--dim);margin-bottom:12px}
|
|
10
|
+
.confirm-label b{color:var(--ink);font-weight:400}
|
|
11
|
+
.confirm-input,.act-form input,.act-form textarea{display:block;width:100%;margin-top:6px;background:var(--deep);
|
|
12
|
+
color:var(--ink);border:1px solid var(--border);border-radius:var(--radius);font:inherit;font-size:12px;padding:7px 9px}
|
|
13
|
+
.confirm-buttons{display:flex;gap:10px;justify-content:flex-end}
|
|
14
|
+
.confirm-buttons button,.act-btn{background:none;border:1px solid var(--border);border-radius:3px;color:var(--dim);
|
|
15
|
+
font:inherit;font-size:10.5px;letter-spacing:.6px;padding:4px 12px;cursor:pointer}
|
|
16
|
+
.confirm-buttons button:hover,.act-btn:hover{color:var(--cyan);border-color:var(--glow)}
|
|
17
|
+
.confirm-go{color:var(--red)!important;border-color:var(--red)!important}
|
|
18
|
+
.confirm-go:disabled{opacity:.35;cursor:not-allowed}
|
|
19
|
+
.act-danger{color:var(--red);border-color:rgba(255,82,82,.4)}
|
|
20
|
+
.act-out{white-space:pre-wrap;word-break:break-word;font-size:11px;line-height:1.6;background:var(--deep);
|
|
21
|
+
border:1px solid var(--border);border-radius:var(--radius);padding:9px 11px;margin-top:8px}
|
|
22
|
+
.act-out.act-refused{border-color:rgba(255,215,64,.35)}
|
|
23
|
+
.act-out.act-bad{border-color:rgba(255,82,82,.4)}
|
|
24
|
+
.act-cmd{color:var(--faint);margin-bottom:4px}
|
|
25
|
+
.act-err{color:var(--amber)}
|
|
26
|
+
.act-form{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin:6px 0 14px}
|
|
27
|
+
.act-form details{font-size:11px;color:var(--dim)}
|
|
28
|
+
.act-form summary{cursor:pointer;letter-spacing:.6px}
|
|
29
|
+
.act-form summary:hover{color:var(--cyan)}
|
|
30
|
+
.act-form .act-row{display:flex;gap:8px;margin-top:6px}
|
|
31
|
+
@media (max-width:760px){.act-form{grid-template-columns:1fr}}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* A confirmation the owner has to MEAN: a dialog that shows what is about to
|
|
2
|
+
happen and asks for a phrase to be typed back before the button works.
|
|
3
|
+
|
|
4
|
+
It sits above everything, the memory card included, and it resolves to the
|
|
5
|
+
typed phrase (or null when the owner backs out). The phrase is not checked
|
|
6
|
+
here beyond enabling the button: what was typed goes to the console, and the
|
|
7
|
+
console's own comparison is what refuses a mismatch. */
|
|
8
|
+
import { esc } from "../dom.js";
|
|
9
|
+
|
|
10
|
+
let open = null;
|
|
11
|
+
|
|
12
|
+
/** confirmTyped({ title, bodyHtml, phrase, action }) → Promise<string|null> */
|
|
13
|
+
export function confirmTyped(opts) {
|
|
14
|
+
if (open) open.close(null);
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
const back = document.createElement("div");
|
|
17
|
+
back.className = "confirm-back";
|
|
18
|
+
back.innerHTML =
|
|
19
|
+
'<div class="confirm" role="dialog" aria-modal="true" aria-labelledby="confirm-title">' +
|
|
20
|
+
'<h3 id="confirm-title">' + esc(opts.title) + "</h3>" +
|
|
21
|
+
'<div class="confirm-body">' + (opts.bodyHtml || "") + "</div>" +
|
|
22
|
+
'<label class="confirm-label">Type <b>' + esc(opts.phrase) + "</b> to confirm" +
|
|
23
|
+
'<input class="confirm-input" type="text" autocomplete="off" spellcheck="false"></label>' +
|
|
24
|
+
'<div class="confirm-buttons">' +
|
|
25
|
+
'<button class="confirm-cancel" type="button">cancel</button>' +
|
|
26
|
+
'<button class="confirm-go" type="button" disabled>' + esc(opts.action || "confirm") + "</button>" +
|
|
27
|
+
"</div>" +
|
|
28
|
+
"</div>";
|
|
29
|
+
const input = back.querySelector(".confirm-input");
|
|
30
|
+
const go = back.querySelector(".confirm-go");
|
|
31
|
+
const close = (value) => {
|
|
32
|
+
if (open !== handle) return;
|
|
33
|
+
open = null;
|
|
34
|
+
removeEventListener("keydown", onKey, true);
|
|
35
|
+
back.parentNode && back.parentNode.removeChild(back);
|
|
36
|
+
resolve(value);
|
|
37
|
+
};
|
|
38
|
+
const handle = { close };
|
|
39
|
+
const onKey = (e) => {
|
|
40
|
+
if (e.key === "Escape") { e.stopPropagation(); close(null); }
|
|
41
|
+
if (e.key === "Enter" && !go.disabled) { e.stopPropagation(); close(input.value); }
|
|
42
|
+
};
|
|
43
|
+
input.addEventListener("input", () => { go.disabled = input.value.trim() !== opts.phrase; });
|
|
44
|
+
go.addEventListener("click", () => close(input.value));
|
|
45
|
+
back.querySelector(".confirm-cancel").addEventListener("click", () => close(null));
|
|
46
|
+
back.addEventListener("click", (e) => { if (e.target === back) close(null); });
|
|
47
|
+
addEventListener("keydown", onKey, true);
|
|
48
|
+
open = handle;
|
|
49
|
+
document.body.appendChild(back);
|
|
50
|
+
input.focus();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.feed{max-height:440px;overflow-y:auto}
|
|
2
|
+
.ev{display:grid;grid-template-columns:52px 1fr;gap:11px;padding:9px 14px;border-bottom:1px solid var(--border);
|
|
3
|
+
font-size:11.5px;cursor:pointer;align-items:baseline}
|
|
4
|
+
.ev:last-child{border-bottom:none}
|
|
5
|
+
.ev:hover{background:var(--hover)}
|
|
6
|
+
.ev .d{color:var(--faint);font-size:10px;white-space:nowrap}
|
|
7
|
+
.ev .t{line-height:1.55;color:var(--ink)}
|
|
8
|
+
.ev .k{display:block;color:var(--faint);font-size:9.5px;letter-spacing:.6px;margin-top:3px}
|
|
9
|
+
.ev.amber .t{color:var(--amber)}
|
|
10
|
+
.ev.notable .t{color:#dfe6ee}
|
|
11
|
+
.ev.calm .t{color:var(--dim)}
|
|
12
|
+
.ev.flash{animation:evflash 1.8s ease-out}
|
|
13
|
+
@keyframes evflash{0%{background:rgba(0,229,255,.14)}100%{background:transparent}}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* The activity feed: narrated durable-log rows, newest first. Any page may
|
|
2
|
+
render one; a feed REGISTERED as live also receives the pulse's new rows
|
|
3
|
+
(`shell/pulse.js`), prepended and flashed. */
|
|
4
|
+
import { absenceLine } from "../absence.js";
|
|
5
|
+
import { $, esc } from "../dom.js";
|
|
6
|
+
import { openEvent } from "../event-modal.js";
|
|
7
|
+
|
|
8
|
+
export function renderFeed(el, events, ctx) {
|
|
9
|
+
if (!events || events.length === 0) {
|
|
10
|
+
el.innerHTML = absenceLine(ctx && ctx.feedAbsent ? ctx.feedAbsent : "(never run)", "nothing has reached my durable log");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
el.innerHTML = events.map((e) =>
|
|
14
|
+
'<div class="ev ' + e.tone + '" data-seq="' + e.seq + '" onclick="openEvent(' + e.seq + ')">' +
|
|
15
|
+
'<span class="d">day ' + e.day + "</span>" +
|
|
16
|
+
'<span class="t">' + esc(e.text) + '<span class="k">' + esc(e.name) +
|
|
17
|
+
(e.node ? " · " + esc(e.node) : "") + "</span></span></div>"
|
|
18
|
+
).join("");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Element ids of the feeds the pulse writes into, in registration order. */
|
|
22
|
+
const LIVE = [];
|
|
23
|
+
export function registerLiveFeed(id) { if (!LIVE.includes(id)) LIVE.push(id); }
|
|
24
|
+
|
|
25
|
+
/** New events arrive oldest-first; each is inserted at the top, flashed. A feed
|
|
26
|
+
* still showing its absence line is left alone (its page repaints it). */
|
|
27
|
+
export function prependToLiveFeeds(fresh) {
|
|
28
|
+
for (const el of LIVE.map((id) => $(id))) {
|
|
29
|
+
if (!el || el.querySelector(".empty")) continue;
|
|
30
|
+
for (const e of fresh) {
|
|
31
|
+
const row = document.createElement("div");
|
|
32
|
+
row.className = "ev " + e.tone + " flash";
|
|
33
|
+
row.dataset.seq = e.seq;
|
|
34
|
+
row.onclick = () => openEvent(e.seq);
|
|
35
|
+
row.innerHTML = '<span class="d">day ' + e.day + '</span><span class="t">' + esc(e.text) +
|
|
36
|
+
'<span class="k">' + esc(e.name) + (e.node ? " · " + esc(e.node) : "") + "</span></span>";
|
|
37
|
+
el.insertBefore(row, el.firstChild);
|
|
38
|
+
}
|
|
39
|
+
while (el.children.length > 60) el.removeChild(el.lastChild);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/* The status light (widgets/light.js). */
|
|
2
|
+
.light{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none;background:var(--faint);opacity:.55}
|
|
3
|
+
.light-green{background:var(--teal);opacity:1;box-shadow:0 0 8px rgba(0,191,165,.7)}
|
|
4
|
+
.light-amber{background:var(--amber);opacity:1;box-shadow:0 0 8px rgba(255,215,64,.45)}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* The status light: one small dot that says whether a mechanism is working.
|
|
2
|
+
green — built, and it fired in the window
|
|
3
|
+
amber — built, and it has not fired in the window
|
|
4
|
+
grey — not built yet; it never claims activity
|
|
5
|
+
The word travels with the dot (as its accessible name), so the colour is
|
|
6
|
+
never the only carrier of the meaning. */
|
|
7
|
+
import { esc } from "../dom.js";
|
|
8
|
+
|
|
9
|
+
export const LIGHT_WORD = { green: "firing", amber: "quiet", grey: "not built yet" };
|
|
10
|
+
|
|
11
|
+
/** A light's markup. Unknown statuses draw grey rather than guess. */
|
|
12
|
+
export function light(status) {
|
|
13
|
+
const s = status === "green" || status === "amber" ? status : "grey";
|
|
14
|
+
return '<span class="light light-' + s + '" role="img" aria-label="' + esc(LIGHT_WORD[s]) + '"></span>';
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
.rows .r{padding:10px 15px;border-bottom:1px solid var(--border);font-size:11.5px;line-height:1.6}
|
|
2
|
+
.rows .r:last-child{border-bottom:none}
|
|
3
|
+
.rows .r.click{cursor:pointer}
|
|
4
|
+
.rows .r.click:hover{background:var(--hover)}
|
|
5
|
+
.rows .meta{color:var(--faint);font-size:10px;margin-top:4px;display:flex;gap:10px;flex-wrap:wrap}
|
|
6
|
+
.rows .meta .k{color:var(--dim)}
|
|
7
|
+
.withheld{color:var(--amber);font-style:italic}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
table{width:100%;border-collapse:collapse;font-size:11px}
|
|
2
|
+
th{text-align:left;color:var(--dim);font-weight:400;text-transform:uppercase;letter-spacing:1.1px;
|
|
3
|
+
font-size:9px;padding:9px 14px;border-bottom:1px solid var(--border);white-space:nowrap}
|
|
4
|
+
td{padding:8px 14px;border-bottom:1px solid var(--border);vertical-align:top}
|
|
5
|
+
tr:last-child td{border-bottom:none}
|
|
6
|
+
tbody tr.click{cursor:pointer}
|
|
7
|
+
tbody tr.click:hover{background:var(--hover)}
|
|
8
|
+
td.num,th.num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
9
|
+
td.dimtd{color:var(--dim)}
|
|
10
|
+
.tablewrap{overflow-x:auto}
|
|
11
|
+
/* The durable-record table: English on top, the identifier under it. Two
|
|
12
|
+
columns rather than three, so it survives a phone without a scroller. */
|
|
13
|
+
td .lead{color:var(--ink);line-height:1.5}
|
|
14
|
+
td .ident{color:var(--faint);font-size:9.5px;letter-spacing:.5px;margin-top:4px;
|
|
15
|
+
display:flex;gap:8px;flex-wrap:wrap;align-items:baseline}
|
|
16
|
+
td .ident .hostmark{color:var(--teal);text-transform:uppercase;letter-spacing:1px;font-size:8.5px}
|
|
17
|
+
td .ident .notemark{color:var(--faint)}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* 124, not 132: the tenth tile (beliefs and entities) has to sit on the first
|
|
2
|
+
row at 1440 rather than orphan itself under nine others. */
|
|
3
|
+
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(124px,1fr));gap:10px;margin-bottom:6px}
|
|
4
|
+
.tile{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:12px 14px;
|
|
5
|
+
transition:border-color .3s,box-shadow .3s}
|
|
6
|
+
.tile:hover,.card:hover{border-color:var(--glow);box-shadow:var(--hovershadow)}
|
|
7
|
+
.tile .n{font-size:23px;font-weight:300;color:var(--cyan);text-shadow:0 0 15px rgba(0,229,255,.2);
|
|
8
|
+
line-height:1.25;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
9
|
+
.tile .l{font-size:9.5px;color:var(--dim);text-transform:uppercase;letter-spacing:1.2px;margin-top:2px}
|
|
10
|
+
.tile .s{font-size:10px;color:var(--faint);margin-top:3px;line-height:1.45}
|
|
11
|
+
.tile.purple .n{color:var(--purple);text-shadow:0 0 15px rgba(179,136,255,.2)}
|
|
12
|
+
.tile.amber .n{color:var(--amber);text-shadow:0 0 15px rgba(255,215,64,.2)}
|
|
13
|
+
.tile.teal .n{color:var(--teal);text-shadow:0 0 15px rgba(0,191,165,.2)}
|
|
14
|
+
.tile.absent .n{color:var(--dim);font-size:15px;text-shadow:none;padding-top:6px;padding-bottom:2px}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* The page registry: which tabs exist, in nav order. Each page module's
|
|
2
|
+
default export is
|
|
3
|
+
{ name, mount(sectionEl), render(), — required
|
|
4
|
+
refresh?(), show?(), resize?(), redraw?(), — optional
|
|
5
|
+
onEvents?(fresh), onDeposit?() } — optional, the pulse
|
|
6
|
+
and `app.html` carries one `<section class="tab" id="tab-<name>">` for it. */
|
|
7
|
+
import home from "../pages/home/index.js";
|
|
8
|
+
import memories from "../pages/memories/index.js";
|
|
9
|
+
import self from "../pages/self/index.js";
|
|
10
|
+
import flow from "../pages/flow/index.js";
|
|
11
|
+
import health from "../pages/health/index.js";
|
|
12
|
+
|
|
13
|
+
export const PAGES = [home, memories, self, flow, health];
|
|
14
|
+
export const TABS = PAGES.map((p) => p.name);
|
|
15
|
+
export const PAGE = Object.fromEntries(PAGES.map((p) => [p.name, p]));
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* The pulse: a four-second poll. Particles ride only on events that are
|
|
2
|
+
actually new, and every page that counts is re-read when the store moves. */
|
|
3
|
+
import { api } from "../shared/api.js";
|
|
4
|
+
import { $ } from "../shared/dom.js";
|
|
5
|
+
import { live, tabs } from "../shared/state.js";
|
|
6
|
+
import { prependToLiveFeeds } from "../shared/widgets/feed.js";
|
|
7
|
+
import { PAGES } from "./pages.js";
|
|
8
|
+
|
|
9
|
+
export async function poll() {
|
|
10
|
+
let d;
|
|
11
|
+
try { d = await api("/api/activity?limit=40&sinceSeq=" + live.lastSeq); } catch (e) { return; }
|
|
12
|
+
// THE SECOND QUESTION, AND THE ONE THAT WAS MISSING.
|
|
13
|
+
//
|
|
14
|
+
// "Has anything happened" was asked of the event log alone, and the event log
|
|
15
|
+
// is not the whole truth: a deposit that writes no durable event never moves
|
|
16
|
+
// `lastSeq`, so the refetch never fired and a page left open on the flow tab
|
|
17
|
+
// said `143 came through` forever while the server already answered 144.
|
|
18
|
+
// `/api/meta` carries a row count for exactly this — one cheap request beside
|
|
19
|
+
// the one we were already making.
|
|
20
|
+
//
|
|
21
|
+
// The example was `counterparts note`, and it is no longer one: since
|
|
22
|
+
// `gate.deposit` (2026-09-05) the authored door writes a row like every other
|
|
23
|
+
// door, so a note moves the sequence and lands in the branch below. This stays
|
|
24
|
+
// as the belt — a store seeded around the door, and any future writer that
|
|
25
|
+
// leaves no row — because a freshness check that is only correct while one
|
|
26
|
+
// particular writer happens to log is not a freshness check.
|
|
27
|
+
let meta = null;
|
|
28
|
+
try { meta = await api("/api/meta"); } catch (e) { /* the next tick retries */ }
|
|
29
|
+
const deposited = meta !== null && live.fingerprint !== null &&
|
|
30
|
+
(meta.rows !== live.fingerprint.rows || meta.day !== live.fingerprint.day);
|
|
31
|
+
if (meta !== null) live.fingerprint = { rows: meta.rows, day: meta.day };
|
|
32
|
+
|
|
33
|
+
if (d.lastSeq > live.lastSeq) {
|
|
34
|
+
live.lastSeq = d.lastSeq;
|
|
35
|
+
// A new event means the store moved, so everything the pages count moved
|
|
36
|
+
// with it: left open, the flow page silently reported yesterday's numbers
|
|
37
|
+
// beside today's feed. Refresh the counters — and the lived day, which is
|
|
38
|
+
// the one number in the header that is allowed to change.
|
|
39
|
+
refreshCounters(meta);
|
|
40
|
+
const fresh = d.events.slice().reverse();
|
|
41
|
+
for (const page of PAGES) if (page.onEvents) page.onEvents(fresh);
|
|
42
|
+
prependToLiveFeeds(fresh);
|
|
43
|
+
// The wall clock gets its OWN chip, and only when something happened. It
|
|
44
|
+
// used to overwrite the lived-day chip on every four-second tick whether or
|
|
45
|
+
// not anything had — so the product's own clock survived four seconds and
|
|
46
|
+
// was then replaced by a host timestamp that means nothing to the store.
|
|
47
|
+
const seen = $("seen");
|
|
48
|
+
seen.hidden = false;
|
|
49
|
+
seen.textContent = "last event " + new Date().toTimeString().slice(0, 8);
|
|
50
|
+
} else if (deposited) {
|
|
51
|
+
// A deposit with no event of its own: the counters moved, and the pages
|
|
52
|
+
// that animate say so (the flow page's `onDeposit`).
|
|
53
|
+
refreshCounters(meta);
|
|
54
|
+
for (const page of PAGES) if (page.onDeposit) page.onDeposit();
|
|
55
|
+
// A different word, because it IS a different thing: something was stored,
|
|
56
|
+
// and nothing was recorded about the storing.
|
|
57
|
+
const seen = $("seen");
|
|
58
|
+
seen.hidden = false;
|
|
59
|
+
seen.textContent = "last deposit " + new Date().toTimeString().slice(0, 8);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* What a change to the store changes, re-read. The poll has already asked for
|
|
65
|
+
* `/api/meta`, so it hands it over rather than making the request twice.
|
|
66
|
+
*
|
|
67
|
+
* THE FLOW PAGE WAS NOT THE ONLY PAGE COUNTING. The first fix for the stale
|
|
68
|
+
* `143 came through` refreshed the flow diagram and stopped there, so the
|
|
69
|
+
* OVERVIEW — the page the dashboard opens on, the one in the README's first
|
|
70
|
+
* image — kept its boot-time tiles: `memories held`, `lived days`, the band
|
|
71
|
+
* bars, the identity panel, all frozen at whatever they were when the tab was
|
|
72
|
+
* opened, while the flow tab beside it moved. Same bug, one page over. Every
|
|
73
|
+
* page with a `refresh` (home, then flow) is re-read here, in nav order,
|
|
74
|
+
* from the one signal that catches a deposit with no durable event of its own.
|
|
75
|
+
*/
|
|
76
|
+
export async function refreshCounters(meta) {
|
|
77
|
+
try {
|
|
78
|
+
const m = meta ?? (await api("/api/meta"));
|
|
79
|
+
$("clock").textContent = "day " + m.day;
|
|
80
|
+
live.fingerprint = { rows: m.rows, day: m.day };
|
|
81
|
+
} catch (e) { /* the next poll retries */ }
|
|
82
|
+
for (const page of PAGES) {
|
|
83
|
+
if (!page.refresh || !tabs.loaded[page.name]) continue;
|
|
84
|
+
try { await page.refresh(); } catch (e) { /* the next poll retries */ }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* The nav strip and tab switching. A tab is built once, on first show (or at
|
|
2
|
+
boot — see `app.js`); coming back to it only redraws what is laid out by
|
|
3
|
+
width. */
|
|
4
|
+
import { $ } from "../shared/dom.js";
|
|
5
|
+
import { tabs } from "../shared/state.js";
|
|
6
|
+
import { PAGE, TABS } from "./pages.js";
|
|
7
|
+
|
|
8
|
+
/* Old hashes still land: a bookmark to `#overview` or `#mind` (and the
|
|
9
|
+
`/brain` page's links) open the tab under its new name, and the address bar
|
|
10
|
+
is corrected to it. */
|
|
11
|
+
const RENAMED = { overview: "home", mind: "self" };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A hash is `<tab>`, optionally with an anchor (`#self/settling`) or a query
|
|
15
|
+
* (`#memories?state=archived`): the tab opens and its page's `route(r)`, if it
|
|
16
|
+
* has one, is handed `{ anchor, params }` once the page is drawn.
|
|
17
|
+
*/
|
|
18
|
+
export function parseRoute(hash) {
|
|
19
|
+
const m = /^([^/?]*)(?:\/([^?]*))?(?:\?(.*))?$/.exec(hash || "");
|
|
20
|
+
return { name: (m && m[1]) || "", anchor: (m && m[2]) || null, params: new URLSearchParams((m && m[3]) || "") };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function showTab(hash, push) {
|
|
24
|
+
const route = parseRoute(hash);
|
|
25
|
+
let name = route.name;
|
|
26
|
+
let rest = hash && hash.length > name.length ? hash.slice(name.length) : "";
|
|
27
|
+
if (RENAMED[name]) { name = RENAMED[name]; push = true; }
|
|
28
|
+
if (!TABS.includes(name)) { name = "home"; rest = ""; }
|
|
29
|
+
tabs.current = name;
|
|
30
|
+
for (const t of TABS) {
|
|
31
|
+
$("tab-" + t).hidden = t !== name;
|
|
32
|
+
const link = $("nav-" + t);
|
|
33
|
+
if (link) link.classList.toggle("on", t === name);
|
|
34
|
+
}
|
|
35
|
+
if (push) history.replaceState(null, "", "#" + name + rest);
|
|
36
|
+
const page = PAGE[name];
|
|
37
|
+
let drawn;
|
|
38
|
+
if (!tabs.loaded[name]) { tabs.loaded[name] = true; drawn = page.render(); }
|
|
39
|
+
else if (page.show) drawn = page.show();
|
|
40
|
+
if (page.route && (route.anchor || [...route.params].length)) {
|
|
41
|
+
Promise.resolve(drawn).then(() => page.route({ anchor: route.anchor, params: route.params }));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function mountNav() {
|
|
46
|
+
$("nav").innerHTML = TABS.map((t) => '<a id="nav-' + t + '" href="#' + t + '">' + t + "</a>").join("");
|
|
47
|
+
for (const t of TABS) $("nav-" + t).onclick = (e) => { e.preventDefault(); showTab(t, true); };
|
|
48
|
+
addEventListener("hashchange", () => showTab(location.hash.slice(1), false));
|
|
49
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which URL paths are the page's own static files, and where each one lives.
|
|
3
|
+
*
|
|
4
|
+
* A pure function of the path — no filesystem here; `server.ts` does the one
|
|
5
|
+
* `readFileSync`. The page is split into plain browser ES modules and
|
|
6
|
+
* stylesheets under `web/` (see `web/README.md`), and this is the whole of what
|
|
7
|
+
* the server will hand out from that tree:
|
|
8
|
+
*
|
|
9
|
+
* - only `/app.js`, and files under `/shared/`, `/shell/`, `/pages/` and
|
|
10
|
+
* `/mechanisms/` — so `server.ts`, `views.ts`, the view modules and the
|
|
11
|
+
* HTML file are NOT reachable as files (the HTML has its own routes);
|
|
12
|
+
* - only an allow-listed extension: `.js`, `.css`, `.woff2`;
|
|
13
|
+
* - every path segment plain (`[A-Za-z0-9_-]` plus inner dots): no `..`, no
|
|
14
|
+
* `.`, no empty segment, no dotfile, no backslash, no NUL, no `%` left
|
|
15
|
+
* after ONE decode (so a double-encoded `%252e%252e` is refused, not
|
|
16
|
+
* decoded twice);
|
|
17
|
+
* - and the joined path must still sit under `web/`, checked after the join,
|
|
18
|
+
* as the last belt.
|
|
19
|
+
*
|
|
20
|
+
* Symlinks are not followed-and-checked: that would need `realpathSync`, and
|
|
21
|
+
* `server.ts`'s filesystem surface is pinned to `readFileSync` alone. The tree
|
|
22
|
+
* is the install's own files; `test/dashboard-web.test.ts` asserts it holds no
|
|
23
|
+
* symlink at all.
|
|
24
|
+
*/
|
|
25
|
+
import { resolve, sep } from "node:path";
|
|
26
|
+
|
|
27
|
+
export const STATIC_TOP_FILES: readonly string[] = ["app.js"];
|
|
28
|
+
export const STATIC_DIRS: readonly string[] = ["shared", "shell", "pages", "mechanisms"];
|
|
29
|
+
|
|
30
|
+
/** Extension → content type. Text types carry a charset: the modules hold
|
|
31
|
+
* `κ ι — × ↓` literals, and a module script with the wrong MIME is refused. */
|
|
32
|
+
export const STATIC_TYPES: Readonly<Record<string, string>> = {
|
|
33
|
+
".js": "text/javascript; charset=utf-8",
|
|
34
|
+
".css": "text/css; charset=utf-8",
|
|
35
|
+
".woff2": "font/woff2",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export interface StaticFile {
|
|
39
|
+
readonly file: string;
|
|
40
|
+
readonly contentType: string;
|
|
41
|
+
/** True for a text type, which is read and served as UTF-8. */
|
|
42
|
+
readonly text: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const SEGMENT = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
|
|
46
|
+
|
|
47
|
+
/** Resolve a request path against the `web/` root, or null for "not a static file". */
|
|
48
|
+
export function resolveStatic(pathname: string, root: string): StaticFile | null {
|
|
49
|
+
let decoded: string;
|
|
50
|
+
try {
|
|
51
|
+
decoded = decodeURIComponent(pathname);
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (!decoded.startsWith("/")) return null;
|
|
56
|
+
const rel = decoded.slice(1);
|
|
57
|
+
if (rel.length === 0 || rel.includes("\0") || rel.includes("\\")) return null;
|
|
58
|
+
const segments = rel.split("/");
|
|
59
|
+
for (const segment of segments) {
|
|
60
|
+
if (!SEGMENT.test(segment) || segment.includes("..")) return null;
|
|
61
|
+
}
|
|
62
|
+
if (segments.length === 1) {
|
|
63
|
+
if (!STATIC_TOP_FILES.includes(rel)) return null;
|
|
64
|
+
} else if (!STATIC_DIRS.includes(segments[0] as string)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const last = segments[segments.length - 1] as string;
|
|
68
|
+
const dot = last.lastIndexOf(".");
|
|
69
|
+
if (dot <= 0) return null;
|
|
70
|
+
const contentType = STATIC_TYPES[last.slice(dot).toLowerCase()];
|
|
71
|
+
if (contentType === undefined) return null;
|
|
72
|
+
const base = resolve(root);
|
|
73
|
+
const file = resolve(base, ...segments);
|
|
74
|
+
if (!file.startsWith(base + sep)) return null;
|
|
75
|
+
return { file, contentType, text: contentType.includes("charset=") };
|
|
76
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/api/activity` and `/api/event` — the durable log, narrated.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `web/views.ts`, which re-exports every public name from here;
|
|
5
|
+
* the four rules in that file's header apply to every line below.
|
|
6
|
+
*/
|
|
7
|
+
import { localClock } from "../../../../core/time.js";
|
|
8
|
+
import { NEVER, NONE } from "../../layout.js";
|
|
9
|
+
import { DURABLE_EVENTS, DURABLE_EVENT_NAMES } from "../../registries.js";
|
|
10
|
+
import type { DurableEventName } from "../../registries.js";
|
|
11
|
+
import type { DashboardSource } from "../../source.js";
|
|
12
|
+
import { FLOW_NODES, eventsOfNode } from "../flow.js";
|
|
13
|
+
import { narrate } from "../narrate.js";
|
|
14
|
+
import type { NarratedEvent } from "../narrate.js";
|
|
15
|
+
import { FEED_LIMIT, LOG_CEILING, eventCountsByName } from "./shared.js";
|
|
16
|
+
|
|
17
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
+
// activity
|
|
19
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
export interface ActivityView {
|
|
22
|
+
readonly events: NarratedEvent[];
|
|
23
|
+
readonly total: number;
|
|
24
|
+
readonly lastSeq: number;
|
|
25
|
+
readonly retentionDays: number;
|
|
26
|
+
readonly bound: string;
|
|
27
|
+
readonly absent: string | null;
|
|
28
|
+
readonly vocabulary: { name: DurableEventName; count: number; description: string; absent: string | null; node: string | null }[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function activityView(
|
|
32
|
+
src: DashboardSource,
|
|
33
|
+
opts: { limit?: number; name?: string; sinceSeq?: number } = {},
|
|
34
|
+
): ActivityView {
|
|
35
|
+
const store = src.store;
|
|
36
|
+
const limit = opts.limit ?? FEED_LIMIT;
|
|
37
|
+
const filter: { name?: string; limit: number } = { limit: LOG_CEILING };
|
|
38
|
+
if (opts.name !== undefined && opts.name.length > 0) filter.name = opts.name;
|
|
39
|
+
const all = store.eventLog(filter);
|
|
40
|
+
const since = opts.sinceSeq;
|
|
41
|
+
const window = since === undefined ? all.slice(-limit).reverse() : all.filter((r) => r.seq > since);
|
|
42
|
+
const events = window.map((row) => narrate(store, row));
|
|
43
|
+
const lastSeq = all.length === 0 ? 0 : (all[all.length - 1]?.seq ?? 0);
|
|
44
|
+
const everLived = store.livedDay() > 0 || store.list().length > 0;
|
|
45
|
+
const counts = eventCountsByName(src);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
events,
|
|
49
|
+
total: all.length,
|
|
50
|
+
lastSeq,
|
|
51
|
+
retentionDays: store.retentionDays,
|
|
52
|
+
bound:
|
|
53
|
+
`I keep events for ${store.retentionDays} lived days; older ones are swept unless a replay latch holds them. ` +
|
|
54
|
+
"This is what I still have, not everything that ever happened.",
|
|
55
|
+
absent: events.length === 0 ? (everLived ? NONE : NEVER) : null,
|
|
56
|
+
vocabulary: DURABLE_EVENT_NAMES.map((name) => {
|
|
57
|
+
const count = counts.get(name) ?? 0;
|
|
58
|
+
return {
|
|
59
|
+
name,
|
|
60
|
+
count,
|
|
61
|
+
description: DURABLE_EVENTS[name],
|
|
62
|
+
absent: count === 0 ? NEVER : null,
|
|
63
|
+
node: (FLOW_NODES.find((nd) => eventsOfNode(nd.key).includes(name))?.key ?? null),
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** One record, opened. `when` is its moment on the reader's clock, converted
|
|
70
|
+
* here (`core/time.ts`), so the page never builds a date itself. */
|
|
71
|
+
export function eventDetail(
|
|
72
|
+
src: DashboardSource,
|
|
73
|
+
seq: number,
|
|
74
|
+
): { found: boolean; event: NarratedEvent | null; when: string | null } {
|
|
75
|
+
const store = src.store;
|
|
76
|
+
for (const row of store.eventLog({ limit: LOG_CEILING })) {
|
|
77
|
+
if (row.seq === seq) return { found: true, event: narrate(store, row), when: localClock(row.at, store.zone()) };
|
|
78
|
+
}
|
|
79
|
+
return { found: false, event: null, when: null };
|
|
80
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a memory was archived, in plain words — the one table the health tab's
|
|
3
|
+
* archive bar, the memories list and the home count all read.
|
|
4
|
+
*
|
|
5
|
+
* `many` names a group ("old handoff notes cleared · 12"); `one` names a single
|
|
6
|
+
* row on its card. A reason not in the table still gets words, from
|
|
7
|
+
* `unmappedArchiveWords`, so nothing archived is ever left unsaid.
|
|
8
|
+
*/
|
|
9
|
+
import { TUNABLES as SCHEMA_TUNABLES } from "../../../../core/schemas/index.js";
|
|
10
|
+
import { MERGE_ARCHIVE_REASON, PRUNE_ARCHIVE_REASON } from "../../../../core/sleep/index.js";
|
|
11
|
+
|
|
12
|
+
/** `owner-op-seam.ts#REMOVED_REASON`, spelled here because that module is the
|
|
13
|
+
* store's WRITE seam and this directory imports no write seam. */
|
|
14
|
+
export const REMOVED_BY_OWNER = "removed-by-owner";
|
|
15
|
+
|
|
16
|
+
export interface ArchiveReasonWords {
|
|
17
|
+
readonly reason: string;
|
|
18
|
+
readonly many: string;
|
|
19
|
+
readonly one: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** EVERY `archived_reason` the code writes, in the order the health bar draws them. */
|
|
23
|
+
export const ARCHIVE_WORDS: readonly ArchiveReasonWords[] = [
|
|
24
|
+
{ reason: "handoff-cleared", many: "old handoff notes cleared", one: "old handoff note cleared" },
|
|
25
|
+
{ reason: "handoff-duplicate", many: "duplicate handoff notes retired", one: "a repeated handoff note, cleared" },
|
|
26
|
+
{ reason: SCHEMA_TUNABLES.REVISED_REASON, many: "revised", one: "revised — a newer version replaced it" },
|
|
27
|
+
{ reason: SCHEMA_TUNABLES.REPLACED_REASON, many: "replaced by a correction", one: "replaced by a correction" },
|
|
28
|
+
{ reason: "supersede", many: "replaced by a newer version", one: "replaced by a newer version" },
|
|
29
|
+
{ reason: "episode-regrown", many: "rebuilt from the journal", one: "regrown from its episode — a newer reading replaced it" },
|
|
30
|
+
{ reason: SCHEMA_TUNABLES.FADE_REASON, many: "faded from use", one: "faded away — nothing mentions it any more" },
|
|
31
|
+
{ reason: PRUNE_ARCHIVE_REASON, many: "let go at the floor", one: "let go at the floor — too weak for too long" },
|
|
32
|
+
{ reason: MERGE_ARCHIVE_REASON, many: "merged duplicates", one: "merged into a near-duplicate" },
|
|
33
|
+
{ reason: REMOVED_BY_OWNER, many: "removed by you", one: "removed by you" },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
/** `[reason, many]` pairs, in the bar's order. */
|
|
37
|
+
export const ARCHIVE_PHRASES: readonly (readonly [string, string])[] = ARCHIVE_WORDS.map((w) => [w.reason, w.many] as const);
|
|
38
|
+
|
|
39
|
+
const BY_REASON = new Map(ARCHIVE_WORDS.map((w) => [w.reason, w]));
|
|
40
|
+
|
|
41
|
+
/** The table's entry for a reason, or undefined when the table has none. */
|
|
42
|
+
export function archiveEntry(reason: string | null): ArchiveReasonWords | undefined {
|
|
43
|
+
return reason === null ? undefined : BY_REASON.get(reason);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The one fallback: a reason nobody mapped keeps its own name; no reason says so. */
|
|
47
|
+
export function unmappedArchiveWords(reason: string | null): string {
|
|
48
|
+
return reason === null || reason.length === 0 ? "archived, no reason recorded" : `archived (${reason})`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** One archived row, in words, for its card or list line. */
|
|
52
|
+
export function archiveWords(reason: string | null, superseded: boolean): string {
|
|
53
|
+
const entry = archiveEntry(reason);
|
|
54
|
+
if (entry !== undefined) return entry.one;
|
|
55
|
+
if (superseded) return "revised — a newer version replaced it";
|
|
56
|
+
return unmappedArchiveWords(reason);
|
|
57
|
+
}
|