clavarium 0.2.430-next.1 → 0.2.431-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,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.430-next.1",
3
+ "version": "0.2.431-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.430-next.1",
9
+ "version": "0.2.431-next.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.430-next.1",
3
+ "version": "0.2.431-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.",
@@ -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
 
@@ -1049,6 +1049,8 @@ export class Conversations {
1049
1049
  holding memory (capacity.mjs, reclaimSleepers) does not put it back to sleep while it is read --
1050
1050
  the reading would end cut (13-11: exit 255). */
1051
1051
  this.#borrowed.add(from);
1052
+ /* Its page says so while it is read (not « Stopped » or « Asleep »): cleared once put back. */
1053
+ this.#store.patch(from, { lentTo: this.#store.get(to)?.title ?? to });
1052
1054
  const started = await this.#vms.start(from);
1053
1055
  if (started.code !== 0) throw new Error(`its original's machine did not start: ${firstLine(started.stderr) || `exit ${started.code}`}.`);
1054
1056
  woke = true;
@@ -1066,10 +1068,18 @@ export class Conversations {
1066
1068
  out.stream.on('data', (d) => { read += d.length; lastAt = Date.now(); say(`Copying ${tool.label}'s memory: ${sizeWords(read)} read`); });
1067
1069
  /* Nothing comes for a while: said, with how long; for too long, the reading is ended and why said --
1068
1070
  never an endless wait nobody can read (14-11: stuck at "36 KB read"). */
1071
+ /* Quiet for 30 s: its machine asked, once, what its reading does -- the file it is on and its state
1072
+ (D: waiting on the disk), its load, its free memory -- or said not to answer at all. Said with the
1073
+ wait, and in the end's why (14-11: stuck at 36 KB on the owner's server, never here). */
1074
+ let seen = '';
1075
+ 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; '
1076
+ + 'echo "load $(cut -d" " -f1 /proc/loadavg)"; awk \'/MemAvailable/{print "free " int($2/1024) " MB"}\' /proc/meminfo';
1077
+ 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
1078
  const watch = setInterval(() => {
1070
1079
  const quiet = Math.round((Date.now() - lastAt) / 1000);
1071
1080
  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`);
1081
+ if (quiet >= 30 && !seen) ask();
1082
+ if (quiet >= 15) say(`Copying ${tool.label}'s memory: ${sizeWords(read)} read, nothing more for ${quiet} s${seen && seen !== '…' ? ` (${seen})` : ''}`);
1073
1083
  }, 5000);
1074
1084
  const failed = new Promise((ok) => child.on('error', () => ok(-1)));
1075
1085
  const file = createWriteStream(carried, { mode: 0o600 });
@@ -1077,7 +1087,7 @@ export class Conversations {
1077
1087
  code = await Promise.race([new Promise((ok) => child.on('close', ok)), failed]).finally(() => clearInterval(watch));
1078
1088
  if (stalled) {
1079
1089
  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'})`);
1090
+ 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
1091
  }
1082
1092
  await new Promise((ok) => (file.writableFinished ? ok() : file.on('finish', ok)));
1083
1093
  if (code !== 255) break;
@@ -1086,6 +1096,7 @@ export class Conversations {
1086
1096
  /* Read: its original back to sleep at once, before the copy's machine is made. */
1087
1097
  if (woke) { await back().catch(() => {}); woke = false; }
1088
1098
  this.#borrowed.delete(from);
1099
+ if (this.#store.get(from)?.lentTo) this.#store.patch(from, { lentTo: undefined });
1089
1100
  }
1090
1101
  open(true);
1091
1102
  await building;
@@ -1119,6 +1130,7 @@ export class Conversations {
1119
1130
  rmSync(dir, { recursive: true, force: true });
1120
1131
  if (woke) await back().catch(() => {});
1121
1132
  this.#borrowed.delete(from);
1133
+ if (this.#store.get(from)?.lentTo) this.#store.patch(from, { lentTo: undefined });
1122
1134
  }
1123
1135
  }
1124
1136
 
@@ -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
@@ -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; }
@@ -1330,9 +1332,10 @@
1330
1332
  /* ONE FLAT POINT per conversation, its colour the state -- the worst that applies: a machine problem (red),
1331
1333
  the agent waits for you (blue), the agent at work (gold, pulsing), the machine busy (amber, pulsing),
1332
1334
  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'
1335
+ /* Stopped is off as asleep is (14-11: a stopped one had the green point of one that runs). */
1336
+ const machineState = (c) => (c.asleep || c.stopped === true ? 'off' : (c.phase === 'failed' || healthNeeds(c)) ? 'problem'
1334
1337
  : (holds(c) || ['building', 'restarting', 'moving'].includes(c.phase)) ? 'busy' : 'online');
1335
- const agentState = (c) => (c.asleep ? 'sleep' : (talkNeeds(c) || c.answerer?.needs) ? 'wait'
1338
+ const agentState = (c) => (c.asleep || c.stopped === true ? 'sleep' : (talkNeeds(c) || c.answerer?.needs) ? 'wait'
1336
1339
  : c.talk?.state === 'working' ? 'work' : c.talk?.state === 'done' ? 'done' : 'idle');
1337
1340
  const STATE_WORDS = KIT.STATE_WORDS;
1338
1341
  const rollup = (c) => { const m = machineState(c); const a = agentState(c);
@@ -1433,9 +1436,9 @@
1433
1436
  /* Under way: the step the panel shows, in its words (the tool named once). */
1434
1437
  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
1438
  /* 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'));
1439
+ 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
1440
  /* 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);
1441
+ const plain = c.phase === 'ready' && !c.asleep && c.stopped !== true && !under && !holds(c);
1439
1442
  const chips = [];
1440
1443
  /* Found by a search while hidden: said. */
1441
1444
  if (c.hidden === true && query) chips.push({ text: uiSaid('set-list-hidden', 'hidden'), cls: 'shared-mark', tone: 'note' });
@@ -1934,7 +1937,7 @@
1934
1937
  async function refresh() {
1935
1938
  clearTimeout(pollTimer);
1936
1939
  try {
1937
- const mark = (x) => (x ? `${x.phase}/${x.asleep === true}/${holds(x)}/${Boolean(x.machine)}/${x.stopped === true}` : '');
1940
+ const mark = (x) => (x ? `${x.phase}/${x.asleep === true}/${holds(x)}/${Boolean(x.machine)}/${x.stopped === true}/${Boolean(x.lentTo)}` : '');
1938
1941
  const before = mark(conversations.find((x) => x.name === current));
1939
1942
  if (DEVICE) {
1940
1943
  const mePath = () => `${API}/me?c=${encodeURIComponent(current)}`;
@@ -2665,7 +2668,19 @@
2665
2668
  }
2666
2669
  /* Its tool's memory, exported as one file, or put back from one (#351): the person's own act, from here. */
2667
2670
  $('carry-box').hidden = DEVICE || !here;
2671
+ /* Its machine must run to be read: stopped or asleep, said there, with the one button that starts it
2672
+ (14-11: a raw « Its machine is not running » came back as the file). */
2673
+ const down = here?.stopped === true || here?.asleep === true;
2668
2674
  $('carry-export').href = `${API}/conversations/${encodeURIComponent(current)}/export`;
2675
+ $('carry-export').toggleAttribute('aria-disabled', down);
2676
+ $('carry-export').onclick = down ? (event) => { event.preventDefault(); } : null;
2677
+ $('carry-import').disabled = down;
2678
+ $('carry-said').hidden = !down;
2679
+ if (down) {
2680
+ 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') });
2681
+ start.addEventListener('click', () => { leavePanel(); connect(); });
2682
+ $('carry-said').replaceChildren(uiSaid('set-carry-down', 'It must run to export or import.'), ' ', start);
2683
+ }
2669
2684
  $('carry-import').onclick = () => $('carry-file').click();
2670
2685
  $('carry-file').onchange = () => {
2671
2686
  const file = $('carry-file').files?.[0]; $('carry-file').value = '';
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; }