clavarium 0.2.131-next.1 → 0.2.134-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/config/tools.json +1 -0
- package/npm-shrinkwrap.json +10 -10
- package/package.json +3 -3
- package/server/api.mjs +10 -0
- package/server/conversations.mjs +27 -0
- package/server/main.mjs +9 -0
- package/server/tools.mjs +3 -1
- package/web/app.js +164 -19
- package/web/index.html +5 -0
- package/web/style.css +35 -0
package/config/tools.json
CHANGED
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.134-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.134-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
|
-
"clavarium-binder": "0.1.
|
|
14
|
+
"clavarium-binder": "0.1.41-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.1",
|
|
16
16
|
"clavarium-parley": "0.17.20-next.1",
|
|
17
|
-
"clavarium-tether": "0.1.0-next.
|
|
17
|
+
"clavarium-tether": "0.1.0-next.33",
|
|
18
18
|
"mermaid": "11.17.2",
|
|
19
19
|
"node-pty": "^1.1.0",
|
|
20
20
|
"pdfjs-dist": "6.4.299",
|
|
@@ -716,9 +716,9 @@
|
|
|
716
716
|
}
|
|
717
717
|
},
|
|
718
718
|
"node_modules/clavarium-binder": {
|
|
719
|
-
"version": "0.1.
|
|
720
|
-
"resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.
|
|
721
|
-
"integrity": "sha512-
|
|
719
|
+
"version": "0.1.41-next.1",
|
|
720
|
+
"resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.41-next.1.tgz",
|
|
721
|
+
"integrity": "sha512-VmO9IR2L2Dztw3bOlrU60dXtBdYOCMQX3KdTbVh7uwhekk5aJS1QxaFstHNEd4BXE4rmX1OM+zXQu5zUG7B1jA==",
|
|
722
722
|
"license": "MIT",
|
|
723
723
|
"bin": {
|
|
724
724
|
"binder": "bin/binder.mjs",
|
|
@@ -755,9 +755,9 @@
|
|
|
755
755
|
}
|
|
756
756
|
},
|
|
757
757
|
"node_modules/clavarium-tether": {
|
|
758
|
-
"version": "0.1.0-next.
|
|
759
|
-
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.
|
|
760
|
-
"integrity": "sha512-
|
|
758
|
+
"version": "0.1.0-next.33",
|
|
759
|
+
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.33.tgz",
|
|
760
|
+
"integrity": "sha512-gcXJ1H1fYaAg5/JrXKG/yeV0RH4zNS/uUPPXPK0wLpRR0T0aHq34ZitciDoG5ZxOVRze423kTP84gVtLd3nXVw==",
|
|
761
761
|
"license": "MIT",
|
|
762
762
|
"bin": {
|
|
763
763
|
"tether": "bin/cli.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.134-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.",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@xterm/addon-fit": "^0.11.0",
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
|
-
"clavarium-binder": "0.1.
|
|
47
|
+
"clavarium-binder": "0.1.41-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.1",
|
|
49
49
|
"clavarium-parley": "0.17.20-next.1",
|
|
50
|
-
"clavarium-tether": "0.1.0-next.
|
|
50
|
+
"clavarium-tether": "0.1.0-next.33",
|
|
51
51
|
"mermaid": "11.17.2",
|
|
52
52
|
"node-pty": "^1.1.0",
|
|
53
53
|
"pdfjs-dist": "6.4.299",
|
package/server/api.mjs
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* GET /api/conversations/<name>/health what was last seen of its machine
|
|
13
13
|
* POST /api/conversations/<name>/health look now (never wakes a machine)
|
|
14
14
|
* POST /api/conversations/<name>/health/seen what it says now no longer calls its owner (Needs you)
|
|
15
|
+
* POST /api/conversations/<name>/exit-report why its tool ended: { now (read in its machine, if it runs), last (kept at its end) }
|
|
15
16
|
* POST /api/conversations/<name>/archive
|
|
16
17
|
* POST /api/conversations/<name>/ask-first {on}: its tool asks before acting (true), or acts without asking in its machine (false, the default), from its next start
|
|
17
18
|
* POST /api/conversations/<name>/resume {on}: its tool takes up its last session when it starts (true), or starts fresh
|
|
@@ -619,6 +620,15 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
619
620
|
}
|
|
620
621
|
const moved = /^\/api\/conversations\/([^/]+)\/work$/.exec(pathname);
|
|
621
622
|
if (moved) return send(202, await conversations.moveWork(decodeURIComponent(moved[1]), body.to)), true;
|
|
623
|
+
/* Why its tool ended: read now in its machine when it runs, else the last kept at its end. */
|
|
624
|
+
const exitOf = /^\/api\/conversations\/([^/]+)\/exit-report$/.exec(pathname);
|
|
625
|
+
if (exitOf) {
|
|
626
|
+
const conversation = decodeURIComponent(exitOf[1]);
|
|
627
|
+
const c = conversations.list().find((x) => x.name === conversation);
|
|
628
|
+
if (!c) throw new Refusal(404, 'No such conversation.');
|
|
629
|
+
const now = await conversations.exitReport(conversation).catch(() => null);
|
|
630
|
+
return send(200, { now, last: c.lastExit ?? null }), true;
|
|
631
|
+
}
|
|
622
632
|
/* "Seen": what its machine says now no longer calls its owner (health.mjs). */
|
|
623
633
|
const seenOf = /^\/api\/conversations\/([^/]+)\/health\/seen$/.exec(pathname);
|
|
624
634
|
if (seenOf && health) {
|
package/server/conversations.mjs
CHANGED
|
@@ -1036,6 +1036,11 @@ export class Conversations {
|
|
|
1036
1036
|
const alive = await this.#vms.exec(name, ['tmux', '-L', SOCKET, 'has-session', '-t', `=${SESSION}`]);
|
|
1037
1037
|
/* true: the tool is still there, only the channel to it dropped. */
|
|
1038
1038
|
if (alive.code === 0) return true;
|
|
1039
|
+
/* Before its machine stops (and its kernel's memory of the night with it): why the tool
|
|
1040
|
+
ended, kept on the conversation and said -- a person without access to the server
|
|
1041
|
+
sees it in Machine, and is told at once when it was cut for lack of memory. */
|
|
1042
|
+
const report = await this.exitReport(name).catch(() => null);
|
|
1043
|
+
if (report) { this.#store.patch(name, { lastExit: report }); try { this.onToolExit?.(name, report); } catch { /* telling is best effort */ } }
|
|
1039
1044
|
this.#cancelStop(name);
|
|
1040
1045
|
const timer = setTimeout(() => {
|
|
1041
1046
|
this.#timers.delete(name);
|
|
@@ -1046,6 +1051,28 @@ export class Conversations {
|
|
|
1046
1051
|
return false;
|
|
1047
1052
|
}
|
|
1048
1053
|
|
|
1054
|
+
/* WHY ITS TOOL ENDED, read inside the machine while it still runs: the kernel's kills for
|
|
1055
|
+
lack of memory since it started (with the program's name), its memory, and the last
|
|
1056
|
+
lines of the tool's own log (`logs` in config/tools.json). Read as the machine's
|
|
1057
|
+
ordinary user; dmesg through sudo when it may. Nothing is changed. */
|
|
1058
|
+
async exitReport(name) {
|
|
1059
|
+
const c = this.#store.get(name);
|
|
1060
|
+
if (!c) throw new Refusal(404, 'No such conversation.');
|
|
1061
|
+
if (await this.#vms.state(name) !== 'Running') throw new Refusal(409, 'Its machine is not running.');
|
|
1062
|
+
const tool = this.#tools.find((t) => t.id === c.tool);
|
|
1063
|
+
const logs = Array.isArray(tool?.logs) ? tool.logs.filter((d) => /^[A-Za-z0-9._/-]+$/.test(d)) : [];
|
|
1064
|
+
const script = [
|
|
1065
|
+
'( sudo -n dmesg -T 2>/dev/null || dmesg -T 2>/dev/null ) | grep -E "Killed process|Out of memory|Memory cgroup out of memory" | tail -n 4 | sed "s/^/oom /"',
|
|
1066
|
+
'awk \'/^MemTotal:/{print "memory", int($2/1024)}\' /proc/meminfo',
|
|
1067
|
+
'for d in "$@"; do f=$(ls -t "$HOME/$d"/*.log 2>/dev/null | head -1); [ -n "$f" ] && { echo "logfile $f"; tail -n 25 "$f" | cut -c1-300 | sed "s/^/log /"; }; done; true',
|
|
1068
|
+
].join('\n');
|
|
1069
|
+
const r = await this.#vms.exec(name, ['bash', '-c', script, 'report', ...logs], { timeoutMs: 20_000 });
|
|
1070
|
+
const lines = String(r.stdout ?? '').split('\n');
|
|
1071
|
+
const pick = (p) => lines.filter((l) => l.startsWith(`${p} `)).map((l) => l.slice(p.length + 1));
|
|
1072
|
+
const memoryMb = Number(pick('memory')[0]) || null;
|
|
1073
|
+
return { at: new Date().toISOString(), oom: pick('oom'), memoryMb, logFile: pick('logfile')[0] ?? null, log: pick('log') };
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1049
1076
|
/* ONE FILE OF THE MACHINE'S OWN DISK, read for the person who asked to
|
|
1050
1077
|
see it (a path on their screen, clicked). Only under /work, only a
|
|
1051
1078
|
plain path, only a regular file of a modest size; read as the
|
package/server/main.mjs
CHANGED
|
@@ -530,6 +530,15 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
530
530
|
reclaim: (name) => { events.add({ kind: 'machine', text: `Machine of ${name}: memory reclaimed (it was asleep but still held RAM)`, conversation: name }); return vms.reclaim(name).then((r) => (r.stdout || '').trim()); },
|
|
531
531
|
say: (name, text) => { try { talk.event(name, { kind: 'machine-problem', text, tone: 'warn', topic: 'Machine' }); } catch { /* its chat may be off */ } } });
|
|
532
532
|
all.room = (ask) => capacity.check(ask);
|
|
533
|
+
/* A tool that ended cut for lack of memory: said in the events, to the owner, and in its chat. */
|
|
534
|
+
all.onToolExit = (name, report) => {
|
|
535
|
+
if (!report?.oom?.length) return;
|
|
536
|
+
const size = report.memoryMb ? ` (${Math.round(report.memoryMb / 1024 * 10) / 10} GB)` : '';
|
|
537
|
+
const text = `Its tool was stopped: the machine ran out of memory${size}. Give it more in Settings → Machine → Memory, or start it fresh.`;
|
|
538
|
+
events.add({ kind: 'machine', text: `Machine of ${name}: its tool was stopped for lack of memory${size}`, conversation: name });
|
|
539
|
+
void alerts.tell({ title: `${name}: its tool ran out of memory`, body: text, url: `/?c=${encodeURIComponent(name)}&open=settings` });
|
|
540
|
+
try { talk.event(name, { kind: 'machine-problem', text, tone: 'warn', topic: 'Machine' }); } catch { /* its chat may be off */ }
|
|
541
|
+
};
|
|
533
542
|
const stopWatch = capacity.start();
|
|
534
543
|
/* The curves of the resources (history.mjs): one look a minute, from what the server knows already. */
|
|
535
544
|
const history = new History({ file: `${dataDir}/history.json` });
|
package/server/tools.mjs
CHANGED
|
@@ -98,13 +98,15 @@ export function readTools(text) {
|
|
|
98
98
|
machine's user (".claude/CLAUDE.md"): a marked block in it points
|
|
99
99
|
the tool to its guide (see guide.mjs). A plain relative path. */
|
|
100
100
|
if (t.instructions !== undefined && !INSTRUCTIONS.test(t.instructions)) throw new Error(`${t.id}: instructions is a relative path in the home, without ".."`);
|
|
101
|
+
/* Where the tool keeps its own log, read when it ends (why it stopped): folders relative to the home. */
|
|
102
|
+
if (t.logs !== undefined && (!Array.isArray(t.logs) || t.logs.some((d) => typeof d !== 'string' || !/^[A-Za-z0-9._/-]+$/.test(d) || d.startsWith('/') || d.split('/').includes('..')))) throw new Error(`${t.id}: logs is a list of folders relative to the home, without ".."`);
|
|
101
103
|
/* Optional: ITS LAUNCHER, a script of config/launch shown at /tools/launch: run at each start,
|
|
102
104
|
given the rights chosen (full, ask) then the command; it sets what the tool needs,
|
|
103
105
|
then runs it. Clavarium knows nothing more of the tool. */
|
|
104
106
|
if (t.launch !== undefined && !/^[a-z][a-z0-9-]{0,40}\.sh$/.test(t.launch)) throw new Error(`${t.id}: launch is the name of a script of config/launch, such as "${t.id}.sh"`);
|
|
105
107
|
/* Repairs an existing machine is given once (see FIXES in conversations.mjs). */
|
|
106
108
|
const fixups = t.install.includes('npm-writable') ? NPM_WRITABLE : [];
|
|
107
|
-
return Object.freeze({ id: t.id, label: t.label, ...(t.instructions ? { instructions: t.instructions } : {}), command: Object.freeze([...t.command]), ...(t.launch ? { launch: t.launch } : {}), ...(t.resume ? { resume: Object.freeze([...t.resume]) } : {}), memoryMb: t.memoryMb, ...(rights ? { rights } : {}), steps: Object.freeze(steps), fixups: Object.freeze(fixups), signin });
|
|
109
|
+
return Object.freeze({ id: t.id, label: t.label, ...(t.instructions ? { instructions: t.instructions } : {}), ...(t.logs ? { logs: Object.freeze([...t.logs]) } : {}), command: Object.freeze([...t.command]), ...(t.launch ? { launch: t.launch } : {}), ...(t.resume ? { resume: Object.freeze([...t.resume]) } : {}), memoryMb: t.memoryMb, ...(rights ? { rights } : {}), steps: Object.freeze(steps), fixups: Object.freeze(fixups), signin });
|
|
108
110
|
});
|
|
109
111
|
}
|
|
110
112
|
|
package/web/app.js
CHANGED
|
@@ -2222,6 +2222,36 @@
|
|
|
2222
2222
|
try { await post(`${API}/conversations/${encodeURIComponent(current)}/health-react`, { on: $('react-on').checked, message: $('react-message').value, command: $('react-command').value }); $('react-said').textContent = 'Saved.'; }
|
|
2223
2223
|
catch (error) { $('react-said').textContent = error.message; }
|
|
2224
2224
|
});
|
|
2225
|
+
/* WHY ITS TOOL STOPPED, said plainly: cut for lack of memory (and what to do), else its log's
|
|
2226
|
+
last lines. `last` was kept when it ended; `now` is read in the machine when it runs. */
|
|
2227
|
+
function paintToolExit(r) {
|
|
2228
|
+
const body = $('tool-exit-body'); body.replaceChildren();
|
|
2229
|
+
const rep = r?.last ?? null; const now = r?.now ?? null;
|
|
2230
|
+
if (!rep && !now) { body.hidden = !r; if (r) body.append(el('p', 'hint', 'Nothing kept yet: its tool has not ended since this was added, and its machine is not running.')); return; }
|
|
2231
|
+
body.hidden = false;
|
|
2232
|
+
const show = (title, x) => {
|
|
2233
|
+
if (!x) return;
|
|
2234
|
+
const box = el('div', 'tool-exit-one');
|
|
2235
|
+
box.append(el('p', '', [title, x.at ? new Date(x.at).toLocaleString() : ''].filter(Boolean).join(' · ')));
|
|
2236
|
+
if (x.oom?.length) {
|
|
2237
|
+
box.append(el('p', 'error', `Stopped for lack of memory: the machine${x.memoryMb ? ` (${sizeWords(x.memoryMb)})` : ''} ran out. Give it more memory below, or start its tool fresh.`));
|
|
2238
|
+
const pre = el('pre', 'tool-exit-lines'); pre.textContent = x.oom.join('\n'); box.append(pre);
|
|
2239
|
+
} else box.append(el('p', 'hint', 'No program was stopped for lack of memory.'));
|
|
2240
|
+
if (x.log?.length) {
|
|
2241
|
+
const d = document.createElement('details'); const sm = document.createElement('summary'); sm.textContent = `Last lines of its own log${x.logFile ? ` (${x.logFile.split('/').pop()})` : ''}`;
|
|
2242
|
+
const pre = el('pre', 'tool-exit-lines'); pre.textContent = x.log.join('\n'); d.append(sm, pre); box.append(d);
|
|
2243
|
+
}
|
|
2244
|
+
body.append(box);
|
|
2245
|
+
};
|
|
2246
|
+
show('Now, in its machine', now);
|
|
2247
|
+
show('When its tool last ended', rep);
|
|
2248
|
+
}
|
|
2249
|
+
$('tool-exit-look').addEventListener('click', async () => {
|
|
2250
|
+
const b = $('tool-exit-look'); b.disabled = true; b.textContent = 'Looking…';
|
|
2251
|
+
try { paintToolExit(await post(`${API}/conversations/${encodeURIComponent(current)}/exit-report`, {})); }
|
|
2252
|
+
catch (error) { $('tool-exit-body').replaceChildren(el('p', 'error', error.message)); $('tool-exit-body').hidden = false; }
|
|
2253
|
+
b.disabled = false; b.textContent = 'Why did its tool stop?';
|
|
2254
|
+
});
|
|
2225
2255
|
function paintMachine(here) {
|
|
2226
2256
|
void paintReact(here);
|
|
2227
2257
|
/* Its curves: asked again when it changes, or once in a while (paintCurves). */
|
|
@@ -2239,6 +2269,7 @@
|
|
|
2239
2269
|
fact('Works in', here.work === 'kept' ? 'a folder kept here (/work)' : 'the disk of its machine (/work)');
|
|
2240
2270
|
}
|
|
2241
2271
|
healthLines($('machine-health'), here?.health ?? null);
|
|
2272
|
+
if ($('tool-exit').dataset.of !== (here?.name ?? '')) { $('tool-exit').dataset.of = here?.name ?? ''; paintToolExit(here?.lastExit ? { last: here.lastExit } : null); }
|
|
2242
2273
|
$('machine-restarted').textContent = here?.restarted ?? ''; $('machine-restarted').hidden = !here?.restarted;
|
|
2243
2274
|
/* The choices are not painted over while somebody is choosing. */
|
|
2244
2275
|
const memory = $('machine-memory'); const disk = $('machine-disk'); const cores = $('machine-cpus');
|
|
@@ -4138,26 +4169,138 @@
|
|
|
4138
4169
|
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
4139
4170
|
if (after) await after(); else await paintAssets();
|
|
4140
4171
|
}
|
|
4141
|
-
/*
|
|
4142
|
-
|
|
4143
|
-
|
|
4172
|
+
/* ONE TETHER CALL WAITING FOR THE OWNER, AS A CARD (#190): what it does in plain words,
|
|
4173
|
+
then who / when / where in short lines, what should make one think (someone outside,
|
|
4174
|
+
a time already taken, administrator rights) in an amber band, the AI's reason in a grey
|
|
4175
|
+
line, and one row of buttons -- the act's own verb, Refuse beside it, "Always…" behind
|
|
4176
|
+
"⋯". The whole card opens its detail (the technical line too). An accept waits a few
|
|
4177
|
+
seconds with "Undo" before it goes. Built from `q.card` (Tether); a call without one
|
|
4178
|
+
keeps its line. `withWho`: name the conversation that asks. */
|
|
4179
|
+
const UNDO_MS = 5000;
|
|
4180
|
+
const dayChip = (when) => {
|
|
4181
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(when ?? ''));
|
|
4182
|
+
if (!m) return null;
|
|
4183
|
+
const d = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], 12));
|
|
4184
|
+
const chip = el('div', 'dm-day');
|
|
4185
|
+
chip.append(el('div', 'dm-day-w', d.toLocaleDateString('en-GB', { weekday: 'short', timeZone: 'UTC' }).toUpperCase()), el('div', 'dm-day-n', String(+m[3])));
|
|
4186
|
+
return chip;
|
|
4187
|
+
};
|
|
4188
|
+
const hhmm = (when) => /[T ](\d{2}:\d{2})/.exec(String(when ?? ''))?.[1] ?? '';
|
|
4189
|
+
const dayWords = (when) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(when ?? '')); return m ? new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], 12)).toLocaleDateString('en-GB', { weekday: 'long', day: 'numeric', month: 'short', timeZone: 'UTC' }) : String(when ?? ''); };
|
|
4190
|
+
const span = (from, to) => [hhmm(from), hhmm(to)].filter(Boolean).join(' – ') || [from, to].filter(Boolean).join(' – ');
|
|
4191
|
+
const nameOfAddr = (a) => { const m = /^\s*"?([^"<]*?)"?\s*<([^>]+)>/.exec(String(a ?? '')); return m && m[1] ? m[1] : String(a ?? '').split('@')[0]; };
|
|
4192
|
+
const askedAgo = (at) => { const s = Math.round((Date.now() - Date.parse(at)) / 1000); if (!Number.isFinite(s)) return ''; return s < 60 ? 'just now' : s < 3600 ? `${Math.round(s / 60)} min ago` : s < 86400 ? `${Math.round(s / 3600)} h ago` : `${Math.round(s / 86400)} d ago`; };
|
|
4193
|
+
const KIND_ICON = { mail: '✉', calendar: '📅', contacts: '👤', terminal: '⌘', files: '🗎', browser: '🌐', screen: '🖥', other: '•' };
|
|
4194
|
+
/* What a card says, from its facts: { title, day?, sub?, facts: [[icon, text|node]], quote?, risk: [], yes } */
|
|
4195
|
+
function demandeWords(q) {
|
|
4196
|
+
const c = q.card ?? {}; const about = c.about ?? {};
|
|
4197
|
+
const own = String(c.self ?? '').split('@')[1] ?? '';
|
|
4198
|
+
const outside = (list) => (own ? (list ?? []).filter((x) => !String(x).toLowerCase().endsWith(`@${own}`)) : []);
|
|
4199
|
+
const chips = (list, ext = []) => { const box = el('span', 'dm-chips'); for (const x of list ?? []) box.append(el('span', `dm-chip${ext.includes(x) ? ' ext' : ''}`, ext.includes(x) ? `${x} · outside` : x)); return box; };
|
|
4200
|
+
const w = { facts: [], risk: [], yes: 'Accept' };
|
|
4201
|
+
const subj = (s) => (s ? `“${s}”` : 'a message');
|
|
4202
|
+
const filesLine = (files) => (files?.length ? files.map((f) => `${f.name}${f.kb ? ` (${f.kb >= 1024 ? `${(f.kb / 1024).toFixed(1)} MB` : `${f.kb} KB`})` : ''}`).join(', ') : '');
|
|
4203
|
+
if (c.kind === 'mail') {
|
|
4204
|
+
const ext = outside([...(c.to ?? []), ...(c.cc ?? []), ...(c.bcc ?? [])]);
|
|
4205
|
+
if (ext.length) w.risk.push(`Goes outside: ${ext.join(', ')}`);
|
|
4206
|
+
const sendWord = c.draft ? 'Save draft' : c.at ? 'Schedule' : 'Send';
|
|
4207
|
+
if (c.action === 'send') { w.title = `${c.draft ? 'Draft' : 'Send'} ${subj(c.subject)}`; w.yes = sendWord; }
|
|
4208
|
+
else if (c.action === 'reply') { w.title = `${c.all ? 'Reply to all on' : 'Reply to'} ${about.from ? nameOfAddr(about.from) : 'a message'}`; if (about.subject) w.facts.push(['≡', `On “${about.subject}”`]); w.yes = sendWord; }
|
|
4209
|
+
else if (c.action === 'forward') {
|
|
4210
|
+
w.title = `Forward ${subj(about.subject)}`; w.yes = c.draft ? 'Save draft' : 'Forward';
|
|
4211
|
+
const k = String(c.keep ?? 'all').toLowerCase();
|
|
4212
|
+
const kept = /^(none|false|no)$/.test(k) ? 'without its files' : /^(all|true|yes|)$/.test(k) ? (about.files?.length ? `with ${filesLine(about.files)}` : 'with its files') : `keeping ${c.keep}`;
|
|
4213
|
+
w.facts.push(['📎', kept]);
|
|
4214
|
+
} else if (c.action === 'move') { w.title = `Move ${subj(about.subject)} to ${c.mailbox ?? 'a folder'}`; w.yes = 'Move'; }
|
|
4215
|
+
else if (c.action === 'flag') { w.title = `Mark ${subj(about.subject)} ${c.flag ?? ''}`.trim(); w.yes = 'Mark'; }
|
|
4216
|
+
else if (c.action === 'delete') { w.title = `Delete ${subj(about.subject)}`; w.yes = 'Delete'; }
|
|
4217
|
+
else w.title = `${c.action ?? 'mail'} ${q.detail ?? ''}`;
|
|
4218
|
+
if (about.from && c.action !== 'reply') w.facts.push(['👤', `From ${about.from}`]);
|
|
4219
|
+
if (c.to?.length) w.facts.push(['→', chips(c.to, ext)]);
|
|
4220
|
+
if (c.cc?.length) w.facts.push(['cc', chips(c.cc, ext)]);
|
|
4221
|
+
if (c.bcc?.length) w.facts.push(['bcc', chips(c.bcc, ext)]);
|
|
4222
|
+
if (c.at) w.facts.push(['⏰', `Leaves ${dayWords(c.at)}${hhmm(c.at) ? `, ${hhmm(c.at)}` : ''} — waits in Drafts until then`]);
|
|
4223
|
+
if (c.files?.length) w.facts.push(['📎', `Joined: ${filesLine(c.files)}`]);
|
|
4224
|
+
if (c.body) w.quote = c.body;
|
|
4225
|
+
} else if (c.kind === 'calendar') {
|
|
4226
|
+
const ev = c.action === 'create' ? c : { ...about, ...Object.fromEntries(Object.entries(c).filter(([k]) => ['title', 'start', 'end', 'where'].includes(k))) };
|
|
4227
|
+
const answer = { accept: 'Accept', yes: 'Accept', decline: 'Decline', no: 'Decline', refuse: 'Decline', tentative: 'Maybe', maybe: 'Maybe' }[String(c.answer ?? '').toLowerCase()] ?? '';
|
|
4228
|
+
w.day = dayChip(ev.start);
|
|
4229
|
+
w.title = c.action === 'respond' ? `${answer || 'Answer'}: ${about.title || 'an invitation'}` : c.action === 'create' ? (c.title ?? 'New event') : c.action === 'delete' ? `Delete “${about.title || 'an event'}”` : c.action === 'update' ? `Change “${about.title || c.title || 'an event'}”` : c.action === 'attach' ? `Attach ${filesLine(c.files)} to “${about.title || 'an event'}”` : `${c.action} ${q.detail ?? ''}`;
|
|
4230
|
+
if (ev.start) w.sub = `${dayWords(ev.start)} · ${span(ev.start, ev.end)}${ev.where ? ` · ${ev.where}` : ''}`;
|
|
4231
|
+
if (about.clashes?.length) w.risk.push(`Clashes with ${about.clashes.join(', ')}`);
|
|
4232
|
+
if (about.organizer && c.action === 'respond') w.facts.push(['👤', `From ${about.organizer}${about.attendees?.length ? ` · with ${about.attendees.length} people` : ''}`]);
|
|
4233
|
+
const guests = c.with ?? [];
|
|
4234
|
+
const ext = outside(guests);
|
|
4235
|
+
if (ext.length) w.risk.push(`Invites someone outside: ${ext.join(', ')}`);
|
|
4236
|
+
if (guests.length) w.facts.push(['👥', chips(guests, ext)]);
|
|
4237
|
+
if (c.online === 'teams' || (c.action === 'create' && guests.length && !c.online)) w.facts.push(['🎥', 'With a Teams meeting (Microsoft)']);
|
|
4238
|
+
if (c.notes) w.quote = c.notes;
|
|
4239
|
+
w.yes = c.action === 'respond' ? (answer || 'Answer') : c.action === 'create' ? (guests.length ? 'Create and invite' : 'Create') : c.action === 'delete' ? 'Delete' : c.action === 'update' ? 'Change' : 'Accept';
|
|
4240
|
+
} else if (c.kind === 'contacts') {
|
|
4241
|
+
w.title = c.action === 'create' ? `Add ${c.name || c.email || 'a contact'}` : c.action === 'update' ? `Update ${c.name || 'a contact'}` : c.action === 'delete' ? 'Delete a contact' : c.action === 'attach' ? 'Set a contact\'s photo' : `${c.action} ${q.detail ?? ''}`;
|
|
4242
|
+
if (c.email) w.facts.push(['✉', c.email]); if (c.phone) w.facts.push(['☎', c.phone]);
|
|
4243
|
+
w.yes = c.action === 'create' ? 'Add' : c.action === 'delete' ? 'Delete' : 'Update';
|
|
4244
|
+
} else if (c.kind === 'terminal') {
|
|
4245
|
+
w.title = c.action === 'run' ? `Run a command on ${q.target?.title ?? 'a machine'}` : c.action === 'type' ? `Type into a terminal on ${q.target?.title ?? 'a machine'}` : `Open a terminal on ${q.target?.title ?? 'a machine'}`;
|
|
4246
|
+
if (/^\s*sudo\b/.test(c.command ?? '')) w.risk.push('As administrator');
|
|
4247
|
+
if (c.command || c.text) { const code = el('code', '', c.command ?? c.text); w.facts.push(['›_', code]); }
|
|
4248
|
+
w.yes = c.action === 'run' ? 'Run' : 'Accept';
|
|
4249
|
+
} else if (c.kind === 'files') {
|
|
4250
|
+
w.title = c.action === 'write' ? `Write ${c.path}` : c.action === 'delete' ? `Delete ${c.path}` : c.action === 'move' ? `Move ${c.from} → ${c.to}` : `${c.action} ${c.path ?? ''}`;
|
|
4251
|
+
if (c.bytes !== undefined) w.facts.push(['≡', `${c.bytes >= 1024 ? `${Math.round(c.bytes / 1024)} KB` : `${c.bytes} bytes`}`]);
|
|
4252
|
+
w.yes = c.action === 'delete' ? 'Delete' : c.action === 'move' ? 'Move' : 'Write';
|
|
4253
|
+
} else if (c.kind === 'browser' && c.action === 'open') { w.title = `Open ${c.url}`; w.yes = 'Open'; }
|
|
4254
|
+
else { w.title = `${q.verb ?? 'action'}${q.detail ? ` ${q.detail}` : ''}`; }
|
|
4255
|
+
return w;
|
|
4256
|
+
}
|
|
4144
4257
|
function demandeRow(q, { withWho = false, after } = {}) {
|
|
4145
|
-
const
|
|
4146
|
-
const
|
|
4147
|
-
const
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
const
|
|
4151
|
-
if (
|
|
4152
|
-
if (
|
|
4153
|
-
|
|
4154
|
-
const
|
|
4155
|
-
const
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4258
|
+
const kind = q.card?.kind ?? String(q.verb ?? '').split('.')[0];
|
|
4259
|
+
const w = demandeWords(q);
|
|
4260
|
+
const card = el('div', `given-row demande dm-card dm-${kind}`);
|
|
4261
|
+
const top = el('div', 'dm-top');
|
|
4262
|
+
top.append(el('span', 'dm-ico', KIND_ICON[kind] ?? '•'), el('span', '', [q.target?.title, withWho ? q.agent?.name : '', askedAgo(q.at)].filter(Boolean).join(' · ')), el('span', 'dm-chev', '›'));
|
|
4263
|
+
const head = el('div', 'dm-head');
|
|
4264
|
+
if (w.day) head.append(w.day);
|
|
4265
|
+
const hw = el('div', 'dm-hw'); hw.append(el('b', 'dm-title', w.title)); if (w.sub) hw.append(el('div', 'dm-sub', w.sub)); head.append(hw);
|
|
4266
|
+
card.append(top, head);
|
|
4267
|
+
for (const r of w.risk) card.append(el('div', 'dm-risk', `⚠ ${r}`));
|
|
4268
|
+
if (w.facts.length) { const f = el('div', 'dm-facts'); for (const [ic, v] of w.facts) { f.append(el('span', 'dm-k', ic)); const cell = el('span', 'dm-v'); if (typeof v === 'string') cell.textContent = v; else cell.append(v); f.append(cell); } card.append(f); }
|
|
4269
|
+
if (w.quote) card.append(el('div', 'dm-quote', w.quote));
|
|
4270
|
+
if (q.why) card.append(el('div', 'dm-why', `Why: ${q.why}`));
|
|
4271
|
+
/* The detail: the whole card opens it -- the technical line, its level, its rule. */
|
|
4272
|
+
const more = el('div', 'dm-more'); more.hidden = true;
|
|
4273
|
+
more.append(el('div', '', `${q.verb ?? ''}${q.detail ? ` — ${q.detail}` : ''}`), el('div', 'hint', [q.target?.title, q.agent?.name, q.level ? `level ${q.level}` : ''].filter(Boolean).join(' · ')));
|
|
4274
|
+
card.append(more);
|
|
4275
|
+
card.addEventListener('click', (e) => { if (e.target.closest('button')) return; more.hidden = !more.hidden; card.classList.toggle('open', !more.hidden); });
|
|
4276
|
+
const acts = el('div', 'dm-acts');
|
|
4277
|
+
const yes = el('button', 'primary', w.yes); yes.type = 'button';
|
|
4278
|
+
const no = el('button', '', 'Refuse'); no.type = 'button';
|
|
4279
|
+
const buttons = [yes, no];
|
|
4280
|
+
let always = null;
|
|
4281
|
+
if (q.rule) {
|
|
4282
|
+
const dots = el('button', 'dm-dots', '⋯'); dots.type = 'button'; dots.setAttribute('aria-label', 'More');
|
|
4283
|
+
always = el('button', '', `Always allow ${q.rule.value ?? 'this'}`); always.type = 'button'; always.hidden = true;
|
|
4284
|
+
dots.addEventListener('click', () => { always.hidden = !always.hidden; });
|
|
4285
|
+
acts.append(dots); buttons.push(always);
|
|
4286
|
+
}
|
|
4287
|
+
acts.append(no, yes);
|
|
4288
|
+
card.append(acts);
|
|
4289
|
+
if (always) card.append(always);
|
|
4290
|
+
const lock = (on) => { for (const b of buttons) b.disabled = on; };
|
|
4291
|
+
/* Accept: a few seconds to take it back, then it goes. Refuse goes at once (nothing happens). */
|
|
4292
|
+
const accept = (decision) => {
|
|
4293
|
+
lock(true);
|
|
4294
|
+
const undo = el('div', 'dm-undo'); const ub = el('button', '', 'Undo'); ub.type = 'button';
|
|
4295
|
+
undo.append(el('span', '', decision === 'always' ? 'Allowed, and from now on' : `${w.yes} — accepted`), ub);
|
|
4296
|
+
acts.replaceWith(undo);
|
|
4297
|
+
const timer = setTimeout(() => { ub.disabled = true; void decideTether(q.id, decision, after); }, UNDO_MS);
|
|
4298
|
+
ub.addEventListener('click', () => { clearTimeout(timer); undo.replaceWith(acts); lock(false); });
|
|
4299
|
+
};
|
|
4300
|
+
yes.addEventListener('click', () => accept('yes'));
|
|
4301
|
+
always?.addEventListener('click', () => accept('always'));
|
|
4302
|
+
no.addEventListener('click', () => { lock(true); void decideTether(q.id, 'no', after); });
|
|
4303
|
+
return card;
|
|
4161
4304
|
}
|
|
4162
4305
|
/* Every call waiting for the owner, on one surface. `withWho`: name who asks. */
|
|
4163
4306
|
function demandesList(approvals, { withWho = false, after } = {}) {
|
|
@@ -5842,6 +5985,8 @@
|
|
|
5842
5985
|
const foot = el('div', 'curve-foot'); foot.append(el('span', '', curveTime(r.from, r.span)), el('span', '', 'now'));
|
|
5843
5986
|
box.append(head, plot, foot);
|
|
5844
5987
|
if (Number.isFinite(level)) box.append(el('small', 'hint curve-legend', '..... the reserve: what must stay free'));
|
|
5988
|
+
/* Said, not only on hover (a tablet has none): what a red dot is, and how many. */
|
|
5989
|
+
if (r.marks?.length) box.append(el('small', 'hint curve-legend curve-legend-oom', `● ${r.marks.length === 1 ? 'a program was' : `${r.marks.length} times a program was`} stopped for lack of memory`));
|
|
5845
5990
|
return box;
|
|
5846
5991
|
}
|
|
5847
5992
|
const curvesAt = new WeakMap();
|
package/web/index.html
CHANGED
|
@@ -165,6 +165,11 @@
|
|
|
165
165
|
<div class="chapter-body">
|
|
166
166
|
<div class="panel-top"><b>Health</b><button type="button" id="health-check">Look now</button></div>
|
|
167
167
|
<ul id="machine-health" class="health-lines" aria-live="polite"></ul>
|
|
168
|
+
<!-- WHY ITS TOOL STOPPED: kept when the tool ends, read again on demand (no server access needed). -->
|
|
169
|
+
<div id="tool-exit" class="tool-exit">
|
|
170
|
+
<div class="row"><button type="button" id="tool-exit-look">Why did its tool stop?</button></div>
|
|
171
|
+
<div id="tool-exit-body" hidden></div>
|
|
172
|
+
</div>
|
|
168
173
|
<!-- ITS CURVES: memory, CPU and disk over time (server/history.mjs). -->
|
|
169
174
|
<div class="curves" id="machine-curves" data-of="" hidden>
|
|
170
175
|
<div class="curves-head"><b>Over time</b><div class="levels curves-span" role="group" aria-label="Over"><button type="button" data-span="1h" aria-pressed="true">1 h</button><button type="button" data-span="24h" aria-pressed="false">24 h</button><button type="button" data-span="7d" aria-pressed="false">7 days</button></div></div>
|
package/web/style.css
CHANGED
|
@@ -1903,3 +1903,38 @@ details.commit > pre { margin: 6px 0 0 1.6em; white-space: pre-wrap; overflow-wr
|
|
|
1903
1903
|
#preview-body:has(> img:only-child) { display: flex; align-items: center; justify-content: center; }
|
|
1904
1904
|
#preview-body > img:only-child { max-height: 100%; width: auto; object-fit: contain; margin: 0; }
|
|
1905
1905
|
#viewer #preview-download.ico svg { width: 20px; height: 20px; }
|
|
1906
|
+
|
|
1907
|
+
/* Why its tool stopped (Machine). */
|
|
1908
|
+
.tool-exit { margin: .4rem 0 .8rem; }
|
|
1909
|
+
.tool-exit-one { margin-top: .5rem; }
|
|
1910
|
+
.tool-exit-one p { margin: .2rem 0; }
|
|
1911
|
+
.tool-exit-lines { max-height: 14rem; overflow: auto; font-size: .78rem; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel-2, rgba(127,127,127,.08)); padding: .5rem .6rem; border-radius: 8px; margin: .3rem 0; }
|
|
1912
|
+
.curve-legend-oom { color: var(--danger); }
|
|
1913
|
+
|
|
1914
|
+
/* A request of the AI as a card (#190). */
|
|
1915
|
+
.dm-card { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 12px; cursor: pointer; position: relative; }
|
|
1916
|
+
.dm-top { display: flex; gap: 8px; align-items: center; font-size: .82rem; color: var(--ink2); }
|
|
1917
|
+
.dm-ico { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: rgba(127,127,127,.15); font-size: .8rem; flex: none; }
|
|
1918
|
+
.dm-chev { margin-left: auto; font-size: 1.2rem; line-height: 1; transition: transform .15s; }
|
|
1919
|
+
.dm-card.open .dm-chev { transform: rotate(90deg); }
|
|
1920
|
+
.dm-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
|
|
1921
|
+
.dm-hw { min-width: 0; }
|
|
1922
|
+
.dm-title { font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
|
|
1923
|
+
.dm-sub { color: var(--ink2); font-size: .88rem; }
|
|
1924
|
+
.dm-day { width: 46px; flex: none; text-align: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
|
|
1925
|
+
.dm-day-w { background: var(--brass); color: #fff; font-size: .66rem; font-weight: 700; letter-spacing: .06em; padding: 1px 0; }
|
|
1926
|
+
.dm-day-n { font-size: 1.15rem; font-weight: 700; padding: 1px 0 3px; }
|
|
1927
|
+
.dm-risk { padding: 5px 9px; border-radius: 8px; background: rgba(217, 154, 30, .16); color: inherit; font-size: .86rem; font-weight: 600; }
|
|
1928
|
+
.dm-facts { display: grid; grid-template-columns: 1.6em 1fr; gap: 3px 6px; font-size: .9rem; }
|
|
1929
|
+
.dm-k { color: var(--ink2); text-align: center; }
|
|
1930
|
+
.dm-v { min-width: 0; overflow-wrap: anywhere; }
|
|
1931
|
+
.dm-chips { display: inline-flex; flex-wrap: wrap; gap: 3px; }
|
|
1932
|
+
.dm-chip { border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: .8rem; }
|
|
1933
|
+
.dm-chip.ext { border-color: rgba(217, 154, 30, .7); }
|
|
1934
|
+
.dm-quote { border-left: 3px solid var(--line); padding: 1px 9px; font-size: .88rem; white-space: pre-line; max-height: 7.5em; overflow: hidden; }
|
|
1935
|
+
.dm-card.open .dm-quote { max-height: none; }
|
|
1936
|
+
.dm-why { color: var(--ink2); font-size: .86rem; }
|
|
1937
|
+
.dm-more { font-size: .8rem; font-family: ui-monospace, monospace; overflow-wrap: anywhere; border-top: 1px dashed var(--line); padding-top: 6px; }
|
|
1938
|
+
.dm-acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
|
|
1939
|
+
.dm-acts .dm-dots { padding-inline: .7em; }
|
|
1940
|
+
.dm-undo { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: .9rem; padding: 4px 0; }
|