@opennous/cli 0.18.0 → 0.18.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @opennous/cli changelog
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Fixed: one machine is one runner
6
+
7
+ The runner named your machine by its network hostname, which on a Mac changes with the network, so
8
+ one Mac could show up as two runners. It now uses the Mac's own name, saved once (GET-1308).
9
+
3
10
  ## 0.18.0
4
11
 
5
12
  ### Changed: one command sets everything up, and the runner is quiet when idle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opennous/cli",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Ownable CLI — set up Ownable, connect it to your coding agent, and read the Context API from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -663,13 +663,14 @@ const runnerCmd = program
663
663
  const { detectAgents, liveRun, NO_AGENT } = await import("./backfill.js");
664
664
  const { runRunner } = await import("./runner.js");
665
665
  const agent = await pickAgent(opts.agent, detectAgents, NO_AGENT);
666
+ const host = await runnerHost();
666
667
  const key = await runnerKey(opts);
667
668
  const api = apiClient(key);
668
669
  const service = process.env.NOUS_RUNNER_SERVICE === "1";
669
670
  const stamp = (line) => (service ? `${new Date().toISOString()} ${line}` : line);
670
671
  console.log(stamp(`Reading on your ${agent} plan. ${service ? "" : "Stop with Ctrl-C; `nous runner install` keeps it going on its own."}`.trim()));
671
672
  await runRunner({
672
- agent, version, run: liveRun(), log: (l) => console.log(stamp(l)),
673
+ agent, host, version, run: liveRun(), log: (l) => console.log(stamp(l)),
673
674
  sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
674
675
  api: {
675
676
  poll: (body) => api.softPost("/v2/runner/poll", body),
@@ -692,7 +693,7 @@ runnerCmd
692
693
  const key = await runnerKey(opts);
693
694
  // One poll before installing, so a bad key or plan fails here and not silently in the background.
694
695
  try {
695
- await apiClient(key).softPost("/v2/runner/poll", { agent, host: hostname(), version, limit: 0 });
696
+ await apiClient(key).softPost("/v2/runner/poll", { agent, host: await runnerHost(), version, limit: 0 });
696
697
  } catch (e) {
697
698
  console.error(`Couldn't connect: ${e.message}`);
698
699
  process.exit(1);
@@ -715,7 +716,7 @@ runnerCmd
715
716
  const { uninstallService } = await import("./runner.js");
716
717
  const removed = uninstallService();
717
718
  // The server stops waiting on this machine (GET-1307): with no runner left, your reading goes back to credits.
718
- if (hasKey()) await apiClient().softDelete("/v2/runner", { host: hostname() }).catch(() => {});
719
+ if (hasKey()) await apiClient().softDelete("/v2/runner", { host: await runnerHost() }).catch(() => {});
719
720
  console.log(removed ? "Stopped. It won't start at login any more, and your reading is back on credits unless another machine runs it." : "No runner is installed on this machine.");
720
721
  });
721
722
 
@@ -730,6 +731,15 @@ runnerCmd
730
731
  if (s.log) console.log(`Log: ${s.log}`);
731
732
  });
732
733
 
734
+ /** This machine's name for its runner, kept in the config so it is the same every run (GET-1308). */
735
+ async function runnerHost() {
736
+ const { machineName } = await import("./runner.js");
737
+ const cfg = readConfig();
738
+ const name = machineName({ saved: cfg.runnerHost ?? null });
739
+ if (name !== cfg.runnerHost) writeConfig({ ...cfg, runnerHost: name });
740
+ return name;
741
+ }
742
+
733
743
  /** The agent to read with: the one asked for, or whichever is signed in. Exits with what to do. */
734
744
  async function pickAgent(asked, detectAgents, noAgent) {
735
745
  const agents = detectAgents();
package/src/runner.js CHANGED
@@ -34,6 +34,21 @@ const ERROR_BACKOFF_MS = 30_000;
34
34
  export const LABEL = "cloud.opennous.runner";
35
35
  export const RUN_COMMAND = "npx -y @opennous/cli@latest runner";
36
36
 
37
+ /**
38
+ * This machine's name for Ownable (GET-1308), the same every run. `os.hostname()` on a Mac follows
39
+ * the network ("Mac.lan" on one, "Bennets-MacBook-Air.local" on another), which made one machine
40
+ * two runners. The Mac's own name (System Settings → General → About) is asked once and kept.
41
+ */
42
+ export function machineName({ saved = null, os = platform(), run = spawnSync, host = hostname } = {}) {
43
+ if (saved) return saved;
44
+ if (os === "darwin") {
45
+ const r = run("scutil", ["--get", "ComputerName"], { encoding: "utf8" });
46
+ const name = r.status === 0 ? String(r.stdout).trim() : "";
47
+ if (name) return name;
48
+ }
49
+ return String(host()).replace(/\.(local|lan|home|localdomain)$/i, "");
50
+ }
51
+
37
52
  /** What the status line says about the read in progress, or null. Pure. */
38
53
  export function readingLine(reading) {
39
54
  if (!reading) return null;