@ouro.bot/cli 0.1.0-alpha.1357 → 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,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.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
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1357",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1357",
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.1357</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 } });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1357",
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.1357",
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.1357",
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": {