clavarium 0.2.58-next.1 → 0.2.61-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 +6 -6
- package/package.json +2 -2
- package/server/guide.mjs +1 -1
- package/server/main.mjs +3 -1
- package/server/secret-scan.mjs +14 -2
- package/server/talk.mjs +19 -4
- package/web/app.js +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.61-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.61-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.8-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.1",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.8-next.1",
|
|
17
17
|
"mermaid": "11.17.2",
|
|
18
18
|
"node-pty": "^1.1.0",
|
|
19
19
|
"pdfjs-dist": "6.4.299",
|
|
@@ -714,9 +714,9 @@
|
|
|
714
714
|
}
|
|
715
715
|
},
|
|
716
716
|
"node_modules/clavarium-parley": {
|
|
717
|
-
"version": "0.17.
|
|
718
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
719
|
-
"integrity": "sha512-
|
|
717
|
+
"version": "0.17.8-next.1",
|
|
718
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.8-next.1.tgz",
|
|
719
|
+
"integrity": "sha512-AJHz4V91heYRuCYh3KXRi8kw5ArNTLNsKpA2Svw6JoGKh7wCRr+Wp3ayiJDpukdjLHkijEuk7vhFE3c7L/LQ3g==",
|
|
720
720
|
"license": "MIT",
|
|
721
721
|
"bin": {
|
|
722
722
|
"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.61-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.8-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.1",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
49
|
+
"clavarium-parley": "0.17.8-next.1",
|
|
50
50
|
"mermaid": "11.17.2",
|
|
51
51
|
"node-pty": "^1.1.0",
|
|
52
52
|
"pdfjs-dist": "6.4.299",
|
package/server/guide.mjs
CHANGED
|
@@ -130,7 +130,7 @@ export function ownText({ name, tool, workKept, resources = [], chat, online, se
|
|
|
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
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.');
|
|
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, or at once with `parley forget NAME` when you are done.');
|
|
134
134
|
const own = lines.map((l) => plain(l)).filter(Boolean).slice(0, LINES_MAX);
|
|
135
135
|
if (own.length) out.push('', '## From the owner', '', ...own.map((l) => `- ${l}`));
|
|
136
136
|
out.push('');
|
package/server/main.mjs
CHANGED
|
@@ -431,7 +431,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
431
431
|
let out = ''; let last = 0; let any = false;
|
|
432
432
|
for (const h of hits) {
|
|
433
433
|
out += text.slice(last, h.start);
|
|
434
|
-
try { const { name } = secrets.stash(conversation, h.value); out += secretRef(name); any = true; }
|
|
434
|
+
try { const { name, expiresAt } = secrets.stash(conversation, h.value); out += secretRef(name, Date.parse(expiresAt)); any = true; }
|
|
435
435
|
catch { out += text.slice(h.start, h.end); } /* cannot be stashed (too large): left as it is */
|
|
436
436
|
last = h.end;
|
|
437
437
|
}
|
|
@@ -439,6 +439,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
439
439
|
if (any) { try { await secrets.deliver(conversation); } catch { /* machine not running: delivered at its next open */ } }
|
|
440
440
|
return out;
|
|
441
441
|
},
|
|
442
|
+
/* The agent asked to forget a short-lived secret (parley forget): drop it from the vault and machine. */
|
|
443
|
+
dropSecret: (conversation, name) => { void secrets.drop(conversation, name).catch(() => {}); },
|
|
442
444
|
alert: (payload) => { void alerts.tell(payload); } });
|
|
443
445
|
/* Its machine restarted or built again: said in its chat, and the tool told to read it again. */
|
|
444
446
|
all.renewed = (name, text, running) => talk.renewed(name, text, running);
|
package/server/secret-scan.mjs
CHANGED
|
@@ -29,6 +29,10 @@ const SHAPES = [
|
|
|
29
29
|
/* A long run of token characters, caught only when it looks random (not a
|
|
30
30
|
path, a hash or a word). */
|
|
31
31
|
const BLOB = /[0-9A-Za-z+/=_-]{40,}/g;
|
|
32
|
+
/* A SHORTER run of letters and digits only (no symbols, so a UUID's or path's dashes break it up): caught
|
|
33
|
+
when it is improbable -- it mixes upper, lower AND digits, and its entropy is high. This is the "unusual
|
|
34
|
+
word" net: a random-looking password or key the known shapes missed, without flagging a hash or an id. */
|
|
35
|
+
const WORD = /[A-Za-z0-9]{20,39}/g;
|
|
32
36
|
const ENTROPY_MIN = 3.5; /* bits per character */
|
|
33
37
|
const CLASSES_MIN = 3; /* of: lower, upper, digit, symbol */
|
|
34
38
|
|
|
@@ -52,13 +56,17 @@ function classes(s) {
|
|
|
52
56
|
function looksRandom(s) {
|
|
53
57
|
return classes(s) >= CLASSES_MIN && entropy(s) >= ENTROPY_MIN;
|
|
54
58
|
}
|
|
59
|
+
/* The shorter net: all three of upper, lower and digit present (a hash or a word misses one), and high entropy. */
|
|
60
|
+
function improbableWord(s) {
|
|
61
|
+
return /[a-z]/.test(s) && /[A-Z]/.test(s) && /[0-9]/.test(s) && entropy(s) >= ENTROPY_MIN;
|
|
62
|
+
}
|
|
55
63
|
|
|
56
64
|
/* How a lifted secret is written back into the message: a marker the chat
|
|
57
65
|
shows as stars (ui side), and the tool reads to use /run/secrets/<name>.
|
|
58
66
|
Named like `SECRET_` + 10 hex (secrets.mjs stash). The angle brackets
|
|
59
67
|
(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})
|
|
68
|
+
export const secretRef = (name, at) => `⟨secret:${name}${Number.isFinite(at) ? `@${at}` : ''}⟩`;
|
|
69
|
+
export const SECRET_REF = /⟨secret:(SECRET_[0-9A-F]{10})(?:@(\d+))?⟩/g;
|
|
62
70
|
|
|
63
71
|
export function scan(text) {
|
|
64
72
|
const str = String(text ?? '');
|
|
@@ -71,6 +79,10 @@ export function scan(text) {
|
|
|
71
79
|
if (looksRandom(m[0])) found.push({ start: m.index, end: m.index + m[0].length, value: m[0], kind: 'high-entropy' });
|
|
72
80
|
}
|
|
73
81
|
BLOB.lastIndex = 0;
|
|
82
|
+
for (let m; (m = WORD.exec(str));) {
|
|
83
|
+
if (improbableWord(m[0])) found.push({ start: m.index, end: m.index + m[0].length, value: m[0], kind: 'high-entropy' });
|
|
84
|
+
}
|
|
85
|
+
WORD.lastIndex = 0;
|
|
74
86
|
/* Keep left-to-right, and when two matches overlap keep the one that starts
|
|
75
87
|
first (and, equal, the longer): a known prefix wins over the blob rule. */
|
|
76
88
|
found.sort((a, b) => a.start - b.start || b.end - a.end);
|
package/server/talk.mjs
CHANGED
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
*/
|
|
61
61
|
import { posix, join } from 'node:path';
|
|
62
62
|
import { randomUUID, createHash } from 'node:crypto';
|
|
63
|
-
import { mkdirSync, lstatSync, rmSync } from 'node:fs';
|
|
63
|
+
import { mkdirSync, lstatSync, rmSync, readFileSync } from 'node:fs';
|
|
64
64
|
import { install, Parley, WAKE, reread, texts, fill, LANGUAGES, SHOWN_MAX, FILES_MAX } from 'clavarium-parley/host';
|
|
65
65
|
import { importFile } from './files.mjs';
|
|
66
66
|
import { KEYS } from 'clavarium-parley/ui';
|
|
@@ -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; #screen;
|
|
185
|
+
#terminal; #health; #ranAt = new Map(); #kept; #screen; #dropSecret;
|
|
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, screen = null }) {
|
|
196
|
-
this.#terminal = terminal; this.#health = health; this.#kept = keptDir; this.#screen = screen;
|
|
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, dropSecret = null }) {
|
|
196
|
+
this.#terminal = terminal; this.#health = health; this.#kept = keptDir; this.#screen = screen; this.#dropSecret = dropSecret;
|
|
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));
|
|
@@ -643,6 +643,7 @@ export class Talk {
|
|
|
643
643
|
|
|
644
644
|
async #tick() {
|
|
645
645
|
for (const r of this.#store.all()) {
|
|
646
|
+
if (r.on === true) this.#reapForgets(r);
|
|
646
647
|
if (r.on === true && r.reread === true) { await this.#tryReread(r.name).catch(() => {}); continue; }
|
|
647
648
|
if (r.on !== true || (!r.pending && !r.woke)) continue;
|
|
648
649
|
/* It has read: what waited is done, and the next message wakes it again. */
|
|
@@ -652,6 +653,20 @@ export class Talk {
|
|
|
652
653
|
}
|
|
653
654
|
}
|
|
654
655
|
|
|
656
|
+
/* The agent asked to forget short-lived secrets (parley forget -> forget.jsonl beside its thread): the
|
|
657
|
+
parloir drops each from its vault and machine at once. Each request is acted on once, counted in the store. */
|
|
658
|
+
#reapForgets(r) {
|
|
659
|
+
if (!this.#dropSecret) return;
|
|
660
|
+
let lines;
|
|
661
|
+
try { lines = readFileSync(`${this.#dir(r.name)}/forget.jsonl`, 'utf8').split('\n').filter(Boolean); } catch { return; }
|
|
662
|
+
const done = r.forgotten ?? 0;
|
|
663
|
+
if (lines.length <= done) return;
|
|
664
|
+
for (const line of lines.slice(done)) {
|
|
665
|
+
try { const name = JSON.parse(line)?.name; if (typeof name === 'string' && /^SECRET_[0-9A-F]{10}$/.test(name)) void this.#dropSecret(r.name, name); } catch { /* a stray line */ }
|
|
666
|
+
}
|
|
667
|
+
this.#store.put({ ...r, forgotten: lines.length });
|
|
668
|
+
}
|
|
669
|
+
|
|
655
670
|
forget(name) { this.#deaf(name); if (this.#keep(name)) rmSync(this.#keep(name), { recursive: true, force: true }); this.#store.remove(name); this.#typedAt.delete(name); this.#ranAt.delete(name); this.#nextTry.delete(name); this.#nextTry.delete(`reread:${name}`); }
|
|
656
671
|
stop() { clearInterval(this.#timer); for (const name of [...this.#listening.keys()]) this.#deaf(name); }
|
|
657
672
|
}
|
package/web/app.js
CHANGED
|
@@ -3228,6 +3228,8 @@
|
|
|
3228
3228
|
const gitSub = (r) => (r.from ? `from ${hostOf(r.from)}` : 'repository');
|
|
3229
3229
|
/* A secret's expiry, as said: `due` when it asks for the person (near, or past). */
|
|
3230
3230
|
const secretState = (s) => {
|
|
3231
|
+
/* Short-lived, lifted from a message (secrets.mjs): minutes, not days -- shown so it can be seen and let go. */
|
|
3232
|
+
if (s.ephemeral) { const mins = Math.max(0, Math.round((s.expiresInMs ?? 0) / 60_000)); return s.expired || mins <= 0 ? { text: 'Expired', tone: 'bad', due: true } : { text: `Short-lived, ${mins} min left`, tone: 'warn', due: true }; }
|
|
3231
3233
|
if (s.expired) return { text: 'Expired', tone: 'bad', due: true };
|
|
3232
3234
|
if (s.days === null || s.days === undefined) return { text: 'No expiry', tone: '', due: false };
|
|
3233
3235
|
if (secretDue(s)) return { text: s.days === 1 ? 'Expires tomorrow' : `Expires in ${s.days} days`, tone: 'warn', due: true };
|