Lines 1-31javascript
2// Thin launcher for the PetBox agent-wiring kit.
4// Plain JS (no TypeScript) so it still starts on an old Node and can print a clear
5// version error. The kit itself is plain TypeScript executed by Node's native
6// type-stripping, which needs Node >= 23.6.
8const [maj, min] = process.versions.node.split(".").map((n) => parseInt(n, 10));
9if (maj < 23 || (maj === 23 && min < 6)) {
11 `petbox-wire needs Node >= 23.6 (native TypeScript type-stripping); you have ${process.versions.node}`,
16// Node deliberately refuses to type-strip .ts files under node_modules
17// (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING), and the npx cache is exactly that — so the
18// kit cannot run in place. Copy it out to a temp dir and import from there; wire.ts then
19// installs the stable copy (~/.petbox/wire/) itself after validating the key.
20const { cpSync, mkdtempSync } = await import("node:fs");
21const { tmpdir } = await import("node:os");
MediumDynamic Require
Package source references dynamic require/import behavior.
bin/petbox-wire.jsView on unpkg · L19 22const { join, dirname } = await import("node:path");
23const { fileURLToPath, pathToFileURL } = await import("node:url");
25const srcDir = join(dirname(fileURLToPath(import.meta.url)), "..", "src");
26const runDir = mkdtempSync(join(tmpdir(), "petbox-wire-"));
27cpSync(srcDir, runDir, { recursive: true });
29// wire.ts runs main() at module top level, so importing it executes the CLI.
30await import(pathToFileURL(join(runDir, "wire.ts")).href);