fix: pass android lint and swiftformat
This commit is contained in:
@@ -13,6 +13,7 @@ import com.clawdbot.android.chat.ChatPendingToolCall
|
||||
import com.clawdbot.android.chat.ChatSessionEntry
|
||||
import com.clawdbot.android.chat.OutgoingAttachment
|
||||
import com.clawdbot.android.gateway.DeviceIdentityStore
|
||||
import com.clawdbot.android.gateway.GatewayClientInfo
|
||||
import com.clawdbot.android.gateway.GatewayConnectOptions
|
||||
import com.clawdbot.android.gateway.GatewayDiscovery
|
||||
import com.clawdbot.android.gateway.GatewayEndpoint
|
||||
@@ -208,7 +209,7 @@ class NodeRuntime(context: Context) {
|
||||
},
|
||||
)
|
||||
|
||||
private val chat =
|
||||
private val chat: ChatController =
|
||||
ChatController(
|
||||
scope = scope,
|
||||
session = operatorSession,
|
||||
|
||||
@@ -219,7 +219,7 @@ class GatewaySession(
|
||||
}
|
||||
}
|
||||
|
||||
fun awaitClose() = closedDeferred.await()
|
||||
suspend fun awaitClose() = closedDeferred.await()
|
||||
|
||||
fun closeQuietly() {
|
||||
if (isClosed.compareAndSet(false, true)) {
|
||||
@@ -315,41 +315,20 @@ class GatewaySession(
|
||||
client.modelIdentifier?.let { put("modelIdentifier", JsonPrimitive(it)) }
|
||||
}
|
||||
|
||||
val params =
|
||||
buildJsonObject {
|
||||
put("minProtocol", JsonPrimitive(GATEWAY_PROTOCOL_VERSION))
|
||||
put("maxProtocol", JsonPrimitive(GATEWAY_PROTOCOL_VERSION))
|
||||
put("client", clientObj)
|
||||
if (options.caps.isNotEmpty()) put("caps", JsonArray(options.caps.map(::JsonPrimitive)))
|
||||
if (options.commands.isNotEmpty()) put("commands", JsonArray(options.commands.map(::JsonPrimitive)))
|
||||
if (options.permissions.isNotEmpty()) {
|
||||
put(
|
||||
"permissions",
|
||||
buildJsonObject {
|
||||
options.permissions.forEach { (key, value) ->
|
||||
put(key, JsonPrimitive(value))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
put("role", JsonPrimitive(options.role))
|
||||
if (options.scopes.isNotEmpty()) put("scopes", JsonArray(options.scopes.map(::JsonPrimitive)))
|
||||
put("locale", JsonPrimitive(locale))
|
||||
}
|
||||
|
||||
val authToken = token?.trim().orEmpty()
|
||||
val authPassword = password?.trim().orEmpty()
|
||||
if (authToken.isNotEmpty()) {
|
||||
params["auth"] =
|
||||
buildJsonObject {
|
||||
put("token", JsonPrimitive(authToken))
|
||||
}
|
||||
} else if (authPassword.isNotEmpty()) {
|
||||
params["auth"] =
|
||||
buildJsonObject {
|
||||
put("password", JsonPrimitive(authPassword))
|
||||
}
|
||||
}
|
||||
val authJson =
|
||||
when {
|
||||
authToken.isNotEmpty() ->
|
||||
buildJsonObject {
|
||||
put("token", JsonPrimitive(authToken))
|
||||
}
|
||||
authPassword.isNotEmpty() ->
|
||||
buildJsonObject {
|
||||
put("password", JsonPrimitive(authPassword))
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
val identity = identityStore.loadOrCreate()
|
||||
val signedAtMs = System.currentTimeMillis()
|
||||
@@ -365,17 +344,40 @@ class GatewaySession(
|
||||
)
|
||||
val signature = identityStore.signPayload(payload, identity)
|
||||
val publicKey = identityStore.publicKeyBase64Url(identity)
|
||||
if (!signature.isNullOrBlank() && !publicKey.isNullOrBlank()) {
|
||||
params["device"] =
|
||||
val deviceJson =
|
||||
if (!signature.isNullOrBlank() && !publicKey.isNullOrBlank()) {
|
||||
buildJsonObject {
|
||||
put("id", JsonPrimitive(identity.deviceId))
|
||||
put("publicKey", JsonPrimitive(publicKey))
|
||||
put("signature", JsonPrimitive(signature))
|
||||
put("signedAt", JsonPrimitive(signedAtMs))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
return params
|
||||
return buildJsonObject {
|
||||
put("minProtocol", JsonPrimitive(GATEWAY_PROTOCOL_VERSION))
|
||||
put("maxProtocol", JsonPrimitive(GATEWAY_PROTOCOL_VERSION))
|
||||
put("client", clientObj)
|
||||
if (options.caps.isNotEmpty()) put("caps", JsonArray(options.caps.map(::JsonPrimitive)))
|
||||
if (options.commands.isNotEmpty()) put("commands", JsonArray(options.commands.map(::JsonPrimitive)))
|
||||
if (options.permissions.isNotEmpty()) {
|
||||
put(
|
||||
"permissions",
|
||||
buildJsonObject {
|
||||
options.permissions.forEach { (key, value) ->
|
||||
put(key, JsonPrimitive(value))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
put("role", JsonPrimitive(options.role))
|
||||
if (options.scopes.isNotEmpty()) put("scopes", JsonArray(options.scopes.map(::JsonPrimitive)))
|
||||
authJson?.let { put("auth", it) }
|
||||
deviceJson?.let { put("device", it) }
|
||||
put("locale", JsonPrimitive(locale))
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun handleMessage(text: String) {
|
||||
|
||||
@@ -309,11 +309,10 @@ fun SettingsSheet(viewModel: MainViewModel) {
|
||||
add("IP: ${gateway.host}:${gateway.port}")
|
||||
gateway.lanHost?.let { add("LAN: $it") }
|
||||
gateway.tailnetDns?.let { add("Tailnet: $it") }
|
||||
if (gateway.gatewayPort != null || gateway.bridgePort != null || gateway.canvasPort != null) {
|
||||
val gw = gateway.gatewayPort?.toString() ?: "—"
|
||||
val br = (gateway.bridgePort ?: gateway.port).toString()
|
||||
if (gateway.gatewayPort != null || gateway.canvasPort != null) {
|
||||
val gw = (gateway.gatewayPort ?: gateway.port).toString()
|
||||
val canvas = gateway.canvasPort?.toString() ?: "—"
|
||||
add("Ports: gw $gw · bridge $br · canvas $canvas")
|
||||
add("Ports: gw $gw · canvas $canvas")
|
||||
}
|
||||
}
|
||||
ListItem(
|
||||
|
||||
Reference in New Issue
Block a user