One tool runtime per node, host-side, is what the runtime was written to be; the catalogue built a container per module around it instead. This lets `serve` take a list — MESH_TOOL_MODULES as <module>=<entrypoint> entries — and do for every assigned module what it did for one: read that module's membership and follow it, serve its tools where the membership says, serve each held seat's verbs on the seat's subjects. The seats come from the memberships now, so the node's credential carries no claims; a module's own runtime still reads its credential's, so nothing built today changes behaviour. A bare path in MESH_TOOL_MODULES stays the one-module form. A bundle that throws on import is said in the log and in what `tools` answers for its module (`failed`), which discovery lists with the reason instead of as "not answering"; the other bundles serve. The filter that dropped every registration under a name but the one module goes; what stays is that a registration under a seat's name is served only where some served module claims the seat. A tool runs attributed to its module, so an event it emits lands on the module's subject and not the runtime's. MESH_OPERATOR_ACCOUNT and MESH_OPERATOR_HOME are read and said; tools take them from their environment. Proven against a real bus: three bundles, one broken; five tools and two seat verbs answer on their subjects; `tools` names the failed bundle; a membership re-issued mid-run re-serves.
15 lines
816 B
JavaScript
15 lines
816 B
JavaScript
// One of several bundles the node's runtime loads (novox/hq ADR 0175): a module with three tools of
|
|
// its own and the implementation of a node seat's two verbs under the seat's name (ADR 0159).
|
|
import { registerModuleTools } from "@novox/mesh-sdk/tools";
|
|
|
|
registerModuleTools("beta", () => [
|
|
{ name: "three", description: "beta's", input: {}, run: async () => ({ beta: 3 }) },
|
|
{ name: "four", description: "beta's", input: {}, run: async () => ({ beta: 4 }) },
|
|
{ name: "five", description: "beta's", input: {}, run: async () => ({ beta: 5 }) },
|
|
]);
|
|
|
|
registerModuleTools("node-shelf", () => [
|
|
{ name: "list", description: "what is on the shelf", input: {}, run: async () => ({ shelf: ["a", "b"] }) },
|
|
{ name: "clear", description: "take it all off", input: {}, run: async () => ({ cleared: true }) },
|
|
]);
|