17 lines · 538 B · TypeScript
RawDownload
import { createClient } from "@rivet-dev/agentos/client";import type { registry } from "./server"; const client = createClient<typeof registry>({ endpoint: "http://localhost:6420" });const agent = client.vm.getOrCreate("my-agent"); const { pid } = await agent.spawn("cat", []); // Write to stdinawait agent.writeProcessStdin(pid, "hello from stdin\n"); // Close stdin when doneawait agent.closeProcessStdin(pid); // Wait for the process to exitconst exitCode = await agent.waitProcess(pid);console.log("exit code:", exitCode);