-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
53 lines (46 loc) · 1.64 KB
/
Copy pathindex.ts
File metadata and controls
53 lines (46 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Multi-CLI bridge example.
//
// Demonstrates Squire's core differentiator: spawning multiple, different
// CLI agents from the same Node process and treating them as peers.
//
// Flow:
// 1. Claude Code answers the first prompt.
// 2. Its reply is captured and passed to Gemini CLI as context for a
// follow-up prompt.
// 3. Gemini's reply is printed.
import { Squire, type SquireEvent } from "@pythonluvr/squire";
async function runOnce(binary: string, args: string[], prompt: string): Promise<string> {
const squire = new Squire({ binary, args, cwd: process.cwd() });
let assembled = "";
squire.on("event", (event: SquireEvent) => {
if (event.type === "text_delta") {
assembled += event.delta;
process.stdout.write(event.delta);
} else if (event.type === "error") {
process.stderr.write(`\n[${binary} error] ${event.error.message}\n`);
}
});
process.stdout.write(`\n--- ${binary} ---\n`);
await squire.start(prompt);
process.stdout.write("\n");
return assembled.trim();
}
const claudeReply = await runOnce(
"claude",
["--permission-mode", "bypassPermissions"],
"Name one strength of subprocess-based AI agent runtimes. One sentence.",
);
const geminiReply = await runOnce(
"gemini",
["-m", "gemini-2.5-flash"],
[
"A peer agent just said the following about subprocess-based AI agent runtimes:",
"",
claudeReply,
"",
"Briefly add one counterpoint or complementary observation. One sentence.",
].join("\n"),
);
process.stdout.write("\n=== Bridged conversation complete ===\n");
process.stdout.write(`Claude: ${claudeReply}\n`);
process.stdout.write(`Gemini: ${geminiReply}\n`);