clavarium 0.2.145-next.1 → 0.2.149-next.1

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.
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.145-next.1",
3
+ "version": "0.2.149-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.145-next.1",
9
+ "version": "0.2.149-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
14
  "clavarium-binder": "0.1.42-next.1",
15
15
  "clavarium-docket": "0.1.1",
16
- "clavarium-parley": "0.17.25-next.1",
16
+ "clavarium-parley": "0.17.27-next.1",
17
17
  "clavarium-tether": "0.1.0-next.34",
18
18
  "mermaid": "11.17.2",
19
19
  "node-pty": "^1.1.0",
@@ -742,9 +742,9 @@
742
742
  }
743
743
  },
744
744
  "node_modules/clavarium-parley": {
745
- "version": "0.17.25-next.1",
746
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.25-next.1.tgz",
747
- "integrity": "sha512-aqCVLjXxh8NHBxXMNklDtd2yypN7fTPk87KifLMmDhwCaiH+cMgQwNC/Nn67AiYd0XHyk663e2/sP7F+NSfD9g==",
745
+ "version": "0.17.27-next.1",
746
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.27-next.1.tgz",
747
+ "integrity": "sha512-AlMZl0BGix500UrWf2M/7fTVcOQEeGe2JHBz1sxIcKxwyy9r9mn3OTkL42hQT58Z3YkbbymRe6HDjDLEZkvKPA==",
748
748
  "license": "MIT",
749
749
  "bin": {
750
750
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.145-next.1",
3
+ "version": "0.2.149-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -46,7 +46,7 @@
46
46
  "@xterm/xterm": "^6.0.0",
47
47
  "clavarium-binder": "0.1.42-next.1",
48
48
  "clavarium-docket": "0.1.1",
49
- "clavarium-parley": "0.17.25-next.1",
49
+ "clavarium-parley": "0.17.27-next.1",
50
50
  "clavarium-tether": "0.1.0-next.34",
51
51
  "mermaid": "11.17.2",
52
52
  "node-pty": "^1.1.0",
package/server/health.mjs CHANGED
@@ -113,7 +113,11 @@ export function judge(record) {
113
113
  if (!kinds && record.oomKills > 0) add('info', 'memory', 'oom', `${record.oomKills} program${record.oomKills === 1 ? ' was' : 's were'} stopped for lack of memory since it started (whether the machine or a limit of their own, it could not be told). Its files are safe.`);
114
114
  if (record.memory && record.memory.totalMb > 0 && record.memory.availableMb < Math.max(MEMORY_LOW_MB, record.memory.totalMb * 0.05)) add('warn', 'memory', 'memory-low', `Its memory is almost full: ${record.memory.availableMb} MB free of ${record.memory.totalMb} MB.`);
115
115
  for (const [path, d] of Object.entries(record.disks ?? {})) {
116
- if (d.sizeMb > 0 && d.availableMb < Math.max(DISK_LOW_MB, d.sizeMb * 0.1)) add('warn', 'disk', `disk:${path}`, `${path === '/' ? 'Its disk' : `Its work folder (${path})`} is almost full: ${d.availableMb} MB left of ${d.sizeMb} MB.`);
116
+ if (!(d.sizeMb > 0 && d.availableMb < Math.max(DISK_LOW_MB, d.sizeMb * 0.1))) continue;
117
+ /* A work folder kept here is on THIS SERVER's disk: short of room, every conversation that keeps
118
+ one would say it at once. Noted quietly; the server's own gauge says it, once. */
119
+ if (path === '/') add('warn', 'disk', 'disk:/', `Its disk is almost full: ${d.availableMb} MB left of ${d.sizeMb} MB.`);
120
+ else add('info', 'server-disk', `disk:${path}`, `Its work folder (${path}) is kept on this server, whose disk is almost full: ${d.availableMb} MB left of ${d.sizeMb} MB.`);
117
121
  }
118
122
  for (const path of record.remounted ?? []) add('info', 'mount', `remounted:${path}`, `${path} had come loose in the machine: it was mounted again.`);
119
123
  for (const { path, why } of record.failed ?? []) add('bad', 'mount', `failed:${path}`, `${path} is not reachable in the machine and could not be mounted again${why ? `: ${why}` : ''}.`);
package/server/talk.mjs CHANGED
@@ -60,7 +60,7 @@
60
60
  */
61
61
  import { posix, join } from 'node:path';
62
62
  import { randomUUID, createHash } from 'node:crypto';
63
- import { mkdirSync, lstatSync, rmSync, readFileSync, writeFileSync } from 'node:fs';
63
+ import { mkdirSync, lstatSync, rmSync, readFileSync, writeFileSync, readdirSync } from 'node:fs';
64
64
  import { install, Parley, WAKE, reread, texts, fill, LANGUAGES, SHOWN_MAX, FILES_MAX } from 'clavarium-parley/host';
65
65
  import { importFile } from './files.mjs';
66
66
  import { KEYS } from 'clavarium-parley/ui';
@@ -70,6 +70,9 @@ import { isConversationName } from './names.mjs';
70
70
 
71
71
  export const FOLDER = '.parley';
72
72
  const IN_MACHINE = `/work/${FOLDER}`;
73
+ /* Texts this server gives the tool to read (keepText): kept this many days, this many at most of one name. */
74
+ export const KEPT_TEXT_DAYS = 7;
75
+ export const KEPT_TEXTS = 10;
73
76
  /* A part of the thread as the page asks for it (?last=200, ?days=3, ?before=ID, ?from=ID, ?since=CURSOR): Parley's options, or null. */
74
77
  export function partOf(query) {
75
78
  if (!query || typeof query !== 'object') return null;
@@ -144,6 +147,7 @@ export const EVENT_LEVELS = Object.freeze({
144
147
  origin: 'trace',
145
148
  wakeup: 'trace',
146
149
  'machine-problem': 'needs-you',
150
+ 'machine-ok': 'news',
147
151
  restarted: 'news',
148
152
  /* New tools in its machine that its tool reads only when it starts: a restart recommended (main.mjs). */
149
153
  'tools-updated': 'news',
@@ -506,6 +510,15 @@ export class Talk {
506
510
  if (!own(join(dir, FILES))) return null;
507
511
  const id = randomUUID();
508
512
  const file = String(fileName).replace(/[^A-Za-z0-9._-]/g, '-').slice(0, 80) || 'text.txt';
513
+ /* Those of the same name given before go after KEPT_TEXT_DAYS, and beyond the newest KEPT_TEXTS. */
514
+ const before = [];
515
+ for (const d of readdirSync(join(dir, FILES), { withFileTypes: true })) {
516
+ if (!d.isDirectory()) continue;
517
+ const f = lstatSync(join(dir, FILES, d.name, file), { throwIfNoEntry: false });
518
+ if (f?.isFile() && readdirSync(join(dir, FILES, d.name)).length === 1) before.push({ name: d.name, at: f.mtimeMs });
519
+ }
520
+ before.sort((a, b) => b.at - a.at);
521
+ before.forEach((x, i) => { if (i >= KEPT_TEXTS - 1 || Date.now() - x.at > KEPT_TEXT_DAYS * 86_400_000) rmSync(join(dir, FILES, x.name), { recursive: true, force: true }); });
509
522
  mkdirSync(join(dir, FILES, id));
510
523
  writeFileSync(join(dir, FILES, id, file), String(text ?? ''), { flag: 'wx', mode: 0o644 });
511
524
  return `${IN_MACHINE}/${FILES}/${id}/${file}`;
@@ -566,6 +579,12 @@ export class Talk {
566
579
  const before = new Set(r.machineKeys ?? []);
567
580
  const fresh = serious.filter((p) => !before.has(p.key ?? p.text));
568
581
  if (keys.join('|') !== (r.machineKeys ?? []).join('|')) this.#store.put({ ...r, machineKeys: keys });
582
+ /* What went away, said once, the machine running: the lines that asked for it ask no more (app.js). */
583
+ const gone = record.state === 'Running' ? [...before].filter((k) => !keys.includes(k)) : [];
584
+ if (gone.length) {
585
+ const said = [...new Set(gone.map((k) => (/^disk:/.test(k) ? 'Its disk has room again.' : k === 'memory-low' ? 'Its memory is no longer short.' : /^oom:/.test(k) ? '' : 'What was wrong with its machine is gone.')).filter(Boolean))];
586
+ if (said.length) this.event(name, { kind: 'machine-ok', text: said.join(' '), topic: 'Machine' });
587
+ }
569
588
  if (fresh.length === 0) return;
570
589
  this.event(name, {
571
590
  kind: 'machine-problem',
package/web/app.js CHANGED
@@ -338,6 +338,24 @@
338
338
  keeps it open (a person who wants it open sets it once). Open only when that choice was remembered. */
339
339
  let listFolded = true;
340
340
  try { listFolded = localStorage.getItem('clavarium-list') !== 'open'; } catch { /* a private window */ }
341
+ /* PINNED OPEN (the pin at the top of the list): it stays open, even when a conversation is opened.
342
+ Folding it by hand takes the pin out. Kept on this device. */
343
+ let listPinned = false;
344
+ try { listPinned = localStorage.getItem('clavarium-list-pin') === 'on'; } catch { /* a private window */ }
345
+ if (listPinned) listFolded = false;
346
+ const paintPin = () => {
347
+ $('list-pin').setAttribute('aria-pressed', String(listPinned));
348
+ const label = listPinned ? 'The list stays open: click to let it fold when a conversation is opened' : 'Keep the list open: it no longer folds when a conversation is opened';
349
+ $('list-pin').title = label; $('list-pin').setAttribute('aria-label', listPinned ? 'Unpin the list' : 'Keep the list open');
350
+ };
351
+ const pin = (on) => {
352
+ listPinned = on;
353
+ try { localStorage.setItem('clavarium-list-pin', on ? 'on' : 'off'); } catch { /* as above */ }
354
+ paintPin();
355
+ };
356
+ paintPin();
357
+ if (DEVICE) $('list-pin').hidden = true;
358
+ $('list-pin').addEventListener('click', () => { pin(!listPinned); if (listPinned && listFolded) $('fold').click(); });
341
359
  /* THE LIST SLIDES, THE PAGE IS LAID OUT ONCE. Animating the grid's columns laid the whole page out (and
342
360
  redrew the terminal) at every frame: it stuttered. The columns change once, the room taking the whole
343
361
  width (its far side off the screen), and the list, the menu and the room slide -- transforms, which cost
@@ -346,6 +364,7 @@
346
364
  const still = () => window.matchMedia?.('(prefers-reduced-motion: reduce)').matches || window.innerWidth <= 700;
347
365
  $('fold').addEventListener('click', async () => {
348
366
  listFolded = !listFolded;
367
+ if (listFolded && listPinned) pin(false);
349
368
  try { localStorage.setItem('clavarium-list', listFolded ? 'folded' : 'open'); } catch { /* as above */ }
350
369
  const folded = listFolded;
351
370
  if (still()) { applyFold(folded); fit.fit(); focusTerminal(); return; }
@@ -916,6 +935,8 @@
916
935
  function select(name, { step = false } = {}) {
917
936
  if (name !== current) { disconnect(); terminal.reset(); }
918
937
  current = name;
938
+ /* The strip over the terminal is the one of the conversation now open, at once -- never the last one's until the next look. */
939
+ paintHealth();
919
940
  /* What was open over the one before -- its tab, an asset, a review,
920
941
  what was over it, a place of the menu (Access, Settings) -- gives way. */
921
942
  const room = nav.last(['room']);
@@ -932,7 +953,7 @@
932
953
  /* Opening a conversation gets the list out of the way, so its room has the room;
933
954
  the "»" button brings the list back. Only on a real pick by the owner, never on a
934
955
  device or when deselecting. */
935
- if (step && name && !DEVICE && !listFolded) {
956
+ if (step && name && !DEVICE && !listFolded && !listPinned) {
936
957
  listFolded = true;
937
958
  try { localStorage.setItem('clavarium-list', 'folded'); } catch { /* a private window */ }
938
959
  applyFold(true); fit.fit?.();
@@ -2756,10 +2777,13 @@
2756
2777
  const seenWords = seenAt ? `\u2713 Seen ${new Date(seenAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}` : '';
2757
2778
  /* Restart, offered by a line, is offered no more once its machine was restarted after it. */
2758
2779
  const restartedAt = data.messages.filter((m) => m.from === 'system' && m.event === 'restarted').map((m) => String(m.at ?? '')).sort().pop() ?? '';
2780
+ /* A problem of its machine that went away since (machine-ok): nothing left to see or to do on its line. */
2781
+ const fixedAt = data.messages.filter((m) => m.from === 'system' && m.event === 'machine-ok').map((m) => String(m.at ?? '')).sort().pop() ?? '';
2782
+ const FIXED_GOES = new Set(['seen', 'room', 'disk', 'memory']);
2759
2783
  /* A Tether demande decided (here, from Assets, or by the agent) is marked done in the thread,
2760
2784
  carrying its id: Accept / Refuse are then offered no more on the line that asked. */
2761
2785
  const settled = new Set(data.messages.filter((m) => m.from === 'system' && m.event === 'tether-done' && m.brief).map((m) => String(m.brief)));
2762
- const actionsOf = (m) => (m.actions ?? []).filter(may).filter((id) => !(id === 'restart' && restartedAt && String(m.at ?? '') < restartedAt)).filter((id) => !(DEMANDE.test(id) && settled.has(id.slice(id.indexOf(':') + 1))))
2786
+ const actionsOf = (m) => (m.actions ?? []).filter(may).filter((id) => !(id === 'restart' && restartedAt && String(m.at ?? '') < restartedAt)).filter((id) => !(FIXED_GOES.has(id) && fixedAt && String(m.at ?? '') < fixedAt)).filter((id) => !(DEMANDE.test(id) && settled.has(id.slice(id.indexOf(':') + 1))))
2763
2787
  .map((id) => (id === 'seen' && seenAt && String(m.at ?? '') <= seenAt ? { id: 'seen-done', label: seenWords } : { id, label: label(id) }));
2764
2788
  return { ...data, messages: data.messages.map((m) => (m.from === 'system' ? { ...m, actions: actionsOf(m), links: linksOf(m) } : m)) };
2765
2789
  }
@@ -2967,6 +2991,7 @@
2967
2991
  ['docket-unhandled', 'Not handled', 'Told three times, never said done'],
2968
2992
  ['docket-reminder', 'Reminder set', 'A reminder the tool set itself'],
2969
2993
  ['machine-problem', 'Machine in trouble', 'Memory, disk, no answer, a failed restart'],
2994
+ ['machine-ok', 'Machine well again', 'What was wrong with it went away'],
2970
2995
  ['restarted', 'Machine restarted', 'Restarted or built again'],
2971
2996
  ['tools-updated', 'New tools', 'After an update: a restart gives its tool all of them'],
2972
2997
  ];
package/web/index.html CHANGED
@@ -14,7 +14,7 @@
14
14
  <link rel="stylesheet" href="/vendor/diff2html.css">
15
15
  <div id="app" data-place="conversations">
16
16
  <aside id="list" hidden>
17
- <div class="top"><b id="list-title" title="Conversations">Clavarium</b><span class="top-acts"><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="primary">+ New</button></span></div>
17
+ <div class="top"><b id="list-title" title="Conversations">Clavarium</b><span class="top-acts"><button type="button" id="list-pin" class="icon-btn" aria-pressed="false" aria-label="Keep the list open" title="Keep the list open: it no longer folds when a conversation is opened"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="primary">+ New</button></span></div>
18
18
  <!-- SEARCH, discreet: opened by the magnifier, "/" or Ctrl+K; filters as it is typed. -->
19
19
  <div id="search" role="search" hidden><input id="search-field" type="search" placeholder="Search" aria-label="Search conversations: name, folder, identifier, tool" autocomplete="off" spellcheck="false" maxlength="60" aria-controls="items"></div>
20
20
  <!-- Needs you and Recent: copies of rows of the list below, by when they were last used (app.js, paint). -->
package/web/style.css CHANGED
@@ -1372,6 +1372,11 @@ select.pill { appearance: auto; }
1372
1372
  .icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; background: transparent; border-color: transparent; color: var(--ink2); }
1373
1373
  .icon-btn:hover, .icon-btn[aria-expanded="true"] { color: inherit; border-color: var(--line); }
1374
1374
  .icon-btn .ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
1375
+ /* The pin that keeps the list open: in brass, filled, while it holds; tilted and quiet when it does not. Wide screens only (the fold is theirs). */
1376
+ #list-pin .ic { stroke-linejoin: round; transform: rotate(35deg); transition: transform .15s; }
1377
+ #list-pin[aria-pressed="true"] { color: var(--brass-ink); }
1378
+ #list-pin[aria-pressed="true"] .ic { transform: none; fill: currentColor; fill-opacity: .25; }
1379
+ @media (max-width: 700px) { #list-pin { display: none; } }
1375
1380
  #search[hidden] { display: none; }
1376
1381
  #search-field { width: 100%; box-sizing: border-box; padding: 6px 10px; font-size: .9rem; border-radius: 8px; }
1377
1382
  #search-none { margin: 0 .25rem; }