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 {
|
try {
|
||||||
JSONObject msg = new JSONObject(json);
|
JSONObject msg = new JSONObject(json);
|
||||||
String type = msg.optString("type", "");
|
String type = msg.optString("type", "");
|
||||||
if ("command".equals(type) && "prompt".equals(msg.optString("kind", ""))) {
|
|
||||||
JSONObject payload = msg.optJSONObject("payload");
|
JSONObject payload = msg.optJSONObject("payload");
|
||||||
String content = payload != null ? payload.optString("content", "") : "";
|
|
||||||
JSONObject params = new JSONObject();
|
JSONObject params = new JSONObject();
|
||||||
|
|
||||||
|
if ("text".equals(type)) {
|
||||||
|
String content = payload != null ? payload.optString("text", "") : "";
|
||||||
params.put("content", content);
|
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) {
|
} catch (Exception e) {
|
||||||
// ignore malformed
|
// ignore malformed
|
||||||
|
|||||||
Reference in New Issue
Block a user