@ouro.bot/cli 0.1.0-alpha.1130 → 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,18 @@
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
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1131",
12
+ "changes": [
13
+ "The app-sessions sense now notices a session blocked on the Copilot app's repository-trust card, from the notification claim the app records in its database, and tells the owner once per decision with the session name and repository. It shows as waiting in the sidebar picture and in `ouro status`."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1130",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1130",
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.1130</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;
@@ -150,6 +151,39 @@ function databaseRows(stateDir) {
150
151
  return [...db.prepare(withHierarchy(workspaces, "workspaces", "w")).all(), ...db.prepare(withHierarchy(CHAT_ROWS, "sessions", "s")).all()];
151
152
  });
152
153
  }
154
+ function hasTable(db, table) {
155
+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) !== undefined;
156
+ }
157
+ /**
158
+ * The sessions blocked on a repository-trust card. When a session that another session created reaches the card, the app
159
+ * records a `repository_trust` notification claim for it, with the decision id as the watermark, and the claim stays after
160
+ * the person decides. So a claim is an open wait only while the project has no trust grant for the session's host and no
161
+ * newer trust revision. A session nobody coordinates leaves no claim and is not seen here.
162
+ */
163
+ function repositoryTrustWaits(stateDir) {
164
+ return withDatabase(stateDir, (db) => {
165
+ const waits = new Map();
166
+ if (!["creator_notification_claims", "project_host_trust", "project_trust_revisions", "workspaces", "projects"].every(table => hasTable(db, table)))
167
+ return waits;
168
+ const named = hasColumn(db, "projects", "github_owner") && hasColumn(db, "projects", "github_repo");
169
+ const revision = hasColumn(db, "project_trust_revisions", "local_revision") ? "max(r.revision, r.local_revision)" : "r.revision";
170
+ const claims = db.prepare(`
171
+ SELECT c.watermark, w.session_id, p.name AS project, ${named ? "p.github_owner AS owner, p.github_repo AS repo" : "NULL AS owner, NULL AS repo"},
172
+ EXISTS (SELECT 1 FROM project_host_trust h WHERE h.project_id = w.project_id AND h.host_id = coalesce(w.host_id, 'local')) AS trusted,
173
+ (SELECT ${revision} FROM project_trust_revisions r WHERE r.project_id = w.project_id) AS current
174
+ FROM creator_notification_claims c JOIN workspaces w ON w.id = c.workspace_id LEFT JOIN projects p ON p.id = w.project_id
175
+ WHERE c.kind = 'repository_trust' AND w.session_id IS NOT NULL`).all();
176
+ for (const claim of claims) {
177
+ const decided = Number(/:(\d+)$/.exec(claim.watermark)?.[1]);
178
+ if (claim.trusted || Number.isNaN(decided) || (claim.current ?? 0) > decided)
179
+ continue;
180
+ if ((waits.get(claim.session_id)?.revision ?? -1) >= decided)
181
+ continue;
182
+ waits.set(claim.session_id, { decisionId: claim.watermark, repo: claim.owner && claim.repo ? `${claim.owner}/${claim.repo}` : claim.project ?? "this repository", revision: decided });
183
+ }
184
+ return new Map([...waits].map(([session, { decisionId, repo }]) => [session, { decisionId, repo }]));
185
+ });
186
+ }
153
187
  function sessionRecord(stateDir, id) {
154
188
  return withDatabase(stateDir, (db) => db.prepare(`
155
189
  SELECT s.id, s.archived_at, w.id AS workspace_id, w.workspace_type, w.archived_at AS workspace_archived_at
@@ -335,13 +369,15 @@ function listAppSessions(options = {}) {
335
369
  const now = (options.now ?? Date.now)();
336
370
  const seen = new Set();
337
371
  const rows = [];
372
+ const trusts = repositoryTrustWaits(stateDir);
338
373
  for (const row of databaseRows(stateDir)) {
339
374
  if (seen.has(row.id) || !SESSION_ID.test(row.id))
340
375
  continue;
341
376
  seen.add(row.id);
342
377
  const facts = cachedTailFacts(stateDir, row.id);
343
378
  const isRunning = row.is_running === 1;
344
- const { state, detail } = classify(isRunning, facts, now);
379
+ const repositoryTrust = trusts.get(row.id);
380
+ const { state, detail } = repositoryTrust ? { state: "waiting", detail: "waiting for a repository trust decision" } : classify(isRunning, facts, now);
345
381
  rows.push({
346
382
  id: row.id,
347
383
  name: row.name || row.title || (row.workspace_id ? "(unnamed)" : "(unnamed chat)"),
@@ -362,6 +398,7 @@ function listAppSessions(options = {}) {
362
398
  updatedAt: row.updated_at,
363
399
  lastActivity: facts.lastActivity ?? row.updated_at,
364
400
  ...(facts.prompt ? { prompt: facts.prompt } : {}),
401
+ ...(repositoryTrust ? { repositoryTrust } : {}),
365
402
  });
366
403
  }
367
404
  (0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_listed", message: "listed the Copilot app's sessions", meta: { sessions: rows.length } });
@@ -626,7 +663,7 @@ async function withdrawQueuedMessages(id, prefix, options = {}) {
626
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 } });
627
664
  return removed;
628
665
  }
629
- /** The nudge the desk's keeper sends a session that stopped mid-work. */
666
+ /** The nudge Housesitter sends a session that stopped mid-work. */
630
667
  function resumePrompt(state, note) {
631
668
  return [
632
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.`,
@@ -734,50 +771,56 @@ function appRunning(options = {}) {
734
771
  return false;
735
772
  }
736
773
  }
737
- // ---------- the app keeper (courtesy restarts) ----------
774
+ // ---------- restarting the app (Housesitter) ----------
738
775
  const realRunFile = (file, args, timeoutMs) => new Promise((resolve) => {
739
776
  (0, node_child_process_1.execFile)(file, args, { timeout: timeoutMs, maxBuffer: 8 * 1024 * 1024 }, (error, stdout, stderr) => {
740
777
  resolve({ code: error ? 1 : 0, stdout: String(stdout), stderr: String(stderr) || (error?.message ?? "") });
741
778
  });
742
779
  });
743
780
  exports.realRunFile = realRunFile;
744
- /** The keeper's launch agent: the node it runs under and its script, from `launchctl print`. */
745
- async function findKeeper(options = {}) {
746
- const run = options.runFile ?? exports.realRunFile;
747
- /* v8 ignore next -- tests always pass a uid; process.getuid exists on every platform the keeper runs on @preserve */
748
- const uid = options.uid ?? process.getuid?.() ?? 0;
749
- const printed = await run("/bin/launchctl", ["print", `gui/${uid}/${exports.KEEPER_LABEL}`], KEEPER_WAIT_MS);
750
- 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)
751
787
  return null;
752
- const block = printed.stdout.match(/\barguments = \{([\s\S]*?)\n\s*\}/);
753
- const args = block ? block[1].split("\n").map(line => line.trim()).filter(Boolean) : [];
754
- const script = args.find(arg => arg.endsWith("app-keeper.mjs"));
755
- const node = printed.stdout.match(/\bprogram = (.+)/)?.[1]?.trim() ?? args[0];
756
- return script && node ? { node, script } : null;
788
+ return found.endsWith(".mjs") ? { file: process.execPath, args: [found] } : { file: found, args: [] };
757
789
  }
758
- const keeperMissing = () => ({
790
+ const housesitterMissing = () => ({
759
791
  installed: false,
760
- 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.`,
761
793
  });
762
- async function runKeeper(args, options) {
794
+ async function runHousesitter(args, options) {
763
795
  const run = options.runFile ?? exports.realRunFile;
764
- const keeper = await findKeeper({ ...options, runFile: run });
765
- if (!keeper)
766
- return keeperMissing();
767
- const result = await run(keeper.node, [keeper.script, ...args], KEEPER_WAIT_MS);
768
- if (result.code !== 0)
769
- throw new Error(`the app keeper failed: ${(result.stderr || result.stdout).trim().slice(0, 300)}`);
770
- return { installed: true, output: JSON.parse(result.stdout) };
771
- }
772
- /** 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}. */
773
812
  async function restartEnqueue(why, by, options = {}) {
774
- const result = await runKeeper(["enqueue", "--why", why, "--by", by], options);
775
- (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 } });
776
- 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 };
777
820
  }
778
- /** 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. */
779
822
  async function restartStatus(options = {}) {
780
- const result = await runKeeper(["status", "--json"], options);
781
- (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 } });
782
825
  return result.installed ? { installed: true, status: result.output } : result;
783
826
  }
@@ -44,7 +44,7 @@ const owner_notice_1 = require("../shepherd/owner-notice");
44
44
  const store_1 = require("./store");
45
45
  const waiting_status_1 = require("./waiting-status");
46
46
  /**
47
- * A session frozen on a permission prompt looks idle from outside, and only the person can answer it in the app. The
47
+ * A session frozen on a permission prompt, or on a repository-trust card, looks idle from outside, and only the person can answer it in the app. The
48
48
  * snapshot already reads every session's history each minute, so noticing is deterministic and costs no model turn:
49
49
  * a prompt open for more than two minutes is told to the owner once, in one plain message, through the same proactive
50
50
  * path Shepherd's owner notices use. A prompt older than a day is shown in `ouro status` but never announced: it is
@@ -57,11 +57,15 @@ exports.WAITING_LIST_MAX = 6;
57
57
  const stateFile = (agentRoot) => path.join((0, store_1.appSessionsStateDir)(agentRoot), "waiting-prompts.json");
58
58
  const promptKey = (prompt) => `${prompt.session}:${prompt.requestId}`;
59
59
  exports.promptKey = promptKey;
60
- /** The open permission prompts in the sidebar. A prompt the app timed without an event time keeps the first time it was seen. */
60
+ /** The open permission prompts and repository-trust decisions in the sidebar. One the app gave no event time keeps the first time it was seen. */
61
61
  function waitingPromptsOf(agentRoot, rows, now) {
62
62
  const before = new Map(((0, store_1.readSnapshot)(agentRoot)?.waitingPrompts ?? []).map(prompt => [(0, exports.promptKey)(prompt), prompt.since]));
63
63
  const prompts = [];
64
64
  for (const row of rows) {
65
+ if (row.repositoryTrust) {
66
+ const requestId = row.repositoryTrust.decisionId;
67
+ prompts.push({ session: row.id, name: row.name, requestId, what: `a repository trust decision for ${row.repositoryTrust.repo}`, since: before.get((0, exports.promptKey)({ session: row.id, requestId })) ?? now });
68
+ }
65
69
  if (!row.prompt)
66
70
  continue;
67
71
  const stamped = Date.parse(row.prompt.at ?? "");
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1130",
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.1130",
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.1130",
3
+ "version": "0.1.0-alpha.1132",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },