mirror of
https://github.com/openai/codex.git
synced 2026-11-14 14:49:31 +00:00
Add attachment upload and resolution APIs and pass stores into sessions (#45556)
## What changed Replace `AttachmentStore::persist` with `upload` and `resolve`. Uploads return inline bytes or a file ID; resolution returns optional file metadata and a download URL only when a minimum URL lifetime is requested. Add image dimensions, digest, size, MIME type, and categorized errors to the API. Make `InlineAttachmentStore` return the original bytes and report `NotFound` when resolving file IDs. Redact attachment bytes and file URLs in debug output. Pass the configured image store from the thread manager into sessions and inherit it in delegated sessions. Allow `TestCodexBuilder` to accept a custom image store. ## Testing Update unit coverage for preserving PNG and JPEG bytes, redacting bytes and URLs in debug output, and rejecting file resolution in the inline store. GitOrigin-RevId: f313e0048925998d84394c7e5a278e0d39d86a45
This commit is contained in:
1 parent
364b511dcd
commit
446b771049
13 files changed
+247
-89
No files matched your search
@@ -13,6 +13,7 @@ use std::time::Duration;
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use codex_attachment_store::AttachmentStore;
|
||||
use codex_config::CloudConfigBundleLoader;
|
||||
use codex_core::CodexThread;
|
||||
pub use codex_core::StartThreadOptions;
|
||||
@@ -342,6 +343,7 @@ pub struct TestCodexBuilder {
|
||||
history_mode: Option<ThreadHistoryMode>,
|
||||
models_manager: Option<SharedModelsManager>,
|
||||
thread_store: Option<Arc<dyn ThreadStore>>,
|
||||
image_store: Arc<dyn AttachmentStore>,
|
||||
}
|
||||
|
||||
impl TestCodexBuilder {
|
||||
@@ -368,6 +370,11 @@ impl TestCodexBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_image_store(mut self, image_store: Arc<dyn AttachmentStore>) -> Self {
|
||||
self.image_store = image_store;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_model(self, model: &str) -> Self {
|
||||
let new_model = model.to_string();
|
||||
self.with_config(move |config| {
|
||||
@@ -739,7 +746,7 @@ impl TestCodexBuilder {
|
||||
Arc::new(extensions.build()),
|
||||
user_instructions_provider,
|
||||
/*analytics_events_client*/ None,
|
||||
codex_core::passthrough_image_store(),
|
||||
Arc::clone(&self.image_store),
|
||||
Arc::clone(&thread_store),
|
||||
codex_core::local_agent_graph_store_from_state_db(state_db.as_ref()),
|
||||
installation_id,
|
||||
@@ -1403,6 +1410,7 @@ pub fn test_codex() -> TestCodexBuilder {
|
||||
history_mode: None,
|
||||
models_manager: None,
|
||||
thread_store: None,
|
||||
image_store: codex_core::passthrough_image_store(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user