clavarium 0.2.144-next.1 → 0.2.146-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/gitaccess.mjs +7 -0
- package/server/gitkeeper.mjs +7 -6
- package/server/gitpush.mjs +6 -2
- package/server/main.mjs +7 -2
- package/server/talk.mjs +30 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.146-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.146-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.42-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.1",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.26-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.26-next.1",
|
|
746
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.26-next.1.tgz",
|
|
747
|
+
"integrity": "sha512-52F1VdsZ9ehStkmWzzj/hEDJ0BEkOUPyfkm1ZcopwYWvJrNIvyc9oD2z7r+S8M2BT3GTVZ020ptqgMjnSPnsBg==",
|
|
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.146-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.42-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.1",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
49
|
+
"clavarium-parley": "0.17.26-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
|
@@ -86,6 +86,13 @@ export function explain(stderr) {
|
|
|
86
86
|
/* What the remote's own hooks said (pre-receive, update: the "remote:" lines of a push), for a
|
|
87
87
|
person and for the agent: colours and control characters out, git's progress lines out, the
|
|
88
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
|
+
}
|
|
89
96
|
export const REMOTE_LINES = 20;
|
|
90
97
|
export const REMOTE_CHARS = 1500;
|
|
91
98
|
export function remoteSaid(stderr) {
|
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
|
}
|
|
@@ -609,7 +610,7 @@ export class GitKeeper {
|
|
|
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);
|
|
611
612
|
/* Refused by the remote, sent by hand: what it said is the agent's to act on too. */
|
|
612
|
-
if (error.kind === 'refused' && error.ai) this.#toAgent(name, error.ai);
|
|
613
|
+
if (error.kind === 'refused' && error.ai) this.#toAgent(name, error.ai, undefined, error.full);
|
|
613
614
|
if (error.kind === 'unknown-unreachable' && branch) this.#patch(name, { blocked: { ...(this.#record(name).blocked ?? {}), [branch]: { head, at: this.#now().toISOString() } } });
|
|
614
615
|
}
|
|
615
616
|
|
|
@@ -640,10 +641,10 @@ export class GitKeeper {
|
|
|
640
641
|
const said = held.said.get(b) ?? new Map();
|
|
641
642
|
if (said.get(conversation) === key) return;
|
|
642
643
|
said.set(conversation, key); held.said.set(b, said);
|
|
643
|
-
const { tell, ai, ...rest } = entry;
|
|
644
|
+
const { tell, ai, full, ...rest } = entry;
|
|
644
645
|
this.#log(name, { branch: b, head: tip.id, ok: false, ...(conversation ? { conversation } : {}), ...rest });
|
|
645
646
|
if (tell && this.settings(name).alert) this.#tell(`${name}: not sent`, entry.what);
|
|
646
|
-
if (ai) this.#toAgent(name, ai, conversation || undefined);
|
|
647
|
+
if (ai) this.#toAgent(name, ai, conversation || undefined, full);
|
|
647
648
|
/* A sending that the owner asked for, refused: said in that
|
|
648
649
|
conversation's chat with what to do. Not a branch outside every
|
|
649
650
|
list -- nothing was asked for it -- nor what is the repository's
|
|
@@ -734,7 +735,7 @@ export class GitKeeper {
|
|
|
734
735
|
routine notices says -- once, and once only. */
|
|
735
736
|
const grave = error instanceof GitFailure && error.alert;
|
|
736
737
|
if (grave && held.said.get(b)?.get(conversation) !== `${tip.id}:${why}`) this.#tell(`${name}: sending needs a look`, error.message);
|
|
737
|
-
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 } : {}) });
|
|
738
739
|
return false;
|
|
739
740
|
}
|
|
740
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, remoteSaid } 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 };
|
|
@@ -661,7 +661,11 @@ export class GitReview {
|
|
|
661
661
|
const hooks = remoteSaid(pushed.stderr);
|
|
662
662
|
const why = verdict || explain(pushed.stderr) || firstLine(summary);
|
|
663
663
|
const said = hooks ? `; it said: "${hooks.split('\n').join(' / ').replace(/"/g, "'")}"` : '';
|
|
664
|
-
|
|
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;
|
|
665
669
|
}
|
|
666
670
|
/* (5) The pushed commits enter the reference only as the remote's history. */
|
|
667
671
|
const after = await this.#refreshLocked(r, { branch: target, head });
|
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;
|
|
@@ -494,6 +497,32 @@ export class Talk {
|
|
|
494
497
|
return { path: `${IN_MACHINE}/${FILES}/${id}/${kept.name}`, name: kept.name, size: kept.size };
|
|
495
498
|
}
|
|
496
499
|
|
|
500
|
+
/* A TEXT THIS SERVER GIVES THE TOOL TO READ (all a git remote said when it refused a sending): put
|
|
501
|
+
where the person's files go, in a folder of its own. Resolves with where the tool finds it, or
|
|
502
|
+
null when the chat is off or its folder is not as it should be. */
|
|
503
|
+
keepText(name, fileName, text) {
|
|
504
|
+
if (!this.of(name).on) return null;
|
|
505
|
+
const own = (path) => { const i = lstatSync(path, { throwIfNoEntry: false }); return i === undefined || (i.isDirectory() && !i.isSymbolicLink()); };
|
|
506
|
+
const dir = this.#dir(name);
|
|
507
|
+
if (!lstatSync(dir, { throwIfNoEntry: false }) || !own(dir) || !own(join(dir, FILES))) return null;
|
|
508
|
+
if (!lstatSync(join(dir, FILES), { throwIfNoEntry: false })) mkdirSync(join(dir, FILES));
|
|
509
|
+
if (!own(join(dir, FILES))) return null;
|
|
510
|
+
const id = randomUUID();
|
|
511
|
+
const file = String(fileName).replace(/[^A-Za-z0-9._-]/g, '-').slice(0, 80) || 'text.txt';
|
|
512
|
+
/* Those of the same name given before go after KEPT_TEXT_DAYS, and beyond the newest KEPT_TEXTS. */
|
|
513
|
+
const before = [];
|
|
514
|
+
for (const d of readdirSync(join(dir, FILES), { withFileTypes: true })) {
|
|
515
|
+
if (!d.isDirectory()) continue;
|
|
516
|
+
const f = lstatSync(join(dir, FILES, d.name, file), { throwIfNoEntry: false });
|
|
517
|
+
if (f?.isFile() && readdirSync(join(dir, FILES, d.name)).length === 1) before.push({ name: d.name, at: f.mtimeMs });
|
|
518
|
+
}
|
|
519
|
+
before.sort((a, b) => b.at - a.at);
|
|
520
|
+
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 }); });
|
|
521
|
+
mkdirSync(join(dir, FILES, id));
|
|
522
|
+
writeFileSync(join(dir, FILES, id, file), String(text ?? ''), { flag: 'wx', mode: 0o644 });
|
|
523
|
+
return `${IN_MACHINE}/${FILES}/${id}/${file}`;
|
|
524
|
+
}
|
|
525
|
+
|
|
497
526
|
/* Whether a file (as the page opens it: "work:report.html") is one of
|
|
498
527
|
this chat: shown by the tool, cited in one of its messages (a path, a
|
|
499
528
|
picture placed in the text), or attached by the person. */
|