Spike: PTY-based Claude Code integration with multi-agent concurrency

Proves that spawning `claude -p` in a pseudo-terminal from Rust gets Max
subscription billing (apiKeySource: "none", rateLimitType: "five_hour")
instead of per-token API charges. Concurrent agents run in parallel PTY
sessions with session resumption via --resume for multi-turn conversations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dave
2026-02-19 15:25:22 +00:00
parent 8f0bc971bf
commit 68a19c393e
17 changed files with 1159 additions and 22 deletions

View File

@@ -1,3 +1,4 @@
mod agents;
mod http;
mod io;
mod llm;
@@ -5,6 +6,7 @@ mod state;
mod store;
mod workflow;
use crate::agents::AgentPool;
use crate::http::build_routes;
use crate::http::context::AppContext;
use crate::state::SessionState;
@@ -22,11 +24,13 @@ async fn main() -> Result<(), std::io::Error> {
JsonFileStore::from_path(PathBuf::from("store.json")).map_err(std::io::Error::other)?,
);
let workflow = Arc::new(std::sync::Mutex::new(WorkflowState::default()));
let agents = Arc::new(AgentPool::new());
let ctx = AppContext {
state: app_state,
store,
workflow,
agents,
};
let app = build_routes(ctx);
@@ -34,10 +38,10 @@ async fn main() -> Result<(), std::io::Error> {
println!(
"\x1b[95;1m ____ _ _ ___ _ \n / ___|| |_ ___ _ __| | _|_ _| |_ \n \\___ \\| __/ _ \\| '__| |/ /| || __|\n ___) | || (_) | | | < | || |_ \n |____/ \\__\\___/|_| |_|\\_\\___|\\__|\n\x1b[0m"
);
println!("\x1b[96;1mFrontend:\x1b[0m \x1b[94mhttp://127.0.0.1:3001\x1b[0m");
println!("\x1b[92;1mOpenAPI Docs:\x1b[0m \x1b[94mhttp://127.0.0.1:3001/docs\x1b[0m");
println!("\x1b[96;1mFrontend:\x1b[0m \x1b[94mhttp://127.0.0.1:3002\x1b[0m");
println!("\x1b[92;1mOpenAPI Docs:\x1b[0m \x1b[94mhttp://127.0.0.1:3002/docs\x1b[0m");
Server::new(TcpListener::bind("127.0.0.1:3001"))
Server::new(TcpListener::bind("127.0.0.1:3002"))
.run(app)
.await
}