Expose discovered CultMesh providers
This commit is contained in:
parent
1cdcf8fbe3
commit
64d95c3504
2 changed files with 66 additions and 17 deletions
|
|
@ -74,24 +74,28 @@ function createInterfaceDiscovery({
|
|||
surfaceDefinition,
|
||||
],
|
||||
});
|
||||
const binding = node.get(interfaceBindingDefinition, "voidbot.swarm");
|
||||
if (!binding?.providerId) {
|
||||
continue;
|
||||
const bindings = typeof node.cache?.getAll === "function"
|
||||
? node.cache.getAll(interfaceBindingDefinition)
|
||||
: [node.get(interfaceBindingDefinition, "voidbot.swarm")].filter(Boolean);
|
||||
for (const binding of bindings) {
|
||||
if (!binding?.providerId) {
|
||||
continue;
|
||||
}
|
||||
const state = node.get(surfaceDefinition, binding.providerId);
|
||||
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`,
|
||||
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,
|
||||
});
|
||||
}
|
||||
const state = node.get(surfaceDefinition, binding.providerId);
|
||||
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`,
|
||||
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,
|
||||
});
|
||||
} catch (error) {
|
||||
interfaces.push(dashboardUnavailable("voidbot.swarm", `cultmesh:${storePath}`, error.message));
|
||||
interfaces.push(dashboardUnavailable(`cultmesh:${storePath}`, `cultmesh:${storePath}`, error.message));
|
||||
}
|
||||
}
|
||||
return interfaces;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ function handleHttp(req, res, getCurrentState, getHealth) {
|
|||
capabilities: ["network-status", "cultmesh-verses", "cultui-surface"],
|
||||
usesCultMesh: true,
|
||||
transport: "CultMesh durable surface + Eve WebSocket",
|
||||
}],
|
||||
}, ...providerCatalogFromState(currentState)],
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
|
@ -43,6 +43,51 @@ function handleHttp(req, res, getCurrentState, getHealth) {
|
|||
res.end("not found");
|
||||
}
|
||||
|
||||
function providerCatalogFromState(state) {
|
||||
const root = state?.surface?.root;
|
||||
const children = Array.isArray(root?.children) ? root.children : [];
|
||||
return children
|
||||
.filter((child) => child?.kind === "interface" && child.props?.providerId)
|
||||
.map((child) => {
|
||||
const props = child.props || {};
|
||||
const embeddedRoot = Array.isArray(child.children) ? child.children[0] : null;
|
||||
return {
|
||||
id: String(props.providerId),
|
||||
title: String(props.title || props.providerId),
|
||||
description: String(props.detail || "Provider-owned Eve/CultUI interface discovered by Odin."),
|
||||
version: String(props.version || 0),
|
||||
endpoint: props.source || "/eve/deck",
|
||||
capabilities: providerCapabilities(embeddedRoot),
|
||||
usesCultMesh: String(props.source || "").startsWith("cultmesh:"),
|
||||
transport: String(props.source || "").startsWith("cultmesh:")
|
||||
? "CultMesh Eve interface binding"
|
||||
: "Eve WebSocket provider",
|
||||
status: props.status || "unknown",
|
||||
updatedAt: props.updatedAt || state.updatedAt,
|
||||
source: props.source || "",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function providerCapabilities(root) {
|
||||
const capabilities = new Set(["cultui-surface"]);
|
||||
if (hasCommand(root)) {
|
||||
capabilities.add("command-surface");
|
||||
}
|
||||
return [...capabilities];
|
||||
}
|
||||
|
||||
function hasCommand(node) {
|
||||
if (!node || typeof node !== "object") {
|
||||
return false;
|
||||
}
|
||||
const props = node.props || {};
|
||||
if (props.command || props.action?.command || props.action?.type) {
|
||||
return true;
|
||||
}
|
||||
return Array.isArray(node.children) && node.children.some(hasCommand);
|
||||
}
|
||||
|
||||
function handleUpgrade(req, socket, clients, getCurrentState, applyClientCommand) {
|
||||
if (!req.url.startsWith("/eve/deck")) {
|
||||
socket.end("HTTP/1.1 404 Not Found\r\n\r\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue