move pi-mono into companion-cloud as apps/companion-os

- Copy all pi-mono source into apps/companion-os/
- Update Dockerfile to COPY pre-built binary instead of downloading from GitHub Releases
- Update deploy-staging.yml to build pi from source (bun compile) before Docker build
- Add apps/companion-os/** to path triggers
- No more cross-repo dispatch needed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Harivansh Rathi 2026-03-07 09:22:50 -08:00
commit 0250f72976
579 changed files with 206942 additions and 0 deletions

View file

@ -0,0 +1,91 @@
import { dirname, join } from "node:path";
import * as readline from "node:readline";
import { fileURLToPath } from "node:url";
import { RpcClient } from "../src/modes/rpc/rpc-client.js";
const __dirname = dirname(fileURLToPath(import.meta.url));
/**
* Interactive example of using coding-agent via RpcClient.
* Usage: npx tsx test/rpc-example.ts
*/
async function main() {
const client = new RpcClient({
cliPath: join(__dirname, "../dist/cli.js"),
provider: "anthropic",
model: "claude-sonnet-4-20250514",
args: ["--no-session"],
});
// Stream events to console
client.onEvent((event) => {
if (event.type === "message_update") {
const { assistantMessageEvent } = event;
if (
assistantMessageEvent.type === "text_delta" ||
assistantMessageEvent.type === "thinking_delta"
) {
process.stdout.write(assistantMessageEvent.delta);
}
}
if (event.type === "tool_execution_start") {
console.log(`\n[Tool: ${event.toolName}]`);
}
if (event.type === "tool_execution_end") {
console.log(
`[Result: ${JSON.stringify(event.result).slice(0, 200)}...]\n`,
);
}
});
await client.start();
const state = await client.getState();
console.log(`Model: ${state.model?.provider}/${state.model?.id}`);
console.log(`Thinking: ${state.thinkingLevel ?? "off"}\n`);
// Handle user input
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: true,
});
let isWaiting = false;
const prompt = () => {
if (!isWaiting) process.stdout.write("You: ");
};
rl.on("line", async (line) => {
if (isWaiting) return;
if (line.trim() === "exit") {
await client.stop();
process.exit(0);
}
isWaiting = true;
await client.promptAndWait(line);
console.log("\n");
isWaiting = false;
prompt();
});
rl.on("SIGINT", () => {
if (isWaiting) {
console.log("\n[Aborting...]");
client.abort();
} else {
client.stop();
process.exit(0);
}
});
console.log("Interactive RPC example. Type 'exit' to quit.\n");
prompt();
}
main().catch(console.error);