@ouro.bot/cli 0.1.0-alpha.1127 → 0.1.0-alpha.1129

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.1129",
6
+ "changes": [
7
+ "New media tools: media_monitor turns Sonarr monitoring on or off for whole seasons or single episodes (and can search them), and media_watch_history reads a Jellyfin user's watched and half-watched items, newest first, with completion percent and last played."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1128",
12
+ "changes": [
13
+ "An await the agent files from its private runtime is no longer cancelled on its first check, and a blocked await send tells the agent why and that it can message the person itself, then cancel the await."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1127",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1127",
2
+ "runtimeVersion": "0.1.0-alpha.1129",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1185,6 +1185,71 @@ export async function mediaEpisodes(a) {
1185
1185
  }
1186
1186
  }
1187
1187
 
1188
+ // Season and episode monitoring: what Sonarr searches for on its own. A season's flag lives on the series;
1189
+ // its episodes carry their own flags, so both are set to match.
1190
+ export async function mediaMonitor(a) {
1191
+ if (a.service_id === undefined || a.service_id === null) return { result: "service_id_required" }
1192
+ const seasons = Array.isArray(a.season_numbers) ? a.season_numbers.map(Number) : []
1193
+ const picked = Array.isArray(a.episode_ids) ? a.episode_ids.map(Number) : []
1194
+ if (!seasons.length && !picked.length) return { result: "seasons_or_episodes_required" }
1195
+ if (typeof a.monitored !== "boolean") return { result: "monitored_required" }
1196
+ const seriesId = Number(a.service_id)
1197
+ const episodeIds = [...picked]
1198
+ if (seasons.length) {
1199
+ const series = await sonarr(`/series/${seriesId}`)
1200
+ const has = (series.seasons ?? []).map((x) => x.seasonNumber)
1201
+ const unknown = seasons.filter((n) => !has.includes(n))
1202
+ if (unknown.length) return { result: "unknown_season", series_id: seriesId, seasons: unknown, has }
1203
+ await sonarr(`/series/${seriesId}`, { method: "PUT", body: { ...series, seasons: series.seasons.map((x) => seasons.includes(x.seasonNumber) ? { ...x, monitored: a.monitored } : x) } })
1204
+ for (const e of await seriesEpisodes(seriesId)) if (seasons.includes(e.seasonNumber) && !episodeIds.includes(e.id)) episodeIds.push(e.id)
1205
+ }
1206
+ if (episodeIds.length) await sonarr("/episode/monitor", { method: "PUT", body: { episodeIds, monitored: a.monitored } })
1207
+ const searched = []
1208
+ if (a.search && a.monitored) {
1209
+ for (const seasonNumber of seasons) {
1210
+ await sonarr("/command", { method: "POST", body: { name: "SeasonSearch", seriesId, seasonNumber } })
1211
+ searched.push(`season ${seasonNumber}`)
1212
+ }
1213
+ if (picked.length) {
1214
+ await sonarr("/command", { method: "POST", body: { name: "EpisodeSearch", episodeIds: picked } })
1215
+ searched.push(`episodes ${picked.join(", ")}`)
1216
+ }
1217
+ }
1218
+ return { result: "monitoring_changed", series_id: seriesId, monitored: a.monitored, seasons, episode_ids: episodeIds, searched }
1219
+ }
1220
+
1221
+ const WATCH_STATES = ["all", "played", "in_progress"]
1222
+ const jellyfin = (path, opts = {}) => req(JELLYFIN.url, path, { key: JELLYFIN.apiKey, header: "X-Emby-Token", ...opts })
1223
+
1224
+ // One Jellyfin user's watched and half-watched items, newest first.
1225
+ export async function mediaWatchHistory(a) {
1226
+ if (!JELLYFIN.url || !JELLYFIN.apiKey) return { result: "jellyfin_not_configured" }
1227
+ const state = a.state ?? "all"
1228
+ if (!WATCH_STATES.includes(state)) return { result: "bad_state", states: WATCH_STATES }
1229
+ const users = (await jellyfin("/Users")) ?? []
1230
+ const names = users.map((u) => u.Name)
1231
+ if (!a.user) return { result: "user_required", users: names }
1232
+ const wanted = String(a.user).toLowerCase()
1233
+ const user = users.find((u) => u.Id === a.user || String(u.Name).toLowerCase() === wanted)
1234
+ if (!user) return { result: "unknown_user", users: names }
1235
+ const filters = state === "all" ? ["IsResumable", "IsPlayed"] : [state === "played" ? "IsPlayed" : "IsResumable"]
1236
+ const pages = await Promise.all(filters.map((Filters) => jellyfin(`/Users/${user.Id}/Items`, { query: {
1237
+ Filters, Recursive: true, IncludeItemTypes: "Episode,Movie", Fields: "UserData", SortBy: "DatePlayed", SortOrder: "Descending", Limit: 500 } })))
1238
+ const title = a.title ? normalizeTitle(String(a.title)) : null
1239
+ const items = pages.flatMap((page) => page?.Items ?? [])
1240
+ .filter((i) => !title || [i.Name, i.SeriesName].some((n) => n && normalizeTitle(n).includes(title)))
1241
+ .map((i) => {
1242
+ const d = i.UserData ?? {}
1243
+ const episode = i.Type === "Episode"
1244
+ return { kind: episode ? "episode" : "movie", title: i.Name, series: i.SeriesName ?? null,
1245
+ code: episode && Number.isInteger(i.ParentIndexNumber) && Number.isInteger(i.IndexNumber) ? sxe({ seasonNumber: i.ParentIndexNumber, episodeNumber: i.IndexNumber }) : null,
1246
+ played: Boolean(d.Played), percent: d.Played ? 100 : Math.round(d.PlayedPercentage ?? 0), play_count: d.PlayCount ?? 0, last_played: d.LastPlayedDate ?? null }
1247
+ })
1248
+ .sort((x, y) => String(y.last_played ?? "").localeCompare(String(x.last_played ?? "")))
1249
+ .slice(0, Number(a.limit) > 0 ? Number(a.limit) : 50)
1250
+ return { result: "watch_history", user: user.Name, count: items.length, items }
1251
+ }
1252
+
1188
1253
  // Free-text search across every Prowlarr indexer: discovery only, it grabs nothing.
1189
1254
  // Sonarr's own search only asks for the season/episode codes it expects; this finds
1190
1255
  // what exists under any name (another numbering, a "Season 2 (2020)" pack, an episode title).
@@ -2157,6 +2222,29 @@ const TOOL_LIST = [
2157
2222
  season_number: { type: "number" },
2158
2223
  }, required: ["service_id"] },
2159
2224
  },
2225
+ {
2226
+ name: "media_monitor",
2227
+ annotations: { readOnlyHint: false },
2228
+ description: "Turn Sonarr monitoring on or off for whole seasons (season_numbers) or single episodes (episode_ids, from media_episodes). Monitored is what Sonarr searches for on its own. search: true also searches what was just monitored.",
2229
+ inputSchema: { type: "object", properties: {
2230
+ service_id: { type: "number", description: "Sonarr series id." },
2231
+ season_numbers: { type: "array", items: { type: "number" } },
2232
+ episode_ids: { type: "array", items: { type: "number" } },
2233
+ monitored: { type: "boolean" },
2234
+ search: { type: "boolean" },
2235
+ }, required: ["service_id", "monitored"] },
2236
+ },
2237
+ {
2238
+ name: "media_watch_history",
2239
+ annotations: { readOnlyHint: true },
2240
+ description: "What a Jellyfin user has watched or is partway through: episodes and movies with completion percent, play count and last played, newest first. Filter by title (a series or movie) and state (all, played, in_progress).",
2241
+ inputSchema: { type: "object", properties: {
2242
+ user: { type: "string", description: "Jellyfin user name or id." },
2243
+ title: { type: "string" },
2244
+ state: { type: "string", enum: WATCH_STATES },
2245
+ limit: { type: "number" },
2246
+ }, required: [] },
2247
+ },
2160
2248
  {
2161
2249
  name: "media_indexer_search",
2162
2250
  annotations: { readOnlyHint: true },
@@ -2276,6 +2364,8 @@ const HANDLERS = {
2276
2364
  media_queue: mediaQueue,
2277
2365
  media_blocklist_stalled: mediaBlocklistStalled,
2278
2366
  media_episodes: mediaEpisodes,
2367
+ media_monitor: mediaMonitor,
2368
+ media_watch_history: mediaWatchHistory,
2279
2369
  media_fill_missing: mediaFillMissing,
2280
2370
  media_indexer_search: mediaIndexerSearch,
2281
2371
  media_release_search: mediaReleaseSearch,
@@ -2,7 +2,7 @@
2
2
  "version": 2,
3
3
  "profiles": {
4
4
  "sanctuary-owner": {
5
- "version": 22,
5
+ "version": 23,
6
6
  "contextScopes": [
7
7
  "household.status",
8
8
  "household.policy",
@@ -78,6 +78,8 @@
78
78
  "media_queue",
79
79
  "media_blocklist_stalled",
80
80
  "media_episodes",
81
+ "media_monitor",
82
+ "media_watch_history",
81
83
  "media_indexer_search",
82
84
  "media_release_search",
83
85
  "media_release_grab",
@@ -158,7 +160,7 @@
158
160
  ]
159
161
  },
160
162
  "sanctuary-agent-peer": {
161
- "version": 12,
163
+ "version": 13,
162
164
  "toolNames": [
163
165
  "external_event_disposition",
164
166
  "query_active_work",
@@ -222,6 +224,8 @@
222
224
  "media_queue",
223
225
  "media_blocklist_stalled",
224
226
  "media_episodes",
227
+ "media_monitor",
228
+ "media_watch_history",
225
229
  "media_indexer_search",
226
230
  "media_release_search",
227
231
  "media_release_grab",
@@ -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.1127</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1129</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -60,7 +60,7 @@ function exactSanctuaryContainmentProfileBoundaries(value) {
60
60
  if (!value || typeof value !== "object" || Array.isArray(value))
61
61
  return false;
62
62
  const boundaries = value;
63
- const versions = { "sanctuary-owner": 22, "sanctuary-household": 6, "sanctuary-event": 4 };
63
+ const versions = { "sanctuary-owner": 23, "sanctuary-household": 6, "sanctuary-event": 4 };
64
64
  if (!(0, node_util_1.isDeepStrictEqual)(Object.keys(boundaries).sort(), Object.keys(versions).sort()))
65
65
  return false;
66
66
  const packageRoot = path.resolve(__dirname, "../../../deploy/unraid/sanctuary.ouro");
@@ -16,7 +16,7 @@ const runtime_1 = require("../nerves/runtime");
16
16
  /** MCP tools whose applied writes are owner-only. */
17
17
  exports.OWNER_ONLY_WRITE_TOOLS = new Set(["media_quality_profile", "media_release_profile"]);
18
18
  /** 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
- exports.REPLAY_REFUSED_WRITE_TOOLS = new Set(["media_request", "media_search_now", "media_blocklist", "media_blocklist_stalled", "media_fill_missing", "media_release_grab", "media_manual_import"]);
19
+ 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
20
  const isWrite = (args) => (args.dry_run === false || args.dry_run === "false") && args.action !== "read";
21
21
  function callerFriend(ctx) {
22
22
  const friend = ctx?.context?.friend;
@@ -528,7 +528,14 @@ async function resolveAwaitTool(name, verdict, observation, agentRoot, agentName
528
528
  (0, runtime_1.emitNervesEvent)({ level: "error", component: "repertoire", event: "repertoire.await_alert_error", message: "await alert delivery threw", meta: { agent: agentName, name, error: error instanceof Error ? error.message : String(error) } });
529
529
  }
530
530
  if (alert?.delivery?.status !== "delivered_now") {
531
- return JSON.stringify({ verdict: "yes", archived: null, alert: alert ? { attempted: alert.attempted, status: alert.delivery?.status ?? null, skipped: alert.skipped ?? null } : null, advancedExternalEvents: [] });
531
+ const why = alert?.delivery?.detail ?? alert?.skipped ?? "the send failed";
532
+ return JSON.stringify({
533
+ verdict: "yes",
534
+ archived: null,
535
+ alert: alert ? { attempted: alert.attempted, status: alert.delivery?.status ?? null, skipped: alert.skipped ?? null } : null,
536
+ advancedExternalEvents: [],
537
+ note: `Not sent yet (${why}). The await stays open and I retry the send on its next check. I can also tell ${existing.filed_for_friend_id} myself on ${existing.filed_from}, then cancel_await "${name}".`,
538
+ });
532
539
  }
533
540
  }
534
541
  const advancedEvents = existing.filed_from === "external-event" && existing.filed_from_key && existing.wake_at
@@ -78,7 +78,7 @@ const SANCTUARY_RELATIONSHIP_BASE_TOOLS = new Set([
78
78
  exports.SANCTUARY_MCP_PROVIDED_TOOLS = new Set([
79
79
  "media_search", "media_request", "media_request_status",
80
80
  "media_diagnose_and_fix", "media_chain_health", "media_play_or_resolve",
81
- "media_search_now", "media_queue", "media_blocklist_stalled", "media_episodes", "media_indexer_search", "media_release_search", "media_release_grab", "media_blocklist", "media_manual_import", "media_quality_profile", "media_release_profile", "media_fill_missing",
81
+ "media_search_now", "media_queue", "media_blocklist_stalled", "media_episodes", "media_monitor", "media_watch_history", "media_indexer_search", "media_release_search", "media_release_grab", "media_blocklist", "media_manual_import", "media_quality_profile", "media_release_profile", "media_fill_missing",
82
82
  ]);
83
83
  /** Channels a Sanctuary turn can arrive on from the host itself, not from a remote party. */
84
84
  const SANCTUARY_LOCAL_CHANNELS = new Set(["inner", "cli", "mcp"]);
@@ -142,9 +142,10 @@ function relationshipAwaitCoordinates(awaitFile) {
142
142
  throw new InvalidRelationshipAwaitProvenanceError("Relationship await provenance is invalid");
143
143
  return { friendId: awaitFile.filed_for_friend_id, channel: "a2a", key: awaitFile.filed_from_key, requestId: null };
144
144
  }
145
- const isSystemAwait = awaitFile.filed_for_friend_id === null
145
+ // The agent's own awaits: filed from its private runtime, the CLI, or with no session at all. No relationship to honour.
146
+ const isSystemAwait = awaitFile.filed_from === "inner" || (awaitFile.filed_for_friend_id === null
146
147
  && awaitFile.filed_from_key === null
147
- && (awaitFile.filed_from === null || awaitFile.filed_from === "unknown" || awaitFile.filed_from === "cli");
148
+ && (awaitFile.filed_from === null || awaitFile.filed_from === "unknown" || awaitFile.filed_from === "cli"));
148
149
  if (isSystemAwait)
149
150
  return null;
150
151
  throw new InvalidRelationshipAwaitProvenanceError("Relationship await provenance is incomplete or legacy");
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1127",
3
+ "version": "0.1.0-alpha.1129",
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.1127",
9
+ "version": "0.1.0-alpha.1129",
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.1127",
3
+ "version": "0.1.0-alpha.1129",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },