1
2
3
4
5
6
7
8
9
10
11
12
13
// node examples/compose.ts > examples/composition.json
import { composition } from "@publicdomainrelay/atlibs/compose/build.js";
import spec from "./modules/stub-agent.json" with { type: "json" };
// the stub agent's binding: its module.json under its key (code mode compiles it; no cargo, so no atlibs compose bindings)
const stubAgent = { key: "stub-agent", ...spec };
const c = composition({ name: "Code mode", description: "An agent writes AssemblyScript and runs it sandboxed through code mode's MCP server." });
const agent = c.instance("agent", stubAgent);
const mcp = c.handler("mcp", "atlibs-code-mode: js/index.js codeMode().handler, or js/cli.mjs as an exec handler");
c.route(agent, "com.fedfork.exec.mcp.message", mcp, "the agent runs code through code mode");
process.stdout.write(await c.json());