Files
codex/codex-rs/thread-store/src/thread_attachments.rs
T
joeytrasatti-openai 2635431edb Add attachment owner lookup to the app-server (#50094)
## Why

`thread/attachment/list` lists attachments for a known thread. Clients also need to find the threads associated with a given attachment identity.

## What changed

Add `thread/attachmentOwner/list` to return owning thread IDs and archive status for an exact `attachmentType` and `identityKey`. Support cursor pagination and an optional `archived` filter, including both archived and non-archived threads by default.

Wire the request through the thread store and update documentation, protocol schemas, and generated TypeScript and Python types. The lookup is limited to the configured thread store and reports current membership, not an atomic resource-cleanup check.

## Testing

Extend app-server integration tests to cover exact type-and-key matching, multiple owners, archive filtering, and invalid cursor rejection.

GitOrigin-RevId: 30f4a20e00243d0023246d465a9b95213b3adeb6
2026-10-01 20:47:05 +00:00

51 lines
1.7 KiB
Rust

//! Typed parameters for attachment operations on stored threads.
use crate::ThreadAttachmentArchiveFilter;
use codex_protocol::ThreadId;
use serde_json::Value;
/// Parameters for attaching a thread-owned attachment.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct AddThreadAttachmentParams {
/// Thread that owns the attachment.
pub thread_id: ThreadId,
/// Client-defined attachment type.
pub attachment_type: String,
/// Stable attachment identity within its thread and type.
pub identity_key: String,
/// Bounded, client-defined attachment metadata.
pub payload: Value,
}
/// Parameters for listing attachments owned by one thread.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ListThreadAttachmentsParams {
/// Thread whose attachments should be returned.
pub thread_id: ThreadId,
/// Opaque cursor returned by a previous attachment listing.
pub cursor: Option<String>,
/// Maximum number of attachments to return.
pub limit: usize,
}
/// Parameters for removing a thread-owned attachment.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RemoveThreadAttachmentParams {
/// Thread that owns the attachment.
pub thread_id: ThreadId,
/// Client-defined attachment type.
pub attachment_type: String,
/// Stable attachment identity within its thread and type.
pub identity_key: String,
}
/// Parameters for finding all owners of one attachment identity in this store.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ListThreadAttachmentThreadsParams {
pub attachment_type: String,
pub identity_key: String,
pub archive_filter: ThreadAttachmentArchiveFilter,
pub cursor: Option<String>,
pub limit: usize,
}