feat: relay watch text/command/cancel to server (session.prompt/cancel)
This commit is contained in:
@@ -75,12 +75,24 @@ public class MainActivity extends AppCompatActivity {
|
||||
try {
|
||||
JSONObject msg = new JSONObject(json);
|
||||
String type = msg.optString("type", "");
|
||||
if ("command".equals(type) && "prompt".equals(msg.optString("kind", ""))) {
|
||||
JSONObject payload = msg.optJSONObject("payload");
|
||||
String content = payload != null ? payload.optString("content", "") : "";
|
||||
JSONObject params = new JSONObject();
|
||||
JSONObject payload = msg.optJSONObject("payload");
|
||||
JSONObject params = new JSONObject();
|
||||
|
||||
if ("text".equals(type)) {
|
||||
String content = payload != null ? payload.optString("text", "") : "";
|
||||
params.put("content", content);
|
||||
serverClient.sendRequest("harness.prompt", params);
|
||||
serverClient.sendRequest("session.prompt", params);
|
||||
} else if ("command".equals(type)) {
|
||||
String kind = msg.optString("kind", payload != null ? payload.optString("kind", "") : "");
|
||||
String content = payload != null ? payload.optString("content", "") : "";
|
||||
if ("cancel".equals(kind)) {
|
||||
serverClient.sendRequest("session.cancel", params);
|
||||
} else {
|
||||
params.put("content", content);
|
||||
serverClient.sendRequest("session.prompt", params);
|
||||
}
|
||||
} else if ("cancel".equals(type)) {
|
||||
serverClient.sendRequest("session.cancel", params);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore malformed
|
||||
|
||||
Reference in New Issue
Block a user