Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

feat: add `--experimental` to `generate-ts` (#10402)

jif-oai059d386f0316
diff --git a/codex-rs/app-server-protocol/src/bin/write_schema_fixtures.rs b/codex-rs/app-server-protocol/src/bin/write_schema_fixtures.rs
index a8e36d1ee8..789d30cea2 100644
--- a/codex-rs/app-server-protocol/src/bin/write_schema_fixtures.rs
+++ b/codex-rs/app-server-protocol/src/bin/write_schema_fixtures.rs
@@ -13,6 +13,10 @@ struct Args {
/// Optional path to the Prettier executable to format generated TypeScript files.
#[arg(short = 'p', long = "prettier", value_name = "PRETTIER_BIN")]
prettier: Option<PathBuf>,
+
+ /// Include experimental API methods and fields in generated fixtures.
+ #[arg(long = "experimental")]
+ experimental: bool,
}
fn main() -> Result<()> {
@@ -22,11 +26,17 @@ fn main() -> Result<()> {
.schema_root
.unwrap_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("schema"));
- codex_app_server_protocol::write_schema_fixtures(&schema_root, args.prettier.as_deref())
- .with_context(|| {
- format!(
- "failed to regenerate schema fixtures under {}",
- schema_root.display()
- )
- })
+ codex_app_server_protocol::write_schema_fixtures_with_options(
+ &schema_root,
+ args.prettier.as_deref(),
+ codex_app_server_protocol::SchemaFixtureOptions {
+ experimental_api: args.experimental,
+ },
+ )
+ .with_context(|| {
+ format!(
+ "failed to regenerate schema fixtures under {}",
+ schema_root.display()
+ )
+ })
}
diff --git a/codex-rs/app-server-protocol/src/lib.rs b/codex-rs/app-server-protocol/src/lib.rs
index 7b3f17045b..54a933bb74 100644
--- a/codex-rs/app-server-protocol/src/lib.rs
+++ b/codex-rs/app-server-protocol/src/lib.rs
@@ -16,5 +16,7 @@ pub use protocol::common::*;
pub use protocol::thread_history::*;
pub use protocol::v1::*;
pub use protocol::v2::*;
+pub use schema_fixtures::SchemaFixtureOptions;
pub use schema_fixtures::read_schema_fixture_tree;
pub use schema_fixtures::write_schema_fixtures;
+pub use schema_fixtures::write_schema_fixtures_with_options;
diff --git a/codex-rs/app-server-protocol/src/schema_fixtures.rs b/codex-rs/app-server-protocol/src/schema_fixtures.rs
index efd8bb2cb0..918011e95c 100644
--- a/codex-rs/app-server-protocol/src/schema_fixtures.rs
+++ b/codex-rs/app-server-protocol/src/schema_fixtures.rs
@@ -6,6 +6,11 @@ use std::collections::BTreeMap;
use std::path::Path;
use std::path::PathBuf;
+#[derive(Clone, Copy, Debug, Default)]
+pub struct SchemaFixtureOptions {
+ pub experimental_api: bool,
+}
+
pub fn read_schema_fixture_tree(schema_root: &Path) -> Result<BTreeMap<PathBuf, Vec<u8>>> {
let typescript_root = schema_root.join("typescript");
let json_root = schema_root.join("json");
@@ -26,14 +31,30 @@ pub fn read_schema_fixture_tree(schema_root: &Path) -> Result<BTreeMap<PathBuf,
/// This is intended to be used by tooling (e.g., `just write-app-server-schema`).
/// It deletes any previously generated files so stale artifacts are removed.
pub fn write_schema_fixtures(schema_root: &Path, prettier: Option<&Path>) -> Result<()> {
+ write_schema_fixtures_with_options(schema_root, prettier, SchemaFixtureOptions::default())
+}
+
+/// Regenerates schema fixtures with configurable options.
+pub fn write_schema_fixtures_with_options(
+ schema_root: &Path,
+ prettier: Option<&Path>,
+ options: SchemaFixtureOptions,
+) -> Result<()> {
let typescript_out_dir = schema_root.join("typescript");
let json_out_dir = schema_root.join("json");
ensure_empty_dir(&typescript_out_dir)?;
ensure_empty_dir(&json_out_dir)?;
- crate::generate_ts(&typescript_out_dir, prettier)?;
- crate::generate_json(&json_out_dir)?;
+ crate::generate_ts_with_options(
+ &typescript_out_dir,
+ prettier,
+ crate::GenerateTsOptions {
+ experimental_api: options.experimental_api,
+ ..crate::GenerateTsOptions::default()
+ },
+ )?;
+ crate::generate_json_with_experimental(&json_out_dir, options.experimental_api)?;
Ok(())
}
diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md
index 67bb36d149..1d5b6d15fd 100644
--- a/codex-rs/app-server/README.md
+++ b/codex-rs/app-server/README.md
@@ -788,6 +788,8 @@ At runtime, clients must send `initialize` with `capabilities.experimentalApi =
```bash
just write-app-server-schema
+ # Include experimental API fields/methods in fixtures.
+ just write-app-server-schema --experimental
```
5. Verify the protocol crate:
diff --git a/justfile b/justfile
index 67577c7c7f..024a31ba2a 100644
--- a/justfile
+++ b/justfile
@@ -69,8 +69,8 @@ write-config-schema:
cargo run -p codex-core --bin codex-write-config-schema
# Regenerate vendored app-server protocol schema artifacts.
-write-app-server-schema:
- cargo run -p codex-app-server-protocol --bin write_schema_fixtures
+write-app-server-schema *args:
+ cargo run -p codex-app-server-protocol --bin write_schema_fixtures -- "$@"
# Tail logs from the state SQLite database
log *args: