mirror of
https://github.com/openai/codex.git
synced 2026-09-08 15:50:34 +00:00
## Summary - introduce a private `session_runtime` boundary for cell creation requests, observation modes, lifecycle events, output items, and tool metadata - update the cell actor and in-process service to use those transport-neutral types - keep cell ID allocation on the owning session side ## Motivation Cell lifecycle vocabulary currently lives inside the cell actor implementation. That makes the service adapter and future session runtime depend on actor-specific types, increasing the size and complexity of the runtime ownership change. This is the first reviewable slice of the session-runtime stack. It separates the transport-neutral data model without moving lifecycle ownership or changing behavior. Later slices will move session state behind this boundary, harden terminal and shutdown behavior, and split cell creation from observation. ## Behavior There are no public API or user-visible behavior changes in this PR. In particular: - `CodeModeSession::execute` and `wait` are unchanged - cell IDs remain allocated by the owning session - cell admission, observation, termination, and shutdown behavior are unchanged
61 lines
2.3 KiB
Rust
61 lines
2.3 KiB
Rust
use codex_code_mode_protocol::CodeModeToolKind;
|
|
use codex_code_mode_protocol::ExecuteRequest;
|
|
use codex_code_mode_protocol::FunctionCallOutputContentItem;
|
|
use codex_code_mode_protocol::ImageDetail;
|
|
use codex_code_mode_protocol::ToolDefinition;
|
|
use codex_protocol::ToolName;
|
|
|
|
use crate::session_runtime::CreateCellRequest as CellRequest;
|
|
use crate::session_runtime::ImageDetail as CellImageDetail;
|
|
use crate::session_runtime::OutputItem as CellOutputItem;
|
|
use crate::session_runtime::ToolKind as CellToolKind;
|
|
|
|
pub(super) fn runtime_request(request: CellRequest) -> ExecuteRequest {
|
|
ExecuteRequest {
|
|
tool_call_id: request.tool_call_id,
|
|
enabled_tools: request
|
|
.enabled_tools
|
|
.into_iter()
|
|
.map(|definition| ToolDefinition {
|
|
name: definition.name,
|
|
tool_name: ToolName {
|
|
name: definition.tool_name.name,
|
|
namespace: definition.tool_name.namespace,
|
|
},
|
|
description: definition.description,
|
|
kind: match definition.kind {
|
|
CellToolKind::Function => CodeModeToolKind::Function,
|
|
CellToolKind::Freeform => CodeModeToolKind::Freeform,
|
|
},
|
|
input_schema: None,
|
|
output_schema: None,
|
|
})
|
|
.collect(),
|
|
source: request.source,
|
|
yield_time_ms: None,
|
|
max_output_tokens: None,
|
|
}
|
|
}
|
|
|
|
pub(super) fn cell_tool_kind(kind: CodeModeToolKind) -> CellToolKind {
|
|
match kind {
|
|
CodeModeToolKind::Function => CellToolKind::Function,
|
|
CodeModeToolKind::Freeform => CellToolKind::Freeform,
|
|
}
|
|
}
|
|
|
|
pub(super) fn output_item(item: FunctionCallOutputContentItem) -> CellOutputItem {
|
|
match item {
|
|
FunctionCallOutputContentItem::InputText { text } => CellOutputItem::Text { text },
|
|
FunctionCallOutputContentItem::InputImage { image_url, detail } => CellOutputItem::Image {
|
|
image_url,
|
|
detail: detail.map(|detail| match detail {
|
|
ImageDetail::Auto => CellImageDetail::Auto,
|
|
ImageDetail::Low => CellImageDetail::Low,
|
|
ImageDetail::High => CellImageDetail::High,
|
|
ImageDetail::Original => CellImageDetail::Original,
|
|
}),
|
|
},
|
|
}
|
|
}
|