// The agent shell's own verbs (init ...) on the native `raea`, which runs this file on its JavaScriptCore with Node's core // (runtime/react/src/scene.rs shell(), raea_native::js::run_node), so each verb has one source: this package's handler. // The host's ops it needs are answered here, one more with each verb ported (docs/agent-surfaces.md); the rest refuse. // // native.ts RAEA VERB ARGS... RAEA: the native raea's path, for the engine's own verbs import { spawnSync } from "node:child_process"; import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { basename, delimiter, dirname, extname } from "node:path"; import { brandKit, pixelsOf } from "./brand"; import { readSite, stylesOf } from "./scrape"; import { wordsOf } from "./heard"; import { harness, library, show, task } from "./app"; import { fromCwd } from "./show"; import { clothesHost } from "./wardrobe"; import { raeaHandler, type Engine, type Host } from "./index"; const [raea, ...args] = process.argv.slice(2); const cwd = process.cwd(); const at = (p: string) => fromCwd(cwd, p); /** The project's shape: its cut's (cuts.json's edit), else a 1080x1920 vertical at 30 fps */ function shape() { const file = at("cuts.json"); const edit = existsSync(file) ? (JSON.parse(readFileSync(file, "utf8")) as { edit?: { width?: number; height?: number; fps?: number } }).edit : undefined; return edit?.width && edit.height && edit.fps ? { width: edit.width, height: edit.height, fps: edit.fps } : { width: 1080, height: 1920, fps: 30 }; } /** The engine's own verb run for its effect (`raea media still ...`); its answer, or why it refused */ function engineRun(a: string[]): string { const r = spawnSync(raea, a, { cwd, encoding: "utf8" }); if (r.status !== 0) throw new Error(`raea ${a.join(" ")}: ${(r.stdout + r.stderr).trim()}`); return r.stdout; } /** The engine's own answer as JSON (`raea media probe|cuts ...`) */ const engineJson = (a: string[]): any => JSON.parse(engineRun(a)); const VIDEO = ["mp4", "mov", "m4v", "mkv", "webm"]; /** a take with sound alone (a voice recording, a bed): cut on its words as a video is, played as