Files
mesh-sdk/test/fixtures/stdio-bundle.mjs
T
jschoubben 5fa64be894 Revert the revert of G's mesh-sdk merge (#191): G's sdk stands again over reader release 3
Main reverted G's half merge (#189, reverted by 8afc3eb in #191) and then took the reader release's S1-S5, which
copied G's code. G's form holds where they differ (process_bus.go, seats.go, state.go and their tests); the
release's kept names stay so main's callers keep building: SeatViewPrefix beside SeatReadPrefix, and QueueInvoke's
empty strings on not-ok (with its test TestQueueInvoke). The tree differs from G's head f30dee54 only by those and
the release's two tests (objects cap option, seat states and stream kinds).

Builds: design 47 G (the milestone's sdk part, as at f30dee54)

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-13 12:49:56 +01:00

18 lines
1.0 KiB
JavaScript

// A tools bundle written against the protocol: the module's own tool, a seat's verb, one that fails, and one that says
// who called it as the runtime proved it and refuses a caller its verb's list does not name.
import { serveStdio } from "../../dist/stdio/index.js";
import { callerOf, callIdOf, refusal } from "../../dist/callers/index.js";
const verbs = { "node-lamp.on": ["mesh-delivery-forge-bridge"] };
await serveStdio("lamp", [
{ name: "brightness", description: "set it", input: { level: { type: "number", description: "0 to 10" } }, run: async (a) => ({ level: a.level }) },
{ name: "node-lamp.on", description: "the seat's verb", input: {}, run: async (a) => {
const no = refusal(verbs, "node-lamp.on", callerOf(a));
if (no) throw no;
return { on: true };
} },
{ name: "fail", description: "it throws", input: {}, run: async () => { throw new Error("the bulb is gone"); } },
{ name: "who", description: "who called", input: {}, run: async (a) => ({ caller: callerOf(a), call: callIdOf(a) }) },
]);