clavarium 0.2.467-next.1 → 0.2.468-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.467-next.1",
3
+ "version": "0.2.468-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.467-next.1",
9
+ "version": "0.2.468-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.467-next.1",
3
+ "version": "0.2.468-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.",
package/server/health.mjs CHANGED
@@ -31,6 +31,8 @@ import { SESSION } from './conversations.mjs';
31
31
  /* A FILE OUTSIDE /work where its tool may ask to be restarted when /work itself is dead (16-11): the
32
32
  one in its chat's folder (talk.mjs, RESTART_ASKED) cannot be written then. Read by the probe. */
33
33
  export const RESTART_OUTSIDE = '/var/tmp/clavarium-restart-asked';
34
+ /* The host of its tools, as pgrep -f reads it (the bracket: never the shell that asks). */
35
+ export const TOOLS_HOST_PATTERN = '/tools/launch/[t]ools-host.mjs';
34
36
  /* What a folder that came loose looks like on a terminal (the kernel's words for ENOTCONN). */
35
37
  const LOOSE_WORDS = 'transport endpoint is not connected|socket is not connected|ENOTCONN';
36
38
  /* A WORK FOLDER THE VM MANAGER CANNOT TAKE BACK (16-11, tried on a test server): its mount program died, multipass
@@ -60,6 +62,9 @@ export const PROBE = [
60
62
  `t=$(tmux -L ${SOCKET} list-panes -t '=${SESSION}:' -F '#{pane_pid}' 2>/dev/null | head -n 1)`,
61
63
  'case "$t" in ""|*[!0-9]*) ;; *) timeout 5 sh -c \'for p in $(ps -o pid= -s "$1" 2>/dev/null); do l=$(readlink "/proc/$p/cwd" 2>/dev/null) || continue; [ -n "$l" ] || continue; [ -d "/proc/$p/cwd/." ] || { echo "stale $p"; exit 0; }; done\' stale "$t";; esac',
62
64
  /* What its terminal shows now: a folder that is not connected, said by its tool (a symptom, not a proof). */
65
+ /* And the host of its tools (config/launch/tools-host.mjs: Parley, Docket... for its agent), started in its own
66
+ session from the tool's folder: left in a dead one, every tool it serves fails, the tool restarted or not. */
67
+ `for p in $(pgrep -f '${TOOLS_HOST_PATTERN}' 2>/dev/null); do [ -d "/proc/$p/cwd/." ] || { echo "stale $p"; break; }; done`,
63
68
  `tmux -L ${SOCKET} capture-pane -p -t '=${SESSION}:' 2>/dev/null | grep -c -i -E '${LOOSE_WORDS}' | awk '{print "screen", $1+0}'`,
64
69
  `if [ -f ${RESTART_OUTSIDE} ]; then echo "restart asked"; fi`,
65
70
  ].join('\n');
package/server/main.mjs CHANGED
@@ -59,7 +59,7 @@ import { GitChecks } from './gitchecks.mjs';
59
59
  import { GitKeeper } from './gitkeeper.mjs';
60
60
  import { GitRunner } from './gitrunner.mjs';
61
61
  import { Shelf } from './shelf.mjs';
62
- import { Health, RESTART_OUTSIDE } from './health.mjs';
62
+ import { Health, RESTART_OUTSIDE, TOOLS_HOST_PATTERN } from './health.mjs';
63
63
  import { Revive } from './revive.mjs';
64
64
  import { LinkGuard, removedLine, toolLine } from './linkguard.mjs';
65
65
  import { Setup } from './setup.mjs';
@@ -620,7 +620,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
620
620
  /* ITS TOOL STILL IN A FOLDER THAT CAME LOOSE, or asking from outside /work (16-11, revive.mjs): restarted
621
621
  by the server, its tool only; told through its docket first (read as it starts), its chat after. */
622
622
  const revive = new Revive({
623
- restart: (name) => all.restartTool(name),
623
+ /* Its tools' host stopped first (it starts again at the tool's first tool, from the folder put back). */
624
+ restart: async (name) => { await vms.exec(name, ['sh', '-c', `for p in $(pgrep -f '${TOOLS_HOST_PATTERN}'); do kill "$p"; done; true`], { timeoutMs: 10_000 }).catch(() => {}); return all.restartTool(name); },
624
625
  restartMachine: async (name) => { const r = await all.machineAction(name, 'restart', { wait: true }); return r?.ok !== false; },
625
626
  busy: (name) => talk.pulse(name)?.busy === true,
626
627
  taken: (name) => vms.exec(name, ['rm', '-f', RESTART_OUTSIDE], { timeoutMs: 10_000 }),