mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
cuter job names
This commit is contained in:
26
codex-rs/Cargo.lock
generated
26
codex-rs/Cargo.lock
generated
@@ -592,8 +592,9 @@ dependencies = [
|
||||
"dirs",
|
||||
"libc",
|
||||
"names",
|
||||
"nanoid",
|
||||
"nix 0.27.1",
|
||||
"petname",
|
||||
"rand 0.9.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sysinfo",
|
||||
@@ -2085,15 +2086,6 @@ dependencies = [
|
||||
"rand 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nanoid"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8"
|
||||
dependencies = [
|
||||
"rand 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.14"
|
||||
@@ -2412,6 +2404,20 @@ dependencies = [
|
||||
"indexmap 2.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "petname"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cd31dcfdbbd7431a807ef4df6edd6473228e94d5c805e8cf671227a21bad068"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"itertools 0.13.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rand 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "phf_shared"
|
||||
version = "0.11.3"
|
||||
|
||||
@@ -33,7 +33,8 @@ sysinfo = "0.29"
|
||||
tabwriter = "1.3"
|
||||
names = { version = "0.14", default-features = false }
|
||||
nix = { version = "0.27", default-features = false, features = ["process", "signal", "term", "fs"] }
|
||||
nanoid = "0.4.0"
|
||||
petname = "2.0.2"
|
||||
rand = "0.9.1"
|
||||
|
||||
# Re-use the codex-exec library for its CLI definition
|
||||
codex_exec = { package = "codex-exec", path = "../exec" }
|
||||
|
||||
@@ -17,12 +17,13 @@ use chrono::SecondsFormat;
|
||||
use clap::Args;
|
||||
use clap::Parser;
|
||||
use clap::Subcommand;
|
||||
use nanoid::nanoid;
|
||||
|
||||
// Platform-specific imports
|
||||
|
||||
#[cfg(unix)]
|
||||
use codex_repl as _;
|
||||
use petname::Generator;
|
||||
use petname::Petnames;
|
||||
use serde::Serialize;
|
||||
|
||||
/// A human-friendly representation of a byte count (e.g. 1.4M).
|
||||
@@ -198,9 +199,17 @@ fn truncate_preview(p: &str) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a new unique session identifier.
|
||||
///
|
||||
/// We use the `petname` crate to create short, memorable names consisting of
|
||||
/// two random words separated by a dash (e.g. "autumn-panda"). In the rare
|
||||
/// event of a collision with an existing session directory we retry until we
|
||||
/// find an unused ID.
|
||||
fn generate_session_id() -> Result<String> {
|
||||
let mut shortnames = Petnames::default();
|
||||
shortnames.retain(|s| s.len() <= 5);
|
||||
loop {
|
||||
let id = nanoid!(8);
|
||||
let id = shortnames.generate_one(2, "-").context("failed to generate session ID")?;
|
||||
if !store::paths_for(&id)?.dir.exists() {
|
||||
return Ok(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user