diff --git a/src/odin/config.cjs b/src/odin/config.cjs index 56eec16..24d6637 100644 --- a/src/odin/config.cjs +++ b/src/odin/config.cjs @@ -26,9 +26,13 @@ function buildConfig(argv) { .filter(Boolean); const observationLogPath = args.observationLogPath || path.join(repoRoot, "..", "Mimir", "artifacts", "runtime", "periwinkle-cultmesh-sensors.out.log"); const observationFreshSeconds = Number(args.observationFreshSeconds || 120); + const defaultInterfaceBindingStores = [ + path.join(repoRoot, "..", "VoidBot", ".voidbot", "status", "cultmesh", "voidbot-swarm-state.cc"), + path.join(repoRoot, "..", "Bifrost", ".bifrost", "provider-advertisement.cc"), + ].join(","); const interfaceBindingStores = String( args.interfaceBindingStore || - path.join(repoRoot, "..", "VoidBot", ".voidbot", "status", "cultmesh", "voidbot-swarm-state.cc"), + defaultInterfaceBindingStores, ) .split(",") .map((entry) => entry.trim()) diff --git a/src/odin/interfaces.cjs b/src/odin/interfaces.cjs index 6373237..1996f2b 100644 --- a/src/odin/interfaces.cjs +++ b/src/odin/interfaces.cjs @@ -139,16 +139,17 @@ function createInterfaceDiscovery({ continue; } const state = node.get(surfaceDefinition, binding.providerId); + const surface = state?.surface || binding.surface || null; interfaces.push({ providerId: binding.providerId, title: binding.title || state?.title || binding.providerId, state: "active", - detail: `${state?.surface?.root?.kind || binding.kind || "surface"} ${state?.nodes?.length || 0} nodes via CultMesh`, + detail: `${surface?.root?.kind || binding.kind || "surface"} ${countSurfaceNodes(surface, state)} nodes via CultMesh`, version: state?.version || 0, updatedAt: state?.updatedAt || binding.updatedAt || new Date().toISOString(), source: `cultmesh:${storePath}`, manifest: binding.provider || null, - surface: state?.surface || binding.surface || null, + surface, }); } } catch (error) { @@ -209,7 +210,7 @@ async function fetchEveProvider(url, providerId, manifest = null) { providerId, title: state.title || manifest?.title || providerId, state: "active", - detail: `${surface?.root?.kind || "surface"} ${state.nodes?.length || 0} nodes`, + detail: `${surface?.root?.kind || "surface"} ${countSurfaceNodes(surface, state)} nodes`, version: state.version, updatedAt: state.updatedAt, source: url, @@ -241,6 +242,31 @@ function dashboardUnavailable(providerId, source, detail) { }; } +function countSurfaceNodes(surface, state = null) { + if (Array.isArray(state?.nodes)) { + return state.nodes.length; + } + if (!surface?.root) { + return 0; + } + + let count = 0; + const stack = [surface.root]; + while (stack.length > 0) { + const node = stack.pop(); + if (!node || typeof node !== "object") { + continue; + } + count += 1; + if (Array.isArray(node.children)) { + for (const child of node.children) { + stack.push(child); + } + } + } + return count; +} + function legacySurfaceFromNodes(state, manifest = null) { const nodes = Array.isArray(state?.nodes) ? state.nodes : []; if (!nodes.length) { diff --git a/src/odin/surface.cjs b/src/odin/surface.cjs index 02f77c8..e46ecd9 100644 --- a/src/odin/surface.cjs +++ b/src/odin/surface.cjs @@ -34,7 +34,8 @@ function buildSurface({ observedAt, docker, adb, hosts, yggdrasilServices, verse id: `interface-${stableId(entry.providerId)}`, kind: "interface", props: { - title: verseUri(entry), + title: entry.title || entry.providerId, + verseUri: verseUri(entry), providerId: entry.providerId, source: entry.source, status: entry.state,