Presence: add device identity fields

This commit is contained in:
Peter Steinberger
2025-12-17 21:17:51 +01:00
parent 9d29fbbf80
commit 51bdf01e2e
7 changed files with 29 additions and 4 deletions

View File

@@ -28,6 +28,9 @@ class BridgePairingClient {
val deviceFamily: String?,
val modelIdentifier: 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)

View File

@@ -43,6 +43,9 @@ class BridgeSession(
val deviceFamily: String?,
val modelIdentifier: 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?)

View File

@@ -46,6 +46,8 @@ class BridgePairingClientTest {
token = "token-123",
platform = "Android",
version = "test",
deviceFamily = "Android",
modelIdentifier = "SM-X000",
),
)
assertTrue(res.ok)
@@ -91,6 +93,8 @@ class BridgePairingClientTest {
token = null,
platform = "Android",
version = "test",
deviceFamily = "Android",
modelIdentifier = "SM-X000",
),
)
assertTrue(res.ok)
@@ -98,4 +102,3 @@ class BridgePairingClientTest {
server.await()
}
}

View File

@@ -1,4 +1,5 @@
import ClawdisKit
import Darwin
import Foundation
import Network
import Observation

View File

@@ -136,12 +136,12 @@ struct InstancesSettings: View {
}
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 model = inst.modelIdentifier?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
if !family.isEmpty, !model.isEmpty { return "\(family) (\(model))" }
if !model.isEmpty { return model }
return family.isEmpty ? nil : family
}
private func prettyPlatform(_ raw: String) -> String? {
let (prefix, version) = self.parsePlatform(raw)
if prefix.isEmpty { return nil }

View File

@@ -69,6 +69,8 @@ export const ConnectParamsSchema = Type.Object(
modelIdentifier: Type.Optional(NonEmptyString),
mode: NonEmptyString,
instanceId: Type.Optional(NonEmptyString),
deviceFamily: Type.Optional(NonEmptyString),
modelIdentifier: Type.Optional(NonEmptyString),
},
{ additionalProperties: false },
),

View File

@@ -1,3 +1,4 @@
import { spawnSync } from "node:child_process";
import os from "node:os";
export type SystemPresence = {
@@ -49,6 +50,17 @@ function initSelfPresence() {
const ip = resolvePrimaryIPv4() ?? undefined;
const version =
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 p = os.platform();
const rel = os.release();
@@ -70,6 +82,7 @@ function initSelfPresence() {
version,
platform,
deviceFamily,
modelIdentifier,
mode: "gateway",
reason: "self",
text,