clavarium 0.2.284-next.1 → 0.2.286-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,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.284-next.1",
3
+ "version": "0.2.286-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.284-next.1",
9
+ "version": "0.2.286-next.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.59-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
- "clavarium-parley": "0.17.50-next.1",
16
+ "clavarium-parley": "0.17.53-next.1",
17
17
  "clavarium-tether": "0.1.0-next.49",
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.50-next.1",
791
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.50-next.1.tgz",
792
- "integrity": "sha512-0IcZLJ4uWqY393Zi7XEkIMzDHZsyCMw3ti9voB6nIuqzDBtsUf9Dy/wMT7y5kFBnU9cRZZqNMhoZNexOVnccBQ==",
790
+ "version": "0.17.53-next.1",
791
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.53-next.1.tgz",
792
+ "integrity": "sha512-hCjOIo7apQnYy5BQKro4fLocw/i50feWBr6BcO9i1eg+YVijKR2adgS0ZNxoKAkuIn9bAZlDNzxQUBWFaaDcng==",
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.284-next.1",
3
+ "version": "0.2.286-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.",
@@ -46,7 +46,7 @@
46
46
  "@xterm/xterm": "^6.0.0",
47
47
  "clavarium-binder": "0.1.59-next.1",
48
48
  "clavarium-docket": "0.1.2-next.2",
49
- "clavarium-parley": "0.17.50-next.1",
49
+ "clavarium-parley": "0.17.53-next.1",
50
50
  "clavarium-tether": "0.1.0-next.49",
51
51
  "mammoth": "1.13.0",
52
52
  "mermaid": "11.17.2",
package/server/api.mjs CHANGED
@@ -89,6 +89,12 @@
89
89
  * POST /api/asset-groups/place {asset, group}: put an asset in a group (group null to take it out)
90
90
  * POST /api/asset-groups/<id>/rename {label}
91
91
  * POST /api/asset-groups/<id>/remove
92
+ * GET /api/rooms the rooms (#268): [{id, name, host, members: [{id, kind, name, ref, host?}]}]
93
+ * POST /api/rooms {name, conversations: [names], boxes: [ids], host?}: a new room
94
+ * POST /api/rooms/<id> {name?, host?, add?: {conversations, boxes}, remove?: [member ids]}
95
+ * POST /api/rooms/<id>/remove the room and its thread
96
+ * GET /api/rooms/<id>/talk?last= its thread, with the room: {room, messages, ...}
97
+ * POST /api/rooms/<id>/talk {text, to?: [AI member ids]}: said in it; to its host, or to the AIs named
92
98
  * GET /api/conversations/<name>/health-react POST the same {on?, message?, command?}: what it does when its machine is short
93
99
  * GET /api/machines/places GET /api/machines/moving POST /api/machines/move {to}: all the machines to another disk
94
100
  * POST /api/machines/forget-old: the copy a move left behind, removed
@@ -165,7 +171,7 @@ function readBody(request, max = BODY_MAX) {
165
171
  /* This run of the server: a page's count of binder changes is of one run, and starts again with the next. */
166
172
  const BOOT = Math.random().toString(36).slice(2, 10);
167
173
 
168
- export async function handleApi(request, response, conversations, headers, resources, originOk = sameOrigin, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups, catalogue) {
174
+ export async function handleApi(request, response, conversations, headers, resources, originOk = sameOrigin, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups, catalogue, rooms) {
169
175
  const { pathname } = new URL(request.url ?? '/', 'http://local');
170
176
  if (!pathname.startsWith('/api/')) return false;
171
177
  let send = (status, body) => {
@@ -265,6 +271,10 @@ export async function handleApi(request, response, conversations, headers, resou
265
271
  holds. Distinct from /api/groups/* above, which are the conversation
266
272
  list's folders. */
267
273
  if (pathname === '/api/asset-groups' && groups) return send(200, groups.list()), true;
274
+ /* Rooms (#268, rooms.mjs): a thread shared by several AIs, the person and boxes. */
275
+ if (pathname === '/api/rooms' && rooms) return send(200, rooms.list()), true;
276
+ const roomTalk = /^\/api\/rooms\/([0-9a-f-]{36})\/talk$/.exec(pathname);
277
+ if (roomTalk && rooms) { const last = Number(query.get('last')); return send(200, rooms.read(roomTalk[1], Number.isInteger(last) && last > 0 ? { last } : undefined)), true; }
268
278
  if (pathname === '/api/mailboxes' && mailboxes) return send(200, mailboxes.list()), true;
269
279
  /* Which providers and kinds an account can be connected for here. */
270
280
  if (pathname === '/api/accounts' && accounts) return send(200, { supported: accounts.supported() }), true;
@@ -402,6 +412,13 @@ export async function handleApi(request, response, conversations, headers, resou
402
412
  const body = await readBody(request, pathname === '/api/setup/preview' || pathname === '/api/setup/import' ? SETUP_BODY_MAX : BODY_MAX);
403
413
  /* What was done, once it was done: said in What happened (events.mjs), for those worth saying. */
404
414
  if (events) { const answer = send; send = (status, out) => { if (status < 300) { try { events.fromRequest(pathname, body, identity, out); } catch { /* never in the way */ } } answer(status, out); }; }
415
+ if (rooms && pathname.startsWith('/api/rooms')) {
416
+ if (pathname === '/api/rooms') return send(201, rooms.create(body ?? {})), true;
417
+ const r = /^\/api\/rooms\/([0-9a-f-]{36})(\/remove|\/talk)?$/.exec(pathname);
418
+ if (r && !r[2]) return send(200, rooms.change(r[1], body ?? {})), true;
419
+ if (r && r[2] === '/remove') { rooms.remove(r[1]); return send(200, { removed: r[1] }), true; }
420
+ if (r && r[2] === '/talk') return send(201, await rooms.say(r[1], body?.text, { to: body?.to })), true;
421
+ }
405
422
  if (pathname === '/api/conversations') {
406
423
  await conversations.admit?.(body);
407
424
  const made = conversations.create(body);
package/server/main.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { Rooms } from './rooms.mjs';
1
2
  import { Catalogue } from './catalog.mjs';
2
3
  /* The server. Loopback only: what faces the internet is the edge in front of it.
3
4
  *
@@ -173,7 +174,7 @@ const withoutTmux = (env) => Object.fromEntries(Object.entries(env).filter(([key
173
174
 
174
175
  const REFUSED = 'This Clavarium belongs to someone else: your account is not one of its operators.\n';
175
176
 
176
- function serve(port, conversations, resources, { gate = () => 'local', originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, repair, capacity, updates, instance = new Instance(), certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue } = {}) {
177
+ function serve(port, conversations, resources, { gate = () => 'local', originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, repair, capacity, updates, instance = new Instance(), certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue, rooms } = {}) {
177
178
  /* Its manifest carries the name of this Clavarium, or the one a device chose (instance.mjs). */
178
179
  const sendManifest = (response, url) => response.writeHead(200, { ...HEADERS, 'content-type': 'application/manifest+json' }).end(instance.manifest(new URL(url ?? '/', 'http://local').searchParams.get('name') ?? undefined));
179
180
  const sendFile = async (response, file) => {
@@ -234,7 +235,7 @@ function serve(port, conversations, resources, { gate = () => 'local', originOk,
234
235
  return;
235
236
  }
236
237
  if (boxes && pathname.startsWith('/api/boxes') && await handleBoxes(request, response, boxes, originOk, HEADERS, (text) => QRCode.toString(text, { type: 'svg', margin: 1, errorCorrectionLevel: 'M' }))) return;
237
- if (conversations && await handleApi(request, response, conversations, HEADERS, resources, originOk, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups, catalogue)) return;
238
+ if (conversations && await handleApi(request, response, conversations, HEADERS, resources, originOk, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups, catalogue, rooms)) return;
238
239
  if (pathname === '/manifest.webmanifest' && request.method === 'GET') { sendManifest(response, request.url); return; }
239
240
  const file = FILES[pathname];
240
241
  if (!file || (request.method !== 'GET' && request.method !== 'HEAD')) {
@@ -483,8 +484,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
483
484
  const gitTimer = gitKeeper.start(gitEveryMs);
484
485
  /* A conversation with a tool on a screen that is not its terminal: see talk.mjs. */
485
486
  /* Voice boxes: what the tool says in their conversation is read aloud (boxes.mjs). */
486
- let boxes;
487
- const talk = new Talk({ spoke: (name, text, to, how) => { void boxes?.agentSaid(name, text, to, how); }, store: talkStore, words: new Store(`${dataDir}/talk-words.json`), keptDir: `${dataDir}/talk-kept`, vms, conversations: all, resources: folders, toolbox, warm: (name) => bridge?.warm(name), ...(talkEveryMs ? { listenEveryMs: talkEveryMs } : {}),
487
+ let boxes; let rooms;
488
+ const talk = new Talk({ spoke: (name, text, to, how) => { void boxes?.agentSaid(name, text, to, how); }, inRoom: (name, entry, kind) => rooms?.answered(name, entry, kind), store: talkStore, words: new Store(`${dataDir}/talk-words.json`), keptDir: `${dataDir}/talk-kept`, vms, conversations: all, resources: folders, toolbox, warm: (name) => bridge?.warm(name), ...(talkEveryMs ? { listenEveryMs: talkEveryMs } : {}),
488
489
  ...(rereadAfterMs === undefined ? {} : { rereadAfterMs }),
489
490
  /* A line typed down the terminal already open when there is one, and
490
491
  what is already known of a machine used instead of asking (talk.mjs). */
@@ -594,7 +595,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
594
595
  const text = `Its tool was stopped: the machine ran out of memory${size}. Give it more in Settings → Machine → Memory, or start it fresh.`;
595
596
  events.add({ kind: 'machine', text: `Machine of ${name}: its tool was stopped for lack of memory${size}`, conversation: name });
596
597
  void alerts.tell({ title: `${name}: its tool ran out of memory`, body: text, url: `/?c=${encodeURIComponent(name)}&open=settings` });
597
- try { talk.event(name, { kind: 'machine-problem', text, tone: 'warn', topic: 'Machine' }); } catch { /* its chat may be off */ }
598
+ try { talk.event(name, { kind: 'machine-problem', text, tone: 'warn', topic: 'Machine', brief: 'Out of memory', actions: ['memory', 'restart', 'terminal'] }); } catch { /* its chat may be off */ }
598
599
  };
599
600
  const stopWatch = capacity.start();
600
601
  /* The curves of the resources (history.mjs): one look a minute, from what the server knows already. */
@@ -641,7 +642,12 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
641
642
  changed: () => { for (const c of all.list()) talk.speakers(c.name, boxes.speakersOf(c.name)); try { syncTargets(tethers.store(), boxes.all()); } catch (error) { console.error(`voice boxes in Tether: ${error.message}`); } },
642
643
  speak: (text) => speech.speak(text),
643
644
  log: (line) => events.add({ kind: 'server', text: line }) });
644
- const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
645
+ /* Rooms (#268): a thread shared by several AIs, the person and boxes (rooms.mjs). */
646
+ rooms = new Rooms({ file: new JsonFile(`${dataDir}/rooms.json`, []), dir: `${dataDir}/rooms`,
647
+ say: (name, text, extra) => talk.say(name, text, undefined, undefined, undefined, extra),
648
+ rooms: (name, list) => talk.rooms(name, list), conversations: () => all.list(), boxes: () => boxes.all() });
649
+ rooms.refresh();
650
+ const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue, rooms, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
645
651
  server.on('close', () => { closing = true; stopBinders(); stopTethers(); clearInterval(historyTimer); clearInterval(secretsTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(restartTimer); clearInterval(expiryTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
646
652
  let closing = false;
647
653
  boxes.attach(server, WebSocketServer);
@@ -0,0 +1,188 @@
1
+ /* ROOMS (#268, #279): a thread shared by several conversations (AIs), the person and voice boxes.
2
+ *
3
+ * A room is kept here, never in a machine: its thread is a Parley folder of this server's (rooms/<id>/),
4
+ * written by this server alone -- the person's side (the person, a box) and, signed, each AI's words. No
5
+ * AI can write there: what it answers comes from its own folder, and is signed by WHERE it came from
6
+ * (which conversation), never by what it says of itself (03-11).
7
+ *
8
+ * members each with an id of its own (a uuid), whatever it is: the person, an AI (a conversation),
9
+ * a box. The name is only shown; the kind picks the shape of its chip.
10
+ * the host one AI of the room: what is said with nobody named goes to it alone (it answers, or
11
+ * hands it on -- #280).
12
+ * to an AI a person's message goes to the host; the host's (and any AI's) answer comes back here
13
+ * when it says so (parley tell --room), and only to a room it is a member of.
14
+ *
15
+ * Each conversation of a room is told which rooms it is in, and who is there (Parley's rooms.json).
16
+ */
17
+ import { mkdirSync, rmSync } from 'node:fs';
18
+ import { randomUUID } from 'node:crypto';
19
+ import { Parley } from 'clavarium-parley/host';
20
+ import { Refusal } from './conversations.mjs';
21
+
22
+ export const ROOM_NAME_MAX = 60;
23
+ export const ROOMS_MAX = 20;
24
+ export const MEMBERS_MAX = 40;
25
+ /* Hand-overs between AIs after the person (or a box) last spoke in a room: a few, never a loop. */
26
+ export const HOPS_MAX = 8;
27
+ const KINDS = ['person', 'ai', 'box'];
28
+ const nameOf = (v) => String(v ?? '').replace(/\s+/g, ' ').trim().slice(0, ROOM_NAME_MAX);
29
+
30
+ export class Rooms {
31
+ #file; #dir; #say; #rooms; #conversations; #boxes; #now; #hops = new Map();
32
+ /* file: a JsonFile of the rooms; dir: where their threads are; say(name, text, extra): a message written in a
33
+ conversation's own chat (talk.say); rooms(name, list): what a conversation is told of its rooms (talk.rooms);
34
+ conversations(): the conversations there are; boxes(): the voice boxes there are. */
35
+ constructor({ file, dir, say, rooms = () => {}, conversations = () => [], boxes = () => [], now = () => new Date() }) {
36
+ this.#file = file; this.#dir = dir; this.#say = say; this.#rooms = rooms; this.#conversations = conversations; this.#boxes = boxes; this.#now = now;
37
+ }
38
+ #all() { const v = this.#file.get(); return Array.isArray(v) ? v : []; }
39
+ #save(list) { this.#file.set(list); this.#tellConversations(list); }
40
+ #thread(id) { mkdirSync(`${this.#dir}/${id}`, { recursive: true }); return new Parley(`${this.#dir}/${id}`, { room: true, now: this.#now }); }
41
+ #find(id) { const r = this.#all().find((x) => x.id === id); if (!r) throw new Refusal(404, 'No such room.'); return r; }
42
+
43
+ /* Its members as they are now: names of the moment (a conversation renamed, a box renamed). */
44
+ #shown(room) {
45
+ const boxes = new Map(this.#boxes().map((b) => [b.id, b]));
46
+ /* An AI is named as its chat names it (the name the owner gave it in its chat settings), else its title, else its name. */
47
+ const convs = new Map(this.#conversations().map((c) => [c.name, c.chatName || c.title || c.name]));
48
+ return room.members.filter((m) => (m.kind === 'ai' ? convs.has(m.ref) : m.kind === 'box' ? boxes.has(m.ref) : true))
49
+ .map((m) => ({ id: m.id, kind: m.kind, name: m.kind === 'box' ? (boxes.get(m.ref)?.name ?? m.name) : m.kind === 'ai' ? convs.get(m.ref) : m.name, ref: m.ref, ...(m.id === room.host ? { host: true } : {}) }));
50
+ }
51
+ list() { return this.#all().map((r) => ({ id: r.id, name: r.name, host: r.host, members: this.#shown(r), at: r.at })); }
52
+ get(id) { const r = this.#find(id); return { id: r.id, name: r.name, host: r.host, members: this.#shown(r), at: r.at }; }
53
+
54
+ /* A new room: its name, its AIs (conversation names), its boxes (ids), and which AI is the host (the first by default). */
55
+ create({ name, conversations = [], boxes = [], host } = {}) {
56
+ const n = nameOf(name);
57
+ if (!n) throw new Refusal(400, 'Give the room a name.');
58
+ const list = this.#all();
59
+ if (list.length >= ROOMS_MAX) throw new Refusal(409, `${ROOMS_MAX} rooms at most.`);
60
+ if (list.some((r) => r.name.toLowerCase() === n.toLowerCase())) throw new Refusal(409, 'A room has that name already.');
61
+ const room = { id: randomUUID(), name: n, at: this.#now().toISOString(), members: [{ id: randomUUID(), kind: 'person', ref: 'owner', name: 'Toi' }] };
62
+ this.#add(room, conversations, boxes);
63
+ const ais = room.members.filter((m) => m.kind === 'ai');
64
+ if (!ais.length) throw new Refusal(400, 'A room has one AI at least: its host.');
65
+ room.host = (ais.find((m) => m.ref === host) ?? ais[0]).id;
66
+ this.#save([...list, room]);
67
+ this.#thread(room.id);
68
+ return this.get(room.id);
69
+ }
70
+ #add(room, conversations, boxes) {
71
+ const known = new Set(this.#conversations().map((c) => c.name));
72
+ const knownBoxes = new Map(this.#boxes().map((b) => [b.id, b]));
73
+ for (const c of Array.isArray(conversations) ? conversations : []) {
74
+ if (!known.has(c)) throw new Refusal(400, `No conversation is called ${String(c).slice(0, 40)}.`);
75
+ if (!room.members.some((m) => m.kind === 'ai' && m.ref === c)) room.members.push({ id: randomUUID(), kind: 'ai', ref: c, name: c });
76
+ }
77
+ for (const b of Array.isArray(boxes) ? boxes : []) {
78
+ const box = knownBoxes.get(b);
79
+ if (!box) throw new Refusal(400, 'No such voice box.');
80
+ if (!room.members.some((m) => m.kind === 'box' && m.ref === b)) room.members.push({ id: randomUUID(), kind: 'box', ref: b, name: box.name });
81
+ }
82
+ /* One name, one member (03-11): who is who is never in doubt, in the thread or said aloud. */
83
+ const names = this.#shown({ ...room, host: null }).map((m) => m.name.toLowerCase());
84
+ if (new Set(names).size !== names.length) throw new Refusal(409, 'Two members of a room cannot have the same name: rename one first.');
85
+ if (room.members.length > MEMBERS_MAX) throw new Refusal(409, `${MEMBERS_MAX} members at most.`);
86
+ }
87
+ /* Its name, its host, members added or taken away. */
88
+ change(id, { name, host, add = {}, remove = [] } = {}) {
89
+ const list = this.#all(); const room = list.find((r) => r.id === id);
90
+ if (!room) throw new Refusal(404, 'No such room.');
91
+ if (name !== undefined) {
92
+ const n = nameOf(name); if (!n) throw new Refusal(400, 'Give the room a name.');
93
+ if (list.some((r) => r.id !== id && r.name.toLowerCase() === n.toLowerCase())) throw new Refusal(409, 'A room has that name already.');
94
+ room.name = n;
95
+ }
96
+ room.members = room.members.filter((m) => m.kind === 'person' || !(Array.isArray(remove) ? remove : []).includes(m.id));
97
+ this.#add(room, add.conversations ?? [], add.boxes ?? []);
98
+ const ais = room.members.filter((m) => m.kind === 'ai');
99
+ if (!ais.length) throw new Refusal(400, 'A room keeps one AI at least: its host.');
100
+ if (host !== undefined) { if (!ais.some((m) => m.id === host)) throw new Refusal(400, 'The host is one of its AIs.'); room.host = host; }
101
+ if (!ais.some((m) => m.id === room.host)) room.host = ais[0].id;
102
+ this.#save(list);
103
+ return this.get(id);
104
+ }
105
+ remove(id) { this.#find(id); this.#save(this.#all().filter((r) => r.id !== id)); rmSync(`${this.#dir}/${id}`, { recursive: true, force: true }); }
106
+
107
+ /* ITS THREAD, as a screen reads it (Parley's read, the members' names of the moment). */
108
+ read(id, options) {
109
+ const room = this.#find(id); const t = this.#thread(room.id); const members = this.#shown(room);
110
+ t.setSpeakers(members.map((m) => ({ id: m.id, name: m.name, kind: m.kind })));
111
+ const read = t.read(options);
112
+ /* A member named in a text (@{id}): its name of the moment, on the screen. */
113
+ const named = (text) => String(text ?? '').replace(/@\{([0-9a-f-]{36})\}/g, (whole, mid) => { const m = members.find((x) => x.id === mid); return m ? `@${m.name}` : whole; });
114
+ return { room: this.get(id), ...read, messages: (read.messages ?? []).map((m) => (typeof m.text === 'string' && m.text.includes('@{') ? { ...m, text: named(m.text) } : m)) };
115
+ }
116
+
117
+ /* SOMEONE OF THE PERSON'S SIDE SPEAKS (the person here, a box): kept in the room, given to the host -- or to the
118
+ AIs named (to: their member ids). */
119
+ async say(id, text, { by, to } = {}) {
120
+ const room = this.#find(id); const members = this.#shown(room);
121
+ const who = by ? members.find((m) => m.id === by && m.kind !== 'ai') : members.find((m) => m.kind === 'person');
122
+ if (!who) throw new Refusal(400, 'Not a member of this room.');
123
+ const t = this.#thread(room.id);
124
+ this.#hops.set(room.id, 0);
125
+ /* The owner is the room's own side (no name over their words, as in any chat); anyone else is named. */
126
+ const now = t.say(text, undefined, [], who.ref === 'owner' ? {} : { by: { id: who.id, name: who.name, kind: who.kind } });
127
+ const said = now.messages.at(-1);
128
+ const named = (Array.isArray(to) ? to : []).map((x) => members.find((m) => m.id === x && m.kind === 'ai')).filter(Boolean);
129
+ const host = members.find((m) => m.id === room.host);
130
+ for (const ai of named.length ? named : host ? [host] : []) {
131
+ await this.#say(ai.ref, said.text, { by: { id: who.id, name: who.name, kind: who.kind }, room: { id: room.id, name: room.name, message: said.id } });
132
+ }
133
+ return this.read(id);
134
+ }
135
+
136
+ /* AN AI ANSWERS IN A ROOM (what its own folder says, entry.room): only to a room it is in; signed by where it
137
+ came from; the message it answers found by its id or its first characters. */
138
+ answered(conversation, entry, kind = 'say') {
139
+ const room = this.#all().find((r) => r.id === entry?.room);
140
+ if (!room) return null;
141
+ const members = this.#shown(room);
142
+ const me = members.find((m) => m.kind === 'ai' && m.ref === conversation);
143
+ if (!me) return null;
144
+ const t = this.#thread(room.id);
145
+ const all = () => t.read({ all: true }).messages;
146
+ const find = (id) => (typeof id === 'string' && id.length >= 8 ? all().find((m) => m.id.startsWith(id)) : undefined);
147
+ const re = find(entry.re)?.id;
148
+ const ids = new Set(members.map((m) => m.id));
149
+ const to = Array.isArray(entry.to) ? entry.to.filter((x) => ids.has(x) && x !== me.id) : [];
150
+ /* The other AIs it is sent to (#280): they get it in their own chat, as said in the room -- never beyond a few
151
+ hand-overs after the person last spoke (no two AIs talking for ever). */
152
+ const ais = to.map((x) => members.find((m) => m.id === x && m.kind === 'ai')).filter(Boolean);
153
+ const handOver = (ai, text, from, message) => {
154
+ const n = (this.#hops.get(room.id) ?? 0) + 1;
155
+ if (n > HOPS_MAX) return false;
156
+ this.#hops.set(room.id, n);
157
+ void this.#say(ai.ref, text, { by: from, room: { id: room.id, name: room.name, message } }).catch(() => {});
158
+ return true;
159
+ };
160
+ /* Handed on as it is: the message itself, by who said it; the room's thread keeps no copy. */
161
+ const forwarded = find(entry.forward);
162
+ if (forwarded) {
163
+ const from = forwarded.by ? { id: forwarded.by.id, name: forwarded.by.name, kind: forwarded.by.kind ?? 'person' } : { id: members.find((m) => m.kind === 'person')?.id ?? 'owner', name: members.find((m) => m.kind === 'person')?.name ?? 'Owner', kind: 'person' };
164
+ for (const ai of ais) handOver(ai, forwarded.text, from, forwarded.id);
165
+ if (!String(entry.text ?? '').trim()) return forwarded.id;
166
+ }
167
+ if (!String(entry.text ?? '').trim()) return null;
168
+ /* @Name of a member, exactly: kept as its id (the screen says its name of the moment). */
169
+ const text = String(entry.text).replace(/@([^\s@{][^@\n]{0,40}?)(?=[\s,.;:!?)]|$)/g, (whole, name) => { const m = members.find((x) => x.name.toLowerCase() === name.toLowerCase()); return m ? `@{${m.id}}` : whole; });
170
+ const id = t.relay({ text, by: { id: me.id, name: me.name, kind: 'ai' }, to, re, kind: kind === 'doing' ? 'doing' : 'say' });
171
+ if (!forwarded && kind !== 'doing') for (const ai of ais) handOver(ai, text, { id: me.id, name: me.name, kind: 'ai' }, id);
172
+ return id;
173
+ }
174
+
175
+ /* Each conversation told the rooms it is in, and who is there. */
176
+ #tellConversations(list) {
177
+ const shown = list.map((r) => ({ ...r, members: this.#shown(r) }));
178
+ for (const c of this.#conversations()) {
179
+ const mine = shown.filter((r) => r.members.some((m) => m.kind === 'ai' && m.ref === c.name))
180
+ .map((r) => ({ id: r.id, name: r.name, members: r.members.map((m) => ({ id: m.id, name: m.name, kind: m.kind })) }));
181
+ try { this.#rooms(c.name, mine); } catch { /* its folder is not there yet */ }
182
+ }
183
+ }
184
+ refresh() { this.#tellConversations(this.#all()); }
185
+ /* A conversation renamed: its member follows it. */
186
+ conversationRenamed(from, to) { const list = this.#all(); let moved = false; for (const r of list) for (const m of r.members) if (m.kind === 'ai' && m.ref === from) { m.ref = to; m.name = to; moved = true; } if (moved) this.#save(list); }
187
+ }
188
+ export { KINDS };
package/server/talk.mjs CHANGED
@@ -191,7 +191,7 @@ export const windowOf = (choice) => { const [kind, n] = String(choice).split(':'
191
191
  /* What the page may ask for: a part of the thread (Parley's read(options)), its own cursor for "since". */
192
192
  const PART = /^[A-Za-z0-9._~-]{1,200}$/;
193
193
  export class Talk {
194
- #store; #words; #vms; #conversations; #resources; #toolbox; #warm; #alert; #spoke; #listening = new Map(); #every; #now;
194
+ #store; #words; #vms; #conversations; #resources; #toolbox; #warm; #alert; #spoke; #inRoom; #listening = new Map(); #every; #now;
195
195
  #typedAt = new Map(); #nextTry = new Map(); #trying = new Map(); #timer; #lastLang = 'en'; #rereadAfter;
196
196
  #terminal; #health; #ranAt = new Map(); #kept; #screen; #dropSecret;
197
197
 
@@ -203,9 +203,9 @@ export class Talk {
203
203
  /* `keptDir`: where each conversation's thread is kept (its own folder),
204
204
  in this server's data -- never in the work folder, which its machine
205
205
  writes. Without it, the bridge folder is all there is. */
206
- constructor({ store, words, vms, conversations, resources, toolbox = null, warm = async () => {}, alert = () => {}, spoke = () => {}, listenEveryMs = 2000, now = () => Date.now(), rereadAfterMs = REREAD_AFTER_MS, terminal = null, health = null, keptDir = null, screen = null, dropSecret = null }) {
206
+ constructor({ store, words, vms, conversations, resources, toolbox = null, warm = async () => {}, alert = () => {}, spoke = () => {}, inRoom = () => {}, listenEveryMs = 2000, now = () => Date.now(), rereadAfterMs = REREAD_AFTER_MS, terminal = null, health = null, keptDir = null, screen = null, dropSecret = null }) {
207
207
  this.#terminal = terminal; this.#health = health; this.#kept = keptDir; this.#screen = screen; this.#dropSecret = dropSecret;
208
- this.#store = store; this.#words = words; this.#vms = vms; this.#conversations = conversations; this.#resources = resources; this.#toolbox = toolbox; this.#warm = warm; this.#alert = alert; this.#spoke = spoke; this.#every = listenEveryMs; this.#now = now; this.#rereadAfter = rereadAfterMs;
208
+ this.#store = store; this.#words = words; this.#vms = vms; this.#conversations = conversations; this.#resources = resources; this.#toolbox = toolbox; this.#warm = warm; this.#alert = alert; this.#spoke = spoke; this.#inRoom = inRoom; this.#every = listenEveryMs; this.#now = now; this.#rereadAfter = rereadAfterMs;
209
209
  for (const s of store.all()) if (s.on === true) this.#listen(s.name);
210
210
  this.#timer = setInterval(() => { void this.#tick(); }, Math.min(listenEveryMs, 1000));
211
211
  this.#timer.unref?.();
@@ -292,6 +292,8 @@ export class Talk {
292
292
  if (event.type === 'person-reacted') { reacted(event); return; }
293
293
  if (event.type === 'person-wrote') { this.#want(name); return; }
294
294
  /* What the tool says or asks: a voice box of this conversation may read it aloud (boxes.mjs). */
295
+ /* Answered in a room it is in (#268): the room takes it, signed by where it came from (rooms.mjs). */
296
+ if (['agent-said', 'agent-asked', 'agent-doing'].includes(event.type) && typeof event.message?.room === 'string') { try { this.#inRoom(name, event.message, event.type === 'agent-doing' ? 'doing' : 'say'); } catch { /* the room's */ } return; }
295
297
  if (event.type === 'agent-said' || event.type === 'agent-asked') this.#spoke(name, event.message?.text ?? '', Array.isArray(event.message?.to) ? event.message.to : null, { asked: event.type === 'agent-asked' });
296
298
  /* What it is doing: said by a box that was just spoken to, so nobody waits in silence. */
297
299
  if (event.type === 'agent-doing') this.#spoke(name, event.message?.text ?? '', Array.isArray(event.message?.to) ? event.message.to : null, { doing: true });
@@ -458,6 +460,8 @@ export class Talk {
458
460
 
459
461
  /* The voice boxes of a conversation, as Parley names them to its agent and its screen (#215). */
460
462
  speakers(name, list) { try { this.#parley(name).setSpeakers(list); } catch { /* its folder is not there yet */ } }
463
+ /* The rooms it is in, and who is there (#268): told to its agent, which answers there by their ids. */
464
+ rooms(name, list) { try { this.#parley(name).setRooms(list); } catch { /* its folder is not there yet */ } }
461
465
 
462
466
  async say(name, text, answers, files, via, extra) {
463
467
  if (!this.of(name).on) throw new Refusal(409, 'Talking through the app is not turned on for this conversation.');
@@ -480,7 +484,7 @@ export class Talk {
480
484
  never lose a message: on any trouble the text is sent as it came. */
481
485
  let said = text ?? '';
482
486
  if (this.#screen && said) { try { said = await this.#screen(name, said); } catch { said = text ?? ''; } }
483
- try { this.#parley(name).say(said, answers, attached, { via: via === 'voice' ? 'voice' : undefined, ...(extra && typeof extra === 'object' ? { picked: extra.picked, replies: extra.replies, about: extra.about, by: extra.by } : {}) }); } catch (error) { if (error instanceof RangeError) throw new Refusal(400, error.message); throw error; }
487
+ try { this.#parley(name).say(said, answers, attached, { via: via === 'voice' ? 'voice' : undefined, ...(extra && typeof extra === 'object' ? { picked: extra.picked, replies: extra.replies, about: extra.about, by: extra.by, room: extra.room } : {}) }); } catch (error) { if (error instanceof RangeError) throw new Refusal(400, error.message); throw error; }
484
488
  const told = await this.#wake(name);
485
489
  return { ...this.of(name), told };
486
490
  }
@@ -600,7 +604,7 @@ export class Talk {
600
604
  const gone = record.state === 'Running' ? [...before].filter((k) => !keys.includes(k)) : [];
601
605
  if (gone.length) {
602
606
  const said = [...new Set(gone.map((k) => (/^disk:/.test(k) ? 'Its disk has room again.' : k === 'memory-low' ? 'Its memory is no longer short.' : /^oom:/.test(k) ? '' : 'What was wrong with its machine is gone.')).filter(Boolean))];
603
- if (said.length) this.event(name, { kind: 'machine-ok', text: said.join(' '), topic: 'Machine' });
607
+ if (said.length) this.event(name, { kind: 'machine-ok', text: said.join(' '), topic: 'Machine', brief: 'Fixed' });
604
608
  }
605
609
  if (fresh.length === 0) return;
606
610
  this.event(name, {
@@ -608,6 +612,8 @@ export class Talk {
608
612
  text: fresh.map((p) => p.text).join(' '),
609
613
  tone: fresh.some((p) => p.level === 'bad') ? 'bad' : 'warn',
610
614
  topic: 'Machine',
615
+ /* Its name on the one line a problem is in the simple view (Parley, 03-11). */
616
+ brief: fresh.some((p) => p.kind === 'memory' || /^oom:|^memory/.test(p.key ?? '')) ? 'Out of memory' : fresh.every((p) => p.kind === 'disk') ? 'Disk almost full' : 'Machine problem',
611
617
  /* What can be done: a disk short of room is looked at (what takes it) or made larger --
612
618
  a restart frees nothing; otherwise more memory where memory is short, a restart, its terminal. */
613
619
  actions: [...(fresh.every((p) => p.kind === 'disk') ? ['room', 'disk'] : [...(fresh.some((p) => p.kind === 'memory') ? ['memory'] : []), 'restart', 'terminal']), 'seen'],
package/web/app.js CHANGED
@@ -5058,16 +5058,88 @@
5058
5058
  return card;
5059
5059
  }
5060
5060
  const cardAgo = (at) => { const s = Math.max(0, (Date.now() - Date.parse(at)) / 1000); return s < 90 ? 'Just now' : s < 5400 ? `${Math.round(s / 60)} min ago` : s < 129600 ? `${Math.round(s / 3600)} h ago` : `${Math.round(s / 86400)} days ago`; };
5061
- function paintDeck() {
5061
+ /* ---------- ROOMS (#268): one thread for several AIs, the person and boxes ---------- */
5062
+ let rooms = [];
5063
+ const loadRooms = async () => { try { const r = await fetch(`${API}/rooms`); rooms = r.ok ? await r.json() : []; } catch { rooms = []; } return rooms; };
5064
+ const huePick = (text) => { let h = 0; for (const ch of String(text)) h = (h * 31 + ch.codePointAt(0)) >>> 0; return h % 360; };
5065
+ /* Its members as small chips, each by its shape: a person round, an AI a rounded square, a box an outline. */
5066
+ const memberChips = (members, max = 7) => {
5067
+ const stack = el('span', 'salon-stack');
5068
+ for (const m of members.slice(0, max)) { const i = el('i', `salon-chip salon-chip-${m.kind}`, m.kind === 'box' ? '' : (m.name.trim()[0] ?? '?').toUpperCase()); if (m.kind !== 'box') i.style.setProperty('--h', String(huePick(m.name))); i.title = m.name; stack.append(i); }
5069
+ return stack;
5070
+ };
5071
+ const countOf = (members) => { const n = (k) => members.filter((m) => m.kind === k).length; const say = (k, one, many) => (n(k) ? `${n(k)} ${n(k) > 1 ? many : one}` : ''); return [say('person', 'person', 'people'), say('ai', 'AI', 'AIs'), say('box', 'box', 'boxes')].filter(Boolean).join(' \u00b7 '); };
5072
+ /* A ROOM AS A CARD: like a conversation's, a little thicker (a card behind it), its members' chips on its picture. */
5073
+ function roomCard(r) {
5074
+ const card = el('button', 'conv-card conv-card-room'); card.type = 'button'; card.dataset.room = r.id;
5075
+ const plate = el('span', 'conv-card-plate'); const dot = el('span', 'conv-card-dot'); dot.dataset.state = 'ready';
5076
+ plate.append(dot, el('b', '', r.name));
5077
+ const art = el('span', 'conv-card-art'); art.style.setProperty('--h', String(huePick(r.name)));
5078
+ art.append(el('span', 'conv-card-initial', '\u2302'), memberChips(r.members));
5079
+ card.append(plate, art, el('span', 'conv-card-type', `Room \u00b7 ${countOf(r.members)}`), el('span', 'conv-card-text'));
5080
+ card.setAttribute('aria-label', `${r.name}, room`);
5081
+ card.addEventListener('click', () => { void openSalon(r.id); });
5082
+ return card;
5083
+ }
5084
+ let salonThread = null; let salonId = ''; let salonTimer = null;
5085
+ function salonLeft() { clearInterval(salonTimer); salonTimer = null; salonThread?.destroy(); salonThread = null; salonId = ''; }
5086
+ async function openSalon(id, push = true) {
5087
+ if (DEVICE) return;
5088
+ await loadRooms();
5089
+ const r = rooms.find((x) => x.id === id); if (!r) return;
5090
+ enterPlace('salon', push);
5091
+ salonLeft(); salonId = id;
5092
+ $('salon-title').textContent = r.name;
5093
+ $('salon-who').replaceChildren(memberChips(r.members), el('span', 'hint', `${countOf(r.members)} \u25BE`));
5094
+ $('salon-who').setAttribute('aria-expanded', 'false'); $('salon-members').hidden = true;
5095
+ const rows = ['person', 'ai', 'box'].map((k) => { const of = r.members.filter((m) => m.kind === k); if (!of.length) return null; const row = el('div', 'salon-members-row'); row.append(el('span', 'hint', k === 'person' ? 'People' : k === 'ai' ? 'AIs' : 'Boxes'), ...of.map((m) => { const x = el('span', 'salon-member'); x.append(memberChips([m], 1), document.createTextNode(m.name)); if (m.host) x.append(el('span', 'salon-host', 'host')); return x; })); return row; }).filter(Boolean);
5096
+ $('salon-members').replaceChildren(...rows);
5097
+ const [{ mount }, words] = await Promise.all([import(new URL('vendor/parley-ui.js', new URL('/', location.href)).href), readWords()]);
5098
+ if (salonId !== id) return;
5099
+ salonThread = mount($('salon-thread'), {
5100
+ words, markdown: true, agentName: '',
5101
+ load: (asked = {}) => fetch(`${API}/rooms/${id}/talk${asked.last ? `?last=${asked.last}` : ''}`).then((x) => x.json()),
5102
+ send: (text) => post(`${API}/rooms/${id}/talk`, { text }),
5103
+ diagram: drawDiagram, highlight: colourCode, touch: touchScreen,
5104
+ });
5105
+ salonTimer = setInterval(() => { if (salonThread && salonId === id) void salonThread.refresh(); }, 3000);
5106
+ }
5107
+ $('salon-close').addEventListener('click', () => leavePlace());
5108
+ $('salon-who').addEventListener('click', () => { const open = $('salon-members').hidden; $('salon-members').hidden = !open; $('salon-who').setAttribute('aria-expanded', String(open)); });
5109
+ /* A NEW ROOM: its name, its AIs (the first ticked is its host), its boxes. */
5110
+ async function openSalonNew(push = true) {
5111
+ if (DEVICE) return;
5112
+ enterPlace('salon-new', push);
5113
+ $('salon-new-error').hidden = true; $('salon-new-name').value = '';
5114
+ const tick = (value, label) => { const l = el('label', 'check'); const i = document.createElement('input'); i.type = 'checkbox'; i.value = value; l.append(i, document.createTextNode(label)); return l; };
5115
+ $('salon-new-ais').replaceChildren(...conversations.map((c) => tick(c.name, shownName(c))));
5116
+ let boxes = []; try { const x = await fetch(`${API}/boxes`); boxes = x.ok ? await x.json() : []; } catch { boxes = []; }
5117
+ $('salon-new-boxes').replaceChildren(...(boxes.length ? boxes.map((b) => tick(b.id, b.name)) : [el('span', 'hint', 'None')]));
5118
+ $('salon-new-name').focus();
5119
+ }
5120
+ $('salon-new-close').addEventListener('click', () => leavePlace());
5121
+ $('salon-new-create').addEventListener('click', async () => {
5122
+ const picked = (box) => [...$(box).querySelectorAll('input:checked')].map((i) => i.value);
5123
+ try {
5124
+ const made = await post(`${API}/rooms`, { name: $('salon-new-name').value, conversations: picked('salon-new-ais'), boxes: picked('salon-new-boxes') });
5125
+ await openSalon(made.id, false);
5126
+ } catch (error) { $('salon-new-error').textContent = error.message; $('salon-new-error').hidden = false; }
5127
+ });
5128
+ async function paintDeck() {
5062
5129
  $('deck-title').textContent = appName;
5063
5130
  const list = [...conversations];
5064
5131
  const add = el('button', 'conv-card conv-card-new'); add.type = 'button';
5065
5132
  add.append(el('span', 'conv-card-plus', '+'), el('small', '', 'New conversation'));
5066
5133
  add.addEventListener('click', () => { void openNew(); });
5067
- $('deck-cards').replaceChildren(...list.map((c) => convCard(c, (x) => { leavePlace(); select(x.name); })), add);
5134
+ const addRoom = el('button', 'conv-card conv-card-new conv-card-new-room'); addRoom.type = 'button';
5135
+ addRoom.append(el('span', 'conv-card-plus', '+'), el('small', '', 'New room'));
5136
+ addRoom.addEventListener('click', () => { void openSalonNew(); });
5137
+ const paint = () => $('deck-cards').replaceChildren(...rooms.map((r) => roomCard(r)), ...list.map((c) => convCard(c, (x) => { leavePlace(); select(x.name); })), add, ...(list.length ? [addRoom] : []));
5138
+ paint();
5068
5139
  $('deck-cards').hidden = list.length === 0; $('deck-empty').hidden = list.length > 0;
5140
+ await loadRooms(); paint();
5069
5141
  }
5070
- function openDeck(push = true) { if (DEVICE) return; enterPlace('deck', push); paintDeck(); }
5142
+ function openDeck(push = true) { if (DEVICE) return; enterPlace('deck', push); void paintDeck(); }
5071
5143
  $('deck-close').addEventListener('click', () => leavePlace());
5072
5144
  $('deck-empty-new').addEventListener('click', () => { void openNew(); });
5073
5145
  /* Import a configuration: the import of the map (Access, Flows), a file chosen at once. */
@@ -5247,6 +5319,8 @@
5247
5319
  $('settings').hidden = which !== 'settings';
5248
5320
  $('assets').hidden = which !== 'assets';
5249
5321
  $('deck').hidden = which !== 'deck';
5322
+ $('salon').hidden = which !== 'salon'; $('salon-new').hidden = which !== 'salon-new';
5323
+ if (which !== 'salon') { try { salonLeft(); } catch { /* not yet set up */ } }
5250
5324
  $('newconv').hidden = which !== 'new';
5251
5325
  if (which !== 'access') composing = false;
5252
5326
  /* What the conversation had open (its tab) waits under the place, as it was. */
package/web/index.html CHANGED
@@ -485,6 +485,24 @@
485
485
  <div id="deck-cards" class="deck"></div>
486
486
  <div id="deck-empty" class="deck-empty" hidden><p>No conversation yet.</p><div class="deck-empty-acts"><button type="button" id="deck-empty-new" class="primary">+ Create a conversation</button><button type="button" id="deck-empty-import">Import a configuration</button></div></div>
487
487
  </div>
488
+ <!-- A room (#268): one thread for several AIs, the person and voice boxes. -->
489
+ <div id="salon" class="sheet as-place" hidden>
490
+ <div class="panel-top"><b id="salon-title">Room</b><button type="button" id="salon-close" class="as-link place-back">&lsaquo; Back</button></div>
491
+ <button type="button" id="salon-who" class="salon-who" aria-expanded="false"></button>
492
+ <div id="salon-members" class="salon-members" hidden></div>
493
+ <div id="salon-thread" class="salon-thread"></div>
494
+ </div>
495
+ <div id="salon-new" class="sheet as-place" hidden>
496
+ <div class="panel-top"><b>New room</b><button type="button" id="salon-new-close" class="as-link place-back">&lsaquo; Back</button></div>
497
+ <div class="salon-new-body">
498
+ <label class="salon-field">Name<input id="salon-new-name" maxlength="60" placeholder="Home" autocomplete="off"></label>
499
+ <h3 class="list-head">AIs</h3><div id="salon-new-ais" class="salon-pick"></div>
500
+ <h3 class="list-head">Voice boxes</h3><div id="salon-new-boxes" class="salon-pick"></div>
501
+ <p class="hint">The first AI ticked welcomes the room: it answers, or hands the message on.</p>
502
+ <p id="salon-new-error" class="error" hidden></p>
503
+ <div class="salon-new-acts"><button type="button" id="salon-new-create" class="primary">Create</button></div>
504
+ </div>
505
+ </div>
488
506
  <div id="assets" class="sheet as-place" hidden>
489
507
  <div class="panel-top"><b>Assets</b><button type="button" id="assets-close" class="as-link place-back">&lsaquo; Conversations</button></div>
490
508
  <p id="assets-error" class="error" role="alert" hidden></p>
package/web/style.css CHANGED
@@ -2214,3 +2214,28 @@ body.as-dragging #assets-rows .as-row { touch-action: none; }
2214
2214
  @keyframes m-try-shut { 0% { opacity: 1; } 35% { opacity: 0; } 70% { opacity: 1; } }
2215
2215
  @media (prefers-reduced-motion: reduce) { .mascot.trying .m-head, .mascot.trying .m-ear, .mascot.trying .m-eye, .mascot.trying .m-shut { animation: none; } }
2216
2216
  #notice-count { cursor: pointer; }
2217
+
2218
+ /* ROOMS (#268): a room's card is a conversation's, a little thicker (a card behind it), its members' chips on its picture. */
2219
+ .conv-card-room { box-shadow: 6px 6px 0 -1px var(--panel), 6px 6px 0 0 var(--line), 0 6px 18px rgba(0, 0, 0, .18); }
2220
+ .conv-card-room .conv-card-art { position: relative; }
2221
+ .conv-card-room .salon-stack { position: absolute; left: 6px; bottom: 6px; }
2222
+ .salon-stack { display: inline-flex; }
2223
+ .salon-chip { width: 20px; height: 20px; margin-left: -6px; display: grid; place-items: center; border: 2px solid var(--panel); font: 600 .6875rem/1 var(--sans); font-style: normal; color: #fff; background: hsl(var(--h, 210) 40% 38%); }
2224
+ .salon-chip:first-child { margin-left: 0; }
2225
+ .salon-chip-person { border-radius: 50%; }
2226
+ .salon-chip-ai { border-radius: 5px; }
2227
+ .salon-chip-box { border-radius: 50%; background: var(--panel); border-color: var(--line); color: var(--ink2); }
2228
+ .salon-chip-box::before { content: ""; width: 9px; height: 9px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H3v6h3l5 4z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H3v6h3l5 4z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7'/%3E%3C/svg%3E") center / contain no-repeat; }
2229
+ #salon { display: flex; flex-direction: column; min-height: 0; }
2230
+ #salon[hidden] { display: none; }
2231
+ .salon-who { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 4px 14px; min-height: 44px; }
2232
+ .salon-members { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
2233
+ .salon-members-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
2234
+ .salon-members-row > .hint { width: 4.5rem; }
2235
+ .salon-member { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; }
2236
+ .salon-host { font-size: .6875rem; color: var(--ink2); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
2237
+ .salon-thread { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 14px 12px; --parley-bg: var(--bg); --parley-text: var(--ink); --parley-dim: var(--ink2); --parley-line: var(--line); --parley-agent: var(--panel); --parley-person: var(--bar); --parley-ask: var(--brass-ink); --parley-wait: var(--wait); --parley-ok: var(--ok); --parley-action: var(--brass-ink); --parley-on-action: var(--on-brass); --parley-live: var(--danger); }
2238
+ .salon-new-body { display: flex; flex-direction: column; gap: 10px; padding: 0 14px 24px; max-width: 32rem; }
2239
+ .salon-field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .8125rem; }
2240
+ .salon-pick { display: flex; flex-direction: column; gap: 4px; }
2241
+ .salon-new-acts { display: flex; justify-content: flex-end; }