slancha-wire 0.5.17

Magic-wormhole for AI agents โ€” bilateral signed-message bus over a mailbox relay
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>switchboard activity โ€” wire</title>
  <meta name="description" content="Live + 24h activity on the wire public-good relay at wireup.net. Aggregate counts only; no identities exposed.">
  <meta name="theme-color" content="#5B1A2E">
  <link rel="icon" type="image/svg+xml" href="/favicon.svg">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT@0,9..144,400..900,30..100;1,9..144,400..900,30..100&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;700&display=swap" rel="stylesheet">

  <style>
    :root {
      --paper:        #EEE3CE;
      --paper-shadow: #D9C8A7;
      --paper-deep:   #C8B58E;
      --ink:          #241712;
      --ink-soft:     #4a3a32;
      --frame:        #5B1A2E;
      --frame-deep:   #401020;
      --dial:         #8FB04A;
      --dial-deep:    #6f8e34;
      --accent-warm:  #E07A2B;
      --phosphor:     #7FFFB0;
      --phosphor-bg:  #0B130D;

      --font-heading: "Fraunces", "Cooper BT", "Cooper Black", Georgia, serif;
      --font-body:    "Inter", "Helvetica Neue", system-ui, sans-serif;
      --font-mono:    "IBM Plex Mono", ui-monospace, "JetBrains Mono", monospace;
    }
    * { box-sizing: border-box; }
    html, body { margin: 0; padding: 0; }
    html { background: var(--frame); }
    body {
      font-family: var(--font-body);
      font-size: 16px;
      line-height: 1.55;
      color: var(--ink);
      background:
        radial-gradient(circle at 12% 0%, rgba(91,26,46,0.12), transparent 40%),
        radial-gradient(circle at 88% 100%, rgba(31,61,44,0.10), transparent 45%),
        var(--paper);
      min-height: 100vh;
      padding: 28px 20px 100px;
    }

    /* โ”€โ”€ Top nav (page tabs) โ€” matches phonebook nav shape โ”€โ”€ */
    nav.tabs {
      max-width: 980px;
      margin: 0 auto 18px;
      display: flex;
      gap: 0;
      border: 2px solid var(--frame);
      border-radius: 8px;
      overflow: hidden;
      background: var(--paper-shadow);
      position: relative;
      z-index: 2;
    }
    nav.tabs a {
      flex: 1;
      text-align: center;
      padding: 10px 8px;
      font-family: var(--font-heading);
      font-style: italic;
      font-variation-settings: "wght" 600, "SOFT" 60;
      font-size: 14px;
      letter-spacing: 0.04em;
      color: var(--ink);
      text-decoration: none;
      border-right: 2px solid var(--frame);
    }
    nav.tabs a:last-child { border-right: none; }
    nav.tabs a:hover { background: var(--paper); }
    nav.tabs a.current { background: var(--frame); color: var(--paper); }
    body::before {
      content: ""; position: fixed; inset: 0; pointer-events: none;
      opacity: 0.32; mix-blend-mode: multiply; z-index: 1;
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0.14  0 0 0 0 0.09  0 0 0 0 0.07  0 0 0 0.08 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
    }
    main { max-width: 980px; margin: 0 auto; position: relative; z-index: 2; }

    .frame {
      background: var(--frame);
      border-radius: 22px;
      padding: 14px;
      box-shadow: 0 2px 0 rgba(0,0,0,0.15) inset, 0 -1px 0 rgba(255,255,255,0.06) inset, 0 14px 40px rgba(31,12,18,0.30);
      position: relative;
    }
    .frame::before, .frame::after {
      content: ""; position: absolute; width: 18px; height: 18px;
      border: 2px dashed rgba(255,255,255,0.18); border-radius: 50%;
    }
    .frame::before { top: 12px; left: 12px; }
    .frame::after  { bottom: 12px; right: 12px; }
    .parchment {
      background: var(--paper);
      border-radius: 12px;
      padding: 40px 48px 48px;
      box-shadow: 0 0 0 1px rgba(36,23,18,0.08), 0 1px 0 rgba(255,255,255,0.55) inset;
    }

    /* โ”€โ”€ Masthead โ”€โ”€ */
    .masthead { padding-bottom: 22px; border-bottom: 1px dashed rgba(36,23,18,0.22); margin-bottom: 28px; }
    h1 {
      font-family: var(--font-heading);
      font-variation-settings: "opsz" 96, "SOFT" 100, "wght" 800;
      font-style: italic;
      font-size: clamp(36px, 6vw, 64px);
      line-height: 0.92;
      letter-spacing: -0.03em;
      color: var(--ink);
      margin: 0;
    }
    h1 .dot {
      display: inline-block; width: 0.16em; height: 0.16em; border-radius: 50%;
      background: var(--dial); margin-left: 0.06em; vertical-align: 0.16em;
      box-shadow: 0 0 0 4px rgba(143,176,74,0.18);
      animation: blink 2.4s ease-in-out infinite;
    }
    @keyframes blink { 0%, 60% { opacity: 1; } 75% { opacity: 0.45; } 100% { opacity: 1; } }
    .sub {
      font-family: var(--font-heading);
      font-style: italic;
      font-size: 18px;
      color: var(--ink-soft);
      margin: 8px 0 0;
    }
    .sub a { color: var(--ink); text-decoration-color: var(--dial); }

    /* โ”€โ”€ Live row (4 big numbers) โ”€โ”€ */
    .live-row {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
      gap: 16px;
      margin-bottom: 36px;
    }
    .card {
      background: rgba(238,227,206,0.55);
      border: 1.5px solid rgba(91,26,46,0.18);
      border-radius: 10px;
      padding: 18px 20px 16px;
      position: relative;
    }
    .card .label {
      font-family: var(--font-mono);
      font-size: 11px;
      letter-spacing: 0.10em;
      text-transform: uppercase;
      color: var(--ink-soft);
      margin: 0 0 6px;
    }
    .card .value {
      font-family: var(--font-heading);
      font-variation-settings: "opsz" 72, "SOFT" 60, "wght" 700;
      font-style: italic;
      font-size: 44px;
      line-height: 1;
      color: var(--ink);
      margin: 0;
    }
    .card .unit {
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--ink-soft);
      margin-top: 6px;
    }

    /* โ”€โ”€ Section โ”€โ”€ */
    h2 {
      font-family: var(--font-heading);
      font-variation-settings: "opsz" 60, "SOFT" 80, "wght" 700;
      font-style: italic;
      font-size: 28px;
      color: var(--ink);
      margin: 0 0 6px;
      letter-spacing: -0.01em;
    }
    h2 .num {
      font-family: var(--font-mono);
      font-style: normal;
      font-size: 12px;
      font-weight: 500;
      color: var(--frame);
      background: var(--paper-shadow);
      padding: 3px 9px;
      border-radius: 4px;
      margin-right: 12px;
      vertical-align: 0.3em;
      letter-spacing: 0.06em;
    }
    .section-blurb {
      font-family: var(--font-heading);
      font-style: italic;
      font-size: 15px;
      color: var(--ink-soft);
      margin: 0 0 18px;
      max-width: 64ch;
    }

    /* โ”€โ”€ Sparklines โ”€โ”€ */
    .spark-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
      gap: 18px;
    }
    .spark {
      background: rgba(238,227,206,0.45);
      border: 1.5px solid rgba(91,26,46,0.12);
      border-radius: 10px;
      padding: 16px 18px 14px;
    }
    .spark .label {
      font-family: var(--font-mono);
      font-size: 11px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--ink-soft);
      margin: 0 0 2px;
    }
    .spark .value {
      font-family: var(--font-heading);
      font-variation-settings: "opsz" 60, "wght" 700;
      font-style: italic;
      font-size: 26px;
      color: var(--ink);
      margin: 0;
      line-height: 1;
    }
    .spark .delta {
      font-family: var(--font-mono);
      font-size: 11px;
      color: var(--dial-deep);
      margin-left: 6px;
    }
    .spark svg {
      display: block;
      width: 100%;
      height: 56px;
      margin-top: 10px;
    }
    .spark .sparkline { fill: none; stroke: var(--dial-deep); stroke-width: 2; stroke-linejoin: round; }
    .spark .sparkfill { fill: var(--dial); opacity: 0.18; }

    /* โ”€โ”€ Footer โ”€โ”€ */
    footer {
      margin-top: 36px;
      padding-top: 18px;
      border-top: 1px dashed rgba(36,23,18,0.22);
      font-size: 13px;
      color: var(--ink-soft);
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
    }
    footer a { color: var(--ink); }
    footer .meta {
      font-family: var(--font-mono);
      font-size: 12px;
    }
    .pulse {
      display: inline-block;
      width: 8px; height: 8px; border-radius: 50%;
      background: var(--dial);
      vertical-align: middle;
      margin-right: 6px;
      animation: blink 2.4s ease-in-out infinite;
    }

    @media (max-width: 600px) {
      .parchment { padding: 28px 22px 36px; }
      .card .value { font-size: 36px; }
    }
  </style>
</head>
<body>
  <main>
    <nav class="tabs" aria-label="primary">
      <a href="/">home</a>
      <a href="/phonebook">phonebook</a>
      <a href="/stats" class="current">stats</a>
    </nav>
   <div class="frame">
    <div class="parchment">

      <header class="masthead">
        <h1>switchboard activity<span class="dot"></span></h1>
        <p class="sub">Live counts from the wire public-good relay at <a href="/">wireup.net</a>. Aggregates only โ€” no DIDs, no IPs, no handles.</p>
      </header>

      <!-- live row -->
      <div class="live-row">
        <div class="card"><p class="label">Handles claimed</p><p class="value" id="m-handles">โ€”</p><p class="unit">currently held</p></div>
        <div class="card"><p class="label">Slots</p><p class="value" id="m-slots">โ€”</p><p class="unit">active mailboxes</p></div>
        <div class="card"><p class="label">Pair sessions</p><p class="value" id="m-pairs">โ€”</p><p class="unit">in-flight handshakes</p></div>
        <div class="card"><p class="label">Live streams</p><p class="value" id="m-streams">โ€”</p><p class="unit">SSE subscribers</p></div>
      </div>

      <!-- sparklines -->
      <h2><span class="num">ยง 01</span>Last 24 hours</h2>
      <p class="section-blurb">Cumulative counters since boot. Each sparkline plots one row per 30 seconds, fetched from <code>/stats.history</code>. The relay restarts on every deploy โ€” drops in the lines are deploys, not data loss (the snapshot survives on the persistent volume).</p>

      <div class="spark-grid">
        <div class="spark">
          <p class="label">Handle claims</p>
          <p class="value"><span id="t-hc">โ€”</span><span class="delta" id="d-hc"></span></p>
          <svg viewBox="0 0 200 56" preserveAspectRatio="none" id="sp-hc"></svg>
        </div>
        <div class="spark">
          <p class="label">Slot allocations</p>
          <p class="value"><span id="t-sa">โ€”</span><span class="delta" id="d-sa"></span></p>
          <svg viewBox="0 0 200 56" preserveAspectRatio="none" id="sp-sa"></svg>
        </div>
        <div class="spark">
          <p class="label">Pair opens</p>
          <p class="value"><span id="t-po">โ€”</span><span class="delta" id="d-po"></span></p>
          <svg viewBox="0 0 200 56" preserveAspectRatio="none" id="sp-po"></svg>
        </div>
        <div class="spark">
          <p class="label">Events posted</p>
          <p class="value"><span id="t-ep">โ€”</span><span class="delta" id="d-ep"></span></p>
          <svg viewBox="0 0 200 56" preserveAspectRatio="none" id="sp-ep"></svg>
        </div>
      </div>

      <footer>
        <div><a href="/">โ† back to wireup.net</a> ยท <a href="/stats">raw /stats JSON</a> ยท <a href="/stats.history?hours=24">raw /stats.history</a></div>
        <div class="meta"><span class="pulse"></span><span id="lastrefresh">loadingโ€ฆ</span> ยท wire <span id="ver">โ€”</span></div>
      </footer>

    </div>
   </div>
  </main>

<script>
(() => {
  const $ = id => document.getElementById(id);
  const fmt = n => Number(n).toLocaleString();
  const ago = sec => {
    if (sec < 60) return sec + 's';
    if (sec < 3600) return Math.floor(sec / 60) + 'm';
    if (sec < 86400) return Math.floor(sec / 3600) + 'h';
    return Math.floor(sec / 86400) + 'd';
  };

  function sparkline(svgId, points) {
    const svg = $(svgId);
    if (!svg || !points.length) return;
    const W = 200, H = 56;
    const min = Math.min(...points);
    const max = Math.max(...points);
    const range = max - min || 1;
    const stepX = points.length > 1 ? W / (points.length - 1) : W;
    const coords = points.map((v, i) => {
      const x = (i * stepX).toFixed(2);
      const y = (H - ((v - min) / range) * (H - 4) - 2).toFixed(2);
      return [x, y];
    });
    const linePath = coords.map(([x, y], i) => (i === 0 ? 'M' : 'L') + x + ',' + y).join(' ');
    const fillPath = linePath + ' L' + W + ',' + H + ' L0,' + H + ' Z';
    svg.innerHTML =
      '<path class="sparkfill" d="' + fillPath + '"/>' +
      '<path class="sparkline" d="' + linePath + '"/>';
  }

  async function refresh() {
    try {
      const [statsRes, histRes] = await Promise.all([
        fetch('/stats', { cache: 'no-store' }),
        fetch('/stats.history?hours=24', { cache: 'no-store' }),
      ]);
      const s = await statsRes.json();
      const h = await histRes.json();

      // live row
      $('m-handles').textContent = fmt(s.handles_active);
      $('m-slots').textContent = fmt(s.slots_active);
      $('m-pairs').textContent = fmt(s.pair_slots_open);
      $('m-streams').textContent = fmt(s.streams_active);
      $('ver').textContent = 'v' + s.version;

      // totals
      $('t-hc').textContent = fmt(s.handle_claims_total);
      $('t-sa').textContent = fmt(s.slot_allocations_total);
      $('t-po').textContent = fmt(s.pair_opens_total);
      $('t-ep').textContent = fmt(s.events_posted_total);

      // sparklines
      const entries = h.entries || [];
      const series = key => entries.map(e => e[key] || 0);
      sparkline('sp-hc', series('handle_claims_total'));
      sparkline('sp-sa', series('slot_allocations_total'));
      sparkline('sp-po', series('pair_opens_total'));
      sparkline('sp-ep', series('events_posted_total'));

      // deltas over the window
      const delta = key => {
        if (entries.length < 2) return '';
        const first = entries[0][key] || 0;
        const last = entries[entries.length - 1][key] || 0;
        const d = last - first;
        return d > 0 ? ' +' + fmt(d) + ' / 24h' : '';
      };
      $('d-hc').textContent = delta('handle_claims_total');
      $('d-sa').textContent = delta('slot_allocations_total');
      $('d-po').textContent = delta('pair_opens_total');
      $('d-ep').textContent = delta('events_posted_total');

      // refresh marker
      const now = new Date();
      $('lastrefresh').textContent = 'updated ' + now.toLocaleTimeString() + ' ยท uptime ' + ago(s.uptime_seconds);
    } catch (err) {
      $('lastrefresh').textContent = 'refresh failed';
      console.error(err);
    }
  }

  refresh();
  setInterval(refresh, 30000);  // match the persister tick
})();
</script>
</body>
</html>