clavarium 0.2.352-next.1 → 0.2.353-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.
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/rooms.mjs +10 -3
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.353-next.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.353-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/rooms.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { mkdirSync, rmSync } from 'node:fs';
|
|
|
18
18
|
import { randomUUID } from 'node:crypto';
|
|
19
19
|
import { Parley } from 'clavarium-parley/host';
|
|
20
20
|
import { Refusal } from './conversations.mjs';
|
|
21
|
+
import { scan } from './secret-scan.mjs';
|
|
21
22
|
|
|
22
23
|
export const ROOM_NAME_MAX = 60;
|
|
23
24
|
export const ROOMS_MAX = 20;
|
|
@@ -29,6 +30,12 @@ export const THINKING_MS = 10 * 60_000;
|
|
|
29
30
|
const KINDS = ['person', 'ai', 'box'];
|
|
30
31
|
const nameOf = (v) => String(v ?? '').replace(/\s+/g, ' ').trim().slice(0, ROOM_NAME_MAX);
|
|
31
32
|
|
|
33
|
+
/* A SECRET IN A ROOM (06-11): a room's thread is read by all its members, now and later -- a token, a key pasted
|
|
34
|
+
there is never kept: the thread shows it as stars, and only the AI the message goes to gets it (lifted into its
|
|
35
|
+
own short-lived store by its chat, as any secret said to it). What an AI writes in a room is masked the same way:
|
|
36
|
+
a secret never passes from one AI to another through a room. */
|
|
37
|
+
export const masked = (text) => { const str = String(text ?? ''); const hits = scan(str); if (!hits.length) return str; let out = ''; let last = 0; for (const h of hits) { out += str.slice(last, h.start) + '••••••'; last = h.end; } return out + str.slice(last); };
|
|
38
|
+
|
|
32
39
|
/* A sign as the cards draw it (web/kit.js hueOf, initialOf): the same name, the same letter and colour. */
|
|
33
40
|
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 }; };
|
|
34
41
|
|
|
@@ -144,13 +151,13 @@ export class Rooms {
|
|
|
144
151
|
const t = this.#thread(room.id);
|
|
145
152
|
this.#hops.set(room.id, 0);
|
|
146
153
|
/* The owner is the room's own side (no name over their words, as in any chat); anyone else is named. */
|
|
147
|
-
const now = t.say(text, undefined, [], who.ref === 'owner' ? {} : { by: { id: who.id, name: who.name, kind: who.kind, look: who.look } });
|
|
154
|
+
const now = t.say(masked(text), undefined, [], who.ref === 'owner' ? {} : { by: { id: who.id, name: who.name, kind: who.kind, look: who.look } });
|
|
148
155
|
const said = now.messages.at(-1);
|
|
149
156
|
const named = (Array.isArray(to) ? to : []).map((x) => members.find((m) => m.id === x && m.kind === 'ai')).filter(Boolean);
|
|
150
157
|
const host = members.find((m) => m.id === room.host);
|
|
151
158
|
for (const ai of named.length ? named : host ? [host] : []) {
|
|
152
159
|
this.#think(room.id, ai.id, true);
|
|
153
|
-
await this.#say(ai.ref,
|
|
160
|
+
await this.#say(ai.ref, text, { by: { id: who.id, name: who.name, kind: who.kind, look: who.look }, room: { id: room.id, name: room.name, message: said.id } });
|
|
154
161
|
}
|
|
155
162
|
/* Handed to its AIs: read, as a conversation's agent would say it (06-11: the clock stayed on every message). */
|
|
156
163
|
try { t.seen?.(); } catch { /* an older Parley */ }
|
|
@@ -192,7 +199,7 @@ export class Rooms {
|
|
|
192
199
|
}
|
|
193
200
|
if (!String(entry.text ?? '').trim()) return null;
|
|
194
201
|
/* @Name of a member, exactly: kept as its id (the screen says its name of the moment). */
|
|
195
|
-
const text =
|
|
202
|
+
const text = masked(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; });
|
|
196
203
|
const id = t.relay({ text, by: { id: me.id, name: me.name, kind: 'ai', look: me.look }, to, re, kind: kind === 'doing' ? 'doing' : 'say' });
|
|
197
204
|
/* The boxes it is sent to say it aloud (#281): its words, a member named by its name, never an id. */
|
|
198
205
|
const boxes = to.map((x) => members.find((m) => m.id === x && m.kind === 'box')).filter(Boolean).map((m) => m.ref);
|