# Pi Codex Search Specification

## Goal

Provide Pi with the remote Codex web-search experience through the configured
OpenAI-compatible provider's `/v1/alpha/search` endpoint, including Sub2API.

## Required Behavior

- Register one remote tool: `web_search`.
- Preserve the Codex command surface: search, image search, open, click, find,
  screenshot, finance, weather, sports, and time.
- Support a direct `openai-compatible` mode whose `baseUrl`, `apiKey`, and remote
  model ID are stored in the extension configuration and sent directly to the
  gateway without consulting Pi's model registry.
- Keep `openai-codex` as the official-login mode. Resolve its model, OAuth token,
  headers, account ID, and base URL through Pi's model registry.
- Mask the direct API key in configuration display, write configuration with
  mode `0600`, and reject direct connection fields for `openai-codex`.
- Reject legacy `provider: "openai"` with migration guidance to avoid confusing
  direct gateway authentication with Pi's built-in OpenAI provider.
- Keep search artifacts (`report.md`, `raw-search.txt`, and metadata), cleanup,
  report paths, and context pruning.
- Treat all returned web content as untrusted data.

## Out Of Scope

- Local URL fetching (`web_fetch` and `web_fetch_read`).
- Local HTML, PDF, Office, or EPUB parsing.
- Exa search and local summary-model pipelines.
- Replacing Pi's built-in file-reading and other extension capabilities.
