clavarium 0.2.42-next.1 → 0.2.43-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/deploy/clavarium-host +10 -2
- package/deploy/updater.mjs +10 -6
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/conversations.mjs +18 -3
- package/server/vm.mjs +4 -2
- package/web/app.js +46 -15
- package/web/index.html +15 -1
- package/web/links.js +19 -5
- package/web/style.css +23 -7
package/deploy/clavarium-host
CHANGED
|
@@ -724,8 +724,16 @@ AREA="$1"; VERB="$2"; shift 2
|
|
|
724
724
|
|
|
725
725
|
case "$AREA $VERB" in
|
|
726
726
|
"vm launch")
|
|
727
|
-
|
|
728
|
-
|
|
727
|
+
# <vm> <memory> [<disk-gigabytes> <cores>]: the size chosen at creation;
|
|
728
|
+
# without the last two, the defaults (DISK, one core).
|
|
729
|
+
[ $# -eq 2 ] || [ $# -eq 4 ] || usage; vm_of "$1"; memory_ok "$2"
|
|
730
|
+
disk="$DISK"; cores=1
|
|
731
|
+
if [ $# -eq 4 ]; then
|
|
732
|
+
[[ "$3" =~ ^[0-9]{1,4}$ ]] && [ "$3" -ge 5 ] && [ "$3" -le "$DISK_MAX_GB" ] || refuse "disk out of bounds: $3"
|
|
733
|
+
[[ "$4" =~ ^[0-9]{1,3}$ ]] && [ "$4" -ge 1 ] && [ "$4" -le "$(nproc)" ] || refuse "cores out of bounds: $4 (the host has $(nproc))"
|
|
734
|
+
disk="${3}G"; cores="$4"
|
|
735
|
+
fi
|
|
736
|
+
run "$MULTIPASS" launch "$IMAGE" --name "$1" --memory "${2}M" --disk "$disk" --cpus "$cores" --timeout "$LAUNCH_SECONDS" ;;
|
|
729
737
|
"vm clone")
|
|
730
738
|
# <shelf> <vm> <memory>: a conversation's machine, copied from the
|
|
731
739
|
# ready-made one (which must be stopped: Multipass refuses otherwise).
|
package/deploy/updater.mjs
CHANGED
|
@@ -274,7 +274,7 @@ export class Updater {
|
|
|
274
274
|
this.restart = restart ?? (() => this.#restart());
|
|
275
275
|
/* What was seen when the server did not come up: its journal, its unit, who holds its port. */
|
|
276
276
|
this.diagnose = diagnose ?? (() => this.#diagnose());
|
|
277
|
-
this.health = health ?? ((release) => this.#health(release));
|
|
277
|
+
this.health = health ?? ((release, opts) => this.#health(release, opts));
|
|
278
278
|
this.backup = backup ?? ((app) => this.#backup(app));
|
|
279
279
|
this.restoreData = restoreData ?? ((app, archive) => this.#restoreData(app, archive));
|
|
280
280
|
this.installPrivileged = installPrivileged ?? ((app) => this.#installPrivileged(app));
|
|
@@ -606,13 +606,16 @@ export class Updater {
|
|
|
606
606
|
await this.installPrivileged(release.app);
|
|
607
607
|
} catch (error) { return `it could not be put in place: ${error.message}`; }
|
|
608
608
|
this.#step(action, version, 'Restarting');
|
|
609
|
-
|
|
609
|
+
/* Once the new server answers, the maintenance page is gone but a minute or two of
|
|
610
|
+
watching that it stays up is left: said as "Confirming", not "Restarting", so a page
|
|
611
|
+
back up does not look stuck restarting (deploy/updater.mjs, #health onUp). */
|
|
612
|
+
return this.#restartAndCheck(release, () => this.#step(action, version, 'Confirming'));
|
|
610
613
|
}
|
|
611
614
|
/* '' when it came up, or why not. */
|
|
612
|
-
async #restartAndCheck(release) {
|
|
615
|
+
async #restartAndCheck(release, onUp) {
|
|
613
616
|
const r = await this.restart().catch((e) => ({ code: 1, stderr: e.message }));
|
|
614
617
|
if (r?.code) return `the server did not restart: ${lastLine(r)}`;
|
|
615
|
-
const h = await this.health(release).catch((e) => e.message || 'no answer');
|
|
618
|
+
const h = await this.health(release, { onUp }).catch((e) => e.message || 'no answer');
|
|
616
619
|
return h || '';
|
|
617
620
|
}
|
|
618
621
|
|
|
@@ -802,7 +805,7 @@ export class Updater {
|
|
|
802
805
|
|
|
803
806
|
/* Comes up (answers, from this release) within healthMs, then STAYS up: watched until watchMs after
|
|
804
807
|
the restart; one restart by systemd is forgiven if it answers at the end, not two. */
|
|
805
|
-
async #health(release) {
|
|
808
|
+
async #health(release, { onUp } = {}) {
|
|
806
809
|
const { clock, sleep } = this.#o;
|
|
807
810
|
const start = clock();
|
|
808
811
|
const target = realpathSync(release.dir);
|
|
@@ -820,7 +823,8 @@ export class Updater {
|
|
|
820
823
|
if (clock() - start > this.#o.healthMs) return said;
|
|
821
824
|
await sleep(1000);
|
|
822
825
|
}
|
|
823
|
-
/*
|
|
826
|
+
/* It answers, from this release: the maintenance page gives way. Now it must stay up. */
|
|
827
|
+
onUp?.();
|
|
824
828
|
const until = Math.max(start + this.#o.watchMs, clock() + this.#o.settleMs);
|
|
825
829
|
let restarts = 0;
|
|
826
830
|
while (clock() < until) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43-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.43-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
|
-
"clavarium-binder": "0.1.
|
|
14
|
+
"clavarium-binder": "0.1.8-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.1",
|
|
16
16
|
"clavarium-parley": "0.17.4-next.1",
|
|
17
17
|
"mermaid": "11.17.2",
|
|
@@ -688,9 +688,9 @@
|
|
|
688
688
|
}
|
|
689
689
|
},
|
|
690
690
|
"node_modules/clavarium-binder": {
|
|
691
|
-
"version": "0.1.
|
|
692
|
-
"resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.
|
|
693
|
-
"integrity": "sha512-
|
|
691
|
+
"version": "0.1.8-next.1",
|
|
692
|
+
"resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.8-next.1.tgz",
|
|
693
|
+
"integrity": "sha512-0ZvTgn4z3IzLWjVyt5H82tnrE4g4Zdh0eb0kKrpVYjJ8vEfun6CmzHFclce9lb7vH+CC5ozKETuTAmSVYkk+lg==",
|
|
694
694
|
"license": "MIT",
|
|
695
695
|
"bin": {
|
|
696
696
|
"binder": "bin/binder.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43-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.",
|
|
@@ -44,7 +44,7 @@
|
|
|
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.8-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.1",
|
|
49
49
|
"clavarium-parley": "0.17.4-next.1",
|
|
50
50
|
"mermaid": "11.17.2",
|
package/server/conversations.mjs
CHANGED
|
@@ -260,7 +260,7 @@ export class Conversations {
|
|
|
260
260
|
return { name: id, title: title !== undefined && title !== id ? title : undefined };
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
create({ name: given, title: read, tool, memoryMb, workOnDisk, group }) {
|
|
263
|
+
create({ name: given, title: read, tool, memoryMb, cpus, diskGb, workOnDisk, group }) {
|
|
264
264
|
const { name, title } = this.#naming({ name: given, title: read });
|
|
265
265
|
if (group !== undefined) { const problem = groupProblem(group); if (problem) throw new Refusal(400, problem); }
|
|
266
266
|
if (!isConversationName(name)) throw new Refusal(400, 'A name is 1 to 32 lower-case letters, digits or hyphens; it starts with a letter and does not end with a hyphen.');
|
|
@@ -270,9 +270,14 @@ export class Conversations {
|
|
|
270
270
|
if (!Number.isInteger(memory) || memory < chosen.memoryMb || memory > 16384) {
|
|
271
271
|
throw new Refusal(400, `This tool needs at least ${chosen.memoryMb} MB of memory.`);
|
|
272
272
|
}
|
|
273
|
+
/* Cores and disk, chosen at creation like the memory; their defaults when not given. */
|
|
274
|
+
const cores = cpus ?? 1;
|
|
275
|
+
if (!Number.isInteger(cores) || cores < 1 || cores > availableParallelism()) throw new Refusal(400, `Cores are 1 to ${availableParallelism()} (what this server has).`);
|
|
276
|
+
const disk = diskGb ?? DISK_GB;
|
|
277
|
+
if (!Number.isInteger(disk) || disk < DISK_GB || disk > DISK_MAX_GB) throw new Refusal(400, `Disk is ${DISK_GB} to ${DISK_MAX_GB} GB.`);
|
|
273
278
|
if (this.#store.get(name)) throw new Refusal(409, 'A conversation already has this name.');
|
|
274
279
|
const now = new Date().toISOString();
|
|
275
|
-
const conversation = { name, ...(title ? { title } : {}), ...(group ? { group } : {}), tool, memoryMb: memory, diskGb:
|
|
280
|
+
const conversation = { name, ...(title ? { title } : {}), ...(group ? { group } : {}), tool, memoryMb: memory, cpus: cores, diskGb: disk, fixed: FIXES, work: workOnDisk === true ? 'disk' : 'kept', phase: 'building', step: 'Starting the machine', createdAt: now, buildingSince: now, progress: buildProgress(now) };
|
|
276
281
|
/* A new one comes first in its folder (or first of those in none). */
|
|
277
282
|
const { order, groups } = this.#order();
|
|
278
283
|
this.#store.put(conversation);
|
|
@@ -284,6 +289,11 @@ export class Conversations {
|
|
|
284
289
|
/* `again`: a machine built anew for a conversation that had one. */
|
|
285
290
|
async #build(name, tool, memoryMb, again = false) {
|
|
286
291
|
const fail = (what, r) => { this.#store.patch(name, { phase: 'failed', step: undefined, progress: undefined, error: `${what}: ${firstLine(r.stderr) || firstLine(r.stdout) || `exit ${r.code}`}` }); };
|
|
292
|
+
/* The size chosen at creation (stored by create, kept on a rebuild): launched with it, or, for a
|
|
293
|
+
copy of a ready-made machine, brought to it while the copy is still stopped. */
|
|
294
|
+
const made = this.#store.get(name);
|
|
295
|
+
const diskGb = made?.diskGb ?? DISK_GB; const cpus = made?.cpus ?? 1;
|
|
296
|
+
const custom = diskGb !== DISK_GB || cpus !== 1;
|
|
287
297
|
/* A COPY OF THE READY-MADE MACHINE when there is one that holds this
|
|
288
298
|
tool (see shelf.mjs): it only has to boot. Anything wrong with the
|
|
289
299
|
copy -- an older VM manager without "clone", a copy that does not
|
|
@@ -293,13 +303,18 @@ export class Conversations {
|
|
|
293
303
|
let readyMade = false;
|
|
294
304
|
if (from) {
|
|
295
305
|
const cloned = await this.#vms.clone(name, from, memoryMb);
|
|
306
|
+
if (cloned.code === 0 && custom) {
|
|
307
|
+
/* Still stopped, like the memory the clone set: its cores, and its disk grown to the chosen size. */
|
|
308
|
+
if (cpus !== 1) await this.#vms.setCpus(name, cpus).catch(() => {});
|
|
309
|
+
if (diskGb !== DISK_GB) await this.#vms.setDisk(name, diskGb).catch(() => {});
|
|
310
|
+
}
|
|
296
311
|
const started = cloned.code === 0 ? await this.#vms.start(name) : cloned;
|
|
297
312
|
readyMade = started.code === 0;
|
|
298
313
|
if (!readyMade && await this.#vms.state(name, { fresh: true }) !== undefined) await this.#vms.remove(name);
|
|
299
314
|
if (!this.#store.get(name)) return undefined; /* archived meanwhile */
|
|
300
315
|
}
|
|
301
316
|
if (!readyMade) {
|
|
302
|
-
const launched = await this.#vms.launch(name, memoryMb);
|
|
317
|
+
const launched = await this.#vms.launch(name, memoryMb, custom ? diskGb : undefined, custom ? cpus : undefined);
|
|
303
318
|
if (launched.code !== 0) return fail('The machine did not start', launched);
|
|
304
319
|
}
|
|
305
320
|
this.#store.patch(name, { step: 'Preparing the machine', readyMade: readyMade || undefined });
|
package/server/vm.mjs
CHANGED
|
@@ -93,8 +93,10 @@ export class Vms {
|
|
|
93
93
|
return this.#asking;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
launch(conversation, memoryMb) {
|
|
97
|
-
|
|
96
|
+
launch(conversation, memoryMb, diskGb, cpus) {
|
|
97
|
+
/* The disk and cores go with the memory only when they are the chosen size, not the defaults. */
|
|
98
|
+
const size = diskGb && cpus ? [String(diskGb), String(cpus)] : [];
|
|
99
|
+
return this.run(['vm', 'launch', vmName(conversation), String(memoryMb), ...size], { timeoutMs: (LAUNCH_SECONDS + 60) * 1000 });
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
/* The machine of a conversation as a COPY of the ready-made one (see
|
package/web/app.js
CHANGED
|
@@ -111,8 +111,10 @@
|
|
|
111
111
|
$('notice-spin').hidden = true; $('notice-steps').hidden = true;
|
|
112
112
|
$('notice-head').hidden = true; delete notice.dataset.progress; delete notice.dataset.loading;
|
|
113
113
|
};
|
|
114
|
-
/* A terminal on its way: a neutral word and the wheel, nothing that sounds like a fault.
|
|
115
|
-
|
|
114
|
+
/* A terminal on its way: a neutral word and the wheel, nothing that sounds like a fault. It
|
|
115
|
+
covers only when the terminal is what is on screen -- not the chat already there, which a tab
|
|
116
|
+
resume (its channel reopened) used to blank behind "Loading the terminal..." (found 26-10). */
|
|
117
|
+
const loading = () => { if (tabNow() !== 'terminal') return; show('Loading the terminal\u2026'); $('notice-spin').hidden = false; notice.dataset.loading = 'yes'; };
|
|
116
118
|
/* A restart: when the page first saw it (when the server did not say), and the clock that tells it. */
|
|
117
119
|
const restartSeen = new Map(); let restartTicking = 0;
|
|
118
120
|
/* A START TOLD STEP BY STEP (a build, a restart, a wake: `progress`, see
|
|
@@ -833,6 +835,11 @@
|
|
|
833
835
|
if (noTerminal()) $('files-open').hidden = deviceShared.length === 0;
|
|
834
836
|
$('sleep').hidden = !usable || c.asleep === true;
|
|
835
837
|
$('restart').hidden = DEVICE || !usable;
|
|
838
|
+
/* The same gestures, surfaced at the top of the panel: wake when asleep, else restart and sleep. */
|
|
839
|
+
$('quick-sleep').hidden = !usable || c.asleep === true;
|
|
840
|
+
$('quick-restart').hidden = DEVICE || !usable;
|
|
841
|
+
$('quick-wake').hidden = !c || c.asleep !== true;
|
|
842
|
+
$('panel-actions').hidden = DEVICE || !c || !(usable || c.asleep === true);
|
|
836
843
|
/* Its own sheet is there as soon as it exists: archiving one that failed is done from it. */
|
|
837
844
|
$('folders').hidden = DEVICE || !c;
|
|
838
845
|
}
|
|
@@ -959,17 +966,21 @@
|
|
|
959
966
|
full -- not marked "Seen"; a program stopped for lack of memory (its files safe) is only said. */
|
|
960
967
|
const healthNeeds = (c) => c.phase === 'ready' && !c.asleep && (c.health?.problems ?? []).some((p) => (p.level === 'bad' || (p.level === 'warn' && ['memory', 'disk'].includes(p.kind) && !String(p.key).startsWith('oom:'))) && !(c.health.seen ?? []).includes(p.key));
|
|
961
968
|
const needsYou = (c) => Boolean(talkNeeds(c) || c.answerer?.needs || c.phase === 'failed' || healthNeeds(c));
|
|
962
|
-
/* ONE
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
const
|
|
969
|
+
/* ONE FLAT POINT per conversation, its colour the state -- the worst that applies: a machine problem (red),
|
|
970
|
+
the agent waits for you (blue), the agent at work (gold, pulsing), the machine busy (amber, pulsing),
|
|
971
|
+
fine (green), asleep (a hollow ring). The same point, same colours, sums a folded group below. */
|
|
972
|
+
const machineState = (c) => (c.asleep ? 'off' : (c.phase === 'failed' || healthNeeds(c)) ? 'problem'
|
|
973
|
+
: (holds(c) || ['building', 'restarting', 'moving'].includes(c.phase)) ? 'busy' : 'online');
|
|
974
|
+
const agentState = (c) => (c.asleep ? 'sleep' : (talkNeeds(c) || c.answerer?.needs) ? 'wait'
|
|
975
|
+
: c.talk?.state === 'working' ? 'work' : c.talk?.state === 'done' ? 'done' : 'idle');
|
|
976
|
+
const STATE_WORDS = { problem: 'a problem', wait: 'waits for you', work: 'at work', busy: 'busy', ok: 'fine', sleep: 'asleep' };
|
|
977
|
+
const rollup = (c) => { const m = machineState(c); const a = agentState(c);
|
|
978
|
+
return (m === 'off' ? 'sleep' : m === 'problem' ? 'problem' : a === 'wait' ? 'wait' : a === 'work' ? 'work' : m === 'busy' ? 'busy' : 'ok'); };
|
|
966
979
|
const statePoint = (state) => { const d = document.createElement('span'); d.className = 'state-dot'; d.dataset.state = state; return d; };
|
|
967
|
-
|
|
968
|
-
there keeps at least one, the worst first -- and the same in words for a screen reader and the pointer. */
|
|
969
|
-
const STATE_ORDER = ['need', 'watch', 'ok', 'sleep'];
|
|
980
|
+
const STATE_ORDER = ['problem', 'wait', 'work', 'busy', 'ok', 'sleep'];
|
|
970
981
|
function stateSummary(list) {
|
|
971
982
|
const count = Object.fromEntries(STATE_ORDER.map((k) => [k, 0]));
|
|
972
|
-
for (const c of list) count[
|
|
983
|
+
for (const c of list) count[rollup(c)] += 1;
|
|
973
984
|
const slots = Math.min(4, list.length);
|
|
974
985
|
const present = STATE_ORDER.filter((k) => count[k] > 0);
|
|
975
986
|
const got = Object.fromEntries(STATE_ORDER.map((k) => [k, 0]));
|
|
@@ -1048,7 +1059,7 @@
|
|
|
1048
1059
|
b.append(when); b.dataset.when = 'true';
|
|
1049
1060
|
} else b.append(title, ...(plain ? [] : [sub]));
|
|
1050
1061
|
/* Its state: one point, on the right. */
|
|
1051
|
-
const point = statePoint(
|
|
1062
|
+
const point = statePoint(rollup(c)); point.title = STATE_WORDS[point.dataset.state]; b.append(point);
|
|
1052
1063
|
/* Found by a search while hidden: said. */
|
|
1053
1064
|
if (c.hidden === true && query) { const mark = document.createElement('small'); mark.className = 'shared-mark'; mark.textContent = 'hidden'; b.append(mark); }
|
|
1054
1065
|
/* Several models answer its simple questions; or they stopped, and it waits for its owner. */
|
|
@@ -1125,7 +1136,9 @@
|
|
|
1125
1136
|
/* One in Needs you just above is not said twice. */
|
|
1126
1137
|
/* The last day only: what is older is found in its group. */
|
|
1127
1138
|
const dayAgo = Date.now() - 24 * 3600_000;
|
|
1128
|
-
|
|
1139
|
+
/* Asleep ones go to the bottom of Recent: they are frozen, not what you came back to. */
|
|
1140
|
+
const recent = conversations.filter((c) => (c.hidden !== true || c.name === current) && !needsYou(c) && activityOf(c) >= dayAgo)
|
|
1141
|
+
.sort((a, b) => (Number(a.asleep === true) - Number(b.asleep === true)) || (activityOf(b) - activityOf(a)));
|
|
1129
1142
|
const few = 4;
|
|
1130
1143
|
if (recent.length && groups.length && section(RECENT, 'Recent', recent)) {
|
|
1131
1144
|
top.append(...unfolding(RECENT, recent.slice(0, showAllRecent ? recent.length : few).map((c) => itemButton(c, true))));
|
|
@@ -1420,6 +1433,15 @@
|
|
|
1420
1433
|
select.replaceChildren(...mems.map((m) => { const o = document.createElement('option'); o.value = String(m); o.textContent = sizeWords(m); return o; }));
|
|
1421
1434
|
select.value = String(mems.includes(was) ? was : least);
|
|
1422
1435
|
$('newconv-memory-least').textContent = tool ? `${tool.label} needs ${sizeWords(least)} at least` : '';
|
|
1436
|
+
/* Cores: 1 to what this server has (learnt from any machine we know), default 1. */
|
|
1437
|
+
const hostCpus = Math.max(1, ...conversations.map((c) => c.hostCpus ?? 1));
|
|
1438
|
+
const cpus = $('newconv-cpus'); const wasCpus = Number(cpus.value) || 1;
|
|
1439
|
+
cpus.replaceChildren(...Array.from({ length: hostCpus }, (_, i) => i + 1).map((n) => { const o = document.createElement('option'); o.value = String(n); o.textContent = `${n}${n === 1 ? ' (default)' : ''}${n === hostCpus && n > 1 ? ' (all of this server)' : ''}`; return o; }));
|
|
1440
|
+
cpus.value = String(wasCpus <= hostCpus ? wasCpus : 1);
|
|
1441
|
+
/* Disk: from the default up; it only grows afterwards. */
|
|
1442
|
+
const disk = $('newconv-disk'); const wasDisk = Number(disk.value) || 8;
|
|
1443
|
+
disk.replaceChildren(...DISK_CHOICES.map((d) => { const o = document.createElement('option'); o.value = String(d); o.textContent = `${d} GB${d === 8 ? ' (default)' : ''}`; return o; }));
|
|
1444
|
+
disk.value = String(DISK_CHOICES.includes(wasDisk) ? wasDisk : 8);
|
|
1423
1445
|
}
|
|
1424
1446
|
function paintNewTools() {
|
|
1425
1447
|
const box = $('newconv-tools');
|
|
@@ -1490,10 +1512,11 @@
|
|
|
1490
1512
|
if (id && !ID_SHAPE.test(id)) { newError('id', 'Lower-case letters, digits, hyphens'); return; }
|
|
1491
1513
|
const least = newTools.find((t) => t.id === chosenTool)?.memoryMb;
|
|
1492
1514
|
const memoryMb = Number($('newconv-memory').value);
|
|
1515
|
+
const cpus = Number($('newconv-cpus').value); const diskGb = Number($('newconv-disk').value);
|
|
1493
1516
|
newError('', '');
|
|
1494
1517
|
creating = true; $('newconv-create').disabled = true;
|
|
1495
1518
|
try {
|
|
1496
|
-
const made = await post(`${API}/conversations`, { title, ...(id ? { name: id } : {}), ...(group ? { group } : {}), tool: chosenTool, workOnDisk: newOnDisk(), ...(memoryMb && memoryMb !== least ? { memoryMb } : {}) });
|
|
1519
|
+
const made = await post(`${API}/conversations`, { title, ...(id ? { name: id } : {}), ...(group ? { group } : {}), tool: chosenTool, workOnDisk: newOnDisk(), ...(memoryMb && memoryMb !== least ? { memoryMb } : {}), ...(cpus && cpus !== 1 ? { cpus } : {}), ...(diskGb && diskGb !== 8 ? { diskGb } : {}) });
|
|
1497
1520
|
$('newconv-name').value = ''; $('newconv-id').value = ''; $('newconv-id').placeholder = 'website-redesign'; $('newconv-group').value = '';
|
|
1498
1521
|
$('newconv-work').querySelector('[data-work="kept"]').click(); $('newconv-more').open = false;
|
|
1499
1522
|
await refresh();
|
|
@@ -1672,6 +1695,9 @@
|
|
|
1672
1695
|
function paintViews() {
|
|
1673
1696
|
if (DEVICE) return;
|
|
1674
1697
|
const now = tabNow();
|
|
1698
|
+
/* The "Loading the terminal..." veil belongs to the terminal: leaving it for the chat (or
|
|
1699
|
+
any other tab) takes the veil away, so a tab already there is not covered. */
|
|
1700
|
+
if (notice.dataset.loading && now !== 'terminal') notice.hidden = true;
|
|
1675
1701
|
for (const [id, tab] of [['view-chat', 'chat'], ['view-terminal', 'terminal'], ['view-assets', 'assets'], ['view-lists', 'lists'], ['folders', 'settings']]) $(id).setAttribute('aria-pressed', String(now === tab));
|
|
1676
1702
|
}
|
|
1677
1703
|
/* THE FOUR TABS: Chat, Terminal, Assets, Settings. The one it opened on
|
|
@@ -7707,7 +7733,7 @@
|
|
|
7707
7733
|
$('share-done').addEventListener('click', leaveCompose);
|
|
7708
7734
|
|
|
7709
7735
|
/* ---------- resting and archiving ---------- */
|
|
7710
|
-
|
|
7736
|
+
async function sleepMachine() {
|
|
7711
7737
|
const name = current;
|
|
7712
7738
|
leavePanel();
|
|
7713
7739
|
disconnect();
|
|
@@ -7715,7 +7741,12 @@
|
|
|
7715
7741
|
show('Going to sleep...');
|
|
7716
7742
|
try { await post(`${API}/conversations/${encodeURIComponent(name)}/sleep`); await refresh(); enter(); }
|
|
7717
7743
|
catch (error) { say('awake', 'ended'); show(error.message, 'Back to the terminal', connect); }
|
|
7718
|
-
}
|
|
7744
|
+
}
|
|
7745
|
+
$('sleep').addEventListener('click', () => void sleepMachine());
|
|
7746
|
+
/* The quick actions at the top of the panel do the same as the Machine chapter's. */
|
|
7747
|
+
$('quick-sleep').addEventListener('click', () => void sleepMachine());
|
|
7748
|
+
$('quick-restart').addEventListener('click', () => { leavePanel(); void restartMachine(false); });
|
|
7749
|
+
$('quick-wake').addEventListener('click', () => { leavePanel(); seeTerminal(); });
|
|
7719
7750
|
async function rebuild() {
|
|
7720
7751
|
const name = current;
|
|
7721
7752
|
disconnect();
|
package/web/index.html
CHANGED
|
@@ -111,6 +111,12 @@
|
|
|
111
111
|
<div id="clists" class="sheet as-room" hidden><div id="clists-binder" class="binder-holder"></div></div>
|
|
112
112
|
<div id="panel" class="sheet" hidden>
|
|
113
113
|
<div class="panel-top"><b id="panel-title">This conversation</b></div>
|
|
114
|
+
<!-- The gestures done often on the machine, without opening the Machine chapter (app.js, paintMachine). -->
|
|
115
|
+
<div class="row panel-actions" id="panel-actions" hidden>
|
|
116
|
+
<button type="button" id="quick-wake" class="primary" hidden>Wake it</button>
|
|
117
|
+
<button type="button" id="quick-restart" hidden>Restart…</button>
|
|
118
|
+
<button type="button" id="quick-sleep" hidden title="Freezes the tool as it is; it wakes when you open the conversation">Sleep</button>
|
|
119
|
+
</div>
|
|
114
120
|
<p id="panel-error" class="error" role="alert" hidden></p>
|
|
115
121
|
<details class="chapter" id="chapter-general" data-chapter="general">
|
|
116
122
|
<summary><span class="chapter-title">General</span><span class="chapter-about">Name, group, chat.</span></summary>
|
|
@@ -372,6 +378,12 @@
|
|
|
372
378
|
<!-- THE MAP (once "Who gets what"): every device, conversation and asset, and the rights between them (links.js). -->
|
|
373
379
|
<div id="links" class="pane">
|
|
374
380
|
<div id="links-legend" class="lk-legend"></div>
|
|
381
|
+
<!-- The column filters, kept out of the board's zoom so a crowded map does not shrink them (links.js). -->
|
|
382
|
+
<div id="links-filters" class="lk-filters">
|
|
383
|
+
<label class="lk-filter"><span>Devices</span><input type="search" class="lk-find" data-k="device" placeholder="Filter…" aria-label="Filter devices"></label>
|
|
384
|
+
<label class="lk-filter"><span>Conversations</span><input type="search" class="lk-find" data-k="conversation" placeholder="Filter…" aria-label="Filter conversations"></label>
|
|
385
|
+
<label class="lk-filter"><span>Assets</span><input type="search" class="lk-find" data-k="asset" placeholder="Filter…" aria-label="Filter assets"></label>
|
|
386
|
+
</div>
|
|
375
387
|
<p id="links-hint" class="hint" aria-live="polite"></p>
|
|
376
388
|
<p id="links-error" class="error" role="alert" hidden></p>
|
|
377
389
|
<div id="links-card" class="lk-card" hidden aria-live="polite"></div>
|
|
@@ -892,10 +904,12 @@
|
|
|
892
904
|
<details class="more"><summary>Which one?</summary>A code project that installs packages: its disk. Can be changed later.</details>
|
|
893
905
|
</div>
|
|
894
906
|
<details class="chapter" id="newconv-more">
|
|
895
|
-
<summary><span class="chapter-title">More</span><span class="chapter-about">Identifier, memory.</span></summary>
|
|
907
|
+
<summary><span class="chapter-title">More</span><span class="chapter-about">Identifier, memory, cores, disk.</span></summary>
|
|
896
908
|
<div class="chapter-body">
|
|
897
909
|
<div class="set-row"><div class="set-what"><label for="newconv-id">Identifier</label><small>Its machine and address. Never changes</small><span id="newconv-id-error" class="err" role="alert" hidden></span></div><div class="set-control"><input id="newconv-id" maxlength="32" pattern="[a-z]([a-z0-9\-]{0,30}[a-z0-9])?" placeholder="website-redesign" spellcheck="false" autocapitalize="none"></div></div>
|
|
898
910
|
<div class="set-row"><div class="set-what"><label for="newconv-memory">Memory</label><small id="newconv-memory-least"></small><span id="newconv-memory-error" class="err" role="alert" hidden></span></div><div class="set-control"><select id="newconv-memory"></select></div></div>
|
|
911
|
+
<div class="set-row"><div class="set-what"><label for="newconv-cpus">Cores</label><small>Shared with the server's machines</small></div><div class="set-control"><select id="newconv-cpus"></select></div></div>
|
|
912
|
+
<div class="set-row"><div class="set-what"><label for="newconv-disk">Disk</label><small>For code kept on the machine; a disk only grows</small></div><div class="set-control"><select id="newconv-disk"></select></div></div>
|
|
899
913
|
</div>
|
|
900
914
|
</details>
|
|
901
915
|
</div>
|
package/web/links.js
CHANGED
|
@@ -69,6 +69,12 @@
|
|
|
69
69
|
let allLines = true;
|
|
70
70
|
try { allLines = localStorage.getItem('clavarium-links-all') !== '0'; } catch { /* none kept */ }
|
|
71
71
|
let picked = null; let pinned = null; let focus = null; let drag = null; let pop = null; let popLink = null; let drawnMany = false;
|
|
72
|
+
/* A box is shown only if its column's filter is empty or its name holds what was typed: so a
|
|
73
|
+
crowded map (many assets) is narrowed to a few boxes, their links with them. The layout is
|
|
74
|
+
kept while typing (no reorder), and a filter cleared brings everything back. */
|
|
75
|
+
const filters = { device: '', conversation: '', asset: '' };
|
|
76
|
+
let laidOut = null;
|
|
77
|
+
const matches = (n, k) => { const f = (filters[k] || '').trim().toLowerCase(); return !f || n.name.toLowerCase().includes(f) || String(n.sub || '').toLowerCase().includes(f); };
|
|
72
78
|
const ph = { screen: 'list', kind: 'device', id: null, adding: false, sheet: null };
|
|
73
79
|
let traceOf = '*';
|
|
74
80
|
|
|
@@ -182,27 +188,35 @@
|
|
|
182
188
|
}
|
|
183
189
|
return best;
|
|
184
190
|
}
|
|
185
|
-
|
|
191
|
+
/* `relayout` false keeps the order found last: used while typing a filter, so boxes do not jump. */
|
|
192
|
+
function paint(relayout = true) {
|
|
186
193
|
for (const b of document.querySelectorAll('#links-tabs [data-view]')) b.setAttribute('aria-selected', String(b.dataset.view === view));
|
|
187
194
|
$('links-all').checked = allLines;
|
|
188
195
|
legend();
|
|
189
196
|
const bd = board();
|
|
190
197
|
bd.className = `lk-board ${VIEWS[view].cols.length === 3 ? 'three' : 'two'}`;
|
|
191
198
|
bd.querySelectorAll('.lk-col, .lk-knob').forEach((e) => e.remove()); closePop();
|
|
192
|
-
|
|
199
|
+
if (relayout || !laidOut) laidOut = layout();
|
|
200
|
+
const lists = laidOut;
|
|
193
201
|
VIEWS[view].cols.forEach((cols, ci) => {
|
|
194
202
|
const col = h('div', { class: 'lk-col' });
|
|
195
203
|
cols.forEach((k, i) => {
|
|
196
204
|
if (i) col.append(h('div', { class: 'lk-gap' }));
|
|
197
|
-
col.append(h('h3', { class: 'lk-colh' }, h('span', { text: TITLES[k] }), plus(k)));
|
|
198
|
-
const
|
|
205
|
+
col.append(h('h3', { class: 'lk-colh' }, h('span', { class: 'lk-colt', text: TITLES[k] }), plus(k)));
|
|
206
|
+
const whole = lists[ci][i];
|
|
207
|
+
const list = whole.filter((n) => matches(n, k));
|
|
199
208
|
for (const n of list) col.append(nodeEl(n));
|
|
200
|
-
if (!list.length) col.append(empty(k));
|
|
209
|
+
if (!list.length) col.append(whole.length ? h('p', { class: 'hint lk-none', text: 'Nothing matches.' }) : empty(k));
|
|
201
210
|
});
|
|
202
211
|
bd.append(col);
|
|
203
212
|
});
|
|
204
213
|
fit(); draw(); hint(); paintPhone();
|
|
205
214
|
}
|
|
215
|
+
/* The filters sit in a bar of their own, ABOVE the board and out of its zoom, so that fitting
|
|
216
|
+
a crowded map (which zooms it down) never shrinks them. Each narrows its column; the board
|
|
217
|
+
is repainted without a relayout (the inputs are not rebuilt, so the caret stays). */
|
|
218
|
+
const onFind = (e) => { filters[e.target.dataset.k] = e.target.value; paint(false); };
|
|
219
|
+
for (const inp of document.querySelectorAll('#links-filters .lk-find')) inp.addEventListener('input', onFind);
|
|
206
220
|
/* How each kind is made: a device paired, a conversation created, an asset added. The same,
|
|
207
221
|
from the small round "+" by each column's title (always there, however many it holds)
|
|
208
222
|
and from an empty column. */
|
package/web/style.css
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
a narrow one, the list and the conversation are two screens. */
|
|
3
3
|
:root {
|
|
4
4
|
--bg: #0f141a; --bar: #161d26; --panel: #131a22; --line: #2b3745; --ink: #e7edf4; --ink2: #a3b1c2;
|
|
5
|
-
--brass: #d2a94e; --on-brass: #1b1405; --ok: #5fc39d; --warn: #e39a5c; --danger: #ee7f79;
|
|
5
|
+
--brass: #d2a94e; --on-brass: #1b1405; --ok: #5fc39d; --warn: #e39a5c; --danger: #ee7f79; --wait: #5aa9f0;
|
|
6
6
|
/* Brass as the colour of text or of a small sign: darker on a light screen, to be read. */
|
|
7
7
|
--brass-ink: #d2a94e;
|
|
8
8
|
--sans: system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
colours of its own for it (app.js): a tool's "white" must stay readable. */
|
|
12
12
|
:root[data-theme="light"] {
|
|
13
13
|
--bg: #fbfbfa; --bar: #eef0f3; --panel: #ffffff; --line: #c5cdd8; --ink: #17202b; --ink2: #4f5d6d;
|
|
14
|
-
--brass: #c79a3a; --on-brass: #1b1405; --ok: #1f7a5a; --warn: #a3581a; --danger: #b3261e; --button: #e6eaef; --brass-ink: #8a5d00;
|
|
14
|
+
--brass: #c79a3a; --on-brass: #1b1405; --ok: #1f7a5a; --warn: #a3581a; --danger: #b3261e; --wait: #2f7fd6; --button: #e6eaef; --brass-ink: #8a5d00;
|
|
15
15
|
}
|
|
16
16
|
* { box-sizing: border-box; }
|
|
17
17
|
/* TEXT IS IN rem: one size at the root (set per device by app.js, as a
|
|
@@ -34,20 +34,25 @@ button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); out
|
|
|
34
34
|
.item[aria-current="true"] { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
|
|
35
35
|
.item b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
36
36
|
.item small { color: var(--ink2); }
|
|
37
|
-
/* ITS STATE, one point on the right of its row
|
|
37
|
+
/* ITS STATE, one point on the right of its row, its colour the worst that
|
|
38
|
+
applies: a machine problem (red), the agent waits for you (blue), the agent
|
|
39
|
+
at work (gold, pulsing), the machine busy (amber, pulsing), fine (green),
|
|
40
|
+
asleep (a hollow ring). The same point, same colours, sums a folded group. */
|
|
38
41
|
.item { position: relative; padding-right: 26px; }
|
|
39
42
|
.state-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-sizing: border-box; background: var(--ok); }
|
|
40
|
-
.state-dot[data-state="
|
|
41
|
-
.state-dot[data-state="
|
|
43
|
+
.state-dot[data-state="problem"] { background: var(--danger); }
|
|
44
|
+
.state-dot[data-state="wait"] { background: var(--wait); }
|
|
45
|
+
.state-dot[data-state="work"] { background: var(--brass); }
|
|
46
|
+
.state-dot[data-state="busy"] { background: var(--ink2); }
|
|
42
47
|
.state-dot[data-state="sleep"] { background: transparent; border: 1.5px solid var(--ink2); }
|
|
43
48
|
.item > .state-dot { position: absolute; right: 10px; top: 13px; }
|
|
44
|
-
.item[data-state="
|
|
49
|
+
.item > .state-dot[data-state="work"], .item > .state-dot[data-state="busy"] { animation: breathe 1.7s ease-in-out infinite; }
|
|
45
50
|
/* Folded: up to four points, how its conversations are. */
|
|
46
51
|
.state-sum { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }
|
|
47
52
|
/* Unfolded: it comes in gently, once. */
|
|
48
53
|
.unfolding { animation: unfold .18s ease-out; }
|
|
49
54
|
@keyframes unfold { from { opacity: 0; transform: translateY(-6px); } }
|
|
50
|
-
@keyframes
|
|
55
|
+
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.85); } }
|
|
51
56
|
@media (prefers-reduced-motion: reduce) { .item > .state-dot, .unfolding { animation: none !important; } }
|
|
52
57
|
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
53
58
|
.choices button[aria-checked="true"] { border-color: var(--brass); background: rgba(210, 169, 78, .16); }
|
|
@@ -127,6 +132,7 @@ footer button.wide { flex: 1 0 auto; background: var(--brass); border-color: var
|
|
|
127
132
|
.chip[data-access="write"] { color: var(--ok); border-color: var(--ok); }
|
|
128
133
|
.sheet { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--panel); overflow-y: auto; }
|
|
129
134
|
.panel-top { display: flex; align-items: center; justify-content: space-between; }
|
|
135
|
+
.panel-actions { margin: 2px 0 12px; }
|
|
130
136
|
#panel-rows { display: flex; flex-direction: column; }
|
|
131
137
|
.folder { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
|
|
132
138
|
.folder b { flex: 1; min-width: 100px; overflow: hidden; text-overflow: ellipsis; }
|
|
@@ -190,6 +196,8 @@ a.button { font: 600 .8125rem var(--sans); text-decoration: none; border-radius:
|
|
|
190
196
|
#mic { flex-basis: 55%; padding-block: 12px; }
|
|
191
197
|
}
|
|
192
198
|
.item[data-asleep="true"] .dot { background: var(--ink2); }
|
|
199
|
+
/* Asleep: faded in the list (and sorted to the bottom of Recent, app.js), so it is plainly not where you are. */
|
|
200
|
+
.item[data-asleep="true"]:not([aria-current="true"]) { opacity: .62; }
|
|
193
201
|
footer button.careful { border-style: dashed; color: var(--ink2); }
|
|
194
202
|
/* On a touch screen every control is at least a fingertip high. */
|
|
195
203
|
@media (max-width: 700px) {
|
|
@@ -1281,6 +1289,14 @@ select.pill { appearance: auto; }
|
|
|
1281
1289
|
/* The title of a column of the map, and its round "+" (a new device, conversation, asset): always there. */
|
|
1282
1290
|
.lk-col h3.lk-colh, .lk-phead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
1283
1291
|
.lk-col h3.lk-colh .lk-add { width: 26px; height: 26px; font-size: .95rem; letter-spacing: 0; }
|
|
1292
|
+
/* The filters: their own bar above the board, out of its zoom, so they stay a usable size. */
|
|
1293
|
+
.lk-filters { display: flex; gap: 10px 16px; flex-wrap: wrap; margin: 2px 0 10px; }
|
|
1294
|
+
.lk-filter { display: flex; align-items: center; gap: 8px; flex: 1 1 200px; min-width: 160px; }
|
|
1295
|
+
.lk-filter > span { flex: none; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
|
|
1296
|
+
.lk-filters .lk-find { flex: 1 1 auto; min-width: 0; font: inherit; font-size: .9rem; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink); }
|
|
1297
|
+
.lk-filters .lk-find::placeholder { color: var(--ink2); }
|
|
1298
|
+
/* The phone shows a list of its own, not the board: the column filters do not apply there. */
|
|
1299
|
+
@media (max-width: 600px) { #links-filters { display: none; } }
|
|
1284
1300
|
.lk-phead { margin: 4px 0 6px; }
|
|
1285
1301
|
.as-kinds { display: flex; flex-wrap: wrap; gap: 8px; } .as-kinds button { display: inline-flex; align-items: center; gap: 8px; }
|
|
1286
1302
|
|