Phase 2 core: ClaudeDriver over stream-json, permissions and questions on the phone
The second driver behind the same trait: claude -p with stream-json both ways, the hidden --permission-prompt-tool stdio flag (without which no permission ever reaches a client), text deltas streamed from raw API events, tool_use/tool_result mapped to tool events, and can_use_tool control requests surfaced as Question events -- plain permissions as Allow/Deny, AskUserQuestion as one Question per sub-question with the chosen labels sent back in updatedInput.answers keyed by question text (wire shapes pinned by live probes against CLI 2.1.237, recorded in the module doc). The CLI session id is persisted per session dir, so a backend restart respawns with --resume and loses nothing. set_model rides the control protocol and persists through the manager; the spawn screen grows model/cwd/permission-mode fields. Also: the dev CA now carries proper keyUsage/basicConstraints extensions (strict verifiers reject it otherwise) -- regenerated and re-pinned before any real phone has installed the app. Verified: 20 unit tests + clippy clean; scripted end-to-end over the HTTP API (AskUserQuestion round trip, Bash permission allow, streaming, restart with --resume remembering earlier work, delete); and on the emulator, a live haiku session asking Tea-or-coffee and acknowledging the tapped answer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017xn8nHw1tw1R6PtiY1eEtw
This commit is contained in:
1 parent
f3cebeea78
commit
95d389e2b8
10 files changed
+882
-37
No files matched your search
@@ -111,12 +111,23 @@ fun fetchSessions(settings: ServerSettings): List<SessionSummary> =
|
||||
}
|
||||
|
||||
/** Spawns a session and returns it as the list would show it. */
|
||||
fun spawnSession(settings: ServerSettings, kind: String, title: String): SessionSummary =
|
||||
fun spawnSession(
|
||||
settings: ServerSettings,
|
||||
kind: String,
|
||||
title: String,
|
||||
model: String? = null,
|
||||
cwd: String? = null,
|
||||
permissionMode: String? = null,
|
||||
): SessionSummary =
|
||||
requestFromServer(
|
||||
settings,
|
||||
"/sessions",
|
||||
method = "POST",
|
||||
jsonBody = JSONObject().put("kind", kind).put("title", title).toString(),
|
||||
jsonBody = JSONObject().put("kind", kind).put("title", title).apply {
|
||||
if (!model.isNullOrBlank()) put("model", model)
|
||||
if (!cwd.isNullOrBlank()) put("cwd", cwd)
|
||||
if (!permissionMode.isNullOrBlank()) put("permissionMode", permissionMode)
|
||||
}.toString(),
|
||||
) { connection ->
|
||||
val session = JSONObject(connection.inputStream.bufferedReader().readText())
|
||||
SessionSummary(
|
||||
|
||||
Reference in new issue
Block a user