The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(tui-gateway): machine.facts RPC
alt-glitchb6abf6f50360
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex 08f069789b1..bf0d4024de4 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -1917,6 +1917,29 @@ export interface ClientCapabilitiesResult {server_requests: string[]declines_not_shown?: boolean}+/** Client→server method params / server→client request params. Unknown keys are rejected. */+export type Params = Record<string, never>+/** ``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``full_name`` is the OS account's real name (never a login handle) and ``locale`` its first UI language; each is null when the OS has none. */+export interface MachineFactsResult {+ machine: MachineInfo+ machine_kind: string+ has_nvidia_gpu: boolean+ is_spark: boolean+ locale?: string | null+ full_name?: string | null+}+/** Measured hardware; a key that was not measured is absent. */+export interface MachineInfo {+ os_family?: string | null+ os_release?: string | null+ native_arch?: string | null+ cpu_model?: string | null+ ram_gb?: number | null+ gpu_class?: string | null+ vendor?: string | null+ wsl?: boolean | null+ container?: boolean | null+}/** ``word`` is the token under the cursor (``@`` prefix = context reference); ``cwd`` / ``session_id`` pick the directory the listing resolves against. */export interface CompletePathParams {profile?: string | null@@ -2157,8 +2180,6 @@ export interface ProfilesGetAssetResult {size?: number | nulldata?: string | null}-/** Client→server method params / server→client request params. Unknown keys are rejected. */-export type Params = Record<string, never>/** ``created`` is false when an existing setup profile was found (and returned untouched). */export interface OnboardingEnsureSetupProfileResult {name: string@@ -5224,6 +5245,8 @@ export interface RpcMethods {'learning.frames': { params: LearningFramesParams; result: LearningFramesResult }/** Stateless one-shot LLM completion (titles, ideas) on the session's or the task backend. */'llm.oneshot': { params: LlmOneshotParams; result: LlmOneshotResult }+ /** Facts about the machine running this backend and its OS account, for the desktop first run. */+ 'machine.facts': { params: Params; result: MachineFactsResult }/** Curated MCP presets with per-profile installed/enabled state and the env keys each needs. */'mcp.catalog': { params: ProfileParams; result: McpCatalogResult }/** Add a server to the profile's config from a catalog preset and/or an explicit config. */@@ -5645,6 +5668,7 @@ export const RPC_METHODS = ['learning.edit','learning.frames','llm.oneshot',+ 'machine.facts','mcp.catalog','mcp.servers.add','mcp.servers.list',diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex d408ccf3c0e..8ff52bc944e 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -1734,6 +1734,24 @@}}},+ {+ "name": "machine.facts",+ "summary": "Facts about the machine running this backend and its OS account, for the desktop first run.",+ "params": [+ {+ "name": "params",+ "schema": {+ "$ref": "#/components/schemas/Params"+ }+ }+ ],+ "result": {+ "name": "result",+ "schema": {+ "$ref": "#/components/schemas/MachineFactsResult"+ }+ }+ },{"name": "mcp.catalog","summary": "Curated MCP presets with per-profile installed/enabled state and the env keys each needs.",@@ -17904,6 +17922,175 @@"title": "LoopSnapshot","type": "object"},+ "MachineFactsResult": {+ "additionalProperties": false,+ "description": "``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``full_name`` is the OS account's\nreal name (never a login handle) and ``locale`` its first UI language; each is null when the OS has none.",+ "properties": {+ "machine": {+ "$ref": "#/components/schemas/MachineInfo"+ },+ "machine_kind": {+ "title": "Machine Kind",+ "type": "string"+ },+ "has_nvidia_gpu": {+ "title": "Has Nvidia Gpu",+ "type": "boolean"+ },+ "is_spark": {+ "title": "Is Spark",+ "type": "boolean"+ },+ "locale": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Locale"+ },+ "full_name": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Full Name"+ }+ },+ "required": [+ "machine",+ "machine_kind",+ "has_nvidia_gpu",+ "is_spark"+ ],+ "title": "MachineFactsResult",+ "type": "object"+ },+ "MachineInfo": {+ "additionalProperties": false,+ "description": "Measured hardware; a key that was not measured is absent.",+ "properties": {+ "os_family": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Os Family"+ },+ "os_release": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Os Release"+ },+ "native_arch": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Native Arch"+ },+ "cpu_model": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Cpu Model"+ },+ "ram_gb": {+ "anyOf": [+ {+ "type": "integer"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Ram Gb"+ },+ "gpu_class": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Gpu Class"+ },+ "vendor": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Vendor"+ },+ "wsl": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Wsl"+ },+ "container": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Container"+ }+ },+ "title": "MachineInfo",+ "type": "object"+ },"McpCatalogEntry": {"additionalProperties": false,"properties": {diff --git a/tests/tui_gateway/test_machine_facts_rpc.py b/tests/tui_gateway/test_machine_facts_rpc.pynew file mode 100644index 00000000000..7920a63a575--- /dev/null+++ b/tests/tui_gateway/test_machine_facts_rpc.py@@ -0,0 +1,41 @@+"""``machine.facts`` answers the host summary through the registered handler and its contract, and+answers the same for every profile one backend serves."""++from __future__ import annotations++import pytest++from tui_gateway import server+from hermes_platform.host import facts, summary+++def n1x(monkeypatch):+ pinned = {"os_family": "win32", "native_arch": "arm64", "gpu_class": "unknown",+ "cpu_model": "NVIDIA RTX Spark N1X", "cpu_vendor": "NVIDIA", "ram_total_bytes": 128 * 2**30}+ for name, value in pinned.items():+ monkeypatch.setattr(facts, name, lambda value=value: value)+ monkeypatch.setattr(summary, "_account", lambda: ("ada", "Ada Lovelace"))+ summary.summary.cache_clear()+ yield+ summary.summary.cache_clear()+++def _call(params: dict) -> dict:+ return server.handle_request({"jsonrpc": "2.0", "id": 7, "method": "machine.facts", "params": params})+++def test_machine_facts_over_the_wire(n1x):+ result = _call({})["result"]++ assert result["is_spark"] is True+ assert result["machine_kind"] == "Spark"+ assert result["has_nvidia_gpu"] is False+ assert result["full_name"] == "Ada Lovelace"+ assert result["machine"]["native_arch"] == "arm64"+ assert result["machine"]["ram_gb"] == 128+++def test_machine_facts_takes_no_profile(n1x):+ # Host-level: a profile param is a client bug, not a scope.+ assert _call({"profile": "work"})["error"]["code"] == 4000diff --git a/tui_gateway/contracts/__init__.py b/tui_gateway/contracts/__init__.pyindex ab63def382c..9d90398eb30 100644--- a/tui_gateway/contracts/__init__.py+++ b/tui_gateway/contracts/__init__.py@@ -12,6 +12,7 @@ from . import (groups_bot_relay,i18n,liveness,+ machine,profiles_vault_complete_foreign_subagents,projects_pets,prompt_voice,diff --git a/tui_gateway/contracts/machine.py b/tui_gateway/contracts/machine.pynew file mode 100644index 00000000000..39e86db4aa9--- /dev/null+++ b/tui_gateway/contracts/machine.py@@ -0,0 +1,40 @@+"""This machine (``methods_machine.py``): host facts from ``hermes_platform.host.summary``.++Host-level by design: there is no ``profile`` param because the answer is the same for every+profile one backend serves.+"""++from __future__ import annotations++from .base import Params, Result+from .registry import method+++class MachineInfo(Result):+ """Measured hardware; a key that was not measured is absent."""++ os_family: str | None = None+ os_release: str | None = None+ native_arch: str | None = None+ cpu_model: str | None = None+ ram_gb: int | None = None+ gpu_class: str | None = None+ vendor: str | None = None+ wsl: bool | None = None+ container: bool | None = None+++class MachineFactsResult(Result):+ """``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``full_name`` is the OS account's+ real name (never a login handle) and ``locale`` its first UI language; each is null when the OS has none."""++ machine: MachineInfo+ machine_kind: str+ has_nvidia_gpu: bool+ is_spark: bool+ locale: str | None = None+ full_name: str | None = None+++method("machine.facts", params=Params, result=MachineFactsResult,+ doc="Facts about the machine running this backend and its OS account, for the desktop first run.")diff --git a/tui_gateway/methods_machine.py b/tui_gateway/methods_machine.pynew file mode 100644index 00000000000..c3bddef7d4b--- /dev/null+++ b/tui_gateway/methods_machine.py@@ -0,0 +1,22 @@+"""``machine.facts``: the host summary the desktop first-run questionnaire branches on.++Bodies are rebound onto server.py's globals (method_ctx.bind_module) and reference them bare.+"""++from __future__ import annotations++from .method_ctx import HandlerRegistry, bind_module++_registry = HandlerRegistry()+method = _registry.method+++# Unscoped on purpose: hardware and the OS account belong to the host, not to any profile home.+@method("machine.facts")+def _(rid, params: dict) -> dict:+ from hermes_platform.host.summary import summary+ return _ok(rid, summary())+++def register(server) -> None:+ bind_module(globals(), server, skip=("_",))diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex 44316003ba4..42fadb827e6 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -3676,7 +3676,7 @@ from . import (methods_vault as _methods_vault, methods_free_tier as _methods_free_tier,methods_connectors as _methods_connectors, methods_connectors_account as _methods_connectors_account,methods_display as _methods_display, methods_display_watch as _methods_display_watch,- methods_onboarding as _methods_onboarding, methods_i18n as _methods_i18n,+ methods_onboarding as _methods_onboarding, methods_i18n as _methods_i18n, methods_machine as _methods_machine,methods_shared_metrics as _methods_shared_metrics, methods_start_chat as _methods_start_chat,methods_plugin_catalog as _methods_plugin_catalog)@@ -3690,6 +3690,6 @@ for _m in (_methods_bot_relay, _prompt_turn, _billing_view, _methods_projects, _methods_session_foreign,_methods_session_control, _methods_subagents, _methods_vault, _methods_free_tier, _methods_connectors,_methods_connectors_account, _methods_display, _methods_display_watch, _methods_onboarding,- _methods_i18n, _methods_shared_metrics, _methods_start_chat, _methods_plugin_catalog):+ _methods_i18n, _methods_machine, _methods_shared_metrics, _methods_start_chat, _methods_plugin_catalog):_m.register(sys.modules[__name__])del _m