mesh/merge-gate head afd002a9004a merged into trunk 1a2c917abfdb — fail: builds adwaita, asus-zephyrus-g14, build-agent, ca-trust, clipmenu, docker, dunst,…
mesh/repo-check head afd002a9004a merged into trunk 1a2c917abfdb — pass: [release feat/57-config-and-provisioning, judged by its controller 6a6628a76961] T…
mesh/delivery superseded: a newer head of the same pull request
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
// showcase's tools — its operator-facing surface, served over the broker.
|
|
//
|
|
// Two of them, because one tool proves a tool can exist and two prove a module can have a surface.
|
|
import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools";
|
|
|
|
export function getShowcaseTools(env: NodeJS.ProcessEnv = process.env): ToolDefinition[] {
|
|
return [
|
|
{
|
|
name: "showcase_greet",
|
|
description: "Greet somebody, and say which machine did it.",
|
|
input: { type: "object", properties: { who: { type: "string" } } },
|
|
async run(args: Readonly<Record<string, unknown>>) {
|
|
const who = typeof args.who === "string" && args.who !== "" ? args.who : "world";
|
|
return { greeting: `hello ${who}`, from: env.MESH_NODE ?? "somewhere" };
|
|
},
|
|
},
|
|
{
|
|
name: "showcase_state",
|
|
description: "What this module was configured with, so a test can read it back.",
|
|
input: { type: "object", properties: {} },
|
|
async run() {
|
|
return {
|
|
greeting: env.SHOWCASE_GREETING ?? "",
|
|
database: env.SHOWCASE_DATABASE ?? "",
|
|
};
|
|
},
|
|
},
|
|
];
|
|
}
|
|
|
|
registerModuleTools("showcase", (env) => getShowcaseTools(env));
|