diff --git a/codex-rs/app-server-protocol/schema/json/EventMsg.json b/codex-rs/app-server-protocol/schema/json/EventMsg.json index 3e73bdc8b6..b6557b4361 100644 --- a/codex-rs/app-server-protocol/schema/json/EventMsg.json +++ b/codex-rs/app-server-protocol/schema/json/EventMsg.json @@ -93,6 +93,34 @@ } ] }, + "Annotations": { + "description": "Optional annotations for the client. The client can use annotations to inform how objects are used or displayed", + "properties": { + "audience": { + "items": { + "$ref": "#/definitions/Role" + }, + "type": [ + "array", + "null" + ] + }, + "lastModified": { + "type": [ + "string", + "null" + ] + }, + "priority": { + "format": "double", + "type": [ + "number", + "null" + ] + } + }, + "type": "object" + }, "AskForApproval": { "description": "Determines the conditions under which the user is consulted to approve running the command proposed by Codex.", "oneOf": [ @@ -126,6 +154,57 @@ } ] }, + "AudioContent": { + "description": "Audio provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "data": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, + "BlobResourceContents": { + "properties": { + "blob": { + "type": "string" + }, + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "uri": { + "type": "string" + } + }, + "required": [ + "blob", + "uri" + ], + "type": "object" + }, "ByteRange": { "properties": { "end": { @@ -150,9 +229,10 @@ "CallToolResult": { "description": "The server's response to a tool call.", "properties": { - "_meta": true, "content": { - "items": true, + "items": { + "$ref": "#/definitions/ContentBlock" + }, "type": "array" }, "isError": { @@ -310,6 +390,41 @@ } ] }, + "CollaborationMode": { + "description": "Collaboration mode for a Codex session.", + "properties": { + "mode": { + "$ref": "#/definitions/ModeKind" + }, + "settings": { + "$ref": "#/definitions/Settings" + } + }, + "required": [ + "mode", + "settings" + ], + "type": "object" + }, + "ContentBlock": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + }, + { + "$ref": "#/definitions/ResourceLink" + }, + { + "$ref": "#/definitions/EmbeddedResource" + } + ] + }, "ContentItem": { "oneOf": [ { @@ -445,6 +560,42 @@ ], "type": "object" }, + "EmbeddedResource": { + "description": "The contents of a resource, embedded into a prompt or tool call result.\n\nIt is up to the client how best to render embedded resources for the benefit of the LLM and/or the user.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "resource": { + "$ref": "#/definitions/EmbeddedResourceResource" + }, + "type": { + "type": "string" + } + }, + "required": [ + "resource", + "type" + ], + "type": "object" + }, + "EmbeddedResourceResource": { + "anyOf": [ + { + "$ref": "#/definitions/TextResourceContents" + }, + { + "$ref": "#/definitions/BlobResourceContents" + } + ] + }, "EventMsg": { "description": "Response event from the agent NOTE: Make sure none of these values have optional types, as it will mess up the extension code-gen.", "oneOf": [ @@ -521,6 +672,17 @@ { "description": "Conversation history was rolled back by dropping the last N user turns.", "properties": { + "model_visible_state": { + "anyOf": [ + { + "$ref": "#/definitions/ModelVisibleState" + }, + { + "type": "null" + } + ], + "description": "Model-visible session state after rollback.\n\nThis lets clients synchronize UI mode/model indicators with core after history rewind. Optional for backward compatibility with older persisted events." + }, "num_turns": { "description": "Number of user turns that were removed from context.", "format": "uint32", @@ -2936,6 +3098,36 @@ ], "type": "object" }, + "ImageContent": { + "description": "An image provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "data": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, "LocalShellAction": { "oneOf": [ { @@ -3129,6 +3321,21 @@ ], "type": "string" }, + "ModelVisibleState": { + "properties": { + "collaboration_mode": { + "anyOf": [ + { + "$ref": "#/definitions/CollaborationMode" + }, + { + "type": "null" + } + ] + } + }, + "type": "object" + }, "NetworkAccess": { "description": "Represents whether outbound network access is available to the agent.", "enum": [ @@ -3441,8 +3648,7 @@ "format": "int64", "type": "integer" } - ], - "description": "ID of a request, which can be either a string or an integer." + ] }, "RequestUserInputQuestion": { "properties": { @@ -3498,21 +3704,22 @@ "Resource": { "description": "A known resource that the server is capable of reading.", "properties": { - "_meta": true, - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", "null" ] }, - "icons": { - "items": true, - "type": [ - "array", - "null" - ] - }, "mimeType": { "type": [ "string", @@ -3545,10 +3752,74 @@ ], "type": "object" }, + "ResourceLink": { + "description": "A resource that the server is capable of reading, included in a prompt or tool call result.\n\nNote: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": "string" + }, + "size": { + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + }, + "type": { + "type": "string" + }, + "uri": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "uri" + ], + "type": "object" + }, "ResourceTemplate": { "description": "A template description for resources available on the server.", "properties": { - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", @@ -4149,6 +4420,14 @@ } ] }, + "Role": { + "description": "The sender or recipient of messages and data in a conversation.", + "enum": [ + "assistant", + "user" + ], + "type": "string" + }, "SandboxPolicy": { "description": "Determines execution restrictions for model shell commands.", "oneOf": [ @@ -4253,6 +4532,34 @@ } ] }, + "Settings": { + "description": "Settings for a collaboration mode.", + "properties": { + "developer_instructions": { + "type": [ + "string", + "null" + ] + }, + "model": { + "type": "string" + }, + "reasoning_effort": { + "anyOf": [ + { + "$ref": "#/definitions/ReasoningEffort" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "model" + ], + "type": "object" + }, "SkillDependencies": { "properties": { "tools": { @@ -4458,6 +4765,32 @@ ], "type": "string" }, + "TextContent": { + "description": "Text provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "text": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "text", + "type" + ], + "type": "object" + }, "TextElement": { "properties": { "byte_range": { @@ -4481,6 +4814,27 @@ ], "type": "object" }, + "TextResourceContents": { + "properties": { + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "text": { + "type": "string" + }, + "uri": { + "type": "string" + } + }, + "required": [ + "text", + "uri" + ], + "type": "object" + }, "ThreadId": { "type": "string" }, @@ -4541,26 +4895,38 @@ "Tool": { "description": "Definition for a tool the client can call.", "properties": { - "_meta": true, - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/ToolAnnotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", "null" ] }, - "icons": { - "items": true, - "type": [ - "array", - "null" - ] + "inputSchema": { + "$ref": "#/definitions/ToolInputSchema" }, - "inputSchema": true, "name": { "type": "string" }, - "outputSchema": true, + "outputSchema": { + "anyOf": [ + { + "$ref": "#/definitions/ToolOutputSchema" + }, + { + "type": "null" + } + ] + }, "title": { "type": [ "string", @@ -4574,6 +4940,82 @@ ], "type": "object" }, + "ToolAnnotations": { + "description": "Additional properties describing a Tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**. They are not guaranteed to provide a faithful description of tool behavior (including descriptive properties like `title`).\n\nClients should never make tool use decisions based on ToolAnnotations received from untrusted servers.", + "properties": { + "destructiveHint": { + "type": [ + "boolean", + "null" + ] + }, + "idempotentHint": { + "type": [ + "boolean", + "null" + ] + }, + "openWorldHint": { + "type": [ + "boolean", + "null" + ] + }, + "readOnlyHint": { + "type": [ + "boolean", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "ToolInputSchema": { + "description": "A JSON Schema object defining the expected parameters for the tool.", + "properties": { + "properties": true, + "required": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "type": { + "default": "object", + "type": "string" + } + }, + "type": "object" + }, + "ToolOutputSchema": { + "description": "An optional JSON Schema object defining the structure of the tool's output returned in the structuredContent field of a CallToolResult.", + "properties": { + "properties": true, + "required": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "type": { + "default": "object", + "type": "string" + } + }, + "type": "object" + }, "TurnAbortReason": { "enum": [ "interrupted", @@ -5048,6 +5490,17 @@ { "description": "Conversation history was rolled back by dropping the last N user turns.", "properties": { + "model_visible_state": { + "anyOf": [ + { + "$ref": "#/definitions/ModelVisibleState" + }, + { + "type": "null" + } + ], + "description": "Model-visible session state after rollback.\n\nThis lets clients synchronize UI mode/model indicators with core after history rewind. Optional for backward compatibility with older persisted events." + }, "num_turns": { "description": "Number of user turns that were removed from context.", "format": "uint32", diff --git a/codex-rs/app-server-protocol/schema/json/ServerNotification.json b/codex-rs/app-server-protocol/schema/json/ServerNotification.json index 5d9e719d8f..a74ae5b99d 100644 --- a/codex-rs/app-server-protocol/schema/json/ServerNotification.json +++ b/codex-rs/app-server-protocol/schema/json/ServerNotification.json @@ -630,6 +630,22 @@ ], "type": "string" }, + "CollaborationMode": { + "description": "Collaboration mode for a Codex session.", + "properties": { + "mode": { + "$ref": "#/definitions/ModeKind" + }, + "settings": { + "$ref": "#/definitions/Settings" + } + }, + "required": [ + "mode", + "settings" + ], + "type": "object" + }, "CommandAction": { "oneOf": [ { @@ -1099,6 +1115,17 @@ { "description": "Conversation history was rolled back by dropping the last N user turns.", "properties": { + "model_visible_state": { + "anyOf": [ + { + "$ref": "#/definitions/ModelVisibleState" + }, + { + "type": "null" + } + ], + "description": "Model-visible session state after rollback.\n\nThis lets clients synchronize UI mode/model indicators with core after history rewind. Optional for backward compatibility with older persisted events." + }, "num_turns": { "description": "Number of user turns that were removed from context.", "format": "uint32", @@ -3908,6 +3935,21 @@ ], "type": "string" }, + "ModelVisibleState": { + "properties": { + "collaboration_mode": { + "anyOf": [ + { + "$ref": "#/definitions/CollaborationMode" + }, + { + "type": "null" + } + ] + } + }, + "type": "object" + }, "NetworkAccess": { "description": "Represents whether outbound network access is available to the agent.", "enum": [ @@ -5370,6 +5412,34 @@ } ] }, + "Settings": { + "description": "Settings for a collaboration mode.", + "properties": { + "developer_instructions": { + "type": [ + "string", + "null" + ] + }, + "model": { + "type": "string" + }, + "reasoning_effort": { + "anyOf": [ + { + "$ref": "#/definitions/ReasoningEffort" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "model" + ], + "type": "object" + }, "SkillDependencies": { "properties": { "tools": { 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 5a5ddd1011..a159933ff2 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 @@ -1893,6 +1893,22 @@ } ] }, + "CollaborationMode": { + "description": "Collaboration mode for a Codex session.", + "properties": { + "mode": { + "$ref": "#/definitions/ModeKind" + }, + "settings": { + "$ref": "#/definitions/Settings" + } + }, + "required": [ + "mode", + "settings" + ], + "type": "object" + }, "CommandExecutionApprovalDecision": { "oneOf": [ { @@ -2361,6 +2377,17 @@ { "description": "Conversation history was rolled back by dropping the last N user turns.", "properties": { + "model_visible_state": { + "anyOf": [ + { + "$ref": "#/definitions/ModelVisibleState" + }, + { + "type": "null" + } + ], + "description": "Model-visible session state after rollback.\n\nThis lets clients synchronize UI mode/model indicators with core after history rewind. Optional for backward compatibility with older persisted events." + }, "num_turns": { "description": "Number of user turns that were removed from context.", "format": "uint32", @@ -5857,6 +5884,21 @@ ], "type": "string" }, + "ModelVisibleState": { + "properties": { + "collaboration_mode": { + "anyOf": [ + { + "$ref": "#/definitions/CollaborationMode" + }, + { + "type": "null" + } + ] + } + }, + "type": "object" + }, "NetworkAccess": { "description": "Represents whether outbound network access is available to the agent.", "enum": [ @@ -8366,6 +8408,34 @@ "title": "SetDefaultModelResponse", "type": "object" }, + "Settings": { + "description": "Settings for a collaboration mode.", + "properties": { + "developer_instructions": { + "type": [ + "string", + "null" + ] + }, + "model": { + "type": "string" + }, + "reasoning_effort": { + "anyOf": [ + { + "$ref": "#/definitions/ReasoningEffort" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "model" + ], + "type": "object" + }, "SkillDependencies": { "properties": { "tools": { diff --git a/codex-rs/app-server-protocol/schema/json/v1/ForkConversationResponse.json b/codex-rs/app-server-protocol/schema/json/v1/ForkConversationResponse.json index ad251a461f..514d8ef163 100644 --- a/codex-rs/app-server-protocol/schema/json/v1/ForkConversationResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v1/ForkConversationResponse.json @@ -93,6 +93,34 @@ } ] }, + "Annotations": { + "description": "Optional annotations for the client. The client can use annotations to inform how objects are used or displayed", + "properties": { + "audience": { + "items": { + "$ref": "#/definitions/Role" + }, + "type": [ + "array", + "null" + ] + }, + "lastModified": { + "type": [ + "string", + "null" + ] + }, + "priority": { + "format": "double", + "type": [ + "number", + "null" + ] + } + }, + "type": "object" + }, "AskForApproval": { "description": "Determines the conditions under which the user is consulted to approve running the command proposed by Codex.", "oneOf": [ @@ -126,6 +154,57 @@ } ] }, + "AudioContent": { + "description": "Audio provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "data": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, + "BlobResourceContents": { + "properties": { + "blob": { + "type": "string" + }, + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "uri": { + "type": "string" + } + }, + "required": [ + "blob", + "uri" + ], + "type": "object" + }, "ByteRange": { "properties": { "end": { @@ -150,9 +229,10 @@ "CallToolResult": { "description": "The server's response to a tool call.", "properties": { - "_meta": true, "content": { - "items": true, + "items": { + "$ref": "#/definitions/ContentBlock" + }, "type": "array" }, "isError": { @@ -310,6 +390,41 @@ } ] }, + "CollaborationMode": { + "description": "Collaboration mode for a Codex session.", + "properties": { + "mode": { + "$ref": "#/definitions/ModeKind" + }, + "settings": { + "$ref": "#/definitions/Settings" + } + }, + "required": [ + "mode", + "settings" + ], + "type": "object" + }, + "ContentBlock": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + }, + { + "$ref": "#/definitions/ResourceLink" + }, + { + "$ref": "#/definitions/EmbeddedResource" + } + ] + }, "ContentItem": { "oneOf": [ { @@ -445,6 +560,42 @@ ], "type": "object" }, + "EmbeddedResource": { + "description": "The contents of a resource, embedded into a prompt or tool call result.\n\nIt is up to the client how best to render embedded resources for the benefit of the LLM and/or the user.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "resource": { + "$ref": "#/definitions/EmbeddedResourceResource" + }, + "type": { + "type": "string" + } + }, + "required": [ + "resource", + "type" + ], + "type": "object" + }, + "EmbeddedResourceResource": { + "anyOf": [ + { + "$ref": "#/definitions/TextResourceContents" + }, + { + "$ref": "#/definitions/BlobResourceContents" + } + ] + }, "EventMsg": { "description": "Response event from the agent NOTE: Make sure none of these values have optional types, as it will mess up the extension code-gen.", "oneOf": [ @@ -521,6 +672,17 @@ { "description": "Conversation history was rolled back by dropping the last N user turns.", "properties": { + "model_visible_state": { + "anyOf": [ + { + "$ref": "#/definitions/ModelVisibleState" + }, + { + "type": "null" + } + ], + "description": "Model-visible session state after rollback.\n\nThis lets clients synchronize UI mode/model indicators with core after history rewind. Optional for backward compatibility with older persisted events." + }, "num_turns": { "description": "Number of user turns that were removed from context.", "format": "uint32", @@ -2936,6 +3098,36 @@ ], "type": "object" }, + "ImageContent": { + "description": "An image provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "data": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, "LocalShellAction": { "oneOf": [ { @@ -3129,6 +3321,21 @@ ], "type": "string" }, + "ModelVisibleState": { + "properties": { + "collaboration_mode": { + "anyOf": [ + { + "$ref": "#/definitions/CollaborationMode" + }, + { + "type": "null" + } + ] + } + }, + "type": "object" + }, "NetworkAccess": { "description": "Represents whether outbound network access is available to the agent.", "enum": [ @@ -3441,8 +3648,7 @@ "format": "int64", "type": "integer" } - ], - "description": "ID of a request, which can be either a string or an integer." + ] }, "RequestUserInputQuestion": { "properties": { @@ -3498,21 +3704,22 @@ "Resource": { "description": "A known resource that the server is capable of reading.", "properties": { - "_meta": true, - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", "null" ] }, - "icons": { - "items": true, - "type": [ - "array", - "null" - ] - }, "mimeType": { "type": [ "string", @@ -3545,10 +3752,74 @@ ], "type": "object" }, + "ResourceLink": { + "description": "A resource that the server is capable of reading, included in a prompt or tool call result.\n\nNote: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": "string" + }, + "size": { + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + }, + "type": { + "type": "string" + }, + "uri": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "uri" + ], + "type": "object" + }, "ResourceTemplate": { "description": "A template description for resources available on the server.", "properties": { - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", @@ -4149,6 +4420,14 @@ } ] }, + "Role": { + "description": "The sender or recipient of messages and data in a conversation.", + "enum": [ + "assistant", + "user" + ], + "type": "string" + }, "SandboxPolicy": { "description": "Determines execution restrictions for model shell commands.", "oneOf": [ @@ -4253,6 +4532,34 @@ } ] }, + "Settings": { + "description": "Settings for a collaboration mode.", + "properties": { + "developer_instructions": { + "type": [ + "string", + "null" + ] + }, + "model": { + "type": "string" + }, + "reasoning_effort": { + "anyOf": [ + { + "$ref": "#/definitions/ReasoningEffort" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "model" + ], + "type": "object" + }, "SkillDependencies": { "properties": { "tools": { @@ -4458,6 +4765,32 @@ ], "type": "string" }, + "TextContent": { + "description": "Text provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "text": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "text", + "type" + ], + "type": "object" + }, "TextElement": { "properties": { "byte_range": { @@ -4481,6 +4814,27 @@ ], "type": "object" }, + "TextResourceContents": { + "properties": { + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "text": { + "type": "string" + }, + "uri": { + "type": "string" + } + }, + "required": [ + "text", + "uri" + ], + "type": "object" + }, "ThreadId": { "type": "string" }, @@ -4541,26 +4895,38 @@ "Tool": { "description": "Definition for a tool the client can call.", "properties": { - "_meta": true, - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/ToolAnnotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", "null" ] }, - "icons": { - "items": true, - "type": [ - "array", - "null" - ] + "inputSchema": { + "$ref": "#/definitions/ToolInputSchema" }, - "inputSchema": true, "name": { "type": "string" }, - "outputSchema": true, + "outputSchema": { + "anyOf": [ + { + "$ref": "#/definitions/ToolOutputSchema" + }, + { + "type": "null" + } + ] + }, "title": { "type": [ "string", @@ -4574,6 +4940,82 @@ ], "type": "object" }, + "ToolAnnotations": { + "description": "Additional properties describing a Tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**. They are not guaranteed to provide a faithful description of tool behavior (including descriptive properties like `title`).\n\nClients should never make tool use decisions based on ToolAnnotations received from untrusted servers.", + "properties": { + "destructiveHint": { + "type": [ + "boolean", + "null" + ] + }, + "idempotentHint": { + "type": [ + "boolean", + "null" + ] + }, + "openWorldHint": { + "type": [ + "boolean", + "null" + ] + }, + "readOnlyHint": { + "type": [ + "boolean", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "ToolInputSchema": { + "description": "A JSON Schema object defining the expected parameters for the tool.", + "properties": { + "properties": true, + "required": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "type": { + "default": "object", + "type": "string" + } + }, + "type": "object" + }, + "ToolOutputSchema": { + "description": "An optional JSON Schema object defining the structure of the tool's output returned in the structuredContent field of a CallToolResult.", + "properties": { + "properties": true, + "required": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "type": { + "default": "object", + "type": "string" + } + }, + "type": "object" + }, "TurnAbortReason": { "enum": [ "interrupted", diff --git a/codex-rs/app-server-protocol/schema/json/v1/ResumeConversationResponse.json b/codex-rs/app-server-protocol/schema/json/v1/ResumeConversationResponse.json index abd5beb211..205339baa0 100644 --- a/codex-rs/app-server-protocol/schema/json/v1/ResumeConversationResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v1/ResumeConversationResponse.json @@ -93,6 +93,34 @@ } ] }, + "Annotations": { + "description": "Optional annotations for the client. The client can use annotations to inform how objects are used or displayed", + "properties": { + "audience": { + "items": { + "$ref": "#/definitions/Role" + }, + "type": [ + "array", + "null" + ] + }, + "lastModified": { + "type": [ + "string", + "null" + ] + }, + "priority": { + "format": "double", + "type": [ + "number", + "null" + ] + } + }, + "type": "object" + }, "AskForApproval": { "description": "Determines the conditions under which the user is consulted to approve running the command proposed by Codex.", "oneOf": [ @@ -126,6 +154,57 @@ } ] }, + "AudioContent": { + "description": "Audio provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "data": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, + "BlobResourceContents": { + "properties": { + "blob": { + "type": "string" + }, + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "uri": { + "type": "string" + } + }, + "required": [ + "blob", + "uri" + ], + "type": "object" + }, "ByteRange": { "properties": { "end": { @@ -150,9 +229,10 @@ "CallToolResult": { "description": "The server's response to a tool call.", "properties": { - "_meta": true, "content": { - "items": true, + "items": { + "$ref": "#/definitions/ContentBlock" + }, "type": "array" }, "isError": { @@ -310,6 +390,41 @@ } ] }, + "CollaborationMode": { + "description": "Collaboration mode for a Codex session.", + "properties": { + "mode": { + "$ref": "#/definitions/ModeKind" + }, + "settings": { + "$ref": "#/definitions/Settings" + } + }, + "required": [ + "mode", + "settings" + ], + "type": "object" + }, + "ContentBlock": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + }, + { + "$ref": "#/definitions/ResourceLink" + }, + { + "$ref": "#/definitions/EmbeddedResource" + } + ] + }, "ContentItem": { "oneOf": [ { @@ -445,6 +560,42 @@ ], "type": "object" }, + "EmbeddedResource": { + "description": "The contents of a resource, embedded into a prompt or tool call result.\n\nIt is up to the client how best to render embedded resources for the benefit of the LLM and/or the user.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "resource": { + "$ref": "#/definitions/EmbeddedResourceResource" + }, + "type": { + "type": "string" + } + }, + "required": [ + "resource", + "type" + ], + "type": "object" + }, + "EmbeddedResourceResource": { + "anyOf": [ + { + "$ref": "#/definitions/TextResourceContents" + }, + { + "$ref": "#/definitions/BlobResourceContents" + } + ] + }, "EventMsg": { "description": "Response event from the agent NOTE: Make sure none of these values have optional types, as it will mess up the extension code-gen.", "oneOf": [ @@ -521,6 +672,17 @@ { "description": "Conversation history was rolled back by dropping the last N user turns.", "properties": { + "model_visible_state": { + "anyOf": [ + { + "$ref": "#/definitions/ModelVisibleState" + }, + { + "type": "null" + } + ], + "description": "Model-visible session state after rollback.\n\nThis lets clients synchronize UI mode/model indicators with core after history rewind. Optional for backward compatibility with older persisted events." + }, "num_turns": { "description": "Number of user turns that were removed from context.", "format": "uint32", @@ -2936,6 +3098,36 @@ ], "type": "object" }, + "ImageContent": { + "description": "An image provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "data": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, "LocalShellAction": { "oneOf": [ { @@ -3129,6 +3321,21 @@ ], "type": "string" }, + "ModelVisibleState": { + "properties": { + "collaboration_mode": { + "anyOf": [ + { + "$ref": "#/definitions/CollaborationMode" + }, + { + "type": "null" + } + ] + } + }, + "type": "object" + }, "NetworkAccess": { "description": "Represents whether outbound network access is available to the agent.", "enum": [ @@ -3441,8 +3648,7 @@ "format": "int64", "type": "integer" } - ], - "description": "ID of a request, which can be either a string or an integer." + ] }, "RequestUserInputQuestion": { "properties": { @@ -3498,21 +3704,22 @@ "Resource": { "description": "A known resource that the server is capable of reading.", "properties": { - "_meta": true, - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", "null" ] }, - "icons": { - "items": true, - "type": [ - "array", - "null" - ] - }, "mimeType": { "type": [ "string", @@ -3545,10 +3752,74 @@ ], "type": "object" }, + "ResourceLink": { + "description": "A resource that the server is capable of reading, included in a prompt or tool call result.\n\nNote: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": "string" + }, + "size": { + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + }, + "type": { + "type": "string" + }, + "uri": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "uri" + ], + "type": "object" + }, "ResourceTemplate": { "description": "A template description for resources available on the server.", "properties": { - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", @@ -4149,6 +4420,14 @@ } ] }, + "Role": { + "description": "The sender or recipient of messages and data in a conversation.", + "enum": [ + "assistant", + "user" + ], + "type": "string" + }, "SandboxPolicy": { "description": "Determines execution restrictions for model shell commands.", "oneOf": [ @@ -4253,6 +4532,34 @@ } ] }, + "Settings": { + "description": "Settings for a collaboration mode.", + "properties": { + "developer_instructions": { + "type": [ + "string", + "null" + ] + }, + "model": { + "type": "string" + }, + "reasoning_effort": { + "anyOf": [ + { + "$ref": "#/definitions/ReasoningEffort" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "model" + ], + "type": "object" + }, "SkillDependencies": { "properties": { "tools": { @@ -4458,6 +4765,32 @@ ], "type": "string" }, + "TextContent": { + "description": "Text provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "text": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "text", + "type" + ], + "type": "object" + }, "TextElement": { "properties": { "byte_range": { @@ -4481,6 +4814,27 @@ ], "type": "object" }, + "TextResourceContents": { + "properties": { + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "text": { + "type": "string" + }, + "uri": { + "type": "string" + } + }, + "required": [ + "text", + "uri" + ], + "type": "object" + }, "ThreadId": { "type": "string" }, @@ -4541,26 +4895,38 @@ "Tool": { "description": "Definition for a tool the client can call.", "properties": { - "_meta": true, - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/ToolAnnotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", "null" ] }, - "icons": { - "items": true, - "type": [ - "array", - "null" - ] + "inputSchema": { + "$ref": "#/definitions/ToolInputSchema" }, - "inputSchema": true, "name": { "type": "string" }, - "outputSchema": true, + "outputSchema": { + "anyOf": [ + { + "$ref": "#/definitions/ToolOutputSchema" + }, + { + "type": "null" + } + ] + }, "title": { "type": [ "string", @@ -4574,6 +4940,82 @@ ], "type": "object" }, + "ToolAnnotations": { + "description": "Additional properties describing a Tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**. They are not guaranteed to provide a faithful description of tool behavior (including descriptive properties like `title`).\n\nClients should never make tool use decisions based on ToolAnnotations received from untrusted servers.", + "properties": { + "destructiveHint": { + "type": [ + "boolean", + "null" + ] + }, + "idempotentHint": { + "type": [ + "boolean", + "null" + ] + }, + "openWorldHint": { + "type": [ + "boolean", + "null" + ] + }, + "readOnlyHint": { + "type": [ + "boolean", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "ToolInputSchema": { + "description": "A JSON Schema object defining the expected parameters for the tool.", + "properties": { + "properties": true, + "required": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "type": { + "default": "object", + "type": "string" + } + }, + "type": "object" + }, + "ToolOutputSchema": { + "description": "An optional JSON Schema object defining the structure of the tool's output returned in the structuredContent field of a CallToolResult.", + "properties": { + "properties": true, + "required": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "type": { + "default": "object", + "type": "string" + } + }, + "type": "object" + }, "TurnAbortReason": { "enum": [ "interrupted", diff --git a/codex-rs/app-server-protocol/schema/json/v1/SessionConfiguredNotification.json b/codex-rs/app-server-protocol/schema/json/v1/SessionConfiguredNotification.json index 69c2c4b8b0..6d368fa4cc 100644 --- a/codex-rs/app-server-protocol/schema/json/v1/SessionConfiguredNotification.json +++ b/codex-rs/app-server-protocol/schema/json/v1/SessionConfiguredNotification.json @@ -93,6 +93,34 @@ } ] }, + "Annotations": { + "description": "Optional annotations for the client. The client can use annotations to inform how objects are used or displayed", + "properties": { + "audience": { + "items": { + "$ref": "#/definitions/Role" + }, + "type": [ + "array", + "null" + ] + }, + "lastModified": { + "type": [ + "string", + "null" + ] + }, + "priority": { + "format": "double", + "type": [ + "number", + "null" + ] + } + }, + "type": "object" + }, "AskForApproval": { "description": "Determines the conditions under which the user is consulted to approve running the command proposed by Codex.", "oneOf": [ @@ -126,6 +154,57 @@ } ] }, + "AudioContent": { + "description": "Audio provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "data": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, + "BlobResourceContents": { + "properties": { + "blob": { + "type": "string" + }, + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "uri": { + "type": "string" + } + }, + "required": [ + "blob", + "uri" + ], + "type": "object" + }, "ByteRange": { "properties": { "end": { @@ -150,9 +229,10 @@ "CallToolResult": { "description": "The server's response to a tool call.", "properties": { - "_meta": true, "content": { - "items": true, + "items": { + "$ref": "#/definitions/ContentBlock" + }, "type": "array" }, "isError": { @@ -310,6 +390,41 @@ } ] }, + "CollaborationMode": { + "description": "Collaboration mode for a Codex session.", + "properties": { + "mode": { + "$ref": "#/definitions/ModeKind" + }, + "settings": { + "$ref": "#/definitions/Settings" + } + }, + "required": [ + "mode", + "settings" + ], + "type": "object" + }, + "ContentBlock": { + "anyOf": [ + { + "$ref": "#/definitions/TextContent" + }, + { + "$ref": "#/definitions/ImageContent" + }, + { + "$ref": "#/definitions/AudioContent" + }, + { + "$ref": "#/definitions/ResourceLink" + }, + { + "$ref": "#/definitions/EmbeddedResource" + } + ] + }, "ContentItem": { "oneOf": [ { @@ -445,6 +560,42 @@ ], "type": "object" }, + "EmbeddedResource": { + "description": "The contents of a resource, embedded into a prompt or tool call result.\n\nIt is up to the client how best to render embedded resources for the benefit of the LLM and/or the user.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "resource": { + "$ref": "#/definitions/EmbeddedResourceResource" + }, + "type": { + "type": "string" + } + }, + "required": [ + "resource", + "type" + ], + "type": "object" + }, + "EmbeddedResourceResource": { + "anyOf": [ + { + "$ref": "#/definitions/TextResourceContents" + }, + { + "$ref": "#/definitions/BlobResourceContents" + } + ] + }, "EventMsg": { "description": "Response event from the agent NOTE: Make sure none of these values have optional types, as it will mess up the extension code-gen.", "oneOf": [ @@ -521,6 +672,17 @@ { "description": "Conversation history was rolled back by dropping the last N user turns.", "properties": { + "model_visible_state": { + "anyOf": [ + { + "$ref": "#/definitions/ModelVisibleState" + }, + { + "type": "null" + } + ], + "description": "Model-visible session state after rollback.\n\nThis lets clients synchronize UI mode/model indicators with core after history rewind. Optional for backward compatibility with older persisted events." + }, "num_turns": { "description": "Number of user turns that were removed from context.", "format": "uint32", @@ -2936,6 +3098,36 @@ ], "type": "object" }, + "ImageContent": { + "description": "An image provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "data": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "data", + "mimeType", + "type" + ], + "type": "object" + }, "LocalShellAction": { "oneOf": [ { @@ -3129,6 +3321,21 @@ ], "type": "string" }, + "ModelVisibleState": { + "properties": { + "collaboration_mode": { + "anyOf": [ + { + "$ref": "#/definitions/CollaborationMode" + }, + { + "type": "null" + } + ] + } + }, + "type": "object" + }, "NetworkAccess": { "description": "Represents whether outbound network access is available to the agent.", "enum": [ @@ -3441,8 +3648,7 @@ "format": "int64", "type": "integer" } - ], - "description": "ID of a request, which can be either a string or an integer." + ] }, "RequestUserInputQuestion": { "properties": { @@ -3498,21 +3704,22 @@ "Resource": { "description": "A known resource that the server is capable of reading.", "properties": { - "_meta": true, - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", "null" ] }, - "icons": { - "items": true, - "type": [ - "array", - "null" - ] - }, "mimeType": { "type": [ "string", @@ -3545,10 +3752,74 @@ ], "type": "object" }, + "ResourceLink": { + "description": "A resource that the server is capable of reading, included in a prompt or tool call result.\n\nNote: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "name": { + "type": "string" + }, + "size": { + "format": "int64", + "type": [ + "integer", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + }, + "type": { + "type": "string" + }, + "uri": { + "type": "string" + } + }, + "required": [ + "name", + "type", + "uri" + ], + "type": "object" + }, "ResourceTemplate": { "description": "A template description for resources available on the server.", "properties": { - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", @@ -4149,6 +4420,14 @@ } ] }, + "Role": { + "description": "The sender or recipient of messages and data in a conversation.", + "enum": [ + "assistant", + "user" + ], + "type": "string" + }, "SandboxPolicy": { "description": "Determines execution restrictions for model shell commands.", "oneOf": [ @@ -4253,6 +4532,34 @@ } ] }, + "Settings": { + "description": "Settings for a collaboration mode.", + "properties": { + "developer_instructions": { + "type": [ + "string", + "null" + ] + }, + "model": { + "type": "string" + }, + "reasoning_effort": { + "anyOf": [ + { + "$ref": "#/definitions/ReasoningEffort" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "model" + ], + "type": "object" + }, "SkillDependencies": { "properties": { "tools": { @@ -4458,6 +4765,32 @@ ], "type": "string" }, + "TextContent": { + "description": "Text provided to or from an LLM.", + "properties": { + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/Annotations" + }, + { + "type": "null" + } + ] + }, + "text": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "text", + "type" + ], + "type": "object" + }, "TextElement": { "properties": { "byte_range": { @@ -4481,6 +4814,27 @@ ], "type": "object" }, + "TextResourceContents": { + "properties": { + "mimeType": { + "type": [ + "string", + "null" + ] + }, + "text": { + "type": "string" + }, + "uri": { + "type": "string" + } + }, + "required": [ + "text", + "uri" + ], + "type": "object" + }, "ThreadId": { "type": "string" }, @@ -4541,26 +4895,38 @@ "Tool": { "description": "Definition for a tool the client can call.", "properties": { - "_meta": true, - "annotations": true, + "annotations": { + "anyOf": [ + { + "$ref": "#/definitions/ToolAnnotations" + }, + { + "type": "null" + } + ] + }, "description": { "type": [ "string", "null" ] }, - "icons": { - "items": true, - "type": [ - "array", - "null" - ] + "inputSchema": { + "$ref": "#/definitions/ToolInputSchema" }, - "inputSchema": true, "name": { "type": "string" }, - "outputSchema": true, + "outputSchema": { + "anyOf": [ + { + "$ref": "#/definitions/ToolOutputSchema" + }, + { + "type": "null" + } + ] + }, "title": { "type": [ "string", @@ -4574,6 +4940,82 @@ ], "type": "object" }, + "ToolAnnotations": { + "description": "Additional properties describing a Tool to clients.\n\nNOTE: all properties in ToolAnnotations are **hints**. They are not guaranteed to provide a faithful description of tool behavior (including descriptive properties like `title`).\n\nClients should never make tool use decisions based on ToolAnnotations received from untrusted servers.", + "properties": { + "destructiveHint": { + "type": [ + "boolean", + "null" + ] + }, + "idempotentHint": { + "type": [ + "boolean", + "null" + ] + }, + "openWorldHint": { + "type": [ + "boolean", + "null" + ] + }, + "readOnlyHint": { + "type": [ + "boolean", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "ToolInputSchema": { + "description": "A JSON Schema object defining the expected parameters for the tool.", + "properties": { + "properties": true, + "required": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "type": { + "default": "object", + "type": "string" + } + }, + "type": "object" + }, + "ToolOutputSchema": { + "description": "An optional JSON Schema object defining the structure of the tool's output returned in the structuredContent field of a CallToolResult.", + "properties": { + "properties": true, + "required": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "type": { + "default": "object", + "type": "string" + } + }, + "type": "object" + }, "TurnAbortReason": { "enum": [ "interrupted", diff --git a/codex-rs/app-server-protocol/schema/typescript/ModelVisibleState.ts b/codex-rs/app-server-protocol/schema/typescript/ModelVisibleState.ts new file mode 100644 index 0000000000..ad303d30ab --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/ModelVisibleState.ts @@ -0,0 +1,6 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CollaborationMode } from "./CollaborationMode"; + +export type ModelVisibleState = { collaboration_mode?: CollaborationMode, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/ThreadRolledBackEvent.ts b/codex-rs/app-server-protocol/schema/typescript/ThreadRolledBackEvent.ts index 30bc64c9c1..1f6b68adaa 100644 --- a/codex-rs/app-server-protocol/schema/typescript/ThreadRolledBackEvent.ts +++ b/codex-rs/app-server-protocol/schema/typescript/ThreadRolledBackEvent.ts @@ -1,9 +1,17 @@ // GENERATED CODE! DO NOT MODIFY BY HAND! // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ModelVisibleState } from "./ModelVisibleState"; export type ThreadRolledBackEvent = { /** * Number of user turns that were removed from context. */ -num_turns: number, }; +num_turns: number, +/** + * Model-visible session state after rollback. + * + * This lets clients synchronize UI mode/model indicators with core after history rewind. + * Optional for backward compatibility with older persisted events. + */ +model_visible_state?: ModelVisibleState, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/index.ts b/codex-rs/app-server-protocol/schema/typescript/index.ts index 91da0708e1..af1344f406 100644 --- a/codex-rs/app-server-protocol/schema/typescript/index.ts +++ b/codex-rs/app-server-protocol/schema/typescript/index.ts @@ -118,6 +118,7 @@ export type { McpToolCallBeginEvent } from "./McpToolCallBeginEvent"; export type { McpToolCallEndEvent } from "./McpToolCallEndEvent"; export type { MessagePhase } from "./MessagePhase"; export type { ModeKind } from "./ModeKind"; +export type { ModelVisibleState } from "./ModelVisibleState"; export type { NetworkAccess } from "./NetworkAccess"; export type { NewConversationParams } from "./NewConversationParams"; export type { NewConversationResponse } from "./NewConversationResponse"; diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 6d1e8d8414..c2b3082ba6 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -2772,16 +2772,13 @@ mod handlers { sub_id: String, updates: SessionSettingsUpdate, ) { - let previous_context = sess - .new_default_turn_with_sub_id(sess.next_internal_sub_id()) - .await; - let previous_collaboration_mode = sess - .state - .lock() - .await - .session_configuration - .collaboration_mode - .clone(); + let (previous_collaboration_mode, initial_context_seeded) = { + let state = sess.state.lock().await; + ( + state.session_configuration.collaboration_mode.clone(), + state.initial_context_seeded, + ) + }; let next_collaboration_mode = updates.collaboration_mode.clone(); if let Err(err) = sess.update_settings(updates).await { @@ -2796,27 +2793,23 @@ mod handlers { return; } - let initial_context_seeded = sess.state.lock().await.initial_context_seeded; if !initial_context_seeded { return; } - let current_context = sess.new_default_turn_with_sub_id(sub_id).await; - let has_model_visible_state_update = next_collaboration_mode.is_some(); - let pending_model_visible_state_sync = { + if let Some(next_mode) = next_collaboration_mode + && next_mode != previous_collaboration_mode + { let mut state = sess.state.lock().await; - state.take_pending_model_visible_state_sync(has_model_visible_state_update) - }; - let update_items = sess.build_settings_update_items( - Some(&previous_context), - ¤t_context, - &previous_collaboration_mode, - next_collaboration_mode.as_ref(), - &pending_model_visible_state_sync, - ); - if !update_items.is_empty() { - sess.record_conversation_items(¤t_context, &update_items) - .await; + if !matches!( + state.pending_model_visible_state_sync, + PendingModelVisibleStateSync::ForceEmitAll + ) { + state.pending_model_visible_state_sync = + PendingModelVisibleStateSync::Snapshot(ModelVisibleState { + collaboration_mode: Some(previous_collaboration_mode), + }); + } } } @@ -2883,7 +2876,10 @@ mod handlers { .session_configuration .collaboration_mode .clone(); - let next_collaboration_mode = updates.collaboration_mode.clone(); + let mut next_collaboration_mode = updates.collaboration_mode.clone(); + if next_collaboration_mode.is_none() { + next_collaboration_mode = Some(previous_collaboration_mode.clone()); + } let Ok(current_context) = sess.new_turn_with_sub_id(sub_id, updates).await else { // new_turn_with_sub_id already emits the error event. return;