clavarium 0.2.401-next.1 → 0.2.404-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.
@@ -1121,10 +1121,11 @@ case "$AREA $VERB" in
1121
1121
  fi
1122
1122
  exit 0 ;;
1123
1123
  "vm smount")
1124
- # <vm> <conversation> <work|folder|view> <resource> <uid> <gid>: into the conversation's own place in a
1125
- # shared machine (/srv/clavarium/<conversation>/...), where its door (clavarium-enter) finds it -- only for
1126
- # a conversation that lives in that machine.
1127
- [ $# -eq 6 ] || usage; vm_of "$1"; is_name "$2" || refuse "not a conversation name: $2"; is_name "$4" || refuse "not a folder name: $4"; number "$5"; number "$6"
1124
+ # <vm> <conversation> <work|folder|view> <resource> <uid> <gid> <its uid> <its gid>: into the conversation's
1125
+ # own place in a shared machine (/srv/clavarium/<conversation>/...), where its door (clavarium-enter) finds
1126
+ # it, owned there by ITS user (not the machine's admin) -- only for a conversation that lives in that machine.
1127
+ [ $# -eq 8 ] || usage; vm_of "$1"; is_name "$2" || refuse "not a conversation name: $2"; is_name "$4" || refuse "not a folder name: $4"; number "$5"; number "$6"; number "$7"; number "$8"
1128
+ [ "$7" -ge 1001 ] && [ "$8" -ge 1001 ] || refuse "its own user is not the machine's admin"
1128
1129
  [ -f "$DATA/shared/$1" ] && grep -qx "$2" "$DATA/shared/$1" || refuse "$2 does not live in $1"
1129
1130
  case "$3" in
1130
1131
  work) [ "$4" = "$2" ] || refuse "a work folder belongs to its own conversation"
@@ -1137,7 +1138,7 @@ case "$AREA $VERB" in
1137
1138
  target="$1:/srv/clavarium/$2/resources/$4" ;;
1138
1139
  *) refuse "a shared mount is of a work folder, a folder or a view" ;;
1139
1140
  esac
1140
- run "$MULTIPASS" mount -u "$5:$VM_ID" -g "$6:$VM_ID" "$source" "$target" ;;
1141
+ run "$MULTIPASS" mount -u "$5:$7" -g "$6:$8" "$source" "$target" ;;
1141
1142
  "vm sumount")
1142
1143
  # <vm> <conversation> <work|resource name>: taken out of its place in a shared machine.
1143
1144
  [ $# -eq 3 ] || usage; vm_of "$1"; is_name "$2" || refuse "not a conversation name: $2"; is_name "$3" || refuse "not a name: $3"
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.401-next.1",
3
+ "version": "0.2.404-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.401-next.1",
9
+ "version": "0.2.404-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.401-next.1",
3
+ "version": "0.2.404-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.",
@@ -445,7 +445,7 @@ export class Conversations {
445
445
  if (me.code !== 0 || !Number.isInteger(uid) || !Number.isInteger(gid)) return fail('Its own user could not be made', me);
446
446
  this.#store.patch(name, { machineUser: { uid, gid } });
447
447
  const kept = await this.#vms.workMake(name);
448
- const shown = kept.code === 0 ? await this.#vms.workMount(name, uid, gid) : kept;
448
+ const shown = kept.code === 0 ? await this.#vms.workMount(name, this.#uid, this.#gid) : kept;
449
449
  if (shown.code !== 0) return fail('The work folder could not be shown in the shared machine', shown);
450
450
  /* Its tool: there already (another conversation installed it), or installed -- a step as root for the
451
451
  machine, any other as its own user (its settings, in its home). */
@@ -159,6 +159,7 @@ export const SETTINGS_WORDS_FR = {
159
159
  'set-na-k-mcp': 'Serveur MCP', 'set-cx-mcp': 'serveur MCP',
160
160
  'set-mcp-head': 'Ajouter un serveur MCP', 'set-mcp-hint': 'Ses outils pour vos IA ; la clé reste ici.',
161
161
  'set-mcp-name': 'Nom', 'set-mcp-url': 'Adresse', 'set-mcp-key': 'Clé', 'set-mcp-add': 'Ajouter',
162
+ 'set-mshared-with': 'Partagée « {m} », avec {others}.', 'set-mshared-alone': 'Machine partagée « {m} », seule pour l\'instant.',
162
163
  'set-carry': 'La mémoire de son outil', 'set-carry-hint': 'Mémoire, sessions, réglages : à emporter.',
163
164
  'set-carry-export': 'Exporter', 'set-carry-import': 'Importer…', 'set-carry-go': 'Importer',
164
165
  'set-carry-ask': '« {file} » dans « {name} » ? Mémoire remplacée.', 'set-carry-done': 'Importé depuis « {from} ».',
package/server/vm.mjs CHANGED
@@ -188,7 +188,7 @@ export class Vms {
188
188
  files written in the VM belong, on the host, to this account. */
189
189
  mount(conversation, kind, name, uid, gid) {
190
190
  /* In a shared machine (#221): into its own place there, where its door finds it. */
191
- if (this.shared(conversation)) { const u = this.#userOf(conversation) ?? { uid, gid }; return this.run(['vm', 'smount', this.vmOf(conversation), conversation, kind, name, String(u.uid), String(u.gid)], { timeoutMs: 600_000 }); }
191
+ if (this.shared(conversation)) { const u = this.#userOf(conversation); if (!u) throw new Error('its own user in the shared machine is not known yet'); return this.run(['vm', 'smount', this.vmOf(conversation), conversation, kind, name, String(uid), String(gid), String(u.uid), String(u.gid)], { timeoutMs: 600_000 }); }
192
192
  return this.run(['vm', 'mount', this.vmOf(conversation), kind, name, String(uid), String(gid)], { timeoutMs: 600_000 });
193
193
  }
194
194
 
@@ -196,7 +196,7 @@ export class Vms {
196
196
  machine at /work. Made (or found again) before it is mounted. */
197
197
  workMake(conversation) { this.vmOf(conversation); return this.run(['work', 'make', conversation]); }
198
198
  workMount(conversation, uid, gid) {
199
- if (this.shared(conversation)) { const u = this.#userOf(conversation) ?? { uid, gid }; return this.run(['vm', 'smount', this.vmOf(conversation), conversation, 'work', conversation, String(u.uid), String(u.gid)], { timeoutMs: 600_000 }); }
199
+ if (this.shared(conversation)) { const u = this.#userOf(conversation); if (!u) throw new Error('its own user in the shared machine is not known yet'); return this.run(['vm', 'smount', this.vmOf(conversation), conversation, 'work', conversation, String(uid), String(gid), String(u.uid), String(u.gid)], { timeoutMs: 600_000 }); }
200
200
  return this.run(['vm', 'mount', this.vmOf(conversation), 'work', conversation, String(uid), String(gid)], { timeoutMs: 600_000 });
201
201
  }
202
202
  workUnmount(conversation) {
package/web/app.js CHANGED
@@ -1987,7 +1987,7 @@
1987
1987
  let chosenTool = '';
1988
1988
  let newTools = [];
1989
1989
  const ID_SHAPE = /^[a-z]([a-z0-9-]{0,30}[a-z0-9])?$/;
1990
- const NEW_FIELDS = ['name', 'group', 'id', 'memory'];
1990
+ const NEW_FIELDS = ['name', 'group', 'id', 'memory', 'machine'];
1991
1991
  function newError(field, text) {
1992
1992
  const at = field && NEW_FIELDS.includes(field) ? field : '';
1993
1993
  for (const f of NEW_FIELDS) {
@@ -2101,6 +2101,20 @@
2101
2101
  b.addEventListener('click', () => { for (const other of $('newconv-work').querySelectorAll('[data-work]')) other.setAttribute('aria-checked', String(other === b)); });
2102
2102
  }
2103
2103
  const newOnDisk = () => $('newconv-work').querySelector('[data-work="disk"]').getAttribute('aria-checked') === 'true';
2104
+ /* WHERE IT LIVES (#221): its own machine, or a shared one -- an existing one offered, or a new name. In a shared
2105
+ machine its files are always kept here: that choice is hidden. */
2106
+ const newShared = () => $('newconv-where').querySelector('[data-where="shared"]').getAttribute('aria-checked') === 'true';
2107
+ const paintWhere = () => {
2108
+ const shared = newShared();
2109
+ $('newconv-machine-row').hidden = !shared;
2110
+ $('newconv-files-card').hidden = shared;
2111
+ const names = [...new Set(conversations.map((c) => c.sharedMachine).filter(Boolean))].sort();
2112
+ $('machine-names').replaceChildren(...names.map((n) => Object.assign(document.createElement('option'), { value: n })));
2113
+ if (shared && !$('newconv-machine').value && names.length) $('newconv-machine').value = names[0];
2114
+ };
2115
+ for (const b of $('newconv-where').querySelectorAll('[data-where]')) {
2116
+ b.addEventListener('click', () => { for (const other of $('newconv-where').querySelectorAll('[data-where]')) other.setAttribute('aria-checked', String(other === b)); paintWhere(); });
2117
+ }
2104
2118
  async function openNew({ push = true, group = null } = {}) {
2105
2119
  if (DEVICE) return;
2106
2120
  newError('', '');
@@ -2149,6 +2163,7 @@
2149
2163
  const group = $('newconv-group').value.trim();
2150
2164
  if (!title) { newError('name', 'Give a name.'); return; }
2151
2165
  if (id && !ID_SHAPE.test(id)) { newError('id', 'Lower-case letters, digits, hyphens'); return; }
2166
+ if (newShared() && !ID_SHAPE.test($('newconv-machine').value.trim())) { newError('machine', 'A name: lower-case letters, digits, hyphens'); return; }
2152
2167
  const least = newTools.find((t) => t.id === chosenTool)?.memoryMb;
2153
2168
  const memoryMb = Number($('newconv-memory').value);
2154
2169
  const cpus = Number($('newconv-cpus').value); const diskGb = Number($('newconv-disk').value);
@@ -2156,9 +2171,9 @@
2156
2171
  creating = true; $('newconv-create').disabled = true;
2157
2172
  try {
2158
2173
  const opencode = await openCodeChoice();
2159
- const made = await post(`${API}/conversations`, { ...(opencode ? { opencode } : {}), title, ...(id ? { name: id } : {}), ...(group ? { group } : {}), tool: chosenTool, workOnDisk: newOnDisk(), ...(document.getElementById('newconv-chat')?.checked === false ? { chat: false } : {}), ...(memoryMb && memoryMb !== least ? { memoryMb } : {}), ...(cpus && cpus !== 1 ? { cpus } : {}), ...(diskGb && diskGb !== 8 ? { diskGb } : {}) });
2174
+ const made = await post(`${API}/conversations`, { ...(opencode ? { opencode } : {}), title, ...(id ? { name: id } : {}), ...(group ? { group } : {}), tool: chosenTool, workOnDisk: newShared() ? false : newOnDisk(), ...(newShared() ? { machine: $('newconv-machine').value.trim() } : {}), ...(document.getElementById('newconv-chat')?.checked === false ? { chat: false } : {}), ...(memoryMb && memoryMb !== least ? { memoryMb } : {}), ...(cpus && cpus !== 1 ? { cpus } : {}), ...(diskGb && diskGb !== 8 ? { diskGb } : {}) });
2160
2175
  $('newconv-name').value = ''; $('newconv-id').value = ''; $('newconv-id').placeholder = 'website-redesign'; $('newconv-group').value = '';
2161
- $('newconv-work').querySelector('[data-work="kept"]').click(); $('newconv-more').open = false; { const ch = document.getElementById('newconv-chat'); if (ch) ch.checked = true; }
2176
+ $('newconv-work').querySelector('[data-work="kept"]').click(); $('newconv-where').querySelector('[data-where="own"]').click(); $('newconv-machine').value = ''; $('newconv-more').open = false; { const ch = document.getElementById('newconv-chat'); if (ch) ch.checked = true; }
2162
2177
  await refresh();
2163
2178
  /* The new one is selected: the page gives way to it, with no step of it left behind. */
2164
2179
  select(made.name);
@@ -2574,6 +2589,15 @@
2574
2589
  catch (error) { show(error.message, 'Back to the terminal', enter); }
2575
2590
  }, () => { notice.hidden = true; focusTerminal(); });
2576
2591
  };
2592
+ /* In a shared machine (#221): its name and the others in it, said once -- stopping it stops them too. */
2593
+ const sharedIn = here?.sharedMachine;
2594
+ $('machine-shared').hidden = DEVICE || !sharedIn;
2595
+ if (sharedIn) {
2596
+ const others = conversations.filter((c) => c.sharedMachine === sharedIn && c.name !== current).map((c) => c.title ?? c.name);
2597
+ $('machine-shared').textContent = others.length
2598
+ ? uiSaid('set-mshared-with', 'Shared machine « {m} », with {others}. Stopping it stops them too.', { m: sharedIn, others: others.join(', ') })
2599
+ : uiSaid('set-mshared-alone', 'Shared machine « {m} », alone in it for now.', { m: sharedIn });
2600
+ }
2577
2601
  /* Its tool's memory, exported as one file, or put back from one (#351): the person's own act, from here. */
2578
2602
  $('carry-box').hidden = DEVICE || !here;
2579
2603
  $('carry-export').href = `${API}/conversations/${encodeURIComponent(current)}/export`;
package/web/index.html CHANGED
@@ -203,6 +203,8 @@
203
203
  <div class="curves-head"><b>Over time</b><div class="levels curves-span" role="group" aria-label="Over"><button type="button" data-span="1h" aria-pressed="true">1 h</button><button type="button" data-span="24h" aria-pressed="false">24 h</button><button type="button" data-span="7d" aria-pressed="false">7 days</button></div></div>
204
204
  <div class="curves-row"></div>
205
205
  </div>
206
+ <!-- IN A SHARED MACHINE (#221): which, and who else lives in it -- its stop or restart stops them too. -->
207
+ <p id="machine-shared" class="hint machine-shared" hidden></p>
206
208
  <p id="machine-restarted" class="hint" role="status" hidden></p>
207
209
  <div id="resume-box" hidden>
208
210
  <div class="set-row"><div class="set-what"><b>When its tool starts</b><small id="resume-hint">After a wake or restart</small></div><div class="set-control"><div class="levels" id="resume-on" role="group" aria-label="When its tool starts"><button type="button" data-on="true">Resume its last session</button><button type="button" data-on="false">Start fresh</button></div></div></div>
@@ -1432,7 +1434,16 @@
1432
1434
  </div>
1433
1435
  <small id="newconv-oc-raw" class="hint" hidden>Set it up yourself in its terminal.</small>
1434
1436
  </div>
1435
- <div class="nc-card">
1437
+ <!-- WHERE IT LIVES (#221): a machine of its own, or a shared one (lighter, for assistants). -->
1438
+ <div class="nc-card" id="newconv-where-card">
1439
+ <span class="sub-head">Where it lives</span>
1440
+ <div id="newconv-where" class="pick two" role="radiogroup" aria-label="Where it lives">
1441
+ <button type="button" role="radio" data-where="own" aria-checked="true"><b>Its own machine</b><small>All to itself</small></button>
1442
+ <button type="button" role="radio" data-where="shared" aria-checked="false"><b>A shared machine</b><small>Lighter. For assistants</small></button>
1443
+ </div>
1444
+ <div class="set-row" id="newconv-machine-row" hidden><div class="set-what"><label for="newconv-machine">Machine</label><small>An existing one, or a new name</small><span id="newconv-machine-error" class="err" role="alert" hidden></span></div><div class="set-control"><input id="newconv-machine" maxlength="32" list="machine-names" placeholder="assistants" spellcheck="false" autocapitalize="off" autocomplete="off"><datalist id="machine-names"></datalist></div></div>
1445
+ </div>
1446
+ <div class="nc-card" id="newconv-files-card">
1436
1447
  <span class="sub-head">Its files</span>
1437
1448
  <div id="newconv-work" class="pick two" role="radiogroup" aria-label="Its files">
1438
1449
  <button type="button" role="radio" data-work="kept" aria-checked="true"><b>Kept here</b><small>Seen in Files. Outlives the machine</small></button>