@ouro.bot/cli 0.1.0-alpha.862 → 0.1.0-alpha.863
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 +7 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.ouro/mcp/media-mcp.mjs +61 -0
- package/deploy/unraid/sanctuary.ouro/psyche/TACIT.md +1 -0
- package/deploy/unraid/sanctuary.ouro/tool-profiles.json +4 -2
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/sanctuary-acceptance-harness.js +1 -1
- package/dist/repertoire/tools-awaiting.js +17 -5
- package/dist/repertoire/tools-unraid.js +1 -1
- package/dist/repertoire/tools.js +1 -1
- package/dist/senses/private-runtime.js +10 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
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.863",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Fixed await ticks always failing resolve_await and cancel_await: the inbound pipeline rewrote the turn's current session to the private-runtime session, so the relationship guard never matched the await being ticked. The tick now carries its own binding, covering only the await being ticked.",
|
|
8
|
+
"Added media_queue, a read-only Sonarr/Radarr queue view (torrent and usenet: status, trackedDownloadState, percent, timeleft, stalled) for the Butler, and made sanctuary_get_download_queue say it only sees the usenet queue, and the await tick now receives the MCP tools its profile allows (it was given none)."
|
|
9
|
+
]
|
|
10
|
+
},
|
|
4
11
|
{
|
|
5
12
|
"version": "0.1.0-alpha.862",
|
|
6
13
|
"changes": [
|
|
@@ -863,6 +863,56 @@ function queueReport(rows) {
|
|
|
863
863
|
size_left_bytes: r.sizeleft ?? 0, stalled: isStalledRow(r, now) }))
|
|
864
864
|
}
|
|
865
865
|
|
|
866
|
+
// ------------------------------------------------------------ tool: media_queue
|
|
867
|
+
|
|
868
|
+
const QUEUE_VIEW_MAX_ROWS = 100
|
|
869
|
+
|
|
870
|
+
// One queue row as the owner's torrent or usenet client reports it through Sonarr/Radarr.
|
|
871
|
+
export function queueRowView(r, nowMs) {
|
|
872
|
+
return {
|
|
873
|
+
queue_id: r.id ?? null, title: r.title ?? null, status: r.status ?? null,
|
|
874
|
+
tracked_download_state: r.trackedDownloadState ?? null, tracked_download_status: r.trackedDownloadStatus ?? null,
|
|
875
|
+
percent: pct(r), timeleft: r.timeleft ?? null, size_left_bytes: r.sizeleft ?? 0, size_bytes: r.size ?? 0,
|
|
876
|
+
protocol: r.protocol ?? null, download_client: r.downloadClient ?? null, indexer: r.indexer ?? null,
|
|
877
|
+
added: r.added ?? null, stalled: isStalledRow(r, nowMs),
|
|
878
|
+
...(r.errorMessage ? { error_message: String(r.errorMessage).slice(0, 300) } : {}),
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// Read-only: the Sonarr/Radarr download queue (torrent and usenet alike). Grabs, removes and blocklists nothing.
|
|
883
|
+
export async function mediaQueue(a) {
|
|
884
|
+
if (a.kind !== "series" && a.kind !== "movie") return { result: "invalid_kind", message: "kind must be 'series' or 'movie'." }
|
|
885
|
+
let rows
|
|
886
|
+
let item = null
|
|
887
|
+
let total = null
|
|
888
|
+
if ((a.service_id !== undefined && a.service_id !== null) || a.tmdb_id || a.title) {
|
|
889
|
+
const found = await resolveLibraryItem(a)
|
|
890
|
+
if (!found.item) return { result: found.result, kind: a.kind, candidates: found.candidates }
|
|
891
|
+
item = found.item
|
|
892
|
+
rows = await itemQueue(a.kind, item.id)
|
|
893
|
+
} else {
|
|
894
|
+
rows = []
|
|
895
|
+
const client = arrFor(a.kind)
|
|
896
|
+
for (let page = 1; page <= QUEUE_MAX_PAGES; page++) {
|
|
897
|
+
const q = await client("/queue", { query: { page, pageSize: QUEUE_PAGE_SIZE, ...(a.kind === "series" ? { includeSeries: true } : {}) } })
|
|
898
|
+
const records = q?.records ?? []
|
|
899
|
+
rows.push(...records)
|
|
900
|
+
if (Number.isFinite(Number(q?.totalRecords))) total = Number(q.totalRecords)
|
|
901
|
+
if (!records.length || !(Number(q?.totalRecords) > page * QUEUE_PAGE_SIZE) || rows.length >= QUEUE_VIEW_MAX_ROWS) break
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
total = Math.max(total ?? 0, rows.length)
|
|
905
|
+
const now = Date.now()
|
|
906
|
+
const shown = rows.slice(0, QUEUE_VIEW_MAX_ROWS).map((r) => queueRowView(r, now))
|
|
907
|
+
return {
|
|
908
|
+
kind: a.kind, ...(item ? { service_id: item.id, title: item.title } : {}),
|
|
909
|
+
count: total, shown: shown.length, ...(total > shown.length ? { truncated: true } : {}), queue: shown,
|
|
910
|
+
summary: !total ? "Nothing for this is in the Sonarr/Radarr queue."
|
|
911
|
+
: `${total} queue row${total === 1 ? "" : "s"}${total > shown.length ? ` (showing ${shown.length})` : ""}; ${shown.filter((r) => r.stalled).length} stalled.`,
|
|
912
|
+
note: "Sonarr/Radarr do not report seeders or peers. A row stuck at the same percent with no timeleft is the stall signal; for a release's seeder count use media_indexer_search.",
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
866
916
|
async function runSearch(kind, serviceId) {
|
|
867
917
|
const body = kind === "series" ? { name: "SeriesSearch", seriesId: serviceId } : { name: "MoviesSearch", movieIds: [serviceId] }
|
|
868
918
|
const c = await arrFor(kind)("/command", { method: "POST", body })
|
|
@@ -1730,6 +1780,16 @@ const TOOL_LIST = [
|
|
|
1730
1780
|
request_id: { type: "string" }, tmdb_id: { type: "number" }, title: { type: "string" },
|
|
1731
1781
|
} },
|
|
1732
1782
|
},
|
|
1783
|
+
{
|
|
1784
|
+
name: "media_queue",
|
|
1785
|
+
description: "Read-only view of the Sonarr/Radarr download queue, torrent and usenet alike: for each row the title, status, trackedDownloadState, percent, timeleft, size left, download client and whether it is stalled. Use this to see whether a series or movie download is progressing (this is the tool for torrent downloads; sanctuary_get_download_queue only sees the usenet/SABnzbd queue). Give service_id, tmdb_id or title for one item, or omit them for the whole queue of that kind. It grabs, removes and blocklists nothing. Seeders and peers are not reported by Sonarr/Radarr; use media_indexer_search for a release's seeders.",
|
|
1786
|
+
inputSchema: { type: "object", properties: {
|
|
1787
|
+
kind: { type: "string", enum: ["series", "movie"] },
|
|
1788
|
+
service_id: { type: "number", description: "Sonarr series id or Radarr movie id." },
|
|
1789
|
+
tmdb_id: { type: "number" },
|
|
1790
|
+
title: { type: "string", description: "Exact or near-exact library title." },
|
|
1791
|
+
}, required: ["kind"] },
|
|
1792
|
+
},
|
|
1733
1793
|
{
|
|
1734
1794
|
name: "media_search_now",
|
|
1735
1795
|
description: "Trigger a Sonarr/Radarr search for a series or movie that is already in the library, and report its queue. Use this when the owner asks to search, re-search, or look again for something already in Sonarr/Radarr; no Jellyseerr request id is needed. Identify it by service_id, tmdb_id, or exact title. Never adds anything new: zero or several matches come back as 'not_found' or 'ambiguous' with candidates. Never tell the owner to click Search in the web UI.",
|
|
@@ -1856,6 +1916,7 @@ const HANDLERS = {
|
|
|
1856
1916
|
media_chain_health: mediaChainHealth,
|
|
1857
1917
|
media_play_or_resolve: mediaPlayOrResolve,
|
|
1858
1918
|
media_search_now: mediaSearchNow,
|
|
1919
|
+
media_queue: mediaQueue,
|
|
1859
1920
|
media_blocklist_stalled: mediaBlocklistStalled,
|
|
1860
1921
|
media_episodes: mediaEpisodes,
|
|
1861
1922
|
media_fill_missing: mediaFillMissing,
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- When a tool for the job is missing, say so in one line and route the work: ask Claude Code over A2A or record it as a follow-up. Never ask Ari to click through a web UI for work the house is meant to do.
|
|
17
17
|
- Answer from primary sources, never from memory. For any factual claim about the world or the house (whether a title or series exists, what is on the shelf, a container's state, a version, a download's progress, a book's metadata, what Ari said before), look it up with the tools first (Sonarr/Radarr/Jellyfin and their TVDB/TMDB lookup, the Unraid tools, calibre-web, libgen, HEY, web_search, your own state files) and answer from what they return. Re-read live state instead of repeating a status from an earlier reply. When no tool can reach the source, say it is unverified rather than asserting it. Never say a title does not exist without a catalog lookup, and when the library holds a strong partial match, offer it first.
|
|
18
18
|
- When episodes are missing, or Ari asks to get them, call `media_fill_missing` first. It re-reads Sonarr, matches releases by episode title and air year, grabs, imports by title and replaces stalled downloads in one call, and it is safe to call again. Relay its `summary` with the evidence it returns and follow its `next_step`; do not redo its steps by hand. When it keeps a stalled download, that download is the only copy and may still finish: never offer to clear, cancel or blocklist it. A yes or "get them" after that answer means call `media_fill_missing` again, never `media_blocklist_stalled`. When it reports `blocklisted_matches`, the only matching release is on the blocklist: tell Ari and offer to retry it; if he says yes, call `media_fill_missing` again with `retry_blocklisted` set to his words. When it grabs something that may never finish, say so plainly and file the follow-up with `await_condition` before ending the turn. When it reports `goal_met`, or an episode Ari asked for is imported, stop: say so and end the turn without further probing.
|
|
19
|
+
- To see whether a series or movie download is progressing, including a torrent, call `media_queue`. `sanctuary_get_download_queue` reads only the usenet queue: an idle answer from it says nothing about a Sonarr or torrent download. A repeated ticking check keeps the download alive with `resolve_await` verdict `no` until `media_fill_missing` reports `goal_met`.
|
|
19
20
|
- Before stating whether an episode is monitored, missing, downloading or on disk, read it from a tool in this turn (`media_fill_missing` or `media_episodes`). Never infer it from an earlier reply or from a tool that did not report it.
|
|
20
21
|
- Use only the parameters a tool lists. If a call is refused for an unknown parameter or a wrong value, read the allowed ones from the refusal and call again correctly; never invent flags such as `dry_run`.
|
|
21
22
|
- When an automatic search finds nothing for episodes that exist and `media_fill_missing` cannot place them, suspect numbering (streaming vs TVDB order, specials, absolute numbers). Read `media_episodes` (its `scene_code` is the numbering release names use), compare its titles with the `media_release_search` results (how Sonarr parsed each release) and with what `media_blocklist` holds, grab the right pack with `media_release_grab` and an explicit episode mapping, and after it downloads, map the files to episodes by title with `media_manual_import`. When Sonarr's search finds nothing, use `media_indexer_search` with the scene code, 'Season N', the year or an episode title to learn whether any release exists at all; if the only matching release has no seeders, still grab it with the right mapping (peers can reappear) and say plainly it may never finish instead of promising it will arrive. Report each step with what Sonarr returned.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 2,
|
|
3
3
|
"profiles": {
|
|
4
4
|
"sanctuary-owner": {
|
|
5
|
-
"version":
|
|
5
|
+
"version": 14,
|
|
6
6
|
"contextScopes": [
|
|
7
7
|
"household.status",
|
|
8
8
|
"household.policy",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"media_chain_health",
|
|
67
67
|
"media_play_or_resolve",
|
|
68
68
|
"media_search_now",
|
|
69
|
+
"media_queue",
|
|
69
70
|
"media_blocklist_stalled",
|
|
70
71
|
"media_episodes",
|
|
71
72
|
"media_indexer_search",
|
|
@@ -141,7 +142,7 @@
|
|
|
141
142
|
]
|
|
142
143
|
},
|
|
143
144
|
"sanctuary-agent-peer": {
|
|
144
|
-
"version":
|
|
145
|
+
"version": 5,
|
|
145
146
|
"toolNames": [
|
|
146
147
|
"external_event_disposition",
|
|
147
148
|
"query_active_work",
|
|
@@ -198,6 +199,7 @@
|
|
|
198
199
|
"media_chain_health",
|
|
199
200
|
"media_play_or_resolve",
|
|
200
201
|
"media_search_now",
|
|
202
|
+
"media_queue",
|
|
201
203
|
"media_blocklist_stalled",
|
|
202
204
|
"media_episodes",
|
|
203
205
|
"media_indexer_search",
|
|
@@ -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.863</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":
|
|
63
|
+
const versions = { "sanctuary-owner": 14, "sanctuary-household": 5, "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");
|
|
@@ -83,6 +83,20 @@ function validateName(name) {
|
|
|
83
83
|
return "name must be alphanumeric, underscores, or hyphens";
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* The relationship scope a resolve/cancel is judged against. A turn that is ticking an await carries that await's own
|
|
88
|
+
* binding (`awaitTick`), because the pipeline rewrites `currentSession` to the private-runtime session; that binding covers the
|
|
89
|
+
* ticked await only, so a tick can never touch any other await. Every other turn is judged by its current session.
|
|
90
|
+
*/
|
|
91
|
+
function relationshipScopeFor(ctx, awaitName) {
|
|
92
|
+
const tick = ctx.awaitTick;
|
|
93
|
+
if (tick) {
|
|
94
|
+
return tick.awaitName === awaitName
|
|
95
|
+
? { session: { friendId: tick.friendId, channel: tick.channel, key: tick.key }, requestId: tick.requestId ?? undefined }
|
|
96
|
+
: { session: undefined, requestId: undefined };
|
|
97
|
+
}
|
|
98
|
+
return { session: ctx.currentSession, requestId: ctx.relationshipAuthorization?.requestId };
|
|
99
|
+
}
|
|
86
100
|
function readAwaitDefinition(agentRoot, name) {
|
|
87
101
|
const filePath = awaitFilePath(agentRoot, name);
|
|
88
102
|
try {
|
|
@@ -537,10 +551,9 @@ exports.awaitingToolDefinitions = [
|
|
|
537
551
|
const agentRoot = (0, identity_1.getAgentRoot)();
|
|
538
552
|
const agentName = (0, identity_1.getAgentName)();
|
|
539
553
|
if (ctx?.relationshipAuthorization) {
|
|
540
|
-
const session = ctx.currentSession;
|
|
541
|
-
const requestId = ctx.relationshipAuthorization.requestId;
|
|
542
|
-
const existing = readAwaitDefinition(agentRoot, String(a.name ?? ""));
|
|
543
554
|
const awaitName = String(a.name ?? "");
|
|
555
|
+
const { session, requestId } = relationshipScopeFor(ctx, awaitName);
|
|
556
|
+
const existing = readAwaitDefinition(agentRoot, awaitName);
|
|
544
557
|
let binding = null;
|
|
545
558
|
if (session?.channel === "external-event" && existing?.wake_at) {
|
|
546
559
|
binding = inspectExternalEventAwait(agentName, { recordPath: session.key, awaitName, wakeAt: existing.wake_at });
|
|
@@ -590,8 +603,7 @@ exports.awaitingToolDefinitions = [
|
|
|
590
603
|
const agentRoot = (0, identity_1.getAgentRoot)();
|
|
591
604
|
const agentName = (0, identity_1.getAgentName)();
|
|
592
605
|
if (ctx?.relationshipAuthorization) {
|
|
593
|
-
const session = ctx.
|
|
594
|
-
const requestId = ctx.relationshipAuthorization.requestId;
|
|
606
|
+
const { session, requestId } = relationshipScopeFor(ctx, String(a.name ?? ""));
|
|
595
607
|
if (!session || !requestId || !hasActiveRelationshipFollowUp(agentRoot, {
|
|
596
608
|
friendId: session.friendId,
|
|
597
609
|
channel: session.channel,
|
|
@@ -444,7 +444,7 @@ exports.unraidToolDefinitions = [
|
|
|
444
444
|
readDefinition("unraid_get_system", "Read bounded Sanctuary system and version health.", "getSystem"),
|
|
445
445
|
readDefinition("sanctuary_get_install_state", "Check whether this Butler installation matches its verified release and report any repair needed.", "getInstallState"),
|
|
446
446
|
readDefinition("unraid_check_services", "Freshly check the fixed public Sanctuary service endpoints and return bounded status with an observation timestamp.", "checkServices"),
|
|
447
|
-
readDefinition("sanctuary_get_download_queue", "Read the bounded live
|
|
447
|
+
readDefinition("sanctuary_get_download_queue", "Read the bounded live usenet (SABnzbd) download queue state only, including whether the spend guard has paused it. It cannot see torrents or Sonarr/Radarr progress: an idle result here does not mean a download is absent. For a series or movie download, including torrents, use media_queue.", "getDownloadQueue"),
|
|
448
448
|
{
|
|
449
449
|
tool: { type: "function", function: { name: "sanctuary_resume_download_queue", description: "Resume the household download queue after Ari confirms the provider is ready, then independently verify paused=false. This can spend prepaid download credit.", parameters: emptyParameters } },
|
|
450
450
|
handler: async (_args, ctx) => JSON.stringify(ctx?.sanctuary ? await ctx.sanctuary.resumeDownloadQueue() : JSON.parse(missingRuntime())),
|
package/dist/repertoire/tools.js
CHANGED
|
@@ -73,7 +73,7 @@ const SANCTUARY_RELATIONSHIP_BASE_TOOLS = new Set([
|
|
|
73
73
|
exports.SANCTUARY_MCP_PROVIDED_TOOLS = new Set([
|
|
74
74
|
"media_search", "media_request", "media_request_status",
|
|
75
75
|
"media_diagnose_and_fix", "media_chain_health", "media_play_or_resolve",
|
|
76
|
-
"media_search_now", "media_blocklist_stalled", "media_episodes", "media_indexer_search", "media_release_search", "media_release_grab", "media_blocklist", "media_manual_import", "media_fill_missing",
|
|
76
|
+
"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_fill_missing",
|
|
77
77
|
]);
|
|
78
78
|
/** Channels a Sanctuary turn can arrive on from the host itself, not from a remote party. */
|
|
79
79
|
const SANCTUARY_LOCAL_CHANNELS = new Set(["inner", "cli", "mcp"]);
|
|
@@ -1383,8 +1383,9 @@ async function runPrivateRuntimeTurn(options) {
|
|
|
1383
1383
|
})
|
|
1384
1384
|
.filter((tool) => !externalEventExcludedTools.has(tool.function.name))
|
|
1385
1385
|
: undefined;
|
|
1386
|
+
// The await tick is relationship-scoped but still needs the MCP tools its profile allows (media_queue for a download await).
|
|
1386
1387
|
const relationshipAwaitToolsResolved = relationshipAwait
|
|
1387
|
-
? (0, tools_1.getToolsForChannel)(innerCapabilities, undefined, undefined, undefined,
|
|
1388
|
+
? (0, tools_1.getToolsForChannel)(innerCapabilities, undefined, undefined, undefined, mcpManager, undefined, {
|
|
1388
1389
|
agentName, relationshipAuthorization: relationshipAwait.relationshipAuthorization,
|
|
1389
1390
|
})
|
|
1390
1391
|
: undefined;
|
|
@@ -1509,6 +1510,14 @@ async function runPrivateRuntimeTurn(options) {
|
|
|
1509
1510
|
friendStore: relationshipAwait.store,
|
|
1510
1511
|
context: relationshipAwait.context,
|
|
1511
1512
|
currentSession: relationshipAwait.currentSession,
|
|
1513
|
+
// The pipeline rewrites currentSession to the private-runtime session; resolve_await/cancel_await need the await's own binding.
|
|
1514
|
+
awaitTick: Object.freeze({
|
|
1515
|
+
awaitName: parsedAwait.name,
|
|
1516
|
+
friendId: relationshipAwait.currentSession.friendId,
|
|
1517
|
+
channel: relationshipAwait.currentSession.channel,
|
|
1518
|
+
key: relationshipAwait.currentSession.key,
|
|
1519
|
+
requestId: relationshipAwaitCoordinatesValue.requestId,
|
|
1520
|
+
}),
|
|
1512
1521
|
relationshipAuthorization: relationshipAwait.relationshipAuthorization,
|
|
1513
1522
|
} : {}),
|
|
1514
1523
|
...(options?.externalEvent ? {
|
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.863",
|
|
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.863",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@azure/identity": "^4.13.0",
|