clavarium 0.2.106-next.1 → 0.2.107-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/main.mjs +2 -0
- package/server/talk.mjs +5 -0
- package/server/tethers.mjs +32 -2
- package/web/app.js +9 -4
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.107-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.107-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/main.mjs
CHANGED
|
@@ -470,6 +470,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
470
470
|
alert: (payload) => { void alerts.tell(payload); } });
|
|
471
471
|
/* Its machine restarted or built again: said in its chat, and the tool told to read it again. */
|
|
472
472
|
all.renewed = (name, text, running) => talk.renewed(name, text, running);
|
|
473
|
+
/* A Tether call waiting for the owner is said in its conversation's thread, with Accept / Refuse. */
|
|
474
|
+
tethers.announce = (name, event) => { try { return talk.event(name, event); } catch { return null; } };
|
|
473
475
|
/* A device given a conversation that talks through the app talks there too. */
|
|
474
476
|
door.talk = talk;
|
|
475
477
|
/* AFTER AN UPDATE, the machines that run get the new tools at once (parley, docket: they serve from
|
package/server/talk.mjs
CHANGED
|
@@ -153,6 +153,11 @@ export const EVENT_LEVELS = Object.freeze({
|
|
|
153
153
|
'docket-failed': 'needs-you',
|
|
154
154
|
'docket-unhandled': 'needs-you',
|
|
155
155
|
'docket-reminder': 'trace',
|
|
156
|
+
/* A Tether call its agent asks the owner to allow (tethers.mjs): offered in the thread with
|
|
157
|
+
Accept / Refuse, the same block a machine problem uses. Its closing line (decided here, from
|
|
158
|
+
Assets, or by the agent) is a trace that carries the call's id, so the buttons close with it. */
|
|
159
|
+
'tether-demande': 'needs-you',
|
|
160
|
+
'tether-done': 'trace',
|
|
156
161
|
});
|
|
157
162
|
const TONES = ['warn', 'bad'];
|
|
158
163
|
/* Bounds of a line: its text, its group (topic), what the grouped line says of it (brief), its buttons. */
|
package/server/tethers.mjs
CHANGED
|
@@ -28,7 +28,10 @@ export const PUMP_MS = 1000;
|
|
|
28
28
|
const AGENT = 'conversation:';
|
|
29
29
|
|
|
30
30
|
export class Tethers {
|
|
31
|
-
#keeper; #resources; #conversations; #secrets; #timers = []; #changes = 0;
|
|
31
|
+
#keeper; #resources; #conversations; #secrets; #timers = []; #changes = 0; #seen = new Map();
|
|
32
|
+
/* Set by the server once the thread is ready (main.mjs): (name, event) => talk.event(...).
|
|
33
|
+
A call waiting for the owner is said in its conversation's thread when there is one. */
|
|
34
|
+
announce = null;
|
|
32
35
|
|
|
33
36
|
/* `resources`: Resources (workFolder). `conversations()`: the names of the conversations.
|
|
34
37
|
`secrets`: the vault, read by name for a connector only (reveal). */
|
|
@@ -38,7 +41,34 @@ export class Tethers {
|
|
|
38
41
|
/* Every change a page shows -- a new approval waiting, one decided, the targets,
|
|
39
42
|
the journal -- bumps the counter the client watches, so the approvals screen
|
|
40
43
|
sees them all at once, not only when a store change happens to wake it. */
|
|
41
|
-
this.#keeper.onChange(() => { this.#changes++; });
|
|
44
|
+
this.#keeper.onChange(() => { this.#changes++; this.#tellNew(); });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* A new call waiting for the owner is said in its conversation's thread -- the same block a
|
|
48
|
+
machine problem uses -- with Accept / Refuse; when it leaves the queue (decided here or from
|
|
49
|
+
Assets, or taken back by the agent) a trace carrying its id closes those buttons. Nothing is
|
|
50
|
+
said until the server wired `announce` (it holds the thread), and nothing to a conversation
|
|
51
|
+
whose chat is off keeps the line waiting for when it opens. */
|
|
52
|
+
#tellNew() {
|
|
53
|
+
if (!this.announce) return;
|
|
54
|
+
let now;
|
|
55
|
+
try { now = this.#keeper.approvals() ?? []; } catch { return; }
|
|
56
|
+
const live = new Set(now.map((r) => r.id));
|
|
57
|
+
for (const r of now) {
|
|
58
|
+
if (this.#seen.has(r.id)) continue;
|
|
59
|
+
const who = r.agent?.id ?? '';
|
|
60
|
+
if (!who.startsWith(AGENT)) continue;
|
|
61
|
+
const name = who.slice(AGENT.length);
|
|
62
|
+
this.#seen.set(r.id, { name, verb: r.verb ?? 'action' });
|
|
63
|
+
const what = [r.verb ?? 'action', r.detail].filter(Boolean).join(' ');
|
|
64
|
+
const text = [what, r.target?.title ? `(${r.target.title})` : '', r.why ? `-- ${r.why}` : ''].filter(Boolean).join(' ');
|
|
65
|
+
try { this.announce(name, { kind: 'tether-demande', text: text || (r.verb ?? 'A Tether call'), topic: 'Demande', tone: 'warn', actions: [`allow:${r.id}`, `deny:${r.id}`] }); } catch { /* its chat is off */ }
|
|
66
|
+
}
|
|
67
|
+
for (const [id, info] of [...this.#seen]) {
|
|
68
|
+
if (live.has(id)) continue;
|
|
69
|
+
this.#seen.delete(id);
|
|
70
|
+
try { this.announce(info.name, { kind: 'tether-done', text: `Request handled: ${info.verb}`, topic: 'Demande', brief: id }); } catch { /* its chat is off */ }
|
|
71
|
+
}
|
|
42
72
|
}
|
|
43
73
|
|
|
44
74
|
/* A secret's value for a connector, by name, from this server's vault; never seen by the agent.
|
package/web/app.js
CHANGED
|
@@ -2553,7 +2553,7 @@
|
|
|
2553
2553
|
/* A reaction to one of its messages: wherever the chat may be written in. */
|
|
2554
2554
|
...(!DEVICE || deviceParts.chat === 'write' ? { react: (to, reaction) => post(talkPath(name, '/react'), { to, reaction }) } : {}),
|
|
2555
2555
|
/* The buttons of a line of the machine: what this screen may do. */
|
|
2556
|
-
act: (id) => { if (id === 'seen-done') return; if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
|
|
2556
|
+
act: (id) => { if (id === 'seen-done') return; if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (id.startsWith('allow:')) void decideTether(id.slice('allow:'.length), 'yes'); else if (id.startsWith('deny:')) void decideTether(id.slice('deny:'.length), 'no'); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
|
|
2557
2557
|
/* What it opens over the thread (a picture, its media, a search...) is a step of this page's: one Back closes it. */
|
|
2558
2558
|
back: { open: (name, close) => nav.over(`chat-${name}`, () => close(), { stack: true }), closed: (step) => { if (step) nav.drop(step); } },
|
|
2559
2559
|
/* Files attached to a message: wherever the chat may be written in. */
|
|
@@ -2682,8 +2682,10 @@
|
|
|
2682
2682
|
/* "commits:<repository>.<to>.<from>.<n>": those commits, in the review ("See the 3 commits"). A commit a
|
|
2683
2683
|
line names (7 to 40 hexadecimal characters, a digit among them) is a link to its review, on a line about
|
|
2684
2684
|
a repository; the agent's own messages are never read for this. */
|
|
2685
|
-
const ACTIONS = { memory: 'More memory...', disk: 'Give it more disk...', room: 'See what takes room', restart: 'Restart...', terminal: 'See the terminal', review: 'Open the review', seen: '\u2713 Seen' };
|
|
2685
|
+
const ACTIONS = { memory: 'More memory...', disk: 'Give it more disk...', room: 'See what takes room', restart: 'Restart...', terminal: 'See the terminal', review: 'Open the review', seen: '\u2713 Seen', allow: 'Accept', deny: 'Refuse' };
|
|
2686
2686
|
const COMMITS = /^commits:([a-z0-9][a-z0-9-]*)\.([0-9a-f]{7,40})\.([0-9a-f]{7,40})\.(\d{1,4})$/;
|
|
2687
|
+
/* A Tether call an agent asked the owner to allow, offered right in the thread: allow:<id> / deny:<id>. */
|
|
2688
|
+
const DEMANDE = /^(allow|deny):[0-9a-f-]{36}$/;
|
|
2687
2689
|
const COMMIT = /^commit:([a-z0-9][a-z0-9-]*)\.([0-9a-f]{7,40})$/;
|
|
2688
2690
|
function openCommits(id) {
|
|
2689
2691
|
if (DEVICE) return;
|
|
@@ -2694,7 +2696,7 @@
|
|
|
2694
2696
|
function machineLines(data) {
|
|
2695
2697
|
if (!Array.isArray(data?.messages)) return data;
|
|
2696
2698
|
const kindOf = (id) => String(id).split(':')[0];
|
|
2697
|
-
const may = (id) => (id === 'terminal' || id === 'room' ? !noTerminal() : id === 'disk' ? !DEVICE && !narrow() : (id === 'memory' || id === 'restart' || id === 'seen' || id === 'seen-done' || /^review:[a-z0-9][a-z0-9._-]*$/.test(id) || COMMITS.test(id)) && !DEVICE);
|
|
2699
|
+
const may = (id) => (id === 'terminal' || id === 'room' ? !noTerminal() : id === 'disk' ? !DEVICE && !narrow() : (id === 'memory' || id === 'restart' || id === 'seen' || id === 'seen-done' || DEMANDE.test(id) || /^review:[a-z0-9][a-z0-9._-]*$/.test(id) || COMMITS.test(id)) && !DEVICE);
|
|
2698
2700
|
const label = (id) => { const n = Number(COMMITS.exec(id)?.[4] ?? 0); return n ? (n === 1 ? 'See the commit' : `See the ${n} commits`) : ACTIONS[kindOf(id)]; };
|
|
2699
2701
|
const linksOf = (m) => {
|
|
2700
2702
|
const repo = DEVICE ? null : (m.actions ?? []).map((id) => /^review:([a-z0-9][a-z0-9-]*)$/.exec(id)?.[1]).find(Boolean);
|
|
@@ -2706,7 +2708,10 @@
|
|
|
2706
2708
|
const seenWords = seenAt ? `\u2713 Seen ${new Date(seenAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}` : '';
|
|
2707
2709
|
/* Restart, offered by a line, is offered no more once its machine was restarted after it. */
|
|
2708
2710
|
const restartedAt = data.messages.filter((m) => m.from === 'system' && m.event === 'restarted').map((m) => String(m.at ?? '')).sort().pop() ?? '';
|
|
2709
|
-
|
|
2711
|
+
/* A Tether demande decided (here, from Assets, or by the agent) is marked done in the thread,
|
|
2712
|
+
carrying its id: Accept / Refuse are then offered no more on the line that asked. */
|
|
2713
|
+
const settled = new Set(data.messages.filter((m) => m.from === 'system' && m.event === 'tether-done' && m.brief).map((m) => String(m.brief)));
|
|
2714
|
+
const actionsOf = (m) => (m.actions ?? []).filter(may).filter((id) => !(id === 'restart' && restartedAt && String(m.at ?? '') < restartedAt)).filter((id) => !(DEMANDE.test(id) && settled.has(id.slice(id.indexOf(':') + 1))))
|
|
2710
2715
|
.map((id) => (id === 'seen' && seenAt && String(m.at ?? '') <= seenAt ? { id: 'seen-done', label: seenWords } : { id, label: label(id) }));
|
|
2711
2716
|
return { ...data, messages: data.messages.map((m) => (m.from === 'system' ? { ...m, actions: actionsOf(m), links: linksOf(m) } : m)) };
|
|
2712
2717
|
}
|