rinne_workers/adapters/
codex.rs1use std::time::Duration;
8
9use rinne_core::worker::{
10 AuthMode, Capability, LatencyProfile, QuotaModel, Transport, WorkerDescriptor, WorkerEvent,
11 WorkerFamily,
12};
13
14use super::common::{HarnessAdapter, ParsedHarness};
15use crate::transport::subprocess::SubprocessOutput;
16
17pub fn worker() -> HarnessAdapter {
18 HarnessAdapter {
19 descriptor: descriptor(),
20 program: "codex".to_string(),
21 build_args,
22 parse,
23 line_mapper,
24 prompt_via_stdin: false,
25 default_timeout: Duration::from_secs(600),
26 }
27}
28
29fn descriptor() -> WorkerDescriptor {
30 WorkerDescriptor {
31 name: "codex".to_string(),
32 family: WorkerFamily::Harness,
33 capabilities: vec![
34 Capability::CodeEdit,
35 Capability::RepoAware,
36 Capability::Reasoning,
37 Capability::ToolRun,
38 Capability::Writing,
39 ],
40 auth_mode: AuthMode::Subscription,
41 quota: QuotaModel {
42 capacity: 150_000.0,
43 refill_per_minute: 15_000.0,
44 },
45 latency: LatencyProfile::Medium,
46 transport: Transport::SubprocessJson,
47 models: Vec::new(),
48 }
49}
50
51fn build_args(prompt: &str, model: Option<&str>) -> Vec<String> {
52 let mut args = vec!["exec".into()];
53 if let Some(m) = model {
54 args.push("--model".into());
55 args.push(m.into());
56 }
57 args.push(prompt.into());
58 args
59}
60
61fn parse(out: &SubprocessOutput) -> ParsedHarness {
64 ParsedHarness::raw(&out.stdout)
65}
66
67fn line_mapper(line: &str) -> Vec<WorkerEvent> {
68 let t = line.trim();
69 if t.is_empty() {
70 Vec::new()
71 } else {
72 vec![WorkerEvent::Message(t.to_string())]
73 }
74}