Files
mesh-sdk/test/fixtures/stdio-bundle.mjs
T
jschoubben 0d546d37f3 T-1, T-2: W1.11: the TypeScript side holds a seat as the Go side does
A TypeScript holder, the forge module first, must judge a verb's caller by the runtime's proof, say its seat's events
and answer its first views' read and ask-again tools (design 47, The forge module's tools come from mesh-sdk's
TypeScript side; G-F1 option A). The stdio session now hands each tool the caller and call id the runtime wrote in
_meta (callers.callerOf, the Go rules for Callers and VerbCallers), binds the runtime for seatPublish over
mesh/seat.publish and config, and views gains the Follower and its two status tools over the state first-views.
@novox/mesh-sdk 0.1.19.

Builds: design 47 G §196, §200, §336

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
2026-11-11 10:51:07 +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) }) },
]);