The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(metrics): hermes.desktop.* contract, schema and gateway RPCs
teknium16c143c238fe2
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex 9d5b69dbb48..ea0e63f3a97 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -687,6 +687,54 @@ export interface SharedMetricsUpdateRunParams {export interface SharedMetricsUpdateRunResult {ok: boolean}+/** ``area`` is a Desktop surface id (``command_palette``, ``terminal_pane``, ``settings_<view>`` …); the backend collapses anything outside its closed set to ``other``. */+export interface SharedMetricsDesktopFeatureUseParams {+ profile?: string | null+ area: string+}+export interface OkResult {+ ok?: boolean+}+/** ``kind`` notice_dismissed|error_toast|renderer_crash|backend_disconnect|slow_frame; ``detail`` a closed code-defined word for that kind (notice id, error category, crash reason, drop reason, frame duration bucket), never message text. */+export interface SharedMetricsDesktopFrictionParams {+ profile?: string | null+ kind: string+ detail: string+}+/** ``step`` a Desktop first-run step id; ``event`` reached|completed|abandoned. */+export interface SharedMetricsDesktopOnboardingParams {+ profile?: string | null+ step: string+ event: string+}+/** ``signal`` quick_close|cancelled|setting_off_default|rage_click|undo|feature_disabled; ``target`` a closed code-defined id for that signal (area, flow, action, undo path, feature toggle); ``setting`` a config key for setting_off_default only (the value is never sent — the backend compares it to the default). */+export interface SharedMetricsDesktopDislikeParams {+ profile?: string | null+ signal: string+ target?: string+ setting?: string | null+}+/** One finished UTC day of Desktop use, aggregated on the client. ``day`` (YYYY-MM-DD) only latches a resend and is never recorded; the raw counts are bucketed by the backend. */+export interface SharedMetricsDesktopDailyParams {+ profile?: string | null+ day: string+ bot_count?: number+ modes?: SharedMetricsDesktopModeDay[]+ actions?: SharedMetricsDesktopActionDay[]+}+export interface SharedMetricsDesktopModeDay {+ mode: 'bots' | 'sessions'+ active_ms?: number+ messages_sent?: number+}+export interface SharedMetricsDesktopActionDay {+ action: string+ via: 'click' | 'menu' | 'palette' | 'shortcut'+ count: number+}+export interface SharedMetricsDesktopDailyResult {+ recorded: boolean+}export interface ModelOptionsParams {profile?: string | nullsession_id?: string | null@@ -1702,9 +1750,6 @@ export interface BotRelayReplyParams {error?: string | nullreason?: string | null}-export interface OkResult {- ok?: boolean-}export interface BrowserControllerRegisterParams {session_id: stringcontroller_id: string@@ -5181,6 +5226,16 @@ export interface RpcMethods {'setup.runtime_check': { params: SetupRuntimeCheckParams; result: SetupRuntimeCheckResult }/** Loose provider check: is ANY provider auth state discoverable for the (launch or named) profile. */'setup.status': { params: ProfileParams; result: SetupStatusResult }+ /** Record one finished Desktop day (mode use + button presses); recorded=false keeps it for a retry. */+ 'shared_metrics.desktop_daily': { params: SharedMetricsDesktopDailyParams; result: SharedMetricsDesktopDailyResult }+ /** Count one Desktop dislike signal (fire-and-forget; capped per signal per day; a no-op unless on). */+ 'shared_metrics.desktop_dislike': { params: SharedMetricsDesktopDislikeParams; result: OkResult }+ /** Count one Desktop area used today (fire-and-forget; once per area per UTC day; a no-op unless on). */+ 'shared_metrics.desktop_feature_use': { params: SharedMetricsDesktopFeatureUseParams; result: OkResult }+ /** Count one Desktop friction event (fire-and-forget; capped per day; a no-op unless on). */+ 'shared_metrics.desktop_friction': { params: SharedMetricsDesktopFrictionParams; result: OkResult }+ /** Count one Desktop first-run step transition (fire-and-forget; once per step+event; a no-op unless on). */+ 'shared_metrics.desktop_onboarding': { params: SharedMetricsDesktopOnboardingParams; result: OkResult }/** Write both shared-metrics opt-ins at once (send requires collection) and reconcile consent windows. */'shared_metrics.set': { params: SharedMetricsSetParams; result: SharedMetricsConsentResult }/** Count one user-typed slash command (fire-and-forget; a no-op unless shared metrics are on). */@@ -5473,6 +5528,11 @@ export const RPC_METHODS = ['session.workspace.move','setup.runtime_check','setup.status',+ 'shared_metrics.desktop_daily',+ 'shared_metrics.desktop_dislike',+ 'shared_metrics.desktop_feature_use',+ 'shared_metrics.desktop_friction',+ 'shared_metrics.desktop_onboarding','shared_metrics.set','shared_metrics.slash_command','shared_metrics.startup_latency',diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex 82e5b6fb11b..40441393eb9 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -3588,6 +3588,96 @@}}},+ {+ "name": "shared_metrics.desktop_daily",+ "summary": "Record one finished Desktop day (mode use + button presses); recorded=false keeps it for a retry.",+ "params": [+ {+ "name": "params",+ "schema": {+ "$ref": "#/components/schemas/SharedMetricsDesktopDailyParams"+ }+ }+ ],+ "result": {+ "name": "result",+ "schema": {+ "$ref": "#/components/schemas/SharedMetricsDesktopDailyResult"+ }+ }+ },+ {+ "name": "shared_metrics.desktop_dislike",+ "summary": "Count one Desktop dislike signal (fire-and-forget; capped per signal per day; a no-op unless on).",+ "params": [+ {+ "name": "params",+ "schema": {+ "$ref": "#/components/schemas/SharedMetricsDesktopDislikeParams"+ }+ }+ ],+ "result": {+ "name": "result",+ "schema": {+ "$ref": "#/components/schemas/OkResult"+ }+ }+ },+ {+ "name": "shared_metrics.desktop_feature_use",+ "summary": "Count one Desktop area used today (fire-and-forget; once per area per UTC day; a no-op unless on).",+ "params": [+ {+ "name": "params",+ "schema": {+ "$ref": "#/components/schemas/SharedMetricsDesktopFeatureUseParams"+ }+ }+ ],+ "result": {+ "name": "result",+ "schema": {+ "$ref": "#/components/schemas/OkResult"+ }+ }+ },+ {+ "name": "shared_metrics.desktop_friction",+ "summary": "Count one Desktop friction event (fire-and-forget; capped per day; a no-op unless on).",+ "params": [+ {+ "name": "params",+ "schema": {+ "$ref": "#/components/schemas/SharedMetricsDesktopFrictionParams"+ }+ }+ ],+ "result": {+ "name": "result",+ "schema": {+ "$ref": "#/components/schemas/OkResult"+ }+ }+ },+ {+ "name": "shared_metrics.desktop_onboarding",+ "summary": "Count one Desktop first-run step transition (fire-and-forget; once per step+event; a no-op unless on).",+ "params": [+ {+ "name": "params",+ "schema": {+ "$ref": "#/components/schemas/SharedMetricsDesktopOnboardingParams"+ }+ }+ ],+ "result": {+ "name": "result",+ "schema": {+ "$ref": "#/components/schemas/OkResult"+ }+ }+ },{"name": "shared_metrics.set","summary": "Write both shared-metrics opt-ins at once (send requires collection) and reconcile consent windows.",@@ -31980,6 +32070,259 @@"title": "SharedMetricsConsentResult","type": "object"},+ "SharedMetricsDesktopActionDay": {+ "additionalProperties": false,+ "properties": {+ "action": {+ "title": "Action",+ "type": "string"+ },+ "via": {+ "enum": [+ "click",+ "menu",+ "palette",+ "shortcut"+ ],+ "title": "Via",+ "type": "string"+ },+ "count": {+ "title": "Count",+ "type": "integer"+ }+ },+ "required": [+ "action",+ "via",+ "count"+ ],+ "title": "SharedMetricsDesktopActionDay",+ "type": "object"+ },+ "SharedMetricsDesktopDailyParams": {+ "additionalProperties": false,+ "description": "One finished UTC day of Desktop use, aggregated on the client. ``day`` (YYYY-MM-DD) only latches\na resend and is never recorded; the raw counts are bucketed by the backend.",+ "properties": {+ "profile": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Profile"+ },+ "day": {+ "title": "Day",+ "type": "string"+ },+ "bot_count": {+ "default": 0,+ "title": "Bot Count",+ "type": "integer"+ },+ "modes": {+ "items": {+ "$ref": "#/components/schemas/SharedMetricsDesktopModeDay"+ },+ "title": "Modes",+ "type": "array"+ },+ "actions": {+ "items": {+ "$ref": "#/components/schemas/SharedMetricsDesktopActionDay"+ },+ "title": "Actions",+ "type": "array"+ }+ },+ "required": [+ "day"+ ],+ "title": "SharedMetricsDesktopDailyParams",+ "type": "object"+ },+ "SharedMetricsDesktopDailyResult": {+ "additionalProperties": false,+ "properties": {+ "recorded": {+ "title": "Recorded",+ "type": "boolean"+ }+ },+ "required": [+ "recorded"+ ],+ "title": "SharedMetricsDesktopDailyResult",+ "type": "object"+ },+ "SharedMetricsDesktopDislikeParams": {+ "additionalProperties": false,+ "description": "``signal`` quick_close|cancelled|setting_off_default|rage_click|undo|feature_disabled; ``target`` a\nclosed code-defined id for that signal (area, flow, action, undo path, feature toggle); ``setting`` a\nconfig key for setting_off_default only (the value is never sent \u2014 the backend compares it to the\ndefault).",+ "properties": {+ "profile": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Profile"+ },+ "signal": {+ "title": "Signal",+ "type": "string"+ },+ "target": {+ "default": "",+ "title": "Target",+ "type": "string"+ },+ "setting": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Setting"+ }+ },+ "required": [+ "signal"+ ],+ "title": "SharedMetricsDesktopDislikeParams",+ "type": "object"+ },+ "SharedMetricsDesktopFeatureUseParams": {+ "additionalProperties": false,+ "description": "``area`` is a Desktop surface id (``command_palette``, ``terminal_pane``, ``settings_<view>`` \u2026);\nthe backend collapses anything outside its closed set to ``other``.",+ "properties": {+ "profile": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Profile"+ },+ "area": {+ "title": "Area",+ "type": "string"+ }+ },+ "required": [+ "area"+ ],+ "title": "SharedMetricsDesktopFeatureUseParams",+ "type": "object"+ },+ "SharedMetricsDesktopFrictionParams": {+ "additionalProperties": false,+ "description": "``kind`` notice_dismissed|error_toast|renderer_crash|backend_disconnect|slow_frame; ``detail`` a\nclosed code-defined word for that kind (notice id, error category, crash reason, drop reason, frame\nduration bucket), never message text.",+ "properties": {+ "profile": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Profile"+ },+ "kind": {+ "title": "Kind",+ "type": "string"+ },+ "detail": {+ "title": "Detail",+ "type": "string"+ }+ },+ "required": [+ "kind",+ "detail"+ ],+ "title": "SharedMetricsDesktopFrictionParams",+ "type": "object"+ },+ "SharedMetricsDesktopModeDay": {+ "additionalProperties": false,+ "properties": {+ "mode": {+ "enum": [+ "bots",+ "sessions"+ ],+ "title": "Mode",+ "type": "string"+ },+ "active_ms": {+ "default": 0,+ "title": "Active Ms",+ "type": "number"+ },+ "messages_sent": {+ "default": 0,+ "title": "Messages Sent",+ "type": "integer"+ }+ },+ "required": [+ "mode"+ ],+ "title": "SharedMetricsDesktopModeDay",+ "type": "object"+ },+ "SharedMetricsDesktopOnboardingParams": {+ "additionalProperties": false,+ "description": "``step`` a Desktop first-run step id; ``event`` reached|completed|abandoned.",+ "properties": {+ "profile": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Profile"+ },+ "step": {+ "title": "Step",+ "type": "string"+ },+ "event": {+ "title": "Event",+ "type": "string"+ }+ },+ "required": [+ "step",+ "event"+ ],+ "title": "SharedMetricsDesktopOnboardingParams",+ "type": "object"+ },"SharedMetricsSetParams": {"additionalProperties": false,"description": "``send`` is ignored unless ``enabled``; ``first_run`` marks the Desktop first-run answer.",diff --git a/hermes_cli/observability/schemas/hermes.shared_metrics.v3.schema.json b/hermes_cli/observability/schemas/hermes.shared_metrics.v3.schema.jsonindex 4a09969beba..ef148b1748d 100644--- a/hermes_cli/observability/schemas/hermes.shared_metrics.v3.schema.json+++ b/hermes_cli/observability/schemas/hermes.shared_metrics.v3.schema.json@@ -237,6 +237,24 @@},{"$ref": "#/$defs/model_switch_after_counter"+ },+ {+ "$ref": "#/$defs/desktop_feature_use_counter"+ },+ {+ "$ref": "#/$defs/desktop_friction_counter"+ },+ {+ "$ref": "#/$defs/desktop_onboarding_counter"+ },+ {+ "$ref": "#/$defs/desktop_mode_use_counter"+ },+ {+ "$ref": "#/$defs/desktop_action_use_counter"+ },+ {+ "$ref": "#/$defs/desktop_dislike_counter"}]}@@ -3452,6 +3470,646 @@"251_to_1000","gte_1001"]+ },+ "desktop_feature_use_counter": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "type",+ "dimensions",+ "value"+ ],+ "properties": {+ "name": {+ "const": "hermes.desktop.feature_use"+ },+ "type": {+ "const": "counter"+ },+ "dimensions": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "area"+ ],+ "properties": {+ "area": {+ "enum": [+ "agents",+ "artifacts",+ "bot_mode",+ "browser_pane",+ "capabilities",+ "command_center",+ "command_palette",+ "cron",+ "extension_page",+ "file_pane",+ "find_in_page",+ "kanban",+ "messaging",+ "model_picker",+ "other",+ "profiles",+ "projects",+ "review_pane",+ "session_import",+ "session_picker",+ "session_search",+ "session_switcher",+ "settings_about",+ "settings_billing",+ "settings_config_advanced",+ "settings_config_appearance",+ "settings_config_browser",+ "settings_config_chat",+ "settings_config_memory",+ "settings_config_model",+ "settings_config_safety",+ "settings_config_voice",+ "settings_config_workspace",+ "settings_gateway",+ "settings_keybinds",+ "settings_keys",+ "settings_notifications",+ "settings_other",+ "settings_providers",+ "settings_sessions",+ "settings_vault",+ "skins",+ "starmap",+ "terminal_pane",+ "voice_conversation",+ "voice_dictation",+ "webhooks"+ ]+ }+ }+ },+ "value": {+ "type": "integer",+ "minimum": 1+ }+ }+ },+ "desktop_friction_counter": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "type",+ "dimensions",+ "value"+ ],+ "properties": {+ "name": {+ "const": "hermes.desktop.friction"+ },+ "type": {+ "const": "counter"+ },+ "dimensions": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "detail",+ "kind"+ ],+ "properties": {+ "detail": {+ "enum": [+ "100ms_to_250ms",+ "1s_to_5s",+ "250ms_to_1s",+ "api_key_missing",+ "api_key_rejected",+ "artifacts_partial_load",+ "backend_exit",+ "backend_skew",+ "background_queue_stuck",+ "billing_banner",+ "billing_block",+ "build_discontinued",+ "client_behind",+ "composer_queue_stuck",+ "crash",+ "credits",+ "disk_full",+ "free_tier_notice",+ "gateway_auth_failed",+ "gateway_error",+ "gte_5s",+ "gui_skew",+ "install_method",+ "killed",+ "mcp_health",+ "method_not_allowed",+ "microphone_permission",+ "model_warning",+ "network",+ "onboarding_handoff",+ "oom",+ "other",+ "pool_slot_timeout",+ "restart_required",+ "restored_draft",+ "rpc_out_of_sync",+ "runtime_not_ready",+ "session_compress",+ "storage_failure",+ "terminal_backend",+ "timeout",+ "tip",+ "unclassified",+ "update_available",+ "voice_live_unavailable",+ "voice_stop_hint"+ ]+ },+ "kind": {+ "enum": [+ "backend_disconnect",+ "error_toast",+ "notice_dismissed",+ "renderer_crash",+ "slow_frame"+ ]+ }+ }+ },+ "value": {+ "type": "integer",+ "minimum": 1+ }+ }+ },+ "desktop_onboarding_counter": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "type",+ "dimensions",+ "value"+ ],+ "properties": {+ "name": {+ "const": "hermes.desktop.onboarding"+ },+ "type": {+ "const": "counter"+ },+ "dimensions": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "event",+ "step"+ ],+ "properties": {+ "event": {+ "enum": [+ "abandoned",+ "completed",+ "reached"+ ]+ },+ "step": {+ "enum": [+ "choose_later",+ "consent",+ "first_message",+ "free_tier_ready",+ "guide",+ "guide_connectors",+ "guide_first_build",+ "guide_layout",+ "guide_look",+ "guide_skip",+ "intro",+ "model_pick",+ "provider_api_key",+ "provider_local",+ "provider_oauth",+ "provider_setup",+ "sign_in"+ ]+ }+ }+ },+ "value": {+ "type": "integer",+ "minimum": 1+ }+ }+ },+ "desktop_mode_use_counter": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "type",+ "dimensions",+ "value"+ ],+ "properties": {+ "name": {+ "const": "hermes.desktop.mode_use"+ },+ "type": {+ "const": "counter"+ },+ "dimensions": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "active_minutes_bucket",+ "bot_count_bucket",+ "messages_sent_bucket",+ "mode"+ ],+ "properties": {+ "active_minutes_bucket": {+ "enum": [+ "0",+ "2h_to_6h",+ "30m_to_2h",+ "5m_to_30m",+ "gte_6h",+ "lt_5m"+ ]+ },+ "bot_count_bucket": {+ "enum": [+ "0",+ "1",+ "101_to_250",+ "11_to_25",+ "2",+ "26_to_100",+ "3_to_5",+ "6_to_10",+ "gte_251"+ ]+ },+ "messages_sent_bucket": {+ "enum": [+ "0",+ "1",+ "101_to_250",+ "11_to_25",+ "2",+ "26_to_100",+ "3_to_5",+ "6_to_10",+ "gte_251"+ ]+ },+ "mode": {+ "enum": [+ "bots",+ "sessions"+ ]+ }+ }+ },+ "value": {+ "type": "integer",+ "minimum": 1+ }+ }+ },+ "desktop_action_use_counter": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "type",+ "dimensions",+ "value"+ ],+ "properties": {+ "name": {+ "const": "hermes.desktop.action_use"+ },+ "type": {+ "const": "counter"+ },+ "dimensions": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "action",+ "count_bucket",+ "via"+ ],+ "properties": {+ "action": {+ "enum": [+ "appearance.toggleMode",+ "composer.attach",+ "composer.cancel",+ "composer.dictate",+ "composer.focus",+ "composer.help",+ "composer.history",+ "composer.mention",+ "composer.modelPicker",+ "composer.newline",+ "composer.queue",+ "composer.reasoningDown",+ "composer.reasoningUp",+ "composer.send",+ "composer.sendQueued",+ "composer.slash",+ "composer.steer",+ "composer.voice",+ "conversation.scrollPageDown",+ "conversation.scrollPageUp",+ "hud.snapToPointer",+ "keybinds.openPanel",+ "message.copy",+ "message.retry",+ "nav.agents",+ "nav.artifacts",+ "nav.capabilities",+ "nav.commandCenter",+ "nav.commandPalette",+ "nav.cron",+ "nav.messaging",+ "nav.profiles",+ "nav.settings",+ "other",+ "profile.create",+ "profile.default",+ "profile.next",+ "profile.prev",+ "profile.toggleAll",+ "session.archive",+ "session.focusSearch",+ "session.new",+ "session.newTab",+ "session.newWindow",+ "session.next",+ "session.prev",+ "session.togglePin",+ "view.closeTab",+ "view.closeTerminal",+ "view.cycleSidebarGrouping",+ "view.findInPage",+ "view.findNext",+ "view.findPrevious",+ "view.flipPanes",+ "view.newTerminal",+ "view.nextTerminal",+ "view.prevTerminal",+ "view.reopenTab",+ "view.selectionToComposer",+ "view.showBrowser",+ "view.showFiles",+ "view.showTerminal",+ "view.terminalCopy",+ "view.terminalPaste",+ "view.toggleHud",+ "view.toggleProfileRail",+ "view.toggleReview",+ "view.toggleRightSidebar",+ "view.toggleSidebar",+ "view.toggleSimpleMode",+ "view.toggleStatusbar",+ "view.toggleTabStrip",+ "workspace.newWorktree",+ "workspace.openFolder"+ ]+ },+ "count_bucket": {+ "enum": [+ "0",+ "1",+ "101_to_250",+ "11_to_25",+ "2",+ "26_to_100",+ "3_to_5",+ "6_to_10",+ "gte_251"+ ]+ },+ "via": {+ "enum": [+ "click",+ "menu",+ "palette",+ "shortcut"+ ]+ }+ }+ },+ "value": {+ "type": "integer",+ "minimum": 1+ }+ }+ },+ "desktop_dislike_counter": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "name",+ "type",+ "dimensions",+ "value"+ ],+ "properties": {+ "name": {+ "const": "hermes.desktop.dislike"+ },+ "type": {+ "const": "counter"+ },+ "dimensions": {+ "type": "object",+ "additionalProperties": false,+ "required": [+ "direction",+ "setting",+ "signal",+ "target"+ ],+ "properties": {+ "direction": {+ "enum": [+ "away_from_default",+ "none",+ "to_default"+ ]+ },+ "setting": {+ "type": "string",+ "minLength": 1,+ "maxLength": 96,+ "pattern": "^[a-z0-9][a-z0-9._:/@+\\-]*$"+ },+ "signal": {+ "enum": [+ "cancelled",+ "feature_disabled",+ "quick_close",+ "rage_click",+ "setting_off_default",+ "undo"+ ]+ },+ "target": {+ "enum": [+ "agents",+ "appearance.toggleMode",+ "artifacts",+ "backdrop",+ "bot_activity_toasts",+ "bot_mode",+ "browser_pane",+ "capabilities",+ "closed_tab",+ "command_center",+ "command_palette",+ "composer.attach",+ "composer.cancel",+ "composer.dictate",+ "composer.focus",+ "composer.help",+ "composer.history",+ "composer.mention",+ "composer.modelPicker",+ "composer.newline",+ "composer.queue",+ "composer.reasoningDown",+ "composer.reasoningUp",+ "composer.send",+ "composer.sendQueued",+ "composer.slash",+ "composer.steer",+ "composer.voice",+ "composer_popout_gestures",+ "conversation.scrollPageDown",+ "conversation.scrollPageUp",+ "cron",+ "extension_page",+ "file_pane",+ "find_in_page",+ "free_tier_sign_in",+ "hud.snapToPointer",+ "intro_splash",+ "kanban",+ "keybind_capture",+ "keybinds.openPanel",+ "message.copy",+ "message.retry",+ "messaging",+ "model_picker",+ "native_notifications",+ "nav.agents",+ "nav.artifacts",+ "nav.capabilities",+ "nav.commandCenter",+ "nav.commandPalette",+ "nav.cron",+ "nav.messaging",+ "nav.profiles",+ "nav.settings",+ "notification_kind",+ "other",+ "profile.create",+ "profile.default",+ "profile.next",+ "profile.prev",+ "profile.toggleAll",+ "profiles",+ "project_create",+ "projects",+ "provider_oauth",+ "reactions",+ "restored_draft",+ "review_pane",+ "session.archive",+ "session.focusSearch",+ "session.new",+ "session.newTab",+ "session.newWindow",+ "session.next",+ "session.prev",+ "session.togglePin",+ "session_import",+ "session_picker",+ "session_search",+ "session_switcher",+ "setting",+ "settings_about",+ "settings_billing",+ "settings_config_advanced",+ "settings_config_appearance",+ "settings_config_browser",+ "settings_config_chat",+ "settings_config_memory",+ "settings_config_model",+ "settings_config_safety",+ "settings_config_voice",+ "settings_config_workspace",+ "settings_gateway",+ "settings_keybinds",+ "settings_keys",+ "settings_notifications",+ "settings_other",+ "settings_providers",+ "settings_sessions",+ "settings_vault",+ "skins",+ "starmap",+ "terminal_pane",+ "thread_timeline",+ "tips",+ "tours",+ "vibe_hearts",+ "view.closeTab",+ "view.closeTerminal",+ "view.cycleSidebarGrouping",+ "view.findInPage",+ "view.findNext",+ "view.findPrevious",+ "view.flipPanes",+ "view.newTerminal",+ "view.nextTerminal",+ "view.prevTerminal",+ "view.reopenTab",+ "view.selectionToComposer",+ "view.showBrowser",+ "view.showFiles",+ "view.showTerminal",+ "view.terminalCopy",+ "view.terminalPaste",+ "view.toggleHud",+ "view.toggleProfileRail",+ "view.toggleReview",+ "view.toggleRightSidebar",+ "view.toggleSidebar",+ "view.toggleSimpleMode",+ "view.toggleStatusbar",+ "view.toggleTabStrip",+ "voice_conversation",+ "voice_dictation",+ "webhooks",+ "workspace.newWorktree",+ "workspace.openFolder"+ ]+ }+ }+ },+ "value": {+ "type": "integer",+ "minimum": 1+ }+ }}}}diff --git a/hermes_cli/observability/shared_metrics_contract.py b/hermes_cli/observability/shared_metrics_contract.pyindex 5ef9870f468..ad4d5b50b92 100644--- a/hermes_cli/observability/shared_metrics_contract.py+++ b/hermes_cli/observability/shared_metrics_contract.py@@ -430,6 +430,132 @@ CACHE_BREAK_CAUSES = frozenset({"toolset_change",})# ---- end v5 efficiency ----+# ---- v5 desktop ----+# Desktop love/hate: which areas get used, what gets in the way, where first run stops. Every value+# is a code-defined Desktop surface id (apps/desktop/src/store/desktop-metrics.ts mirrors these+# sets); anything the client names outside them collapses to `other` before it is recorded.+DESKTOP_FEATURE_USE_MARK = DESKTOP_FEATURE_USE_METRIC = "hermes.desktop.feature_use"+DESKTOP_FRICTION_MARK = DESKTOP_FRICTION_METRIC = "hermes.desktop.friction"+DESKTOP_ONBOARDING_MARK = DESKTOP_ONBOARDING_METRIC = "hermes.desktop.onboarding"+# Settings views are `SETTINGS_VIEWS` in apps/desktop/src/app/settings/index.tsx (the legacy+# `connections` tab redirects to `gateway`).+DESKTOP_SETTINGS_AREAS = frozenset({+ "settings_about", "settings_billing", "settings_config_advanced", "settings_config_appearance",+ "settings_config_browser", "settings_config_chat", "settings_config_memory", "settings_config_model",+ "settings_config_safety", "settings_config_voice", "settings_config_workspace", "settings_gateway",+ "settings_keybinds", "settings_keys", "settings_notifications", "settings_other", "settings_providers",+ "settings_sessions", "settings_vault",+})+DESKTOP_FEATURE_AREAS = DESKTOP_SETTINGS_AREAS | {+ # panes and panels+ "browser_pane", "file_pane", "review_pane", "terminal_pane",+ # overlays and pickers+ "command_palette", "find_in_page", "model_picker", "session_picker", "session_switcher",+ # first-class features+ "bot_mode", "projects", "session_search", "skins", "voice_conversation", "voice_dictation",+ # full pages (APP_ROUTES in apps/desktop/src/app/routes.ts, plus contributed plugin pages)+ "agents", "artifacts", "capabilities", "command_center", "cron", "extension_page", "kanban", "messaging",+ "profiles", "session_import", "starmap", "webhooks",+ "other",+}+# notice_dismissed: stable toast ids and dismissible strips the Desktop code defines.+DESKTOP_NOTICE_IDS = frozenset({+ "artifacts_partial_load", "background_queue_stuck", "backend_skew", "billing_banner", "billing_block",+ "build_discontinued", "client_behind", "composer_queue_stuck", "credits",+ "free_tier_notice", "gateway_error", "gui_skew", "install_method", "mcp_health", "model_warning",+ "onboarding_handoff", "restored_draft", "runtime_not_ready", "session_compress", "terminal_backend", "tip",+ "update_available", "voice_live_unavailable", "voice_stop_hint", "other",+})+# error_toast: the notifyError summary rule that matched (apps/desktop/src/store/notifications.ts).+DESKTOP_ERROR_TOAST_CATEGORIES = frozenset({+ "api_key_missing", "api_key_rejected", "disk_full", "gateway_auth_failed", "method_not_allowed",+ "microphone_permission", "pool_slot_timeout", "restart_required", "rpc_out_of_sync", "storage_failure",+ "timeout", "unclassified", "other",+})+DESKTOP_SLOW_FRAME_BUCKETS = frozenset({"100ms_to_250ms", "250ms_to_1s", "1s_to_5s", "gte_5s"})+DESKTOP_FRICTION_DETAILS: dict[str, frozenset[str]] = {+ "backend_disconnect": frozenset({"backend_exit", "network", "timeout", "other"}),+ "error_toast": DESKTOP_ERROR_TOAST_CATEGORIES,+ "notice_dismissed": DESKTOP_NOTICE_IDS,+ # Electron render-process-gone reasons: crashed -> crash; oom; killed; anything else -> other.+ "renderer_crash": frozenset({"crash", "killed", "oom", "other"}),+ "slow_frame": DESKTOP_SLOW_FRAME_BUCKETS,+}+DESKTOP_FRICTION_KINDS = frozenset(DESKTOP_FRICTION_DETAILS)+DESKTOP_FRICTION_DETAIL_VALUES = frozenset().union(*DESKTOP_FRICTION_DETAILS.values())+# The Desktop first-run flows: the classic provider overlay (store/onboarding.ts), the guided flow+# (store/onboarding-gate.ts phases + committed guide cards), free-tier sign-in, then the consent+# answer and the first message.+DESKTOP_ONBOARDING_STEPS = frozenset({+ "choose_later", "consent", "first_message", "free_tier_ready", "guide", "guide_connectors",+ "guide_first_build", "guide_layout", "guide_look", "guide_skip", "intro", "model_pick", "provider_api_key",+ "provider_local", "provider_oauth", "provider_setup", "sign_in",+})+DESKTOP_ONBOARDING_EVENTS = frozenset({"abandoned", "completed", "reached"})+# Bot Mode (a bot's canonical chat or a bot side-chat in front) vs regular Sessions mode, per day.+DESKTOP_MODE_USE_MARK = DESKTOP_MODE_USE_METRIC = "hermes.desktop.mode_use"+DESKTOP_MODES = frozenset({"bots", "sessions"})+DESKTOP_ACTIVE_MINUTES_BUCKETS = frozenset({"0", "lt_5m", "5m_to_30m", "30m_to_2h", "2h_to_6h", "gte_6h"})+_DESKTOP_ACTIVE_THRESHOLDS = ((300_000, "lt_5m"), (1_800_000, "5m_to_30m"), (7_200_000, "30m_to_2h"),+ (21_600_000, "2h_to_6h"))+++def desktop_active_minutes_bucket(active_ms: Any) -> str:+ """Bucket a day's active time in one Desktop mode; nothing measurable reads 0."""+ value = _non_negative_number(active_ms) or 0+ return "0" if value <= 0 else _bucket(value, _DESKTOP_ACTIVE_THRESHOLDS, "gte_6h")+# ---- end v5 desktop ----++# ---- v5 desktop actions ----+# Button presses per day. Action ids are the Desktop keybinding registry (KEYBIND_ACTIONS in+# apps/desktop/src/lib/keybinds/actions.ts) plus the typed button table DESKTOP_BUTTON_ACTIONS in+# apps/desktop/src/store/desktop-metrics.ts; contributed/plugin actions collapse to `other`.+DESKTOP_ACTION_USE_MARK = DESKTOP_ACTION_USE_METRIC = "hermes.desktop.action_use"+DESKTOP_KEYBIND_ACTION_IDS = frozenset({+ "appearance.toggleMode", "composer.cancel", "composer.dictate", "composer.focus", "composer.help",+ "composer.history", "composer.mention", "composer.modelPicker", "composer.newline", "composer.queue",+ "composer.reasoningDown", "composer.reasoningUp", "composer.send", "composer.sendQueued", "composer.slash",+ "composer.steer", "composer.voice", "conversation.scrollPageDown", "conversation.scrollPageUp",+ "hud.snapToPointer", "keybinds.openPanel", "nav.agents", "nav.artifacts", "nav.capabilities",+ "nav.commandCenter", "nav.commandPalette", "nav.cron", "nav.messaging", "nav.profiles", "nav.settings",+ "profile.create", "profile.default", "profile.next", "profile.prev", "profile.toggleAll",+ "session.archive", "session.focusSearch", "session.new", "session.newTab", "session.newWindow",+ "session.next", "session.prev", "session.togglePin", "view.closeTab", "view.closeTerminal",+ "view.cycleSidebarGrouping", "view.findInPage", "view.findNext", "view.findPrevious", "view.flipPanes",+ "view.newTerminal", "view.nextTerminal", "view.prevTerminal", "view.reopenTab", "view.selectionToComposer",+ "view.showBrowser", "view.showFiles", "view.showTerminal", "view.terminalCopy", "view.terminalPaste",+ "view.toggleHud", "view.toggleProfileRail", "view.toggleReview", "view.toggleRightSidebar",+ "view.toggleSidebar", "view.toggleSimpleMode", "view.toggleStatusbar", "view.toggleTabStrip",+ "workspace.newWorktree", "workspace.openFolder",+})+DESKTOP_BUTTON_ACTION_IDS = frozenset({"composer.attach", "message.copy", "message.retry"})+DESKTOP_ACTION_IDS = DESKTOP_KEYBIND_ACTION_IDS | DESKTOP_BUTTON_ACTION_IDS | {"other"}+DESKTOP_ACTION_VIAS = frozenset({"click", "menu", "palette", "shortcut"})+# Dislike signals, each naming its target from a closed set (setting keys are DEFAULT_CONFIG leaf+# paths, checked against the live schema by shared_metrics_desktop and shape-checked here).+DESKTOP_DISLIKE_MARK = DESKTOP_DISLIKE_METRIC = "hermes.desktop.dislike"+DESKTOP_FLOW_IDS = frozenset({+ "command_palette", "free_tier_sign_in", "keybind_capture", "model_picker", "project_create", "provider_oauth",+ "session_picker", "session_switcher", "other",+})+DESKTOP_FEATURE_TOGGLES = frozenset({+ "backdrop", "bot_activity_toasts", "composer_popout_gestures", "intro_splash", "native_notifications",+ "notification_kind", "reactions", "thread_timeline", "tips", "tours", "vibe_hearts", "other",+})+DESKTOP_UNDO_TARGETS = frozenset({"closed_tab", "restored_draft", "other"})+DESKTOP_DISLIKE_TARGETS: dict[str, frozenset[str]] = {+ "cancelled": DESKTOP_FLOW_IDS,+ "feature_disabled": DESKTOP_FEATURE_TOGGLES,+ "quick_close": DESKTOP_FEATURE_AREAS,+ "rage_click": DESKTOP_ACTION_IDS,+ "setting_off_default": frozenset({"setting"}),+ "undo": DESKTOP_UNDO_TARGETS,+}+DESKTOP_DISLIKE_SIGNALS = frozenset(DESKTOP_DISLIKE_TARGETS)+DESKTOP_DISLIKE_TARGET_VALUES = frozenset().union(*DESKTOP_DISLIKE_TARGETS.values())+DESKTOP_DISLIKE_DIRECTIONS = frozenset({"away_from_default", "none", "to_default"})+DESKTOP_SETTING_KEY_MAX_LENGTH = 96+# ---- end v5 desktop actions ----_ARCHITECTURE_ALIASES = {"amd64": "x86_64", "x64": "x86_64", "x86_64": "x86_64",@@ -661,6 +787,19 @@ _COUNTER_DIMENSION_VALUES: dict[str, dict[str, frozenset[str]]] = {ENGAGEMENT_SURFACE_METRIC: {"active_minutes_bucket": ACTIVE_MINUTES_BUCKETS, "surface": ENGAGEMENT_SURFACES},MODEL_SWITCH_AFTER_METRIC: {"turns_before_switch_bucket": TURNS_BEFORE_SWITCH_BUCKETS},# ---- end v5 engagement ----+ # ---- v5 desktop ----+ DESKTOP_FEATURE_USE_METRIC: {"area": DESKTOP_FEATURE_AREAS},+ DESKTOP_FRICTION_METRIC: {"detail": DESKTOP_FRICTION_DETAIL_VALUES, "kind": DESKTOP_FRICTION_KINDS},+ DESKTOP_ONBOARDING_METRIC: {"event": DESKTOP_ONBOARDING_EVENTS, "step": DESKTOP_ONBOARDING_STEPS},+ DESKTOP_MODE_USE_METRIC: {+ "active_minutes_bucket": DESKTOP_ACTIVE_MINUTES_BUCKETS, "bot_count_bucket": SIZE_BUCKETS,+ "messages_sent_bucket": SIZE_BUCKETS, "mode": DESKTOP_MODES,+ },+ DESKTOP_ACTION_USE_METRIC: {"action": DESKTOP_ACTION_IDS, "count_bucket": SIZE_BUCKETS, "via": DESKTOP_ACTION_VIAS},+ DESKTOP_DISLIKE_METRIC: {+ "direction": DESKTOP_DISLIKE_DIRECTIONS, "signal": DESKTOP_DISLIKE_SIGNALS, "target": DESKTOP_DISLIKE_TARGET_VALUES,+ },+ # ---- end v5 desktop ----}_MODEL_ROUTE_MAX_LENGTHS = {"model": MODEL_IDENTIFIER_MAX_LENGTH, "provider": PROVIDER_IDENTIFIER_MAX_LENGTH,@@ -694,6 +833,9 @@ _IDENTIFIER_FIELDS: dict[str, dict[str, int]] = {},MODEL_SWITCH_AFTER_METRIC: _MODEL_ROUTE_MAX_LENGTHS,# ---- end v5 engagement ----+ # ---- v5 desktop ----+ DESKTOP_DISLIKE_METRIC: {"setting": DESKTOP_SETTING_KEY_MAX_LENGTH},+ # ---- end v5 desktop ----}# ---- v5 engagement ----# Conversation volume on the session row: new fields, so rows recorded before them still package.@@ -768,6 +910,11 @@ _DECISION_MARK_METRICS = {# ---- v5 engagement ----MODEL_SWITCH_AFTER_MARK: MODEL_SWITCH_AFTER_METRIC,# ---- end v5 engagement ----+ # ---- v5 desktop ----+ DESKTOP_FEATURE_USE_MARK: DESKTOP_FEATURE_USE_METRIC, DESKTOP_FRICTION_MARK: DESKTOP_FRICTION_METRIC,+ DESKTOP_ONBOARDING_MARK: DESKTOP_ONBOARDING_METRIC, DESKTOP_MODE_USE_MARK: DESKTOP_MODE_USE_METRIC,+ DESKTOP_ACTION_USE_MARK: DESKTOP_ACTION_USE_METRIC, DESKTOP_DISLIKE_MARK: DESKTOP_DISLIKE_METRIC,+ # ---- end v5 desktop ----}diff --git a/hermes_cli/observability/shared_metrics_desktop.py b/hermes_cli/observability/shared_metrics_desktop.pynew file mode 100644index 00000000000..c491d5b240e--- /dev/null+++ b/hermes_cli/observability/shared_metrics_desktop.py@@ -0,0 +1,240 @@+"""Shared-metrics facts the Desktop app reports about itself: area use, friction, first-run steps,+dislike signals, and one daily report (Bot Mode / Sessions split, button presses per action).++The renderer dedupes on its side (a per-day set persisted only while collection is on); the backend+latches again here so a second window, a reconnect replay or a cleared localStorage cannot inflate a+row: feature use once per (profile, UTC day, area), friction and dislike capped per (profile, UTC day),+onboarding once per (profile, step, event) ever, the daily report once per (profile, usage day). Every value collapses onto the closed+sets in ``shared_metrics_contract``; raw client words are never recorded. All latches are claimed only+after the ``enabled()`` gate (inside the ``_emit`` builders), so a disabled profile writes nothing.+"""++from __future__ import annotations++import os+import re+import threading+from datetime import datetime, timezone+from typing import Any++from . import shared_metrics_contract as contract+from .shared_metrics_events import _emit++# Per-day ceiling for one (kind, detail) friction pair: a toast loop or a janky session still shows+# up as "a lot", but cannot flood the store.+FRICTION_DAILY_CAP = 50+ONBOARDING_LATCH_DIRNAME = "desktop_onboarding"+DAILY_ACTION_ROWS_MAX = 200+_DAY = re.compile(r"\d{4}-\d{2}-\d{2}")+_LATCH_LOCK = threading.Lock()+# (home, day, key) -> count; pruned to the current day so the process never grows it.+_daily: dict[tuple[str, str, str], int] = {}+# (home, usage day) already reported by a daily Desktop report in this process.+_reported_days: set[tuple[str, str]] = set()+++def _utc_day() -> str:+ return datetime.now(timezone.utc).date().isoformat()+++def _home() -> str:+ from hermes_constants import get_hermes_home++ return str(get_hermes_home())+++def _word(value: Any) -> str:+ return value.strip().lower() if isinstance(value, str) else ""+++def _claim_daily(key: str, *, cap: int = 1, day: str | None = None) -> bool:+ """True while ``key`` has been claimed fewer than ``cap`` times today in this profile."""+ today = _utc_day()+ slot = (_home(), day or today, key)+ with _LATCH_LOCK:+ for stale in [k for k in _daily if k[1] < today and k[1] != slot[1]]:+ del _daily[stale]+ if _daily.get(slot, 0) >= cap:+ return False+ _daily[slot] = _daily.get(slot, 0) + 1+ return True+++def feature_area(area: Any) -> str:+ word = _word(area)+ if word in contract.DESKTOP_FEATURE_AREAS:+ return word+ return "settings_other" if word.startswith("settings_") else "other"+++def friction_pair(kind: Any, detail: Any) -> tuple[str, str] | None:+ """``(kind, detail)`` with detail checked against ITS kind's set; unknown kinds record nothing."""+ kind_word = _word(kind)+ details = contract.DESKTOP_FRICTION_DETAILS.get(kind_word)+ if details is None:+ return None+ detail_word = _word(detail)+ return kind_word, detail_word if detail_word in details else "other"+++def _feature_use_fields(*, area: Any) -> dict[str, str] | None:+ value = feature_area(area)+ return {"area": value} if _claim_daily(f"area:{value}") else None+++def _friction_fields(*, kind: Any, detail: Any) -> dict[str, str] | None:+ pair = friction_pair(kind, detail)+ if pair is None or not _claim_daily(f"friction:{pair[0]}:{pair[1]}", cap=FRICTION_DAILY_CAP):+ return None+ return {"detail": pair[1], "kind": pair[0]}+++def _claim_onboarding(step: str, event: str) -> bool:+ """Once per (step, event) per profile, across processes: an O_EXCL latch file (≤ ~51 of them)."""+ from hermes_constants import get_hermes_home++ directory = get_hermes_home() / "telemetry" / "shared_metrics" / ONBOARDING_LATCH_DIRNAME+ directory.mkdir(parents=True, exist_ok=True)+ try:+ os.close(os.open(directory / f"{step}.{event}", os.O_CREAT | os.O_EXCL | os.O_WRONLY))+ except FileExistsError:+ return False+ return True+++def _onboarding_fields(*, step: Any, event: Any) -> dict[str, str] | None:+ step_word, event_word = _word(step), _word(event)+ if step_word not in contract.DESKTOP_ONBOARDING_STEPS or event_word not in contract.DESKTOP_ONBOARDING_EVENTS:+ return None+ return {"event": event_word, "step": step_word} if _claim_onboarding(step_word, event_word) else None+++def _count(value: Any) -> int:+ return int(value) if isinstance(value, (int, float)) and not isinstance(value, bool) and value >= 0 else 0+++def action_id(action: Any) -> str:+ """Action ids are case-sensitive registry ids (``view.toggleSidebar``): only strip them."""+ word = action.strip() if isinstance(action, str) else ""+ return word if word in contract.DESKTOP_ACTION_IDS else "other"+++def _setting_leaves(config: dict, prefix: str = "") -> dict[str, Any]:+ leaves: dict[str, Any] = {}+ for key, value in config.items():+ path = f"{prefix}.{key}" if prefix else str(key)+ if isinstance(value, dict) and value:+ leaves.update(_setting_leaves(value, path))+ else:+ leaves[path] = value+ return leaves+++def _setting_direction(key: str) -> tuple[str, str]:+ """``(setting, direction)`` for a config key the Desktop settings page just saved: the key only if+ it is a DEFAULT_CONFIG leaf (the settings schema), the direction from comparing the saved value to+ the default here in the backend, so the value never leaves this process."""+ from hermes_cli.config import DEFAULT_CONFIG, load_config++ defaults = _setting_leaves(DEFAULT_CONFIG)+ if key not in defaults or len(key) > contract.DESKTOP_SETTING_KEY_MAX_LENGTH:+ return "other", "none"+ current: Any = load_config()+ for part in key.split("."):+ current = current.get(part) if isinstance(current, dict) else None+ return key, "to_default" if current == defaults[key] else "away_from_default"+++def _dislike_fields(*, signal: Any, target: Any, setting: Any) -> dict[str, str] | None:+ signal_word = _word(signal)+ targets = contract.DESKTOP_DISLIKE_TARGETS.get(signal_word)+ if targets is None:+ return None+ if signal_word == "setting_off_default":+ key = setting.strip() if isinstance(setting, str) else ""+ setting_word, direction = _setting_direction(key)+ target_word = "setting"+ else:+ raw = target.strip() if isinstance(target, str) else ""+ target_word = raw if signal_word == "rage_click" and raw in targets else _word(raw)+ target_word = target_word if target_word in targets else "other"+ setting_word, direction = "none", "none"+ if not _claim_daily(f"dislike:{signal_word}", cap=FRICTION_DAILY_CAP):+ return None+ return {"direction": direction, "setting": setting_word, "signal": signal_word, "target": target_word}+++def _mode_rows(modes: Any, bot_count: Any) -> list[tuple[str, dict[str, str]]]:+ rows: dict[str, tuple[str, dict[str, str]]] = {}+ for entry in modes if isinstance(modes, list) else []:+ mode = _word(entry.get("mode")) if isinstance(entry, dict) else ""+ active_ms, messages = (_count(entry.get("active_ms")), _count(entry.get("messages_sent"))) if mode else (0, 0)+ # Only modes actually used that day get a row.+ if mode not in contract.DESKTOP_MODES or mode in rows or not (active_ms or messages):+ continue+ rows[mode] = (contract.DESKTOP_MODE_USE_MARK, {+ "active_minutes_bucket": contract.desktop_active_minutes_bucket(active_ms),+ "bot_count_bucket": contract.size_bucket(_count(bot_count)),+ "messages_sent_bucket": contract.size_bucket(messages),+ "mode": mode,+ })+ return list(rows.values())+++def _action_rows(actions: Any) -> list[tuple[str, dict[str, str]]]:+ totals: dict[tuple[str, str], int] = {}+ for entry in (actions if isinstance(actions, list) else [])[:DAILY_ACTION_ROWS_MAX]:+ if not isinstance(entry, dict) or _word(entry.get("via")) not in contract.DESKTOP_ACTION_VIAS:+ continue+ key = (action_id(entry.get("action")), _word(entry.get("via")))+ totals[key] = totals.get(key, 0) + _count(entry.get("count"))+ return [+ (contract.DESKTOP_ACTION_USE_MARK, {"action": action, "count_bucket": contract.size_bucket(count), "via": via})+ for (action, via), count in sorted(totals.items()) if count+ ]+++def record_desktop_daily(*, day: Any, modes: Any, actions: Any, bot_count: Any) -> bool:+ """Record one finished Desktop day: a mode_use row per mode used (with the bot count) and an+ action_use row per (action, via). True once the day is settled (saved, already reported, or+ collection off) so the client drops its copy; False keeps it for the next attach."""+ try:+ from .relay_shared_metrics import enabled+ from .shared_metrics_events import emit_saved++ if not enabled():+ return True+ usage_day = day if isinstance(day, str) and _DAY.fullmatch(day) else None+ if usage_day is None:+ return True+ marks = _mode_rows(modes, bot_count) + _action_rows(actions)+ if not marks:+ return True+ with _LATCH_LOCK:+ latch = (_home(), usage_day)+ if latch in _reported_days:+ return True+ _reported_days.add(latch)+ settled = emit_saved(marks) == len(marks)+ if not settled:+ with _LATCH_LOCK:+ _reported_days.discard(latch)+ return settled+ except Exception:+ return False+++def record_desktop_feature_use(*, area: Any) -> None:+ _emit(contract.DESKTOP_FEATURE_USE_MARK, _feature_use_fields, area=area)+++def record_desktop_friction(*, kind: Any, detail: Any) -> None:+ _emit(contract.DESKTOP_FRICTION_MARK, _friction_fields, kind=kind, detail=detail)+++def record_desktop_onboarding(*, step: Any, event: Any) -> None:+ _emit(contract.DESKTOP_ONBOARDING_MARK, _onboarding_fields, step=step, event=event)+++def record_desktop_dislike(*, signal: Any, target: Any, setting: Any = None) -> None:+ _emit(contract.DESKTOP_DISLIKE_MARK, _dislike_fields, signal=signal, target=target, setting=setting)diff --git a/tests/hermes_cli/test_shared_metrics_desktop.py b/tests/hermes_cli/test_shared_metrics_desktop.pynew file mode 100644index 00000000000..14bde14f7d5--- /dev/null+++ b/tests/hermes_cli/test_shared_metrics_desktop.py@@ -0,0 +1,182 @@+"""v5 desktop: hermes.desktop.{feature_use,friction,onboarding,dislike,mode_use,action_use}.++Every value the Desktop sends collapses onto a closed code-defined set, the backend latches again so a+replay cannot inflate a row, and a disabled profile writes nothing (not even a latch file)."""++from __future__ import annotations++import json+from pathlib import Path+from types import SimpleNamespace++import pytest++from hermes_cli.observability import relay_shared_metrics+from hermes_cli.observability import shared_metrics_contract as contract+from hermes_cli.observability import shared_metrics_desktop as desktop+import tui_gateway.server as server+++def marks(tmp_path, monkeypatch):+ captured: list[tuple[str, dict]] = []+ policy = {"on": True}+ home = tmp_path / "home"+ home.mkdir()+ monkeypatch.setenv("HERMES_HOME", str(home))+ monkeypatch.setattr(relay_shared_metrics, "enabled", lambda: policy["on"])+ monkeypatch.setattr(relay_shared_metrics, "record_process_mark", lambda mark, data: captured.append((mark, data)))+ store = {"saves": True}++ def saved(rows):+ if not policy["on"]:+ return len(rows)+ if store["saves"]:+ captured.extend(rows)+ return len(rows) if store["saves"] else 0++ monkeypatch.setattr(relay_shared_metrics, "record_process_marks_saved", saved, raising=False)+ monkeypatch.setattr(desktop, "_daily", {})+ monkeypatch.setattr(desktop, "_reported_days", set())+ yield SimpleNamespace(rows=captured, policy=policy, home=home, store=store)+++def _rpc(method: str, **params) -> dict:+ return server.handle_request({"jsonrpc": "2.0", "id": "r1", "method": method, "params": params})+++def _assert_valid(rows) -> None:+ for mark, data in rows:+ assert contract.counter_dimensions_are_valid(contract._DECISION_MARK_METRICS[mark], data), (mark, data)+++def test_feature_use_counts_each_area_once_per_day_and_collapses_unknown_areas(marks):+ for area in ("terminal_pane", "terminal_pane", "settings_config_voice", "settings_brand_new_tab", "/Users/x"):+ assert _rpc("shared_metrics.desktop_feature_use", area=area)["result"] == {"ok": True}++ assert [data["area"] for _, data in marks.rows] == [+ "terminal_pane", "settings_config_voice", "settings_other", "other"]+ _assert_valid(marks.rows)+++def test_friction_detail_is_checked_against_its_own_kind_and_capped_per_day(marks):+ _rpc("shared_metrics.desktop_friction", kind="renderer_crash", detail="oom")+ _rpc("shared_metrics.desktop_friction", kind="renderer_crash", detail="network") # a disconnect word+ _rpc("shared_metrics.desktop_friction", kind="error_toast", detail="ENOSPC: /home/alice/.hermes is full")+ _rpc("shared_metrics.desktop_friction", kind="made_up", detail="crash")+ for _ in range(desktop.FRICTION_DAILY_CAP + 5):+ _rpc("shared_metrics.desktop_friction", kind="slow_frame", detail="1s_to_5s")++ rows = [(d["kind"], d["detail"]) for _, d in marks.rows]+ assert rows[:3] == [("renderer_crash", "oom"), ("renderer_crash", "other"), ("error_toast", "other")]+ assert rows.count(("slow_frame", "1s_to_5s")) == desktop.FRICTION_DAILY_CAP+ _assert_valid(marks.rows)+++def test_onboarding_is_once_per_step_event_across_processes(marks, monkeypatch):+ _rpc("shared_metrics.desktop_onboarding", step="provider_setup", event="reached")+ monkeypatch.setattr(desktop, "_daily", {}) # a fresh backend process: only the file latch remains+ _rpc("shared_metrics.desktop_onboarding", step="provider_setup", event="reached")+ _rpc("shared_metrics.desktop_onboarding", step="provider_setup", event="abandoned")+ _rpc("shared_metrics.desktop_onboarding", step="not_a_step", event="reached")++ assert [(d["step"], d["event"]) for _, d in marks.rows] == [+ ("provider_setup", "reached"), ("provider_setup", "abandoned")]+ _assert_valid(marks.rows)+++def test_disabled_profile_records_nothing_and_leaves_no_latch(marks):+ marks.policy["on"] = False+ _rpc("shared_metrics.desktop_feature_use", area="projects")+ _rpc("shared_metrics.desktop_friction", kind="renderer_crash", detail="crash")+ _rpc("shared_metrics.desktop_onboarding", step="consent", event="completed")+ _rpc("shared_metrics.desktop_dislike", signal="quick_close", target="terminal_pane")+ daily = _rpc("shared_metrics.desktop_daily", day="2026-09-26",+ modes=[{"mode": "sessions", "active_ms": 60_000, "messages_sent": 3}])++ assert daily["result"] == {"recorded": True} # settled: the client drops the day+ assert marks.rows == []+ assert desktop._daily == {} and desktop._reported_days == set()+ assert not (marks.home / "telemetry").exists()++ marks.policy["on"] = True # the earlier calls claimed nothing, so opting in later still counts+ _rpc("shared_metrics.desktop_feature_use", area="projects")+ assert [d["area"] for _, d in marks.rows] == ["projects"]+++def test_daily_report_records_used_modes_and_bucketed_actions_once_per_day(marks):+ params = {+ "day": "2026-09-26", "bot_count": 4,+ "modes": [+ {"mode": "sessions", "active_ms": 45 * 60_000, "messages_sent": 12},+ {"mode": "bots", "active_ms": 0, "messages_sent": 0}, # not used that day: no row+ ],+ "actions": [+ {"action": "view.toggleSidebar", "via": "shortcut", "count": 30},+ {"action": "view.toggleSidebar", "via": "click", "count": 2},+ {"action": "plugin.someContributedThing", "via": "palette", "count": 1},+ ],+ }+ assert _rpc("shared_metrics.desktop_daily", **params)["result"] == {"recorded": True}+ assert _rpc("shared_metrics.desktop_daily", **params)["result"] == {"recorded": True} # replay: no rows++ assert marks.rows == [+ (contract.DESKTOP_MODE_USE_MARK, {"active_minutes_bucket": "30m_to_2h", "bot_count_bucket": "3_to_5",+ "messages_sent_bucket": "11_to_25", "mode": "sessions"}),+ (contract.DESKTOP_ACTION_USE_MARK, {"action": "other", "count_bucket": "1", "via": "palette"}),+ (contract.DESKTOP_ACTION_USE_MARK, {"action": "view.toggleSidebar", "count_bucket": "2", "via": "click"}),+ (contract.DESKTOP_ACTION_USE_MARK, {"action": "view.toggleSidebar", "count_bucket": "26_to_100",+ "via": "shortcut"}),+ ]+ _assert_valid(marks.rows)+++def test_daily_report_that_the_store_refuses_stays_with_the_client(marks):+ marks.store["saves"] = False+ params = {"day": "2026-09-26", "modes": [{"mode": "bots", "active_ms": 1, "messages_sent": 0}]}+ assert _rpc("shared_metrics.desktop_daily", **params)["result"] == {"recorded": False}+ marks.store["saves"] = True+ assert _rpc("shared_metrics.desktop_daily", **params)["result"] == {"recorded": True}+ assert [d["active_minutes_bucket"] for _, d in marks.rows] == ["lt_5m"]+++def test_dislike_targets_are_closed_per_signal(marks):+ _rpc("shared_metrics.desktop_dislike", signal="quick_close", target="browser_pane")+ _rpc("shared_metrics.desktop_dislike", signal="cancelled", target="model_picker")+ _rpc("shared_metrics.desktop_dislike", signal="rage_click", target="composer.send")+ _rpc("shared_metrics.desktop_dislike", signal="undo", target="restored_draft")+ _rpc("shared_metrics.desktop_dislike", signal="feature_disabled", target="tips")+ _rpc("shared_metrics.desktop_dislike", signal="quick_close", target="keybind_capture") # a flow, not an area+ _rpc("shared_metrics.desktop_dislike", signal="loathing", target="tips")++ assert [(d["signal"], d["target"]) for _, d in marks.rows] == [+ ("quick_close", "browser_pane"), ("cancelled", "model_picker"), ("rage_click", "composer.send"),+ ("undo", "restored_draft"), ("feature_disabled", "tips"), ("quick_close", "other")]+ assert {(d["setting"], d["direction"]) for _, d in marks.rows} == {("none", "none")}+ _assert_valid(marks.rows)+++def test_setting_change_sends_only_the_schema_key_and_the_backend_decides_the_direction(marks):+ config = marks.home / "config.yaml"+ config.write_text("display:\n compact: true\n skin: default\n")+ _rpc("shared_metrics.desktop_dislike", signal="setting_off_default", setting="display.compact")+ _rpc("shared_metrics.desktop_dislike", signal="setting_off_default", setting="display.skin")+ _rpc("shared_metrics.desktop_dislike", signal="setting_off_default", setting="providers.my-secret-box.api_key")++ assert [(d["target"], d["setting"], d["direction"]) for _, d in marks.rows] == [+ ("setting", "display.compact", "away_from_default"), ("setting", "display.skin", "to_default"),+ ("setting", "other", "none")]+ _assert_valid(marks.rows)+++def test_v3_schema_accepts_exactly_the_desktop_contract_values():+ import hermes_cli.observability as observability++ schema = json.loads((Path(observability.__file__).parent / "schemas/hermes.shared_metrics.v3.schema.json").read_text())+ by_name = {d["properties"]["name"]["const"]: d for d in schema["$defs"].values() if "properties" in d}+ for metric in (contract.DESKTOP_FEATURE_USE_METRIC, contract.DESKTOP_FRICTION_METRIC,+ contract.DESKTOP_ONBOARDING_METRIC, contract.DESKTOP_MODE_USE_METRIC,+ contract.DESKTOP_ACTION_USE_METRIC, contract.DESKTOP_DISLIKE_METRIC):+ dims = by_name[metric]["properties"]["dimensions"]["properties"]+ assert {f: set(spec["enum"]) for f, spec in dims.items() if "enum" in spec} == {+ f: set(values) for f, values in contract._COUNTER_DIMENSION_VALUES[metric].items()}diff --git a/tui_gateway/contracts/config_free_tier_control.py b/tui_gateway/contracts/config_free_tier_control.pyindex a538ef25fd6..ae26ab468b9 100644--- a/tui_gateway/contracts/config_free_tier_control.py+++ b/tui_gateway/contracts/config_free_tier_control.py@@ -15,7 +15,7 @@ from typing import Literalfrom pydantic import Fieldfrom .base import JsonValue, Params, Result, WireEnum-from .common import OpenModel, ProfileParams, SessionLiveInfo+from .common import OkResult, OpenModel, ProfileParams, SessionLiveInfofrom .registry import method# ── config.get ────────────────────────────────────────────────────────────────────────────────@@ -303,6 +303,93 @@ method("shared_metrics.update_run", params=SharedMetricsUpdateRunParams, result=# ---- end v4 reliability ----+# ---- v5 desktop ----+class SharedMetricsDesktopFeatureUseParams(ProfileParams):+ """``area`` is a Desktop surface id (``command_palette``, ``terminal_pane``, ``settings_<view>`` …);+ the backend collapses anything outside its closed set to ``other``."""++ area: str+++method("shared_metrics.desktop_feature_use", params=SharedMetricsDesktopFeatureUseParams,+ result=OkResult,+ doc="Count one Desktop area used today (fire-and-forget; once per area per UTC day; a no-op unless on).")+++class SharedMetricsDesktopFrictionParams(ProfileParams):+ """``kind`` notice_dismissed|error_toast|renderer_crash|backend_disconnect|slow_frame; ``detail`` a+ closed code-defined word for that kind (notice id, error category, crash reason, drop reason, frame+ duration bucket), never message text."""++ kind: str+ detail: str+++method("shared_metrics.desktop_friction", params=SharedMetricsDesktopFrictionParams,+ result=OkResult,+ doc="Count one Desktop friction event (fire-and-forget; capped per day; a no-op unless on).")+++class SharedMetricsDesktopOnboardingParams(ProfileParams):+ """``step`` a Desktop first-run step id; ``event`` reached|completed|abandoned."""++ step: str+ event: str+++method("shared_metrics.desktop_onboarding", params=SharedMetricsDesktopOnboardingParams,+ result=OkResult,+ doc="Count one Desktop first-run step transition (fire-and-forget; once per step+event; a no-op unless on).")+++class SharedMetricsDesktopDislikeParams(ProfileParams):+ """``signal`` quick_close|cancelled|setting_off_default|rage_click|undo|feature_disabled; ``target`` a+ closed code-defined id for that signal (area, flow, action, undo path, feature toggle); ``setting`` a+ config key for setting_off_default only (the value is never sent — the backend compares it to the+ default)."""++ signal: str+ target: str = ""+ setting: str | None = None+++method("shared_metrics.desktop_dislike", params=SharedMetricsDesktopDislikeParams,+ result=OkResult,+ doc="Count one Desktop dislike signal (fire-and-forget; capped per signal per day; a no-op unless on).")+++class SharedMetricsDesktopModeDay(Params):+ mode: Literal["bots", "sessions"]+ active_ms: float = 0+ messages_sent: int = 0+++class SharedMetricsDesktopActionDay(Params):+ action: str+ via: Literal["click", "menu", "palette", "shortcut"]+ count: int+++class SharedMetricsDesktopDailyParams(ProfileParams):+ """One finished UTC day of Desktop use, aggregated on the client. ``day`` (YYYY-MM-DD) only latches+ a resend and is never recorded; the raw counts are bucketed by the backend."""++ day: str+ bot_count: int = 0+ modes: list[SharedMetricsDesktopModeDay] = Field(default_factory=list)+ actions: list[SharedMetricsDesktopActionDay] = Field(default_factory=list)+++class SharedMetricsDesktopDailyResult(Result):+ recorded: bool+++method("shared_metrics.desktop_daily", params=SharedMetricsDesktopDailyParams,+ result=SharedMetricsDesktopDailyResult,+ doc="Record one finished Desktop day (mode use + button presses); recorded=false keeps it for a retry.")+# ---- end v5 desktop ----++# ── model.options ─────────────────────────────────────────────────────────────────────────────diff --git a/tui_gateway/methods_shared_metrics.py b/tui_gateway/methods_shared_metrics.pyindex 5ac2481ba34..bdff73670e1 100644--- a/tui_gateway/methods_shared_metrics.py+++ b/tui_gateway/methods_shared_metrics.py@@ -130,5 +130,65 @@ def _(rid, params: dict) -> dict:# ---- end v4 reliability ----+# ---- v5 desktop ----+@method("shared_metrics.desktop_feature_use")+@_profile_scoped+def _(rid, params: dict) -> dict:+ """Desktop reports each area the user opened, at most once per UTC day (latched on both sides).+ Always ``{ok: true}``; a no-op unless shared metrics are on."""+ from hermes_cli.observability.shared_metrics_desktop import record_desktop_feature_use++ record_desktop_feature_use(area=params.get("area"))+ return _ok(rid, {"ok": True})+++@method("shared_metrics.desktop_friction")+@_profile_scoped+def _(rid, params: dict) -> dict:+ """One Desktop friction event (dismissed notice, error toast by category, renderer crash, backend+ disconnect, slow frame), capped per day. Always ``{ok: true}``."""+ from hermes_cli.observability.shared_metrics_desktop import record_desktop_friction++ record_desktop_friction(kind=params.get("kind"), detail=params.get("detail"))+ return _ok(rid, {"ok": True})+++@method("shared_metrics.desktop_onboarding")+@_profile_scoped+def _(rid, params: dict) -> dict:+ """One Desktop first-run step transition, once per (step, event) per profile. Always ``{ok: true}``."""+ from hermes_cli.observability.shared_metrics_desktop import record_desktop_onboarding++ record_desktop_onboarding(step=params.get("step"), event=params.get("event"))+ return _ok(rid, {"ok": True})+++@method("shared_metrics.desktop_dislike")+@_profile_scoped+def _(rid, params: dict) -> dict:+ """One Desktop dislike signal (quick close, cancelled flow, setting changed vs default, rage click,+ undo, feature disabled), capped per signal per day. For a setting the backend reads the saved value+ and compares it to the default itself; only the key and the direction are recorded."""+ from hermes_cli.observability.shared_metrics_desktop import record_desktop_dislike++ record_desktop_dislike(signal=params.get("signal"), target=params.get("target"), setting=params.get("setting"))+ return _ok(rid, {"ok": True})+++@method("shared_metrics.desktop_daily")+@_profile_scoped+def _(rid, params: dict) -> dict:+ """One finished Desktop day: mode use (Bot Mode vs Sessions, with the bot count) and button presses+ per action. ``{recorded: true}`` once settled, so the client drops the day; false keeps it."""+ from hermes_cli.observability.shared_metrics_desktop import record_desktop_daily++ recorded = record_desktop_daily(+ day=params.get("day"), modes=params.get("modes"), actions=params.get("actions"),+ bot_count=params.get("bot_count"),+ )+ return _ok(rid, {"recorded": recorded})+# ---- end v5 desktop ----++def register(server) -> None:bind_module(globals(), server, skip=("_",))diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.mdindex 0cb64a67a73..8e890e7c6f0 100644--- a/website/docs/developer-guide/relay-shared-metrics.md+++ b/website/docs/developer-guide/relay-shared-metrics.md@@ -321,6 +321,27 @@ on (the inbound's platform, else the platform the connector fronts), never| `hermes.update.stage` | stage, outcome, duration_bucket | Per-stage result and wall time of `hermes update` (plan, snapshot, apply, deps, build, restart, verify), from the receipt's stage timestamps. || `hermes.process.exit` | process_kind, exit_kind, crash_class | How CLI / TUI / gateway / serve / cron-tick processes end (`clean`, `crash` with an exception family only, `killed`, `watchdog`), reported by the next start in the same profile from a local marker. Turns aborted by a turn watchdog also count as `exit_kind=watchdog`. |++<!-- ---- v5 desktop ---- -->+#### Desktop app: what gets used, what gets in the way, what gets turned off++Recorded by the Desktop app into the focused profile's store, only while that+profile's collection switch is on. With it off the app keeps no local record+(switching it off deletes what was kept) and sends nothing. There is no rating+prompt or other new UI; each fact comes from an interaction the app already has.+Every value is a closed id defined in the app's code (area, action, notice, flow,+toggle, step), a published config key, or a bucket. Message text, toast text,+session/bot/profile names, paths and setting values never leave.++| Metric | Dimensions | Question it answers |+|---|---|---|+| `hermes.desktop.feature_use` | area (panes, command palette, model/session pickers, voice, Bot Mode, skins, projects, each settings page, full pages, `other`) | Which Desktop areas are used at all, counted at most once per area per UTC day per install. |+| `hermes.desktop.action_use` | action (the app's command/keybinding ids plus a few named buttons, else `other`), via (`click`/`shortcut`/`palette`/`menu`), count bucket | Which buttons and commands people press, and how: aggregated in the app and reported once per finished day (no per-press rows). |+| `hermes.desktop.mode_use` | mode (`sessions`/`bots`), active-minutes bucket, messages-sent bucket, bot-count bucket | How Desktop time splits between Bot Mode and regular Sessions. One row per mode used that day; active time sums gaps between interactions of up to 5 minutes. |+| `hermes.desktop.friction` | kind (`notice_dismissed`, `error_toast`, `renderer_crash`, `backend_disconnect`, `slow_frame`), detail (notice id, error category, crash reason, drop reason, frame-duration bucket) | What gets in the way. Error toasts carry only their code-defined category; renderer crashes are recorded by the app shell and reported after the window comes back; slow frames are long frames while the window is visible, capped per day. |+| `hermes.desktop.dislike` | signal (`quick_close`, `cancelled`, `setting_off_default`, `rage_click`, `undo`, `feature_disabled`), target, setting, direction | Signals that a feature is unwanted: a pane closed within 5s of opening, a dialog/flow backed out of, a setting moved to or away from its default (the key only; the backend compares the saved value to the default itself), three clicks on one control within a second, an undo, a shipped feature switched off. Capped per signal per day. |+| `hermes.desktop.onboarding` | step (first-run steps: provider picker, sign-in, API key, local endpoint, model pick, choose later, free-tier screen, guided setup cards, consent, first message), event (`reached`/`completed`/`abandoned`) | Where first run stops. Each step event once per install; `abandoned` is a step still open when the app next starts. |+Sessions are summarized when they close (finalize, reset or process exit);delegated child sessions are not counted separately. Milestones latch in thelocal database, so each fires once per install however many processes reach it.