From bfeff620812f9f140533d8d5d2f4bd0081087e73 Mon Sep 17 00:00:00 2001 From: Roy Han Date: Tue, 5 May 2026 12:09:35 -0700 Subject: [PATCH] add image generation content model --- .../schema/json/ServerNotification.json | 113 ++++++++++++++++- .../codex_app_server_protocol.schemas.json | 120 +++++++++++++++++- .../codex_app_server_protocol.v2.schemas.json | 120 +++++++++++++++++- .../json/v2/ItemCompletedNotification.json | 113 ++++++++++++++++- .../json/v2/ItemStartedNotification.json | 113 ++++++++++++++++- .../schema/json/v2/ReviewStartResponse.json | 111 ++++++++++++++++ .../schema/json/v2/ThreadForkResponse.json | 111 ++++++++++++++++ .../schema/json/v2/ThreadListResponse.json | 111 ++++++++++++++++ .../json/v2/ThreadMetadataUpdateResponse.json | 111 ++++++++++++++++ .../schema/json/v2/ThreadReadResponse.json | 111 ++++++++++++++++ .../schema/json/v2/ThreadResumeResponse.json | 111 ++++++++++++++++ .../json/v2/ThreadRollbackResponse.json | 111 ++++++++++++++++ .../schema/json/v2/ThreadStartResponse.json | 111 ++++++++++++++++ .../json/v2/ThreadStartedNotification.json | 111 ++++++++++++++++ .../json/v2/ThreadUnarchiveResponse.json | 111 ++++++++++++++++ .../json/v2/TurnCompletedNotification.json | 111 ++++++++++++++++ .../schema/json/v2/TurnStartResponse.json | 111 ++++++++++++++++ .../json/v2/TurnStartedNotification.json | 111 ++++++++++++++++ .../typescript/v2/ImageGenerationContent.ts | 5 + .../schema/typescript/v2/ThreadItem.ts | 3 +- .../schema/typescript/v2/index.ts | 1 + .../src/protocol/thread_history.rs | 21 +++ .../app-server-protocol/src/protocol/v2.rs | 80 ++++++++++++ codex-rs/tui/src/chatwidget/tests/helpers.rs | 7 + 24 files changed, 2133 insertions(+), 6 deletions(-) create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/ImageGenerationContent.ts diff --git a/codex-rs/app-server-protocol/schema/json/ServerNotification.json b/codex-rs/app-server-protocol/schema/json/ServerNotification.json index 3a1a9744a5..e023e65766 100644 --- a/codex-rs/app-server-protocol/schema/json/ServerNotification.json +++ b/codex-rs/app-server-protocol/schema/json/ServerNotification.json @@ -1930,6 +1930,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "ItemCompletedNotification": { "properties": { "completedAtMs": { @@ -3783,6 +3879,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, @@ -6040,4 +6151,4 @@ } ], "title": "ServerNotification" -} +} \ No newline at end of file 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.json index 00278cccb6..b7c74ae108 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 @@ -10129,6 +10129,102 @@ ], "type": "string" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "InputModality": { "description": "Canonical user-input modality tags advertised by a model.", "oneOf": [ @@ -10282,6 +10378,13 @@ "title": "ItemStartedNotification", "type": "object" }, + "LargeContentMode": { + "enum": [ + "inline", + "deferred" + ], + "type": "string" + }, "ListMcpServerStatusParams": { "$schema": "http://json-schema.org/draft-07/schema#", "properties": { @@ -16121,6 +16224,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/v2/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, @@ -18431,4 +18549,4 @@ }, "title": "CodexAppServerProtocol", "type": "object" -} +} \ No newline at end of file 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.json index 597fde945e..6ee6fde946 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 @@ -6696,6 +6696,102 @@ ], "type": "string" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "InitializeCapabilities": { "description": "Client-declared capabilities negotiated during initialize.", "properties": { @@ -6893,6 +6989,13 @@ "title": "ItemStartedNotification", "type": "object" }, + "LargeContentMode": { + "enum": [ + "inline", + "deferred" + ], + "type": "string" + }, "ListMcpServerStatusParams": { "$schema": "http://json-schema.org/draft-07/schema#", "properties": { @@ -14007,6 +14110,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, @@ -16316,4 +16434,4 @@ }, "title": "CodexAppServerProtocolV2", "type": "object" -} +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ItemCompletedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/ItemCompletedNotification.json index 4ec0e10bc9..c8d79aa839 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ItemCompletedNotification.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ItemCompletedNotification.json @@ -285,6 +285,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1035,6 +1131,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, @@ -1393,4 +1504,4 @@ ], "title": "ItemCompletedNotification", "type": "object" -} +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ItemStartedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/ItemStartedNotification.json index 8684989356..5e0ce35bca 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ItemStartedNotification.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ItemStartedNotification.json @@ -285,6 +285,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1035,6 +1131,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, @@ -1393,4 +1504,4 @@ ], "title": "ItemStartedNotification", "type": "object" -} +} \ No newline at end of file diff --git a/codex-rs/app-server-protocol/schema/json/v2/ReviewStartResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ReviewStartResponse.json index 16abcd7806..9114b9ee83 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ReviewStartResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ReviewStartResponse.json @@ -422,6 +422,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1179,6 +1275,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json index 653c5f2387..490406608d 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json @@ -756,6 +756,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -2005,6 +2101,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadListResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadListResponse.json index 2f5cbb9500..0c0b71977a 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadListResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadListResponse.json @@ -448,6 +448,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1455,6 +1551,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadMetadataUpdateResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadMetadataUpdateResponse.json index b9ae59708a..906a9c7391 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadMetadataUpdateResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadMetadataUpdateResponse.json @@ -448,6 +448,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1455,6 +1551,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json index cda474c294..b99a71a44d 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadReadResponse.json @@ -448,6 +448,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1455,6 +1551,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json index 27cf47f2fc..1ad0a1618f 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json @@ -756,6 +756,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -2005,6 +2101,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadRollbackResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadRollbackResponse.json index e5339f4e99..27d4163f5f 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadRollbackResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadRollbackResponse.json @@ -448,6 +448,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1455,6 +1551,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json index 7d93606aa4..09b3225fd8 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json @@ -756,6 +756,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -2005,6 +2101,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartedNotification.json index 774686e46a..e3bd0752ea 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartedNotification.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartedNotification.json @@ -448,6 +448,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1455,6 +1551,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadUnarchiveResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadUnarchiveResponse.json index 64179af7e1..acff4d8ac7 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadUnarchiveResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadUnarchiveResponse.json @@ -448,6 +448,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1455,6 +1551,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/TurnCompletedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/TurnCompletedNotification.json index 0739fa31bc..db1464cfdd 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/TurnCompletedNotification.json +++ b/codex-rs/app-server-protocol/schema/json/v2/TurnCompletedNotification.json @@ -422,6 +422,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1179,6 +1275,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/TurnStartResponse.json b/codex-rs/app-server-protocol/schema/json/v2/TurnStartResponse.json index bc5917ef15..da2c5205c5 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/TurnStartResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/TurnStartResponse.json @@ -422,6 +422,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1179,6 +1275,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/json/v2/TurnStartedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/TurnStartedNotification.json index 22ad85d906..a82bfcc491 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/TurnStartedNotification.json +++ b/codex-rs/app-server-protocol/schema/json/v2/TurnStartedNotification.json @@ -422,6 +422,102 @@ ], "type": "object" }, + "ImageGenerationContent": { + "oneOf": [ + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "dataBase64": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "inline" + ], + "title": "InlineImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "dataBase64", + "mimeType", + "type" + ], + "title": "InlineImageGenerationContent", + "type": "object" + }, + { + "properties": { + "byteLength": { + "format": "uint64", + "minimum": 0.0, + "type": "integer" + }, + "contentId": { + "type": "string" + }, + "height": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + }, + "mimeType": { + "type": "string" + }, + "type": { + "enum": [ + "deferred" + ], + "title": "DeferredImageGenerationContentType", + "type": "string" + }, + "width": { + "format": "uint32", + "minimum": 0.0, + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "byteLength", + "contentId", + "mimeType", + "type" + ], + "title": "DeferredImageGenerationContent", + "type": "object" + } + ] + }, "McpToolCallError": { "properties": { "message": { @@ -1179,6 +1275,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ImageGenerationContent.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ImageGenerationContent.ts new file mode 100644 index 0000000000..435e711837 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ImageGenerationContent.ts @@ -0,0 +1,5 @@ +// 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. + +export type ImageGenerationContent = { "type": "inline", mimeType: string, dataBase64: string, byteLength: bigint, width: number | null, height: number | null, } | { "type": "deferred", contentId: string, mimeType: string, byteLength: bigint, width: number | null, height: number | null, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadItem.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadItem.ts index f7880c9d32..6f0ac9ed37 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadItem.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadItem.ts @@ -15,6 +15,7 @@ import type { DynamicToolCallOutputContentItem } from "./DynamicToolCallOutputCo import type { DynamicToolCallStatus } from "./DynamicToolCallStatus"; import type { FileUpdateChange } from "./FileUpdateChange"; import type { HookPromptFragment } from "./HookPromptFragment"; +import type { ImageGenerationContent } from "./ImageGenerationContent"; import type { McpToolCallError } from "./McpToolCallError"; import type { McpToolCallResult } from "./McpToolCallResult"; import type { McpToolCallStatus } from "./McpToolCallStatus"; @@ -98,4 +99,4 @@ reasoningEffort: ReasoningEffort | null, /** * Last known status of the target agents, when available. */ -agentsStates: { [key in string]?: CollabAgentState }, } | { "type": "webSearch", id: string, query: string, action: WebSearchAction | null, } | { "type": "imageView", id: string, path: AbsolutePathBuf, } | { "type": "imageGeneration", id: string, status: string, revisedPrompt: string | null, result: string, savedPath?: AbsolutePathBuf, } | { "type": "enteredReviewMode", id: string, review: string, } | { "type": "exitedReviewMode", id: string, review: string, } | { "type": "contextCompaction", id: string, }; +agentsStates: { [key in string]?: CollabAgentState }, } | { "type": "webSearch", id: string, query: string, action: WebSearchAction | null, } | { "type": "imageView", id: string, path: AbsolutePathBuf, } | { "type": "imageGeneration", id: string, status: string, revisedPrompt: string | null, content: ImageGenerationContent, result: string, savedPath?: AbsolutePathBuf, } | { "type": "enteredReviewMode", id: string, review: string, } | { "type": "exitedReviewMode", id: string, review: string, } | { "type": "contextCompaction", id: string, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts index 037534a22f..125c1d94e8 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts @@ -171,6 +171,7 @@ export type { HookStartedNotification } from "./HookStartedNotification"; export type { HooksListEntry } from "./HooksListEntry"; export type { HooksListParams } from "./HooksListParams"; export type { HooksListResponse } from "./HooksListResponse"; +export type { ImageGenerationContent } from "./ImageGenerationContent"; export type { ItemCompletedNotification } from "./ItemCompletedNotification"; export type { ItemGuardianApprovalReviewCompletedNotification } from "./ItemGuardianApprovalReviewCompletedNotification"; export type { ItemGuardianApprovalReviewStartedNotification } from "./ItemGuardianApprovalReviewStartedNotification"; diff --git a/codex-rs/app-server-protocol/src/protocol/thread_history.rs b/codex-rs/app-server-protocol/src/protocol/thread_history.rs index 6228d754d6..0924b959ea 100644 --- a/codex-rs/app-server-protocol/src/protocol/thread_history.rs +++ b/codex-rs/app-server-protocol/src/protocol/thread_history.rs @@ -585,6 +585,13 @@ impl ThreadHistoryBuilder { id: payload.call_id.clone(), status: String::new(), revised_prompt: None, + content: crate::protocol::v2::ImageGenerationContent::Inline { + mime_type: "image/png".to_string(), + data_base64: String::new(), + byte_length: 0, + width: None, + height: None, + }, result: String::new(), saved_path: None, }; @@ -596,6 +603,13 @@ impl ThreadHistoryBuilder { id: payload.call_id.clone(), status: payload.status.clone(), revised_prompt: payload.revised_prompt.clone(), + content: crate::protocol::v2::ImageGenerationContent::Inline { + mime_type: "image/png".to_string(), + data_base64: payload.result.clone(), + byte_length: crate::protocol::v2::image_generation_byte_length(&payload.result), + width: None, + height: None, + }, result: payload.result.clone(), saved_path: payload.saved_path.clone(), }; @@ -1465,6 +1479,13 @@ mod tests { id: "ig_123".into(), status: "completed".into(), revised_prompt: Some("final prompt".into()), + content: crate::protocol::v2::ImageGenerationContent::Inline { + mime_type: "image/png".into(), + data_base64: "Zm9v".into(), + byte_length: 3, + width: None, + height: None, + }, result: "Zm9v".into(), saved_path: Some(test_path_buf("/tmp/ig_123.png").abs()), }, diff --git a/codex-rs/app-server-protocol/src/protocol/v2.rs b/codex-rs/app-server-protocol/src/protocol/v2.rs index 7ab25a943f..e098bce541 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2.rs @@ -6215,6 +6215,8 @@ pub enum ThreadItem { id: String, status: String, revised_prompt: Option, + #[serde(default)] + content: ImageGenerationContent, result: String, #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -6231,6 +6233,52 @@ pub enum ThreadItem { ContextCompaction { id: String }, } +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] +#[serde(tag = "type", rename_all = "camelCase")] +#[ts(tag = "type", export_to = "v2/")] +pub enum ImageGenerationContent { + #[serde(rename_all = "camelCase")] + #[ts(rename_all = "camelCase")] + Inline { + mime_type: String, + data_base64: String, + byte_length: u64, + width: Option, + height: Option, + }, + #[serde(rename_all = "camelCase")] + #[ts(rename_all = "camelCase")] + Deferred { + content_id: String, + mime_type: String, + byte_length: u64, + width: Option, + height: Option, + }, +} + +impl Default for ImageGenerationContent { + fn default() -> Self { + Self::Inline { + mime_type: "image/png".to_string(), + data_base64: String::new(), + byte_length: 0, + width: None, + height: None, + } + } +} + +pub(crate) fn image_generation_byte_length(data_base64: &str) -> u64 { + let padding_len = data_base64 + .as_bytes() + .iter() + .rev() + .take_while(|byte| **byte == b'=') + .count(); + ((data_base64.len() / 4) * 3).saturating_sub(padding_len) as u64 +} + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(rename_all = "camelCase", export_to = "v2/")] @@ -6692,6 +6740,13 @@ impl From for ThreadItem { id: image.id, status: image.status, revised_prompt: image.revised_prompt, + content: ImageGenerationContent::Inline { + mime_type: "image/png".to_string(), + data_base64: image.result.clone(), + byte_length: image_generation_byte_length(&image.result), + width: None, + height: None, + }, result: image.result, saved_path: image.saved_path, }, @@ -11883,4 +11938,29 @@ mod tests { "unexpected error: {err}" ); } + + #[test] + fn image_generation_defaults_missing_content_for_legacy_payloads() { + let item: ThreadItem = serde_json::from_value(json!({ + "type": "imageGeneration", + "id": "ig_123", + "status": "completed", + "revisedPrompt": null, + "result": "Zm9v", + "savedPath": null + })) + .expect("legacy image generation item should deserialize"); + + assert_eq!( + item, + ThreadItem::ImageGeneration { + id: "ig_123".to_string(), + status: "completed".to_string(), + revised_prompt: None, + content: ImageGenerationContent::default(), + result: "Zm9v".to_string(), + saved_path: None, + } + ); + } } diff --git a/codex-rs/tui/src/chatwidget/tests/helpers.rs b/codex-rs/tui/src/chatwidget/tests/helpers.rs index 8f3d37e76c..cb21fef303 100644 --- a/codex-rs/tui/src/chatwidget/tests/helpers.rs +++ b/codex-rs/tui/src/chatwidget/tests/helpers.rs @@ -831,6 +831,13 @@ pub(super) fn handle_image_generation_end( id: call_id.into(), status: "completed".to_string(), revised_prompt, + content: codex_app_server_protocol::ImageGenerationContent::Inline { + mime_type: "image/png".to_string(), + data_base64: String::new(), + byte_length: 0, + width: None, + height: None, + }, result: String::new(), saved_path, },