Guide
Embedding POLYTONE
Since Sprint 353 POLYTONE runs inside other programs — as a process, as compiled WebAssembly in JavaScript, or as a VM with your own Host in Rust.
import { readFileSync } from "node:fs";
import { runModule } from "./runtime/wasm/host.mjs";
// ptc build grade.pt grade.wasm, then:
const r = await runModule(readFileSync("grade.wasm"), { stdin: "ada 92\n" });
console.log(r.stdout, r.stderr, r.exitCode); // "ada pass\n" "1 graded\n" 0runModule returns stdout, stderr and the exit code, with closed defaults: no environment, no processes and an empty stdin unless the embedder passes env, processes: true or stdin. In Rust, polytone_vm::run_with_host runs a checked, lowered program against your own Host — six required methods (files, env, clock, entropy, HTTP), every later capability defaulted. docs/EMBEDDING.md is the contract; examples/interop/ drives one filter from Python and from Node.