deep-roon-mcp 0.5.12 → 0.5.13

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/README.md CHANGED
@@ -40,7 +40,7 @@ Version 0.5: sixty-eight tools (sixty with a read-only library; seventy-two with
40
40
  | `roon_zones` | Roon's zones and groups |
41
41
  | `roon_now_playing` | What plays in each zone, with the volume |
42
42
  | `roon_waveform` | The waveform of what plays in a zone, as Roon draws it in its seek bar (local files, and streams once played) |
43
- | `roon_queue` | A zone's queue, numbered (1 is what plays) |
43
+ | `roon_queue` | A zone's queue, numbered (1 is what plays), each row with its `item` id |
44
44
  | `roon_cover` | The cover of what plays, as an image |
45
45
  | `roon_history` | Roon's play history, newest first |
46
46
  | `roon_top` | Most played albums, artists or tracks over your whole history |
@@ -76,7 +76,7 @@ Version 0.5: sixty-eight tools (sixty with a read-only library; seventy-two with
76
76
  | `roon_seek` | A position in the playing track |
77
77
  | `roon_volume` | A zone's volume, mute |
78
78
  | `roon_settings` | Shuffle, repeat, Roon Radio |
79
- | `roon_queue_jump`, `roon_queue_remove`, `roon_queue_move` | Jump to an item of the queue, take items out, move one before or after another |
79
+ | `roon_queue_jump`, `roon_queue_remove`, `roon_queue_move` | Jump to an item of the queue, take items out, move one before or after another — by the `item` from `roon_queue`, so a track that ended in between doesn't shift the target |
80
80
  | `roon_queue_clear` | Clear what comes after the playing track (or everything) |
81
81
  | `roon_transfer` | Move what plays, with its queue, to another zone |
82
82
  | `roon_group`, `roon_ungroup` | Group zones, and undo it |
@@ -15489,7 +15489,7 @@ var require_lib2 = __commonJS({
15489
15489
  var version2;
15490
15490
  var init_package = __esm({
15491
15491
  "package.json"() {
15492
- version2 = "0.5.12";
15492
+ version2 = "0.5.13";
15493
15493
  }
15494
15494
  });
15495
15495
 
@@ -50055,18 +50055,28 @@ function queueRow(c, oid) {
50055
50055
  return r;
50056
50056
  }
50057
50057
  __name(queueRow, "queueRow");
50058
- async function queueItemAt(c, zoneName, n) {
50058
+ function pick2(refs, at2, n, item, zone3) {
50059
+ if (item !== void 0) {
50060
+ const i = refs.findIndex((o) => String(o) === item);
50061
+ if (i < at2) throw new RoonError(`That item is no longer in the queue of ${zone3} (it played or was removed) \u2014 read roon_queue again`, "invalid");
50062
+ return refs[i];
50063
+ }
50064
+ const oid = refs[at2 + n - 1];
50065
+ if (oid === void 0) throw new RoonError(`The queue of ${zone3} has no item ${n} (${Math.max(0, refs.length - at2)} from here)`, "invalid");
50066
+ return oid;
50067
+ }
50068
+ __name(pick2, "pick");
50069
+ async function queueItemAt(c, zoneName, n, item) {
50059
50070
  const { z: z2, q } = queueOf(c, zoneName);
50060
50071
  const refs = await queueItems(c, q);
50061
50072
  const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
50062
- const oid = refs[at2 + n - 1];
50063
- if (oid === void 0) throw new RoonError(`The queue of ${z2.name} has no item ${n} (${Math.max(0, refs.length - at2)} from here)`, "invalid");
50073
+ const oid = pick2(refs, at2, n, item, z2.name);
50064
50074
  return { z: z2, q, oid, refs, at: at2 };
50065
50075
  }
50066
50076
  __name(queueItemAt, "queueItemAt");
50067
- async function queueJump(zoneName, n) {
50077
+ async function queueJump(zoneName, n, item) {
50068
50078
  const r = await withCore(async (c) => {
50069
- const { z: z2, q, oid } = await queueItemAt(c, zoneName, n);
50079
+ const { z: z2, q, oid } = await queueItemAt(c, zoneName, n, item);
50070
50080
  c.remoting.callMethodNoReply(q.oid, formatMethodSignature("Queue", "PlayFromHere", [{ type: "TransportItem", name: "item" }]), buildArgs([Arg.ref(oid)]));
50071
50081
  log(`queue_jump: ${z2.name} \u2192 item ${n}`);
50072
50082
  return { zone: z2.name, n };
@@ -50074,12 +50084,12 @@ async function queueJump(zoneName, n) {
50074
50084
  return { ok: true, ...r, ...await started2(r.zone, PRIORITY["now"]) };
50075
50085
  }
50076
50086
  __name(queueJump, "queueJump");
50077
- async function queueRemove(zoneName, ns) {
50087
+ async function queueRemove(zoneName, ns, items2) {
50078
50088
  return withCore(async (c) => {
50079
50089
  const { z: z2, q } = queueOf(c, zoneName);
50080
50090
  const refs = await queueItems(c, q);
50081
50091
  const at2 = Math.max(0, field2(c.graph.getObject(q.oid), "CurrentItemIndex") ?? 0);
50082
- const oids = [...new Set(ns)].map((n) => refs[at2 + n - 1]).filter((o) => o !== void 0);
50092
+ const oids = items2?.length ? [...new Set(items2.map((it) => pick2(refs, at2, 0, it, z2.name)))].filter((o) => o !== refs[at2]) : [...new Set(ns)].map((n) => refs[at2 + n - 1]).filter((o) => o !== void 0);
50083
50093
  if (!oids.length) throw new RoonError("No such items in the queue", "invalid");
50084
50094
  c.remoting.callMethodNoReply(q.oid, formatMethodSignature("Queue", "RemoveItems", [{ type: "IEnumerable<TransportItem>", name: "items" }]), buildArgs([Arg.collection(oids.map((o) => buildArgs([Arg.ref(o)])))]));
50085
50095
  log(`queue_remove: ${z2.name} \u2212 ${oids.length} item(s)`);
@@ -50090,11 +50100,11 @@ async function queueRemove(zoneName, ns) {
50090
50100
  }
50091
50101
  __name(queueRemove, "queueRemove");
50092
50102
  var INSERTION = { before: 3, after: 2 };
50093
- async function queueMove(zoneName, n, to, where) {
50103
+ async function queueMove(zoneName, n, to, where, item, toItem) {
50094
50104
  return withCore(async (c) => {
50095
- const { z: z2, q, oid, refs, at: at2 } = await queueItemAt(c, zoneName, n);
50096
- const rel = refs[at2 + to - 1];
50097
- if (rel === void 0 || to === n) throw new RoonError(`The queue of ${z2.name} has no item ${to} to move next to`, "invalid");
50105
+ const { z: z2, q, oid, refs, at: at2 } = await queueItemAt(c, zoneName, n, item);
50106
+ const rel = toItem !== void 0 ? pick2(refs, at2, to, toItem, z2.name) : refs[at2 + to - 1];
50107
+ if (rel === void 0 || rel === oid) throw new RoonError(`The queue of ${z2.name} has no item ${to} to move next to`, "invalid");
50098
50108
  const point = INSERTION[where];
50099
50109
  const res = await c.call(
50100
50110
  "Queue",
@@ -50108,7 +50118,7 @@ async function queueMove(zoneName, n, to, where) {
50108
50118
  await wait(300);
50109
50119
  const after = await queueItems(c, q);
50110
50120
  const now = after.indexOf(oid) - at2 + 1;
50111
- return { ok: true, zone: z2.name, moved: n, now_at: now > 0 ? now : void 0 };
50121
+ return { ok: true, zone: z2.name, moved: refs.indexOf(oid) - at2 + 1, now_at: now > 0 ? now : void 0 };
50112
50122
  });
50113
50123
  }
50114
50124
  __name(queueMove, "queueMove");
@@ -50120,7 +50130,7 @@ async function queue2(zoneName, limit3) {
50120
50130
  const view = refs.slice(at2, at2 + Math.min(Math.max(1, limit3), 200));
50121
50131
  const end = Date.now() + 2500;
50122
50132
  while (Date.now() < end && view.some((oid) => queueRow(c, oid).title === null)) await wait(50);
50123
- return { zone: z2.name, left: Math.max(0, refs.length - at2), rows: view.map((oid, i) => ({ n: i + 1, now: i === 0 || void 0, ...queueRow(c, oid) })) };
50133
+ return { zone: z2.name, left: Math.max(0, refs.length - at2), rows: view.map((oid, i) => ({ n: i + 1, now: i === 0 || void 0, item: String(oid), ...queueRow(c, oid) })) };
50124
50134
  });
50125
50135
  }
50126
50136
  __name(queue2, "queue");
@@ -50238,15 +50248,15 @@ __name(standby, "standby");
50238
50248
  async function cover(zoneName) {
50239
50249
  const t = await findTarget();
50240
50250
  const info = await withCore(async (c) => {
50241
- const pick2 = zoneName ? findZone(c, zoneName) : null;
50251
+ const pick3 = zoneName ? findZone(c, zoneName) : null;
50242
50252
  const zones4 = c.graph.findByType("Zone");
50243
- const z2 = pick2 ? c.graph.getObject(pick2.oid) : zones4.find((x) => (field2(x, "State") ?? 0) === 0 && items(c, field2(obj(c, field2(x, "NowPlaying")), "Tracks")).length) ?? zones4.find((x) => field2(x, "State") === 2 && items(c, field2(obj(c, field2(x, "NowPlaying")), "Tracks")).length);
50253
+ const z2 = pick3 ? c.graph.getObject(pick3.oid) : zones4.find((x) => (field2(x, "State") ?? 0) === 0 && items(c, field2(obj(c, field2(x, "NowPlaying")), "Tracks")).length) ?? zones4.find((x) => field2(x, "State") === 2 && items(c, field2(obj(c, field2(x, "NowPlaying")), "Tracks")).length);
50244
50254
  if (!z2) throw new RoonError(zoneName ? `Nothing plays on ${zoneName}` : "Nothing plays in Roon right now", "not_found");
50245
50255
  const tr = obj(c, field2(items(c, field2(obj(c, field2(z2, "NowPlaying")), "Tracks"))[0], "Track"));
50246
50256
  const al = obj(c, field2(tr, "Album"));
50247
50257
  const url2 = String(field2(obj(c, field2(al, "Image")), "Url") ?? field2(obj(c, field2(tr, "Image")), "Url") ?? "");
50248
50258
  const key = /^broker:\/\/\/image\/([^.]+)\./.exec(url2)?.[1];
50249
- return { key, title: field2(tr, "Title"), album: field2(al, "Title"), artist: clean(field2(al, "PerformedBy")), zone: pick2?.name ?? zoneNames(c).get(String(z2.oid)) };
50259
+ return { key, title: field2(tr, "Title"), album: field2(al, "Title"), artist: clean(field2(al, "PerformedBy")), zone: pick3?.name ?? zoneNames(c).get(String(z2.oid)) };
50250
50260
  });
50251
50261
  const off = info.zone ? officialZone(info.zone) : void 0;
50252
50262
  const urls = [
@@ -50841,22 +50851,33 @@ function registerControlTools(server, internal = true) {
50841
50851
  }, ({ zone: zn, limit: limit3 }) => run(() => queue2(zn, limit3 ?? 50)));
50842
50852
  reg("roon_queue_jump", {
50843
50853
  title: "Jump in the queue",
50844
- description: "Play an item of the zone's queue now (`n` as roon_queue numbers them: 1 is what plays, 2 the next \u2026); what came before it is done. Only on an explicit request.",
50845
- inputSchema: { zone, n: external_exports.number().int().min(1) },
50854
+ description: "Play an item of the zone's queue now (`n` as roon_queue numbers them: 1 is what plays, 2 the next \u2026); what came before it is done. Pass the row's `item` from roon_queue too: positions shift when a track ends, the item doesn't. Only on an explicit request.",
50855
+ inputSchema: { zone, n: external_exports.number().int().min(1), item: external_exports.string().optional().describe("The row's `item` from roon_queue \u2014 finds that item even if the positions moved on, and refuses if it is gone.") },
50846
50856
  annotations: PLAYS
50847
- }, ({ zone: zn, n }) => run(() => queueJump(zn, n)));
50857
+ }, ({ zone: zn, n, item }) => run(() => queueJump(zn, n, item)));
50848
50858
  reg("roon_queue_remove", {
50849
50859
  title: "Remove from the queue",
50850
- description: "Take items out of the zone's queue, by their numbers from roon_queue (`ns`, e.g. [3, 4]). Only on an explicit request.",
50851
- inputSchema: { zone, ns: external_exports.array(external_exports.number().int().min(2)).min(1).max(100).describe("Positions from roon_queue (2 and up: 1 is what plays).") },
50860
+ description: "Take items out of the zone's queue, by their numbers from roon_queue (`ns`, e.g. [3, 4]) \u2014 and preferably their `items` too: positions shift when a track ends, the items don't. Only on an explicit request.",
50861
+ inputSchema: {
50862
+ zone,
50863
+ ns: external_exports.array(external_exports.number().int().min(2)).min(1).max(100).describe("Positions from roon_queue (2 and up: 1 is what plays)."),
50864
+ items: external_exports.array(external_exports.string()).max(100).optional().describe("The rows' `item` from roon_queue: exactly these are removed, and nothing if one is gone.")
50865
+ },
50852
50866
  annotations: CHANGES_QUEUE
50853
- }, ({ zone: zn, ns }) => run(() => queueRemove(zn, ns)));
50867
+ }, ({ zone: zn, ns, items: items2 }) => run(() => queueRemove(zn, ns, items2)));
50854
50868
  reg("roon_queue_move", {
50855
50869
  title: "Move in the queue",
50856
- description: "Move an item of the zone's queue next to another: `n` goes `before` or `after` item `to` (numbers from roon_queue; 1 is what plays). Only on an explicit request.",
50857
- inputSchema: { zone, n: external_exports.number().int().min(2), to: external_exports.number().int().min(2), where: external_exports.enum(["before", "after"]).optional().describe("before (default) or after item `to`.") },
50870
+ description: "Move an item of the zone's queue next to another: `n` goes `before` or `after` item `to` (numbers from roon_queue; 1 is what plays). Pass `item` and `to_item` from roon_queue too: positions shift when a track ends, items don't. Only on an explicit request.",
50871
+ inputSchema: {
50872
+ zone,
50873
+ n: external_exports.number().int().min(2),
50874
+ to: external_exports.number().int().min(2),
50875
+ where: external_exports.enum(["before", "after"]).optional().describe("before (default) or after item `to`."),
50876
+ item: external_exports.string().optional().describe("The `item` of row n from roon_queue."),
50877
+ to_item: external_exports.string().optional().describe("The `item` of row `to` from roon_queue.")
50878
+ },
50858
50879
  annotations: CHANGES_QUEUE
50859
- }, ({ zone: zn, n, to, where }) => run(() => queueMove(zn, n, to, where ?? "before")));
50880
+ }, ({ zone: zn, n, to, where, item, to_item }) => run(() => queueMove(zn, n, to, where ?? "before", item, to_item)));
50860
50881
  reg("roon_queue_clear", {
50861
50882
  title: "Clear the queue",
50862
50883
  description: "Clear the queue of a Roon zone. By default the track that plays keeps playing and everything after it is removed; `everything: true` also removes the playing track (the zone falls silent). Only on an explicit request.",
@@ -51566,11 +51587,11 @@ var STATE3 = { 0: "playing", 1: "loading", 2: "paused", 3: "stopped" };
51566
51587
  async function signalPath(zoneName) {
51567
51588
  return withCore(async (c) => {
51568
51589
  const names2 = zoneNames(c);
51569
- let pick2 = zoneName ? String(findZone(c, zoneName).oid) : null;
51570
- if (pick2) {
51590
+ let pick3 = zoneName ? String(findZone(c, zoneName).oid) : null;
51591
+ if (pick3) {
51571
51592
  const hasPath = /* @__PURE__ */ __name((oid) => items(c, field2(obj(c, field2(c.graph.getObject(BigInt(oid)), "SignalPath")), "Elements")).length > 0, "hasPath");
51572
- if (!hasPath(pick2)) {
51573
- const target2 = names2.get(pick2);
51593
+ if (!hasPath(pick3)) {
51594
+ const target2 = names2.get(pick3);
51574
51595
  const same = /* @__PURE__ */ new Set();
51575
51596
  for (const e of c.graph.findByType("Endpoint")) {
51576
51597
  const z2 = field2(e, "Zone");
@@ -51579,11 +51600,11 @@ async function signalPath(zoneName) {
51579
51600
  const better = [...same].find(hasPath);
51580
51601
  if (better) {
51581
51602
  names2.set(better, target2);
51582
- pick2 = better;
51603
+ pick3 = better;
51583
51604
  }
51584
51605
  }
51585
51606
  }
51586
- return { zones: c.graph.findByType("Zone").filter((z2) => names2.has(String(z2.oid)) && (!pick2 || String(z2.oid) === pick2)).map((z2) => {
51607
+ return { zones: c.graph.findByType("Zone").filter((z2) => names2.has(String(z2.oid)) && (!pick3 || String(z2.oid) === pick3)).map((z2) => {
51587
51608
  const name = names2.get(String(z2.oid));
51588
51609
  const sp = obj(c, field2(z2, "SignalPath"));
51589
51610
  const r = { zone: name, state: officialZone(name)?.state ?? STATE3[field2(z2, "State") ?? 0], quality: QUALITY[field2(sp, "Quality") ?? 0] ?? String(field2(sp, "Quality")) };
@@ -51652,12 +51673,12 @@ function dspParts(c, d) {
51652
51673
  __name(dspParts, "dspParts");
51653
51674
  async function dsp(zoneName) {
51654
51675
  return withCore(async (c) => {
51655
- const pick2 = zoneName ? findZone(c, zoneName).oid : null;
51676
+ const pick3 = zoneName ? findZone(c, zoneName).oid : null;
51656
51677
  const names2 = zoneNames(c);
51657
51678
  const zones4 = [];
51658
51679
  for (const e of currentEndpoints(c)) {
51659
51680
  const z2 = field2(e, "Zone");
51660
- if (!isRef2(z2) || typeof field2(e, "Name") !== "string" || pick2 !== null && String(z2.$ref) !== String(pick2)) continue;
51681
+ if (!isRef2(z2) || typeof field2(e, "Name") !== "string" || pick3 !== null && String(z2.$ref) !== String(pick3)) continue;
51661
51682
  const d = await dspOf(c, e);
51662
51683
  const r = { zone: names2.get(String(z2.$ref)) ?? field2(e, "Name") };
51663
51684
  if (field2(e, "Name") !== r.zone) r.output = field2(e, "Name");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deep-roon-mcp",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "An MCP server for Roon that reaches the parts the official API doesn't: reviews, biographies, Qobuz's and TIDAL's shelves, TIDAL's playlists, your history, search across your library and the streaming services",
5
5
  "license": "Apache-2.0",
6
6
  "author": "René Bouwmeester <21277119+renebouwmeester@users.noreply.github.com>",