clavarium 0.2.202-beta.1 → 0.2.203-beta.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,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.202-beta.1",
3
+ "version": "0.2.203-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.202-beta.1",
9
+ "version": "0.2.203-beta.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.202-beta.1",
3
+ "version": "0.2.203-beta.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.",
@@ -278,7 +278,7 @@ export class Conversations {
278
278
  return this.#store.all().sort((a, b) => order.indexOf(a.name) - order.indexOf(b.name)).map((c) => {
279
279
  const tool = this.#tools.find((t) => t.id === c.tool);
280
280
  /* An AI tool has an instruction file; a shell has none: what is dictated there is never marked. */
281
- return { ...c, rank: order.indexOf(c.name), ...(c.group ? { groupRank: groups.indexOf(c.group) } : {}), toolLabel: tool?.label ?? c.tool, memoryMinMb: tool?.memoryMb, resumes: Boolean(tool?.resume), rights: Boolean(tool?.rights), ai: Boolean(tool?.instructions), voiceMark: Boolean(tool?.instructions) && c.voiceMark !== false, cpus: c.cpus ?? 1, hostCpus: availableParallelism() };
281
+ return { ...c, ...(c.lentTo && !this.#borrowed.has(c.name) ? { lentTo: undefined } : {}), rank: order.indexOf(c.name), ...(c.group ? { groupRank: groups.indexOf(c.group) } : {}), toolLabel: tool?.label ?? c.tool, memoryMinMb: tool?.memoryMb, resumes: Boolean(tool?.resume), rights: Boolean(tool?.rights), ai: Boolean(tool?.instructions), voiceMark: Boolean(tool?.instructions) && c.voiceMark !== false, cpus: c.cpus ?? 1, hostCpus: availableParallelism() };
282
282
  });
283
283
  }
284
284
 
@@ -1042,13 +1042,17 @@ export class Conversations {
1042
1042
  const state = await this.#vms.state(from, { fresh: true }).catch(() => undefined);
1043
1043
  if (state !== 'Running') {
1044
1044
  /* Put back as it was found (14-11: one stopped was left asleep, its memory held). */
1045
- putBack = state === 'Stopped' ? 'stop' : 'sleep';
1045
+ /* Asleep by its record and not seen stopped: back to sleep; otherwise (stopped, or its state not read --
1046
+ 14-11 on test-c, just after a restart) stopped, which frees its memory. */
1047
+ putBack = this.#store.get(from)?.asleep === true && state !== 'Stopped' ? 'sleep' : 'stop';
1046
1048
  this.#store.patch(to, { step: `Copying ${tool.label}'s memory: ${putBack === 'stop' ? 'starting its original (it was stopped)' : 'waking its original'}` });
1047
1049
  await this.room({ kind: 'start', name: from, memoryMb: Number(c.memoryMb) || tool.memoryMb });
1048
1050
  /* Woken outside a wake, it is still marked asleep: borrowed, so that the server's sweep of sleepers
1049
1051
  holding memory (capacity.mjs, reclaimSleepers) does not put it back to sleep while it is read --
1050
1052
  the reading would end cut (13-11: exit 255). */
1051
1053
  this.#borrowed.add(from);
1054
+ /* Its page says so while it is read (not « Stopped » or « Asleep »): cleared once put back. */
1055
+ this.#store.patch(from, { lentTo: this.#store.get(to)?.title ?? to });
1052
1056
  const started = await this.#vms.start(from);
1053
1057
  if (started.code !== 0) throw new Error(`its original's machine did not start: ${firstLine(started.stderr) || `exit ${started.code}`}.`);
1054
1058
  woke = true;
@@ -1066,10 +1070,18 @@ export class Conversations {
1066
1070
  out.stream.on('data', (d) => { read += d.length; lastAt = Date.now(); say(`Copying ${tool.label}'s memory: ${sizeWords(read)} read`); });
1067
1071
  /* Nothing comes for a while: said, with how long; for too long, the reading is ended and why said --
1068
1072
  never an endless wait nobody can read (14-11: stuck at "36 KB read"). */
1073
+ /* Quiet for 30 s: its machine asked, once, what its reading does -- the file it is on and its state
1074
+ (D: waiting on the disk), its load, its free memory -- or said not to answer at all. Said with the
1075
+ wait, and in the end's why (14-11: stuck at 36 KB on the owner's server, never here). */
1076
+ let seen = '';
1077
+ const probe = 'for p in $(pgrep -x tar); do f=$(ls -l /proc/$p/fd 2>/dev/null | grep -o "/home/[^ ]*" | tail -1); echo "tar $(cut -d" " -f3 /proc/$p/stat) ${f#$HOME/}"; done; '
1078
+ + 'echo "load $(cut -d" " -f1 /proc/loadavg)"; awk \'/MemAvailable/{print "free " int($2/1024) " MB"}\' /proc/meminfo';
1079
+ const ask = () => { seen = '…'; this.#vms.exec(from, ['sh', '-c', probe], { timeoutMs: 20_000 }).then((r) => { seen = r.code === 0 ? (r.stdout || '').trim().split('\n').join(', ').slice(0, 200) : 'its machine did not answer'; }, () => { seen = 'its machine did not answer'; }); };
1069
1080
  const watch = setInterval(() => {
1070
1081
  const quiet = Math.round((Date.now() - lastAt) / 1000);
1071
1082
  if (quiet >= COPY_QUIET_MS / 1000) { stalled = true; child.kill('SIGKILL'); return; }
1072
- if (quiet >= 15) say(`Copying ${tool.label}'s memory: ${sizeWords(read)} read, nothing more for ${quiet} s`);
1083
+ if (quiet >= 30 && !seen) ask();
1084
+ if (quiet >= 15) say(`Copying ${tool.label}'s memory: ${sizeWords(read)} read, nothing more for ${quiet} s${seen && seen !== '…' ? ` (${seen})` : ''}`);
1073
1085
  }, 5000);
1074
1086
  const failed = new Promise((ok) => child.on('error', () => ok(-1)));
1075
1087
  const file = createWriteStream(carried, { mode: 0o600 });
@@ -1077,7 +1089,7 @@ export class Conversations {
1077
1089
  code = await Promise.race([new Promise((ok) => child.on('close', ok)), failed]).finally(() => clearInterval(watch));
1078
1090
  if (stalled) {
1079
1091
  const now = await this.#vms.state(from, { fresh: true }).catch(() => undefined);
1080
- throw new Error(`its original stopped sending its tool's memory (${sizeWords(read)} read, then nothing for ${COPY_QUIET_MS / 60_000} min; its machine is ${now ?? 'in a state that could not be read'})`);
1092
+ throw new Error(`its original stopped sending its tool's memory (${sizeWords(read)} read, then nothing for ${COPY_QUIET_MS / 60_000} min; its machine is ${now ?? 'in a state that could not be read'}${seen && seen !== '…' ? `; it said: ${seen}` : ''})`);
1081
1093
  }
1082
1094
  await new Promise((ok) => (file.writableFinished ? ok() : file.on('finish', ok)));
1083
1095
  if (code !== 255) break;
@@ -1086,6 +1098,7 @@ export class Conversations {
1086
1098
  /* Read: its original back to sleep at once, before the copy's machine is made. */
1087
1099
  if (woke) { await back().catch(() => {}); woke = false; }
1088
1100
  this.#borrowed.delete(from);
1101
+ if (this.#store.get(from)?.lentTo) this.#store.patch(from, { lentTo: undefined });
1089
1102
  }
1090
1103
  open(true);
1091
1104
  await building;
@@ -1119,6 +1132,7 @@ export class Conversations {
1119
1132
  rmSync(dir, { recursive: true, force: true });
1120
1133
  if (woke) await back().catch(() => {});
1121
1134
  this.#borrowed.delete(from);
1135
+ if (this.#store.get(from)?.lentTo) this.#store.patch(from, { lentTo: undefined });
1122
1136
  }
1123
1137
  }
1124
1138
 
@@ -135,7 +135,8 @@ export const SETTINGS_WORDS_FR = {
135
135
  'set-list-not-filed': 'Sans groupe', 'set-list-asks': 'vous demande', 'set-list-waits': 'vous attend',
136
136
  'set-list-asks-for': 'le répondeur vous demande', 'set-list-answered': 'a répondu à votre place',
137
137
  'set-list-wakeup': '1 réveil', 'set-list-wakeups': '{n} réveils', 'set-list-hidden': 'cachée',
138
- 'set-list-asleep': 'en veille', 'set-list-starting': 'démarre', 'set-list-restarting': 'redémarre',
138
+ 'set-list-asleep': 'en veille', 'set-list-stopped': 'arrêtée',
139
+ 'set-lent-page': 'Lue pour sa copie « {t} » · rien à faire', 'set-carry-down': 'Elle doit tourner pour exporter ou importer', 'set-list-starting': 'démarre', 'set-list-restarting': 'redémarre',
139
140
  'set-list-moving': 'déplace son travail', 'set-list-failed': 'en échec', 'set-list-you': 'Vous : {text}',
140
141
  'set-list-fewer': 'En montrer moins', 'set-list-more': 'En montrer {n} de plus',
141
142
  'set-list-hide-hidden': 'Masquer les {n} cachées', 'set-list-n-hidden': '{n} cachées',
package/web/app.js CHANGED
@@ -590,7 +590,7 @@
590
590
  if (listPinned) listFolded = false;
591
591
  const paintPin = () => {
592
592
  $('list-pin').setAttribute('aria-pressed', String(listPinned));
593
- 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';
593
+ const label = listPinned ? 'The list stays open: click to let it fold when something is opened' : 'Keep the list open: it no longer folds when something is opened';
594
594
  $('list-pin').title = label; $('list-pin').setAttribute('aria-label', listPinned ? 'Unpin the list' : 'Keep the list open');
595
595
  };
596
596
  const pin = (on) => {
@@ -1224,6 +1224,8 @@
1224
1224
  return;
1225
1225
  }
1226
1226
  /* STOPPED BY ITS OWNER: it stays stopped until somebody starts it. */
1227
+ /* Read for a copy just now (#221): started or woken without its tool, put back as it was after -- said, not « Stopped ». */
1228
+ if (c && c.lentTo && !socket && c.phase === 'ready') { say('read for a copy', 'connecting'); show(uiSaid('set-lent-page', 'Read for its copy « {t} » · nothing to do', { t: c.lentTo })); $('notice-spin').hidden = false; return; }
1227
1229
  if (c && c.stopped === true && !socket && c.phase === 'ready') { say('stopped', 'waiting'); show(uiSaid('set-stopped-page', 'Stopped. It starts when you start it.'), uiSaid('set-m-start', 'Start'), connect); return; }
1228
1230
  if (c && c.phase === 'moving') { disconnect(); say('moving', 'connecting'); show(`Moving its work: ${c.step ?? 'working'}... The tool is stopped meanwhile and starts again by itself.`); $('notice-spin').hidden = false; return; }
1229
1231
  if (c && c.phase === 'failed') { disconnect(); say('failed', 'ended'); show(c.error ?? 'This conversation could not be built.', DEVICE ? undefined : 'Build it again', () => void rebuild()); return; }
@@ -1272,7 +1274,9 @@
1272
1274
  }
1273
1275
  /* Opening a conversation or a room gets the list out of the way, so it has the room;
1274
1276
  the "»" button brings the list back. Only on a real pick by the owner, never on a
1275
- device or when deselecting. */
1277
+ device or when deselecting. The same for any pick in the list column that changes
1278
+ the right pane (Settings, Assets, Access, New, the server gauge): called from those
1279
+ clicks, never from showPlace/enterPlace (they also run on reload, address, Back). */
1276
1280
  function foldOnOpen() {
1277
1281
  if (DEVICE || listFolded || listPinned) return;
1278
1282
  listFolded = true;
@@ -1330,9 +1334,10 @@
1330
1334
  /* ONE FLAT POINT per conversation, its colour the state -- the worst that applies: a machine problem (red),
1331
1335
  the agent waits for you (blue), the agent at work (gold, pulsing), the machine busy (amber, pulsing),
1332
1336
  fine (green), asleep (a hollow ring). The same point, same colours, sums a folded group below. */
1333
- const machineState = (c) => (c.asleep ? 'off' : (c.phase === 'failed' || healthNeeds(c)) ? 'problem'
1337
+ /* Stopped is off as asleep is (14-11: a stopped one had the green point of one that runs). */
1338
+ const machineState = (c) => (c.asleep || c.stopped === true ? 'off' : (c.phase === 'failed' || healthNeeds(c)) ? 'problem'
1334
1339
  : (holds(c) || ['building', 'restarting', 'moving'].includes(c.phase)) ? 'busy' : 'online');
1335
- const agentState = (c) => (c.asleep ? 'sleep' : (talkNeeds(c) || c.answerer?.needs) ? 'wait'
1340
+ const agentState = (c) => (c.asleep || c.stopped === true ? 'sleep' : (talkNeeds(c) || c.answerer?.needs) ? 'wait'
1336
1341
  : c.talk?.state === 'working' ? 'work' : c.talk?.state === 'done' ? 'done' : 'idle');
1337
1342
  const STATE_WORDS = KIT.STATE_WORDS;
1338
1343
  const rollup = (c) => { const m = machineState(c); const a = agentState(c);
@@ -1433,9 +1438,9 @@
1433
1438
  /* Under way: the step the panel shows, in its words (the tool named once). */
1434
1439
  const under = c.phase === 'building' && /^(Copying|Taking|Putting|Giving)\b/.test(c.step ?? '') ? c.step : c.progress && ['building', 'restarting', 'ready'].includes(c.phase) ? stepNow(c.progress, c.toolLabel) : '';
1435
1440
  /* What it is doing, when it says something: its tool is not named on every row. */
1436
- const now = under || (holds(c) && c.phase !== 'building' ? (c.progress.kind === 'build' ? uiSaid('set-list-starting', 'starting') : uiSaid('set-list-restarting', 'restarting')) : c.phase === 'ready' ? (c.asleep ? uiSaid('set-list-asleep', 'asleep') : '') : c.phase === 'building' ? (c.step ?? 'building') : c.phase === 'moving' ? uiSaid('set-list-moving', 'moving its work') : c.phase === 'restarting' ? uiSaid('set-list-restarting', 'restarting') : uiSaid('set-list-failed', 'failed'));
1441
+ const now = under || (holds(c) && c.phase !== 'building' ? (c.progress.kind === 'build' ? uiSaid('set-list-starting', 'starting') : uiSaid('set-list-restarting', 'restarting')) : c.phase === 'ready' ? (c.asleep ? uiSaid('set-list-asleep', 'asleep') : c.stopped === true ? uiSaid('set-list-stopped', 'stopped') : '') : c.phase === 'building' ? (c.step ?? 'building') : c.phase === 'moving' ? uiSaid('set-list-moving', 'moving its work') : c.phase === 'restarting' ? uiSaid('set-list-restarting', 'restarting') : uiSaid('set-list-failed', 'failed'));
1437
1442
  /* The line of its tool only when it says something: under way, asleep, failed -- not "Claude Code" again and again. */
1438
- const plain = c.phase === 'ready' && !c.asleep && !under && !holds(c);
1443
+ const plain = c.phase === 'ready' && !c.asleep && c.stopped !== true && !under && !holds(c);
1439
1444
  const chips = [];
1440
1445
  /* Found by a search while hidden: said. */
1441
1446
  if (c.hidden === true && query) chips.push({ text: uiSaid('set-list-hidden', 'hidden'), cls: 'shared-mark', tone: 'note' });
@@ -1934,7 +1939,7 @@
1934
1939
  async function refresh() {
1935
1940
  clearTimeout(pollTimer);
1936
1941
  try {
1937
- const mark = (x) => (x ? `${x.phase}/${x.asleep === true}/${holds(x)}/${Boolean(x.machine)}/${x.stopped === true}` : '');
1942
+ const mark = (x) => (x ? `${x.phase}/${x.asleep === true}/${holds(x)}/${Boolean(x.machine)}/${x.stopped === true}/${Boolean(x.lentTo)}` : '');
1938
1943
  const before = mark(conversations.find((x) => x.name === current));
1939
1944
  if (DEVICE) {
1940
1945
  const mePath = () => `${API}/me?c=${encodeURIComponent(current)}`;
@@ -2210,7 +2215,7 @@
2210
2215
  if (!nav.close('create')) leavePlace();
2211
2216
  }
2212
2217
  $('hidden-toggle').addEventListener('click', () => { showHidden = !showHidden; paint(); });
2213
- $('new').addEventListener('click', () => { void openNew(); });
2218
+ $('new').addEventListener('click', () => { foldOnOpen(); void openNew(); });
2214
2219
  $('newconv-cancel').addEventListener('click', closeNew);
2215
2220
  $('newconv-close').addEventListener('click', closeNew);
2216
2221
  /* From the map's "+" of Conversations: the same page. */
@@ -2665,7 +2670,19 @@
2665
2670
  }
2666
2671
  /* Its tool's memory, exported as one file, or put back from one (#351): the person's own act, from here. */
2667
2672
  $('carry-box').hidden = DEVICE || !here;
2673
+ /* Its machine must run to be read: stopped or asleep, said there, with the one button that starts it
2674
+ (14-11: a raw « Its machine is not running » came back as the file). */
2675
+ const down = here?.stopped === true || here?.asleep === true;
2668
2676
  $('carry-export').href = `${API}/conversations/${encodeURIComponent(current)}/export`;
2677
+ $('carry-export').toggleAttribute('aria-disabled', down);
2678
+ $('carry-export').onclick = down ? (event) => { event.preventDefault(); } : null;
2679
+ $('carry-import').disabled = down;
2680
+ $('carry-said').hidden = !down;
2681
+ if (down) {
2682
+ const start = Object.assign(document.createElement('button'), { type: 'button', className: 'inline', textContent: here.asleep === true ? uiSaid('set-wake-it', 'Wake it') : uiSaid('set-m-start', 'Start') });
2683
+ start.addEventListener('click', () => { leavePanel(); connect(); });
2684
+ $('carry-said').replaceChildren(uiSaid('set-carry-down', 'It must run to export or import.'), ' ', start);
2685
+ }
2669
2686
  $('carry-import').onclick = () => $('carry-file').click();
2670
2687
  $('carry-file').onchange = () => {
2671
2688
  const file = $('carry-file').files?.[0]; $('carry-file').value = '';
@@ -7025,15 +7042,15 @@
7025
7042
  }
7026
7043
  nav.outside = () => { if (!DEVICE) void followAddress(); };
7027
7044
  $('nav-conversations').addEventListener('click', () => { leavePlace({ list: true }); });
7028
- $('nav-access').addEventListener('click', () => { if (place !== 'access' || accessTab !== 'map' || mapMode !== 'map') void openAccessPage('map', { mode: 'map' }); });
7029
- $('nav-assets').addEventListener('click', () => { if (place !== 'assets') void openAssetsPlace(); });
7045
+ $('nav-access').addEventListener('click', () => { foldOnOpen(); if (place !== 'access' || accessTab !== 'map' || mapMode !== 'map') void openAccessPage('map', { mode: 'map' }); });
7046
+ $('nav-assets').addEventListener('click', () => { foldOnOpen(); if (place !== 'assets') void openAssetsPlace(); });
7030
7047
  $('map-new-device').addEventListener('click', () => newDevice(accessFor));
7031
7048
  /* Every device and what each was given, by device or by thing: a step over the map. */
7032
7049
  $('map-all-devices').addEventListener('click', () => { void openAccessPage('devices'); });
7033
7050
  /* Voice boxes are on the page of all devices: opened there, at them. */
7034
7051
  $('map-voice-boxes').addEventListener('click', async () => { await openAccessPage('devices'); $('boxes')?.scrollIntoView({ block: 'start' }); });
7035
7052
  $('share-manage-close').addEventListener('click', () => { if (!nav.close('sub')) void openAccessPage('map', { push: false }); });
7036
- $('nav-settings').addEventListener('click', () => { if (place !== 'settings') void openSettings(); });
7053
+ $('nav-settings').addEventListener('click', () => { foldOnOpen(); if (place !== 'settings') void openSettings(); });
7037
7054
  $('access-close').addEventListener('click', () => leavePlace());
7038
7055
  $('access-for-clear').addEventListener('click', () => { accessFor = ''; void openAccessPage(accessTab, { push: false }); });
7039
7056
  for (const b of $('map-mode').querySelectorAll('[data-mode]')) b.addEventListener('click', () => { if (b.dataset.mode !== mapMode || accessTab !== 'map') void openAccessPage('map', { mode: b.dataset.mode }); });
@@ -8856,6 +8873,7 @@
8856
8873
  g.hidden = false;
8857
8874
  }
8858
8875
  $('server-gauge').addEventListener('click', async () => {
8876
+ foldOnOpen();
8859
8877
  if (place !== 'settings') await openSettings(); else await paintServer();
8860
8878
  const top = openChapter('s-resources');
8861
8879
  top.scrollIntoView({ block: 'start' });
package/web/style.css CHANGED
@@ -3077,3 +3077,4 @@ button.kit-switch[aria-checked="true"]::after { left: 18px; background: var(--ok
3077
3077
  /* At hand (13-11): a switch's name never under its buttons -- the name keeps its width, the buttons wrap. */
3078
3078
  .hand-switches .set-row > .set-what { flex: none; }
3079
3079
  .hand-switches .set-row > .set-control { flex: 0 1 auto; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
3080
+ a.button[aria-disabled] { opacity: .5; pointer-events: none; }