Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
feat(teamhub): send an availability reason code beside the English label
yunhe3f878eee82a1
diff --git a/apps/teamhub/internal/agentregistry/agent_registration.go b/apps/teamhub/internal/agentregistry/agent_registration.goindex 8a945c2f..0b879455 100644--- a/apps/teamhub/internal/agentregistry/agent_registration.go+++ b/apps/teamhub/internal/agentregistry/agent_registration.go@@ -50,7 +50,8 @@ func (s *Service) agentRepresentedHumanIdentity(func listedTenantAgentAvailability(row store.ListTenantAgentsForAccountRow) httpapi.TenantAgentAvailability {return httpapi.TenantAgentAvailability{- Status: httpapi.TenantAgentAvailabilityStatusOnline, Label: "Online", ActiveTaskCount: row.ActiveTaskCount,+ Status: httpapi.TenantAgentAvailabilityStatusOnline, Label: "Online",+ Reason: availabilityReason(httpapi.TenantAgentAvailabilityReasonOnline), ActiveTaskCount: row.ActiveTaskCount,}}@@ -98,18 +99,18 @@ func availabilityWithLocalRuntimeStatus(connectionUncertain := status.ConnectionStatus == "reconnecting" || status.ConnectionStatus == "unknown"if availability.Status != httpapi.TenantAgentAvailabilityStatusError &&(status.Status == "unknown" || (status.Status == "ready" && connectionUncertain)) {- label := "Status unavailable"+ label, reason := "Status unavailable", httpapi.TenantAgentAvailabilityReasonStatusUnavailableif status.ConnectionStatus == "reconnecting" {- label = "Reconnecting"+ label, reason = "Reconnecting", httpapi.TenantAgentAvailabilityReasonReconnecting}return httpapi.TenantAgentAvailability{Status: httpapi.TenantAgentAvailabilityStatusUnknown,- Label: label, ActiveTaskCount: availability.ActiveTaskCount,+ Label: label, Reason: availabilityReason(reason), ActiveTaskCount: availability.ActiveTaskCount,CurrentActivity: availability.CurrentActivity,}}if status.Status == "authentication_required" {- projected := offlineAgentAvailability("Authentication required")+ projected := offlineAgentAvailability(httpapi.TenantAgentAvailabilityReasonAuthenticationRequired, "Authentication required")projected.ActiveTaskCount = availability.ActiveTaskCountreturn projected}@@ -119,7 +120,7 @@ func availabilityWithLocalRuntimeStatus(}if status.ComputerStatus == "offline" || status.ErrorCode == "LOCAL_COMPUTER_OFFLINE" {// The Agent waits for its Computer and runs there once it connects.- projected := offlineAgentAvailability("Waiting for the computer to connect")+ projected := offlineAgentAvailability(httpapi.TenantAgentAvailabilityReasonWaitingForComputer, "Waiting for the computer to connect")projected.ActiveTaskCount = availability.ActiveTaskCountreturn projected}@@ -127,9 +128,16 @@ func availabilityWithLocalRuntimeStatus(if summary == "" {summary = "Local Runtime needs attention"}+ reason := httpapi.TenantAgentAvailabilityReasonRuntimeError+ switch status.Status {+ case "not_installed":+ reason = httpapi.TenantAgentAvailabilityReasonRuntimeNotInstalled+ case "incompatible":+ reason = httpapi.TenantAgentAvailabilityReasonRuntimeIncompatible+ }return httpapi.TenantAgentAvailability{Status: httpapi.TenantAgentAvailabilityStatusError,- Label: "Needs attention", ActiveTaskCount: availability.ActiveTaskCount,+ Label: "Needs attention", Reason: availabilityReason(reason), ActiveTaskCount: availability.ActiveTaskCount,CurrentActivity: &httpapi.TenantAgentCurrentActivity{Summary: truncateActivity(summary),},@@ -247,16 +255,22 @@ func listedTenantAgentModel()}-func offlineAgentAvailability(summary string) httpapi.TenantAgentAvailability {+func offlineAgentAvailability(reason httpapi.TenantAgentAvailabilityReason, summary string) httpapi.TenantAgentAvailability {return httpapi.TenantAgentAvailability{Status: httpapi.TenantAgentAvailabilityStatusOffline,- Label: "Offline",+ Label: "Offline", Reason: availabilityReason(reason),CurrentActivity: &httpapi.TenantAgentCurrentActivity{Summary: summary,},}}+// availabilityReason is the code clients word; Label and the summary stay+// the English wording for clients that do not know it.+func availabilityReason(reason httpapi.TenantAgentAvailabilityReason) *httpapi.TenantAgentAvailabilityReason {+ return &reason+}+func truncateActivity(value string) string {runes := []rune(strings.TrimSpace(value))if len(runes) <= 240 {diff --git a/apps/teamhub/internal/agentregistry/local_runtime_availability_test.go b/apps/teamhub/internal/agentregistry/local_runtime_availability_test.goindex 8216e4bf..f0a29e76 100644--- a/apps/teamhub/internal/agentregistry/local_runtime_availability_test.go+++ b/apps/teamhub/internal/agentregistry/local_runtime_availability_test.go@@ -110,3 +110,32 @@ func TestPersistedLocalRuntimeObservationSeparatesConnectionFromDiagnostics(t *t}})}++func TestAvailabilityCarriesReasonBesideEnglishLabel(t *testing.T) {+ online := listedTenantAgentAvailability(store.ListTenantAgentsForAccountRow{ActiveTaskCount: 1})+ for _, tc := range []struct {+ name string+ status roomagent.LocalAgentRuntimeStatus+ want httpapi.TenantAgentAvailabilityReason+ label string+ }{+ {"ready", roomagent.LocalAgentRuntimeStatus{ComputerStatus: "online", Status: "ready", ConnectionStatus: "connected"}, httpapi.TenantAgentAvailabilityReasonOnline, "Online"},+ {"unknown", roomagent.LocalAgentRuntimeStatus{Status: "unknown", ConnectionStatus: "unknown"}, httpapi.TenantAgentAvailabilityReasonStatusUnavailable, "Status unavailable"},+ {"reconnecting", roomagent.LocalAgentRuntimeStatus{Status: "ready", ConnectionStatus: "reconnecting"}, httpapi.TenantAgentAvailabilityReasonReconnecting, "Reconnecting"},+ {"sign-in", roomagent.LocalAgentRuntimeStatus{ComputerStatus: "online", Status: "authentication_required", ConnectionStatus: "connected"}, httpapi.TenantAgentAvailabilityReasonAuthenticationRequired, "Offline"},+ {"computer offline", roomagent.LocalAgentRuntimeStatus{ComputerStatus: "offline", Status: "error", ConnectionStatus: "connected", ErrorCode: "LOCAL_COMPUTER_OFFLINE"}, httpapi.TenantAgentAvailabilityReasonWaitingForComputer, "Offline"},+ {"not installed", roomagent.LocalAgentRuntimeStatus{ComputerStatus: "online", Status: "not_installed", ConnectionStatus: "connected"}, httpapi.TenantAgentAvailabilityReasonRuntimeNotInstalled, "Needs attention"},+ {"incompatible", roomagent.LocalAgentRuntimeStatus{ComputerStatus: "online", Status: "incompatible", ConnectionStatus: "connected"}, httpapi.TenantAgentAvailabilityReasonRuntimeIncompatible, "Needs attention"},+ {"error", roomagent.LocalAgentRuntimeStatus{ComputerStatus: "online", Status: "error", ConnectionStatus: "connected", Message: "Probe failed"}, httpapi.TenantAgentAvailabilityReasonRuntimeError, "Needs attention"},+ } {+ t.Run(tc.name, func(t *testing.T) {+ projected := availabilityWithLocalRuntimeStatus(online, tc.status)+ if projected.Reason == nil || *projected.Reason != tc.want || projected.Label != tc.label {+ t.Fatalf("availability = %+v, reason = %v", projected, projected.Reason)+ }+ if !projected.Reason.Valid() {+ t.Fatalf("reason %q is not in the contract enum", *projected.Reason)+ }+ })+ }+}diff --git a/contracts/generated/go/teamhubpublic/openapi.gen.go b/contracts/generated/go/teamhubpublic/openapi.gen.goindex 36f90f7a..67eeffb5 100644--- a/contracts/generated/go/teamhubpublic/openapi.gen.go+++ b/contracts/generated/go/teamhubpublic/openapi.gen.go@@ -3773,6 +3773,42 @@ func (e TeamMdPattern) Valid() bool {}}+// Defines values for TenantAgentAvailabilityReason.+const (+ TenantAgentAvailabilityReasonAuthenticationRequired TenantAgentAvailabilityReason = "authentication_required"+ TenantAgentAvailabilityReasonOnline TenantAgentAvailabilityReason = "online"+ TenantAgentAvailabilityReasonReconnecting TenantAgentAvailabilityReason = "reconnecting"+ TenantAgentAvailabilityReasonRuntimeError TenantAgentAvailabilityReason = "runtime_error"+ TenantAgentAvailabilityReasonRuntimeIncompatible TenantAgentAvailabilityReason = "runtime_incompatible"+ TenantAgentAvailabilityReasonRuntimeNotInstalled TenantAgentAvailabilityReason = "runtime_not_installed"+ TenantAgentAvailabilityReasonStatusUnavailable TenantAgentAvailabilityReason = "status_unavailable"+ TenantAgentAvailabilityReasonWaitingForComputer TenantAgentAvailabilityReason = "waiting_for_computer"+)++// Valid indicates whether the value is a known member of the TenantAgentAvailabilityReason enum.+func (e TenantAgentAvailabilityReason) Valid() bool {+ switch e {+ case TenantAgentAvailabilityReasonAuthenticationRequired:+ return true+ case TenantAgentAvailabilityReasonOnline:+ return true+ case TenantAgentAvailabilityReasonReconnecting:+ return true+ case TenantAgentAvailabilityReasonRuntimeError:+ return true+ case TenantAgentAvailabilityReasonRuntimeIncompatible:+ return true+ case TenantAgentAvailabilityReasonRuntimeNotInstalled:+ return true+ case TenantAgentAvailabilityReasonStatusUnavailable:+ return true+ case TenantAgentAvailabilityReasonWaitingForComputer:+ return true+ default:+ return false+ }+}+// Defines values for TenantAgentAvailabilityStatus.const (TenantAgentAvailabilityStatusError TenantAgentAvailabilityStatus = "error"@@ -9170,7 +9206,12 @@ type TenantAgentAvailability struct {// ActiveTaskCount Number of non-terminal managed Tasks assigned to this Agent.ActiveTaskCount int64 `json:"active_task_count"`CurrentActivity *TenantAgentCurrentActivity `json:"current_activity,omitempty"`- Label string `json:"label"`++ // Label English wording of the status, the fallback for clients that do not know `reason`.+ Label string `json:"label"`++ // Reason Why the Agent has its status, as a stable code clients word in their own language. `label` and `current_activity.summary` carry the same state in English for clients that do not know the code. With `runtime_error` the summary is the Runtime's own diagnostic text.+ Reason *TenantAgentAvailabilityReason `json:"reason,omitempty"`// Status Runtime availability. Managed Task execution is represented by active_task_count.Status TenantAgentAvailabilityStatus `json:"status"`@@ -9182,6 +9223,9 @@ type TenantAgentAvailabilityPage struct {Page PageMeta `json:"page"`}+// TenantAgentAvailabilityReason Why the Agent has its status, as a stable code clients word in their own language. `label` and `current_activity.summary` carry the same state in English for clients that do not know the code. With `runtime_error` the summary is the Runtime's own diagnostic text.+type TenantAgentAvailabilityReason string+// TenantAgentAvailabilitySnapshot defines model for TenantAgentAvailabilitySnapshot.type TenantAgentAvailabilitySnapshot struct {// ActorId Opaque, case-sensitive identifier. Clients must not infer type or time from it.diff --git a/contracts/generated/typescript/src/generated/teamhub-public/types.ts b/contracts/generated/typescript/src/generated/teamhub-public/types.tsindex 061c6e88..f8f9403f 100644--- a/contracts/generated/typescript/src/generated/teamhub-public/types.ts+++ b/contracts/generated/typescript/src/generated/teamhub-public/types.ts@@ -4423,6 +4423,19 @@ export interface components {* @enum {string}*/TenantAgentAvailabilityStatus: "online" | "error" | "offline" | "unknown";+ /**+ * @description Why the Agent has its status, as a stable code clients word in their own language. `label` and `current_activity.summary` carry the same state in English for clients that do not know the code. With `runtime_error` the summary is the Runtime's own diagnostic text.+ * @enum {string}+ */+ TenantAgentAvailabilityReason:+ | "online"+ | "status_unavailable"+ | "reconnecting"+ | "authentication_required"+ | "waiting_for_computer"+ | "runtime_not_installed"+ | "runtime_incompatible"+ | "runtime_error";TenantAgentCurrentActivity: {summary: string;run_id?: components["schemas"]["Id"];@@ -4430,7 +4443,9 @@ export interface components {};TenantAgentAvailability: {status: components["schemas"]["TenantAgentAvailabilityStatus"];+ /** @description English wording of the status, the fallback for clients that do not know `reason`. */label: string;+ reason?: components["schemas"]["TenantAgentAvailabilityReason"];/*** Format: int64* @description Number of non-terminal managed Tasks assigned to this Agent.diff --git a/contracts/openapi/components/domain.yaml b/contracts/openapi/components/domain.yamlindex a7716756..d3418122 100644--- a/contracts/openapi/components/domain.yaml+++ b/contracts/openapi/components/domain.yaml@@ -511,6 +511,24 @@ components:type: stringenum: [online, error, offline, unknown]description: Runtime availability. Managed Task execution is represented by active_task_count.+ TenantAgentAvailabilityReason:+ type: string+ enum:+ [+ online,+ status_unavailable,+ reconnecting,+ authentication_required,+ waiting_for_computer,+ runtime_not_installed,+ runtime_incompatible,+ runtime_error,+ ]+ description: >-+ Why the Agent has its status, as a stable code clients word in their own language.+ `label` and `current_activity.summary` carry the same state in English for clients+ that do not know the code. With `runtime_error` the summary is the Runtime's own+ diagnostic text.TenantAgentCurrentActivity:type: objectadditionalProperties: false@@ -535,6 +553,9 @@ components:type: stringminLength: 1maxLength: 120+ description: English wording of the status, the fallback for clients that do not know `reason`.+ reason:+ $ref: "#/components/schemas/TenantAgentAvailabilityReason"active_task_count:type: integerformat: int64