Something went wrong. Try again.
Parametric learning in your code harness.
Something went wrong. Try again.
JavaScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465#!/usr/bin/env nodeimport { spawn } from "node:child_process";import { fileURLToPath } from "node:url";import path from "node:path";
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");const argv = process.argv.slice(2);
if (argv.includes("--help") || argv.includes("-h")) { console.log(`machine-tinker-agent — non-interactive adapter for /tinker
Usage: machine-tinker-agent machine-tinker-agent use tinker://.../sampler_weights/final [alias] machine-tinker-agent checkpoints logs/run --use machine-tinker-agent --cwd /path/to/project use tinker://.../final
This adapter runs Machine's /tinker command in Pi print mode.`); process.exit(0);}
let cwd = process.cwd();const cwdIndex = argv.indexOf("--cwd");if (cwdIndex !== -1) { const requested = argv[cwdIndex + 1]; if (!requested) { console.error("--cwd requires a directory"); process.exit(2); } cwd = path.resolve(requested); argv.splice(cwdIndex, 2);}
if (argv[0] === "/tinker" || argv[0] === "tinker") argv.shift();
const command = argv.length === 0 ? "/tinker" : `/tinker ${argv.map((value) => JSON.stringify(value)).join(" ")}`;const piBinary = process.env.PI_TINKER_PI_BIN || "pi";const child = spawn( piBinary, ["--no-extensions", "-e", packageRoot, "--no-session", "-p", command], { cwd, env: { ...process.env, PI_TINKER_AGENT_CLI: "1" }, stdio: ["inherit", "pipe", "pipe"] },);
child.stdout.pipe(process.stdout);child.stderr.pipe(process.stdout);
for (const signal of ["SIGINT", "SIGTERM"]) { process.on(signal, () => child.kill(signal));}
child.on("error", (error) => { if (error.code === "ENOENT") { console.error("Could not find the `pi` executable. Install Pi first, then retry."); } else { console.error(error.message); } process.exitCode = 1;});
child.on("exit", (code, signal) => { if (signal) process.exitCode = 1; else process.exitCode = code ?? 1;});