clavarium 0.2.199-beta.1 → 0.2.200-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 +2 -2
- package/package.json +1 -1
- package/server/conversations.mjs +12 -1
- package/server/copywork.mjs +7 -2
- package/server/main.mjs +1 -1
- package/web/app.js +5 -2
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.200-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.200-beta.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/conversations.mjs
CHANGED
|
@@ -21,6 +21,8 @@ import { join } from 'node:path';
|
|
|
21
21
|
export const SESSION = 'main';
|
|
22
22
|
export const STOP_DELAY_MS = 60_000;
|
|
23
23
|
const STEP_MS = 15 * 60_000;
|
|
24
|
+
/* A size in words: 840 KB, 12 MB, 1.4 GB. */
|
|
25
|
+
const sizeWords = (bytes) => (bytes >= 1024 ** 3 ? `${(bytes / 1024 ** 3).toFixed(1)} GB` : bytes >= 1024 ** 2 ? `${Math.round(bytes / 1024 ** 2)} MB` : `${Math.round(bytes / 1024)} KB`);
|
|
24
26
|
/* The door of a conversation in a shared machine (#221), put in the machine by the server. */
|
|
25
27
|
export const DOOR = new URL('../config/machine/clavarium-enter', import.meta.url);
|
|
26
28
|
/* The most programs one conversation may run in a shared machine. */
|
|
@@ -1026,12 +1028,17 @@ export class Conversations {
|
|
|
1026
1028
|
const built = this.#store.get(to);
|
|
1027
1029
|
if (!built) return undefined; /* erased meanwhile */
|
|
1028
1030
|
if (built.phase === 'failed') throw new Error(built.error ?? 'its machine could not be made.');
|
|
1031
|
+
/* Said as it goes, once a second at most: a long copy is seen moving (13-11, "on ne sait pas si ça marche"). */
|
|
1032
|
+
let said = 0;
|
|
1033
|
+
const say = (step) => { const now = Date.now(); if (now - said < 1000) return; said = now; if (this.#store.get(to)) this.#store.patch(to, { step }); };
|
|
1029
1034
|
this.#store.patch(to, { step: 'Copying its work' });
|
|
1030
|
-
await this.copyWork(from, to);
|
|
1035
|
+
const work = await this.copyWork(from, to, (p) => say(`Copying its work: ${p.files} file${p.files === 1 ? '' : 's'}, ${sizeWords(p.bytes)}`));
|
|
1036
|
+
if (work?.files !== undefined) this.#store.patch(to, { step: `Copying its work: ${work.files} file${work.files === 1 ? '' : 's'}, ${sizeWords(work.bytes)}, done` });
|
|
1031
1037
|
if (tool.state) {
|
|
1032
1038
|
this.#store.patch(to, { step: `Copying ${tool.label}'s memory` });
|
|
1033
1039
|
const state = await this.#vms.state(from, { fresh: true }).catch(() => undefined);
|
|
1034
1040
|
if (state !== 'Running') {
|
|
1041
|
+
this.#store.patch(to, { step: `Copying ${tool.label}'s memory: waking its original` });
|
|
1035
1042
|
await this.room({ kind: 'start', name: from, memoryMb: Number(c.memoryMb) || tool.memoryMb });
|
|
1036
1043
|
/* Woken outside a wake, it is still marked asleep: borrowed, so that the server's sweep of sleepers
|
|
1037
1044
|
holding memory (capacity.mjs, reclaimSleepers) does not put it back to sleep while it is read --
|
|
@@ -1047,8 +1054,11 @@ export class Conversations {
|
|
|
1047
1054
|
let code; let child;
|
|
1048
1055
|
for (let attempt = 0; attempt < 2 && code !== 0; attempt++) {
|
|
1049
1056
|
if (attempt) await new Promise((ok) => setTimeout(ok, 10_000));
|
|
1057
|
+
this.#store.patch(to, { step: `Copying ${tool.label}'s memory` });
|
|
1050
1058
|
const out = await this.exportState(from);
|
|
1051
1059
|
child = out.child;
|
|
1060
|
+
let read = 0;
|
|
1061
|
+
out.stream.on('data', (d) => { read += d.length; say(`Copying ${tool.label}'s memory: ${sizeWords(read)} read`); });
|
|
1052
1062
|
const failed = new Promise((ok) => child.on('error', () => ok(-1)));
|
|
1053
1063
|
const file = createWriteStream(carried, { mode: 0o600 });
|
|
1054
1064
|
out.stream.pipe(file);
|
|
@@ -1061,6 +1071,7 @@ export class Conversations {
|
|
|
1061
1071
|
const started = await this.#vms.start(to);
|
|
1062
1072
|
if (started.code !== 0) throw new Error(`its machine did not start: ${firstLine(started.stderr) || `exit ${started.code}`}.`);
|
|
1063
1073
|
}
|
|
1074
|
+
this.#store.patch(to, { step: `Putting ${tool.label}'s memory in the copy` });
|
|
1064
1075
|
await this.#unpack(to, c.tool, createReadStream(carried));
|
|
1065
1076
|
}
|
|
1066
1077
|
this.#store.patch(to, { step: 'Giving it the same accesses' });
|
package/server/copywork.mjs
CHANGED
|
@@ -16,13 +16,18 @@ export function copied(path) {
|
|
|
16
16
|
return !NOT_COPIED.some((x) => p === x || p.startsWith(`${x}/`));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
/* `onProgress({ files, bytes })`: how far, as it goes (each file as it is taken) -- a long copy says so. */
|
|
20
|
+
export async function copyWorkFolder(from, to, onProgress) {
|
|
21
|
+
const done = { files: 0, bytes: 0 };
|
|
20
22
|
await cp(from, to, {
|
|
21
23
|
recursive: true, force: true, preserveTimestamps: true, verbatimSymlinks: true, errorOnExist: false,
|
|
22
24
|
filter: async (source) => {
|
|
23
25
|
if (!copied(relative(from, source))) return false;
|
|
24
26
|
const s = await lstat(source).catch(() => null);
|
|
25
|
-
|
|
27
|
+
const ok = Boolean(s && (s.isFile() || s.isDirectory() || s.isSymbolicLink()));
|
|
28
|
+
if (ok && s.isFile()) { done.files += 1; done.bytes += s.size; onProgress?.({ ...done }); }
|
|
29
|
+
return ok;
|
|
26
30
|
},
|
|
27
31
|
});
|
|
32
|
+
return done;
|
|
28
33
|
}
|
package/server/main.mjs
CHANGED
|
@@ -669,7 +669,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
669
669
|
all.room = (ask) => capacity.check(ask);
|
|
670
670
|
/* A COPY (conversations.copy): its work folder from its original's, host side -- what is its alone left out
|
|
671
671
|
(its reminders, its pending asks to the keepers, its devices, its chat's live files) -- then the same accesses. */
|
|
672
|
-
all.copyWork = (from, to) => copyWorkFolder(folders.workFolder(from), folders.workFolder(to));
|
|
672
|
+
all.copyWork = (from, to, onProgress) => copyWorkFolder(folders.workFolder(from), folders.workFolder(to), onProgress);
|
|
673
673
|
all.copyRights = async (from, to) => {
|
|
674
674
|
for (const r of folders.of(from)) {
|
|
675
675
|
if (r.access === 'write') gitKeeper?.beforeWriter(r.name, to, true);
|
package/web/app.js
CHANGED
|
@@ -368,7 +368,10 @@
|
|
|
368
368
|
const owner = conversations.find((x) => x.name === panel.of.split('/')[0]);
|
|
369
369
|
paintMlive($('notice-mlive'), owner);
|
|
370
370
|
const mline = mstepLine(owner?.machine);
|
|
371
|
-
|
|
371
|
+
/* A copy or a move, past its machine's build: what it does now (its work, its tool's memory), said as the server says it. */
|
|
372
|
+
const carrying = owner?.phase === 'building' && /^(Copying|Taking|Putting|Giving)\b/.test(owner.step ?? '') ? owner.step : '';
|
|
373
|
+
if (carrying) $('notice-title').textContent = owner.copyOf ? 'Copying it' : 'Moving it';
|
|
374
|
+
$('notice-text').textContent = mline || (carrying ? `${carrying}\u2026` : `${stepNow(p, tool)}${s >= 180 ? ` \u2014 ${usualFor(p.kind, s)}` : ''}`);
|
|
372
375
|
return true;
|
|
373
376
|
};
|
|
374
377
|
/* Shown, or brought up to date when it is shown already (its wheel keeps turning). */
|
|
@@ -1428,7 +1431,7 @@
|
|
|
1428
1431
|
const agentWho = (c) => [c.chatName, c.toolLabel ?? c.tool].filter(Boolean).join(' \u00b7 ');
|
|
1429
1432
|
function convModel(c, told = false) {
|
|
1430
1433
|
/* Under way: the step the panel shows, in its words (the tool named once). */
|
|
1431
|
-
const under = c.progress && ['building', 'restarting', 'ready'].includes(c.phase) ? stepNow(c.progress, c.toolLabel) : '';
|
|
1434
|
+
const under = c.phase === 'building' && /^(Copying|Taking|Putting|Giving)\b/.test(c.step ?? '') ? c.step : c.progress && ['building', 'restarting', 'ready'].includes(c.phase) ? stepNow(c.progress, c.toolLabel) : '';
|
|
1432
1435
|
/* What it is doing, when it says something: its tool is not named on every row. */
|
|
1433
1436
|
const now = under || (holds(c) && c.phase !== 'building' ? (c.progress.kind === 'build' ? uiSaid('set-list-starting', 'starting') : uiSaid('set-list-restarting', 'restarting')) : c.phase === 'ready' ? (c.asleep ? uiSaid('set-list-asleep', 'asleep') : '') : c.phase === 'building' ? (c.step ?? 'building') : c.phase === 'moving' ? uiSaid('set-list-moving', 'moving its work') : c.phase === 'restarting' ? uiSaid('set-list-restarting', 'restarting') : uiSaid('set-list-failed', 'failed'));
|
|
1434
1437
|
/* The line of its tool only when it says something: under way, asleep, failed -- not "Claude Code" again and again. */
|