@gorlitzer-labs/seldon 0.19.0 → 0.19.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/bin/seldon.js CHANGED
@@ -8,11 +8,11 @@ import fs from "node:fs";
8
8
  import os from "node:os";
9
9
  import readline from "node:readline";
10
10
  import { MODULES, byId, DEPS, RAW, MONOREPO, withRequires, platformOk } from "../modules.mjs";
11
- import { ensureSiblingPath, loadState, resolveProject, adopt as fAdopt, staff as fStaff, attach as fAttach, hiveOf, sameDir } from "../lib/projects.mjs";
11
+ import { ensureSiblingPath, has, loadState, resolveProject, adopt as fAdopt, staff as fStaff, attach as fAttach, hiveOf, sameDir } from "../lib/projects.mjs";
12
12
  import { readLanes, readPlan, addToPlan, projectRoot, writeReport } from "../lib/agents.mjs";
13
13
  import { openCommand, stopCommand, transitions, laneForItem, slugify, HARNESSES } from "../lib/lanes.mjs";
14
14
  import { startLane, stopLane, resumeLane, removeLane, findLane } from "../lib/actions.mjs";
15
- import { listMachines, addMachine, fetchLanes, remoteGroups, sshArgs, lastJsonLine } from "../lib/machines.mjs";
15
+ import { listMachines, addMachine, fetchLanes, machinePoller, sshArgs, lastJsonLine } from "../lib/machines.mjs";
16
16
  import { notify } from "../lib/notify.mjs";
17
17
  import { sendCard, watchCard, KINDS, tokenName, readChat, writeChat, chatFromUpdates, getUpdates, sendText, sendFile, pollUpdates, fileFromMessage, inboxName, freeName, noteLine, downloadFile, react, MAX_DOWNLOAD } from "../lib/telegram.mjs";
18
18
  import { reportFromEvent, mergeCodexHooks, removeCodexHooks, opencodePlugin } from "../lib/reports.mjs";
@@ -63,8 +63,8 @@ function run(cmd, args, opts = {}) {
63
63
  return r.status === 0;
64
64
  }
65
65
 
66
- // Is a command on PATH? (used to pick the fastest package manager)
67
- const has = (bin) => { try { execSync(`command -v ${bin}`, { stdio: "ignore" }); return true; } catch { return false; } };
66
+ // Colour per lane state, shared by the panel and the workspace list.
67
+ const TINT = { "needs-you": C.gold, working: C.green, running: C.green, idle: C.dim, failed: C.red, stopped: C.dim, off: C.dim };
68
68
 
69
69
  // A usable uv, for Python modules. Prefer one on PATH; else a prior isolated
70
70
  // copy; else bootstrap uv into ~/.seldon/bin with NO shell/profile changes.
@@ -326,7 +326,7 @@ async function doInstall(ids, { dev } = {}) {
326
326
  const bad = results.filter(([, r]) => !r).map(([i]) => i);
327
327
  console.log("\n" + C.bold("Done. ") + C.green(good.join(", ") || "—") + (bad.length ? " " + C.red("failed: " + bad.join(", ")) : ""));
328
328
  // demerzel's models are the heavy part — offer to pull them now, at install time.
329
- if (good.includes("demerzel")) await ensureDemerzelModels({ ask: true });
329
+ if (good.includes("demerzel")) await ensureDemerzelModels();
330
330
  }
331
331
 
332
332
  // ---- uninstall --------------------------------------------------------------
@@ -495,30 +495,6 @@ function demerzelModelsMissing() {
495
495
  const demerzelModelsReady = () => demerzelModelsMissing().length === 0;
496
496
  const demerzelInstalled = () => fs.existsSync(path.join(SELDON_HOME, "demerzel", ".venv", "bin", "python"));
497
497
 
498
- // This machine's Tailscale IPv4 (100.64.0.0/10), or null. Tries PATH then the
499
- // macOS app location. Used to expose the voice to your phone over the tailnet.
500
- function tailnetIp() {
501
- for (const bin of ["tailscale", "/Applications/Tailscale.app/Contents/MacOS/tailscale"]) {
502
- try {
503
- const ip = execSync(`${bin} ip -4`, { stdio: ["ignore", "pipe", "ignore"] }).toString().trim().split(/\s+/)[0];
504
- if (/^100\./.test(ip)) return ip;
505
- } catch {}
506
- }
507
- // CLI missing/moved? The tailnet address is still on a utun interface —
508
- // read it straight from the OS (Tailscale's CGNAT range is 100.64.0.0/10).
509
- try {
510
- const out = execSync("ifconfig", { stdio: ["ignore", "pipe", "ignore"] }).toString();
511
- const m = out.match(/inet (100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7])\.\d+\.\d+)/);
512
- if (m) return m[1];
513
- } catch {}
514
- try { // linux `ip addr`
515
- const out = execSync("ip -4 addr", { stdio: ["ignore", "pipe", "ignore"] }).toString();
516
- const m = out.match(/inet (100\.(?:6[4-9]|[7-9]\d|1[01]\d|12[0-7])\.\d+\.\d+)/);
517
- if (m) return m[1];
518
- } catch {}
519
- return null;
520
- }
521
-
522
498
  // Find the Tailscale CLI (PATH, homebrew, or the macOS app bundle).
523
499
  function tailscaleBin() {
524
500
  for (const b of ["tailscale", "/opt/homebrew/bin/tailscale", "/usr/local/bin/tailscale", "/Applications/Tailscale.app/Contents/MacOS/tailscale", "/usr/bin/tailscale"]) {
@@ -571,7 +547,7 @@ function tailscaleServeSetup() {
571
547
  // Fetch demerzel's model set (~25 GB) — offered, never silent. Respects the
572
548
  // chosen LLM (DEMERZEL_LLM) so `seldon install demerzel` / `seldon up` pull the
573
549
  // model you'll actually run. --models forces yes, --no-models forces skip.
574
- async function ensureDemerzelModels({ ask = true } = {}) {
550
+ async function ensureDemerzelModels() {
575
551
  if (!demerzelInstalled() || !platformOk(byId.demerzel)) return false;
576
552
  if (demerzelModelsReady()) return true;
577
553
  const home = path.join(SELDON_HOME, "demerzel");
@@ -691,7 +667,7 @@ async function up() {
691
667
  const home = path.join(SELDON_HOME, "demerzel");
692
668
  if (!platformOk(dem)) later.push("Voice (demerzel) needs macOS on Apple silicon — skipped here.");
693
669
  else {
694
- if (!demerzelModelsReady()) await ensureDemerzelModels({ ask: true }); // offer the fetch inline
670
+ if (!demerzelModelsReady()) await ensureDemerzelModels(); // offer the fetch inline
695
671
  if (demerzelModelsReady()) {
696
672
  const env = { ...process.env };
697
673
  // --- choose the brain (remembered) ---
@@ -945,14 +921,7 @@ async function panel() {
945
921
  // slow or sleeping machine never freezes this screen; `seen` says how each one answered.
946
922
  const machines = listMachines();
947
923
  const seen = new Map(); // name -> { groups, error, at, inflight }
948
- const pollMachines = () => {
949
- for (const m of machines) {
950
- const was = seen.get(m.name) || {};
951
- if (was.inflight || (was.at && Date.now() - was.at < 10_000)) continue;
952
- seen.set(m.name, { ...was, inflight: true });
953
- fetchLanes(m, (r) => { seen.set(m.name, { groups: r.lanes ? remoteGroups(m, r.lanes) : was.groups || [], error: r.error || null, at: Date.now(), inflight: false }); });
954
- }
955
- };
924
+ const pollMachines = machinePoller(machines, seen);
956
925
  const machineOf = (name) => machines.find((m) => m.name === name);
957
926
  // Run seldon (or foundation) on a machine. `tty`: it may need a terminal (a trust dialog),
958
927
  // so it inherits this one; otherwise its output is captured for the note line.
@@ -975,7 +944,7 @@ async function panel() {
975
944
  const allLanes = () => groups.flatMap((g) => g.lanes);
976
945
 
977
946
  const svc = (label, on) => (on ? C.green("●") : C.dim("○")) + " " + label;
978
- const tint = { "needs-you": C.gold, working: C.green, running: C.green, idle: C.dim, failed: C.red, stopped: C.dim };
947
+ const tint = TINT;
979
948
  // Below 70 columns (a phone over ssh) a lane is one short line: glyph, name, the state in a
980
949
  // word. The full detail is one ⏎ away.
981
950
  const narrow = () => (process.stdout.columns || 100) < 70;
@@ -1590,14 +1559,7 @@ async function wsSidebar() {
1590
1559
  ensureSiblingPath();
1591
1560
  const machines = listMachines();
1592
1561
  const seen = new Map();
1593
- const poll = () => {
1594
- for (const m of machines) {
1595
- const was = seen.get(m.name) || {};
1596
- if (was.inflight || (was.at && Date.now() - was.at < 10_000)) continue;
1597
- seen.set(m.name, { ...was, inflight: true });
1598
- fetchLanes(m, (r) => { seen.set(m.name, { groups: r.lanes ? remoteGroups(m, r.lanes) : was.groups || [], error: r.error || null, at: Date.now(), inflight: false }); });
1599
- }
1600
- };
1562
+ const poll = machinePoller(machines, seen);
1601
1563
  let rows = [], cur = 0, note = "";
1602
1564
  const home = wsHome();
1603
1565
  const load = () => {
@@ -1611,7 +1573,7 @@ async function wsSidebar() {
1611
1573
  cur = keep >= 0 ? keep : Math.min(cur, Math.max(0, rows.length - 1));
1612
1574
  wsSave(WS_ROWS, JSON.stringify(rows.map((r) => ({ n: r.n, key: r.key, name: r.name, state: r.state, off: r.off, cmd: paneCommand(r, { machines, home }) }))));
1613
1575
  };
1614
- const tint = { "needs-you": C.gold, working: C.green, running: C.green, idle: C.dim, failed: C.red, stopped: C.dim, off: C.dim };
1576
+ const tint = TINT;
1615
1577
  const draw = () => {
1616
1578
  const width = process.stdout.columns || 38, height = process.stdout.rows || 40;
1617
1579
  const open = wsCurrent(), h = wsHeadline(rows);
@@ -1934,7 +1896,7 @@ function holdsCmd() {
1934
1896
  // (`--no-attach`). The value form has to be CONSUMED: filtering out everything starting with
1935
1897
  // `--` and keeping the rest as positionals read `seldon go --agent claude` as the project
1936
1898
  // named "claude".
1937
- const VALUE_FLAGS = new Set(["agent", "model", "effort", "name", "port", "pm", "stall", "dir", "for", "wait", "as", "note", "interval", "task", "owner", "file", "token-name", "card"]);
1899
+ const VALUE_FLAGS = new Set(["agent", "model", "effort", "name", "pm", "dir", "for", "wait", "as", "note", "interval", "task", "file", "token-name", "card"]);
1938
1900
  function parseArgv(raw) {
1939
1901
  const flags = {}, positional = [];
1940
1902
  for (let i = 0; i < raw.length; i++) {
@@ -1993,11 +1955,11 @@ const ids = tokens.filter((id) => byId[id]); // only the valid module
1993
1955
  if (cmd === "lanes") return lanesCmd(flags);
1994
1956
  if (cmd === "machines") return machinesCmd(tokens[0], tokens[1], tokens[2]);
1995
1957
  if (cmd === "lane") return laneCmd(tokens[0], tokens[1], flags);
1996
- if (cmd === "ws" || cmd === "workspace") return wsCmd(tokens[0], tokens[1]);
1958
+ if (cmd === "ws") return wsCmd(tokens[0], tokens[1]);
1997
1959
  if (cmd === "tell") return tellCmd(tokens, flags);
1998
1960
  if (cmd === "inbox") return inboxCmd(flags);
1999
1961
  if (cmd === "setup") return setupCmd(tokens[0], flags);
2000
- if (cmd === "panel" || cmd === "board") return panel();
1962
+ if (cmd === "panel") return panel();
2001
1963
  if (cmd && cmd !== "install") { help(); process.exitCode = 1; return; }
2002
1964
  if (cmd === "install") return install_picker({ dev }); // `install` with no ids
2003
1965
 
package/lib/machines.mjs CHANGED
@@ -11,7 +11,7 @@ import { join } from "node:path";
11
11
  import { homedir } from "node:os";
12
12
  import { groupByProject } from "./lanes.mjs";
13
13
 
14
- export const REALMS_DIR = join(homedir(), ".config", "bifrost", "realms");
14
+ const REALMS_DIR = join(homedir(), ".config", "bifrost", "realms");
15
15
 
16
16
  // Read narrowly — two keys, quotes stripped, nothing executed. Sourcing a file to learn a
17
17
  // hostname is not something to do.
@@ -80,3 +80,16 @@ export function fetchLanes(machine, cb) {
80
80
  cb(lanes ? { lanes } : { error: err ? (err.killed ? "timed out" : "unreachable") : "no seldon there" });
81
81
  });
82
82
  }
83
+
84
+ // Poll every machine's lanes in the background, at most every 10s each, so a slow or sleeping
85
+ // machine never blocks a redraw. `seen` maps name -> { groups, error, at, inflight }.
86
+ export function machinePoller(machines, seen, fetch = fetchLanes) {
87
+ return () => {
88
+ for (const m of machines) {
89
+ const was = seen.get(m.name) || {};
90
+ if (was.inflight || (was.at && Date.now() - was.at < 10_000)) continue;
91
+ seen.set(m.name, { ...was, inflight: true });
92
+ fetch(m, (r) => { seen.set(m.name, { groups: r.lanes ? remoteGroups(m, r.lanes) : was.groups || [], error: r.error || null, at: Date.now(), inflight: false }); });
93
+ }
94
+ };
95
+ }
package/lib/projects.mjs CHANGED
@@ -52,11 +52,6 @@ export function gitRootOf(dir) {
52
52
  const realish = (p) => { try { return fs.realpathSync(p); } catch { return p; } };
53
53
  export const sameDir = (a, b) => !!a && !!b && realish(a) === realish(b);
54
54
 
55
- // A repo carries its hive in .factory.json — the local truth, which survives a pruned or
56
- // hand-edited registry.
57
- export function localHive(dir) {
58
- try { return JSON.parse(readFileSync(path.join(dir, ".factory.json"), "utf8")); } catch { return null; }
59
- }
60
55
 
61
56
  /**
62
57
  * What did the user mean, and what do we know about it?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gorlitzer-labs/seldon",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "Install the Seldon stack — pick your tools from a checklist; each installs via its native method.",
5
5
  "type": "module",
6
6
  "bin": {