clavarium 0.2.60-next.1 → 0.2.62-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.60-next.1",
3
+ "version": "0.2.62-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.60-next.1",
9
+ "version": "0.2.62-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.7-next.1",
16
+ "clavarium-parley": "0.17.9-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.7-next.1",
718
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.7-next.1.tgz",
719
- "integrity": "sha512-qzkXBaBY8zn3VQbsbrNeqy3+x/q2wUNn9GIoob+I4EYsFRQGufhboVaD5yogeMgiq1uB1hk5O5/N9Oh18dDUNg==",
717
+ "version": "0.17.9-next.1",
718
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.9-next.1.tgz",
719
+ "integrity": "sha512-pKwFQnq/6JO2nA37u9RNCO6ddgCUvpqmmmqRPQMa5GGT1nL0dFGDs1hY+Wed3TqKYRKxLmCgUWgts0aQBYihqw==",
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.60-next.1",
3
+ "version": "0.2.62-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.7-next.1",
49
+ "clavarium-parley": "0.17.9-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
@@ -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);
@@ -29,8 +29,18 @@ 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 */
38
+ /* With a word nearby that announces a secret, the net is widened: a shorter run (a 10-char password) is
39
+ lifted, on a lower entropy floor -- because the context already says it is one. A bare short string, with
40
+ no such word, is left alone (too many false positives). */
41
+ const KEYWORD = /\b(pass(?:word|phrase)s?|mots?\s+de\s+passe|pwd|secrets?|tokens?|jetons?|cl[eé]s?|api[_\s-]?keys?|keys?|auth|credentials?|identifiants?)\b/i;
42
+ const SHORT_WORD = /[A-Za-z0-9]{10,39}/g;
43
+ const ENTROPY_SHORT = 3.2;
34
44
 
35
45
  function entropy(s) {
36
46
  const count = new Map();
@@ -52,6 +62,11 @@ function classes(s) {
52
62
  function looksRandom(s) {
53
63
  return classes(s) >= CLASSES_MIN && entropy(s) >= ENTROPY_MIN;
54
64
  }
65
+ /* The shorter net: all three of upper, lower and digit present (a hash or a word misses one), and high
66
+ entropy (a lower floor when a nearby word already announces a secret). */
67
+ function improbableWord(s, floor = ENTROPY_MIN) {
68
+ return /[a-z]/.test(s) && /[A-Z]/.test(s) && /[0-9]/.test(s) && entropy(s) >= floor;
69
+ }
55
70
 
56
71
  /* How a lifted secret is written back into the message: a marker the chat
57
72
  shows as stars (ui side), and the tool reads to use /run/secrets/<name>.
@@ -71,6 +86,14 @@ export function scan(text) {
71
86
  if (looksRandom(m[0])) found.push({ start: m.index, end: m.index + m[0].length, value: m[0], kind: 'high-entropy' });
72
87
  }
73
88
  BLOB.lastIndex = 0;
89
+ /* A word nearby that announces a secret widens the net to shorter runs, on a lower floor. */
90
+ const near = KEYWORD.test(str);
91
+ const wordRe = near ? SHORT_WORD : WORD;
92
+ const floor = near ? ENTROPY_SHORT : ENTROPY_MIN;
93
+ for (let m; (m = wordRe.exec(str));) {
94
+ if (improbableWord(m[0], floor)) found.push({ start: m.index, end: m.index + m[0].length, value: m[0], kind: 'high-entropy' });
95
+ }
96
+ wordRe.lastIndex = 0;
74
97
  /* Keep left-to-right, and when two matches overlap keep the one that starts
75
98
  first (and, equal, the longer): a known prefix wins over the blob rule. */
76
99
  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
  }