@ouro.bot/cli 0.1.0-alpha.1356 → 0.1.0-alpha.1358

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.1358",
6
+ "changes": [
7
+ "The Butler's media tools follow trust rungs: a friend can find media and clear a stuck download, while changing quality or release profiles, removing blocklist entries, forcing a stalled download out, retrying blocklisted releases and replacing an existing file stay with family."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1357",
12
+ "changes": [
13
+ "send_message, read_file, edit_file, grep, shell and load_skill are marked to stay loaded once tools are deferred."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1356",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1356",
2
+ "runtimeVersion": "0.1.0-alpha.1358",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1482,9 +1482,11 @@ export async function mediaManualImport(a) {
1482
1482
  return { path: f.path, seriesId, episodeIds: f.episode_ids.map(Number), quality: r.quality, languages: r.languages, releaseGroup: r.releaseGroup ?? "",
1483
1483
  indexerFlags: r.indexerFlags ?? 0, releaseType: r.releaseType ?? "unknown", downloadId: a.download_id }
1484
1484
  })
1485
- const c = await sonarr("/command", { method: "POST", body: { name: "ManualImport", files, importMode: "auto" } })
1486
- // Episodes that already had a file: Sonarr treats these imports as replacements.
1485
+ // Episodes that already had a file: Sonarr treats these imports as replacements, which is family-only (spec R12). The harness
1486
+ // guard stamps caller_rung; a call with no stamp (run outside the harness) is treated as family, as before.
1487
1487
  const replacing = seriesEps.filter((e) => e.hasFile && targets.includes(e.id)).map((e) => ({ episode_id: e.id, code: sxe(e) }))
1488
+ if (a.caller_rung === "friend" && replacing.length) return { result: "family_only", tool: "media_manual_import", argument: "files", replacing }
1489
+ const c = await sonarr("/command", { method: "POST", body: { name: "ManualImport", files, importMode: "auto" } })
1488
1490
  return { mode: "import", imported: a.files.map((f) => ({ path: f.path, episode_ids: f.episode_ids })), ...(replacing.length ? { replacing } : {}), command: { id: c?.id ?? null, name: c?.name ?? "ManualImport", status: c?.status ?? null } }
1489
1491
  }
1490
1492
 
@@ -2408,6 +2410,7 @@ const TOOL_LIST = [
2408
2410
  service_id: { type: "number", description: "Sonarr series id." },
2409
2411
  download_id: { type: "string", description: "Download client id of the completed download (queue row downloadId)." },
2410
2412
  files: { type: "array", items: { type: "object", properties: { path: { type: "string" }, episode_ids: { type: "array", items: { type: "number" } } }, required: ["path", "episode_ids"] } },
2413
+ caller_rung: { type: "string", enum: ["family", "friend"], description: "Filled in by the runtime from who is asking; leave it out. An import that replaces a file is for family." },
2411
2414
  }, required: ["service_id", "download_id"] },
2412
2415
  },
2413
2416
  ]
@@ -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.1356</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1358</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REPLAY_REFUSED_WRITE_TOOLS = exports.OWNER_ONLY_WRITE_TOOLS = void 0;
3
+ exports.REPLAY_REFUSED_WRITE_TOOLS = exports.RUNG_STAMPED_TOOLS = exports.FAMILY_ONLY_ARGUMENTS = exports.OWNER_ONLY_WRITE_TOOLS = void 0;
4
+ exports.callerRung = callerRung;
4
5
  exports.guardMcpArgs = guardMcpArgs;
5
6
  /**
6
7
  * Runtime guards on MCP tool arguments that the MCP server itself cannot enforce, because only the runtime knows who is calling.
@@ -8,16 +9,49 @@ exports.guardMcpArgs = guardMcpArgs;
8
9
  * - A replay identity (the host's replay gate, src/a2a/replay-harness.ts) never applies a change: every tool that declares a
9
10
  * `dry_run` argument is forced to a dry run for it, so a gate case can never alter the live house.
10
11
  * - A replay identity may not call a write tool that has no dry run at all (see REPLAY_REFUSED_WRITE_TOOLS).
11
- * - Some tools change settings only the owner may change: applying (dry_run false) is refused for any other caller, and the
12
- * caller is stamped into the arguments so the tool's audit line names who asked.
12
+ * - Media trust rungs (spec R12): a friend may do everything that finds media and makes it available; some arguments are
13
+ * family-only. The rung is the caller's trust level, not its profile, so an agent peer gets the rung of its friend record.
14
+ * A family-only argument from a friend returns the policy result `{ result: "family_only", tool, argument }`.
15
+ * - The quality and release profile tools stamp the caller into the arguments, so the tool's audit line names who asked.
13
16
  */
14
17
  const replay_harness_1 = require("../a2a/replay-harness");
15
18
  const runtime_1 = require("../nerves/runtime");
16
- /** MCP tools whose applied writes are owner-only. */
19
+ /** MCP tools whose applied writes are family-only, and which stamp the caller. */
17
20
  exports.OWNER_ONLY_WRITE_TOOLS = new Set(["media_quality_profile", "media_release_profile"]);
21
+ const nonEmpty = (value) => (Array.isArray(value) ? value.length > 0 : typeof value === "string" ? value.trim() !== "" : value !== undefined && value !== null);
22
+ /** A call applies unless it says dry_run === true (an omitted dry_run is not a loophole); a read never applies. */
23
+ const applies = (args) => args.dry_run !== true && args.dry_run !== "true" && args.action !== "read";
24
+ /**
25
+ * The family-only column of the rung table: for each tool, the argument a friend may not use, and when a call uses it.
26
+ * media_manual_import's family-only case (an import that replaces a file) is known only to the tool, so it gets the rung stamped.
27
+ */
28
+ exports.FAMILY_ONLY_ARGUMENTS = {
29
+ media_quality_profile: { argument: "dry_run", used: applies },
30
+ media_release_profile: { argument: "dry_run", used: applies },
31
+ media_blocklist: { argument: "remove_ids", used: (args) => nonEmpty(args.remove_ids) },
32
+ media_blocklist_stalled: { argument: "owner_words", used: (args) => nonEmpty(args.owner_words) },
33
+ media_fill_missing: { argument: "retry_blocklisted", used: (args) => nonEmpty(args.retry_blocklisted) },
34
+ };
35
+ /** Tools that decide a family-only case themselves, from the rung the guard stamps as `caller_rung`. */
36
+ exports.RUNG_STAMPED_TOOLS = new Set(["media_manual_import"]);
37
+ /**
38
+ * The caller's rung: family for a family friend record, the owner profile, or the agent's own turn (no friend and no relationship);
39
+ * friend for anyone else, including unknown trust and a call with no turn context at all.
40
+ */
41
+ function callerRung(ctx) {
42
+ if (ctx === undefined)
43
+ return "friend";
44
+ if (ctx.relationshipAuthorization?.profileId === "sanctuary-owner")
45
+ return "family";
46
+ const friendId = ctx?.context?.friend?.id ?? ctx?.relationshipAuthorization?.actor?.friendId;
47
+ // No friend and no relationship is the agent's own turn; a relationship with no friend behind it is not trusted as family.
48
+ if (friendId === undefined)
49
+ return ctx.relationshipAuthorization === undefined ? "family" : "friend";
50
+ const trust = ctx?.context?.friend?.trustLevel ?? ctx?.relationshipAuthorization?.actor?.trustLevel;
51
+ return trust === "family" ? "family" : "friend";
52
+ }
18
53
  /** MCP tools that change the house and have no dry run: a replay identity may not call them at all. media_manual_import is a write only in `import` mode. */
19
54
  exports.REPLAY_REFUSED_WRITE_TOOLS = new Set(["media_request", "media_search_now", "media_blocklist", "media_blocklist_stalled", "media_fill_missing", "media_monitor", "media_release_grab", "media_manual_import"]);
20
- const isWrite = (args) => (args.dry_run === false || args.dry_run === "false") && args.action !== "read";
21
55
  function callerFriend(ctx) {
22
56
  const friend = ctx?.context?.friend;
23
57
  return { id: friend?.id ?? ctx?.relationshipAuthorization?.actor?.friendId, name: friend?.name };
@@ -26,13 +60,18 @@ function guardMcpArgs(input) {
26
60
  const { toolName, declaresDryRun, ctx } = input;
27
61
  let args = input.args;
28
62
  const caller = callerFriend(ctx);
63
+ const rung = callerRung(ctx);
64
+ const familyOnly = exports.FAMILY_ONLY_ARGUMENTS[toolName];
65
+ if (familyOnly && rung === "friend" && familyOnly.used(args)) {
66
+ (0, runtime_1.emitNervesEvent)({ level: "warn", component: "repertoire", event: "mcp.write_refused_non_owner", message: "a family-only MCP argument was refused for a friend", meta: { tool: toolName, argument: familyOnly.argument } });
67
+ return { rejected: JSON.stringify({ result: "family_only", tool: toolName, argument: familyOnly.argument }) };
68
+ }
29
69
  if (exports.OWNER_ONLY_WRITE_TOOLS.has(toolName)) {
30
- if (isWrite(args) && ctx?.relationshipAuthorization?.profileId !== "sanctuary-owner") {
31
- (0, runtime_1.emitNervesEvent)({ level: "warn", component: "repertoire", event: "mcp.write_refused_non_owner", message: "an owner-only MCP write was refused", meta: { tool: toolName } });
32
- return { rejected: `${toolName} changes settings only the owner may change. Show the owner the dry run and ask them to confirm; do not apply it for anyone else.` };
33
- }
34
70
  args = { ...args, caller: caller.id ? `${caller.id}${caller.name ? ` (${caller.name})` : ""}` : "unknown" };
35
71
  }
72
+ // The model's own caller_rung is never trusted: the guard always writes it.
73
+ if (exports.RUNG_STAMPED_TOOLS.has(toolName))
74
+ args = { ...args, caller_rung: rung };
36
75
  const replay = Boolean(caller.id && ctx?.agentRoot && (0, replay_harness_1.isReplayIdentity)(ctx.agentRoot, caller.id));
37
76
  if (replay && !declaresDryRun && exports.REPLAY_REFUSED_WRITE_TOOLS.has(toolName) && (toolName !== "media_manual_import" || args.mode === "import")) {
38
77
  (0, runtime_1.emitNervesEvent)({ level: "warn", component: "repertoire", event: "mcp.replay_write_refused", message: "a replay identity's MCP write with no dry run was refused", meta: { tool: toolName } });
@@ -170,7 +170,7 @@ exports.fileToolDefinitions = [
170
170
  },
171
171
  summaryKeys: ["path"],
172
172
  riskProfile: READS_ONLY,
173
- ax: { id: "tool:read_file", group: "turn-files", when: "Pick this to see a file's exact text before you quote or change it; to find which file holds something, grep or glob first.", effect: "read", idempotent: true, errors: [
173
+ ax: { id: "tool:read_file", eager: true, group: "turn-files", when: "Pick this to see a file's exact text before you quote or change it; to find which file holds something, grep or glob first.", effect: "read", idempotent: true, errors: [
174
174
  { code: "guardrail-blocked", means: "The path is inside the folder holding the sync key, which no tool may read, or the path can't be resolved (a link loop or a folder you can't open).", fix: "Read a file outside that folder; for a path that won't resolve, check it with ls first." },
175
175
  { code: "invalid-arguments", means: "path is missing, or offset, limit or char_offset isn't a number.", fix: "Call read_file again with path as text and offset, limit and char_offset as numbers." },
176
176
  ] },
@@ -288,7 +288,7 @@ exports.fileToolDefinitions = [
288
288
  },
289
289
  summaryKeys: ["path"],
290
290
  riskProfile: { mutates: "durable_state_write", risk: "high", reason: "edits file contents" },
291
- ax: { id: "tool:edit_file", group: "turn-files", when: "Pick this to change one exact passage of a file you have read, including psyche/TACIT.md, where what you've learned about how things work here lives; write_file is for new files and full rewrites.", effect: "write", errors: [
291
+ ax: { id: "tool:edit_file", eager: true, group: "turn-files", when: "Pick this to change one exact passage of a file you have read, including psyche/TACIT.md, where what you've learned about how things work here lives; write_file is for new files and full rewrites.", effect: "write", errors: [
292
292
  { code: "read-first", means: "You haven't read this file with read_file yet, so the edit was refused.", fix: "Call read_file on the same path, then send the edit again." },
293
293
  { code: "no-match", means: "old_string appears nowhere in the file, often because whitespace or an earlier edit differs.", fix: "Read the file again and copy old_string from it exactly, indentation included." },
294
294
  { code: "ambiguous-match", means: "old_string appears more than once, so the edit can't tell which place you mean.", fix: "Add surrounding lines to old_string until it matches one place only." },
@@ -489,7 +489,7 @@ exports.fileToolDefinitions = [
489
489
  },
490
490
  summaryKeys: ["pattern", "path", "include"],
491
491
  riskProfile: READS_ONLY,
492
- ax: { id: "tool:grep", group: "turn-files", when: "Pick this to learn which files and lines contain some text or regex; then read_file shows a match in full.", effect: "read", idempotent: true, errors: [
492
+ ax: { id: "tool:grep", eager: true, group: "turn-files", when: "Pick this to learn which files and lines contain some text or regex; then read_file shows a match in full.", effect: "read", idempotent: true, errors: [
493
493
  { code: "guardrail-blocked", means: "The search path is, or contains, the folder holding the sync key, or it can't be resolved.", fix: "Pass a narrower path that leaves that folder out." },
494
494
  { code: "invalid-arguments", means: "pattern is missing, or context_lines, ignore_case or files_only has the wrong type.", fix: "Call grep again with pattern as text, context_lines as a number and the flags as true or false." },
495
495
  ] },
@@ -104,7 +104,7 @@ exports.notesToolDefinitions = [
104
104
  },
105
105
  summaryKeys: ["name"],
106
106
  riskProfile: { mutates: "none", risk: "low" },
107
- ax: { id: "tool:load_skill", group: "turn-skills", when: "Pick this to read a skill's full steps once list_skills has shown you its exact name.", effect: "read", idempotent: true, errors: [
107
+ ax: { id: "tool:load_skill", eager: true, group: "turn-skills", when: "Pick this to read a skill's full steps once list_skills has shown you its exact name.", effect: "read", idempotent: true, errors: [
108
108
  { code: "skill-not-found", means: "No skill with that name could be found or read; the message lists the folders checked.", fix: "Call list_skills and load one of the names it returns, spelled exactly." },
109
109
  ] },
110
110
  },
@@ -1141,7 +1141,7 @@ exports.sessionToolDefinitions = [
1141
1141
  return renderCrossChatDeliveryStatus(`${friendId} on ${channel}/${key}`, deliveryResult);
1142
1142
  },
1143
1143
  riskProfile: sendMessageRiskProfile,
1144
- ax: { id: "tool:send_message", group: "turn-sessions", when: "Pick this to reach someone in a different chat or channel than this one, or a phone call by voice; to keep thinking privately, use ponder.", effect: "write", errors: [
1144
+ ax: { id: "tool:send_message", eager: true, group: "turn-sessions", when: "Pick this to reach someone in a different chat or channel than this one, or a phone call by voice; to keep thinking privately, use ponder.", effect: "write", errors: [
1145
1145
  { code: "delivery-blocked", means: "The message wasn't sent: no routable chat exists for that session, or the text carries internal markers.", fix: "Check the friend and channel with query_session, and remove internal notes from the content." },
1146
1146
  { code: "delivery-failed", means: "The channel tried to send and failed, or the person can't be reached that way.", fix: "Try again once, or reach them on another channel they use." },
1147
1147
  { code: "orientation-hold", means: "This turn is on a correction hold, so messages to other chats wait.", fix: "Call orientation_get, settle what the person meant, then send if it still fits." },
@@ -195,7 +195,7 @@ exports.shellToolDefinitions = [
195
195
  return output;
196
196
  },
197
197
  summaryKeys: ["command"],
198
- ax: { id: "tool:shell", group: "turn-shell", when: "Pick this to run a program or script in your home; for plain file reads and searches, read_file, grep and glob are safer.", effect: "consequential", confirm: "Approve shell with exact arguments <the call's arguments as JSON>?", errors: [
198
+ ax: { id: "tool:shell", eager: true, group: "turn-shell", when: "Pick this to run a program or script in your home; for plain file reads and searches, read_file, grep and glob are safer.", effect: "consequential", confirm: "Approve shell with exact arguments <the call's arguments as JSON>?", errors: [
199
199
  { code: "command-failed", means: "The command ran and exited non-zero; its stdout and stderr follow the first line.", fix: "Read stderr, fix the command or its input, and run it again." },
200
200
  { code: "command-timed-out", means: "The command ran past its timeout and was stopped; whatever it printed follows.", fix: "Run it again with a larger timeout_ms, at most 600000, or with background: true and watch it with shell_status." },
201
201
  { code: "command-not-started", means: "The shell couldn't start the command at all, so nothing ran.", fix: "Check the program's name and that it is installed, then run it again." },
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1356",
3
+ "version": "0.1.0-alpha.1358",
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.1356",
9
+ "version": "0.1.0-alpha.1358",
10
10
  "bundleDependencies": [
11
11
  "@ouro.bot/friends"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1356",
3
+ "version": "0.1.0-alpha.1358",
4
4
  "description": "Ouroboros, the agent harness: agents with durable memory that live where you talk (terminal, Teams, iMessage, mail, voice) and use real tools. Start with npx ouro.bot@latest.",
5
5
  "homepage": "https://ouroboros.bot/",
6
6
  "engines": {