clavarium 0.2.206-beta.1 → 0.2.207-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,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.206-beta.1",
3
+ "version": "0.2.207-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.206-beta.1",
9
+ "version": "0.2.207-beta.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.62-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
- "clavarium-parley": "0.17.92-next.1",
16
+ "clavarium-parley": "0.17.93-next.1",
17
17
  "clavarium-tether": "0.1.0-next.67",
18
18
  "mammoth": "1.13.0",
19
19
  "mermaid": "11.17.2",
@@ -787,9 +787,9 @@
787
787
  }
788
788
  },
789
789
  "node_modules/clavarium-parley": {
790
- "version": "0.17.92-next.1",
791
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.92-next.1.tgz",
792
- "integrity": "sha512-THH8l0YkllcG6J4H1suSthJLgRWYbGnRMj6m90OSqyui7ttVBaeCC1sREVROs+D6KnHS7yZXRdWeFwiK0gwzdQ==",
790
+ "version": "0.17.93-next.1",
791
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.93-next.1.tgz",
792
+ "integrity": "sha512-D+h9CwtW2j8mgS+hUlSyc1h5aSvMfqSUQ821cijtR4dvHNlgPe/0/GYZqsf1Kms8dV+eGUxQBT2aTd8CcxvpXA==",
793
793
  "license": "MIT",
794
794
  "bin": {
795
795
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.206-beta.1",
3
+ "version": "0.2.207-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.",
@@ -47,7 +47,7 @@
47
47
  "@xterm/xterm": "^6.0.0",
48
48
  "clavarium-binder": "0.1.62-next.1",
49
49
  "clavarium-docket": "0.1.2-next.2",
50
- "clavarium-parley": "0.17.92-next.1",
50
+ "clavarium-parley": "0.17.93-next.1",
51
51
  "clavarium-tether": "0.1.0-next.67",
52
52
  "mammoth": "1.13.0",
53
53
  "mermaid": "11.17.2",
package/server/api.mjs CHANGED
@@ -34,6 +34,8 @@
34
34
  * POST /api/conversations/<name>/talk {text, answers?, files?, via?}: written in its chat; files from .../talk/file; via 'voice': dictated
35
35
  * POST /api/conversations/<name>/talk/react {to, reaction}: the owner's reaction to a message of the tool (null: taken back)
36
36
  * POST /api/conversations/<name>/talk/pin {to, on}: the owner pins a message of the chat (on: false unpins); 5 at most
37
+ * POST /api/conversations/<name>/talk/split {messages: 500..100000} | {days: 0.5..365} | {off: true}: when its thread is
38
+ * archived into volumes (nothing deleted) -> {split}; read back as `split` in GET .../talk
37
39
  * POST /api/conversations/<name>/chat-name {name}: the name the chat gives its tool ('' : the neutral word of the dictionary)
38
40
  * POST /api/conversations/<name>/tasks-binder {binder}: the binder shown beside its chat ('' automatic, '-' none, else an id)
39
41
  * POST /api/conversations/<name>/voice-mark {on}: what is dictated into its terminal starts with a microphone sign (AI tools only)
@@ -835,13 +837,14 @@ export async function handleApi(request, response, conversations, headers, resou
835
837
  }
836
838
  return send(200, { asset, rights, given }), true;
837
839
  }
838
- const talking = /^\/api\/conversations\/([^/]+)\/talk(\/invite|\/remind|\/react|\/pin)?$/.exec(pathname);
840
+ const talking = /^\/api\/conversations\/([^/]+)\/talk(\/invite|\/remind|\/react|\/pin|\/split)?$/.exec(pathname);
839
841
  if (talking && talk) {
840
842
  const conversation = decodeURIComponent(talking[1]);
841
843
  if (talking[2] === '/invite') return send(200, await talk.invite(conversation, typeof body.lang === 'string' ? body.lang : 'en')), true;
842
844
  if (talking[2] === '/remind') return send(200, await talk.remind(conversation, { urgent: body?.urgent === true })), true;
843
845
  if (talking[2] === '/react') return send(200, await talk.react(conversation, body.to, body.reaction ?? null)), true;
844
846
  if (talking[2] === '/pin') return send(200, await talk.pin(conversation, body.to, body.on !== false)), true;
847
+ if (talking[2] === '/split') return send(200, talk.setSplit(conversation, { messages: body.messages, days: body.days, off: body.off })), true;
845
848
  if (typeof body.on === 'boolean') { const now = await talk.set(conversation, body.on); retell(conversation); return send(200, now), true; }
846
849
  /* What the chat may add to an answer: the choices ticked, the answers of a group, the zone of a picture it is about (Parley checks each). */
847
850
  return send(201, await talk.say(conversation, body.text, body.answers, body.files, body.via, { picked: body.picked, replies: body.replies, about: body.about, quick: body.quick === true })), true;
@@ -180,9 +180,13 @@ export class Capacity {
180
180
  const set = this.reserve();
181
181
  const all = this.#conversations.list();
182
182
  const records = new Map(all.map((c) => [`clv-${c.name}`, c]));
183
+ /* A shared machine (#221) is no conversation's own: named, with who lives in it (14-11: it showed as « another machine »). */
184
+ const shared = new Map();
185
+ for (const c of all) if (c.sharedMachine) { const s = shared.get(`clv-${c.sharedMachine}`) ?? { shared: c.sharedMachine, who: [], sizeMb: c.machineMb ?? null }; s.who.push(c.title ?? c.name); shared.set(`clv-${c.sharedMachine}`, s); }
183
186
  const machines = room.machines.map((m) => {
184
187
  const c = records.get(m.vm);
185
- return { name: c ? c.name : null, shelf: m.vm.startsWith('clvshelf-'), rssMb: m.rssMb, sizeMb: c?.memoryMb ?? null, ...(room.machineAge?.[m.vm] !== undefined ? { ageS: room.machineAge[m.vm] } : {}) };
188
+ const s = c ? null : shared.get(m.vm);
189
+ return { name: c ? c.name : null, ...(s ? { shared: s.shared, who: s.who } : {}), shelf: m.vm.startsWith('clvshelf-'), rssMb: m.rssMb, sizeMb: c?.memoryMb ?? s?.sizeMb ?? null, ...(room.machineAge?.[m.vm] !== undefined ? { ageS: room.machineAge[m.vm] } : {}) };
186
190
  });
187
191
  /* What the system says is available: the machines' own use is in it already. */
188
192
  const memory = room.memory ? { totalMb: room.memory.totalMb, freeMb: room.memory.availableMb, usedPercent: percent(room.memory.totalMb - room.memory.availableMb, room.memory.totalMb) } : null;
@@ -11,6 +11,9 @@ export const SETTINGS_WORDS_FR = {
11
11
  'set-ch-s-words': 'Écran du chat', 'set-ch-s-dictation': 'Dictée', 'set-ch-s-shortcuts': 'Raccourcis', 'set-ch-s-thread': 'Événements du chat',
12
12
  'set-ch-s-updates': 'Mises à jour', 'set-ch-s-binders': 'Classeurs', 'set-ch-s-events': 'Activité', 'set-ch-s-jobs': 'Tâches', 'set-ch-s-logs': 'Journaux',
13
13
  'set-ch-s-usage': 'Usage', 'set-ch-s-backup': 'Sauvegarde', 'set-ch-s-advanced': 'Avancé',
14
+ /* Chat › when its thread is archived (talk.mjs setSplit). */
15
+ 'set-chat-split': 'Archiver son fil', 'set-split-2000': 'Tous les 2 000 messages', 'set-split-5000': 'Tous les 5 000',
16
+ 'set-split-week': 'Chaque semaine', 'set-split-day': 'Chaque jour', 'set-split-never': 'Jamais',
14
17
  'set-check-updates': 'Chercher une mise à jour', 'set-activity': 'Activité', 'set-restart-dots': 'Redémarrer…', 'set-terminal': 'Terminal',
15
18
  'set-search': 'Chercher', 'set-why': 'Pourquoi',
16
19
  /* Diagnostics › Tâches (jobs.mjs): celles du jour, chacune avec son journal. */
@@ -166,7 +169,7 @@ export const SETTINGS_WORDS_FR = {
166
169
  'set-mcp-name': 'Nom', 'set-mcp-url': 'Adresse', 'set-mcp-key': 'Clé', 'set-mcp-add': 'Ajouter',
167
170
  /* Où elle tourne, et l'assistant Copier ou déplacer (#221, 14-11). */
168
171
  'set-where': 'Où elle tourne', 'set-where-copy': 'Copier…', 'set-where-move': 'Déplacer…', 'set-where-own': 'Sa propre machine',
169
- 'set-where-shared': 'Machine partagée « {m} », avec {others}', 'set-where-alone': 'Machine partagée « {m} », seule', 'set-where-stops': 'L’arrêter les arrête aussi',
172
+ 'set-where-shared': 'Machine partagée « {m} », avec {others}', 'set-where-alone': 'Machine partagée « {m} », seule', 'set-where-stops': 'L’arrêter les arrête aussi', 'set-mem-shared': 'Partagée « {m} » : {who}',
170
173
  'set-cm-title': 'Copier ou déplacer {t}', 'set-cm-copy': 'Copier', 'set-cm-copy-what': 'Celle-ci reste telle quelle',
171
174
  'set-cm-move': 'Déplacer', 'set-cm-move-what': 'La même, sur une autre machine', 'set-cm-cancel': 'Annuler', 'set-cm-next': 'Suivant',
172
175
  'set-cm-not-yet': 'Pas encore', 'set-cm-with': 'Avec {who}', 'set-cm-shared': 'Machine partagée « {m} »', 'set-cm-new': 'Une nouvelle machine partagée',
package/server/talk.mjs CHANGED
@@ -71,6 +71,9 @@ import { SOCKET } from './tmux.mjs';
71
71
  import { isConversationName } from './names.mjs';
72
72
 
73
73
  export const FOLDER = '.parley';
74
+ /* What the owner may choose for archiving a thread (setSplit): messages from 500 to 100,000, days from half a day to a year. */
75
+ export const SPLIT_MESSAGES = Object.freeze([500, 100_000]);
76
+ export const SPLIT_DAYS = Object.freeze([0.5, 365]);
74
77
  const IN_MACHINE = `/work/${FOLDER}`;
75
78
  /* Texts this server gives the tool to read (keepText): kept this many days, this many at most of one name. */
76
79
  export const KEPT_TEXT_DAYS = 7;
@@ -352,11 +355,12 @@ export class Talk {
352
355
  /* The machine's lines go among the messages, where they happened. */
353
356
  const lines = (record.system ?? []).map((l) => ({ from: 'system', kind: 'system', choices: [], ...l }));
354
357
  const asked = partOf(part);
355
- if (asked?.state) return { on: true, possible, tools, wake };
358
+ /* When its thread is archived (split), with the rest of its chat's state: a small file read. */
359
+ if (asked?.state) return { on: true, possible, tools, wake, split: this.split(name) };
356
360
  if (!asked) {
357
361
  const read = this.#parley(name).read();
358
362
  const messages = [...read.messages, ...lines].sort((a, b) => String(a.at).localeCompare(String(b.at))).slice(-SHOWN_MAX);
359
- return { on: true, possible, tools, ...read, messages, wake };
363
+ return { on: true, possible, tools, ...read, messages, wake, split: this.split(name) };
360
364
  }
361
365
  /* Its own lines change apart from the thread (and their buttons with what was marked seen): their stamp is part of the cursor. */
362
366
  const stamp = createHash('sha256').update(JSON.stringify([record.system ?? [], this.#health?.of?.(name)?.seenAt ?? null])).digest('hex').slice(0, 10);
@@ -376,6 +380,26 @@ export class Talk {
376
380
  return this.#parley(name).search(String(text ?? '').slice(0, 200));
377
381
  }
378
382
 
383
+ /* WHEN ITS THREAD IS ARCHIVED (Parley's split, "The archive" in its protocol): its older messages go into
384
+ volumes, nothing deleted, every part still read as one thread. The owner's choice per conversation, kept in
385
+ its bridge folder (.parley/settings.json): { messages: N } once the thread holds N lines, { days: D } for
386
+ volumes of D days at most, or false (never). Parley's own default is { messages: 5000 }. */
387
+ split(name) { this.#known(name); return this.#parley(name).split(); }
388
+ setSplit(name, { messages, days, off } = {}) {
389
+ if (this.#known(name).work !== 'kept') throw new Refusal(409, 'Its work folder is not kept here: its chat has no thread to archive.');
390
+ let value;
391
+ if (off === true) value = false;
392
+ else if (messages !== undefined) {
393
+ if (!Number.isInteger(messages) || messages < SPLIT_MESSAGES[0] || messages > SPLIT_MESSAGES[1]) throw new Refusal(400, `"messages" is a whole number from ${SPLIT_MESSAGES[0]} to ${SPLIT_MESSAGES[1]}.`);
394
+ value = { messages };
395
+ } else if (days !== undefined) {
396
+ if (typeof days !== 'number' || !Number.isFinite(days) || days < SPLIT_DAYS[0] || days > SPLIT_DAYS[1]) throw new Refusal(400, `"days" is a number from ${SPLIT_DAYS[0]} to ${SPLIT_DAYS[1]}.`);
397
+ value = { days };
398
+ } else throw new Refusal(400, 'Say {messages}, {days} or {off: true}.');
399
+ this.#parley(name).setSplit(value);
400
+ return { split: this.split(name) };
401
+ }
402
+
379
403
  /* What the tool reads of its chat after a restart (REREAD), the owner's choice of WINDOWS. */
380
404
  window() {
381
405
  const ai = this.#words?.get('window')?.ai;
package/web/app.js CHANGED
@@ -3864,6 +3864,7 @@
3864
3864
  const here = conversations.find((x) => x.name === current);
3865
3865
  if (document.activeElement !== $('chat-name')) $('chat-name').value = here?.chatName ?? '';
3866
3866
  void paintTasksBinder(here);
3867
+ void paintChatSplit();
3867
3868
  if (document.activeElement !== $('title-name')) $('title-name').value = shownName(here);
3868
3869
  $('title-box').hidden = $('hide-box').hidden = $('group-box').hidden = DEVICE || !here;
3869
3870
  if (document.activeElement !== $('group-name')) $('group-name').value = here?.group ?? '';
@@ -3941,6 +3942,32 @@
3941
3942
  try { await post(`${API}/conversations/${encodeURIComponent(current)}/tasks-binder`, { binder: $('tasks-binder').value }); await refresh(); void paintTasks(current); }
3942
3943
  catch (error) { $('panel-error').textContent = error.message; $('panel-error').hidden = false; }
3943
3944
  });
3945
+ /* WHEN ITS THREAD IS ARCHIVED (server/talk.mjs setSplit): a choice of a few; another value set elsewhere is shown as it is. */
3946
+ const CHAT_SPLITS = [
3947
+ ['messages:2000', () => uiSaid('set-split-2000', 'Every 2,000 messages')],
3948
+ ['messages:5000', () => uiSaid('set-split-5000', 'Every 5,000')],
3949
+ ['days:7', () => uiSaid('set-split-week', 'Every week')],
3950
+ ['days:1', () => uiSaid('set-split-day', 'Every day')],
3951
+ ['off', () => uiSaid('set-split-never', 'Never')],
3952
+ ];
3953
+ const splitKey = (v) => (v === false ? 'off' : v?.days ? `days:${v.days}` : `messages:${v?.messages ?? 5000}`);
3954
+ async function paintChatSplit() {
3955
+ const name = current;
3956
+ const t = talkOf === name ? talk : await readTalk();
3957
+ if (name !== current) return;
3958
+ $('chat-split-row').hidden = !t?.on || t.split === undefined;
3959
+ if ($('chat-split-row').hidden || document.activeElement === $('chat-split')) return;
3960
+ const now = splitKey(t.split);
3961
+ const choices = CHAT_SPLITS.some(([v]) => v === now) ? CHAT_SPLITS : [...CHAT_SPLITS, [now, () => now.replace(':', ' ')]];
3962
+ $('chat-split').replaceChildren(...choices.map(([v, text]) => { const o = document.createElement('option'); o.value = v; o.textContent = text(); o.selected = v === now; return o; }));
3963
+ }
3964
+ $('chat-split').addEventListener('change', async () => {
3965
+ const [kind, n] = $('chat-split').value.split(':');
3966
+ $('panel-error').hidden = true;
3967
+ try { await post(`${API}/conversations/${encodeURIComponent(current)}/talk/split`, kind === 'off' ? { off: true } : { [kind]: Number(n) }); await readTalk(); }
3968
+ catch (error) { $('panel-error').textContent = error.message; $('panel-error').hidden = false; }
3969
+ $('chat-split').blur(); await paintChatSplit();
3970
+ });
3944
3971
  $('chat-name-form').addEventListener('submit', async (event) => {
3945
3972
  event.preventDefault();
3946
3973
  $('panel-error').hidden = true;
@@ -4304,7 +4331,9 @@
4304
4331
  });
4305
4332
  }
4306
4333
  /* Its settings, on the Access chapter. `giving`: « Give… » instead, in its Assets tab (07-11, assets step 4). */
4307
- async function openAccess(giving = false) {
4334
+ /* `atAccess`: on its Access chapter (a link that asks for it). The settings button keeps the tab the person was
4335
+ on (14-11: it jumped from Resources to Access by itself, each time the settings were opened or painted again). */
4336
+ async function openAccess(giving = false, { atAccess = true } = {}) {
4308
4337
  if (DEVICE || !current) return;
4309
4338
  if (place !== 'conversations') leavePlace();
4310
4339
  if (giving) { openGive(); return; }
@@ -4312,10 +4341,13 @@
4312
4341
  /* What it has may have changed from another screen: asked again before it is shown. */
4313
4342
  await refresh();
4314
4343
  await paintPanel();
4315
- /* The folders button shows the folders: their chapter opened, in its tab. */
4316
- openChapter('access');
4344
+ if (atAccess) openChapter('access');
4317
4345
  }
4318
- $('folders').addEventListener('click', () => { void openAccess(false); });
4346
+ $('folders').addEventListener('click', () => {
4347
+ /* A tab chosen before on this device: that one. Never chosen: its Access chapter, as it always opened. */
4348
+ let kept = null; try { kept = localStorage.getItem('clavarium-tab-panel'); } catch { /* a private window */ }
4349
+ void openAccess(false, { atAccess: !kept });
4350
+ });
4319
4351
  /* « N assets · see »: its Assets tab. */
4320
4352
  $('access-assets').addEventListener('click', () => { goTab('assets'); });
4321
4353
 
@@ -8899,7 +8931,7 @@
8899
8931
  $('server-memory-note').textContent = aboveWords(mem.freeMb - r.reserve.memoryMb, r.reserve.memoryMb);
8900
8932
  const held = r.machines.reduce((a, x) => a + x.rssMb, 0);
8901
8933
  const rest = Math.max(0, mem.totalMb - mem.freeMb - held);
8902
- const named = r.machines.map((x, i) => ({ key: x.name ?? `vm-${i}`, label: x.shelf ? 'ready-made machine (being made)' : (x.name ? machineTitle(x.name) : 'another machine'), mb: x.rssMb, x }));
8934
+ const named = r.machines.map((x, i) => ({ key: x.name ?? `vm-${i}`, label: x.shelf ? 'ready-made machine (being made)' : x.name ? machineTitle(x.name) : x.shared ? uiSaid('set-mem-shared', 'Shared « {m} »: {who}', { m: x.shared, who: (x.who ?? []).join(', ') }) : 'another machine', mb: x.rssMb, x }));
8903
8935
  const share = shareOf(named, rest, mem.freeMb);
8904
8936
  $('server-memory-share').replaceChildren(...(r.machines.length ? [shareDonut(share.slices, uiSaid('set-share-memory', 'Memory by machine'), mem.totalMb - mem.freeMb, mem.totalMb)] : []));
8905
8937
  parts($('server-memory-parts'), [
package/web/index.html CHANGED
@@ -297,6 +297,8 @@
297
297
  <div class="chapter-body">
298
298
  <div id="talk-box">
299
299
  <form id="chat-name-form" class="set-row" autocomplete="off"><div class="set-what"><label for="chat-name">Its name in the chat</label><small id="chat-name-hint">Empty: "Assistant"</small></div><div class="set-control"><input id="chat-name" maxlength="40" placeholder="Assistant" spellcheck="false"><button type="submit">Save</button></div></form>
300
+ <!-- WHEN ITS THREAD IS ARCHIVED (Parley's split): older messages go into volumes, none deleted, still read and searched. -->
301
+ <div class="set-row" id="chat-split-row" hidden><div class="set-what"><label for="chat-split" data-said="set-chat-split">Archive its thread</label></div><div class="set-control"><select id="chat-split"></select></div></div>
300
302
  <div class="set-row" id="tasks-binder-row" hidden><div class="set-what"><label for="tasks-binder">Binder beside the chat</label><small class="tip" hidden>Automatic: its first binder of batches</small></div><div class="set-control"><select id="tasks-binder"></select></div></div>
301
303
  </div>
302
304
  <!-- DICTATION INTO ITS TERMINAL: marked once per message, so that the tool knows it may hold recognition mistakes. -->