@ouro.bot/cli 0.1.0-alpha.1131 → 0.1.0-alpha.1132

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.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1132",
6
+ "changes": [
7
+ "app_sessions_restart now restarts the Copilot app through Housesitter (`housesitter restart-copilot --resume --detach`) and reads its state, step and result from `--status`, instead of the old per-Mac keeper. It finds Housesitter at HOUSESITTER_BIN, ~/code/housesitter or on PATH, and says so when it is missing."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1131",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1131",
2
+ "runtimeVersion": "0.1.0-alpha.1132",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>ouro-butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1131</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1132</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -210,7 +210,7 @@ exports.appSessionsResumeTool = {
210
210
  type: "function",
211
211
  function: {
212
212
  name: "app_sessions_resume",
213
- description: "Nudge a stuck or stopped Copilot app session to continue where it left off (the resume message the Mac's app keeper sends after a restart), with an optional note. Its next reply comes back to you.",
213
+ description: "Nudge a stuck or stopped Copilot app session to continue where it left off (the resume message Housesitter sends after a restart), with an optional note. Its next reply comes back to you.",
214
214
  parameters: {
215
215
  type: "object",
216
216
  properties: { session: sessionParam, note: { type: "string", description: "Anything to add to the resume message." } },
@@ -304,12 +304,12 @@ exports.appSessionsRestartTool = {
304
304
  type: "function",
305
305
  function: {
306
306
  name: "app_sessions_restart",
307
- description: "The Copilot app's courtesy restart, through this Mac's app keeper (it never restarts the app itself). status: the keeper's queue, panel, last restarts and resume state. enqueue: ask for a restart; the keeper restarts at once when nobody is at the Mac, otherwise shows the person a \"Restart now\" / \"Not now\" panel, and resumes every working session afterwards. Says so plainly when the keeper is not installed.",
307
+ description: "Restart the Copilot app and lose no session's work, through Housesitter on this Mac (it restarts the app from outside, as a launchd job). status: the restart in progress or the last one: state, step, start time, result, log. enqueue: start one now; every working session is asked to reach a safe point, the app is quit through its Quit menu (it waits while a person is using the Mac), relaunched, and every session that was working gets a resume message and is checked to have taken a turn. Starting one while another runs is refused. Says so plainly when Housesitter is not on this Mac.",
308
308
  parameters: {
309
309
  type: "object",
310
310
  properties: {
311
311
  action: { type: "string", enum: ["status", "enqueue"], description: "Default status." },
312
- why: { type: "string", description: "enqueue: the reason, shown to the person in the panel." },
312
+ why: { type: "string", description: "enqueue: the reason; it completes \"restarted at 11:40 for …\" in the resume message each session gets." },
313
313
  },
314
314
  additionalProperties: false,
315
315
  },
@@ -320,12 +320,12 @@ exports.appSessionsRestartTool = {
320
320
  return await (0, client_1.restartStatus)(clientOptions);
321
321
  const why = text(args.why);
322
322
  if (!why)
323
- throw new Error("say why the app needs a restart; the person sees it in the panel");
323
+ throw new Error("say why the app needs a restart; every session is told in its resume message");
324
324
  return await (0, client_1.restartEnqueue)(why, ctx?.agentName ?? "an agent", clientOptions);
325
325
  }),
326
326
  summaryKeys: ["action"],
327
327
  riskProfile: (args) => text(args.action) === "enqueue"
328
- ? { mutates: "external_side_effect", risk: "high", reason: "queues a restart of the owner's Copilot app" }
328
+ ? { mutates: "external_side_effect", risk: "high", reason: "restarts the owner's Copilot app" }
329
329
  : { mutates: "none", risk: "low" },
330
330
  };
331
331
  exports.appSessionsWatchTool = {
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.realRunFile = exports.KEEPER_LABEL = exports.SEND_WAIT_MS = void 0;
39
+ exports.realRunFile = exports.HOUSESITTER_ENV = exports.SEND_WAIT_MS = void 0;
40
40
  exports.defaultStateDir = defaultStateDir;
41
41
  exports.assertSessionId = assertSessionId;
42
42
  exports.eventLogPath = eventLogPath;
@@ -62,7 +62,7 @@ exports.resumeAppSession = resumeAppSession;
62
62
  exports.openAppChat = openAppChat;
63
63
  exports.archiveAppSession = archiveAppSession;
64
64
  exports.appRunning = appRunning;
65
- exports.findKeeper = findKeeper;
65
+ exports.findHousesitter = findHousesitter;
66
66
  exports.restartEnqueue = restartEnqueue;
67
67
  exports.restartStatus = restartStatus;
68
68
  const fs = __importStar(require("node:fs"));
@@ -76,12 +76,13 @@ const runtime_1 = require("../../nerves/runtime");
76
76
  const copilot_app_1 = require("../shepherd/copilot-app");
77
77
  /** The most a send waits: a session whose runtime is not in memory loads first, often for more than 20 s. */
78
78
  exports.SEND_WAIT_MS = 120_000;
79
- exports.KEEPER_LABEL = "com.arimendelow.copilot-app-keeper";
79
+ /** Names the Housesitter command to run: the path of its `bin/housesitter.mjs`, or of an executable. */
80
+ exports.HOUSESITTER_ENV = "HOUSESITTER_BIN";
80
81
  const REQUEST_WAIT_MS = 30_000;
81
82
  const ARCHIVE_WAIT_MS = 60_000;
82
83
  const CHAT_ARCHIVE_WAIT_MS = 20_000;
83
84
  const RENAME_WAIT_MS = 1_500;
84
- const KEEPER_WAIT_MS = 20_000;
85
+ const HOUSESITTER_WAIT_MS = 30_000;
85
86
  const STATUS_TAIL_BYTES = 512 * 1024;
86
87
  const EVENT_CHUNK_BYTES = 256 * 1024;
87
88
  const MAX_EVENT_BYTES = 8 * 1024 * 1024;
@@ -662,7 +663,7 @@ async function withdrawQueuedMessages(id, prefix, options = {}) {
662
663
  (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_queue_withdrawn", message: "took back queued messages a newer one replaces", meta: { session: id, found: mine.length, removed } });
663
664
  return removed;
664
665
  }
665
- /** The nudge the desk's keeper sends a session that stopped mid-work. */
666
+ /** The nudge Housesitter sends a session that stopped mid-work. */
666
667
  function resumePrompt(state, note) {
667
668
  return [
668
669
  `This session stopped while it was ${state}. Continue exactly where you left off. Anything that was in flight (a shell command, a subagent, a send or a push) was interrupted: re-check its real state before relying on it, and redo it if it did not finish.`,
@@ -770,50 +771,56 @@ function appRunning(options = {}) {
770
771
  return false;
771
772
  }
772
773
  }
773
- // ---------- the app keeper (courtesy restarts) ----------
774
+ // ---------- restarting the app (Housesitter) ----------
774
775
  const realRunFile = (file, args, timeoutMs) => new Promise((resolve) => {
775
776
  (0, node_child_process_1.execFile)(file, args, { timeout: timeoutMs, maxBuffer: 8 * 1024 * 1024 }, (error, stdout, stderr) => {
776
777
  resolve({ code: error ? 1 : 0, stdout: String(stdout), stderr: String(stderr) || (error?.message ?? "") });
777
778
  });
778
779
  });
779
780
  exports.realRunFile = realRunFile;
780
- /** The keeper's launch agent: the node it runs under and its script, from `launchctl print`. */
781
- async function findKeeper(options = {}) {
782
- const run = options.runFile ?? exports.realRunFile;
783
- /* v8 ignore next -- tests always pass a uid; process.getuid exists on every platform the keeper runs on @preserve */
784
- const uid = options.uid ?? process.getuid?.() ?? 0;
785
- const printed = await run("/bin/launchctl", ["print", `gui/${uid}/${exports.KEEPER_LABEL}`], KEEPER_WAIT_MS);
786
- if (printed.code !== 0)
781
+ /** Housesitter's command on this Mac: `HOUSESITTER_BIN`, the checkout at `~/code/housesitter`, or `housesitter` on PATH. */
782
+ function findHousesitter(options = {}) {
783
+ const onPath = (process.env.PATH ?? "").split(path.delimiter).filter(Boolean).map(dir => path.join(dir, "housesitter"));
784
+ const candidates = options.housesitterPaths ?? [process.env[exports.HOUSESITTER_ENV] ?? "", path.join(options.homeDir ?? os.homedir(), "code", "housesitter", "bin", "housesitter.mjs"), ...onPath];
785
+ const found = candidates.find(candidate => candidate && fs.existsSync(candidate));
786
+ if (!found)
787
787
  return null;
788
- const block = printed.stdout.match(/\barguments = \{([\s\S]*?)\n\s*\}/);
789
- const args = block ? block[1].split("\n").map(line => line.trim()).filter(Boolean) : [];
790
- const script = args.find(arg => arg.endsWith("app-keeper.mjs"));
791
- const node = printed.stdout.match(/\bprogram = (.+)/)?.[1]?.trim() ?? args[0];
792
- return script && node ? { node, script } : null;
788
+ return found.endsWith(".mjs") ? { file: process.execPath, args: [found] } : { file: found, args: [] };
793
789
  }
794
- const keeperMissing = () => ({
790
+ const housesitterMissing = () => ({
795
791
  installed: false,
796
- message: `The Copilot app keeper (${exports.KEEPER_LABEL}) is not installed on this Mac, so nothing was queued and the app was not restarted. Install it with \`node app-keeper.mjs install\` from the desk's machine setup.`,
792
+ message: `Housesitter is not on this Mac, so the app was not restarted. Clone https://github.com/ourostack/housesitter to ~/code/housesitter, put \`housesitter\` on PATH, or set ${exports.HOUSESITTER_ENV} to its bin/housesitter.mjs.`,
797
793
  });
798
- async function runKeeper(args, options) {
794
+ async function runHousesitter(args, options) {
799
795
  const run = options.runFile ?? exports.realRunFile;
800
- const keeper = await findKeeper({ ...options, runFile: run });
801
- if (!keeper)
802
- return keeperMissing();
803
- const result = await run(keeper.node, [keeper.script, ...args], KEEPER_WAIT_MS);
804
- if (result.code !== 0)
805
- throw new Error(`the app keeper failed: ${(result.stderr || result.stdout).trim().slice(0, 300)}`);
806
- return { installed: true, output: JSON.parse(result.stdout) };
807
- }
808
- /** Queue a courtesy restart of the app: the keeper restarts now if nobody is at the Mac, else shows its "Restart now" / "Not now" panel. */
796
+ const command = findHousesitter(options);
797
+ if (!command)
798
+ return housesitterMissing();
799
+ const result = await run(command.file, [...command.args, "restart-copilot", ...args, "--json"], HOUSESITTER_WAIT_MS);
800
+ let output = null;
801
+ try {
802
+ output = JSON.parse(result.stdout);
803
+ }
804
+ catch { /* not JSON: housesitter refused or failed */ }
805
+ // `--status` exits 1 for a failed run and `--detach` for a job launchd would not start; both still answer on stdout.
806
+ const answered = output !== null && ("state" in output || output.ok === false);
807
+ if (!output || (result.code !== 0 && !answered))
808
+ throw new Error(`housesitter failed: ${(result.stderr || result.stdout).trim().slice(0, 300)}`);
809
+ return { installed: true, output };
810
+ }
811
+ /** Restart the app now, as a launchd job that outlives the app: Housesitter asks working sessions to reach a safe point, quits the app through its Quit menu (waiting while a person is using the Mac), relaunches it and resumes every session that was working. Read the outcome with {@link restartStatus}. */
809
812
  async function restartEnqueue(why, by, options = {}) {
810
- const result = await runKeeper(["enqueue", "--why", why, "--by", by], options);
811
- (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_restart_enqueued", message: "asked the app keeper for a courtesy restart", meta: { installed: result.installed, why } });
812
- return result.installed ? { installed: true, request: result.output } : result;
813
+ const result = await runHousesitter(["--resume", "--detach", "--why", `${why} (asked by ${by})`], options);
814
+ (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_restart_enqueued", message: "asked housesitter to restart the app", meta: { installed: result.installed, why } });
815
+ if (!result.installed)
816
+ return result;
817
+ if (result.output.ok === false)
818
+ throw new Error(`housesitter did not start the restart: ${String(result.output.error ?? "no reason given")}`);
819
+ return { installed: true, request: result.output };
813
820
  }
814
- /** The keeper's queue, panel, last restarts and resume state. */
821
+ /** The restart in progress or the last one: state (running, done, failed, none), step, start time, result, log. */
815
822
  async function restartStatus(options = {}) {
816
- const result = await runKeeper(["status", "--json"], options);
817
- (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_restart_status", message: "read the app keeper's restart status", meta: { installed: result.installed } });
823
+ const result = await runHousesitter(["--status"], options);
824
+ (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_restart_status", message: "read housesitter's restart status", meta: { installed: result.installed } });
818
825
  return result.installed ? { installed: true, status: result.output } : result;
819
826
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1131",
3
+ "version": "0.1.0-alpha.1132",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@ouro.bot/cli",
9
- "version": "0.1.0-alpha.1131",
9
+ "version": "0.1.0-alpha.1132",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@ouro.bot/friends": "0.1.0-alpha.18",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1131",
3
+ "version": "0.1.0-alpha.1132",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },