feat(server): capability framework, AudioMuse sonic routing & PsyLab Connections (#1033)

* feat(server): probe AudioMuse via OpenSubsonic and add PsyLab Connections tab

Navidrome ≥0.62: detect sonicSimilarity extension for reliable plugin signal;
older servers keep the legacy getSimilarSongs probe. PsyLab gets a Connections
tab with session, endpoint, and active-server capability details.

* feat(psylab): polish Connections tab, admin role probe, and tab bar layout

Status badges and Navidrome admin/user validation in Connections; prevent
PsyLab tab row from vertically collapsing under the Logs flex layout.

* docs: add CHANGELOG and credits for PR #1032

* feat(settings): auto-enable AudioMuse on Navidrome 0.62+ with status indicator

Replace the per-server manual toggle with a probe-driven badge when
sonicSimilarity is available; pre-0.62 Navidrome keeps the legacy toggle.

* feat(server): capability framework with AudioMuse sonic routing

Add a declarative server-capability catalog (src/serverCapabilities/) that
picks a feature strategy per server generation, runs only the needed probes,
and routes API calls. AudioMuse Instant Mix now prefers the OpenSubsonic
sonicSimilarity endpoint (getSonicSimilarTracks) on Navidrome 0.62+ and
falls back to legacy getSimilarSongs.

- catalog/context/resolve: eligibility, detection, activation, call routing
- storeView: read facade over the existing per-server probe maps
- getSonicSimilarTracks API client + fetchSimilarTracksRouted router
- route Instant Mix and Lucky Mix through the resolver
- ServersTab + PsyLab Connections read the resolver (auto status vs toggle)
- tests: resolve, storeView, router

* docs: update CHANGELOG and credits for PR #1033

Renamed branch supersedes PR #1032: point changelog/credits at #1033 and
document the server-capability framework, auto-managed AudioMuse indicator,
and sonic Instant Mix routing.

* refactor(server): address PR #1033 review — idempotent probe, drop dead code

- Make scheduleInstantMixProbeForServer idempotent: skip when a definitive
  result is cached; re-probe only on force (add/edit/test server), a prior
  error, or a server version/type change (invalidated in setSubsonicServerIdentity).
  Removes the steady-state 120 s re-probe, the present→probing→present flicker,
  and the momentary legacy-fallback routing window.
- Remove now-dead identity helpers (showAudiomuseNavidromeServerSetting,
  isAudiomusePluginAutoManaged, isNavidromeSonicSimilarityEligible,
  resolveAudiomusePluginProbeUiStatus + type) and the superseded
  probeAudiomusePluginWithCredentials; the catalog is the single source of truth.
- Drop the never-emitted 'unsupported' AudiomusePluginProbeResult variant.
- Fill audiomuseStatus* keys in all 8 non-en locales.
- Tests: probe idempotency + version-change invalidation; retarget
  OpenSubsonic test to fetchOpenSubsonicExtensionsWithCredentials.
This commit is contained in:
cucadmuh
2026-06-09 00:16:29 +03:00
committed by GitHub
parent 0878cbf308
commit 6118b3940f
43 changed files with 1867 additions and 74 deletions
+71
View File
@@ -0,0 +1,71 @@
import type { CapabilityDefinition } from './types';
/**
* Declarative map of server-side features, the strategies that can provide them
* per server generation, how to detect each, and which endpoint to route to.
*
* To add a feature with a new server path:
* 1. (optional) register a probe in `probes.ts` and map it in the orchestrator
* (`api/subsonic.ts`) + read facade (`storeView.ts`).
* 2. add a `CapabilityDefinition` here with one strategy per server generation.
* 3. consumers read it via `storeView` (UI) and the call router (runtime).
* No version `if` checks belong in UI or call sites — they live here.
*/
export const SONIC_SIMILARITY_EXTENSION = 'sonicSimilarity';
export const FEATURE_AUDIOMUSE_SIMILAR_TRACKS = 'audiomuse.similarTracks';
export const PROBE_OPENSUBSONIC_EXTENSIONS = 'opensubsonic.extensions';
export const PROBE_LEGACY_INSTANT_MIX = 'navidrome.instantMix.legacy';
/** Operation names used by the call router. */
export const OP_SIMILAR_TRACKS = 'similarTracks';
export const SERVER_CAPABILITY_CATALOG: CapabilityDefinition[] = [
{
feature: FEATURE_AUDIOMUSE_SIMILAR_TRACKS,
labelKey: 'settings.audiomuseTitle',
strategies: [
{
// Navidrome ≥ 0.62: AudioMuse plugin advertised via OpenSubsonic.
id: 'opensubsonic.sonicSimilarity',
priority: 100,
when: (ctx) => ctx.isNavidrome && ctx.semverGte([0, 62, 0]),
detection: {
kind: 'extension',
probeId: PROBE_OPENSUBSONIC_EXTENSIONS,
extension: SONIC_SIMILARITY_EXTENSION,
},
trust: 'high',
activation: 'auto',
calls: {
[OP_SIMILAR_TRACKS]: { endpoint: 'getSonicSimilarTracks.view', transport: 'opensubsonic' },
},
labelKey: 'settings.audiomuseStrategySonic',
},
{
// Navidrome ≥ 0.60: legacy Instant Mix via getSimilarSongs (agents/plugin).
id: 'subsonic.getSimilarSongs',
priority: 50,
when: (ctx) => ctx.isNavidrome && ctx.semverGte([0, 60, 0]),
detection: {
kind: 'functional',
probeId: PROBE_LEGACY_INSTANT_MIX,
presentWhen: (outcome) => outcome.status === 'present',
},
trust: 'low',
activation: 'manual',
alwaysCallable: true,
calls: {
[OP_SIMILAR_TRACKS]: { endpoint: 'getSimilarSongs.view', transport: 'subsonic' },
},
labelKey: 'settings.audiomuseStrategyLegacy',
},
],
},
];
export function getCapabilityDefinition(feature: string): CapabilityDefinition | undefined {
return SERVER_CAPABILITY_CATALOG.find((d) => d.feature === feature);
}
+26
View File
@@ -0,0 +1,26 @@
import {
isNavidromeServer,
parseLeadingSemver,
type SubsonicServerIdentity,
} from '../utils/server/subsonicServerIdentity';
import type { CapabilityContext, Semver } from './types';
function semverGte(a: Semver, b: Semver): boolean {
for (let i = 0; i < 3; i++) {
if (a[i] > b[i]) return true;
if (a[i] < b[i]) return false;
}
return true;
}
/** Build the eligibility context for a connected server from its `ping` identity. */
export function buildCapabilityContext(identity: SubsonicServerIdentity | undefined): CapabilityContext {
const version = parseLeadingSemver(identity?.serverVersion);
return {
identity,
isNavidrome: isNavidromeServer(identity),
openSubsonic: !!identity?.openSubsonic,
version,
semverGte: (min) => (version ? semverGte(version, min) : false),
};
}
+117
View File
@@ -0,0 +1,117 @@
import { describe, expect, it } from 'vitest';
import { buildCapabilityContext } from './context';
import {
FEATURE_AUDIOMUSE_SIMILAR_TRACKS,
OP_SIMILAR_TRACKS,
PROBE_LEGACY_INSTANT_MIX,
PROBE_OPENSUBSONIC_EXTENSIONS,
SERVER_CAPABILITY_CATALOG,
SONIC_SIMILARITY_EXTENSION,
getCapabilityDefinition,
} from './catalog';
import {
isCapabilityActive,
neededProbeIds,
pickStrategy,
resolveCallChain,
resolveCapability,
} from './resolve';
import type { ProbeOutcome } from './types';
const def = getCapabilityDefinition(FEATURE_AUDIOMUSE_SIMILAR_TRACKS)!;
function ctxFor(version: string | undefined, type = 'navidrome') {
return buildCapabilityContext(version === undefined && type === ''
? undefined
: { type, serverVersion: version, openSubsonic: true });
}
const extPresent: ProbeOutcome = { status: 'present', extensions: [SONIC_SIMILARITY_EXTENSION] };
const extAbsent: ProbeOutcome = { status: 'present', extensions: [] };
describe('pickStrategy', () => {
it('chooses sonicSimilarity on Navidrome ≥ 0.62', () => {
expect(pickStrategy(def, ctxFor('0.62.0'))?.id).toBe('opensubsonic.sonicSimilarity');
});
it('chooses legacy getSimilarSongs on Navidrome 0.61', () => {
expect(pickStrategy(def, ctxFor('0.61.0'))?.id).toBe('subsonic.getSimilarSongs');
});
it('is ineligible on non-Navidrome', () => {
expect(pickStrategy(def, ctxFor('1.0.0', 'gonic'))).toBeNull();
});
it('is ineligible on Navidrome older than 0.60', () => {
expect(pickStrategy(def, ctxFor('0.59.9'))).toBeNull();
});
});
describe('neededProbeIds', () => {
it('asks for the extensions probe on 0.62+', () => {
const ids = neededProbeIds(SERVER_CAPABILITY_CATALOG, ctxFor('0.62.0'));
expect(ids.has(PROBE_OPENSUBSONIC_EXTENSIONS)).toBe(true);
expect(ids.has(PROBE_LEGACY_INSTANT_MIX)).toBe(false);
});
it('asks for the legacy probe on 0.61', () => {
const ids = neededProbeIds(SERVER_CAPABILITY_CATALOG, ctxFor('0.61.0'));
expect(ids.has(PROBE_LEGACY_INSTANT_MIX)).toBe(true);
expect(ids.has(PROBE_OPENSUBSONIC_EXTENSIONS)).toBe(false);
});
});
describe('resolveCapability', () => {
it('present when sonicSimilarity extension is advertised', () => {
const r = resolveCapability(def, ctxFor('0.62.0'), { [PROBE_OPENSUBSONIC_EXTENSIONS]: extPresent });
expect(r).toMatchObject({ strategyId: 'opensubsonic.sonicSimilarity', status: 'present', trust: 'high', activation: 'auto' });
});
it('absent when extensions list lacks sonicSimilarity', () => {
const r = resolveCapability(def, ctxFor('0.62.0'), { [PROBE_OPENSUBSONIC_EXTENSIONS]: extAbsent });
expect(r.status).toBe('absent');
});
it('error propagates from probe', () => {
const r = resolveCapability(def, ctxFor('0.62.0'), { [PROBE_OPENSUBSONIC_EXTENSIONS]: { status: 'error' } });
expect(r.status).toBe('error');
});
it('unknown when not yet probed', () => {
expect(resolveCapability(def, ctxFor('0.62.0'), {}).status).toBe('unknown');
});
it('legacy present when functional probe ok', () => {
const r = resolveCapability(def, ctxFor('0.61.0'), { [PROBE_LEGACY_INSTANT_MIX]: { status: 'present' } });
expect(r).toMatchObject({ strategyId: 'subsonic.getSimilarSongs', status: 'present', trust: 'low', activation: 'manual' });
});
it('ineligible on non-Navidrome', () => {
expect(resolveCapability(def, ctxFor('1.0.0', 'gonic'), {}).status).toBe('ineligible');
});
});
describe('isCapabilityActive', () => {
it('auto feature on iff detected present', () => {
const present = resolveCapability(def, ctxFor('0.62.0'), { [PROBE_OPENSUBSONIC_EXTENSIONS]: extPresent });
const absent = resolveCapability(def, ctxFor('0.62.0'), { [PROBE_OPENSUBSONIC_EXTENSIONS]: extAbsent });
expect(isCapabilityActive(present, false)).toBe(true);
expect(isCapabilityActive(absent, true)).toBe(false);
});
it('manual feature follows opt-in unless proven absent', () => {
const ok = resolveCapability(def, ctxFor('0.61.0'), { [PROBE_LEGACY_INSTANT_MIX]: { status: 'present' } });
const empty = resolveCapability(def, ctxFor('0.61.0'), { [PROBE_LEGACY_INSTANT_MIX]: { status: 'absent' } });
expect(isCapabilityActive(ok, true)).toBe(true);
expect(isCapabilityActive(ok, false)).toBe(false);
expect(isCapabilityActive(empty, true)).toBe(false);
});
});
describe('resolveCallChain (prefer sonic, fallback legacy)', () => {
it('0.62 with plugin → sonic then legacy', () => {
const chain = resolveCallChain(def, ctxFor('0.62.0'), { [PROBE_OPENSUBSONIC_EXTENSIONS]: extPresent }, OP_SIMILAR_TRACKS);
expect(chain.map(r => r.endpoint)).toEqual(['getSonicSimilarTracks.view', 'getSimilarSongs.view']);
});
it('0.62 without plugin → legacy only', () => {
const chain = resolveCallChain(def, ctxFor('0.62.0'), { [PROBE_OPENSUBSONIC_EXTENSIONS]: extAbsent }, OP_SIMILAR_TRACKS);
expect(chain.map(r => r.endpoint)).toEqual(['getSimilarSongs.view']);
});
it('0.61 → legacy only', () => {
const chain = resolveCallChain(def, ctxFor('0.61.0'), {}, OP_SIMILAR_TRACKS);
expect(chain.map(r => r.endpoint)).toEqual(['getSimilarSongs.view']);
});
it('non-Navidrome → empty', () => {
expect(resolveCallChain(def, ctxFor('1.0.0', 'gonic'), {}, OP_SIMILAR_TRACKS)).toEqual([]);
});
});
+109
View File
@@ -0,0 +1,109 @@
import type {
CapabilityCallRoute,
CapabilityContext,
CapabilityDefinition,
CapabilityStatus,
CapabilityStrategy,
ProbeOutcome,
ResolvedCapability,
StrategyDetection,
} from './types';
/** Strategies eligible for this server, strongest first. */
export function eligibleStrategies(
def: CapabilityDefinition,
ctx: CapabilityContext,
): CapabilityStrategy[] {
return def.strategies
.filter((s) => s.when(ctx))
.sort((a, b) => b.priority - a.priority);
}
/** The single strategy that owns this feature on the connected server. */
export function pickStrategy(
def: CapabilityDefinition,
ctx: CapabilityContext,
): CapabilityStrategy | null {
return eligibleStrategies(def, ctx)[0] ?? null;
}
/** Probe ids that need running for the selected strategy of each catalog feature. */
export function neededProbeIds(
catalog: CapabilityDefinition[],
ctx: CapabilityContext,
): Set<string> {
const ids = new Set<string>();
for (const def of catalog) {
const strategy = pickStrategy(def, ctx);
if (strategy) ids.add(strategy.detection.probeId);
}
return ids;
}
export function detectionStatus(
detection: StrategyDetection,
outcome: ProbeOutcome | undefined,
): CapabilityStatus {
if (!outcome) return 'unknown';
if (outcome.status === 'probing') return 'probing';
if (outcome.status === 'error') return 'error';
if (detection.kind === 'extension') {
if (outcome.status !== 'present') return 'absent';
return (outcome.extensions ?? []).includes(detection.extension) ? 'present' : 'absent';
}
return detection.presentWhen(outcome) ? 'present' : 'absent';
}
/** Resolve a feature's current state from catalog + probe outcomes. */
export function resolveCapability(
def: CapabilityDefinition,
ctx: CapabilityContext,
probes: Record<string, ProbeOutcome | undefined>,
): ResolvedCapability {
const strategy = pickStrategy(def, ctx);
if (!strategy) {
return { feature: def.feature, strategyId: null, status: 'ineligible', trust: null, activation: null };
}
const outcome = probes[strategy.detection.probeId];
return {
feature: def.feature,
strategyId: strategy.id,
status: detectionStatus(strategy.detection, outcome),
trust: strategy.trust,
activation: strategy.activation,
};
}
/**
* Whether a resolved feature is effectively on. Auto features follow detection;
* manual features follow the user opt-in unless detection proves them absent.
*/
export function isCapabilityActive(resolved: ResolvedCapability, userOptIn: boolean): boolean {
if (resolved.strategyId === null || resolved.status === 'ineligible') return false;
if (resolved.activation === 'auto') return resolved.status === 'present';
if (resolved.status === 'absent') return false;
return userOptIn;
}
/**
* Ordered call routes for an operation: strongest strategy first. A strategy is
* included when its detection is present, or when it is marked `alwaysCallable`
* (legacy fallback). Enables prefer-new-then-fallback routing.
*/
export function resolveCallChain(
def: CapabilityDefinition,
ctx: CapabilityContext,
probes: Record<string, ProbeOutcome | undefined>,
op: string,
): CapabilityCallRoute[] {
const routes: CapabilityCallRoute[] = [];
for (const strategy of eligibleStrategies(def, ctx)) {
const call = strategy.calls[op];
if (!call) continue;
const status = detectionStatus(strategy.detection, probes[strategy.detection.probeId]);
if (status === 'present' || strategy.alwaysCallable) {
routes.push({ strategyId: strategy.id, endpoint: call.endpoint, transport: call.transport });
}
}
return routes;
}
+67
View File
@@ -0,0 +1,67 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { useAuthStore } from '../store/authStore';
import { FEATURE_AUDIOMUSE_SIMILAR_TRACKS, OP_SIMILAR_TRACKS } from './catalog';
import {
isFeatureActiveForServer,
resolveCallRoutesForServer,
resolveFeatureForServer,
} from './storeView';
const SID = 'srv-test';
function seed(identity: Record<string, unknown>, extra: Record<string, unknown> = {}) {
useAuthStore.setState({
subsonicServerIdentityByServer: { [SID]: identity as never },
audiomusePluginProbeByServer: {},
instantMixProbeByServer: {},
audiomuseNavidromeByServer: {},
...extra,
} as never);
}
describe('storeView (capability read facade)', () => {
beforeEach(() => {
useAuthStore.setState({
subsonicServerIdentityByServer: {},
audiomusePluginProbeByServer: {},
instantMixProbeByServer: {},
audiomuseNavidromeByServer: {},
} as never);
});
it('resolves sonic strategy as present from the plugin probe map', () => {
seed({ type: 'navidrome', serverVersion: '0.62.1', openSubsonic: true }, {
audiomusePluginProbeByServer: { [SID]: 'present' },
});
const resolved = resolveFeatureForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS);
expect(resolved).toMatchObject({ strategyId: 'opensubsonic.sonicSimilarity', status: 'present', activation: 'auto' });
expect(isFeatureActiveForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS)).toBe(true);
expect(resolveCallRoutesForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS, OP_SIMILAR_TRACKS).map(r => r.endpoint))
.toEqual(['getSonicSimilarTracks.view', 'getSimilarSongs.view']);
});
it('resolves sonic absent → legacy-only route, feature off', () => {
seed({ type: 'navidrome', serverVersion: '0.62.1', openSubsonic: true }, {
audiomusePluginProbeByServer: { [SID]: 'absent' },
});
expect(resolveFeatureForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS)?.status).toBe('absent');
expect(isFeatureActiveForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS)).toBe(false);
expect(resolveCallRoutesForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS, OP_SIMILAR_TRACKS).map(r => r.endpoint))
.toEqual(['getSimilarSongs.view']);
});
it('legacy server: manual opt-in drives active state', () => {
seed({ type: 'navidrome', serverVersion: '0.61.0', openSubsonic: false }, {
instantMixProbeByServer: { [SID]: 'ok' },
audiomuseNavidromeByServer: { [SID]: true },
});
expect(resolveFeatureForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS)?.strategyId).toBe('subsonic.getSimilarSongs');
expect(isFeatureActiveForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS)).toBe(true);
});
it('non-Navidrome server resolves ineligible with no routes', () => {
seed({ type: 'gonic', serverVersion: '0.16.0', openSubsonic: true });
expect(resolveFeatureForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS)?.status).toBe('ineligible');
expect(resolveCallRoutesForServer(SID, FEATURE_AUDIOMUSE_SIMILAR_TRACKS, OP_SIMILAR_TRACKS)).toEqual([]);
});
});
+85
View File
@@ -0,0 +1,85 @@
import { useAuthStore } from '../store/authStore';
import type {
AudiomusePluginProbeResult,
InstantMixProbeResult,
} from '../utils/server/subsonicServerIdentity';
import { buildCapabilityContext } from './context';
import {
PROBE_LEGACY_INSTANT_MIX,
PROBE_OPENSUBSONIC_EXTENSIONS,
SONIC_SIMILARITY_EXTENSION,
getCapabilityDefinition,
} from './catalog';
import {
isCapabilityActive,
resolveCallChain,
resolveCapability,
} from './resolve';
import type {
CapabilityCallRoute,
ProbeOutcome,
ResolvedCapability,
} from './types';
/**
* Probe results currently live in dedicated per-server store maps. This facade
* maps them into the generic `ProbeOutcome` shape the resolver consumes, so the
* catalog/resolver/router stay storage-agnostic.
*/
function pluginProbeToOutcome(probe: AudiomusePluginProbeResult | undefined): ProbeOutcome | undefined {
switch (probe) {
case 'present': return { status: 'present', extensions: [SONIC_SIMILARITY_EXTENSION] };
case 'absent': return { status: 'present', extensions: [] };
case 'probing': return { status: 'probing' };
case 'error': return { status: 'error' };
default: return undefined;
}
}
function legacyProbeToOutcome(probe: InstantMixProbeResult | undefined): ProbeOutcome | undefined {
switch (probe) {
case 'ok': return { status: 'present' };
case 'empty':
case 'skipped': return { status: 'absent' };
case 'error': return { status: 'error' };
default: return undefined;
}
}
export function buildProbeOutcomesForServer(serverId: string): Record<string, ProbeOutcome | undefined> {
const s = useAuthStore.getState();
return {
[PROBE_OPENSUBSONIC_EXTENSIONS]: pluginProbeToOutcome(s.audiomusePluginProbeByServer[serverId]),
[PROBE_LEGACY_INSTANT_MIX]: legacyProbeToOutcome(s.instantMixProbeByServer[serverId]),
};
}
export function resolveFeatureForServer(
serverId: string,
feature: string,
): ResolvedCapability | null {
const def = getCapabilityDefinition(feature);
if (!def) return null;
const s = useAuthStore.getState();
const ctx = buildCapabilityContext(s.subsonicServerIdentityByServer[serverId]);
return resolveCapability(def, ctx, buildProbeOutcomesForServer(serverId));
}
export function isFeatureActiveForServer(serverId: string, feature: string): boolean {
const resolved = resolveFeatureForServer(serverId, feature);
if (!resolved) return false;
const userOptIn = !!useAuthStore.getState().audiomuseNavidromeByServer[serverId];
return isCapabilityActive(resolved, userOptIn);
}
export function resolveCallRoutesForServer(
serverId: string,
feature: string,
op: string,
): CapabilityCallRoute[] {
const def = getCapabilityDefinition(feature);
if (!def) return [];
const s = useAuthStore.getState();
const ctx = buildCapabilityContext(s.subsonicServerIdentityByServer[serverId]);
return resolveCallChain(def, ctx, buildProbeOutcomesForServer(serverId), op);
}
+92
View File
@@ -0,0 +1,92 @@
import type { SubsonicServerIdentity } from '../utils/server/subsonicServerIdentity';
export type Semver = [number, number, number];
/**
* Derived view of a connected server used by capability strategies to decide
* eligibility. Built once from the `ping` identity (see `context.ts`).
*/
export interface CapabilityContext {
identity: SubsonicServerIdentity | undefined;
isNavidrome: boolean;
openSubsonic: boolean;
version: Semver | null;
/** True when the connected server version is ≥ `min` (false when unknown). */
semverGte(min: Semver): boolean;
}
/** Raw outcome of a single probe (one network question against the server). */
export type ProbeStatus = 'probing' | 'present' | 'absent' | 'error';
export interface ProbeOutcome {
status: ProbeStatus;
/** OpenSubsonic extension names, for `extension`-kind detectors to read. */
extensions?: string[];
}
export type FeatureTrust = 'high' | 'low';
export type FeatureActivation = 'auto' | 'manual';
/** How a strategy decides it is actually available on the connected server. */
export type StrategyDetection =
| { kind: 'extension'; probeId: string; extension: string }
| { kind: 'functional'; probeId: string; presentWhen: (outcome: ProbeOutcome) => boolean };
/** A concrete API route a strategy can serve for a named operation. */
export interface CapabilityCall {
/** Subsonic REST endpoint, e.g. `getSonicSimilarTracks.view`. */
endpoint: string;
transport: 'subsonic' | 'opensubsonic';
}
/**
* One way to provide a feature on a given server generation. Higher `priority`
* wins when several strategies are eligible for the same server.
*/
export interface CapabilityStrategy {
id: string;
priority: number;
/** Eligible for the connected server type/version. */
when: (ctx: CapabilityContext) => boolean;
detection: StrategyDetection;
trust: FeatureTrust;
activation: FeatureActivation;
/** Operations this strategy can serve, keyed by operation name. */
calls: Record<string, CapabilityCall>;
/**
* Callable as a fallback even when detection is not satisfied — e.g. legacy
* `getSimilarSongs` still answers via Last.fm / local agents.
*/
alwaysCallable?: boolean;
labelKey: string;
}
export interface CapabilityDefinition {
feature: string;
labelKey: string;
strategies: CapabilityStrategy[];
}
export type CapabilityStatus =
| 'ineligible'
| 'unknown'
| 'probing'
| 'present'
| 'absent'
| 'error';
/** Resolved per-server state for one feature, derived from catalog + probes. */
export interface ResolvedCapability {
feature: string;
strategyId: string | null;
status: CapabilityStatus;
trust: FeatureTrust | null;
activation: FeatureActivation | null;
}
/** An ordered call route returned by the router for a feature operation. */
export interface CapabilityCallRoute {
strategyId: string;
endpoint: string;
transport: 'subsonic' | 'opensubsonic';
}