Commit Graph

4 Commits

  • Emit goal update events from goal extension tools (#23306)
    ## Why
    
    Goal creation and completion are moving through the goal extension, but
    the rest of Codex still observes goal state through `ThreadGoalUpdated`
    events. Without an event from the extension-owned tool path, a
    model-initiated `create_goal` or `update_goal` can mutate the backend
    and return a tool result while app-server and TUI listeners miss the
    goal state transition.
    
    ## What changed
    
    - Added `GoalEventEmitter` as a small wrapper around the host
    `ExtensionEventSink` to build `EventMsg::ThreadGoalUpdated` events for
    goal updates.
    - Threaded the registry event sink into `GoalExtension` and the
    `GoalToolExecutor`s created by the extension. The public
    `GoalExtension::new` constructor keeps a `NoopExtensionEventSink`
    fallback for standalone use.
    - Emitted a goal update after successful `create_goal` and `update_goal`
    tool calls. Until `ToolCall` exposes the current turn submission id,
    these events use the tool call id as the event id and leave `turn_id`
    unset.
    
    Relevant code:
    
    -
    [`GoalEventEmitter::thread_goal_updated`](https://github.com/openai/codex/blob/1fe2d73890df9a50996f67f705d4da4cc3d4b866/codex-rs/ext/goal/src/events.rs#L19-L32)
    - [`GoalToolExecutor` emission
    points](https://github.com/openai/codex/blob/1fe2d73890df9a50996f67f705d4da4cc3d4b866/codex-rs/ext/goal/src/tool.rs#L161-L190)
    
    ## Testing
    
    - `cargo test -p codex-goal-extension`
  • chore: make token usage async (#23305)
    Make the `TokenUsageContributor` async. This will be required for future
    extension and it's basically free
  • Make extension lifecycle hooks async (#23291)
    ## Why
    
    Extension lifecycle hooks sit on the host/extension boundary, but the
    current trait surface only allows synchronous callbacks. That forces
    extensions that need to seed, rehydrate, observe, or flush
    extension-owned state during thread and turn transitions to either block
    inside the callback or move async work into separate host plumbing.
    
    This PR makes those lifecycle callbacks awaitable so extension
    implementations can perform async work directly at the lifecycle point
    where the host already has the relevant session, thread, or turn stores
    available.
    
    ## What changed
    
    - Makes `ThreadLifecycleContributor` and `TurnLifecycleContributor`
    async in `codex-extension-api`.
    - Awaits thread start/resume/stop and turn start/stop/abort lifecycle
    callbacks from `codex-core`.
    - Updates the guardian and memories extensions to implement the async
    lifecycle trait surface.
    - Updates the existing lifecycle tests to use async contributor
    implementations.
    - Adds `async-trait` to the crates that now expose or implement these
    async object-safe lifecycle traits.
    
    ## Testing
    
    - Existing `codex-core` lifecycle tests were updated to cover async
    implementations for thread stop and turn abort ordering.
  • chore: goal ext skeleton (#23288)
    Skeleton of `/goal` in extension
    Lot's of follow-ups coming