flop-guild 0.2.13 → 0.2.14
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/dist/content.js +13 -1
- package/dist/econ.js +43 -26
- package/dist/minerpage.js +83 -11
- package/dist/miners.js +5 -2
- package/dist/server.js +20 -8
- package/dist/shell.js +73 -4
- package/package.json +1 -1
- package/site/start.html +29 -18
- package/site/toc.js +27 -0
package/dist/content.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// quick start, the packaged skill.md and the hosted MCP all render from here, so they cannot drift.
|
|
3
3
|
// Text uses a small Markdown subset: `code`, [text](url), and the word PROVISIONAL.
|
|
4
4
|
import { render } from "./config.js";
|
|
5
|
-
import { esc } from "./shell.js";
|
|
5
|
+
import { esc, sideCard } from "./shell.js";
|
|
6
6
|
import { testnetLine } from "./testnet.js";
|
|
7
7
|
export const ROLES = [
|
|
8
8
|
{
|
|
@@ -259,3 +259,15 @@ ${notes}
|
|
|
259
259
|
export function guidesHtml(icon) {
|
|
260
260
|
return `<div class="agent-links">\n${GUIDES.map((g) => ` <a class="card link-card" href="/guides/${g.slug}"><span class="tile">${icon}</span><span><b>${esc(g.title)}</b><span class="muted small">${esc(g.summary)}</span></span></a>`).join("\n")}\n</div>`;
|
|
261
261
|
}
|
|
262
|
+
// ---------- inner page sidebars ----------
|
|
263
|
+
/** "On this page": built from the h2 sections; /toc.js marks the section in view. */
|
|
264
|
+
export function tocCard(toc, icons) {
|
|
265
|
+
const body = toc.length
|
|
266
|
+
? `<ul class="links toc">${toc.map((t) => `<li><a href="#${t.id}">${esc(t.text)}</a></li>`).join("")}</ul>`
|
|
267
|
+
: '<p class="muted small">This guide is a single section.</p>';
|
|
268
|
+
return sideCard("On this page", body, icons.doc, ' data-toc=""');
|
|
269
|
+
}
|
|
270
|
+
export function relatedGuidesCard(current, icons) {
|
|
271
|
+
const others = GUIDES.filter((g) => g.slug !== current);
|
|
272
|
+
return sideCard("Related guides", `<ul class="links">${others.map((g) => `<li><a href="/guides/${g.slug}">${esc(g.title)}</a></li>`).join("")}</ul>`, icons.agent);
|
|
273
|
+
}
|
package/dist/econ.js
CHANGED
|
@@ -41,34 +41,43 @@ const DEADLINE_MS = 150_000;
|
|
|
41
41
|
* page cap marks the read as incomplete. Sessions are counted once per channelId.
|
|
42
42
|
*/
|
|
43
43
|
export const PAGE_RETRY_WAITS = [2_000, 5_000, 10_000];
|
|
44
|
-
|
|
44
|
+
export const PARALLEL_PAGES = 4;
|
|
45
|
+
/**
|
|
46
|
+
* One explorer page. Network errors, 429 and 5xx are retried up to 3 times (2 s, 5 s, 10 s, or the
|
|
47
|
+
* server's Retry-After when longer). Other 4xx answers are not retried: asking again will not help.
|
|
48
|
+
*/
|
|
45
49
|
export async function pageWithRetry(base, p, fetchPage = channelPage, sleep = (ms) => new Promise((r) => setTimeout(r, ms)), waits = PAGE_RETRY_WAITS) {
|
|
46
50
|
for (let i = 0;; i++) {
|
|
47
51
|
try {
|
|
48
52
|
return await fetchPage(base, p);
|
|
49
53
|
}
|
|
50
54
|
catch (e) {
|
|
51
|
-
|
|
55
|
+
const st = e.status;
|
|
56
|
+
const retryable = st === undefined || st === 429 || st >= 500;
|
|
57
|
+
if (!retryable || i >= waits.length)
|
|
52
58
|
throw e;
|
|
53
|
-
await sleep(waits[i]);
|
|
59
|
+
await sleep(Math.max(waits[i], e.retryAfterMs ?? 0));
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
}
|
|
63
|
+
export const RESUME_MAX_AGE_MS = 15 * 60 * 1000;
|
|
57
64
|
export async function loadDemand(network, explorer, now = Date.now(), o = {}) {
|
|
58
65
|
const base = explorer.replace(/\/+$/, "");
|
|
66
|
+
const r = o.resume && o.resume.base === base && o.resume.network === network && Date.now() - o.resume.startedAt < RESUME_MAX_AGE_MS ? o.resume : undefined;
|
|
67
|
+
if (r)
|
|
68
|
+
now = r.now; // keep the original window so resumed pages line up
|
|
59
69
|
const start = now - WEEK;
|
|
60
70
|
const deadline = Date.now() + DEADLINE_MS;
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
let
|
|
65
|
-
let
|
|
66
|
-
let rowsScanned = 0;
|
|
67
|
-
let explorerTotal;
|
|
71
|
+
// Rows by channel id: a page re-read after new sessions shifted the offsets is de-duplicated here.
|
|
72
|
+
const rows = new Map(r ? r.channels.map(([k, t, m]) => [k, { t, miner: m }]) : []);
|
|
73
|
+
let pagesRead = r?.pagesRead ?? 0;
|
|
74
|
+
let rowsScanned = r?.rowsScanned ?? 0;
|
|
75
|
+
let explorerTotal = r?.explorerTotal;
|
|
68
76
|
let reachedCutoff = false;
|
|
69
77
|
let reachedEnd = false;
|
|
70
78
|
let stop;
|
|
71
|
-
let next = 0;
|
|
79
|
+
let next = r?.nextPage ?? 0;
|
|
80
|
+
const parallel = Math.max(1, o.parallel ?? PARALLEL_PAGES);
|
|
72
81
|
while (!reachedCutoff && !reachedEnd && !stop) {
|
|
73
82
|
if (next >= MAX_PAGES) {
|
|
74
83
|
stop = `page cap of ${MAX_PAGES} reached`;
|
|
@@ -78,36 +87,33 @@ export async function loadDemand(network, explorer, now = Date.now(), o = {}) {
|
|
|
78
87
|
stop = `timed out after ${DEADLINE_MS / 1000} s`;
|
|
79
88
|
break;
|
|
80
89
|
}
|
|
81
|
-
const batch =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
const batch = Array.from({ length: parallel }, (_, k) => next + k).filter((p) => p < MAX_PAGES);
|
|
91
|
+
const pages = await Promise.all(batch.map((p) => pageWithRetry(base, p, o.fetchPage, o.sleep).then((x) => x, (e) => e)));
|
|
92
|
+
for (let k = 0; k < pages.length; k++) {
|
|
93
|
+
const p = pages[k];
|
|
85
94
|
if (p instanceof Error) {
|
|
86
95
|
if (pagesRead === 0)
|
|
87
96
|
throw p;
|
|
88
|
-
stop = `page ${
|
|
97
|
+
stop = `page ${batch[k] + 1} failed: ${p.message}`;
|
|
98
|
+
next = batch[k]; // resume here; pages after it in this batch are read again next time
|
|
89
99
|
break;
|
|
90
100
|
}
|
|
91
101
|
pagesRead += 1;
|
|
102
|
+
next = batch[k] + 1;
|
|
92
103
|
rowsScanned += p.data.length;
|
|
93
104
|
explorerTotal ??= p.total;
|
|
94
105
|
for (const c of p.data) {
|
|
95
106
|
const t = c.openedAt;
|
|
96
|
-
const id = c.channelId
|
|
107
|
+
const id = c.channelId ?? `${t}:${c.miner}`;
|
|
97
108
|
if (typeof t !== "number")
|
|
98
109
|
continue;
|
|
99
110
|
if (t < start) {
|
|
100
|
-
reachedCutoff = true;
|
|
111
|
+
reachedCutoff = true; // newest first: everything after this is older than the window
|
|
101
112
|
continue;
|
|
102
113
|
}
|
|
103
|
-
if (t > now
|
|
114
|
+
if (t > now)
|
|
104
115
|
continue;
|
|
105
|
-
|
|
106
|
-
seen.add(id);
|
|
107
|
-
sessions += 1;
|
|
108
|
-
byHour[new Date(t).getUTCHours()] += 1;
|
|
109
|
-
if (c.miner)
|
|
110
|
-
miners.add(c.miner);
|
|
116
|
+
rows.set(id, { t, miner: c.miner });
|
|
111
117
|
}
|
|
112
118
|
if (reachedCutoff)
|
|
113
119
|
break;
|
|
@@ -116,11 +122,19 @@ export async function loadDemand(network, explorer, now = Date.now(), o = {}) {
|
|
|
116
122
|
break;
|
|
117
123
|
}
|
|
118
124
|
if (p.data.length < PAGE_SIZE) {
|
|
119
|
-
stop = `page ${
|
|
125
|
+
stop = `page ${batch[k] + 1} returned ${p.data.length} rows, expected ${PAGE_SIZE}`;
|
|
120
126
|
break;
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
}
|
|
130
|
+
const byHour = new Array(24).fill(0);
|
|
131
|
+
const miners = new Set();
|
|
132
|
+
for (const { t, miner } of rows.values()) {
|
|
133
|
+
byHour[new Date(t).getUTCHours()] += 1;
|
|
134
|
+
if (miner)
|
|
135
|
+
miners.add(miner);
|
|
136
|
+
}
|
|
137
|
+
const sessions = rows.size;
|
|
124
138
|
// The end of the list counts as complete only if every row the explorer reported was read.
|
|
125
139
|
if (reachedEnd && explorerTotal !== undefined && rowsScanned < explorerTotal) {
|
|
126
140
|
stop = `read ${rowsScanned} of ${explorerTotal} rows before the list ended`;
|
|
@@ -135,5 +149,8 @@ export async function loadDemand(network, explorer, now = Date.now(), o = {}) {
|
|
|
135
149
|
network, explorer: base, fetchedAt: Date.now(), windowStart: start, windowEnd: now,
|
|
136
150
|
sessions, minerCount: miners.size, byHour, perHour: sessions / hours, busiest,
|
|
137
151
|
pagesRead, rowsScanned, explorerTotal, complete, note: stop,
|
|
152
|
+
progress: complete
|
|
153
|
+
? undefined
|
|
154
|
+
: { network, base, now, startedAt: r?.startedAt ?? Date.now(), nextPage: next, channels: [...rows].map(([k, x]) => [k, x.t, x.miner]), pagesRead, rowsScanned, explorerTotal },
|
|
138
155
|
};
|
|
139
156
|
}
|
package/dist/minerpage.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
// /miner: demand by UTC hour (7 days, cached 10 min) and a rent vs airdrop calculator.
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
2
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { homeDir } from "./identity.js";
|
|
3
5
|
import { CALC_DEFAULTS, loadDemand, minerCalc } from "./econ.js";
|
|
4
6
|
import { activeNetwork, networksPath } from "./net.js";
|
|
5
7
|
import { testnetLine } from "./testnet.js";
|
|
8
|
+
import { ICONS, innerLayout, networkCard, sideCard } from "./shell.js";
|
|
6
9
|
export const MINER_FOOTER = "Unofficial community tool. Estimates only. Draft Flop rules may change. No airdrop promises.";
|
|
7
10
|
const TTL = 10 * 60 * 1000;
|
|
8
11
|
export const PARTIAL_NOTE = "Partial data, showing last complete read";
|
|
@@ -12,12 +15,46 @@ let lastAttempt;
|
|
|
12
15
|
let lastAttemptAt = 0;
|
|
13
16
|
let inflight;
|
|
14
17
|
let lastError;
|
|
18
|
+
let resume; // pages kept from a stopped read; the next read resumes from them
|
|
19
|
+
let loadedFor;
|
|
15
20
|
function explorerFor(network) {
|
|
16
21
|
const n = JSON.parse(readFileSync(networksPath(), "utf8"))[network];
|
|
17
22
|
if (!n?.explorer)
|
|
18
23
|
throw new Error(`no explorer configured for ${network}`);
|
|
19
24
|
return n.explorer;
|
|
20
25
|
}
|
|
26
|
+
// ---------- the last complete read, kept on disk across restarts ----------
|
|
27
|
+
export const savedPath = (network) => join(homeDir(), `miner-demand-${network.replace(/[^a-z0-9_-]/gi, "")}.json`);
|
|
28
|
+
function saveComplete(d) {
|
|
29
|
+
try {
|
|
30
|
+
mkdirSync(homeDir(), { recursive: true, mode: 0o700 });
|
|
31
|
+
const p = savedPath(d.network);
|
|
32
|
+
writeFileSync(p + ".tmp", JSON.stringify({ format: "flop-guild-demand/1", demand: d }) + "\n", { mode: 0o600 });
|
|
33
|
+
renameSync(p + ".tmp", p);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
/* the page still works from memory */
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Load the saved complete read once per network: /miner shows it at once, and a refresh starts in the background. */
|
|
40
|
+
export function loadSaved(network) {
|
|
41
|
+
if (loadedFor === network)
|
|
42
|
+
return lastComplete;
|
|
43
|
+
loadedFor = network;
|
|
44
|
+
try {
|
|
45
|
+
const j = JSON.parse(readFileSync(savedPath(network), "utf8"));
|
|
46
|
+
const d = j?.demand;
|
|
47
|
+
if (j?.format !== "flop-guild-demand/1" || !d || d.network !== network || !d.complete || !Array.isArray(d.byHour))
|
|
48
|
+
return undefined;
|
|
49
|
+
lastComplete ??= d;
|
|
50
|
+
lastAttempt ??= d;
|
|
51
|
+
// lastAttemptAt stays 0, so the first request starts a refresh; the timestamps come from the file.
|
|
52
|
+
return d;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
21
58
|
function view() {
|
|
22
59
|
const latest = lastAttempt;
|
|
23
60
|
if (!latest)
|
|
@@ -26,15 +63,19 @@ function view() {
|
|
|
26
63
|
}
|
|
27
64
|
/** Cached demand: refresh after 10 minutes (2 after a partial read); a partial read never replaces a complete one. */
|
|
28
65
|
export async function demand(network = process.env.MINER_NETWORK || activeNetwork(), waitMs = 25_000) {
|
|
66
|
+
loadSaved(network);
|
|
29
67
|
const age = Date.now() - lastAttemptAt;
|
|
30
68
|
const stale = !lastAttempt || age > (lastAttempt.complete ? TTL : PARTIAL_RETRY);
|
|
31
69
|
if (stale && !inflight) {
|
|
32
70
|
lastAttemptAt = Date.now();
|
|
33
|
-
inflight = loadDemand(network, explorerFor(network))
|
|
34
|
-
.then((d) => {
|
|
71
|
+
inflight = loadDemand(network, explorerFor(network), Date.now(), { resume })
|
|
72
|
+
.then(({ progress, ...d }) => {
|
|
73
|
+
resume = progress; // undefined after a complete read
|
|
35
74
|
lastAttempt = d;
|
|
36
|
-
if (d.complete)
|
|
75
|
+
if (d.complete) {
|
|
37
76
|
lastComplete = d;
|
|
77
|
+
saveComplete(d);
|
|
78
|
+
}
|
|
38
79
|
lastError = undefined;
|
|
39
80
|
return d;
|
|
40
81
|
})
|
|
@@ -97,7 +138,10 @@ export const MINER_STYLE = `
|
|
|
97
138
|
.prose table{margin:.6rem 0}.prose td{text-align:right;font-variant-numeric:tabular-nums}.prose th{font-weight:400;color:var(--muted)}
|
|
98
139
|
#miner-count{font-family:var(--display)}
|
|
99
140
|
.note{font-size:.88rem}.fresh{font-size:.88rem;color:var(--muted);margin:.4rem 0 .8rem}
|
|
100
|
-
.miners-src .prov{margin-left:.3rem}
|
|
141
|
+
.miners-src .prov{margin-left:.3rem}
|
|
142
|
+
table.results{font-size:.86rem;margin:0 0 .5rem}table.results th{font-weight:400;color:var(--muted);padding-right:.6rem}
|
|
143
|
+
table.results td{text-align:right;font-variant-numeric:tabular-nums;font-weight:600}
|
|
144
|
+
#calc{grid-template-columns:repeat(auto-fit,minmax(12rem,1fr))}`;
|
|
101
145
|
export const LOADING = "loading";
|
|
102
146
|
const utc = (t) => new Date(t).toISOString().slice(0, 16).replace("T", " ");
|
|
103
147
|
const RETRY = '<p id="retry-wrap"><a class="btn" id="retry" href="/miner" role="button">Retry</a></p>';
|
|
@@ -137,10 +181,23 @@ export function readInfoHtml(v) {
|
|
|
137
181
|
const d = v?.shown;
|
|
138
182
|
return d ? ` <span class="note">(${d.sessions.toLocaleString("en-US")} sessions read since ${utc(d.windowStart)} UTC, ${d.pagesRead} explorer pages, ${d.complete ? "complete read" : "partial read"})</span>` : "";
|
|
139
183
|
}
|
|
184
|
+
/** "Live numbers" card body: miners active, sessions per hour, last checked. */
|
|
185
|
+
export function liveNumbersHtml(v, state = v?.shown ? "ready" : "unavailable") {
|
|
186
|
+
const d = v?.shown;
|
|
187
|
+
const none = state === "loading" ? LOADING : "unavailable";
|
|
188
|
+
return `<table class="kv">
|
|
189
|
+
<tr><th>Miners active</th><td id="live-miners">${d ? d.minerCount.toLocaleString("en-US") : none}${d && !d.complete ? ' <span class="prov">partial</span>' : ""}</td></tr>
|
|
190
|
+
<tr><th>Sessions / hour</th><td>${d ? d.perHour.toFixed(1) : none}</td></tr>
|
|
191
|
+
<tr><th>Last checked</th><td>${v ? `${hhmm(v.latest.fetchedAt)} UTC, ${ago(v.latest.fetchedAt)}` : none}</td></tr>
|
|
192
|
+
<tr><th>Complete read</th><td>${d?.complete ? `${hhmm(d.fetchedAt)} UTC, ${ago(d.fetchedAt)}` : d ? "none yet" : none}</td></tr>
|
|
193
|
+
</table>
|
|
194
|
+
<p class="muted small">Miners active = miners that served at least one session in the last 7 days, read from the explorer.</p>`;
|
|
195
|
+
}
|
|
140
196
|
/**
|
|
141
|
-
* /miner
|
|
142
|
-
*
|
|
143
|
-
*
|
|
197
|
+
* /miner, in the shared inner layout. Main: the demand chart card, then the calculator inputs.
|
|
198
|
+
* Sidebar: the results card (sticky with the sidebar), live numbers, network status.
|
|
199
|
+
* With cached data it renders complete; without, in the "loading" state, and /miner.js fetches
|
|
200
|
+
* /api/miner-stats in the background (3 tries, 3 s apart). A missing miner count is never treated as 0.
|
|
144
201
|
*/
|
|
145
202
|
export function minerPage(v, err, state = v?.shown ? "ready" : "unavailable") {
|
|
146
203
|
const d = v?.shown;
|
|
@@ -148,13 +205,18 @@ export function minerPage(v, err, state = v?.shown ? "ready" : "unavailable") {
|
|
|
148
205
|
const minerCount = d?.minerCount ?? 0;
|
|
149
206
|
const out = minerCalc({ ...CALC_DEFAULTS, minerCount });
|
|
150
207
|
const countText = known ? minerCount.toLocaleString("en-US") : state === "loading" ? LOADING : "unavailable";
|
|
151
|
-
|
|
208
|
+
const head = `<header class="page-head">
|
|
209
|
+
<h1>Miner economics</h1>
|
|
152
210
|
<p>What miners are paid for: how much inference demand there is, by hour, and what renting a GPU costs against an estimated airdrop share.</p>
|
|
211
|
+
</header>`;
|
|
212
|
+
const main = `<section class="card prose">
|
|
153
213
|
<h2>Demand by UTC hour, last 7 days</h2>
|
|
154
214
|
<p><strong>${esc(testnetLine())}</strong></p>
|
|
155
215
|
<div id="demand" data-state="${known ? "ready" : state}" aria-live="polite">
|
|
156
216
|
${demandSection(v, state, err)}
|
|
157
217
|
</div>
|
|
218
|
+
</section>
|
|
219
|
+
<section class="card prose">
|
|
158
220
|
<h2>Rent vs airdrop calculator</h2>
|
|
159
221
|
<form id="calc" class="grid" data-miners="${known ? minerCount : ""}">
|
|
160
222
|
<label>Miners active in the last 7 days<input id="in-miners" type="number" step="1" min="1" value="${known ? minerCount : ""}" placeholder="${known ? "" : countText}"></label>
|
|
@@ -170,9 +232,16 @@ ${demandSection(v, state, err)}
|
|
|
170
232
|
<p class="miners-src">Live value: <strong id="miner-count">${countText}</strong>, source: explorer <span id="partial-tag" class="prov"${known && !d.complete ? "" : " hidden"}>partial read, count may be low</span><span id="read-info">${readInfoHtml(v)}</span></p>
|
|
171
233
|
<p class="note">No eligibility threshold has been published by Flop; this counts miners active in the last 7 days. Edit the count above to try other values.</p>
|
|
172
234
|
${!known && state === "unavailable" ? RETRY : ""}
|
|
173
|
-
<table><tbody>${calcRows(out, known, state === "loading" ? "waiting for the miner count" : NA)}</tbody></table>
|
|
174
235
|
<p class="note">Share estimate = your weight / (miner count × average weight) × (hours per day / 24). The share assumes the average miner runs 24 hours a day.</p>
|
|
175
|
-
<p class="note">The real share is your verified compute divided by all verified compute, which nobody can know in advance. No FLOP token or price exists yet.</p
|
|
236
|
+
<p class="note">The real share is your verified compute divided by all verified compute, which nobody can know in advance. No FLOP token or price exists yet.</p>
|
|
237
|
+
</section>`;
|
|
238
|
+
// Live numbers and network status sit beside the chart; the results card comes last and stays pinned
|
|
239
|
+
// (sticky) while the reader scrolls through the calculator inputs, so inputs and results are side by side.
|
|
240
|
+
const side = `${sideCard("Live numbers", `<div id="live-numbers">${liveNumbersHtml(v, known ? "ready" : state)}</div>`, ICONS.miner)}
|
|
241
|
+
${networkCard()}
|
|
242
|
+
<div class="side-sticky">${sideCard("Results", `<table class="results"><tbody>${calcRows(out, known, state === "loading" ? "waiting for the miner count" : NA)}</tbody></table>
|
|
243
|
+
<p class="muted small">Estimates only. Updates as you type.</p>`, ICONS.faucet, ' id="results-card"')}</div>`;
|
|
244
|
+
return `${head}\n${innerLayout(main, side, { stickyAll: false })}`;
|
|
176
245
|
}
|
|
177
246
|
/** Browser script: the same minerCalc as the server, input wiring, and the background data fetch. */
|
|
178
247
|
export function minerScript() {
|
|
@@ -248,6 +317,7 @@ ${minerCalc.toString()}
|
|
|
248
317
|
box.setAttribute("data-state", "loading");
|
|
249
318
|
box.innerHTML = '<p class="note">Loading demand data from the explorer. The calculator works meanwhile.</p>';
|
|
250
319
|
set("miner-count", "loading");
|
|
320
|
+
if ($("live-miners")) set("live-miners", "loading");
|
|
251
321
|
if (!edited) $("in-miners").placeholder = "loading";
|
|
252
322
|
missing = WAITING; run();
|
|
253
323
|
}
|
|
@@ -261,6 +331,7 @@ ${minerCalc.toString()}
|
|
|
261
331
|
var a = document.createElement("a"); a.className = "btn"; a.id = "retry"; a.href = "/miner"; a.setAttribute("role", "button"); a.textContent = "Retry";
|
|
262
332
|
w.appendChild(a); box.appendChild(w);
|
|
263
333
|
set("miner-count", "unavailable");
|
|
334
|
+
if ($("live-miners")) set("live-miners", "unavailable");
|
|
264
335
|
if (!edited) $("in-miners").placeholder = "unavailable";
|
|
265
336
|
missing = NA; run();
|
|
266
337
|
wireRetry();
|
|
@@ -269,6 +340,7 @@ ${minerCalc.toString()}
|
|
|
269
340
|
box.innerHTML = j.fragments.demand;
|
|
270
341
|
box.setAttribute("data-state", "ready");
|
|
271
342
|
$("read-info").innerHTML = j.fragments.readInfo;
|
|
343
|
+
if (j.fragments.live && $("live-numbers")) $("live-numbers").innerHTML = j.fragments.live;
|
|
272
344
|
live = Number(j.demand.minerCount) || 0;
|
|
273
345
|
known = true;
|
|
274
346
|
f.setAttribute("data-miners", String(live));
|
package/dist/miners.js
CHANGED
|
@@ -35,8 +35,11 @@ async function page(base, offset) {
|
|
|
35
35
|
headers: { "user-agent": UA, accept: "application/json" },
|
|
36
36
|
signal: AbortSignal.timeout(20_000),
|
|
37
37
|
});
|
|
38
|
-
if (!res.ok)
|
|
39
|
-
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
// Status and Retry-After let the caller back off politely on 429 and 5xx.
|
|
40
|
+
const ra = Number(res.headers.get("retry-after"));
|
|
41
|
+
throw Object.assign(new Error(`HTTP ${res.status}`), { status: res.status, retryAfterMs: Number.isFinite(ra) && ra > 0 ? Math.min(ra, 120) * 1000 : undefined });
|
|
42
|
+
}
|
|
40
43
|
const j = await res.json();
|
|
41
44
|
if (!Array.isArray(j?.data))
|
|
42
45
|
throw new Error("unexpected response shape (no data array)");
|
package/dist/server.js
CHANGED
|
@@ -7,8 +7,8 @@ import { dirname, join } from "node:path";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { GUILD_ROOM, publicHost, render } from "./config.js";
|
|
9
9
|
import { networksPath } from "./net.js";
|
|
10
|
-
import { DISCLAIMER, esc, ICONS, page } from "./shell.js";
|
|
11
|
-
import { expand, GUIDES, guidesHtml, mdToHtml, ROLES, roleMd, rolesHtml, rolesMd, withTestnetLine } from "./content.js";
|
|
10
|
+
import { DISCLAIMER, esc, ICONS, innerLayout, networkCard, page } from "./shell.js";
|
|
11
|
+
import { expand, GUIDES, guidesHtml, mdToHtml, relatedGuidesCard, ROLES, roleMd, rolesHtml, rolesMd, tocCard, withTestnetLine } from "./content.js";
|
|
12
12
|
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
13
13
|
const SITE = join(ROOT, "site");
|
|
14
14
|
const VERSION = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8")).version;
|
|
@@ -208,7 +208,8 @@ const START_CSP = [
|
|
|
208
208
|
].join("; ");
|
|
209
209
|
const START_STYLE = `
|
|
210
210
|
.start-grid{display:grid;gap:1rem;grid-template-columns:minmax(0,1fr)}
|
|
211
|
-
|
|
211
|
+
ul.facts{margin:0;padding-left:1.1rem;font-size:.88rem;color:var(--muted)}ul.facts li{margin:0 0 .45rem}
|
|
212
|
+
.side-card ol.next>li{font-size:.88rem}
|
|
212
213
|
.start-grid .card{margin:0}.card h2{display:flex;align-items:center;gap:.6rem}
|
|
213
214
|
.num{display:inline-grid;place-items:center;width:1.6rem;height:1.6rem;border-radius:50%;border:1px solid var(--line-2);font:700 .8rem/1 var(--display);color:var(--accent);flex:none}
|
|
214
215
|
.didline{font-size:.9rem;color:var(--muted)}#did,#signed-sig,#signed-msg{word-break:break-all}
|
|
@@ -258,6 +259,7 @@ const STATIC_JS = {
|
|
|
258
259
|
"/vendor/noble-ed25519-LICENSE.txt": { file: "vendor/noble-ed25519-LICENSE.txt", type: "text/plain; charset=utf-8" },
|
|
259
260
|
"/copy.js": { file: "copy.js", type: "text/javascript; charset=utf-8" },
|
|
260
261
|
"/theme.js": { file: "theme.js", type: "text/javascript; charset=utf-8" },
|
|
262
|
+
"/toc.js": { file: "toc.js", type: "text/javascript; charset=utf-8" },
|
|
261
263
|
"/tabs.js": { file: "tabs.js", type: "text/javascript; charset=utf-8" },
|
|
262
264
|
"/logo.svg": { file: "logo.svg", type: "image/svg+xml" },
|
|
263
265
|
"/favicon.svg": { file: "favicon.svg", type: "image/svg+xml" },
|
|
@@ -374,6 +376,8 @@ async function mcp(req, res) {
|
|
|
374
376
|
export function startServer(port, host = "0.0.0.0") {
|
|
375
377
|
publicHost(); // fail fast on a bad PUBLIC_HOST
|
|
376
378
|
void import("./testnet.js").then((t) => t.startWatcher());
|
|
379
|
+
// Load the last complete explorer read from disk so /miner has data at once after a restart.
|
|
380
|
+
void Promise.all([import("./minerpage.js"), import("./net.js")]).then(([m, n]) => m.loadSaved(process.env.MINER_NETWORK || n.activeNetwork()));
|
|
377
381
|
const server = createServer(async (req, res) => {
|
|
378
382
|
try {
|
|
379
383
|
const path = new URL(req.url ?? "/", "http://x").pathname.replace(/\/+$/, "") || "/";
|
|
@@ -388,7 +392,11 @@ export function startServer(port, host = "0.0.0.0") {
|
|
|
388
392
|
if (path === "/healthz")
|
|
389
393
|
return send(res, 200, "text/plain", "ok\n", { "cache-control": "no-store" });
|
|
390
394
|
if (path === "/start") {
|
|
391
|
-
|
|
395
|
+
const html = render(readFileSync(join(SITE, "start.html"), "utf8")).replace(/\{\{icon:([a-z]+)\}\}/g, (_m, k) => ICONS[k] ?? "");
|
|
396
|
+
const [head, rest = ""] = html.split("<!--MAIN-->");
|
|
397
|
+
const [mainPart, sidePart = ""] = rest.split("<!--SIDE-->");
|
|
398
|
+
const startBody = `${head}\n${innerLayout(mainPart, sidePart.replace("{{NETWORK_CARD}}", networkCard()))}`;
|
|
399
|
+
return send(res, 200, "text/html; charset=utf-8", page("Start: your did:key", startBody, { footerNote: START_FOOTER, style: START_STYLE, script: "/start.js", module: true, layout: "prebuilt" }), {
|
|
392
400
|
"content-security-policy": START_CSP,
|
|
393
401
|
"cache-control": "no-store",
|
|
394
402
|
});
|
|
@@ -414,11 +422,11 @@ export function startServer(port, host = "0.0.0.0") {
|
|
|
414
422
|
if (path === "/api/miner-stats") {
|
|
415
423
|
const { CALC_DEFAULTS, minerCalc } = await import("./econ.js");
|
|
416
424
|
const body = d
|
|
417
|
-
? { demand: d, partial: v.partial, latestRead: v.partial ? v.latest : undefined, defaults: CALC_DEFAULTS, defaultResult: minerCalc({ ...CALC_DEFAULTS, minerCount: d.minerCount }), fragments: { demand: mp.demandSection(v, "ready"), readInfo: mp.readInfoHtml(v) }, disclaimer: mp.MINER_FOOTER }
|
|
425
|
+
? { demand: d, partial: v.partial, latestRead: v.partial ? v.latest : undefined, defaults: CALC_DEFAULTS, defaultResult: minerCalc({ ...CALC_DEFAULTS, minerCount: d.minerCount }), fragments: { demand: mp.demandSection(v, "ready"), readInfo: mp.readInfoHtml(v), live: mp.liveNumbersHtml(v, "ready") }, disclaimer: mp.MINER_FOOTER }
|
|
418
426
|
: { error: mp.demandError() ?? "loading, try again in a minute", disclaimer: mp.MINER_FOOTER };
|
|
419
427
|
return send(res, d ? 200 : 503, "application/json", JSON.stringify(body, null, 2), d ? fresh : { "cache-control": "no-store" });
|
|
420
428
|
}
|
|
421
|
-
return send(res, 200, "text/html; charset=utf-8", page("Miner economics", mp.minerPage(v, mp.demandError(), v?.shown ? "ready" : "loading"), { footerNote: mp.MINER_FOOTER, style: mp.MINER_STYLE, script: "/miner.js",
|
|
429
|
+
return send(res, 200, "text/html; charset=utf-8", page("Miner economics", mp.minerPage(v, mp.demandError(), v?.shown ? "ready" : "loading"), { footerNote: mp.MINER_FOOTER, style: mp.MINER_STYLE, script: "/miner.js", layout: "prebuilt" }), fresh);
|
|
422
430
|
}
|
|
423
431
|
if (path === "/") {
|
|
424
432
|
const body = render(readFileSync(join(SITE, "index.html"), "utf8"))
|
|
@@ -426,7 +434,7 @@ export function startServer(port, host = "0.0.0.0") {
|
|
|
426
434
|
.replace("{{ROLES}}", withTestnetLine(render(rolesHtml(ICONS))))
|
|
427
435
|
.replace("{{GUIDES}}", guidesHtml(ICONS.doc))
|
|
428
436
|
.replace("{{STATS}}", await homeStats());
|
|
429
|
-
return send(res, 200, "text/html; charset=utf-8", page("flopguild: pick your role", body, { footerNote: START_FOOTER, style: HOME_STYLE, script: "/tabs.js" }), { "cache-control": "public, max-age=60" });
|
|
437
|
+
return send(res, 200, "text/html; charset=utf-8", page("flopguild: pick your role", body, { footerNote: START_FOOTER, style: HOME_STYLE, script: "/tabs.js", layout: "home" }), { "cache-control": "public, max-age=60" });
|
|
430
438
|
}
|
|
431
439
|
if (path === "/llms.txt")
|
|
432
440
|
return send(res, 200, "text/plain; charset=utf-8", expand(readFileSync(join(SITE, "llms.txt"), "utf8")));
|
|
@@ -436,7 +444,11 @@ export function startServer(port, host = "0.0.0.0") {
|
|
|
436
444
|
if (g) {
|
|
437
445
|
const md = guideMd(g[1]);
|
|
438
446
|
if (md)
|
|
439
|
-
return g[2] ? send(res, 200, "text/markdown; charset=utf-8", md) : send(res, 200, "text/html; charset=utf-8", page(md.split("\n")[0].replace(/^# /, ""), mdToHtml(md), {
|
|
447
|
+
return g[2] ? send(res, 200, "text/markdown; charset=utf-8", md) : send(res, 200, "text/html; charset=utf-8", page(md.split("\n")[0].replace(/^# /, ""), mdToHtml(md), {
|
|
448
|
+
cards: true,
|
|
449
|
+
scripts: ["/toc.js"],
|
|
450
|
+
side: (toc) => `${tocCard(toc, ICONS)}\n${relatedGuidesCard(g[1], ICONS)}\n${networkCard()}`,
|
|
451
|
+
}));
|
|
440
452
|
}
|
|
441
453
|
return send(res, 404, "text/plain", "not found\n");
|
|
442
454
|
}
|
package/dist/shell.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Everything is served from this site: fonts from /fonts, scripts from /copy.js and page scripts.
|
|
3
3
|
import { GUILD_ROOM, GUILD_ROOM_URL } from "./config.js";
|
|
4
4
|
import { activeNetwork } from "./net.js";
|
|
5
|
+
import { status as testnetStatus } from "./testnet.js";
|
|
5
6
|
export const esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
6
7
|
export const RUN_IN_SHELL = "Run in: Ubuntu, macOS Terminal, or WSL on Windows (not PowerShell)";
|
|
7
8
|
export const RUN_IN_POWERSHELL = "Run in: PowerShell";
|
|
@@ -40,11 +41,53 @@ export function decorateCode(body) {
|
|
|
40
41
|
return `<div class="term"><div class="term-bar"><span class="runin">${label}</span></div><pre class="copyable${isCommand ? " cmd" : ""}"><code>${lines}</code></pre></div>`;
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
+
const slug = (t) => t
|
|
45
|
+
.replace(/<[^>]+>/g, "")
|
|
46
|
+
.toLowerCase()
|
|
47
|
+
.replace(/&[a-z]+;/g, "")
|
|
48
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
49
|
+
.replace(/^-+|-+$/g, "")
|
|
50
|
+
.slice(0, 60) || "section";
|
|
51
|
+
/** The h1 block becomes the page header, every h2 section a card with an id, listed in the table of contents. */
|
|
44
52
|
export function cardify(body) {
|
|
45
53
|
const parts = body.split(/(?=<h2[ >])/);
|
|
46
54
|
const head = parts.shift() ?? "";
|
|
47
|
-
|
|
55
|
+
const toc = [];
|
|
56
|
+
const used = new Set();
|
|
57
|
+
const sections = parts
|
|
58
|
+
.map((p) => {
|
|
59
|
+
const m = p.match(/^<h2[^>]*>([\s\S]*?)<\/h2>/);
|
|
60
|
+
const text = (m?.[1] ?? "Section").replace(/<[^>]+>/g, "");
|
|
61
|
+
let id = slug(text);
|
|
62
|
+
for (let n = 2; used.has(id); n++)
|
|
63
|
+
id = `${slug(text)}-${n}`;
|
|
64
|
+
used.add(id);
|
|
65
|
+
toc.push({ id, text });
|
|
66
|
+
return `<section class="card prose" id="${id}">${p}</section>`;
|
|
67
|
+
})
|
|
68
|
+
.join("\n");
|
|
69
|
+
return { head: `<header class="page-head">${head}</header>`, sections, toc };
|
|
70
|
+
}
|
|
71
|
+
/** The shared inner-page layout: main column left, sticky sidebar of cards right; one column below 1024 px. */
|
|
72
|
+
export function innerLayout(main, side, o = {}) {
|
|
73
|
+
const cls = o.stickyAll === false ? "side-stack free" : "side-stack";
|
|
74
|
+
return `<div class="inner"><div class="inner-main">\n${main}\n</div>\n<aside class="inner-side" aria-label="Page sidebar"><div class="${cls}">\n${side}\n</div></aside></div>`;
|
|
75
|
+
}
|
|
76
|
+
export function sideCard(title, body, icon = "", extra = "") {
|
|
77
|
+
return `<section class="card side-card"${extra}><h2 class="side-title">${icon ? `<span class="tile">${icon}</span>` : ""}${esc(title)}</h2>\n${body}\n</section>`;
|
|
78
|
+
}
|
|
79
|
+
/** Network status, the same wording as the home page card, from the watcher's state (/api/status). */
|
|
80
|
+
export function networkCard() {
|
|
81
|
+
const st = testnetStatus();
|
|
82
|
+
const when = (iso) => (iso ? `${iso.slice(11, 16)} UTC` : "not yet");
|
|
83
|
+
const net = activeNetwork();
|
|
84
|
+
const testnet = st.published ? "Endpoints published, not yet enabled in the kit" : "Waiting for Flop endpoints";
|
|
85
|
+
const dot = st.published ? '<span class="live on">LIVE</span>' : '<span class="live off">WATCHING</span>';
|
|
86
|
+
return sideCard("Network status", `<table class="kv"><tr><th>Kit network</th><td><span class="pill-sm">${esc(net.toUpperCase())}</span></td></tr>
|
|
87
|
+
<tr><th>Testnet</th><td>${esc(testnet)} ${dot}</td></tr>
|
|
88
|
+
<tr><th>Last check</th><td>${esc(when(st.lastChecked))}</td></tr></table>
|
|
89
|
+
<p class="muted small">${esc(st.line)}</p>
|
|
90
|
+
<p class="small"><a href="/api/status">/api/status</a></p>`, ICONS.clock);
|
|
48
91
|
}
|
|
49
92
|
const FONT_CSS = `
|
|
50
93
|
@font-face{font-family:"Inter";font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/inter-latin-400-normal.woff2) format("woff2")}
|
|
@@ -99,6 +142,24 @@ main.wrap{padding-top:1.8rem;padding-bottom:3rem}
|
|
|
99
142
|
.card>:last-child{margin-bottom:0}
|
|
100
143
|
.page-head{margin:0 0 1.4rem;max-width:48rem}.page-head p{color:var(--muted)}
|
|
101
144
|
.prose{max-width:52rem}
|
|
145
|
+
/* inner pages: main column + sticky sidebar */
|
|
146
|
+
.inner{display:grid;grid-template-columns:minmax(0,1fr);gap:1rem}
|
|
147
|
+
.inner-main{min-width:0}.inner-main .prose{max-width:none}.inner-main>:last-child{margin-bottom:0}
|
|
148
|
+
.inner-side{min-width:0}.side-stack>.card:last-child{margin-bottom:0}
|
|
149
|
+
@media (min-width:1024px){.inner{grid-template-columns:minmax(0,1fr) minmax(18rem,22rem);gap:1.5rem;align-items:stretch}
|
|
150
|
+
.side-stack{position:sticky;top:4.8rem}
|
|
151
|
+
.side-stack.free{position:static;height:100%;display:flex;flex-direction:column}.side-sticky{position:sticky;top:4.8rem}}
|
|
152
|
+
.side-card{padding:1rem 1.05rem}.side-title{display:flex;align-items:center;gap:.55rem;font-size:.9rem;margin:0 0 .75rem}
|
|
153
|
+
.side-title .tile{width:1.7rem;height:1.7rem;border-radius:7px}.side-title .tile svg{width:.95rem;height:.95rem}
|
|
154
|
+
.side-card p:last-child{margin-bottom:0}
|
|
155
|
+
table.kv{font-size:.84rem;margin:0 0 .6rem}table.kv th{font-weight:400;color:var(--muted);width:6.2rem;white-space:nowrap}
|
|
156
|
+
.pill-sm{font:600 .66rem/1 var(--mono);letter-spacing:.08em;color:var(--warn);border:1px solid var(--warn-line);background:var(--warn-bg);border-radius:99px;padding:.15rem .45rem}
|
|
157
|
+
.live{display:inline-flex;align-items:center;gap:.3rem;font:600 .6rem/1 var(--mono);letter-spacing:.08em;color:var(--dim);white-space:nowrap;vertical-align:.1em}
|
|
158
|
+
.live::before{content:"";width:.42rem;height:.42rem;border-radius:50%;background:var(--dim)}
|
|
159
|
+
.live.on{color:var(--accent)}.live.on::before{background:var(--accent);box-shadow:0 0 0 3px var(--glow)}
|
|
160
|
+
ul.links{list-style:none;margin:0;padding:0}ul.links li{margin:0}ul.links a{display:block;padding:.38rem .55rem;border-radius:7px;color:var(--muted);font-size:.88rem;border-left:2px solid transparent}
|
|
161
|
+
ul.links a:hover{background:var(--card-2);color:var(--fg);text-decoration:none}
|
|
162
|
+
ul.links a.on,ul.links a[aria-current]{color:var(--fg);background:var(--card-2);border-left-color:var(--accent)}
|
|
102
163
|
.muted,.note{color:var(--muted)}.small{font-size:.85rem}
|
|
103
164
|
.tile{display:inline-grid;place-items:center;width:2rem;height:2rem;border-radius:8px;background:var(--card-2);border:1px solid var(--line-2);color:var(--accent);flex:none}
|
|
104
165
|
.tile svg{width:1.05rem;height:1.05rem}
|
|
@@ -167,8 +228,15 @@ ${col("Project", [`<a href="${GUILD_ROOM_URL}">Guild room ${GUILD_ROOM}</a>`, '<
|
|
|
167
228
|
</footer>`;
|
|
168
229
|
}
|
|
169
230
|
export function page(title, body, o = {}) {
|
|
170
|
-
|
|
231
|
+
const layout = o.layout ?? "inner";
|
|
232
|
+
if (layout === "inner") {
|
|
233
|
+
const c = o.cards ? cardify(body) : { head: "", sections: body, toc: [] };
|
|
234
|
+
const side = typeof o.side === "function" ? o.side(c.toc) : (o.side ?? networkCard());
|
|
235
|
+
body = `${c.head}\n${innerLayout(c.sections, side)}`;
|
|
236
|
+
}
|
|
237
|
+
body = decorateCode(body);
|
|
171
238
|
const copy = body.includes("copyable") ? '<script defer src="/copy.js"></script>' : "";
|
|
239
|
+
const extra = (o.scripts ?? []).map((src) => `<script defer src="${src}"></script>`).join("");
|
|
172
240
|
return `<!doctype html>
|
|
173
241
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
174
242
|
<script src="/theme.js"></script>
|
|
@@ -177,7 +245,7 @@ export function page(title, body, o = {}) {
|
|
|
177
245
|
<link rel="preload" href="/fonts/space-mono-latin-700-normal.woff2" as="font" type="font/woff2" crossorigin>
|
|
178
246
|
<style>${SHELL_CSS}
|
|
179
247
|
${o.style ?? ""}
|
|
180
|
-
</style>${copy}${o.script ? `<script ${o.module ? 'type="module"' : "defer"} src="${o.script}"></script>` : ""}</head><body>
|
|
248
|
+
</style>${copy}${extra}${o.script ? `<script ${o.module ? 'type="module"' : "defer"} src="${o.script}"></script>` : ""}</head><body>
|
|
181
249
|
<header class="topbar"><div class="wrap">
|
|
182
250
|
<a class="brand" href="/" aria-label="flopguild home"><img src="/logo.svg" alt="" width="28" height="28"><span class="wm"><span>flop</span><b>guild</b></span></a>
|
|
183
251
|
<span class="pill" title="The network this kit is set to use (networks.json)">${esc(activeNetwork().toUpperCase())}</span>
|
|
@@ -200,5 +268,6 @@ export const ICONS = {
|
|
|
200
268
|
clock: svg('<circle cx="12" cy="12" r="8.5"/><path d="M12 7.5V12l3 2"/>'),
|
|
201
269
|
doc: svg('<path d="M7 3.5h7l4 4v13H7z"/><path d="M14 3.5v4h4M9.5 12h6M9.5 15.5h6"/>'),
|
|
202
270
|
plug: svg('<path d="M9 3v5M15 3v5M6.5 8h11v3a5.5 5.5 0 0 1-11 0zM12 16.5V21"/>'),
|
|
271
|
+
key: svg('<circle cx="8" cy="12" r="4"/><path d="M12 12h8.5M17 12v3.5M20 12v2.5"/>'),
|
|
203
272
|
chat: svg('<path d="M4 5h16v10.5H9.5L5.5 19v-3.5H4z"/>'),
|
|
204
273
|
};
|
package/package.json
CHANGED
package/site/start.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
code served from this site; nothing is fetched from anywhere else, and the page can only talk to
|
|
5
5
|
technocore.chat.</p>
|
|
6
6
|
</header>
|
|
7
|
-
|
|
7
|
+
<!--MAIN-->
|
|
8
8
|
<div class="start-grid">
|
|
9
9
|
<section class="card wide">
|
|
10
10
|
<h2><span class="num">1</span>Make a key</h2>
|
|
@@ -13,7 +13,7 @@ technocore.chat.</p>
|
|
|
13
13
|
<p class="didline">Your did:key: <code id="did">none yet</code></p>
|
|
14
14
|
</section>
|
|
15
15
|
|
|
16
|
-
<section id="step2" class="card" hidden>
|
|
16
|
+
<section id="step2" class="card wide" hidden>
|
|
17
17
|
<h2><span class="num">2</span>Download it, encrypted</h2>
|
|
18
18
|
<p>Pick a passphrase of at least 12 characters. The file is encrypted with PBKDF2 (SHA-256,
|
|
19
19
|
600,000 rounds) and AES-256-GCM before it leaves this page.</p>
|
|
@@ -25,7 +25,7 @@ technocore.chat.</p>
|
|
|
25
25
|
<p id="save-msg" class="msg" aria-live="polite"></p>
|
|
26
26
|
</section>
|
|
27
27
|
|
|
28
|
-
<section id="step3" class="card" hidden>
|
|
28
|
+
<section id="step3" class="card wide" hidden>
|
|
29
29
|
<h2><span class="num">3</span>Introduce yourself (optional)</h2>
|
|
30
30
|
<p>One line, signed with your key as <code>{{ROOM}}|<nonce>|<text></code> and posted to
|
|
31
31
|
<a href="{{ROOM_URL}}">{{ROOM}}</a>. The kit adds <code>(via flop-guild)</code>. The room is public and has
|
|
@@ -40,10 +40,30 @@ no owner; this page never claims it.</p>
|
|
|
40
40
|
</div>
|
|
41
41
|
</section>
|
|
42
42
|
|
|
43
|
-
<section class="card">
|
|
44
|
-
<h2>
|
|
43
|
+
<section class="card wide">
|
|
44
|
+
<h2>Check it on Technocore</h2>
|
|
45
|
+
<p>Post your introduction above with Dry run unticked, then find it in <a href="{{ROOM_URL}}">{{ROOM}}</a>.
|
|
46
|
+
The did:key next to your line should match the one printed by
|
|
47
|
+
<code>npx flop-guild whoami --key <name></code>. You can also read the room from the terminal:</p>
|
|
48
|
+
<pre><code>npx flop-guild read --room {{ROOM}} --limit 10</code></pre>
|
|
49
|
+
<p>See the <a href="/guides/agent-quickstart">agent quick start</a> for more.</p>
|
|
50
|
+
</section>
|
|
51
|
+
</div>
|
|
52
|
+
<!--SIDE-->
|
|
53
|
+
<section class="card side-card">
|
|
54
|
+
<h2 class="side-title"><span class="tile">{{icon:key}}</span>What happens to your keys</h2>
|
|
55
|
+
<ul class="facts">
|
|
56
|
+
<li>The key is made in this browser tab by code served from this site.</li>
|
|
57
|
+
<li>The secret stays in the page's memory. Nothing is stored, and nothing is sent anywhere except the optional introduction to technocore.chat.</li>
|
|
58
|
+
<li>The download is encrypted with your passphrase (PBKDF2, 600,000 rounds, AES-256-GCM). Lose the passphrase and the key is gone.</li>
|
|
59
|
+
<li>Closing the tab without downloading discards the key.</li>
|
|
60
|
+
</ul>
|
|
61
|
+
</section>
|
|
62
|
+
|
|
63
|
+
<section class="card side-card">
|
|
64
|
+
<h2 class="side-title"><span class="tile">{{icon:agent}}</span>Next: your agent</h2>
|
|
45
65
|
<ol class="next">
|
|
46
|
-
<li>Make a key
|
|
66
|
+
<li>Make a key and download it, or use a key file you downloaded earlier.</li>
|
|
47
67
|
<li>Import it into the command line kit. It asks for the passphrase:
|
|
48
68
|
<pre><code>npx flop-guild import-key flop-guild-key.json --name <name></code></pre></li>
|
|
49
69
|
<li>Set up the wallet, faucet and enrollment. Agents need a DID and a wallet; setup keeps the key you imported:
|
|
@@ -51,17 +71,8 @@ no owner; this page never claims it.</p>
|
|
|
51
71
|
<li>Run the agent within its daily budget:
|
|
52
72
|
<pre><code>npx flop-guild autopilot</code></pre></li>
|
|
53
73
|
</ol>
|
|
54
|
-
<p>If you prefer not to trust a website with your key, skip step 1 and run
|
|
74
|
+
<p class="muted small">If you prefer not to trust a website with your key, skip step 1 and run
|
|
55
75
|
<code>npx flop-guild keygen <name></code> to make the key on your own machine.</p>
|
|
56
|
-
<p>Devnet FLOP has no value: running an agent there earns nothing, and no airdrop is promised.</p>
|
|
57
|
-
</section>
|
|
58
|
-
|
|
59
|
-
<section class="card">
|
|
60
|
-
<h2>Check it on Technocore</h2>
|
|
61
|
-
<p>Post your introduction above with Dry run unticked, then find it in <a href="{{ROOM_URL}}">{{ROOM}}</a>.
|
|
62
|
-
The did:key next to your line should match the one printed by
|
|
63
|
-
<code>npx flop-guild whoami --key <name></code>. You can also read the room from the terminal:</p>
|
|
64
|
-
<pre><code>npx flop-guild read --room {{ROOM}} --limit 10</code></pre>
|
|
65
|
-
<p>See the <a href="/guides/agent-quickstart">agent quick start</a> for more.</p>
|
|
76
|
+
<p class="muted small">Devnet FLOP has no value: running an agent there earns nothing, and no airdrop is promised.</p>
|
|
66
77
|
</section>
|
|
67
|
-
|
|
78
|
+
{{NETWORK_CARD}}
|
package/site/toc.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// flop-guild guides: mark the section in view in the "On this page" card.
|
|
2
|
+
(() => {
|
|
3
|
+
const links = [...document.querySelectorAll("[data-toc] a[href^='#']")];
|
|
4
|
+
if (!links.length || !("IntersectionObserver" in window)) return;
|
|
5
|
+
const byId = new Map(links.map((a) => [a.getAttribute("href").slice(1), a]));
|
|
6
|
+
const sections = [...byId.keys()].map((id) => document.getElementById(id)).filter(Boolean);
|
|
7
|
+
const visible = new Set();
|
|
8
|
+
const mark = () => {
|
|
9
|
+
// The first section (in page order) that is in view wins; at the very end, the last one.
|
|
10
|
+
let id = sections.find((s) => visible.has(s.id))?.id;
|
|
11
|
+
if (window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 4) id = sections[sections.length - 1].id;
|
|
12
|
+
for (const [k, a] of byId) {
|
|
13
|
+
a.classList.toggle("on", k === id);
|
|
14
|
+
if (k === id) a.setAttribute("aria-current", "location");
|
|
15
|
+
else a.removeAttribute("aria-current");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const io = new IntersectionObserver(
|
|
19
|
+
(entries) => {
|
|
20
|
+
for (const e of entries) e.isIntersecting ? visible.add(e.target.id) : visible.delete(e.target.id);
|
|
21
|
+
mark();
|
|
22
|
+
},
|
|
23
|
+
{ rootMargin: "-80px 0px -55% 0px" },
|
|
24
|
+
);
|
|
25
|
+
sections.forEach((s) => io.observe(s));
|
|
26
|
+
window.addEventListener("scroll", mark, { passive: true });
|
|
27
|
+
})();
|