mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
fmt
This commit is contained in:
@@ -72,7 +72,6 @@ enum Commands {
|
||||
Logs(LogsCmd),
|
||||
/// List all known sessions.
|
||||
List(ListCmd),
|
||||
|
||||
// (previous mux variant removed)
|
||||
}
|
||||
|
||||
@@ -86,7 +85,6 @@ enum AgentKind {
|
||||
|
||||
/// Interactive Read-Eval-Print-Loop agent.
|
||||
Repl(ReplCreateCmd),
|
||||
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
@@ -111,7 +109,6 @@ pub struct ReplCreateCmd {
|
||||
repl_cli: codex_repl::Cli,
|
||||
}
|
||||
|
||||
|
||||
impl CreateCmd {
|
||||
pub async fn run(self) -> Result<()> {
|
||||
let id = match &self.id {
|
||||
@@ -123,20 +120,29 @@ impl CreateCmd {
|
||||
store::prepare_dirs(&paths)?;
|
||||
|
||||
// Spawn underlying agent
|
||||
let (pid, prompt_preview, kind): (u32, Option<String>, store::SessionKind) = match self.agent {
|
||||
AgentKind::Exec(cmd) => {
|
||||
let args = build_exec_args(&cmd.exec_cli);
|
||||
let child = spawn::spawn_exec(&paths, &args)?;
|
||||
let preview = cmd.exec_cli.prompt.as_ref().map(|p| truncate_preview(p));
|
||||
(child.id().unwrap_or_default(), preview, store::SessionKind::Exec)
|
||||
}
|
||||
AgentKind::Repl(cmd) => {
|
||||
let args = build_repl_args(&cmd.repl_cli);
|
||||
let child = spawn::spawn_repl(&paths, &args)?;
|
||||
let preview = cmd.repl_cli.prompt.as_ref().map(|p| truncate_preview(p));
|
||||
(child.id().unwrap_or_default(), preview, store::SessionKind::Repl)
|
||||
}
|
||||
};
|
||||
let (pid, prompt_preview, kind): (u32, Option<String>, store::SessionKind) =
|
||||
match self.agent {
|
||||
AgentKind::Exec(cmd) => {
|
||||
let args = build_exec_args(&cmd.exec_cli);
|
||||
let child = spawn::spawn_exec(&paths, &args)?;
|
||||
let preview = cmd.exec_cli.prompt.as_ref().map(|p| truncate_preview(p));
|
||||
(
|
||||
child.id().unwrap_or_default(),
|
||||
preview,
|
||||
store::SessionKind::Exec,
|
||||
)
|
||||
}
|
||||
AgentKind::Repl(cmd) => {
|
||||
let args = build_repl_args(&cmd.repl_cli);
|
||||
let child = spawn::spawn_repl(&paths, &args)?;
|
||||
let preview = cmd.repl_cli.prompt.as_ref().map(|p| truncate_preview(p));
|
||||
(
|
||||
child.id().unwrap_or_default(),
|
||||
preview,
|
||||
store::SessionKind::Repl,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
// Persist metadata **after** the process has been spawned so we can record its PID.
|
||||
let meta = store::SessionMeta {
|
||||
@@ -304,7 +310,8 @@ impl AttachCmd {
|
||||
async fn attach_line_oriented(&self, id: &str, paths: &store::Paths) -> Result<()> {
|
||||
use tokio::io::AsyncBufReadExt;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use tokio::time::sleep;
|
||||
use tokio::time::Duration;
|
||||
|
||||
// Ensure stdin pipe exists.
|
||||
if !paths.stdin.exists() {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
//! Spawn detached Codex agent processes for exec and repl sessions.
|
||||
|
||||
use crate::store::Paths;
|
||||
use anyhow::{Context, Result};
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use std::fs::OpenOptions;
|
||||
use tokio::process::{Child, Command};
|
||||
use tokio::process::Child;
|
||||
use tokio::process::Command;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// exec – non-interactive batch agent
|
||||
@@ -130,4 +132,3 @@ pub fn spawn_repl(paths: &Paths, repl_args: &[String]) -> Result<Child> {
|
||||
anyhow::bail!("codex-repl sessions are not supported on Windows yet");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@ pub enum SessionKind {
|
||||
}
|
||||
|
||||
impl Default for SessionKind {
|
||||
fn default() -> Self { SessionKind::Exec }
|
||||
fn default() -> Self {
|
||||
SessionKind::Exec
|
||||
}
|
||||
}
|
||||
|
||||
/// Create the on-disk directory structure and write metadata + empty log files.
|
||||
|
||||
Reference in New Issue
Block a user