Lightweight coding agent that runs in your terminal
Rust
generate an internal json schema for `RolloutLine` (#14434)
Keyan Zhang904dbd414f22
diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.jsonindex dd5c955cfa..9c2004f057 100644--- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json+++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json@@ -871,24 +871,6 @@}]},- "FunctionCallOutputPayload": {- "description": "The payload we send back to OpenAI when reporting a tool call result.\n\n`body` serializes directly as the wire value for `function_call_output.output`. `success` remains internal metadata for downstream handling.",- "properties": {- "body": {- "$ref": "#/definitions/FunctionCallOutputBody"- },- "success": {- "type": [- "boolean",- "null"- ]- }- },- "required": [- "body"- ],- "type": "object"- },"FuzzyFileSearchParams": {"properties": {"cancellationToken": {@@ -1583,10 +1565,6 @@"null"]},- "id": {- "type": "string",- "writeOnly": true- },"summary": {"items": {"$ref": "#/definitions/ReasoningItemReasoningSummary"@@ -1602,7 +1580,6 @@}},"required": [- "id","summary","type"],@@ -1736,7 +1713,7 @@"type": "string"},"output": {- "$ref": "#/definitions/FunctionCallOutputPayload"+ "$ref": "#/definitions/FunctionCallOutputBody"},"type": {"enum": [@@ -1801,7 +1778,7 @@"type": "string"},"output": {- "$ref": "#/definitions/FunctionCallOutputPayload"+ "$ref": "#/definitions/FunctionCallOutputBody"},"type": {"enum": [diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.jsonindex 4709bae11c..e370546dc2 100644--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json@@ -7731,24 +7731,6 @@}]},- "FunctionCallOutputPayload": {- "description": "The payload we send back to OpenAI when reporting a tool call result.\n\n`body` serializes directly as the wire value for `function_call_output.output`. `success` remains internal metadata for downstream handling.",- "properties": {- "body": {- "$ref": "#/definitions/v2/FunctionCallOutputBody"- },- "success": {- "type": [- "boolean",- "null"- ]- }- },- "required": [- "body"- ],- "type": "object"- },"GetAccountParams": {"$schema": "http://json-schema.org/draft-07/schema#","properties": {@@ -10195,10 +10177,6 @@"null"]},- "id": {- "type": "string",- "writeOnly": true- },"summary": {"items": {"$ref": "#/definitions/v2/ReasoningItemReasoningSummary"@@ -10214,7 +10192,6 @@}},"required": [- "id","summary","type"],@@ -10348,7 +10325,7 @@"type": "string"},"output": {- "$ref": "#/definitions/v2/FunctionCallOutputPayload"+ "$ref": "#/definitions/v2/FunctionCallOutputBody"},"type": {"enum": [@@ -10413,7 +10390,7 @@"type": "string"},"output": {- "$ref": "#/definitions/v2/FunctionCallOutputPayload"+ "$ref": "#/definitions/v2/FunctionCallOutputBody"},"type": {"enum": [diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.jsonindex 601306fe14..b069d3e5e7 100644--- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json+++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json@@ -4375,24 +4375,6 @@}]},- "FunctionCallOutputPayload": {- "description": "The payload we send back to OpenAI when reporting a tool call result.\n\n`body` serializes directly as the wire value for `function_call_output.output`. `success` remains internal metadata for downstream handling.",- "properties": {- "body": {- "$ref": "#/definitions/FunctionCallOutputBody"- },- "success": {- "type": [- "boolean",- "null"- ]- }- },- "required": [- "body"- ],- "type": "object"- },"FuzzyFileSearchParams": {"$schema": "http://json-schema.org/draft-07/schema#","properties": {@@ -6983,10 +6965,6 @@"null"]},- "id": {- "type": "string",- "writeOnly": true- },"summary": {"items": {"$ref": "#/definitions/ReasoningItemReasoningSummary"@@ -7002,7 +6980,6 @@}},"required": [- "id","summary","type"],@@ -7136,7 +7113,7 @@"type": "string"},"output": {- "$ref": "#/definitions/FunctionCallOutputPayload"+ "$ref": "#/definitions/FunctionCallOutputBody"},"type": {"enum": [@@ -7201,7 +7178,7 @@"type": "string"},"output": {- "$ref": "#/definitions/FunctionCallOutputPayload"+ "$ref": "#/definitions/FunctionCallOutputBody"},"type": {"enum": [diff --git a/codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.jsonindex 19f0fe34f2..621332c3c2 100644--- a/codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.json+++ b/codex-rs/app-server-protocol/schema/json/v2/RawResponseItemCompletedNotification.json@@ -133,24 +133,6 @@}]},- "FunctionCallOutputPayload": {- "description": "The payload we send back to OpenAI when reporting a tool call result.\n\n`body` serializes directly as the wire value for `function_call_output.output`. `success` remains internal metadata for downstream handling.",- "properties": {- "body": {- "$ref": "#/definitions/FunctionCallOutputBody"- },- "success": {- "type": [- "boolean",- "null"- ]- }- },- "required": [- "body"- ],- "type": "object"- },"GhostCommit": {"description": "Details of a ghost commit created from a repository state.","properties": {@@ -413,10 +395,6 @@"null"]},- "id": {- "type": "string",- "writeOnly": true- },"summary": {"items": {"$ref": "#/definitions/ReasoningItemReasoningSummary"@@ -432,7 +410,6 @@}},"required": [- "id","summary","type"],@@ -566,7 +543,7 @@"type": "string"},"output": {- "$ref": "#/definitions/FunctionCallOutputPayload"+ "$ref": "#/definitions/FunctionCallOutputBody"},"type": {"enum": [@@ -631,7 +608,7 @@"type": "string"},"output": {- "$ref": "#/definitions/FunctionCallOutputPayload"+ "$ref": "#/definitions/FunctionCallOutputBody"},"type": {"enum": [diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.jsonindex b21c5a78ee..3524f86b26 100644--- a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json+++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json@@ -191,24 +191,6 @@}]},- "FunctionCallOutputPayload": {- "description": "The payload we send back to OpenAI when reporting a tool call result.\n\n`body` serializes directly as the wire value for `function_call_output.output`. `success` remains internal metadata for downstream handling.",- "properties": {- "body": {- "$ref": "#/definitions/FunctionCallOutputBody"- },- "success": {- "type": [- "boolean",- "null"- ]- }- },- "required": [- "body"- ],- "type": "object"- },"GhostCommit": {"description": "Details of a ghost commit created from a repository state.","properties": {@@ -479,10 +461,6 @@"null"]},- "id": {- "type": "string",- "writeOnly": true- },"summary": {"items": {"$ref": "#/definitions/ReasoningItemReasoningSummary"@@ -498,7 +476,6 @@}},"required": [- "id","summary","type"],@@ -632,7 +609,7 @@"type": "string"},"output": {- "$ref": "#/definitions/FunctionCallOutputPayload"+ "$ref": "#/definitions/FunctionCallOutputBody"},"type": {"enum": [@@ -697,7 +674,7 @@"type": "string"},"output": {- "$ref": "#/definitions/FunctionCallOutputPayload"+ "$ref": "#/definitions/FunctionCallOutputBody"},"type": {"enum": [diff --git a/codex-rs/app-server-protocol/schema/typescript/FunctionCallOutputPayload.ts b/codex-rs/app-server-protocol/schema/typescript/FunctionCallOutputPayload.tsdeleted file mode 100644index 6376c5b8eb..0000000000--- a/codex-rs/app-server-protocol/schema/typescript/FunctionCallOutputPayload.ts+++ /dev/null@@ -1,12 +0,0 @@-// GENERATED CODE! DO NOT MODIFY BY HAND!--// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.-import type { FunctionCallOutputBody } from "./FunctionCallOutputBody";--/**- * The payload we send back to OpenAI when reporting a tool call result.- *- * `body` serializes directly as the wire value for `function_call_output.output`.- * `success` remains internal metadata for downstream handling.- */-export type FunctionCallOutputPayload = { body: FunctionCallOutputBody, success: boolean | null, };diff --git a/codex-rs/app-server-protocol/schema/typescript/ResponseItem.ts b/codex-rs/app-server-protocol/schema/typescript/ResponseItem.tsindex 2464037a50..48e6b69d73 100644--- a/codex-rs/app-server-protocol/schema/typescript/ResponseItem.ts+++ b/codex-rs/app-server-protocol/schema/typescript/ResponseItem.ts@@ -2,7 +2,7 @@// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.import type { ContentItem } from "./ContentItem";-import type { FunctionCallOutputPayload } from "./FunctionCallOutputPayload";+import type { FunctionCallOutputBody } from "./FunctionCallOutputBody";import type { GhostCommit } from "./GhostCommit";import type { LocalShellAction } from "./LocalShellAction";import type { LocalShellStatus } from "./LocalShellStatus";@@ -15,4 +15,4 @@ export type ResponseItem = { "type": "message", role: string, content: Array<Con/*** Set when using the Responses API.*/-call_id: string | null, status: LocalShellStatus, action: LocalShellAction, } | { "type": "function_call", name: string, namespace?: string, arguments: string, call_id: string, } | { "type": "tool_search_call", call_id: string | null, status?: string, execution: string, arguments: unknown, } | { "type": "function_call_output", call_id: string, output: FunctionCallOutputPayload, } | { "type": "custom_tool_call", status?: string, call_id: string, name: string, input: string, } | { "type": "custom_tool_call_output", call_id: string, output: FunctionCallOutputPayload, } | { "type": "tool_search_output", call_id: string | null, status: string, execution: string, tools: unknown[], } | { "type": "web_search_call", status?: string, action?: WebSearchAction, } | { "type": "image_generation_call", id: string, status: string, revised_prompt?: string, result: string, } | { "type": "ghost_snapshot", ghost_commit: GhostCommit, } | { "type": "compaction", encrypted_content: string, } | { "type": "other" };+call_id: string | null, status: LocalShellStatus, action: LocalShellAction, } | { "type": "function_call", name: string, namespace?: string, arguments: string, call_id: string, } | { "type": "tool_search_call", call_id: string | null, status?: string, execution: string, arguments: unknown, } | { "type": "function_call_output", call_id: string, output: FunctionCallOutputBody, } | { "type": "custom_tool_call", status?: string, call_id: string, name: string, input: string, } | { "type": "custom_tool_call_output", call_id: string, output: FunctionCallOutputBody, } | { "type": "tool_search_output", call_id: string | null, status: string, execution: string, tools: unknown[], } | { "type": "web_search_call", status?: string, action?: WebSearchAction, } | { "type": "image_generation_call", id: string, status: string, revised_prompt?: string, result: string, } | { "type": "ghost_snapshot", ghost_commit: GhostCommit, } | { "type": "compaction", encrypted_content: string, } | { "type": "other" };diff --git a/codex-rs/app-server-protocol/schema/typescript/index.ts b/codex-rs/app-server-protocol/schema/typescript/index.tsindex 08a04de5a6..396d07e12b 100644--- a/codex-rs/app-server-protocol/schema/typescript/index.ts+++ b/codex-rs/app-server-protocol/schema/typescript/index.ts@@ -18,7 +18,6 @@ export type { FileChange } from "./FileChange";export type { ForcedLoginMethod } from "./ForcedLoginMethod";export type { FunctionCallOutputBody } from "./FunctionCallOutputBody";export type { FunctionCallOutputContentItem } from "./FunctionCallOutputContentItem";-export type { FunctionCallOutputPayload } from "./FunctionCallOutputPayload";export type { FuzzyFileSearchParams } from "./FuzzyFileSearchParams";export type { FuzzyFileSearchResponse } from "./FuzzyFileSearchResponse";export type { FuzzyFileSearchResult } from "./FuzzyFileSearchResult";diff --git a/codex-rs/app-server-protocol/src/export.rs b/codex-rs/app-server-protocol/src/export.rsindex c280bd2e2b..b89f23c666 100644--- a/codex-rs/app-server-protocol/src/export.rs+++ b/codex-rs/app-server-protocol/src/export.rs@@ -17,6 +17,7 @@ use crate::protocol::common::EXPERIMENTAL_CLIENT_METHODS;use anyhow::Context;use anyhow::Result;use anyhow::anyhow;+use codex_protocol::protocol::RolloutLine;use schemars::JsonSchema;use schemars::schema_for;use serde::Serialize;@@ -185,6 +186,12 @@ pub fn generate_json(out_dir: &Path) -> Result<()> {generate_json_with_experimental(out_dir, /*experimental_api*/ false)}+pub fn generate_internal_json_schema(out_dir: &Path) -> Result<()> {+ ensure_dir(out_dir)?;+ write_json_schema::<RolloutLine>(out_dir, "RolloutLine")?;+ Ok(())+}+pub fn generate_json_with_experimental(out_dir: &Path, experimental_api: bool) -> Result<()> {ensure_dir(out_dir)?;let envelope_emitters: Vec<JsonSchemaEmitter> = vec![diff --git a/codex-rs/app-server-protocol/src/lib.rs b/codex-rs/app-server-protocol/src/lib.rsindex 067dcb0369..3c5fa6dc2e 100644--- a/codex-rs/app-server-protocol/src/lib.rs+++ b/codex-rs/app-server-protocol/src/lib.rs@@ -6,6 +6,7 @@ mod schema_fixtures;pub use experimental_api::*;pub use export::GenerateTsOptions;+pub use export::generate_internal_json_schema;pub use export::generate_json;pub use export::generate_json_with_experimental;pub use export::generate_ts;diff --git a/codex-rs/cli/src/main.rs b/codex-rs/cli/src/main.rsindex 972c2854f8..05b568b7b7 100644--- a/codex-rs/cli/src/main.rs+++ b/codex-rs/cli/src/main.rs@@ -351,12 +351,17 @@ struct AppServerCommand {}#[derive(Debug, clap::Subcommand)]+#[allow(clippy::enum_variant_names)]enum AppServerSubcommand {/// [experimental] Generate TypeScript bindings for the app server protocol.GenerateTs(GenerateTsCommand),/// [experimental] Generate JSON Schema for the app server protocol.GenerateJsonSchema(GenerateJsonSchemaCommand),++ /// [internal] Generate internal JSON Schema artifacts for Codex tooling.+ #[clap(hide = true)]+ GenerateInternalJsonSchema(GenerateInternalJsonSchemaCommand),}#[derive(Debug, Args)]@@ -385,6 +390,13 @@ struct GenerateJsonSchemaCommand {experimental: bool,}+#[derive(Debug, Args)]+struct GenerateInternalJsonSchemaCommand {+ /// Output directory where internal JSON Schema artifacts will be written+ #[arg(short = 'o', long = "out", value_name = "DIR")]+ out_dir: PathBuf,+}+#[derive(Debug, Parser)]struct StdioToUdsCommand {/// Path to the Unix domain socket to connect to.@@ -665,6 +677,9 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {gen_cli.experimental,)?;}+ Some(AppServerSubcommand::GenerateInternalJsonSchema(gen_cli)) => {+ codex_app_server_protocol::generate_internal_json_schema(&gen_cli.out_dir)?;+ }},#[cfg(target_os = "macos")]Some(Subcommand::App(app_cli)) => {diff --git a/codex-rs/protocol/src/models.rs b/codex-rs/protocol/src/models.rsindex 700c1f80e0..1e5a7445e3 100644--- a/codex-rs/protocol/src/models.rs+++ b/codex-rs/protocol/src/models.rs@@ -231,6 +231,8 @@ pub enum ResponseInputItem {},FunctionCallOutput {call_id: String,+ #[ts(as = "FunctionCallOutputBody")]+ #[schemars(with = "FunctionCallOutputBody")]output: FunctionCallOutputPayload,},McpToolCallOutput {@@ -239,6 +241,8 @@ pub enum ResponseInputItem {},CustomToolCallOutput {call_id: String,+ #[ts(as = "FunctionCallOutputBody")]+ #[schemars(with = "FunctionCallOutputBody")]output: FunctionCallOutputPayload,},ToolSearchOutput {@@ -306,6 +310,7 @@ pub enum ResponseItem {Reasoning {#[serde(default, skip_serializing)]#[ts(skip)]+ #[schemars(skip)]id: String,summary: Vec<ReasoningItemReasoningSummary>,#[serde(default, skip_serializing_if = "should_serialize_reasoning_content")]@@ -356,6 +361,8 @@ pub enum ResponseItem {// We keep this behavior centralized in `FunctionCallOutputPayload`.FunctionCallOutput {call_id: String,+ #[ts(as = "FunctionCallOutputBody")]+ #[schemars(with = "FunctionCallOutputBody")]output: FunctionCallOutputPayload,},CustomToolCall {@@ -375,6 +382,8 @@ pub enum ResponseItem {// text or structured content items.CustomToolCallOutput {call_id: String,+ #[ts(as = "FunctionCallOutputBody")]+ #[schemars(with = "FunctionCallOutputBody")]output: FunctionCallOutputPayload,},ToolSearchOutput {