clavarium 0.2.51-next.1 → 0.2.53-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/guide.mjs +2 -0
- package/server/main.mjs +19 -0
- package/server/secret-scan.mjs +81 -0
- package/server/secrets.mjs +63 -3
- package/server/talk.mjs +10 -4
- package/web/app.js +5 -19
- package/web/style.css +9 -24
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.53-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.53-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/guide.mjs
CHANGED
|
@@ -129,6 +129,8 @@ export function ownText({ name, tool, workKept, resources = [], chat, online, se
|
|
|
129
129
|
if (chat) out.push('- When you work in batches: keep them in a binder of batches, shown beside the chat. None yet: make it once (binder new batches; MCP: new-list, template batches). Then one card each (binder add Batches "title"), kept up to date; start only those the person ticked.');
|
|
130
130
|
out.push(online === false ? '- Internet: off.' : '- Internet: on.');
|
|
131
131
|
if (secrets.length) out.push(`- Secrets given, by name only: ${list(secrets.map((s) => plain(s, 40)))}.`);
|
|
132
|
+
/* A secret pasted in the chat is lifted out (talk.mjs, secret-scan.mjs): the message shows a marker, the value waits in /run/secrets. */
|
|
133
|
+
if (chat) out.push('- A secret the person pastes in the chat is kept OUT of it: the message shows ⟨secret:NAME⟩ and the value waits at /run/secrets/NAME for a few minutes. Use it only from there, inside a command (clv-run, or $(cat /run/secrets/NAME)); never write its value back into the chat. It clears itself when its time runs out.');
|
|
132
134
|
const own = lines.map((l) => plain(l)).filter(Boolean).slice(0, LINES_MAX);
|
|
133
135
|
if (own.length) out.push('', '## From the owner', '', ...own.map((l) => `- ${l}`));
|
|
134
136
|
out.push('');
|
package/server/main.mjs
CHANGED
|
@@ -35,6 +35,7 @@ import { Devices } from './devices.mjs';
|
|
|
35
35
|
import { handleDoor, deviceTerminal } from './door.mjs';
|
|
36
36
|
import { Vault } from './vault.mjs';
|
|
37
37
|
import { Secrets, RUNNER } from './secrets.mjs';
|
|
38
|
+
import { scan, secretRef } from './secret-scan.mjs';
|
|
38
39
|
import { Network } from './network.mjs';
|
|
39
40
|
import { Answerer, answererConfig } from './answerer.mjs';
|
|
40
41
|
import { Dockets } from './dockets.mjs';
|
|
@@ -420,6 +421,24 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
420
421
|
what is already known of a machine used instead of asking (talk.mjs). */
|
|
421
422
|
terminal: { open: (name) => bridge?.open(name) ?? false, type: (name, line, ms) => bridge?.type(name, line, ms) ?? false, droppedAt: (name) => bridge?.droppedAt(name) },
|
|
422
423
|
health: { of: (name) => health?.of(name) ?? null },
|
|
424
|
+
/* A secret pasted in a message is lifted out before the message is kept:
|
|
425
|
+
it goes to the short-lived vault and the message keeps only a marker
|
|
426
|
+
the chat shows as stars; the value reaches the machine as
|
|
427
|
+
/run/secrets/<name>, and is swept after a few minutes. */
|
|
428
|
+
screen: async (conversation, text) => {
|
|
429
|
+
const hits = scan(text);
|
|
430
|
+
if (!hits.length) return text;
|
|
431
|
+
let out = ''; let last = 0; let any = false;
|
|
432
|
+
for (const h of hits) {
|
|
433
|
+
out += text.slice(last, h.start);
|
|
434
|
+
try { const { name } = secrets.stash(conversation, h.value); out += secretRef(name); any = true; }
|
|
435
|
+
catch { out += text.slice(h.start, h.end); } /* cannot be stashed (too large): left as it is */
|
|
436
|
+
last = h.end;
|
|
437
|
+
}
|
|
438
|
+
out += text.slice(last);
|
|
439
|
+
if (any) { try { await secrets.deliver(conversation); } catch { /* machine not running: delivered at its next open */ } }
|
|
440
|
+
return out;
|
|
441
|
+
},
|
|
423
442
|
alert: (payload) => { void alerts.tell(payload); } });
|
|
424
443
|
/* Its machine restarted or built again: said in its chat, and the tool told to read it again. */
|
|
425
444
|
all.renewed = (name, text, running) => talk.renewed(name, text, running);
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* SECRET SCANNER -- finds likely secrets in a message, without any model.
|
|
2
|
+
*
|
|
3
|
+
* Used when a person's message arrives (talk.mjs): what looks like a token,
|
|
4
|
+
* key or password is lifted out, kept in the vault for a few minutes, and the
|
|
5
|
+
* message keeps only a reference. The aim is FEW FALSE POSITIVES: we match
|
|
6
|
+
* shapes that are almost never anything but a secret (known token prefixes, a
|
|
7
|
+
* PEM private key), plus long high-entropy blobs. Ordinary prose, file paths,
|
|
8
|
+
* URLs, git hashes and UUIDs are left alone. A person can still mark a
|
|
9
|
+
* selection by hand (talk.mjs) for what the shapes miss, or undo a wrong one.
|
|
10
|
+
*
|
|
11
|
+
* `scan(text)` returns the non-overlapping matches, each { start, end, value,
|
|
12
|
+
* kind }, left to right. Nothing is stored here: the caller decides.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/* Shapes that are almost always a secret. Order matters only for the `kind`
|
|
16
|
+
label; overlaps are resolved by position below. */
|
|
17
|
+
const SHAPES = [
|
|
18
|
+
{ kind: 'private-key', re: /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z0-9]+ )*PRIVATE KEY-----/g },
|
|
19
|
+
{ kind: 'github', re: /\bgithub_pat_[0-9A-Za-z_]{40,}\b/g },
|
|
20
|
+
{ kind: 'github', re: /\bgh[pousr]_[0-9A-Za-z]{36,}\b/g },
|
|
21
|
+
{ kind: 'npm', re: /\bnpm_[0-9A-Za-z]{36}\b/g },
|
|
22
|
+
{ kind: 'aws', re: /\bAKIA[0-9A-Z]{16}\b/g },
|
|
23
|
+
{ kind: 'google', re: /\bAIza[0-9A-Za-z_-]{35}\b/g },
|
|
24
|
+
{ kind: 'slack', re: /\bxox[baprs]-[0-9A-Za-z-]{10,}\b/g },
|
|
25
|
+
{ kind: 'api-key', re: /\bsk-(?:ant-|proj-|live-|test-)?[0-9A-Za-z_-]{20,}\b/g },
|
|
26
|
+
{ kind: 'jwt', re: /\beyJ[0-9A-Za-z_-]{10,}\.[0-9A-Za-z_-]{10,}\.[0-9A-Za-z_-]{10,}\b/g },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
/* A long run of token characters, caught only when it looks random (not a
|
|
30
|
+
path, a hash or a word). */
|
|
31
|
+
const BLOB = /[0-9A-Za-z+/=_-]{40,}/g;
|
|
32
|
+
const ENTROPY_MIN = 3.5; /* bits per character */
|
|
33
|
+
const CLASSES_MIN = 3; /* of: lower, upper, digit, symbol */
|
|
34
|
+
|
|
35
|
+
function entropy(s) {
|
|
36
|
+
const count = new Map();
|
|
37
|
+
for (const c of s) count.set(c, (count.get(c) ?? 0) + 1);
|
|
38
|
+
let bits = 0;
|
|
39
|
+
for (const n of count.values()) { const p = n / s.length; bits -= p * Math.log2(p); }
|
|
40
|
+
return bits;
|
|
41
|
+
}
|
|
42
|
+
function classes(s) {
|
|
43
|
+
let n = 0;
|
|
44
|
+
if (/[a-z]/.test(s)) n += 1;
|
|
45
|
+
if (/[A-Z]/.test(s)) n += 1;
|
|
46
|
+
if (/[0-9]/.test(s)) n += 1;
|
|
47
|
+
if (/[^0-9A-Za-z]/.test(s)) n += 1;
|
|
48
|
+
return n;
|
|
49
|
+
}
|
|
50
|
+
/* A blob that is only hex (a git sha, a checksum) or only one case is not a
|
|
51
|
+
secret for us: too many false positives, and real tokens mix classes. */
|
|
52
|
+
function looksRandom(s) {
|
|
53
|
+
return classes(s) >= CLASSES_MIN && entropy(s) >= ENTROPY_MIN;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* How a lifted secret is written back into the message: a marker the chat
|
|
57
|
+
shows as stars (ui side), and the tool reads to use /run/secrets/<name>.
|
|
58
|
+
Named like `SECRET_` + 10 hex (secrets.mjs stash). The angle brackets
|
|
59
|
+
(U+27E8/U+27E9) are vanishingly rare in a real message. */
|
|
60
|
+
export const secretRef = (name) => `⟨secret:${name}⟩`;
|
|
61
|
+
export const SECRET_REF = /⟨secret:(SECRET_[0-9A-F]{10})⟩/g;
|
|
62
|
+
|
|
63
|
+
export function scan(text) {
|
|
64
|
+
const str = String(text ?? '');
|
|
65
|
+
const found = [];
|
|
66
|
+
for (const { kind, re } of SHAPES) {
|
|
67
|
+
re.lastIndex = 0;
|
|
68
|
+
for (let m; (m = re.exec(str));) found.push({ start: m.index, end: m.index + m[0].length, value: m[0], kind });
|
|
69
|
+
}
|
|
70
|
+
for (let m; (m = BLOB.exec(str));) {
|
|
71
|
+
if (looksRandom(m[0])) found.push({ start: m.index, end: m.index + m[0].length, value: m[0], kind: 'high-entropy' });
|
|
72
|
+
}
|
|
73
|
+
BLOB.lastIndex = 0;
|
|
74
|
+
/* Keep left-to-right, and when two matches overlap keep the one that starts
|
|
75
|
+
first (and, equal, the longer): a known prefix wins over the blob rule. */
|
|
76
|
+
found.sort((a, b) => a.start - b.start || b.end - a.end);
|
|
77
|
+
const out = [];
|
|
78
|
+
let reach = -1;
|
|
79
|
+
for (const f of found) { if (f.start >= reach) { out.push(f); reach = f.end; } }
|
|
80
|
+
return out;
|
|
81
|
+
}
|
package/server/secrets.mjs
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* should use on the agent's behalf (a push key, a mailbox password) does not
|
|
22
22
|
* belong here, and never enters a VM.
|
|
23
23
|
*/
|
|
24
|
+
import { randomBytes } from 'node:crypto';
|
|
24
25
|
import { Refusal } from './conversations.mjs';
|
|
25
26
|
import { Grants, conversationSubject } from './grants.mjs';
|
|
26
27
|
import { isConversationName } from './names.mjs';
|
|
@@ -30,6 +31,12 @@ export const SECRETS_DIR = '/run/secrets';
|
|
|
30
31
|
export const RUNNER = '/usr/local/bin/clv-run';
|
|
31
32
|
export const VALUE_MAX = 8 * 1024;
|
|
32
33
|
export const WARN_DAYS = 7;
|
|
34
|
+
/* A secret lifted from a message (secret-scan.mjs): a random name, a short
|
|
35
|
+
life in MINUTES (not days), swept when it runs out. */
|
|
36
|
+
export const EPHEMERAL_PREFIX = 'SECRET_';
|
|
37
|
+
export const TTL_DEFAULT_MS = 10 * 60_000;
|
|
38
|
+
export const TTL_MIN_MS = 60_000;
|
|
39
|
+
export const TTL_MAX_MS = 60 * 60_000;
|
|
33
40
|
const DAY = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
34
41
|
const DAY_MS = 86_400_000;
|
|
35
42
|
const NAME = /^[A-Z][A-Z0-9_]{0,39}$/;
|
|
@@ -69,7 +76,7 @@ export function daysTo(day, now = new Date()) {
|
|
|
69
76
|
const firstLine = (text) => String(text ?? '').trim().split('\n').filter(Boolean).pop()?.slice(0, 200) ?? '';
|
|
70
77
|
|
|
71
78
|
export class Secrets {
|
|
72
|
-
#store; #vault; #vms; #grants; #now;
|
|
79
|
+
#store; #vault; #vms; #grants; #now; #timers = new Map();
|
|
73
80
|
|
|
74
81
|
/* `grants`: the one table of rights. "Handed to a conversation" is a
|
|
75
82
|
line of it: the conversation may USE the secret. */
|
|
@@ -80,9 +87,19 @@ export class Secrets {
|
|
|
80
87
|
for (const conversation of Object.keys(s.attachments)) this.#grants.give(conversationSubject(conversation), `secret:${s.name}`, 'x');
|
|
81
88
|
delete s.attachments; store.put(s);
|
|
82
89
|
}
|
|
90
|
+
/* A restart loses the sweep timers: drop the ephemeral secrets that ran
|
|
91
|
+
out while down, and set a fresh timer for those still alive. */
|
|
92
|
+
for (const s of store.all()) {
|
|
93
|
+
if (s.ephemeral !== true) continue;
|
|
94
|
+
const who = this.#users(s.name)[0];
|
|
95
|
+
const left = who ? Date.parse(s.expiresAt) - this.#now().getTime() : 0;
|
|
96
|
+
if (!who || !(left > 0)) { store.remove(s.name); this.#grants.forgetAsset(`secret:${s.name}`); }
|
|
97
|
+
else this.#schedule(who, s.name, left);
|
|
98
|
+
}
|
|
83
99
|
}
|
|
84
100
|
#handed(conversation, name) { return this.#grants.can(conversationSubject(conversation), `secret:${name}`, 'x'); }
|
|
85
|
-
|
|
101
|
+
/* Ephemeral: gone at its moment (minutes). Otherwise: gone from its day on. */
|
|
102
|
+
#expired(s) { return s.expiresAt ? Date.parse(s.expiresAt) <= this.#now().getTime() : (Boolean(s.expires) && daysTo(s.expires, this.#now()) <= 0); }
|
|
86
103
|
#users(name) { return this.#grants.on(`secret:${name}`).map((g) => g.subject.slice('conversation:'.length)); }
|
|
87
104
|
/* What is delivered to this conversation: handed, and not expired. */
|
|
88
105
|
#given(conversation) { return this.#store.all().filter((s) => this.#handed(conversation, s.name) && !this.#expired(s)); }
|
|
@@ -91,7 +108,8 @@ export class Secrets {
|
|
|
91
108
|
days left (null without an expiry); `expired`: no longer delivered. */
|
|
92
109
|
list() {
|
|
93
110
|
return this.#store.all().map((s) => ({ name: s.name, conversations: this.#users(s.name), createdAt: s.createdAt,
|
|
94
|
-
expires: s.expires ?? null, days: s.expires ? daysTo(s.expires, this.#now()) : null, expired: this.#expired(s)
|
|
111
|
+
expires: s.expires ?? null, days: s.expires ? daysTo(s.expires, this.#now()) : null, expired: this.#expired(s),
|
|
112
|
+
...(s.ephemeral ? { ephemeral: true, expiresAt: s.expiresAt, expiresInMs: Math.max(0, Date.parse(s.expiresAt) - this.#now().getTime()) } : {}) }));
|
|
95
113
|
}
|
|
96
114
|
/* Past its expiry day: kept, not used (nor by dictation, voice.mjs). */
|
|
97
115
|
isExpired(name) { const s = this.#store.get(name); return Boolean(s) && this.#expired(s); }
|
|
@@ -187,6 +205,48 @@ export class Secrets {
|
|
|
187
205
|
for (const s of this.#store.all()) this.#grants.take(conversationSubject(conversation), `secret:${s.name}`);
|
|
188
206
|
}
|
|
189
207
|
|
|
208
|
+
/* AN EPHEMERAL SECRET lifted from a message of `conversation` (talk.mjs):
|
|
209
|
+
a random name, a few minutes to live, handed at once to that
|
|
210
|
+
conversation, swept when it runs out. Returns { name, expiresAt } -- the
|
|
211
|
+
name is the reference the message keeps (its value is masked there). As
|
|
212
|
+
with every secret the value is sealed and never returned by any route;
|
|
213
|
+
the tool uses it only as /run/secrets/<name>, and never sees it. */
|
|
214
|
+
stash(conversation, value, { ttlMs } = {}) {
|
|
215
|
+
if (!isConversationName(conversation)) throw new Refusal(400, 'Not a conversation.');
|
|
216
|
+
const sealed = this.#seal(value);
|
|
217
|
+
const ttl = Math.min(TTL_MAX_MS, Math.max(TTL_MIN_MS, Number.isFinite(ttlMs) ? ttlMs : TTL_DEFAULT_MS));
|
|
218
|
+
let name; do { name = EPHEMERAL_PREFIX + randomBytes(5).toString('hex').toUpperCase(); } while (this.#store.get(name));
|
|
219
|
+
const expiresAt = new Date(this.#now().getTime() + ttl).toISOString();
|
|
220
|
+
this.#store.put({ name, sealed, createdAt: this.#now().toISOString(), expiresAt, ephemeral: true });
|
|
221
|
+
this.#grants.give(conversationSubject(conversation), `secret:${name}`, 'x');
|
|
222
|
+
this.#schedule(conversation, name, ttl);
|
|
223
|
+
return { name, expiresAt };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* Forgotten before it runs out, on the tool's word or the owner's: gone
|
|
227
|
+
from the vault and, at once, from the running machine. */
|
|
228
|
+
async drop(conversation, name) {
|
|
229
|
+
const s = this.#store.get(name);
|
|
230
|
+
if (!s || s.ephemeral !== true) throw new Refusal(404, 'No such short-lived secret.');
|
|
231
|
+
const t = this.#timers.get(name); if (t) { clearTimeout(t); this.#timers.delete(name); }
|
|
232
|
+
await this.#reap(conversation, name);
|
|
233
|
+
return { name };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
#schedule(conversation, name, ttl) {
|
|
237
|
+
const t = setTimeout(() => { this.#timers.delete(name); void this.#reap(conversation, name); }, ttl);
|
|
238
|
+
t.unref?.();
|
|
239
|
+
this.#timers.set(name, t);
|
|
240
|
+
}
|
|
241
|
+
/* Remove it, then rewrite the machine's /run/secrets without it (a tmpfs
|
|
242
|
+
already cleared if the machine is gone -- so a failure here is fine). */
|
|
243
|
+
async #reap(conversation, name) {
|
|
244
|
+
if (this.#store.get(name)) { this.#store.remove(name); this.#grants.forgetAsset(`secret:${name}`); }
|
|
245
|
+
try { await this.deliver(conversation); } catch { /* machine asleep or busy: /run/secrets is tmpfs */ }
|
|
246
|
+
try { this.reaped(conversation, name); } catch { /* told nowhere: never a reason to fail */ }
|
|
247
|
+
}
|
|
248
|
+
reaped = () => {};
|
|
249
|
+
|
|
190
250
|
/* What a delivery to this conversation would contain, as one string that
|
|
191
251
|
changes whenever a delivery would differ: names and sealed values. */
|
|
192
252
|
signature(conversation) {
|
package/server/talk.mjs
CHANGED
|
@@ -182,7 +182,7 @@ const PART = /^[A-Za-z0-9._~-]{1,200}$/;
|
|
|
182
182
|
export class Talk {
|
|
183
183
|
#store; #words; #vms; #conversations; #resources; #toolbox; #warm; #alert; #listening = new Map(); #every; #now;
|
|
184
184
|
#typedAt = new Map(); #nextTry = new Map(); #trying = new Map(); #timer; #lastLang = 'en'; #rereadAfter;
|
|
185
|
-
#terminal; #health; #ranAt = new Map(); #kept;
|
|
185
|
+
#terminal; #health; #ranAt = new Map(); #kept; #screen;
|
|
186
186
|
|
|
187
187
|
/* `alert({ title, body, url })`: told when the tool asks, or waits.
|
|
188
188
|
`words`: a store for the owner's choice of words (one record). */
|
|
@@ -192,8 +192,8 @@ export class Talk {
|
|
|
192
192
|
/* `keptDir`: where each conversation's thread is kept (its own folder),
|
|
193
193
|
in this server's data -- never in the work folder, which its machine
|
|
194
194
|
writes. Without it, the bridge folder is all there is. */
|
|
195
|
-
constructor({ store, words, vms, conversations, resources, toolbox = null, warm = async () => {}, alert = () => {}, listenEveryMs = 2000, now = () => Date.now(), rereadAfterMs = REREAD_AFTER_MS, terminal = null, health = null, keptDir = null }) {
|
|
196
|
-
this.#terminal = terminal; this.#health = health; this.#kept = keptDir;
|
|
195
|
+
constructor({ store, words, vms, conversations, resources, toolbox = null, warm = async () => {}, alert = () => {}, listenEveryMs = 2000, now = () => Date.now(), rereadAfterMs = REREAD_AFTER_MS, terminal = null, health = null, keptDir = null, screen = null }) {
|
|
196
|
+
this.#terminal = terminal; this.#health = health; this.#kept = keptDir; this.#screen = screen;
|
|
197
197
|
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.#every = listenEveryMs; this.#now = now; this.#rereadAfter = rereadAfterMs;
|
|
198
198
|
for (const s of store.all()) if (s.on === true) this.#listen(s.name);
|
|
199
199
|
this.#timer = setInterval(() => { void this.#tick(); }, Math.min(listenEveryMs, 1000));
|
|
@@ -448,7 +448,13 @@ export class Talk {
|
|
|
448
448
|
const note = item && typeof item === 'object' && typeof item.note === 'string' ? item.note : '';
|
|
449
449
|
return { path, name: m[2], size: info.size, ...(note ? { note } : {}) };
|
|
450
450
|
});
|
|
451
|
-
|
|
451
|
+
/* A secret pasted in the message (a token, a key) is lifted into a
|
|
452
|
+
short-lived store, and the message keeps only a reference -- the
|
|
453
|
+
thread never holds the value (secret-scan.mjs, secrets.mjs). It must
|
|
454
|
+
never lose a message: on any trouble the text is sent as it came. */
|
|
455
|
+
let said = text ?? '';
|
|
456
|
+
if (this.#screen && said) { try { said = await this.#screen(name, said); } catch { said = text ?? ''; } }
|
|
457
|
+
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 } : {}) }); } catch (error) { if (error instanceof RangeError) throw new Refusal(400, error.message); throw error; }
|
|
452
458
|
const told = await this.#wake(name);
|
|
453
459
|
return { ...this.of(name), told };
|
|
454
460
|
}
|
package/web/app.js
CHANGED
|
@@ -966,31 +966,17 @@
|
|
|
966
966
|
full -- not marked "Seen"; a program stopped for lack of memory (its files safe) is only said. */
|
|
967
967
|
const healthNeeds = (c) => c.phase === 'ready' && !c.asleep && (c.health?.problems ?? []).some((p) => (p.level === 'bad' || (p.level === 'warn' && ['memory', 'disk'].includes(p.kind) && !String(p.key).startsWith('oom:'))) && !(c.health.seen ?? []).includes(p.key));
|
|
968
968
|
const needsYou = (c) => Boolean(talkNeeds(c) || c.answerer?.needs || c.phase === 'failed' || healthNeeds(c));
|
|
969
|
-
/*
|
|
970
|
-
|
|
971
|
-
|
|
969
|
+
/* ONE FLAT POINT per conversation, its colour the state -- the worst that applies: a machine problem (red),
|
|
970
|
+
the agent waits for you (blue), the agent at work (gold, pulsing), the machine busy (amber, pulsing),
|
|
971
|
+
fine (green), asleep (a hollow ring). The same point, same colours, sums a folded group below. */
|
|
972
972
|
const machineState = (c) => (c.asleep ? 'off' : (c.phase === 'failed' || healthNeeds(c)) ? 'problem'
|
|
973
973
|
: (holds(c) || ['building', 'restarting', 'moving'].includes(c.phase)) ? 'busy' : 'online');
|
|
974
974
|
const agentState = (c) => (c.asleep ? 'sleep' : (talkNeeds(c) || c.answerer?.needs) ? 'wait'
|
|
975
975
|
: c.talk?.state === 'working' ? 'work' : c.talk?.state === 'done' ? 'done' : 'idle');
|
|
976
|
-
const MACHINE_WORDS = { online: '', busy: 'machine busy', problem: 'a problem', off: 'asleep' };
|
|
977
|
-
const AGENT_WORDS = { work: 'at work', wait: 'waits for you', done: 'finished', idle: '', sleep: '' };
|
|
978
|
-
const stateIndicator = (c) => {
|
|
979
|
-
const m = machineState(c); const a = agentState(c);
|
|
980
|
-
const ind = document.createElement('span'); ind.className = 'state-ind'; ind.dataset.machine = m; ind.dataset.agent = a;
|
|
981
|
-
const ring = document.createElement('span'); ring.className = 'state-ring';
|
|
982
|
-
const core = document.createElement('span'); core.className = 'state-core';
|
|
983
|
-
ind.append(ring, core); ind.setAttribute('role', 'img');
|
|
984
|
-
const words = [MACHINE_WORDS[m], AGENT_WORDS[a]].filter(Boolean).join(' · ') || 'idle';
|
|
985
|
-
ind.title = words; ind.setAttribute('aria-label', words);
|
|
986
|
-
return ind;
|
|
987
|
-
};
|
|
988
|
-
const statePoint = (state) => { const d = document.createElement('span'); d.className = 'state-dot'; d.dataset.state = state; return d; };
|
|
989
|
-
/* Folded, a heading sums its conversations: one flat point each, same colours, no ring -- the worst kept first
|
|
990
|
-
(a problem, waits for you, at work, busy, fine, asleep) -- and the same in words for a screen reader. */
|
|
991
976
|
const STATE_WORDS = { problem: 'a problem', wait: 'waits for you', work: 'at work', busy: 'busy', ok: 'fine', sleep: 'asleep' };
|
|
992
977
|
const rollup = (c) => { const m = machineState(c); const a = agentState(c);
|
|
993
978
|
return (m === 'off' ? 'sleep' : m === 'problem' ? 'problem' : a === 'wait' ? 'wait' : a === 'work' ? 'work' : m === 'busy' ? 'busy' : 'ok'); };
|
|
979
|
+
const statePoint = (state) => { const d = document.createElement('span'); d.className = 'state-dot'; d.dataset.state = state; return d; };
|
|
994
980
|
const STATE_ORDER = ['problem', 'wait', 'work', 'busy', 'ok', 'sleep'];
|
|
995
981
|
function stateSummary(list) {
|
|
996
982
|
const count = Object.fromEntries(STATE_ORDER.map((k) => [k, 0]));
|
|
@@ -1073,7 +1059,7 @@
|
|
|
1073
1059
|
b.append(when); b.dataset.when = 'true';
|
|
1074
1060
|
} else b.append(title, ...(plain ? [] : [sub]));
|
|
1075
1061
|
/* Its state: one point, on the right. */
|
|
1076
|
-
|
|
1062
|
+
const point = statePoint(rollup(c)); point.title = STATE_WORDS[point.dataset.state]; b.append(point);
|
|
1077
1063
|
/* Found by a search while hidden: said. */
|
|
1078
1064
|
if (c.hidden === true && query) { const mark = document.createElement('small'); mark.className = 'shared-mark'; mark.textContent = 'hidden'; b.append(mark); }
|
|
1079
1065
|
/* Several models answer its simple questions; or they stopped, and it waits for its owner. */
|
package/web/style.css
CHANGED
|
@@ -34,41 +34,26 @@ button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); out
|
|
|
34
34
|
.item[aria-current="true"] { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
|
|
35
35
|
.item b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
36
36
|
.item small { color: var(--ink2); }
|
|
37
|
-
/* ITS STATE, on the right of its row
|
|
38
|
-
machine (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.item { position: relative; padding-right:
|
|
37
|
+
/* ITS STATE, one point on the right of its row, its colour the worst that
|
|
38
|
+
applies: a machine problem (red), the agent waits for you (blue), the agent
|
|
39
|
+
at work (gold, pulsing), the machine busy (amber, pulsing), fine (green),
|
|
40
|
+
asleep (a hollow ring). The same point, same colours, sums a folded group. */
|
|
41
|
+
.item { position: relative; padding-right: 26px; }
|
|
42
42
|
.state-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-sizing: border-box; background: var(--ok); }
|
|
43
43
|
.state-dot[data-state="problem"] { background: var(--danger); }
|
|
44
44
|
.state-dot[data-state="wait"] { background: var(--wait); }
|
|
45
45
|
.state-dot[data-state="work"] { background: var(--brass); }
|
|
46
46
|
.state-dot[data-state="busy"] { background: var(--warn); }
|
|
47
47
|
.state-dot[data-state="sleep"] { background: transparent; border: 1.5px solid var(--ink2); }
|
|
48
|
-
|
|
49
|
-
.state-
|
|
50
|
-
.item > .state-ind { position: absolute; right: 9px; top: 11px; }
|
|
51
|
-
.state-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; box-sizing: border-box; }
|
|
52
|
-
.state-core { width: 7px; height: 7px; border-radius: 50%; box-sizing: border-box; background: var(--ok); }
|
|
53
|
-
.state-ind[data-machine="busy"] .state-core { background: var(--warn); animation: breathe 1.5s ease-in-out infinite; }
|
|
54
|
-
.state-ind[data-machine="problem"] .state-core { background: var(--danger); }
|
|
55
|
-
.state-ind[data-machine="off"] .state-core { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink2); }
|
|
56
|
-
.state-ind[data-agent="work"] .state-ring { border-color: var(--brass); animation: breathe 1.9s ease-in-out infinite; }
|
|
57
|
-
.state-ind[data-agent="wait"] .state-ring { border-color: var(--wait); }
|
|
58
|
-
.state-ind[data-agent="done"] .state-ring { border-color: var(--ok); }
|
|
59
|
-
.state-ind[data-agent="sleep"] .state-ring { border-color: var(--line); }
|
|
48
|
+
.item > .state-dot { position: absolute; right: 10px; top: 13px; }
|
|
49
|
+
.item > .state-dot[data-state="work"], .item > .state-dot[data-state="busy"] { animation: breathe 1.7s ease-in-out infinite; }
|
|
60
50
|
/* Folded: up to four points, how its conversations are. */
|
|
61
51
|
.state-sum { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }
|
|
62
52
|
/* Unfolded: it comes in gently, once. */
|
|
63
53
|
.unfolding { animation: unfold .18s ease-out; }
|
|
64
54
|
@keyframes unfold { from { opacity: 0; transform: translateY(-6px); } }
|
|
65
|
-
@keyframes
|
|
66
|
-
@
|
|
67
|
-
/* Movement off: no pulse, and a dashed ring tells "at work" by shape instead. */
|
|
68
|
-
@media (prefers-reduced-motion: reduce) {
|
|
69
|
-
.state-core, .state-ring, .unfolding { animation: none !important; }
|
|
70
|
-
.state-ind[data-agent="work"] .state-ring { border-style: dashed; }
|
|
71
|
-
}
|
|
55
|
+
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.85); } }
|
|
56
|
+
@media (prefers-reduced-motion: reduce) { .item > .state-dot, .unfolding { animation: none !important; } }
|
|
72
57
|
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
73
58
|
.choices button[aria-checked="true"] { border-color: var(--brass); background: rgba(210, 169, 78, .16); }
|
|
74
59
|
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|