Feat: Support streaming all outputs and also support passing history with -q
Hi, thanks for making this open source!
I want to propose a few cli options for non-interactive mode (-q):
--history - pass a message history for non-interactive mode to continue working
--stream - stream all outputs (not just the final output) from non-interactive mode.
Note that for --stream, I believe this may already be available as -j/--json and it needs to be exposed? https://github.com/openai/codex/blob/main/codex-cli/src/cli.tsx#L37
Example use case for history
If a user runs an initial command with -q (or -j), then gets all the message history from stdout, then they could pass that information back to another -q / -j call in order to incrementally work with the LLM. This is similar to interactive mode, but it also allows non-interactive consumers to pass message history properly in the standard openai message format.
I'm currently working on an API server at https://github.com/Flux159/codex-api-server that could then expose this functionality to other clients via HTTP/S (with auth) - allowing a number of other clients to be built with codex without being restricted by the terminal api.
Storing history
There's another potential command around history that may be useful purely for the interactive CLI --save-history. Essentially it would store chat history in ~/.codex/chats. This would allow a user to restart an interactive session with a previous history by using --load-history ~/.codex/chats/chat-1.json without losing the intermediate messages & context.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗