Show startup shell before background avatar admission and update reviewed capabilities
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package android.util
|
||||
object Log {
|
||||
@JvmStatic fun i(tag: String,message: String)=0
|
||||
@JvmStatic fun getStackTraceString(error: Throwable) = error.stackTraceToString()
|
||||
@JvmStatic fun w(tag: String, message: String) = 0
|
||||
@JvmStatic fun w(tag: String, message: String, error: Throwable) = 0
|
||||
|
||||
@@ -490,6 +490,7 @@ fun runChecks() {
|
||||
}
|
||||
|
||||
fun main() {
|
||||
startupCapabilityCheck()
|
||||
checkCallControls()
|
||||
checkFaceTransmission()
|
||||
run {
|
||||
|
||||
@@ -3,19 +3,20 @@ package com.gorios.lanvoice.net
|
||||
// Event doubles isolate DialogueClient callback ordering from the unchanged JSON parser.
|
||||
// Production DialogueProtocol/JSONObject were compiled separately with actual dependencies.
|
||||
class Payload(private val ok: Boolean = true, private val turn: Long? = null, private val state: String = "", private val reason: String = "", private val fields: Map<String, Any> = emptyMap()) {
|
||||
fun optBoolean(key: String, fallback: Boolean) = if (key == "ok") ok else fallback
|
||||
fun optBoolean(key: String, fallback: Boolean) = if (key == "ok") ok else fields[key] as? Boolean ?: fallback
|
||||
fun optString(key: String, fallback: String = "") = when (key) { "state" -> state; "reason" -> reason; else -> fields[key] as? String ?: fallback }
|
||||
fun optInt(key: String, fallback: Int) = if (key == "context_face_cue_version") 1 else fallback
|
||||
fun opt(key: String): Any? = if (key == "turn_id") turn else fields[key]
|
||||
}
|
||||
enum class EventKind { AUTH, HELLO, ERROR, HISTORY, UNKNOWN, LISTEN, VAD, STT, LLM, TTS, ABORT, REPLY_EMOTION, EXPRESSION_PREPARE, ACTION, SPEECH }
|
||||
enum class EventKind { AUTH, HELLO, ERROR, HISTORY, UNKNOWN, LISTEN, VAD, STT, LLM, TTS, ABORT, REPLY_EMOTION, EXPRESSION_PREPARE, ACTION, CAPABILITIES, SPEECH }
|
||||
data class ServerEvent(val type: String, val kind: EventKind, val payload: Payload)
|
||||
class DownlinkFrame(val turnId: Long = 0, val sequence: Long = 0, val pcm16: ByteArray = ByteArray(2))
|
||||
object DialogueProtocol {
|
||||
val uplinks = mutableListOf<Triple<Long, Long, Int>>()
|
||||
fun actionStatus(value: com.gorios.lanvoice.avatar.ActionStatus) = "action_status"
|
||||
fun faceCue(turn: Long, observation: com.gorios.lanvoice.expression.FaceCueObservation, age: Long) = "face_cue"
|
||||
fun hello(actionPackSha: String? = null) = "hello"
|
||||
fun hello(actionPackSha: String? = null,pendingPackSha: String?=null) = "hello"
|
||||
fun capabilitiesReady(pin: String) = "capabilities_ready"
|
||||
fun listen(start: Boolean) = "listen"
|
||||
fun abort(turn: Long) = "abort"
|
||||
fun playbackDrained(turn: Long) = "drained"
|
||||
@@ -24,6 +25,9 @@ object DialogueProtocol {
|
||||
fun parseEvent(text: String) = when (text) {
|
||||
"auth" -> ServerEvent("auth", EventKind.AUTH, Payload())
|
||||
"auth failed" -> ServerEvent("auth", EventKind.AUTH, Payload(false))
|
||||
"hello pending" -> ServerEvent("hello",EventKind.HELLO,Payload(fields=mapOf("action_available" to false,"action_pending" to true)))
|
||||
"cap accepted" -> ServerEvent("client.capabilities",EventKind.CAPABILITIES,Payload(fields=mapOf("action_available" to true,"action_pack_sha256" to "a".repeat(64))))
|
||||
"cap wrong" -> ServerEvent("client.capabilities",EventKind.CAPABILITIES,Payload(fields=mapOf("action_available" to true,"action_pack_sha256" to "b".repeat(64))))
|
||||
"hello available" -> ServerEvent("hello", EventKind.HELLO, Payload(fields=mapOf("action_available" to true)))
|
||||
"hello unavailable" -> ServerEvent("hello", EventKind.HELLO, Payload(fields=mapOf("action_available" to false)))
|
||||
"hello" -> ServerEvent("hello", EventKind.HELLO, Payload())
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import android.os.Handler
|
||||
import com.gorios.lanvoice.net.*
|
||||
|
||||
fun startupCapabilityCheck() {
|
||||
var installed: String?=null
|
||||
val client=DialogueClient("localhost",5011,{},actionPackSha={installed},pendingActionPackSha={"a".repeat(64)})
|
||||
val socket=FakeSocket();client.setField("socket",socket);val listener=client.callbacks(0)
|
||||
fun event(value: String) { listener.onMessage(socket,value);Handler.drain() }
|
||||
event("auth");event("hello pending")
|
||||
check(client.actionNegotiation=="pending_pack" && !client.capabilitiesReady())
|
||||
installed="a".repeat(64);check(client.capabilitiesReady());check(!client.capabilitiesReady())
|
||||
check(socket.sent.count { it=="capabilities_ready" }==1)
|
||||
event("cap wrong");check(client.actionNegotiation=="pending_pack")
|
||||
event("cap accepted");check(client.actionNegotiation=="accepted")
|
||||
client.disconnect();event("cap accepted");check(client.actionNegotiation=="disconnected")
|
||||
client.release();Handler.drain()
|
||||
val legacy=DialogueClient("localhost",5011,{},actionPackSha={"a".repeat(64)})
|
||||
val old=FakeSocket();legacy.setField("socket",old)
|
||||
val callbacks=legacy.callbacks(0);callbacks.onMessage(old,"auth");Handler.drain();callbacks.onMessage(old,"hello unavailable");Handler.drain()
|
||||
check(!legacy.capabilitiesReady());legacy.release();Handler.drain()
|
||||
val failing=DialogueClient("localhost",5011,{},actionPackSha={installed},pendingActionPackSha={"a".repeat(64)})
|
||||
installed=null;val broken=FakeSocket();failing.setField("socket",broken);val cb=failing.callbacks(0)
|
||||
cb.onMessage(broken,"auth");Handler.drain();cb.onMessage(broken,"hello pending");Handler.drain()
|
||||
installed="a".repeat(64);broken.acceptSend=false;check(!failing.capabilitiesReady())
|
||||
check(failing.actionNegotiation=="disconnected" && broken.cancelled);failing.release();Handler.drain()
|
||||
println("PASS: production DialogueClient pending/ready capability callback, exactpin, once, stale socket and legacy gates; no turn reset/reconnect")
|
||||
}
|
||||
Reference in New Issue
Block a user