diff --git a/codex-rs/app-server-protocol/schema/json/ServerNotification.json b/codex-rs/app-server-protocol/schema/json/ServerNotification.json index 046bab211c..17c5839aeb 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" }, @@ -6074,4 +6185,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 dafa256aec..cc5de319e9 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 @@ -10169,6 +10169,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": [ @@ -10322,6 +10418,13 @@ "title": "ItemStartedNotification", "type": "object" }, + "LargeContentMode": { + "enum": [ + "inline", + "deferred" + ], + "type": "string" + }, "ListMcpServerStatusParams": { "$schema": "http://json-schema.org/draft-07/schema#", "properties": { @@ -16188,6 +16291,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/v2/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, @@ -18553,4 +18671,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 f028f9b3ea..0a17c939c8 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 @@ -6736,6 +6736,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": { @@ -6933,6 +7029,13 @@ "title": "ItemStartedNotification", "type": "object" }, + "LargeContentMode": { + "enum": [ + "inline", + "deferred" + ], + "type": "string" + }, "ListMcpServerStatusParams": { "$schema": "http://json-schema.org/draft-07/schema#", "properties": { @@ -14074,6 +14177,21 @@ }, { "properties": { + "content": { + "allOf": [ + { + "$ref": "#/definitions/ImageGenerationContent" + } + ], + "default": { + "byteLength": 0, + "dataBase64": "", + "height": null, + "mimeType": "image/png", + "type": "inline", + "width": null + } + }, "id": { "type": "string" }, @@ -16438,4 +16556,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 9afd1ae514..83546c1999 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 00689feda0..a617ddd123 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 4db2ae4642..c452ba1e80 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 003c75e597..febb6650e2 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 50147feca1..99a098dc81 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 ff774402b9..d6db04702c 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 75b08d53d6..e3b892f16d 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 a0f39a29f6..67ef30e9c8 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 ff7c4a5320..bbb7584944 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 1b5aa29683..722f939359 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 e5e2558e9c..9e283a3ed4 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 a2eff7fdd8..a1c94bd3a1 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 0952db2aca..f3337b98fb 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 547f0f1018..129ab6d745 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts @@ -172,6 +172,7 @@ export type { HookTrustStatus } from "./HookTrustStatus"; 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 1f45180c9e..47e541cf16 100644 --- a/codex-rs/app-server-protocol/src/protocol/thread_history.rs +++ b/codex-rs/app-server-protocol/src/protocol/thread_history.rs @@ -586,6 +586,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, }; @@ -597,6 +604,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(), }; @@ -1469,6 +1483,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 3328cd2516..6dd4eaa370 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2.rs @@ -6250,6 +6250,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)] @@ -6266,6 +6268,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/")] @@ -6727,6 +6775,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, }, @@ -11950,4 +12005,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 3f7c9bd5b2..d60473b242 100644 --- a/codex-rs/tui/src/chatwidget/tests/helpers.rs +++ b/codex-rs/tui/src/chatwidget/tests/helpers.rs @@ -832,6 +832,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, },