feat(codex): share sessions across terminal and web

Use one native app-server for terminal, Web and phone clients while retaining the existing CLI and Runner lifecycle.

Synchronize native queues, permissions, question history and steering state; preserve explicit permission precedence and per-turn usage models. Resume inactive clear commands through Runner and reject independent child cold resumes.

Add shared-runtime regression tests, generated protocol fixtures and lifecycle documentation.
This commit is contained in:
weishu
2026-09-12 10:59:17 +08:00
parent 25af3f8e13
commit 0c4abcb3d1
111 changed files with 4684 additions and 960 deletions
@@ -42,6 +42,9 @@ interface AttachmentUploadApi {
* and [AttachmentUploadApi] for the composer attachment flow (B-M3f).
*/
interface ChatSessionApi : MessagesApi, AttachmentUploadApi {
/** Shared root creation; only the initiating client navigates. */
suspend fun clearConversation(sessionId: String): ResumeSessionResponse
/** `POST /api/sessions/:id/messages` — `{ok:true}`; the row arrives via SSE. */
suspend fun sendMessage(sessionId: String, message: SendMessageRequest)
@@ -280,6 +280,10 @@ class HapiApi internal constructor(
QueuedStateRequest(localIds).toJsonBody(),
)
/** `POST /api/sessions/:id/clear` — shared sessions; returns an independent root. */
override suspend fun clearConversation(sessionId: String): ResumeSessionResponse =
request("POST", url("api", "sessions", sessionId, "clear").build(), EMPTY_JSON)
/** `POST /api/sessions/:id/abort` — active sessions only. */
override suspend fun abortSession(sessionId: String) {
request<Unit>("POST", url("api", "sessions", sessionId, "abort").build(), EMPTY_JSON)