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

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.1133",
6
+ "changes": [
7
+ "My errors come back to me: a rejected or unparseable settle is answered with why, and I correct course instead of the turn failing; my house notes count however I write them."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1132",
12
+ "changes": [
13
+ "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."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1131",
6
18
  "changes": [
@@ -352,6 +352,9 @@ const filedWithClaudeCode = (trace) => trace.some((entry) => entry.name === "rep
352
352
  /** The path a write_file or edit_file call names, or "" when its arguments are not JSON with a string path. */
353
353
  const filePathOf = (args) => { try { const parsed = JSON.parse(String(args ?? "")); return typeof parsed?.path === "string" ? parsed.path : "" } catch { return "" } }
354
354
  const WROTE_TACIT = /(?:^|\/)psyche\/TACIT\.md$/
355
+ /** A shell command that writes TACIT.md: a redirect, tee, or sed -i onto it. How he writes it is his call; the file is checked separately. */
356
+ const SHELL_WROTE_TACIT = /(?:>>?|\btee\b(?:\s+-a)?)\s*["']?(?:\S*\/)?TACIT\.md\b|\bsed\s+-i\S*\s[^|;&]*TACIT\.md\b/
357
+ const commandOf = (args) => { try { const parsed = JSON.parse(String(args ?? "")); return typeof parsed?.command === "string" ? parsed.command : "" } catch { return "" } }
355
358
  // Scoped to media-ask-no-hedge (REPLY_HEDGE_TERMS is pinned by the no-hedge psyche work): a refusal of the torrent, never a
356
359
  // plain "no torrent needed", which is right for a title already in the library. Each torrent pattern stays in one sentence.
357
360
  const TORRENT_DEFLECTIONS = [
@@ -571,13 +574,14 @@ export const CASES = [
571
574
  sender: "principal",
572
575
  delegated: false,
573
576
  readback: ({ trace, before, after }) => {
574
- const writes = trace.filter((entry) => /^(write_file|edit_file)$/.test(entry.name) && WROTE_TACIT.test(filePathOf(entry.args)))
577
+ const writes = trace.filter((entry) => (/^(write_file|edit_file)$/.test(entry.name) && WROTE_TACIT.test(filePathOf(entry.args)))
578
+ || (entry.name === "shell" && SHELL_WROTE_TACIT.test(commandOf(entry.args))))
575
579
  // A refused write leaves TACIT as it was, so a TACIT that already mentioned subtitles must also have changed.
576
580
  const was = before.tacit?.text ?? null
577
581
  const now = after.tacit?.text ?? ""
578
582
  const learned = /subtitle/i.test(now) && (!/subtitle/i.test(was ?? "") || was !== now)
579
583
  return [
580
- check("a write_file or edit_file call wrote psyche/TACIT.md", writes.length > 0, `${trace.length} tool calls`),
584
+ check("a tool call wrote psyche/TACIT.md (write_file, edit_file or a shell write)", writes.length > 0, `${trace.length} tool calls`),
581
585
  check("TACIT gained the subtitle rule during the case (it mentions subtitles now, and did not before or has new text)", learned),
582
586
  check("the identity files (SOUL, IDENTITY, LORE, ASPIRATIONS) are unchanged", before.identitySha !== null && before.identitySha === after.identitySha),
583
587
  ]
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1131",
2
+ "runtimeVersion": "0.1.0-alpha.1133",
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.1133</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -1313,7 +1313,11 @@ async function runAgent(messages, callbacks, channel, signal, options) {
1313
1313
  const queueRequiredCorrection = (assistant, message, limitContext) => {
1314
1314
  if (budgetExhausted())
1315
1315
  throw new Error(`provider iteration limit exhausted at response ${stepBudget} ${limitContext}`);
1316
- rejectAttempt(assistant, [{ role: "user", content: message }]);
1316
+ // A rejected tool call (settle, a terminal tool) is answered by its own tool result, so the agent reads why and corrects course.
1317
+ if (assistant.tool_calls?.length)
1318
+ rejectToolBatch(assistant, assistant.tool_calls.map(() => message));
1319
+ else
1320
+ rejectAttempt(assistant, [{ role: "user", content: message }]);
1317
1321
  };
1318
1322
  const toolLoopState = (0, tool_loop_1.createToolLoopState)();
1319
1323
  const toolFrictionLedger = (0, tool_friction_1.createToolFrictionLedger)();
@@ -1501,6 +1505,9 @@ async function runAgent(messages, callbacks, channel, signal, options) {
1501
1505
  messages: [...canonicalBudget.messages, ...rejectedAttempt, ...nextAttemptControls],
1502
1506
  }).messages]
1503
1507
  : [...canonicalBudget.messages];
1508
+ // Whatever path built this request, every tool call reaches the provider with a result: a gap the runtime left must
1509
+ // never 400 the turn and leave the agent unable to answer.
1510
+ repairOrphanedToolCalls(attemptMessages);
1504
1511
  if (rejectedAttempt.length > 0 || canonicalBudget.status !== "within_budget")
1505
1512
  providerRuntime.resetTurnState(attemptMessages);
1506
1513
  const turnCallbackBufferRef = { current: null };
@@ -1622,15 +1629,6 @@ async function runAgent(messages, callbacks, channel, signal, options) {
1622
1629
  }
1623
1630
  const streamCallbackBuffer = turnCallbackBufferRef.current;
1624
1631
  turnCallbackBufferRef.current = null;
1625
- if (result.settleFinalization && !result.settleFinalization.ok) {
1626
- // A completed settle payload is terminal provider output, not a prompt
1627
- // for another model turn. Retractable callbacks have already cleared;
1628
- // core-owned callback buffers must be discarded before surfacing the exact
1629
- // parser failure through the ordinary terminal-error path.
1630
- streamCallbackBuffer?.discard();
1631
- finishTerminalProviderError(new Error(result.settleFinalization.errorCode), "unknown");
1632
- continue;
1633
- }
1634
1632
  // Track usage from the latest API call
1635
1633
  if (result.usage)
1636
1634
  lastUsage = result.usage;
@@ -1685,6 +1683,13 @@ async function runAgent(messages, callbacks, channel, signal, options) {
1685
1683
  if (thinkingItems.length > 0) {
1686
1684
  msg._thinking_blocks = thinkingItems;
1687
1685
  }
1686
+ if (result.settleFinalization && !result.settleFinalization.ok) {
1687
+ // An unparseable settle is the agent's own output: nothing reached anyone, so the agent reads why and settles again.
1688
+ // Retractable callbacks have already cleared; core-owned callback buffers are discarded with the attempt.
1689
+ streamCallbackBuffer?.discard();
1690
+ queueRequiredCorrection(msg, `settle was not delivered: its arguments did not parse (${result.settleFinalization.errorCode}). Call settle again with valid JSON arguments.`, "after an unparseable settle");
1691
+ continue;
1692
+ }
1688
1693
  const settlingNow = result.toolCalls.length === 1 && (result.toolCalls[0].name === "settle" || result.toolCalls[0].name === "rest");
1689
1694
  if (stepReportIteration === null && result.toolCalls.length > 0 && !settlingNow && budgetExhausted()) {
1690
1695
  const wrapUpTool = candidateToolNames.has("settle") ? "settle" : candidateToolNames.has("rest") ? "rest" : null;
@@ -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.1133",
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.1133",
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.1133",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },