mirror of
https://github.com/openai/codex.git
synced 2026-11-04 00:24:43 +00:00
## What changed - Require each `ContextualUserFragment` to provide a stable `<feature>.<name>` `ContentItemKind`. - Add `AnnotatedContent` and `RenderedFragment` so rendered text, its role, and its classification can travel together to API boundaries. - Derive extension-owned world-state classifications from the extension ID and keep the skills catalog classification with its fragment implementation. ## Testing - Verify that an extension-owned world-state section renders with an `<extension-id>.instructions` content kind. GitOrigin-RevId: e46b74a0bb41e0b6112667c9d36bc9e7f2714451
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
use codex_protocol::models::ContentItem;
|
|
use codex_protocol::models::ContentItemKind;
|
|
|
|
/// Model-visible content paired with its harness-owned classification.
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct AnnotatedContent {
|
|
content: ContentItem,
|
|
kind: ContentItemKind,
|
|
}
|
|
|
|
impl AnnotatedContent {
|
|
/// Creates content and its classification together.
|
|
pub fn new(content: ContentItem, kind: ContentItemKind) -> Self {
|
|
Self { content, kind }
|
|
}
|
|
|
|
/// Creates model-visible input text and its classification together.
|
|
pub fn input_text(text: impl Into<String>, kind: ContentItemKind) -> Self {
|
|
Self::new(ContentItem::InputText { text: text.into() }, kind)
|
|
}
|
|
|
|
/// Returns the model-visible content.
|
|
pub fn content(&self) -> &ContentItem {
|
|
&self.content
|
|
}
|
|
|
|
/// Returns the classification associated with the content.
|
|
pub fn kind(&self) -> &ContentItemKind {
|
|
&self.kind
|
|
}
|
|
|
|
/// Separates the content from its classification at an API boundary.
|
|
pub fn into_parts(self) -> (ContentItem, ContentItemKind) {
|
|
(self.content, self.kind)
|
|
}
|
|
}
|