Files
prometeu-studio/docs/specs/studio/16. Codex ACP Integration Specification.md
T
bquarkz 481c479427
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
feat(studio): render structured AI conversations
Add reusable UI2 conversation balloons, tool cards, native Markdown, copy actions and controlled streaming scroll. Preserve typed ACP tool updates and chat lifecycle, add Alt+Enter sending, update specifications and qualify the UI through desktop tests. Include the Pong asset cache.
2026-11-23 19:12:26 +00:00

146 lines
9.1 KiB
Markdown

# Codex ACP Integration Specification
Status: Implemented initial conversation slice. Owner: `studio`.
## Scope and ownership
The Studio JavaFX 2 project shell MUST consume an asynchronous, JavaFX-free
`AgentConnection` port in Studio API. The application MUST own the process adapter
and composition. UI MUST NOT launch processes or parse ACP; Core MUST NOT depend
on JavaFX. This extends specifications 8 and 15 and does not change runtime or MCP
authority. Assets, model selection, persistent chat indexing and history resumption
are outside this slice.
## Project connection and authentication
Studio preferences MUST offer Codex, ChatGPT login, executable, an ordered argument
vector, Connect and connection state. Launch settings MUST be machine-local and
shared by every project in `~/.prometeu-studio/ai-settings.json`. Project setup MUST
NOT override them. Legacy project `acp` values MUST be ignored without losing runtime,
save, indentation or MCP intent; new setup writes MUST omit the legacy field. A
project MUST NOT silently supply the global default. Apply MUST save without
restarting a connected agent; changed settings apply at the next connection.
Connect MUST save the configuration before launching it. With no project open,
preferences MUST remain editable, while connection/login indicate that a project
must first be opened.
The default executable MUST be `~/.prometeu-studio/bin/codex-acp`, with no arguments.
The explicit installer MUST stage adapter 2.9.0 under
`~/.prometeu-studio/agents/codex-acp/2.9.0`, use a working Node 22+ absolute executable
and set its PATH in the stable launcher. Runtime MUST NOT depend on npx or temporary
files. The launcher SHOULD reuse an installed compatible Codex 0.171.x through
CODEX_PATH; otherwise it MUST use the package dependency. Installation MUST be
idempotent, refuse replacing an unmanaged launcher and preserve an existing explicit
global preference. It MUST NOT modify system Node/npm or authentication. Installation
is explicit; opening a project MUST NOT download or update the adapter.
After a project is successfully presented, Studio MUST connect using global launch
settings and that project's root as cwd. Process, ACP sessions, transcript and drafts
MUST remain project-owned. Connection failure MUST remain visible and direct the
user to Studio preferences. The executable MUST be invoked directly, without shell
text evaluation. No browser login MAY start automatically; existing ChatGPT login is
reused, or explicit login remains available in preferences for the opened project.
The adapter MUST negotiate ACP v1 over stdio JSON-RPC, require the `chat-gpt`
authentication method and recognize existing active ChatGPT authentication through
`auth/status` and status updates. Explicit login MUST request only `chat-gpt`;
the adapter owns browser login and credential storage. Studio MUST NOT offer API
keys or billing indications, forward inherited OPENAI_API_KEY/CODEX_API_KEY, save
credentials in setup/AIE, or expose raw environment/stderr in UI or evidence.
Connection/authentication failures MUST remain visible and MUST NOT imply readiness.
## Sessions, sending and drafts
Each local chat MUST lazily obtain its own ACP session on first send. Sessions MUST
use the project cwd and select the offered `workspace-write` mode before prompting,
which uses Codex's on-request permission policy. No unattended approval mode is
introduced. Only one request MAY run per project; selecting chats and editing their
independent drafts MUST remain possible while it runs.
Send MUST snapshot only the selected draft, select its chat and open AI, collapsing
the external prompt. Responses MUST route by session rather than current selection.
ACP has no separate prompt-accepted response: first relevant agent progress or a
successful prompt response MUST acknowledge delivery. The corresponding draft MUST
clear only if still identical to the snapshot. Pre-delivery failure MUST preserve
it; edits made while sending MUST survive. The submitted text and failures MUST
remain in the conversation. Recover last request MUST copy that text only into an
empty draft. Failed work MUST NOT be automatically resubmitted.
The conversation MUST retain separate typed items for user messages, streamed
assistant segments, tool calls and terminal results. Thought content MUST NOT be
stored or shown; generic working activity MAY be shown. Current activity and
connection state MUST remain visible, including the running chat identity when
another chat is selected. Presentation follows specification 15.
The JavaFX-free port MUST preserve tool identity, title, category, state, input,
output and supported content from ACP tool_call/tool_call_update notifications.
Updates MUST route by session and toolCallId. Omitted/null optional fields MUST
retain prior values; explicit empty content MUST clear content. Supplied snapshots
MUST replace their corresponding fields rather than being concatenated as deltas.
Unsupported content MUST NOT be presented as invented shell output. Missing terminal
tool status at turn completion MUST remain an unconfirmed/interrupted outcome.
Studio's conversation remains transient and bounded, not an authoritative persisted
agent history. Its reducer MUST limit each message/content/output field to 64,000
UTF-16 code units, tool input to 16,000 and title to 1,000. New tool identities MUST
be nonblank and at most 512 code units. A turn MUST admit at most 256 content items
plus its terminal result, with a shared 200,000-character budget across message text,
titles, input and output; terminal error detail MAY add at most 1,000 characters.
Omitted fields MUST remain unchanged even at the budget boundary. Truncation MUST
preserve UTF-16 surrogate pairs and be indicated visibly. Oversized transport fields
MUST also be bounded before dispatch and carry an explicit truncation marker.
Completed older turns MUST be retired as complete turns to retain at most 200,000
characters, 512 items and 20 turns, subject to retaining the newest turn intact
within its own admission limits. The active turn MUST remain retained while running
and MAY temporarily coexist with that completed history budget. History retirement
and admission limits MUST produce a visible localized notice. Virtualization MUST
NOT be treated as a data-memory limit. Repeated deltas or snapshots after reaching a
limit MUST NOT create unlimited empty balloons or entries.
Connection loss MUST invalidate bound session IDs. Retained transcripts MUST remain
readable, with explicit guidance to create a new chat after reconnecting. Studio MUST
NOT silently create a replacement session pretending to retain conversation context.
## Permission and cancellation
Each `session/request_permission` MUST require an explicit choice from its offered
options. The owned, nonblocking dialog MUST identify the chat and requested action,
with a bounded scrollable action preview when supplied. Closing/cancelling MUST
return cancelled; unknown options MUST NOT authorize. Cancellation, turn completion
and project close MUST dismiss stale permission dialogs. UI callbacks MUST run on FX;
protocol IO and process waits MUST run off FX.
Cancel MUST send `session/cancel` and await the active prompt's terminal response.
If unresponsive for ten seconds, the connection MUST terminate its owned process
tree and invalidate sessions before cancellation finishes. Deleting a running chat
MUST confirm, cancel and await termination before removing local state. Failure MUST
retain the chat and report an error. Deletion MUST NOT undo project changes or claim
to delete the agent's own persisted history.
Project close MUST cancel and await the agent alongside runtime shutdown, then
terminate the owned process tree before discarding chats/drafts and closing the
project session. Cancellation has a ten-second grace; process termination MUST
escalate from graceful destruction to force with bounded waits (two plus three
seconds). A termination failure MUST keep closure visibly incomplete and allow
cleanup retry. Cleanup MUST target only the launched process and tracked descendants,
never unrelated Codex processes.
## Transport and verification
Requests MUST correlate IDs, support asynchronous notifications and incoming
permission requests, bound frame size to 4 MiB and use finite RPC timeouts. Missing
or incompatible agents, rejection, malformed frames, process death and timeout MUST
fail visibly. Unsupported incoming methods MUST receive method-not-found. Reconnect
MUST dispose the previous transport before launch and fence old process output.
Display-free tests MUST exercise real stdio peers, handshake/authentication,
independent sessions, explicit permission choices, cancellation, unresponsive peers,
malformed/disconnected transport and process-tree cleanup. Chat-state tests MUST
cover independent drafts, delivery failure, edits during delivery, session creation
cancellation, delete waiting and invalidated sessions. Desktop tests MUST exercise
the actual settings, prompt, chat routing, permissions and project lifetime with a
controlled backend. The opt-in live smoke MUST use a disposable project and an
existing ChatGPT login, request no tools or file changes, and await full shutdown.
Live smoke MUST NOT run as part of ordinary unit tests.