@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 +12 -0
- package/deploy/unraid/sanctuary-replay-gate.mjs +6 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/core.js +15 -10
- package/dist/repertoire/tools-app-sessions.js +5 -5
- package/dist/senses/app-sessions/client.js +43 -36
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
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
|
|
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,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.
|
|
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>
|
package/dist/heart/core.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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: "
|
|
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
|
|
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;
|
|
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: "
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
781
|
-
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
|
|
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
|
-
|
|
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
|
|
790
|
+
const housesitterMissing = () => ({
|
|
795
791
|
installed: false,
|
|
796
|
-
message: `
|
|
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
|
|
794
|
+
async function runHousesitter(args, options) {
|
|
799
795
|
const run = options.runFile ?? exports.realRunFile;
|
|
800
|
-
const
|
|
801
|
-
if (!
|
|
802
|
-
return
|
|
803
|
-
const result = await run(
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
|
|
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
|
|
811
|
-
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_restart_enqueued", message: "asked
|
|
812
|
-
|
|
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
|
|
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
|
|
817
|
-
(0, runtime_1.emitNervesEvent)({ component: "senses", event: "senses.app_sessions_restart_status", message: "read
|
|
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
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
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.
|
|
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",
|