clavarium 0.2.227-next.1 → 0.2.229-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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.227-next.1",
3
+ "version": "0.2.229-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.227-next.1",
9
+ "version": "0.2.229-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.227-next.1",
3
+ "version": "0.2.229-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.",
@@ -310,7 +310,9 @@ export class Capacity {
310
310
  const f = this.#figures(await this.room({ fresh: true }).catch(() => null));
311
311
  if (!f) return [];
312
312
  const awake = new Set(this.#conversations.awake?.() ?? []);
313
- const holding = f.machines.filter((m) => m.name && !m.shelf && !awake.has(m.name) && m.rssMb >= RECLAIM_MIN_MB);
313
+ /* Only a machine put to sleep: one being built is not awake either, yet must never be touched. */
314
+ const asleep = this.#conversations.asleep ? new Set(this.#conversations.asleep()) : null;
315
+ const holding = f.machines.filter((m) => m.name && !m.shelf && !awake.has(m.name) && (!asleep || asleep.has(m.name)) && m.rssMb >= RECLAIM_MIN_MB);
314
316
  if (!holding.length) return [];
315
317
  const now = this.#now();
316
318
  const at = this.#store.get('reclaim')?.at ?? {};
@@ -393,7 +393,8 @@ export class Conversations {
393
393
  if (!tool) throw new Refusal(400, 'The tool of this conversation is no longer offered.');
394
394
  const state = await this.#vms.state(name, { fresh: true });
395
395
  if (state !== undefined && c.phase !== 'failed' && !reset) throw new Refusal(409, 'This conversation has its machine: there is nothing to build again.');
396
- await this.room({ kind: 'create', name, memoryMb: c.memoryMb });
396
+ /* A reset replaces its own machine: the room it takes is given back first. */
397
+ if (!(reset && state !== undefined)) await this.room({ kind: 'create', name, memoryMb: c.memoryMb });
397
398
  this.#cancelStop(name);
398
399
  this.drop(name);
399
400
  /* Marked first: two requests cannot both start a build. */
@@ -1226,6 +1227,9 @@ export class Conversations {
1226
1227
 
1227
1228
  /* The conversations whose machine should be running: built, not asleep. */
1228
1229
  awake() { return this.#store.all().filter((c) => c.phase === 'ready' && c.asleep !== true).map((c) => c.name); }
1230
+ /* Put to sleep, and nothing else: not one being built (02-11: a reset machine was taken for a sleeper and
1231
+ suspended mid-build), not a failed one. */
1232
+ asleep() { return this.#store.all().filter((c) => c.phase === 'ready' && c.asleep === true).map((c) => c.name); }
1229
1233
 
1230
1234
  /* Whether the machine of a conversation runs right now. */
1231
1235
  async running(name) { return (await this.#vms.state(name)) === 'Running'; }