Presence: add device identity fields
This commit is contained in:
@@ -28,6 +28,9 @@ class BridgePairingClient {
|
|||||||
val deviceFamily: String?,
|
val deviceFamily: String?,
|
||||||
val modelIdentifier: String?,
|
val modelIdentifier: String?,
|
||||||
val caps: List<String>?,
|
val caps: List<String>?,
|
||||||
|
val deviceFamily: String?,
|
||||||
|
val modelIdentifier: String?,
|
||||||
|
val caps: List<String>?,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class PairResult(val ok: Boolean, val token: String?, val error: String? = null)
|
data class PairResult(val ok: Boolean, val token: String?, val error: String? = null)
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ class BridgeSession(
|
|||||||
val deviceFamily: String?,
|
val deviceFamily: String?,
|
||||||
val modelIdentifier: String?,
|
val modelIdentifier: String?,
|
||||||
val caps: List<String>?,
|
val caps: List<String>?,
|
||||||
|
val deviceFamily: String?,
|
||||||
|
val modelIdentifier: String?,
|
||||||
|
val caps: List<String>?,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class InvokeRequest(val id: String, val command: String, val paramsJson: String?)
|
data class InvokeRequest(val id: String, val command: String, val paramsJson: String?)
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class BridgePairingClientTest {
|
|||||||
token = "token-123",
|
token = "token-123",
|
||||||
platform = "Android",
|
platform = "Android",
|
||||||
version = "test",
|
version = "test",
|
||||||
|
deviceFamily = "Android",
|
||||||
|
modelIdentifier = "SM-X000",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertTrue(res.ok)
|
assertTrue(res.ok)
|
||||||
@@ -91,6 +93,8 @@ class BridgePairingClientTest {
|
|||||||
token = null,
|
token = null,
|
||||||
platform = "Android",
|
platform = "Android",
|
||||||
version = "test",
|
version = "test",
|
||||||
|
deviceFamily = "Android",
|
||||||
|
modelIdentifier = "SM-X000",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assertTrue(res.ok)
|
assertTrue(res.ok)
|
||||||
@@ -98,4 +102,3 @@ class BridgePairingClientTest {
|
|||||||
server.await()
|
server.await()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import ClawdisKit
|
import ClawdisKit
|
||||||
|
import Darwin
|
||||||
import Foundation
|
import Foundation
|
||||||
import Network
|
import Network
|
||||||
import Observation
|
import Observation
|
||||||
|
|||||||
@@ -136,12 +136,12 @@ struct InstancesSettings: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func deviceDescription(_ inst: InstanceInfo) -> String? {
|
private func deviceDescription(_ inst: InstanceInfo) -> String? {
|
||||||
let model = inst.modelIdentifier?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
||||||
if !model.isEmpty { return model }
|
|
||||||
let family = inst.deviceFamily?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
let family = inst.deviceFamily?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||||
|
let model = inst.modelIdentifier?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
||||||
|
if !family.isEmpty, !model.isEmpty { return "\(family) (\(model))" }
|
||||||
|
if !model.isEmpty { return model }
|
||||||
return family.isEmpty ? nil : family
|
return family.isEmpty ? nil : family
|
||||||
}
|
}
|
||||||
|
|
||||||
private func prettyPlatform(_ raw: String) -> String? {
|
private func prettyPlatform(_ raw: String) -> String? {
|
||||||
let (prefix, version) = self.parsePlatform(raw)
|
let (prefix, version) = self.parsePlatform(raw)
|
||||||
if prefix.isEmpty { return nil }
|
if prefix.isEmpty { return nil }
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ export const ConnectParamsSchema = Type.Object(
|
|||||||
modelIdentifier: Type.Optional(NonEmptyString),
|
modelIdentifier: Type.Optional(NonEmptyString),
|
||||||
mode: NonEmptyString,
|
mode: NonEmptyString,
|
||||||
instanceId: Type.Optional(NonEmptyString),
|
instanceId: Type.Optional(NonEmptyString),
|
||||||
|
deviceFamily: Type.Optional(NonEmptyString),
|
||||||
|
modelIdentifier: Type.Optional(NonEmptyString),
|
||||||
},
|
},
|
||||||
{ additionalProperties: false },
|
{ additionalProperties: false },
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { spawnSync } from "node:child_process";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
|
|
||||||
export type SystemPresence = {
|
export type SystemPresence = {
|
||||||
@@ -49,6 +50,17 @@ function initSelfPresence() {
|
|||||||
const ip = resolvePrimaryIPv4() ?? undefined;
|
const ip = resolvePrimaryIPv4() ?? undefined;
|
||||||
const version =
|
const version =
|
||||||
process.env.CLAWDIS_VERSION ?? process.env.npm_package_version ?? "unknown";
|
process.env.CLAWDIS_VERSION ?? process.env.npm_package_version ?? "unknown";
|
||||||
|
const modelIdentifier = (() => {
|
||||||
|
const p = os.platform();
|
||||||
|
if (p === "darwin") {
|
||||||
|
const res = spawnSync("sysctl", ["-n", "hw.model"], {
|
||||||
|
encoding: "utf-8",
|
||||||
|
});
|
||||||
|
const out = typeof res.stdout === "string" ? res.stdout.trim() : "";
|
||||||
|
return out.length > 0 ? out : undefined;
|
||||||
|
}
|
||||||
|
return os.arch();
|
||||||
|
})();
|
||||||
const platform = (() => {
|
const platform = (() => {
|
||||||
const p = os.platform();
|
const p = os.platform();
|
||||||
const rel = os.release();
|
const rel = os.release();
|
||||||
@@ -70,6 +82,7 @@ function initSelfPresence() {
|
|||||||
version,
|
version,
|
||||||
platform,
|
platform,
|
||||||
deviceFamily,
|
deviceFamily,
|
||||||
|
modelIdentifier,
|
||||||
mode: "gateway",
|
mode: "gateway",
|
||||||
reason: "self",
|
reason: "self",
|
||||||
text,
|
text,
|
||||||
|
|||||||
Reference in New Issue
Block a user