clavarium 0.2.92-beta.2 → 0.2.93-beta.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/gitaccess.mjs +32 -0
- package/server/gitkeeper.mjs +8 -5
- package/server/gitpush.mjs +15 -2
- package/server/health.mjs +5 -1
- package/server/main.mjs +7 -2
- package/server/talk.mjs +37 -1
- package/web/app.js +27 -2
- package/web/index.html +1 -1
- package/web/style.css +5 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.93-beta.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.93-beta.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.42-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.1",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.27-next.1",
|
|
17
17
|
"clavarium-tether": "0.1.0-next.34",
|
|
18
18
|
"mermaid": "11.17.2",
|
|
19
19
|
"node-pty": "^1.1.0",
|
|
@@ -742,9 +742,9 @@
|
|
|
742
742
|
}
|
|
743
743
|
},
|
|
744
744
|
"node_modules/clavarium-parley": {
|
|
745
|
-
"version": "0.17.
|
|
746
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
747
|
-
"integrity": "sha512-
|
|
745
|
+
"version": "0.17.27-next.1",
|
|
746
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.27-next.1.tgz",
|
|
747
|
+
"integrity": "sha512-AlMZl0BGix500UrWf2M/7fTVcOQEeGe2JHBz1sxIcKxwyy9r9mn3OTkL42hQT58Z3YkbbymRe6HDjDLEZkvKPA==",
|
|
748
748
|
"license": "MIT",
|
|
749
749
|
"bin": {
|
|
750
750
|
"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.93-beta.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.42-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.1",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
49
|
+
"clavarium-parley": "0.17.27-next.1",
|
|
50
50
|
"clavarium-tether": "0.1.0-next.34",
|
|
51
51
|
"mermaid": "11.17.2",
|
|
52
52
|
"node-pty": "^1.1.0",
|
package/server/gitaccess.mjs
CHANGED
|
@@ -83,6 +83,38 @@ export function explain(stderr) {
|
|
|
83
83
|
return String(text).trim().split('\n').filter(Boolean).pop()?.slice(0, 300) ?? '';
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/* What the remote's own hooks said (pre-receive, update: the "remote:" lines of a push), for a
|
|
87
|
+
person and for the agent: colours and control characters out, git's progress lines out, the
|
|
88
|
+
last REMOTE_LINES lines, REMOTE_CHARS characters at most. Text of the remote: data, quoted. */
|
|
89
|
+
export const REMOTE_ALL = 64 * 1024;
|
|
90
|
+
/* All of it, cleaned the same way, for a file the agent reads (REMOTE_ALL characters at most, the end kept). */
|
|
91
|
+
export function remoteAll(stderr) {
|
|
92
|
+
const text = String(stderr ?? '').split(/\r?\n|\r/).filter((l) => /^remote:/.test(l))
|
|
93
|
+
.map((l) => l.replace(/^remote:\s?/, '').replace(/\x1b\[[0-9;?]*[ -\/]*[@-~]/g, '').replace(/[\x00-\x08\x0b-\x1f\x7f]/g, '').trimEnd()).join('\n').trim();
|
|
94
|
+
return text.length > REMOTE_ALL ? `…${text.slice(-REMOTE_ALL)}` : text;
|
|
95
|
+
}
|
|
96
|
+
export const REMOTE_LINES = 20;
|
|
97
|
+
export const REMOTE_CHARS = 1500;
|
|
98
|
+
export function remoteSaid(stderr) {
|
|
99
|
+
const lines = String(stderr ?? '').split(/\r?\n|\r/)
|
|
100
|
+
.filter((l) => /^remote:/.test(l))
|
|
101
|
+
.map((l) => l.replace(/^remote:\s?/, '').replace(/\x1b\[[0-9;?]*[ -\/]*[@-~]/g, '').replace(/[\x00-\x1f\x7f]/g, '').trimEnd())
|
|
102
|
+
.filter((l) => l.trim() && !/^(Resolving deltas|Counting objects|Compressing objects|Processing changes|Total \d|Enumerating objects|Writing objects)\b/.test(l.trim()));
|
|
103
|
+
/* A very talkative hook: the lines that say what is wrong first (error, refused, must…), in their
|
|
104
|
+
order, then the end of what it said, up to REMOTE_LINES; "[N lines left out]" where lines went. */
|
|
105
|
+
let kept = lines;
|
|
106
|
+
if (lines.length > REMOTE_LINES) {
|
|
107
|
+
const telling = new Set(lines.map((l, i) => (/\b(error|errors|denied|reject|rejected|refused|must|fail|failed|failure|forbidden|invalid|not allowed|violation|required|missing|GH\d{3})\b/i.test(l) ? i : -1)).filter((i) => i >= 0).slice(0, REMOTE_LINES - 5));
|
|
108
|
+
for (let i = lines.length - 1; telling.size < REMOTE_LINES && i >= 0; i -= 1) telling.add(i);
|
|
109
|
+
const picked = [...telling].sort((a, b) => a - b);
|
|
110
|
+
kept = [];
|
|
111
|
+
picked.forEach((i, k) => { const gap = i - (k ? picked[k - 1] + 1 : 0); if (gap > 0) kept.push(`[${gap} line${gap > 1 ? 's' : ''} left out]`); kept.push(lines[i]); });
|
|
112
|
+
}
|
|
113
|
+
let text = kept.join('\n');
|
|
114
|
+
if (text.length > REMOTE_CHARS) text = `…${text.slice(-REMOTE_CHARS)}`;
|
|
115
|
+
return text;
|
|
116
|
+
}
|
|
117
|
+
|
|
86
118
|
/* An ed25519 key pair in the formats OpenSSH reads, made with Node's own
|
|
87
119
|
crypto: no program is run and nothing touches the disk. The private key is
|
|
88
120
|
the unencrypted "openssh-key-v1" container (it is encrypted by the vault). */
|
package/server/gitkeeper.mjs
CHANGED
|
@@ -396,10 +396,11 @@ export class GitKeeper {
|
|
|
396
396
|
#attached(name) { try { return Object.entries(this.#resources.list().find((x) => x.name === name)?.attachments ?? {}).filter(([, access]) => access && access !== 'none').map(([c]) => c).sort(); } catch { return []; } }
|
|
397
397
|
/* Marked as told only once somebody was: a line typed to no machine
|
|
398
398
|
(all asleep, a terminal that failed) is said again the next time. */
|
|
399
|
-
|
|
399
|
+
/* `full`: a longer text the line stands for (all a remote said), that the agent can be given to read. */
|
|
400
|
+
#toAgent(name, line, conversation, full) {
|
|
400
401
|
if (this.#record(name).toldAgent === line || this.#telling.get(name) === line) return;
|
|
401
402
|
this.#telling.set(name, line);
|
|
402
|
-
void Promise.resolve(this.#tellAgent(name, `Clavarium, repository ${name}: ${line}.`, conversation))
|
|
403
|
+
void Promise.resolve(this.#tellAgent(name, `Clavarium, repository ${name}: ${line}.`, conversation, full))
|
|
403
404
|
.then((heard) => { if (heard !== false) this.#patch(name, { toldAgent: line }); }, () => {})
|
|
404
405
|
.finally(() => { if (this.#telling.get(name) === line) this.#telling.delete(name); });
|
|
405
406
|
}
|
|
@@ -608,6 +609,8 @@ export class GitKeeper {
|
|
|
608
609
|
if (['look', 'confirm', 'busy'].includes(error.kind)) return;
|
|
609
610
|
this.#log(name, { ok: false, branch: branch ?? null, head: head ?? null, what: error.message });
|
|
610
611
|
if (error.alert) this.#tell(`${name}: sending needs a look`, error.message);
|
|
612
|
+
/* Refused by the remote, sent by hand: what it said is the agent's to act on too. */
|
|
613
|
+
if (error.kind === 'refused' && error.ai) this.#toAgent(name, error.ai, undefined, error.full);
|
|
611
614
|
if (error.kind === 'unknown-unreachable' && branch) this.#patch(name, { blocked: { ...(this.#record(name).blocked ?? {}), [branch]: { head, at: this.#now().toISOString() } } });
|
|
612
615
|
}
|
|
613
616
|
|
|
@@ -638,10 +641,10 @@ export class GitKeeper {
|
|
|
638
641
|
const said = held.said.get(b) ?? new Map();
|
|
639
642
|
if (said.get(conversation) === key) return;
|
|
640
643
|
said.set(conversation, key); held.said.set(b, said);
|
|
641
|
-
const { tell, ai, ...rest } = entry;
|
|
644
|
+
const { tell, ai, full, ...rest } = entry;
|
|
642
645
|
this.#log(name, { branch: b, head: tip.id, ok: false, ...(conversation ? { conversation } : {}), ...rest });
|
|
643
646
|
if (tell && this.settings(name).alert) this.#tell(`${name}: not sent`, entry.what);
|
|
644
|
-
if (ai) this.#toAgent(name, ai, conversation || undefined);
|
|
647
|
+
if (ai) this.#toAgent(name, ai, conversation || undefined, full);
|
|
645
648
|
/* A sending that the owner asked for, refused: said in that
|
|
646
649
|
conversation's chat with what to do. Not a branch outside every
|
|
647
650
|
list -- nothing was asked for it -- nor what is the repository's
|
|
@@ -732,7 +735,7 @@ export class GitKeeper {
|
|
|
732
735
|
routine notices says -- once, and once only. */
|
|
733
736
|
const grave = error instanceof GitFailure && error.alert;
|
|
734
737
|
if (grave && held.said.get(b)?.get(conversation) !== `${tip.id}:${why}`) this.#tell(`${name}: sending needs a look`, error.message);
|
|
735
|
-
once(why, { what: error instanceof Refusal ? error.message : 'Not sent: the sending failed.', tell: !grave, ...(error.ai ? { ai: error.ai.replace(/origin\/(\S+)/g, (m, x) => `origin/${plain(x)}`) } : {}) });
|
|
738
|
+
once(why, { what: error instanceof Refusal ? error.message : 'Not sent: the sending failed.', tell: !grave, ...(error.ai ? { ai: error.ai.replace(/origin\/(\S+)/g, (m, x) => `origin/${plain(x)}`) } : {}), ...(error.full ? { full: error.full } : {}) });
|
|
736
739
|
return false;
|
|
737
740
|
}
|
|
738
741
|
}
|
package/server/gitpush.mjs
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* password, which only ever goes back to the https origin it was given for.
|
|
28
28
|
*/
|
|
29
29
|
import { Refusal } from './conversations.mjs';
|
|
30
|
-
import { GitAccess, readAddress, explain } from './gitaccess.mjs';
|
|
30
|
+
import { GitAccess, readAddress, explain, remoteSaid, remoteAll } from './gitaccess.mjs';
|
|
31
31
|
import { GitRunner, GitFailure, EMPTY_TREE, branchProblem, protocolOf, isId } from './gitrunner.mjs';
|
|
32
32
|
|
|
33
33
|
export { branchProblem };
|
|
@@ -653,7 +653,20 @@ export class GitReview {
|
|
|
653
653
|
if (line && ours && (flag === '+' || /forced update/.test(summary))) throw new GitFailure(502, 'forced', 'The push was not as reviewed (a forced update): look at the remote.', { alert: true });
|
|
654
654
|
if (line && !ours && (flag === ' ' || flag === '*' || flag === '+')) throw new GitFailure(502, 'forced', 'The push was not as reviewed (another source): look at the remote.', { alert: true });
|
|
655
655
|
if (flag === '!' && /stale info|fetch first|non-fast-forward/.test(summary)) throw new GitFailure(409, 'remote-moved', `Not sent: the remote's ${target} moved (the lease was refused). Look again.`, { ai: `origin/${target} moved: pull origin/${target} first` });
|
|
656
|
-
if (pushed.code !== 0 || !(flag === ' ' || flag === '*'))
|
|
656
|
+
if (pushed.code !== 0 || !(flag === ' ' || flag === '*')) {
|
|
657
|
+
/* Why, as the remote put it: its verdict on our ref ("[remote rejected] (pre-receive hook
|
|
658
|
+
declined)") rather than git's closing "failed to push some refs", and what its hooks
|
|
659
|
+
said -- to the owner, and to the agent that can fix the commit. */
|
|
660
|
+
const verdict = flag === '!' && summary ? firstLine(summary) : '';
|
|
661
|
+
const hooks = remoteSaid(pushed.stderr);
|
|
662
|
+
const why = verdict || explain(pushed.stderr) || firstLine(summary);
|
|
663
|
+
const said = hooks ? `; it said: "${hooks.split('\n').join(' / ').replace(/"/g, "'")}"` : '';
|
|
664
|
+
const failure = new GitFailure(502, 'refused', `The remote refused: ${why}${said}`, { detail: hooks, ai: `the remote refused the sending to ${target}: ${why}${said}` });
|
|
665
|
+
/* All it said, when the summary left some out: put where the agent can read it (main.mjs). */
|
|
666
|
+
const all = remoteAll(pushed.stderr);
|
|
667
|
+
if (all && all !== hooks) failure.full = all;
|
|
668
|
+
throw failure;
|
|
669
|
+
}
|
|
657
670
|
/* (5) The pushed commits enter the reference only as the remote's history. */
|
|
658
671
|
const after = await this.#refreshLocked(r, { branch: target, head });
|
|
659
672
|
return sent(after.ok ? {} : { refreshed: false, note: 'Sent; the reference was not refreshed.' });
|
package/server/health.mjs
CHANGED
|
@@ -113,7 +113,11 @@ export function judge(record) {
|
|
|
113
113
|
if (!kinds && record.oomKills > 0) add('info', 'memory', 'oom', `${record.oomKills} program${record.oomKills === 1 ? ' was' : 's were'} stopped for lack of memory since it started (whether the machine or a limit of their own, it could not be told). Its files are safe.`);
|
|
114
114
|
if (record.memory && record.memory.totalMb > 0 && record.memory.availableMb < Math.max(MEMORY_LOW_MB, record.memory.totalMb * 0.05)) add('warn', 'memory', 'memory-low', `Its memory is almost full: ${record.memory.availableMb} MB free of ${record.memory.totalMb} MB.`);
|
|
115
115
|
for (const [path, d] of Object.entries(record.disks ?? {})) {
|
|
116
|
-
if (d.sizeMb > 0 && d.availableMb < Math.max(DISK_LOW_MB, d.sizeMb * 0.1))
|
|
116
|
+
if (!(d.sizeMb > 0 && d.availableMb < Math.max(DISK_LOW_MB, d.sizeMb * 0.1))) continue;
|
|
117
|
+
/* A work folder kept here is on THIS SERVER's disk: short of room, every conversation that keeps
|
|
118
|
+
one would say it at once. Noted quietly; the server's own gauge says it, once. */
|
|
119
|
+
if (path === '/') add('warn', 'disk', 'disk:/', `Its disk is almost full: ${d.availableMb} MB left of ${d.sizeMb} MB.`);
|
|
120
|
+
else add('info', 'server-disk', `disk:${path}`, `Its work folder (${path}) is kept on this server, whose disk is almost full: ${d.availableMb} MB left of ${d.sizeMb} MB.`);
|
|
117
121
|
}
|
|
118
122
|
for (const path of record.remounted ?? []) add('info', 'mount', `remounted:${path}`, `${path} had come loose in the machine: it was mounted again.`);
|
|
119
123
|
for (const { path, why } of record.failed ?? []) add('bad', 'mount', `failed:${path}`, `${path} is not reachable in the machine and could not be mounted again${why ? `: ${why}` : ''}.`);
|
package/server/main.mjs
CHANGED
|
@@ -428,11 +428,16 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
428
428
|
automatic sending to the branches the owner listed: see gitkeeper.mjs. */
|
|
429
429
|
/* What could not be read is told to the agents that write in the repository, where they can act. */
|
|
430
430
|
/* `only`: the conversation whose automatic sending it is about: its agent alone can act on it. */
|
|
431
|
-
|
|
431
|
+
/* `full`: what the line sums up (all a remote said), put in each one's chat folder for it to read. */
|
|
432
|
+
const tellAgent = async (repository, line, only, full) => {
|
|
432
433
|
const writers = Object.entries(folders.list().find((x) => x.name === repository)?.attachments ?? {}).filter(([, access]) => access === 'write').map(([conversation]) => conversation).filter((c) => only === undefined || c === only);
|
|
433
434
|
/* Told: at least one of them had the line typed (see GitKeeper #toAgent). */
|
|
434
435
|
let heard = false;
|
|
435
|
-
for (const conversation of writers)
|
|
436
|
+
for (const conversation of writers) {
|
|
437
|
+
let path = null;
|
|
438
|
+
if (full) { try { path = talk.keepText(conversation, 'git-remote-refused.txt', full); } catch { path = null; } }
|
|
439
|
+
if (await wakeups.say(conversation, path ? `${line.replace(/\.$/, '')}; all it said: ${path}.` : line) === true) heard = true;
|
|
440
|
+
}
|
|
436
441
|
return heard;
|
|
437
442
|
};
|
|
438
443
|
/* What happened to a repository is said in the chat of the conversations it is attached to (talk.mjs). */
|
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, readFileSync } from 'node:fs';
|
|
63
|
+
import { mkdirSync, lstatSync, rmSync, readFileSync, writeFileSync, readdirSync } 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';
|
|
@@ -70,6 +70,9 @@ import { isConversationName } from './names.mjs';
|
|
|
70
70
|
|
|
71
71
|
export const FOLDER = '.parley';
|
|
72
72
|
const IN_MACHINE = `/work/${FOLDER}`;
|
|
73
|
+
/* Texts this server gives the tool to read (keepText): kept this many days, this many at most of one name. */
|
|
74
|
+
export const KEPT_TEXT_DAYS = 7;
|
|
75
|
+
export const KEPT_TEXTS = 10;
|
|
73
76
|
/* A part of the thread as the page asks for it (?last=200, ?days=3, ?before=ID, ?from=ID, ?since=CURSOR): Parley's options, or null. */
|
|
74
77
|
export function partOf(query) {
|
|
75
78
|
if (!query || typeof query !== 'object') return null;
|
|
@@ -144,6 +147,7 @@ export const EVENT_LEVELS = Object.freeze({
|
|
|
144
147
|
origin: 'trace',
|
|
145
148
|
wakeup: 'trace',
|
|
146
149
|
'machine-problem': 'needs-you',
|
|
150
|
+
'machine-ok': 'news',
|
|
147
151
|
restarted: 'news',
|
|
148
152
|
/* New tools in its machine that its tool reads only when it starts: a restart recommended (main.mjs). */
|
|
149
153
|
'tools-updated': 'news',
|
|
@@ -494,6 +498,32 @@ export class Talk {
|
|
|
494
498
|
return { path: `${IN_MACHINE}/${FILES}/${id}/${kept.name}`, name: kept.name, size: kept.size };
|
|
495
499
|
}
|
|
496
500
|
|
|
501
|
+
/* A TEXT THIS SERVER GIVES THE TOOL TO READ (all a git remote said when it refused a sending): put
|
|
502
|
+
where the person's files go, in a folder of its own. Resolves with where the tool finds it, or
|
|
503
|
+
null when the chat is off or its folder is not as it should be. */
|
|
504
|
+
keepText(name, fileName, text) {
|
|
505
|
+
if (!this.of(name).on) return null;
|
|
506
|
+
const own = (path) => { const i = lstatSync(path, { throwIfNoEntry: false }); return i === undefined || (i.isDirectory() && !i.isSymbolicLink()); };
|
|
507
|
+
const dir = this.#dir(name);
|
|
508
|
+
if (!lstatSync(dir, { throwIfNoEntry: false }) || !own(dir) || !own(join(dir, FILES))) return null;
|
|
509
|
+
if (!lstatSync(join(dir, FILES), { throwIfNoEntry: false })) mkdirSync(join(dir, FILES));
|
|
510
|
+
if (!own(join(dir, FILES))) return null;
|
|
511
|
+
const id = randomUUID();
|
|
512
|
+
const file = String(fileName).replace(/[^A-Za-z0-9._-]/g, '-').slice(0, 80) || 'text.txt';
|
|
513
|
+
/* Those of the same name given before go after KEPT_TEXT_DAYS, and beyond the newest KEPT_TEXTS. */
|
|
514
|
+
const before = [];
|
|
515
|
+
for (const d of readdirSync(join(dir, FILES), { withFileTypes: true })) {
|
|
516
|
+
if (!d.isDirectory()) continue;
|
|
517
|
+
const f = lstatSync(join(dir, FILES, d.name, file), { throwIfNoEntry: false });
|
|
518
|
+
if (f?.isFile() && readdirSync(join(dir, FILES, d.name)).length === 1) before.push({ name: d.name, at: f.mtimeMs });
|
|
519
|
+
}
|
|
520
|
+
before.sort((a, b) => b.at - a.at);
|
|
521
|
+
before.forEach((x, i) => { if (i >= KEPT_TEXTS - 1 || Date.now() - x.at > KEPT_TEXT_DAYS * 86_400_000) rmSync(join(dir, FILES, x.name), { recursive: true, force: true }); });
|
|
522
|
+
mkdirSync(join(dir, FILES, id));
|
|
523
|
+
writeFileSync(join(dir, FILES, id, file), String(text ?? ''), { flag: 'wx', mode: 0o644 });
|
|
524
|
+
return `${IN_MACHINE}/${FILES}/${id}/${file}`;
|
|
525
|
+
}
|
|
526
|
+
|
|
497
527
|
/* Whether a file (as the page opens it: "work:report.html") is one of
|
|
498
528
|
this chat: shown by the tool, cited in one of its messages (a path, a
|
|
499
529
|
picture placed in the text), or attached by the person. */
|
|
@@ -549,6 +579,12 @@ export class Talk {
|
|
|
549
579
|
const before = new Set(r.machineKeys ?? []);
|
|
550
580
|
const fresh = serious.filter((p) => !before.has(p.key ?? p.text));
|
|
551
581
|
if (keys.join('|') !== (r.machineKeys ?? []).join('|')) this.#store.put({ ...r, machineKeys: keys });
|
|
582
|
+
/* What went away, said once, the machine running: the lines that asked for it ask no more (app.js). */
|
|
583
|
+
const gone = record.state === 'Running' ? [...before].filter((k) => !keys.includes(k)) : [];
|
|
584
|
+
if (gone.length) {
|
|
585
|
+
const said = [...new Set(gone.map((k) => (/^disk:/.test(k) ? 'Its disk has room again.' : k === 'memory-low' ? 'Its memory is no longer short.' : /^oom:/.test(k) ? '' : 'What was wrong with its machine is gone.')).filter(Boolean))];
|
|
586
|
+
if (said.length) this.event(name, { kind: 'machine-ok', text: said.join(' '), topic: 'Machine' });
|
|
587
|
+
}
|
|
552
588
|
if (fresh.length === 0) return;
|
|
553
589
|
this.event(name, {
|
|
554
590
|
kind: 'machine-problem',
|
package/web/app.js
CHANGED
|
@@ -338,6 +338,24 @@
|
|
|
338
338
|
keeps it open (a person who wants it open sets it once). Open only when that choice was remembered. */
|
|
339
339
|
let listFolded = true;
|
|
340
340
|
try { listFolded = localStorage.getItem('clavarium-list') !== 'open'; } catch { /* a private window */ }
|
|
341
|
+
/* PINNED OPEN (the pin at the top of the list): it stays open, even when a conversation is opened.
|
|
342
|
+
Folding it by hand takes the pin out. Kept on this device. */
|
|
343
|
+
let listPinned = false;
|
|
344
|
+
try { listPinned = localStorage.getItem('clavarium-list-pin') === 'on'; } catch { /* a private window */ }
|
|
345
|
+
if (listPinned) listFolded = false;
|
|
346
|
+
const paintPin = () => {
|
|
347
|
+
$('list-pin').setAttribute('aria-pressed', String(listPinned));
|
|
348
|
+
const label = listPinned ? 'The list stays open: click to let it fold when a conversation is opened' : 'Keep the list open: it no longer folds when a conversation is opened';
|
|
349
|
+
$('list-pin').title = label; $('list-pin').setAttribute('aria-label', listPinned ? 'Unpin the list' : 'Keep the list open');
|
|
350
|
+
};
|
|
351
|
+
const pin = (on) => {
|
|
352
|
+
listPinned = on;
|
|
353
|
+
try { localStorage.setItem('clavarium-list-pin', on ? 'on' : 'off'); } catch { /* as above */ }
|
|
354
|
+
paintPin();
|
|
355
|
+
};
|
|
356
|
+
paintPin();
|
|
357
|
+
if (DEVICE) $('list-pin').hidden = true;
|
|
358
|
+
$('list-pin').addEventListener('click', () => { pin(!listPinned); if (listPinned && listFolded) $('fold').click(); });
|
|
341
359
|
/* THE LIST SLIDES, THE PAGE IS LAID OUT ONCE. Animating the grid's columns laid the whole page out (and
|
|
342
360
|
redrew the terminal) at every frame: it stuttered. The columns change once, the room taking the whole
|
|
343
361
|
width (its far side off the screen), and the list, the menu and the room slide -- transforms, which cost
|
|
@@ -346,6 +364,7 @@
|
|
|
346
364
|
const still = () => window.matchMedia?.('(prefers-reduced-motion: reduce)').matches || window.innerWidth <= 700;
|
|
347
365
|
$('fold').addEventListener('click', async () => {
|
|
348
366
|
listFolded = !listFolded;
|
|
367
|
+
if (listFolded && listPinned) pin(false);
|
|
349
368
|
try { localStorage.setItem('clavarium-list', listFolded ? 'folded' : 'open'); } catch { /* as above */ }
|
|
350
369
|
const folded = listFolded;
|
|
351
370
|
if (still()) { applyFold(folded); fit.fit(); focusTerminal(); return; }
|
|
@@ -916,6 +935,8 @@
|
|
|
916
935
|
function select(name, { step = false } = {}) {
|
|
917
936
|
if (name !== current) { disconnect(); terminal.reset(); }
|
|
918
937
|
current = name;
|
|
938
|
+
/* The strip over the terminal is the one of the conversation now open, at once -- never the last one's until the next look. */
|
|
939
|
+
paintHealth();
|
|
919
940
|
/* What was open over the one before -- its tab, an asset, a review,
|
|
920
941
|
what was over it, a place of the menu (Access, Settings) -- gives way. */
|
|
921
942
|
const room = nav.last(['room']);
|
|
@@ -932,7 +953,7 @@
|
|
|
932
953
|
/* Opening a conversation gets the list out of the way, so its room has the room;
|
|
933
954
|
the "»" button brings the list back. Only on a real pick by the owner, never on a
|
|
934
955
|
device or when deselecting. */
|
|
935
|
-
if (step && name && !DEVICE && !listFolded) {
|
|
956
|
+
if (step && name && !DEVICE && !listFolded && !listPinned) {
|
|
936
957
|
listFolded = true;
|
|
937
958
|
try { localStorage.setItem('clavarium-list', 'folded'); } catch { /* a private window */ }
|
|
938
959
|
applyFold(true); fit.fit?.();
|
|
@@ -2756,10 +2777,13 @@
|
|
|
2756
2777
|
const seenWords = seenAt ? `\u2713 Seen ${new Date(seenAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}` : '';
|
|
2757
2778
|
/* Restart, offered by a line, is offered no more once its machine was restarted after it. */
|
|
2758
2779
|
const restartedAt = data.messages.filter((m) => m.from === 'system' && m.event === 'restarted').map((m) => String(m.at ?? '')).sort().pop() ?? '';
|
|
2780
|
+
/* A problem of its machine that went away since (machine-ok): nothing left to see or to do on its line. */
|
|
2781
|
+
const fixedAt = data.messages.filter((m) => m.from === 'system' && m.event === 'machine-ok').map((m) => String(m.at ?? '')).sort().pop() ?? '';
|
|
2782
|
+
const FIXED_GOES = new Set(['seen', 'room', 'disk', 'memory']);
|
|
2759
2783
|
/* A Tether demande decided (here, from Assets, or by the agent) is marked done in the thread,
|
|
2760
2784
|
carrying its id: Accept / Refuse are then offered no more on the line that asked. */
|
|
2761
2785
|
const settled = new Set(data.messages.filter((m) => m.from === 'system' && m.event === 'tether-done' && m.brief).map((m) => String(m.brief)));
|
|
2762
|
-
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))))
|
|
2786
|
+
const actionsOf = (m) => (m.actions ?? []).filter(may).filter((id) => !(id === 'restart' && restartedAt && String(m.at ?? '') < restartedAt)).filter((id) => !(FIXED_GOES.has(id) && fixedAt && String(m.at ?? '') < fixedAt)).filter((id) => !(DEMANDE.test(id) && settled.has(id.slice(id.indexOf(':') + 1))))
|
|
2763
2787
|
.map((id) => (id === 'seen' && seenAt && String(m.at ?? '') <= seenAt ? { id: 'seen-done', label: seenWords } : { id, label: label(id) }));
|
|
2764
2788
|
return { ...data, messages: data.messages.map((m) => (m.from === 'system' ? { ...m, actions: actionsOf(m), links: linksOf(m) } : m)) };
|
|
2765
2789
|
}
|
|
@@ -2967,6 +2991,7 @@
|
|
|
2967
2991
|
['docket-unhandled', 'Not handled', 'Told three times, never said done'],
|
|
2968
2992
|
['docket-reminder', 'Reminder set', 'A reminder the tool set itself'],
|
|
2969
2993
|
['machine-problem', 'Machine in trouble', 'Memory, disk, no answer, a failed restart'],
|
|
2994
|
+
['machine-ok', 'Machine well again', 'What was wrong with it went away'],
|
|
2970
2995
|
['restarted', 'Machine restarted', 'Restarted or built again'],
|
|
2971
2996
|
['tools-updated', 'New tools', 'After an update: a restart gives its tool all of them'],
|
|
2972
2997
|
];
|
package/web/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<link rel="stylesheet" href="/vendor/diff2html.css">
|
|
15
15
|
<div id="app" data-place="conversations">
|
|
16
16
|
<aside id="list" hidden>
|
|
17
|
-
<div class="top"><b id="list-title" title="Conversations">Clavarium</b><span class="top-acts"><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="primary">+ New</button></span></div>
|
|
17
|
+
<div class="top"><b id="list-title" title="Conversations">Clavarium</b><span class="top-acts"><button type="button" id="list-pin" class="icon-btn" aria-pressed="false" aria-label="Keep the list open" title="Keep the list open: it no longer folds when a conversation is opened"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="primary">+ New</button></span></div>
|
|
18
18
|
<!-- SEARCH, discreet: opened by the magnifier, "/" or Ctrl+K; filters as it is typed. -->
|
|
19
19
|
<div id="search" role="search" hidden><input id="search-field" type="search" placeholder="Search" aria-label="Search conversations: name, folder, identifier, tool" autocomplete="off" spellcheck="false" maxlength="60" aria-controls="items"></div>
|
|
20
20
|
<!-- Needs you and Recent: copies of rows of the list below, by when they were last used (app.js, paint). -->
|
package/web/style.css
CHANGED
|
@@ -1372,6 +1372,11 @@ select.pill { appearance: auto; }
|
|
|
1372
1372
|
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; background: transparent; border-color: transparent; color: var(--ink2); }
|
|
1373
1373
|
.icon-btn:hover, .icon-btn[aria-expanded="true"] { color: inherit; border-color: var(--line); }
|
|
1374
1374
|
.icon-btn .ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
|
|
1375
|
+
/* The pin that keeps the list open: in brass, filled, while it holds; tilted and quiet when it does not. Wide screens only (the fold is theirs). */
|
|
1376
|
+
#list-pin .ic { stroke-linejoin: round; transform: rotate(35deg); transition: transform .15s; }
|
|
1377
|
+
#list-pin[aria-pressed="true"] { color: var(--brass-ink); }
|
|
1378
|
+
#list-pin[aria-pressed="true"] .ic { transform: none; fill: currentColor; fill-opacity: .25; }
|
|
1379
|
+
@media (max-width: 700px) { #list-pin { display: none; } }
|
|
1375
1380
|
#search[hidden] { display: none; }
|
|
1376
1381
|
#search-field { width: 100%; box-sizing: border-box; padding: 6px 10px; font-size: .9rem; border-radius: 8px; }
|
|
1377
1382
|
#search-none { margin: 0 .25rem; }
|