clavarium 0.2.214-next.1 → 0.2.215-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.214-next.1",
3
+ "version": "0.2.215-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.214-next.1",
9
+ "version": "0.2.215-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.214-next.1",
3
+ "version": "0.2.215-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.",
package/server/boxes.mjs CHANGED
@@ -699,7 +699,10 @@ export class Boxes {
699
699
  * POST /api/boxes/<id>/revoke
700
700
  * POST /api/boxes/<id>/volume {level 0-100}
701
701
  * POST /api/boxes/<id>/wifi-scan -> {networks}
702
- * POST /api/boxes/<id>/wifi-join {ssid, password}: the password goes to the box, and is kept nowhere here
702
+ * POST /api/boxes/<id>/wifi-join {ssid, password}: the password goes to the box, and is kept nowhere here;
703
+ * the box ADDS it to the networks it knows (8 at most) and goes to the strongest
704
+ * POST /api/boxes/<id>/wifi-known -> {networks, current}: the names it knows (never a password)
705
+ * POST /api/boxes/<id>/wifi-forget {ssid}: not the one it uses now
703
706
  * POST /api/boxes/<id>/alert {text?}
704
707
  * POST /api/boxes/<id>/reboot
705
708
  */
@@ -734,6 +737,8 @@ export async function handleBoxes(request, response, boxes, originOk, headers =
734
737
  case 'revoke': boxes.revoke(id); return send(200, { ok: true });
735
738
  case 'volume': return answered(await boxes.setVolume(id, body.level));
736
739
  case 'wifi-scan': { const r = await boxes.command(id, { t: 'wifi.scan' }); return send(200, { networks: Array.isArray(r.networks) ? r.networks : [] }); }
740
+ case 'wifi-known': { const r = await boxes.command(id, { t: 'wifi.list' }); return send(200, { networks: Array.isArray(r.networks) ? r.networks.map(String) : [], current: String(r.current ?? '') }); }
741
+ case 'wifi-forget': return answered(await boxes.command(id, { t: 'wifi.forget', ssid: String(body.ssid ?? '').slice(0, 32) }));
737
742
  case 'wifi-join': return answered(await boxes.command(id, { t: 'wifi.join', ssid: String(body.ssid ?? ''), password: String(body.password ?? '') }, 90_000));
738
743
  case 'alert': return answered(await boxes.command(id, { t: 'alert', text: String(body.text ?? '').slice(0, 300) }, 10 * 60_000));
739
744
  case 'reboot': return answered(await boxes.command(id, { t: 'reboot' }));
package/web/app.js CHANGED
@@ -8874,6 +8874,48 @@
8874
8874
  const volRow = el('label', 'box-volume'); volRow.append('Volume ', vol, volSaid);
8875
8875
  const acts = el('div', 'action-row'); acts.append(whereRow, place, volRow, rename, remove);
8876
8876
  card.append(head, acts);
8877
+ /* ITS WI-FI NETWORKS (01-11): the box knows several and goes to the strongest it hears; one is added
8878
+ here before it moves, from the networks it hears itself -- no phone, no button. */
8879
+ if (b.online) {
8880
+ const wifi = el('div', 'box-wifi');
8881
+ const known = el('div', 'box-wifi-known');
8882
+ const add = el('button', '', 'Add a Wi-Fi'); add.type = 'button';
8883
+ const paintKnown = async () => {
8884
+ known.replaceChildren(el('small', 'hint', 'Its Wi-Fi networks…'));
8885
+ const r = await post(`${API}/boxes/${b.id}/wifi-known`, {}).catch(() => null);
8886
+ known.replaceChildren();
8887
+ if (!r) { known.append(el('small', 'hint', 'Its networks cannot be read just now.')); return; }
8888
+ for (const ssid of r.networks) {
8889
+ const chip = el('span', 'box-wifi-net', ssid === r.current ? `${ssid} (now)` : ssid);
8890
+ if (ssid !== r.current) {
8891
+ const x = el('button', 'quiet', '×'); x.type = 'button'; x.setAttribute('aria-label', `Forget ${ssid}`);
8892
+ x.addEventListener('click', async () => { await post(`${API}/boxes/${b.id}/wifi-forget`, { ssid }).catch(() => {}); await paintKnown(); });
8893
+ chip.append(x);
8894
+ }
8895
+ known.append(chip);
8896
+ }
8897
+ };
8898
+ add.addEventListener('click', async () => {
8899
+ add.disabled = true; add.textContent = 'Listening for networks…';
8900
+ const r = await post(`${API}/boxes/${b.id}/wifi-scan`, {}).catch(() => ({ networks: [] }));
8901
+ add.disabled = false; add.textContent = 'Add a Wi-Fi';
8902
+ const pick = el('select'); pick.setAttribute('aria-label', 'Network');
8903
+ for (const n of r.networks ?? []) { const o = el('option', '', `${n.ssid}${n.secure ? '' : ' (open)'}`); o.value = n.ssid; pick.append(o); }
8904
+ const pass = el('input'); pass.type = 'password'; pass.placeholder = 'Password'; pass.autocomplete = 'off'; pass.setAttribute('aria-label', 'Password of the network');
8905
+ const join = el('button', 'primary', 'Add'); join.type = 'button';
8906
+ const said = el('small', 'hint', '');
8907
+ join.addEventListener('click', async () => {
8908
+ join.disabled = true; said.textContent = 'The box tries it (up to 20 s); it comes back on its network after.';
8909
+ try { await post(`${API}/boxes/${b.id}/wifi-join`, { ssid: pick.value, password: pass.value }); said.textContent = `Added: ${pick.value}.`; form.remove(); await paintKnown(); }
8910
+ catch (error) { said.textContent = `Not joined: ${error.message}`; join.disabled = false; }
8911
+ });
8912
+ const form = el('div', 'action-row box-wifi-add'); form.append(pick, pass, join, said);
8913
+ wifi.append(form); focusField(pass);
8914
+ });
8915
+ wifi.append(el('small', 'hint', 'Wi-Fi it knows (it goes to the strongest): '), known, add);
8916
+ card.append(wifi);
8917
+ void paintKnown();
8918
+ }
8877
8919
  rows.append(card);
8878
8920
  }
8879
8921
  }
package/web/style.css CHANGED
@@ -2075,3 +2075,9 @@ body.as-dragging #assets-rows .as-row { touch-action: none; }
2075
2075
  .box-qr { width: 180px; max-width: 100%; background: #fff; border-radius: 8px; padding: 6px; }
2076
2076
  .box-qr svg { display: block; width: 100%; height: auto; }
2077
2077
  .button-link { display: inline-block; padding: 8px 12px; border-radius: 7px; background: var(--accent, #d4a64a); color: #111; font-weight: 600; text-decoration: none; }
2078
+
2079
+ /* A voice box's Wi-Fi networks: names as small chips, the one it uses marked. */
2080
+ .box-wifi { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
2081
+ .box-wifi-known { display: flex; flex-wrap: wrap; gap: 6px; }
2082
+ .box-wifi-net { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--line, #ccc); border-radius: 999px; font-size: 0.85em; }
2083
+ .box-wifi-add { width: 100%; }