clavarium 0.2.237-beta.1 → 0.2.238-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.
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/api.mjs +1 -1
- package/server/main.mjs +2 -0
- package/server/rooms.mjs +47 -13
- package/server/settingswords.mjs +1 -1
- package/server/talk.mjs +1 -0
- package/web/app.js +19 -3
- package/web/index.html +2 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.238-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.238-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.66-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.3",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.99-next.1",
|
|
17
17
|
"clavarium-tether": "0.1.0-next.79",
|
|
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.
|
|
791
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
792
|
-
"integrity": "sha512-
|
|
790
|
+
"version": "0.17.99-next.1",
|
|
791
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.99-next.1.tgz",
|
|
792
|
+
"integrity": "sha512-DeoKzByZyckP7UU29bGpA+ui861j0q+t+4AQYhcsDO57wkdQXHjf9v0z0MetvvVZeOHQcx4QqG/wphepSwguqw==",
|
|
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.
|
|
3
|
+
"version": "0.2.238-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.66-next.1",
|
|
49
49
|
"clavarium-docket": "0.1.2-next.3",
|
|
50
|
-
"clavarium-parley": "0.17.
|
|
50
|
+
"clavarium-parley": "0.17.99-next.1",
|
|
51
51
|
"clavarium-tether": "0.1.0-next.79",
|
|
52
52
|
"mammoth": "1.13.0",
|
|
53
53
|
"mermaid": "11.17.2",
|
package/server/api.mjs
CHANGED
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
* POST /api/asset-groups/<id>/remove
|
|
111
111
|
* GET /api/rooms the rooms (#268): [{id, name, host, members: [{id, kind, name, ref, host?}], unread, last, thinking: [names]}]
|
|
112
112
|
* POST /api/rooms {name, conversations: [names], boxes: [ids], host?}: a new room
|
|
113
|
-
* POST /api/rooms/<id> {name?, host?, add?: {conversations, boxes}, remove?: [member ids]}
|
|
113
|
+
* POST /api/rooms/<id> {name?, host?, add?: {conversations, boxes}, remove?: [member ids], perHour?: N (0: no limit) or null (the default, 60): hand-overs between its AIs an hour}
|
|
114
114
|
* quiet?: true/false (muted in the list: no dot, at the bottom)
|
|
115
115
|
* POST /api/rooms/<id>/remove the room and its thread
|
|
116
116
|
* POST /api/rooms/<id>/give {asset, rights, shared?}: the same right given to each AI of it, its own
|
package/server/main.mjs
CHANGED
|
@@ -885,6 +885,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
885
885
|
rooms = new Rooms({ file: new JsonFile(`${dataDir}/rooms.json`, []), dir: `${dataDir}/rooms`,
|
|
886
886
|
removed: (id) => grants.forgetAsset(`room:${id}`),
|
|
887
887
|
say: (name, text, extra, files) => talk.say(name, text, undefined, files, undefined, extra),
|
|
888
|
+
/* A line in an AI's own chat, not a message (it wakes nothing): a hand-over of its not passed on. */
|
|
889
|
+
note: (name, text) => talk.event(name, { kind: 'room-hops', text }),
|
|
888
890
|
attach: (name, fileName, request) => talk.attach(name, fileName, request),
|
|
889
891
|
rooms: (name, list) => talk.rooms(name, list), conversations: () => all.list(), boxes: () => boxes.all(),
|
|
890
892
|
speak: (where, text, ids, how) => { void boxes.agentSaid(where, text, ids, how); },
|
package/server/rooms.mjs
CHANGED
|
@@ -25,13 +25,19 @@ import { scan } from './secret-scan.mjs';
|
|
|
25
25
|
export const ROOM_NAME_MAX = 60;
|
|
26
26
|
export const ROOMS_MAX = 20;
|
|
27
27
|
export const MEMBERS_MAX = 40;
|
|
28
|
-
/*
|
|
29
|
-
|
|
28
|
+
/* 19-11, the owner: hand-overs between a room's AIs AN HOUR (`perHour`, PER_HOUR_DEFAULT unless set; 0: none), a
|
|
29
|
+
bucket: past it, they wait -- said in the room and to the AI that sent it, never silently -- and go on as it fills
|
|
30
|
+
again. Every AI of the room is told the limit and what is left (its rooms list), to answer why nothing came. */
|
|
31
|
+
export const HOPS_WINDOW_MS = 60 * 60_000;
|
|
32
|
+
export const PER_HOUR_MAX = 1000;
|
|
33
|
+
/* 19-11, the owner: 60 an hour unless the room says otherwise (0: no limit). */
|
|
34
|
+
export const PER_HOUR_DEFAULT = 60;
|
|
35
|
+
const perHourOf = (r) => (Number.isInteger(r?.perHour) ? r.perHour : PER_HOUR_DEFAULT);
|
|
30
36
|
/* How long an AI given a message is said to be thinking, at most (it may never answer). */
|
|
31
37
|
export const THINKING_MS = 10 * 60_000;
|
|
32
38
|
const KINDS = ['person', 'ai', 'box'];
|
|
33
39
|
/* A ROOM'S OWN LINES (a Tether call held for one of its AIs, and what closes it): the kinds, their level, at most kept. */
|
|
34
|
-
const LINE_LEVELS = Object.freeze({ 'tether-demande': 'needs-you', 'tether-done': 'trace' });
|
|
40
|
+
const LINE_LEVELS = Object.freeze({ 'tether-demande': 'needs-you', 'tether-done': 'trace', 'room-hops': 'news' });
|
|
35
41
|
const LEVELS = ['needs-you', 'news', 'trace'];
|
|
36
42
|
const LINE_ACTION = /^[a-z]{1,20}(:[a-z0-9][a-z0-9._-]{0,63})?$/;
|
|
37
43
|
export const ROOM_LINES_MAX = 50;
|
|
@@ -70,7 +76,7 @@ const maskedAll = (v, depth = 0) => (typeof v === 'string' ? masked(v) : depth >
|
|
|
70
76
|
export const lookOf = (name) => { const text = String(name ?? ''); let h = 0; for (const ch of text) h = (h * 31 + ch.codePointAt(0)) >>> 0; return { initial: ([...text.trim()][0] ?? '?').toUpperCase(), hue: h % 360 }; };
|
|
71
77
|
|
|
72
78
|
export class Rooms {
|
|
73
|
-
#file; #dir; #say; #attach; #read; #rooms; #conversations; #boxes; #now; #speak; #reachOf; #shownIn; #removed; #hops = new Map(); #thinking = new Map();
|
|
79
|
+
#file; #dir; #say; #note; #attach; #read; #rooms; #conversations; #boxes; #now; #speak; #reachOf; #shownIn; #removed; #hops = new Map(); #thinking = new Map();
|
|
74
80
|
/* file: a JsonFile of the rooms; dir: where their threads are; say(name, text, extra): a message written in a
|
|
75
81
|
conversation's own chat (talk.say; its 4th argument the paths of its files there); attach(name, fileName,
|
|
76
82
|
request): a file put in a conversation's chat as the person attaches one (talk.attach); rooms(name, list): what a conversation is told of its rooms (talk.rooms);
|
|
@@ -80,9 +86,9 @@ export class Rooms {
|
|
|
80
86
|
read(name, ref): that file of that conversation ({ name, size, stream }), read with its rights -- what an AI
|
|
81
87
|
shows or cites to another AI of the room is copied from it (#carried).
|
|
82
88
|
removed(id): a room removed (what was given of it, to an API key, goes with it). */
|
|
83
|
-
constructor({ file, dir, say, removed = () => {}, attach = async () => { throw new Refusal(409, 'Files cannot be given here.'); }, rooms = () => {}, conversations = () => [], boxes = () => [], speak = () => {}, now = () => new Date(), reach = () => null, shown = () => false, read = async () => { throw new Refusal(404, 'No such file.'); } }) {
|
|
89
|
+
constructor({ file, dir, say, note = () => {}, removed = () => {}, attach = async () => { throw new Refusal(409, 'Files cannot be given here.'); }, rooms = () => {}, conversations = () => [], boxes = () => [], speak = () => {}, now = () => new Date(), reach = () => null, shown = () => false, read = async () => { throw new Refusal(404, 'No such file.'); } }) {
|
|
84
90
|
this.#removed = removed; this.#speak = speak; this.#attach = attach; this.#read = read; this.#reachOf = reach; this.#shownIn = shown;
|
|
85
|
-
this.#file = file; this.#dir = dir; this.#say = say; this.#rooms = rooms; this.#conversations = conversations; this.#boxes = boxes; this.#now = now;
|
|
91
|
+
this.#file = file; this.#dir = dir; this.#say = say; this.#note = note; this.#rooms = rooms; this.#conversations = conversations; this.#boxes = boxes; this.#now = now;
|
|
86
92
|
}
|
|
87
93
|
#all() { const v = this.#file.get(); return Array.isArray(v) ? v : []; }
|
|
88
94
|
#save(list) { this.#file.set(list); this.#tellConversations(list); }
|
|
@@ -115,7 +121,7 @@ export class Rooms {
|
|
|
115
121
|
/* ITS AIs, as conversations (06-11): the names of the conversations of its AI members that are there now --
|
|
116
122
|
never a box, never the person, never one taken out of the room. What « give to all its AIs » gives to. */
|
|
117
123
|
ais(id) { return this.#shown(this.#find(id)).filter((m) => m.kind === 'ai').map((m) => m.ref); }
|
|
118
|
-
get(id) { const r = this.#find(id); return { id: r.id, name: r.name, host: r.host, members: this.#shown(r), at: r.at }; }
|
|
124
|
+
get(id) { const r = this.#find(id); return { id: r.id, name: r.name, host: r.host, members: this.#shown(r), at: r.at, perHour: perHourOf(r), perHourSet: Number.isInteger(r.perHour) }; }
|
|
119
125
|
|
|
120
126
|
/* A new room: its name, its AIs (conversation names), its boxes (ids), and which AI is the host (the first by default). */
|
|
121
127
|
create({ name, conversations = [], boxes = [], host } = {}) {
|
|
@@ -151,10 +157,16 @@ export class Rooms {
|
|
|
151
157
|
if (room.members.length > MEMBERS_MAX) throw new Refusal(409, `${MEMBERS_MAX} members at most.`);
|
|
152
158
|
}
|
|
153
159
|
/* Its name, its host, members added or taken away; `quiet` (07-11, the tidy-up): muted in the list, or not. */
|
|
154
|
-
change(id, { name, host, add = {}, remove = [], quiet } = {}) {
|
|
160
|
+
change(id, { name, host, add = {}, remove = [], quiet, perHour } = {}) {
|
|
155
161
|
const list = this.#all(); const room = list.find((r) => r.id === id);
|
|
156
162
|
if (!room) throw new Refusal(404, 'No such room.');
|
|
157
163
|
if (quiet !== undefined) { if (quiet === true) room.quiet = true; else delete room.quiet; }
|
|
164
|
+
/* Hand-overs between its AIs an hour (19-11): a whole number (0: no limit), or null: the default. */
|
|
165
|
+
if (perHour !== undefined) {
|
|
166
|
+
if (perHour === null) delete room.perHour;
|
|
167
|
+
else if (Number.isInteger(perHour) && perHour >= 0 && perHour <= PER_HOUR_MAX) room.perHour = perHour;
|
|
168
|
+
else throw new Refusal(400, `perHour: a whole number from 0 (no limit) to ${PER_HOUR_MAX}, or null (the default, ${PER_HOUR_DEFAULT}).`);
|
|
169
|
+
}
|
|
158
170
|
if (name !== undefined) {
|
|
159
171
|
const n = nameOf(name); if (!n) throw new Refusal(400, 'Give the room a name.');
|
|
160
172
|
if (list.some((r) => r.id !== id && r.name.toLowerCase() === n.toLowerCase())) throw new Refusal(409, 'A room has that name already.');
|
|
@@ -279,7 +291,6 @@ export class Rooms {
|
|
|
279
291
|
if (!who) throw new Refusal(400, 'Not a member of this room.');
|
|
280
292
|
const attached = this.#filesSaid(room.id, files);
|
|
281
293
|
const t = this.#thread(room.id);
|
|
282
|
-
this.#hops.set(room.id, 0);
|
|
283
294
|
/* The owner is the room's own side (no name over their words, as in any chat); anyone else is named. */
|
|
284
295
|
let now;
|
|
285
296
|
try { now = t.say(masked(text), undefined, attached.map(({ path, name, size }) => ({ path, name, size })), who.ref === 'owner' ? {} : { by: { id: who.id, name: who.name, kind: who.kind, look: who.look } }); } catch (error) { if (error instanceof RangeError) throw new Refusal(400, error.message); throw error; }
|
|
@@ -335,9 +346,25 @@ export class Rooms {
|
|
|
335
346
|
const ais = to.map((x) => members.find((m) => m.id === x && m.kind === 'ai')).filter(Boolean);
|
|
336
347
|
/* `paths`: the files it shows or cites in it -- each AI it goes to gets its own copy, as when the person attaches one. */
|
|
337
348
|
const handOver = (ai, text, from, message, paths = []) => {
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
|
|
349
|
+
const limit = perHourOf(room);
|
|
350
|
+
if (limit) {
|
|
351
|
+
/* A BUCKET (19-11, the owner): `limit` tokens, filled again continuously at `limit` an hour; a hand-over
|
|
352
|
+
takes one. A burst goes at once, then they come back a little at a time. */
|
|
353
|
+
const nowMs = this.#now().getTime();
|
|
354
|
+
const kept = this.#hops.get(room.id) ?? { tokens: limit, at: nowMs, said: 0 };
|
|
355
|
+
kept.tokens = Math.min(limit, kept.tokens + ((nowMs - kept.at) * limit) / HOPS_WINDOW_MS); kept.at = nowMs;
|
|
356
|
+
this.#hops.set(room.id, kept);
|
|
357
|
+
const every = Math.max(1, Math.round(60 / limit));
|
|
358
|
+
if (kept.tokens < 1) {
|
|
359
|
+
/* Said in the room, once an hour at most, and to the AI that sent it, each time (never a hand-over lost without a word). */
|
|
360
|
+
if (nowMs - kept.said >= HOPS_WINDOW_MS) { kept.said = nowMs; const list = this.#all(); const r = list.find((x) => x.id === room.id); if (r && this.#line(r, { kind: 'room-hops', text: `${me.name} → ${ai.name}: not passed on. The AIs of this room used their ${limit} hand-overs an hour, the limit set for it: they go on as it fills again (one every ${every} min; Settings of the room).`, tone: 'warn' })) this.#file.set(list); }
|
|
361
|
+
try { this.#note(me.ref, `In the room ${room.name}, your message to ${ai.name} was not passed on: this room allows ${limit} hand-overs between its AIs an hour, all used. One more every ${every} min; the person can change it in the room's settings.`); } catch { /* its chat may be off */ }
|
|
362
|
+
this.#tellConversations(this.#all());
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
kept.tokens -= 1;
|
|
366
|
+
this.#tellConversations(this.#all());
|
|
367
|
+
}
|
|
341
368
|
this.#think(room.id, ai.id, true);
|
|
342
369
|
void (async () => {
|
|
343
370
|
const copies = paths.length ? await this.#carried(me, ai, paths) : [];
|
|
@@ -441,11 +468,18 @@ export class Rooms {
|
|
|
441
468
|
const shown = list.map((r) => ({ ...r, members: this.#shown(r) }));
|
|
442
469
|
for (const c of this.#conversations()) {
|
|
443
470
|
const mine = shown.filter((r) => r.members.some((m) => m.kind === 'ai' && m.ref === c.name))
|
|
444
|
-
.map((r) => ({ id: r.id, name: r.name, members: r.members.map((m) => ({ id: m.id, name: m.name, kind: m.kind, look: m.look })) }));
|
|
471
|
+
.map((r) => ({ id: r.id, name: r.name, members: r.members.map((m) => ({ id: m.id, name: m.name, kind: m.kind, look: m.look })), handovers: this.#handovers(r) }));
|
|
445
472
|
try { this.#rooms(c.name, mine); } catch { /* its folder is not there yet */ }
|
|
446
473
|
}
|
|
447
474
|
}
|
|
448
475
|
refresh() { this.#tellConversations(this.#all()); }
|
|
476
|
+
/* Where a room is with hand-overs between its AIs: { perHour, left } (perHour 0: no limit). */
|
|
477
|
+
#handovers(r) {
|
|
478
|
+
const limit = perHourOf(r); if (!limit) return { perHour: 0 };
|
|
479
|
+
const kept = this.#hops.get(r.id); if (!kept) return { perHour: limit, left: limit };
|
|
480
|
+
const now = this.#now().getTime();
|
|
481
|
+
return { perHour: limit, left: Math.floor(Math.min(limit, kept.tokens + ((now - kept.at) * limit) / HOPS_WINDOW_MS)) };
|
|
482
|
+
}
|
|
449
483
|
/* The boxes bound to a room (their conversation 'room:<id>') are members of it, by themselves (#281). */
|
|
450
484
|
boxesBound(boxes) {
|
|
451
485
|
const list = this.#all(); let changed = false;
|
package/server/settingswords.mjs
CHANGED
|
@@ -270,7 +270,7 @@ export const SETTINGS_WORDS_FR = {
|
|
|
270
270
|
'set-room-find': 'Chercher une conversation', 'set-room-boxes': 'Boîtiers vocaux',
|
|
271
271
|
'set-room-remove': 'Supprimer le salon', 'set-room-remove-what': 'Le fil part · les IA et boîtiers restent',
|
|
272
272
|
'set-room-remove-dots': 'Supprimer…', 'set-room-remove-yes': 'Supprimer {name}', 'set-room-keep': 'Garder',
|
|
273
|
-
'set-room-create': 'Créer', 'set-room-new': 'Nouveau salon',
|
|
273
|
+
'set-room-create': 'Créer', 'set-room-new': 'Nouveau salon', 'set-room-limit': 'Échanges entre ses IA, par heure', 'set-room-limit-hint': 'Vide : 60 · 0 : sans limite',
|
|
274
274
|
/* A room's settings as every settings page (07-11): each change saved at once, said a moment in the bar. */
|
|
275
275
|
'set-room-saved': 'Enregistré', 'set-room-settings-of': '{name} · Réglages', 'set-room-of': '{n} sur {t}',
|
|
276
276
|
'set-room-host-how': 'Touchez une autre IA du salon pour la déplacer',
|
package/server/talk.mjs
CHANGED
|
@@ -164,6 +164,7 @@ export const LEVELS = Object.freeze(['needs-you', 'news', 'trace']);
|
|
|
164
164
|
export const RESTART_ASKED = 'restart-asked';
|
|
165
165
|
export const EVENT_LEVELS = Object.freeze({
|
|
166
166
|
sent: 'news',
|
|
167
|
+
'room-hops': 'news',
|
|
167
168
|
refused: 'needs-you',
|
|
168
169
|
'sent-by-hand': 'news',
|
|
169
170
|
origin: 'trace',
|
package/web/app.js
CHANGED
|
@@ -3724,8 +3724,8 @@
|
|
|
3724
3724
|
threadOf = name;
|
|
3725
3725
|
/* The short-lived secrets live in this conversation now (secret-scan.mjs): the chat shows each as
|
|
3726
3726
|
stars with its time left and a way to forget it. Kept current on each reload, read on each repaint. */
|
|
3727
|
-
const chatSecrets = {};
|
|
3728
|
-
const refreshSecrets = () => { for (const k of Object.keys(chatSecrets)) delete chatSecrets[k]; for (const s of conversations.find((x) => x.name === name)?.ephemeralSecrets ?? []) chatSecrets[s.name] = { expiresInMs: s.expiresInMs }; };
|
|
3727
|
+
const chatSecrets = {}; const goneSecrets = new Set();
|
|
3728
|
+
const refreshSecrets = () => { for (const k of Object.keys(chatSecrets)) delete chatSecrets[k]; for (const s of conversations.find((x) => x.name === name)?.ephemeralSecrets ?? []) chatSecrets[s.name] = { expiresInMs: s.expiresInMs }; for (const k of goneSecrets) chatSecrets[k] = { gone: true }; };
|
|
3729
3729
|
refreshSecrets();
|
|
3730
3730
|
/* The lines of its machine seen so far: what changed comes alone, and their buttons are worked out on all of them. */
|
|
3731
3731
|
const lines = new Map();
|
|
@@ -3805,7 +3805,8 @@
|
|
|
3805
3805
|
diagram: drawDiagram, highlight: colourCode,
|
|
3806
3806
|
/* Short-lived secrets of this conversation: the stars say their time left and offer to forget them. */
|
|
3807
3807
|
secrets: chatSecrets,
|
|
3808
|
-
|
|
3808
|
+
/* Its chip says « deleted » (kept marked gone), or why not -- the error goes back to it (19-11: it said nothing). */
|
|
3809
|
+
forget: (secretName) => post(`${API}/conversations/${encodeURIComponent(name)}/secrets/${encodeURIComponent(secretName)}/forget`, {}).then(() => { goneSecrets.add(secretName); chatSecrets[secretName] = { gone: true }; if (thread && threadOf === name) void thread.refresh(); }),
|
|
3809
3810
|
remind: (o) => post(talkPath(name, '/remind'), o?.urgent ? { urgent: true } : {}),
|
|
3810
3811
|
/* The helpers of the terminal, in the chat: this page's voice, the owner's ready answers, the keyboard rule of this device. */
|
|
3811
3812
|
voice: chatVoice(), autoSend: chatAuto, autoSendMs: chatAutoMs, onAutoSendMs: keepAutoMs,
|
|
@@ -7334,6 +7335,19 @@
|
|
|
7334
7335
|
}
|
|
7335
7336
|
$('salon-new-search').addEventListener('input', paintSalonMembers);
|
|
7336
7337
|
/* Its name: saved at Enter, or on leaving the field (a room's settings); Escape gives it back. */
|
|
7338
|
+
$('salon-limit').addEventListener('change', async () => {
|
|
7339
|
+
const r = salonEditing; if (!r) return;
|
|
7340
|
+
const raw = $('salon-limit').value.trim(); const perHour = raw === '' ? null : Math.round(Number(raw));
|
|
7341
|
+
$('salon-new-error').hidden = true;
|
|
7342
|
+
try {
|
|
7343
|
+
const now = await post(`${API}/rooms/${r.id}`, { perHour });
|
|
7344
|
+
if (salonEditing !== r) return;
|
|
7345
|
+
salonEditing = { ...r, ...now };
|
|
7346
|
+
$('salon-limit').value = salonEditing.perHourSet ? String(salonEditing.perHour) : '';
|
|
7347
|
+
const said = $('salon-new-status'); said.textContent = `✓ ${uiSaid('set-room-saved', 'Saved')}`;
|
|
7348
|
+
clearTimeout(salonSavedTimer); salonSavedTimer = setTimeout(() => { said.textContent = ''; }, 2500);
|
|
7349
|
+
} catch (error) { if (salonEditing !== r) return; $('salon-new-error').textContent = error.message; $('salon-new-error').hidden = false; $('salon-limit').value = r.perHourSet ? String(r.perHour) : ''; }
|
|
7350
|
+
});
|
|
7337
7351
|
$('salon-new-name').addEventListener('keydown', (e) => {
|
|
7338
7352
|
if (!salonEditing) return;
|
|
7339
7353
|
if (e.key === 'Enter') { e.preventDefault(); $('salon-new-name').blur(); }
|
|
@@ -7444,6 +7458,8 @@
|
|
|
7444
7458
|
$('salon-new-status').textContent = ''; clearTimeout(salonSavedTimer);
|
|
7445
7459
|
$('salon-new-remove-card').hidden = !editing; salonRemoveAsk?.close(); salonRemoveAsk = null;
|
|
7446
7460
|
$('salon-new-error').hidden = true; $('salon-new-name').value = editing?.name ?? ''; $('salon-new-search').value = '';
|
|
7461
|
+
/* Its limit of hand-overs between AIs an hour (19-11): a room that is there; empty, the default (60); 0, none. */
|
|
7462
|
+
$('salon-limit-row').hidden = !editing; $('salon-limit').value = editing?.perHourSet ? String(editing.perHour) : '';
|
|
7447
7463
|
salonTake(editing);
|
|
7448
7464
|
/* A new room: its name and its AIs open, the rest as the person left it. */
|
|
7449
7465
|
if (!editing) for (const id of ['salon-ch-general', 'salon-ch-ais']) $(id).open = true;
|
package/web/index.html
CHANGED
|
@@ -757,6 +757,8 @@
|
|
|
757
757
|
<summary><span class="chapter-title" data-said="set-tab-general">General</span><span class="chapter-about" id="salon-sum-general"></span></summary>
|
|
758
758
|
<div class="chapter-body">
|
|
759
759
|
<div class="set-row"><div class="set-what"><label for="salon-new-name" data-said="set-room-name">Name</label></div><div class="set-control"><input id="salon-new-name" maxlength="60" placeholder="Home" spellcheck="false" autocomplete="off" enterkeyhint="done"></div></div>
|
|
760
|
+
<!-- Hand-overs between its AIs an hour (rooms.mjs perHour, a bucket): empty, the default (60); 0, no limit. -->
|
|
761
|
+
<div class="set-row" id="salon-limit-row" hidden><div class="set-what"><label for="salon-limit" data-said="set-room-limit">Hand-overs between its AIs, an hour</label><small class="hint" data-said="set-room-limit-hint">Empty: 60 · 0: no limit</small></div><div class="set-control"><input id="salon-limit" type="number" min="0" max="1000" step="1" inputmode="numeric" placeholder="60"></div></div>
|
|
760
762
|
</div>
|
|
761
763
|
</details>
|
|
762
764
|
<details class="chapter" id="salon-ch-ais" data-chapter="room-ais">
|