Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(home): make the connect flow honest about every way it can fail
nirholas68f570f4e9f3
diff --git a/api/home/[id].js b/api/home/[id].jsindex 29ec6a28e..5e52a6039 100644--- a/api/home/[id].js+++ b/api/home/[id].js@@ -19,6 +19,7 @@ import { requireCsrf } from '../_lib/csrf.js';import { filterGraphForScope, publicHome, resolveHomeAccess } from '../_lib/home/access.js';import { homeError, toHomeFailure } from '../_lib/home/errors.js';import { revokeConnection } from '../_lib/home/store.js';+import { revokeAtRelay } from '../_lib/home/relay.js';import { closeHome, snapshot } from '../_lib/home/runtime.js';import { cors, error, json, method, rateLimited, wrap } from '../_lib/http.js';import { limits } from '../_lib/rate-limit.js';@@ -80,8 +81,22 @@ async function handleRevoke(req, res, { caller, home }) {// opened earlier is already authenticated. Drop it so an open SSE stream stops// now rather than at the end of the idle window.closeHome(home.id);+ // A relayed home has a second, longer-lived socket: the one the house itself+ // opened outward to the relay. Revocation has to be both-ended or "I+ // disconnected my home" would leave that tunnel standing until its next+ // heartbeat. This is push, not poll, and it is deliberately not awaited into+ // the failure path: the database row already gates every session, so a relay+ // that is briefly unreachable must not make disconnecting fail.+ const relayDrop = home.transport === 'relay' && home.relay_id ? await revokeAtRelay(home.relay_id) : null;+ if (relayDrop && !relayDrop.ok) {+ console.warn(`[home] relay revoke for ${home.relay_id} did not land: ${relayDrop.detail}`);+ }return json(res, 200, {revoked: true,+ // Whether the house's own outbound socket was dropped at the relay, so an+ // operator reading a log can tell "revoked and the tunnel is down" from+ // "revoked, and the relay did not answer when we told it".+ ...(relayDrop ? { relay_dropped: Boolean(relayDrop.ok) } : {}),// True on the first call, false on every one after it. The client renders// the same "disconnected" state either way; this is for a log.changed: result.revoked,diff --git a/api/home/satellite.js b/api/home/satellite.jsindex 7b5f307b7..68f030648 100644--- a/api/home/satellite.js+++ b/api/home/satellite.js@@ -122,7 +122,7 @@ export default wrap(async (req, res) => {// Distinguishing them would turn this endpoint into an oracle for// guessing codes, and none of the four is actionable differently: the// fix is always "get a fresh code".- return error(res, 400, 'invalid_code', 'that pairing code is not valid. Codes are single use and expire after 15 minutes; generate a new one at /home/satellite.');+ return error(res, 400, 'invalid_code', 'that pairing code is not valid. Codes are single use and expire after 15 minutes; generate a new one at /smart-home/satellite.');}const [agentRow] = await sql`select id, name, avatar_id from agent_identities where id = ${result.satellite.agent_id} limit 1`;diff --git a/data/changelog.json b/data/changelog.jsonindex 3940b3f5c..35d36d406 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -25875,6 +25875,15 @@"improvement"],"link": "/status"+ },+ {+ "date": "2026-09-03",+ "title": "Connect your house to your agent, and see every way it can go wrong",+ "summary": "The /smart-home page now takes you from \"I have a Home Assistant somewhere\" to a connected house, and it is honest at every step. An address that only exists on your home network is refused the moment you type it, with the two real ways round it, instead of spinning for fifteen seconds. A rejected token says so and puts the cursor back in the token box. A house that stops answering keeps its rooms on screen, marked stale with how long ago it last replied, rather than blanking out. Your access token is sent once, encrypted at rest, and never comes back to the page: it is not in your browser storage, not in a URL, and not in any response. Disconnecting says plainly that the stored token is erased and reminds you to delete it in Home Assistant too.",+ "tags": [+ "feature"+ ],+ "link": "/smart-home"}]}diff --git a/packages/home-bridge/src/mcp.js b/packages/home-bridge/src/mcp.jsindex 868ce1864..0de8806e3 100644--- a/packages/home-bridge/src/mcp.js+++ b/packages/home-bridge/src/mcp.js@@ -10,6 +10,11 @@* It is optional on purpose: `mcp_server` needs setting up, while the WebSocket* API in bridge.js works on every instance with nothing but a token. This is an* upgrade, never a requirement.+ *+ * Two transports, tried in that order, because Home Assistant moved this+ * endpoint: `/api/mcp` (Streamable HTTP) on current releases, `/mcp_server/sse`+ * (SSE) on the older ones still in wide use. Which one a house speaks is+ * discovered by asking it, never by reading its version number.*/import { ERR, HomeBridgeError } from './errors.js';@@ -39,35 +44,70 @@ export async function connectHomeMcp({ baseUrl, token, api, clientName = 'three.let Client;let StreamableHTTPClientTransport;+ let SSEClientTransport;try {({ Client } = await import('@modelcontextprotocol/sdk/client/index.js'));({ StreamableHTTPClientTransport } = await import('@modelcontextprotocol/sdk/client/streamableHttp.js'));+ ({ SSEClientTransport } = await import('@modelcontextprotocol/sdk/client/sse.js'));} catch (cause) {throw new HomeBridgeError(ERR.NO_MCP, 'The MCP channel needs @modelcontextprotocol/sdk installed alongside this package.', cause);}- const url = new URL(`${http}/api/mcp${api ? `/${api}` : ''}`);- const transport = new StreamableHTTPClientTransport(url, {- requestInit: { headers: { authorization: `Bearer ${token}` } },- // A server dialling a user-supplied URL passes a fetch pinned to the- // addresses its SSRF guard validated; the browser has nothing to pin.- ...(fetchImpl ? { fetch: fetchImpl } : {}),- });const client = new Client({ name: clientName, version: '0.1.0' }, { capabilities: {} });+ const attempts = [+ { transport: 'streamable-http', url: new URL(`${http}/api/mcp${api ? `/${api}` : ''}`) },+ { transport: 'sse', url: new URL(`${http}/mcp_server/sse`) },+ ];- try {- await client.connect(transport);- } catch (cause) {- // A 404 here is the ordinary case, not a fault: the integration is simply- // not set up. Say which one it is so the UI can offer the right next step.- const status = cause?.code ?? cause?.status;- if (status === 404 || /404/.test(String(cause?.message || ''))) {- throw new HomeBridgeError(ERR.NO_MCP, 'This home does not have the Model Context Protocol Server integration enabled. Add it in Settings, Devices and services, to give your agent your own curated tools.', cause);- }- if (status === 401 || status === 403) {- throw new HomeBridgeError(ERR.AUTH, 'Home Assistant rejected that token on the MCP endpoint.', cause);+ let connected = null;+ let lastCause = null;+ for (const attempt of attempts) {+ const transport =+ attempt.transport === 'streamable-http'+ ? new StreamableHTTPClientTransport(attempt.url, {+ requestInit: { headers: authHeaders(token) },+ // A server dialling a user-supplied URL passes a fetch pinned to+ // the addresses its SSRF guard validated; the browser has nothing+ // to pin.+ ...(fetchImpl ? { fetch: fetchImpl } : {}),+ })+ : new SSEClientTransport(attempt.url, {+ requestInit: { headers: authHeaders(token) },+ // The SSE transport opens its stream with a plain GET that carries+ // no requestInit, so the token has to be attached to that fetch+ // too or Home Assistant answers 401 on the stream alone.+ eventSourceInit: {+ fetch: (input, init) =>+ (fetchImpl || fetch)(input, { ...init, headers: { ...(init?.headers || {}), ...authHeaders(token) } }),+ },+ });++ try {+ await client.connect(transport);+ connected = attempt;+ break;+ } catch (cause) {+ lastCause = cause;+ const status = cause?.code ?? cause?.status;+ if (status === 401 || status === 403) {+ throw new HomeBridgeError(ERR.AUTH, 'Home Assistant rejected that token on the MCP endpoint.', cause);+ }+ // Only a 404 means "not here, try the other transport". Anything else is+ // a real outage and must not be retried into a misleading NO_MCP.+ if (!isNotFound(cause)) {+ throw new HomeBridgeError(ERR.UNREACHABLE, `Could not open the MCP channel at ${attempt.url.href}.`, cause);+ }}- throw new HomeBridgeError(ERR.UNREACHABLE, `Could not open the MCP channel at ${url.href}.`, cause);+ }++ if (!connected) {+ // Both transports 404: the integration really is not set up. That is the+ // ordinary case, not a fault, so say which one it is and offer the step.+ throw new HomeBridgeError(+ ERR.NO_MCP,+ 'This home does not have the Model Context Protocol Server integration enabled. Add it in Settings, Devices and services, to give your agent your own curated tools.',+ lastCause,+ );}const { tools } = await client.listTools();@@ -95,7 +135,31 @@ export async function connectHomeMcp({ baseUrl, token, api, clientName = 'three.return {client,tools,+ /** Which transport this house answered on: 'streamable-http' or 'sse'. */+ transport: connected.transport,+ endpoint: connected.url.href,callTool,close: () => client.close(),};}++function authHeaders(token) {+ return { authorization: `Bearer ${token}` };+}++/**+ * A 404 from either transport, however the SDK chose to report it.+ *+ * Home Assistant moved the MCP endpoint between releases: through 2025.10 the+ * integration served only the SSE transport at `/mcp_server/sse`, and the+ * Streamable HTTP endpoint at `/api/mcp` arrived later. Asking for `/api/mcp`+ * on an older house therefore 404s even though its MCP server is running and+ * exposing real tools, which is how a working house came to be reported as+ * having no MCP at all. We try both and let the house answer, rather than+ * parsing its version string and deciding for it.+ */+function isNotFound(cause) {+ const status = cause?.code ?? cause?.status;+ if (status === 404) return true;+ return /\b404\b|not found/i.test(String(cause?.message || ''));+}diff --git a/pages/smart-home.html b/pages/smart-home.htmlindex eda7d51e4..43a96ed49 100644--- a/pages/smart-home.html+++ b/pages/smart-home.html@@ -65,5 +65,9 @@<script src="/nav.js"></script><script type="module" src="/src/home/connect.js"></script>+ <!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>.+ Without it the data-i18n attributes above are inert and the page renders+ English in all 87 locales, and the RTL locales never get their dir flip. -->+ <script type="module" src="/i18n.js"></script></body></html>diff --git a/public/locales/en.json b/public/locales/en.jsonindex d70ccc293..d1c4c6490 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -9129,6 +9129,11 @@"your_ai_deserves_a_body": "Your AI deserves<br>a <em>body.</em>","your_visitors_walk_together": "Your visitors walk<br><em>together.</em>"},+ "home_plan": {+ "eyebrow": "Smart home",+ "lede": "What your plan covers, what you are using, and when it resets. Every limit is here whether or not you are near it, because a quota you only meet at the moment it stops you is a quota nobody showed you. Locking a door, closing a garage or a valve and arming an alarm are never refused by a limit, on any plan.",+ "title": "Your home plan"+ },"hydrate_index": {"connect_wallet": "Connect Wallet","dashboard": "Dashboard",@@ -10595,6 +10600,7 @@"meta_title": "Legal · three.ws","meta_twitter_description": "Every three.ws policy in one place, plus where to report copyright, abuse, or privacy issues.","meta_twitter_title": "Legal · three.ws",+ "nvidia_ngc_container_eula_license_terms_for": "<a class=\"doc\" href=\"/legal/nvidia-ngc-eula\"> <span class=\"doc-title\">NVIDIA NGC Container EULA</span> <span class=\"doc-desc\">License terms for three.ws container images distributed through the NVIDIA NGC catalog.</span> <span class=\"doc-date\">Effective September 2, 2026</span> </a>","policies": "Policies","privacy_policy_what_data_we_collect_why": "<a class=\"doc\" href=\"/legal/privacy\"> <span class=\"doc-title\">Privacy Policy</span> <span class=\"doc-desc\">What data we collect, why we hold it, who we share it with, and the controls you have over it.</span> <span class=\"doc-date\">Effective July 16, 2026</span> </a>","privacy_three_ws_data_requests_access_correc": "<span class=\"who\"><a href=\"mailto:[email protected]\">[email protected]</a></span> <span class=\"what\">Data requests: access, correction, deletion, or a question about how your data is handled.</span>",@@ -10607,9 +10613,60 @@"three_ws_terms_of_service_privacy_policy": "three.ws · <a href=\"/legal/tos\">Terms of Service</a> · <a href=\"/legal/privacy\">Privacy Policy</a> · <a href=\"/\">Home</a>","you_do_not_need_a_lawyer_to": "You do not need a lawyer to reach us, and you do not need to file a formal notice before we will look at a problem. Tell us the URL and what is wrong with it."},+ "legal_nvidia_ngc_eula": {+ "10_disclaimer_of_warranties": "10. Disclaimer of Warranties",+ "11_limitation_of_liability": "11. Limitation of Liability",+ "12_indemnification": "12. Indemnification",+ "13_term_and_termination": "13. Term and Termination",+ "14_export_and_compliance": "14. Export and Compliance",+ "15_governing_law": "15. Governing Law",+ "16_entire_agreement": "16. Entire Agreement",+ "17_contact": "17. Contact",+ "1_relationship_to_nvidia": "1. Relationship to NVIDIA",+ "2_license_grant": "2. License Grant",+ "3_what_the_container_is": "3. What the Container Is",+ "4_model_weights_and_third_party_components": "4. Model Weights and Third-Party Components",+ "5_no_fees": "5. No Fees",+ "6_no_service_levels_no_support_obligation": "6. No Service Levels; No Support Obligation",+ "7_acceptable_use": "7. Acceptable Use",+ "8_data_and_privacy": "8. Data and Privacy",+ "9_intellectual_property": "9. Intellectual Property",+ "because_the_container_is_provided_free_of": "BECAUSE THE CONTAINER IS PROVIDED FREE OF CHARGE, OUR TOTAL AGGREGATE LIABILITY ARISING OUT OF OR RELATED TO IT AND THIS EULA WILL NOT EXCEED ONE HUNDRED U.S. DOLLARS (US$100). SOME JURISDICTIONS DO NOT ALLOW CERTAIN LIMITATIONS, SO SOME OF THE ABOVE MAY NOT APPLY TO YOU.",+ "effective_september_2_2026_terms_of_service": "Effective: September 2, 2026 · <a href=\"/legal/tos\">Terms of Service</a> · <a href=\"/legal/privacy\">Privacy Policy</a>",+ "generate_from_the_container_content_that_inf": "Generate, from the Container, content that infringes another party's intellectual property or likeness rights, or that is unlawful, deceptive, or abusive.",+ "meta_description": "License terms for three.ws container images distributed through the NVIDIA NGC catalog: what the license covers, the model weights it does not ship, and the data the container does not collect.",+ "meta_title": "NVIDIA NGC Container EULA · three.ws",+ "nvidia_ngc_container_end_user_license_agreem": "NVIDIA NGC Container End User License Agreement",+ "privacy_policy": "Privacy Policy",+ "questions_about_this_eula_email_legal_three": "Questions about this EULA? Email <a href=\"mailto:[email protected]\">[email protected]</a>.",+ "redistribute_the_container_as_your_own_produ": "Redistribute the Container as your own product, or represent modified builds as unmodified three.ws images.",+ "remove_obscure_or_alter_any_copyright_licens": "Remove, obscure, or alter any copyright, license, or attribution notice shipped in the image.",+ "the_container_also_includes_open_source_comp": "The Container also includes open-source components licensed by their respective owners, including the NVIDIA CUDA base image and the NVIDIA software it contains, which remain subject to the NVIDIA license terms shipped with them. A complete component and license listing is included in the image and in the repository. Where a third-party license conflicts with this EULA for that component, the third-party license governs that component.",+ "the_container_is_distributed_through_the_ngc": "The Container is distributed through the NGC catalog, operated by NVIDIA Corporation and its affiliates (\"NVIDIA\"). NVIDIA is not a party to this EULA and is not responsible for the Container. Your use of the NGC catalog is also governed by NVIDIA's own terms. This EULA governs your use of the Container itself. Nothing in this EULA makes three.ws an NVIDIA partner, and distribution through NGC is not an NVIDIA endorsement of three.ws or of any output the Container produces.",+ "the_container_is_offered_free_of_charge": "The Container is offered free of charge. No license fees, subscription fees, or usage fees are payable to us for it, and accordingly no refunds apply. You bear the cost of the hardware, cloud capacity, and bandwidth you use to run it. Because the Container is provided at no cost, you acknowledge that you receive it without payment and bear all risk of its use.",+ "the_container_is_provided_as_is_and": "THE CONTAINER IS PROVIDED \"AS IS\" AND \"AS AVAILABLE\" WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT. WE DO NOT WARRANT THAT THE CONTAINER WILL BE UNINTERRUPTED, SECURE, OR ERROR-FREE, THAT IT WILL RUN ON ANY PARTICULAR HARDWARE, OR THAT ITS OUTPUT WILL BE ACCURATE, ORIGINAL, OR FIT FOR ANY PURPOSE. GENERATIVE MODELS PRODUCE UNPREDICTABLE OUTPUT, AND YOU ASSUME ALL RISK ARISING FROM YOUR USE OF THE CONTAINER AND OF ANYTHING IT GENERATES.",+ "the_container_is_provided_without_any_servic": "The Container is provided without any service-level agreement, uptime commitment, or guaranteed support. We may change, re-tag, deprecate, or withdraw any published image at any time and without liability. Support, if any, is best-effort through the public repository, and we are under no obligation to provide it.",+ "the_container_packages_a_gpu_inference_serve": "The Container packages a GPU inference server: our serving code, its Python dependencies, and CUDA build artifacts compiled at image build time. It exposes an HTTP API documented in the listing overview and in the repository at <a href=\"https://github.com/nirholas/three.ws\">github.com/nirholas/three.ws</a>. It is inference software, not a hosted service: you run it on your own hardware, under your own control, and we have no access to it or to anything it produces.",+ "the_container_ships_no_machine_learning_mode": "The Container ships no machine-learning model weights. Weights are obtained by you, at run time, from the upstream publisher named in the listing overview, and your use of them is governed by the upstream license that accompanies them, not by this EULA. You are responsible for reading and complying with that license, including any non-commercial or field-of-use restriction it carries.",+ "the_three_ws_source_code_inside_the": "The three.ws source code inside the Container is licensed under the Apache License, Version 2.0, and your rights in that code are the rights that license grants you. Subject to your compliance with this EULA and with the third-party terms in Section 4, we additionally grant you a worldwide, non-exclusive, non-transferable, revocable license to pull, run, and internally modify the Container image as a whole, for your own use. We reserve all rights not expressly granted.",+ "this_end_user_license_agreement_eula_is": "This End User License Agreement (\"EULA\") is a binding agreement between three.ws (\"we\", \"us\", \"our\") and the individual or entity (\"you\") that pulls, runs, or otherwise uses a three.ws container image published in the NVIDIA NGC catalog (each, the \"Container\"). By pulling or running the Container, you agree to this EULA. If you do not agree, do not pull or run it.",+ "this_eula_applies_for_as_long_as": "This EULA applies for as long as you retain or run the Container. You may end it at any time by deleting the image and ceasing all use. We may terminate the license in Section 2 for breach. On termination you must stop running the Container and delete it; the Apache-2.0 rights in the underlying source code survive on their own terms. Sections 4 and 8 through 15 survive termination.",+ "this_eula_is_governed_by_the_laws": "This EULA is governed by the laws of the State of Delaware, USA, without regard to its conflict-of-law provisions. Any dispute will be resolved exclusively in the state or federal courts located in Delaware, and you consent to their jurisdiction.",+ "this_eula_together_with_the_three_ws": "This EULA, together with the three.ws <a href=\"/legal/tos\">Terms of Service</a> and <a href=\"/legal/privacy\">Privacy Policy</a> (incorporated by reference), is the entire agreement between you and us regarding the Container and supersedes any prior agreements on that subject. If any provision is held unenforceable, the remaining provisions remain in effect. Our failure to enforce any right is not a waiver of it.",+ "three_ws_terms_of_service_privacy_policy": "three.ws · <a href=\"/legal/tos\">Terms of Service</a> · <a href=\"/legal/privacy\">Privacy Policy</a> · <a href=\"/\">Home</a>",+ "to_the_maximum_extent_permitted_by_law": "TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT WILL THREE.WS OR ITS OFFICERS, DIRECTORS, EMPLOYEES, OR AGENTS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES, OR FOR ANY LOSS OF PROFITS, REVENUE, DATA, GOODWILL, OR OTHER INTANGIBLE LOSSES, ARISING OUT OF OR RELATED TO THE CONTAINER OR THIS EULA, WHETHER IN CONTRACT, TORT, OR OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.",+ "use_the_container_in_the_operation_of": "Use the Container in the operation of safety-critical systems, including life support, medical devices, aircraft navigation, or nuclear facilities.",+ "use_the_container_in_violation_of_any": "Use the Container in violation of any applicable law, regulation, or third-party right, including the upstream model license described in Section 4.",+ "we_and_our_licensors_retain_all_right": "We and our licensors retain all right, title, and interest in the three.ws code and marks in the Container, except as expressly licensed in Section 2. You own the outputs you generate with the Container, to the extent the upstream model license permits, and we claim no rights in them. Feedback you provide may be used by us without restriction or obligation to you.",+ "we_may_terminate_the_license_in_section": "We may terminate the license in Section 2 immediately for any breach of this Section, without notice and without liability.",+ "you_agree_not_to": "You agree not to:",+ "you_agree_to_indemnify_defend_and_hold": "You agree to indemnify, defend, and hold harmless three.ws and its officers, directors, employees, and agents from any claims, liabilities, damages, judgments, losses, and expenses (including reasonable legal fees) arising out of or related to your use of the Container, the inputs you process with it, the outputs you generate, or your violation of this EULA, of any upstream model license, or of any applicable law or third-party right.",+ "you_represent_that_you_are_not_located": "You represent that you are not located in, and will not use the Container in, any country or by any party subject to U.S. or other applicable sanctions or export restrictions, and that you will comply with all applicable export-control and sanctions laws, including those NVIDIA applies to the CUDA components in the image."+ },"legal_privacy": {"10_mcp_connectors_ai_processing_payments": "10. MCP Connectors, AI Processing & Payments","10a_free_3d_actions_chatgpt_gpt_store": "10a. Free 3D Actions (ChatGPT / GPT Store)",+ "10b_connected_homes_three_ws_home": "10b. Connected Homes (three.ws Home)","11_changes_to_this_policy": "11. Changes to This Policy","12_contact": "12. Contact","1_information_we_collect": "1. Information We Collect",@@ -10633,6 +10690,8 @@"authentication_security": "Authentication, security","business_transfers_in_connection_with_a_merg": "<strong>Business transfers:</strong> in connection with a merger, acquisition, or sale of assets, with notice to affected users.","category": "Category",+ "connected_home_data": "Connected home data",+ "connected_home_data_is_kept_while_the": "<strong>Connected home data</strong> is kept while the home is connected and is deleted when you delete the home or your account. The home action log has its own window, 90 days by default, which you control per home and can shorten to a single day. We never store the names of your rooms or devices, their states, or any audio from voice control. The full inventory is in <a href=\"/docs/home-privacy\">Home privacy and retention</a>.","content_you_upload": "Content you upload","cookies_local_storage": "Cookies & Local Storage","csrf_cookies_short_lived_for_siwe_siws": "<strong>CSRF cookies</strong> (<code>__Host-csrf-siwe</code>, <code>__Host-csrf-siws</code>): Short-lived, for SIWE/SIWS replay protection.",@@ -10647,6 +10706,7 @@"how_the_prompt_is_used_the_prompt": "<strong>How the prompt is used:</strong> the prompt is forwarded to our generation provider (NVIDIA NIM / Microsoft TRELLIS) solely to produce the model. Do not include personal or confidential information in the prompt.","identity_verification_subscription_status": "Identity verification, subscription status","if_you_are_a_california_resident_the": "If you are a California resident: the categories of personal information we collect are listed in Section 1, the purposes in Section 2, and the recipients in Section 4. We do <strong>not</strong> sell personal information and do <strong>not</strong> share it for cross-context behavioral advertising, so there is nothing to opt out of; browser opt-out signals such as Global Privacy Control are honored by default because there is no sale or sharing to stop. We do not use or disclose sensitive personal information for purposes requiring a right to limit.",+ "if_you_connect_a_home_assistant_instance": "If you connect a Home Assistant instance, the access token you provide is a credential to a physical building. We encrypt it at rest with the same primitive we use for custodial wallet keys, never display it again, and erase it the moment you disconnect the home. Actions that open a building (unlocking, opening, disarming) always require an explicit human confirmation, which cannot be produced by an AI model, until you grant a standing allowance for one specific entity.","infrastructure_providers_google_cloud_platfo": "<strong>Infrastructure providers:</strong> Google Cloud Platform (hosting and compute), Neon (database), Cloudflare (storage and CDN), Resend (transactional email), and Privy (optional sign-in). Each processes data on our behalf under its own privacy policy and data-processing terms.","legal_acceptance_records": "Legal acceptance records","legal_acceptance_records_your_acceptance_of": "<strong>Legal acceptance records</strong> (your acceptance of the Terms of Service and Risk Disclosure) are retained for the life of your account and afterward for as long as needed to establish or defend legal claims. This retention is a legal obligation and survives an account-deletion request.",@@ -10661,6 +10721,7 @@"meta_twitter_title": "Privacy Policy · three.ws","oauth_scoped_access_when_you_connect_via": "<strong>OAuth-scoped access:</strong> when you connect via OAuth, the connector can read and write only the three.ws account data covered by the scopes you grant (avatars, agents, memory, profile). It cannot access your AI client's chat history, memory, or local files.","on_chain_data": "On-chain data",+ "operating_the_three_ws_home_features_you": "Operating the three.ws Home features you enabled, and giving you an audit trail of them","payment_data_x402_paid_tools_settle_in": "<strong>Payment data (x402):</strong> paid tools settle in USDC via the x402 payment protocol. When you pay per call we receive your public wallet address and the payment/settlement transaction signature, verified through a payment facilitator (Coinbase CDP and/or the public x402.org facilitator). We never receive, request, or store your private keys or seed phrase. The only token three.ws itself references is <code>$THREE</code>; USDC is used purely for settlement.","payment_facilitators_for_paid_features_settl": "<strong>Payment facilitators:</strong> for paid features settled on-chain (x402), payment verification runs through a facilitator such as Coinbase Developer Platform or the public x402.org facilitator. They see your public wallet address and transaction signatures, never private keys.","privacy_policy": "Privacy Policy",@@ -10673,6 +10734,7 @@"session_data": "Session data","table_information_we_collect_label": "Information we collect","terms_of_service_version_accepted_risk_discl": "Terms of Service version accepted, Risk Disclosure version accepted, timestamp, IP address, user agent, which flow recorded it",+ "the_address_and_label_of_a_home": "The address and label of a Home Assistant instance you connect, its encrypted access token, entity and area <em>counts</em>, standing per-entity permissions you grant, household members and invitations, and a log of every action the agent takes in that home","the_service_is_not_directed_to_children": "The Service is not directed to children under 13. We do not knowingly collect personal information from children under 13. If we learn we have collected such information, we will delete it promptly. Features that move real funds additionally require users to be at least 18 (see the <a href=\"/legal/tos\">Terms of Service</a>).","the_service_is_operated_from_the_united": "The Service is operated from the United States and data is processed on infrastructure located in the United States. If you use the Service from outside the U.S., your information is transferred to and processed in the U.S. Where GDPR applies, transfers to our processors rely on their standard contractual clauses or an applicable adequacy framework.","third_party_ai_model_providers_generation_an": "<strong>Third-party AI model providers:</strong> generation and editing tools forward your prompts and asset URLs to upstream model APIs to produce results. Depending on the tool, these may include NVIDIA NIM (Microsoft TRELLIS), Meshy, Replicate, Stability, Hugging Face, OpenAI, Anthropic, Google (Vertex AI), and IBM (Granite). Each provider processes the input under its own privacy policy. Do not submit confidential or personal data in tool prompts.",@@ -10694,6 +10756,7 @@"wallet_addresses_and_on_chain_registrations": "Wallet addresses and on-chain registrations are public by nature of blockchain technology. We index publicly available on-chain data (ERC-8004 events, Metaplex metadata) to power the agent directory. We do not create profiles that link on-chain identity to off-chain personal information beyond what you explicitly provide. Note that anything written to a public blockchain is permanent and outside our control; we cannot delete it.","we_do_not_collect_advertising_identifiers_us": "We do <strong>not</strong> collect advertising identifiers, use third-party tracking pixels, or sell personal data to any third party.","we_do_not_sell_your_personal_data": "We do not sell your personal data, and we do not share it for cross-context behavioral advertising. We share information only with:",+ "we_do_not_store_the_names_of": "We do not store the names of your rooms, devices or scenes, and we do not store their states. There is no record of which lights were on, or when. The room graph is read live from your own instance and held in memory only while the connection is open. Voice audio is never stored.","we_do_not_use_third_party_advertising": "We do not use third-party advertising cookies.","we_may_update_this_privacy_policy_we": "We may update this Privacy Policy. We will notify you of material changes by email or a prominent notice on the Service. The \"Effective\" date and version at the top reflect the most recent revision.","we_protect_your_data_with_industry_standard": "We protect your data with industry-standard measures: TLS in transit, encrypted storage, hashed session tokens and IP addresses, scoped credentials, and audit logging. No system is perfectly secure; if we learn of a breach affecting your personal data we will notify you and, where required, regulators without undue delay and within the timelines applicable law requires (for example, 72 hours to supervisory authorities under GDPR).",@@ -10703,6 +10766,7 @@"what_we_receive_only_the_text_prompt": "<strong>What we receive:</strong> only the text prompt you send. We do not ask for, receive, or store any name, email, wallet address, or other personal information through this endpoint.","what_we_return_a_public_url_to": "<strong>What we return:</strong> a public URL to the generated GLB model (hosted on our CDN) and a link to view it. The response contains no account identifiers or personal data. Generated model files are served from public URLs so you can download and share them; treat a model URL as public.","why": "Why",+ "you_can_see_export_and_delete_everything": "You can see, export and delete everything this feature holds at any time, and set your own retention window for the action log. See <a href=\"/docs/home-privacy\">Home privacy and retention</a> for the complete inventory and the API.","you_have_the_right_to_lodge_a": "You have the right to lodge a complaint with your local supervisory authority. You may also contact us first at <a href=\"mailto:[email protected]\">[email protected]</a>; we would welcome the chance to resolve your concern directly.","you_have_the_rights_to_know_access": "You have the rights to know, access, correct, delete, and port your personal information, and to not be discriminated against for exercising them. Exercise them via <a href=\"mailto:[email protected]\">[email protected]</a> (Section 6). We verify requests using your signed-in session, your account email, or a message signed by your wallet. An authorized agent may act for you with written permission."},@@ -14087,6 +14151,38 @@"what_the_article_covers": "What the article covers","x402": "x402"},+ "news_huggingface_building_3d_ai_agents": {+ "3d": "3d",+ "agents": "agents",+ "all_news": "← All news",+ "discover": "Discover",+ "distribution_the_web_component_ar_seven_host": "<strong>Distribution:</strong> the web component, AR, seven hosted MCP servers, ChatGPT, Android, and the terminal.",+ "every_partner_and_program_named_with_the": "<strong>Every partner and program</strong> named with the status it actually carries.",+ "huggingface": "huggingface",+ "inside_three_ws_our_second_hugging_face": "Inside three.ws: our second Hugging Face article, and the whole stack in one piece",+ "marketplace": "Marketplace",+ "mcp": "mcp",+ "meta_description": "The whole stack in one article on Hugging Face: every 3D generation model and where it runs, rigging and retargeting for any humanoid, the motion library and motion models, the multi-model brain, typed memory, the seven-layer guard chain, x402 agent payments, MCP and ChatGPT distribution, and every program and partner behind it, with a live 3D model embedded in the page.",+ "meta_og_description": "The whole stack in one article on Hugging Face: every 3D generation model and where it runs, rigging and retargeting for any humanoid, the motion library and motion models, the multi-model brain, typed memory, the seven-layer guard chain, x402 agent payments, MCP and ChatGPT distribution, and every program and partner behind it, with a live 3D model embedded in the page.",+ "meta_og_title": "Inside three.ws: our second Hugging Face article, and the whole stack in one piece",+ "meta_title": "Inside three.ws: our second Hugging Face article, and the whole stack in one piece — three.ws",+ "meta_twitter_description": "The whole stack in one article on Hugging Face: every 3D generation model and where it runs, rigging and retargeting for any humanoid, the motion library and motion models, the multi-model brain, typed memory, the seven-layer guard chain, x402 agent payments, MCP and ChatGPT distribution, and every program and partner behind it, with a live 3D model embedded in the page.",+ "meta_twitter_title": "Inside three.ws: our second Hugging Face article, and the whole stack in one piece",+ "most_ai_agents_are_a_text_box": "<strong>Most AI agents are a text box. Ours walk into your room in AR, remember what you told them last week, and pay each other for work.</strong> That is how our second community article on Hugging Face opens, and the rest is the long version of what three.ws is, written to be checked: every claim links to the code, and the model files sit in the same account.",+ "news": "News",+ "news_announcements": "News & Announcements",+ "originally_published_on_x": "<em>Originally published on <a href=\"https://huggingface.co/blog/three-ws/building-3d-ai-agents-end-to-end\" rel=\"noopener\">X</a>.</em>",+ "read_it_huggingface_co_blog_three_ws": "Read it: <a href=\"https://huggingface.co/blog/three-ws/building-3d-ai-agents-end-to-end\" rel=\"noopener\">huggingface.co/blog/three-ws/building-3d-ai-agents-end-to-end</a>",+ "the_3d_pipeline_trellis_hunyuan3d_2_1": "<strong>The 3D pipeline:</strong> TRELLIS, Hunyuan3D 2.1, TripoSG, and TripoSR by lane and by hardware, the selfie lane and its fidelity metric, Make-It-Animatable rigging, retargeting across roughly twenty bone-naming families, the 3,000-clip motion library, and text- and video-to-motion.",+ "the_agent_a_brain_that_routes_across": "<strong>The agent:</strong> a brain that routes across 20-plus models with deterministic failover, an eight-step tool loop, typed memory, the Empathy Layer, voice and lip-sync, and the seven-layer guard chain in front of every fund-moving call.",+ "the_article_embeds_a_rigged_avatar_you": "The article embeds a rigged avatar you can orbit in place, rendered by <a href=\"https://huggingface.co/spaces/three-ws/avatar-viewer\" rel=\"noopener\">our Space</a>, and avatars that wave as animated PNGs from the platform's render API.",+ "the_economy_on_chain_identity_x402_payments": "<strong>The economy:</strong> on-chain identity, x402 payments with the live settlement numbers, and the agent wallet.",+ "three_ws": "three.ws",+ "three_ws_home_news_rss_x_github": "© three.ws · <a href=\"/\">Home</a> · <a href=\"/news\">News</a> · <a href=\"/rss/announcements.xml\">RSS</a> · <a href=\"https://x.com/trythreews\" rel=\"noopener\">X</a> · <a href=\"https://github.com/nirholas/three.ws\" rel=\"noopener\">GitHub</a>",+ "visit_three_ws": "Visit three.ws →",+ "what_the_article_covers": "What the article covers",+ "x402": "x402"+ },"news_ibm_collaboration_showcase": {"a_formal_ibm_partnership": "A formal IBM partnership","agent_3d": "agent-3d",@@ -14178,6 +14274,7 @@"april_30_2026_googlecloud_x_three_ws": "<a class=\"post-link\" href=\"/news/2049997615421649363\"> <div class=\"post-body\"> <div class=\"post-date\"><time datetime=\"2026-04-30T23:41:33.000Z\">April 30, 2026</time></div> <h2 class=\"post-title\">@GoogleCloud x three.ws</h2> <p class=\"post-summary\">@GoogleCloud x three.ws We are excited to announce we are joining forces with Google Cloud! Google Cloud's infrastructure unlocks the next phase of three.ws development. Google Cloud enables us to dramatically expand our 3D rendering pipeline, global inference capacity, and en…</p> </div> </a>","april_30_2026_meeting_with_google_cloud": "<a class=\"post-link\" href=\"/news/2049765915575914834\"> <div class=\"post-body\"> <div class=\"post-date\"><time datetime=\"2026-04-30T08:20:51.000Z\">April 30, 2026</time></div> <h2 class=\"post-title\">meeting with Google Cloud team for Google Cloud for Web3 Startups partnership</h2> <p class=\"post-summary\">meeting with Google Cloud team for Google Cloud for Web3 Startups partnership more compute incoming — expanding our 3D rendering pipeline and global inference capacity for browser-native on-chain agents.</p> </div> </a>","april_30_2026_solana_wallet_integration_for": "<a class=\"post-link\" href=\"/news/2049762836881301865\"> <div class=\"post-body\"> <div class=\"post-date\"><time datetime=\"2026-04-30T08:08:37.000Z\">April 30, 2026</time></div> <h2 class=\"post-title\">Solana wallet integration for autonomous 3D agents now live on @trythreews</h2> <p class=\"post-summary\">Solana wallet integration for autonomous 3D agents now live on @trythreews Your agent can now hold and spend money. Give your agents access to money. Let them work while you sleep. three.ws</p> </div> </a>",+ "august_29_2026_inside_three_ws_our": "<a class=\"post-link\" href=\"/news/huggingface-building-3d-ai-agents\"> <div class=\"post-body\"> <div class=\"post-date\"><time datetime=\"2026-08-29T12:00:00.000Z\">August 29, 2026</time></div> <h2 class=\"post-title\">Inside three.ws: our second Hugging Face article, and the whole stack in one piece</h2> <p class=\"post-summary\">The whole stack in one article on Hugging Face: every 3D generation model and where it runs, rigging and retargeting for any humanoid, the motion library and motion models, the multi-model brain, typed memory, the seven-layer guard chain, x402 agent payments, MCP and ChatGPT distribution, and every program and partner behind it, with a live 3D model embedded in the page.</p> <div class=\"tag-list\"><span class=\"tag\">huggingface</span><span class=\"tag\">3d</span><span class=\"tag\">agents</span><span class=\"tag\">mcp</span><span class=\"tag\">x402</span></div> </div> </a>","discover": "Discover","july_13_2026_giving_ai_agents_3d": "<a class=\"post-link\" href=\"/news/huggingface-bodies-and-wallets\"> <div class=\"post-body\"> <div class=\"post-date\"><time datetime=\"2026-07-13T12:00:00.000Z\">July 13, 2026</time></div> <h2 class=\"post-title\">Giving AI Agents 3D Bodies, Real Jobs, and Wallets on three.ws</h2> <p class=\"post-summary\">Our community article on Hugging Face, the platform where the machine-learning world publishes and checks models: four problems an embodied agent has to solve, and the shipped surface that answers each one. Published alongside a repository of rigged avatars and a running Space that renders them in the browser.</p> <div class=\"tag-list\"><span class=\"tag\">huggingface</span><span class=\"tag\">3d</span><span class=\"tag\">agents</span><span class=\"tag\">x402</span><span class=\"tag\">agent-payments</span><span class=\"tag\">blog</span></div> </div> </a>","july_16_2026_three_ws_joins_the": "<a class=\"post-link\" href=\"/news/quicknode-startup-program\"> <div class=\"post-body\"> <div class=\"post-date\"><time datetime=\"2026-07-16T12:00:00.000Z\">July 16, 2026</time></div> <h2 class=\"post-title\">three.ws Joins the Quicknode Startup Program</h2> <p class=\"post-summary\">three.ws has been accepted into the Quicknode Startup Program and approved for free infrastructure credits: more RPC headroom for the Solana-first agent economy, provider redundancy, and Quicknode's founder network.</p> <div class=\"tag-list\"><span class=\"tag\">quicknode</span><span class=\"tag\">infrastructure</span><span class=\"tag\">solana</span><span class=\"tag\">rpc</span></div> </div> </a>",@@ -18218,6 +18315,11 @@"meta_twitter_description": "Browse, search, and install agent skills — tool packs, knowledge bases, and capabilities that make AI agents smarter.","meta_twitter_title": "Skills Marketplace · three.ws"},+ "smart_home": {+ "eyebrow": "Smart home",+ "lede": "Connect a Home Assistant instance and your agent can see every room, read every device, and run the scenes you already built. Reads are free. Anything that unlocks, opens or disarms stops and asks you first, every time.",+ "title": "Put your agent inside your house"+ },"smart_money": {"all": "All","all_2": "All",diff --git a/scripts/publish-mcp-servers.mjs b/scripts/publish-mcp-servers.mjsindex cad6b4236..6ad4f5fc6 100644--- a/scripts/publish-mcp-servers.mjs+++ b/scripts/publish-mcp-servers.mjs@@ -124,6 +124,7 @@ const SERVERS = [},{ key: 'herald-mcp', dir: 'packages/herald-mcp', manifest: 'packages/herald-mcp/server.json' },{ key: 'knock-mcp', dir: 'packages/knock-mcp', manifest: 'packages/knock-mcp/server.json' },+ { key: 'home-mcp', dir: 'packages/home-mcp', manifest: 'packages/home-mcp/server.json' },{ key: 'remote-main', manifest: 'server.json' },{ key: 'remote-pumpfun', manifest: 'server-pumpfun.json' },{ key: 'remote-3d', manifest: 'server-3d.json' },diff --git a/scripts/publish-packages.mjs b/scripts/publish-packages.mjsindex a71442443..9532fd91a 100644--- a/scripts/publish-packages.mjs+++ b/scripts/publish-packages.mjs@@ -48,6 +48,10 @@ const PACKAGES = [{ key: 'pumpfun-skills', dir: 'packages/pumpfun-skills' },{ key: 'irl', dir: 'packages/irl' },{ key: 'tty-avatar', dir: 'packages/tty-avatar' },+ // The home lane's client library. Pre-1.0 and its API will move: an agent+ // reaching a real building is new enough that the shape is not settled, and+ // saying so in the README beats freezing it early.+ { key: 'home-bridge', dir: 'packages/home-bridge' },// Assistant widget SDK — the one-tag / npm loader for the 3D avatar// assistant. Has a real build (build.mjs, run via prepublishOnly) that also// mirrors the one-tag bundle to public/assistant/v1.js. Standalone dir, likediff --git a/services/home-satellite/src/index.js b/services/home-satellite/src/index.jsindex e3ca4aa26..2acf084a4 100755--- a/services/home-satellite/src/index.js+++ b/services/home-satellite/src/index.js@@ -23,7 +23,7 @@ if (argv.includes('--help') || argv.includes('-h')) {process.stdout.write(`three.ws home satellite ${SERVICE_VERSION}node src/index.js satellite [flags]- --pairing-code <code> redeem a code from three.ws/home/satellite (first run only)+ --pairing-code <code> redeem a code from three.ws/smart-home/satellite (first run only)--name <name> what Home Assistant calls this satellite--area <area> suggested area for the device--api-base <url> three.ws base URL (default https://three.ws)diff --git a/services/home-satellite/src/pairing.js b/services/home-satellite/src/pairing.jsindex debc4d881..d9bcaddb4 100644--- a/services/home-satellite/src/pairing.js+++ b/services/home-satellite/src/pairing.js@@ -50,7 +50,7 @@ export async function saveIdentity(stateDir, identity) {** @param {object} options* @param {string} options.apiBase e.g. https://three.ws- * @param {string} options.code The code from three.ws/home/satellite.+ * @param {string} options.code The code from three.ws/smart-home/satellite.* @param {string} options.name What the satellite should be called.* @param {string} options.version This service's version.* @param {string|null} [options.area]diff --git a/services/home-satellite/src/satellite.js b/services/home-satellite/src/satellite.jsindex f104f4c75..626261b0a 100644--- a/services/home-satellite/src/satellite.js+++ b/services/home-satellite/src/satellite.js@@ -151,7 +151,7 @@ export class WyomingSatellite extends EventEmitter {// Refuse, but say why. Home Assistant logs the error text, so the// person who set this up sees "this satellite has not been paired"// rather than a bare connection reset.- socket.write(encodeEvent(errorEvent('This three.ws satellite has not been paired. Run it with a pairing code from three.ws/home/satellite.', 'unpaired')));+ socket.write(encodeEvent(errorEvent('This three.ws satellite has not been paired. Run it with a pairing code from three.ws/smart-home/satellite.', 'unpaired')));this.emit('log', { level: 'warn', event: 'wyoming.refused_unpaired', remote: socket.remoteAddress });socket.end();return;diff --git a/src/home/home.css b/src/home/home.cssindex 7d3b59e66..315bf8e32 100644--- a/src/home/home.css+++ b/src/home/home.css@@ -132,6 +132,22 @@.hm-reveal:hover { color: var(--ink); border-color: var(--hm-line-strong); }.hm-reveal:focus-visible { outline: none; border-color: var(--hm-focus); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.22); }.hm-reveal:active { background: var(--hm-panel); }+/*+ * A finger is not a mouse pointer. At its text size this button renders 52x31,+ * which is fine to click and too small to tap: WCAG 2.5.5 asks 44x44 of a touch+ * target, and this one sits inside the token field, where a miss puts the+ * caret in the middle of a pasted credential. Only coarse pointers pay the+ * extra height, so the desktop layout of the field is untouched.+ */+@media (pointer: coarse) {+ .hm-reveal {+ min-width: 44px;+ min-height: 44px;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ }+}/* ── Buttons ─────────────────────────────────────────────────────────────── */diff --git a/src/home/members.js b/src/home/members.jsnew file mode 100644index 000000000..b3b79a397--- /dev/null+++ b/src/home/members.js@@ -0,0 +1,405 @@+/**+ * The household panel: who else can reach this house, and what they may do.+ *+ * Mounted on every home card in the manage view. It renders what the SERVER+ * says, never what it decided for itself: the roster response carries this+ * caller's own role, the roles they are allowed to hand out, and a per-member+ * flag for whether they may administer that person. A member with no roster+ * authority sees the household and no controls, because hiding the fact that+ * other people hold keys to the house you are in would be the wrong secret to+ * keep, and showing a button that 403s would be the wrong promise to make.+ *+ * The rule this panel exists to make legible, said in the UI rather than only in+ * the schema: a guest can turn a light on and can never authorise unlocking a+ * door. Every role's line says what it can and cannot do, at the moment somebody+ * chooses one, rather than in documentation nobody opens.+ */++import { listHousehold, inviteToHousehold, removeFromHousehold, revokeHouseholdInvite, setHouseholdRole } from './api.js';+import { clear, el, noticeEl } from './connect.js';++/**+ * One line per role, shown next to the picker.+ *+ * Written for the person choosing, not for the schema. "Cannot" comes second and+ * is never omitted: a role is a decision about what somebody may not do, and a+ * description that lists only powers is how a house sitter ends up an admin.+ */+const ROLE_COPY = {+ owner: 'Connected this home. Can do everything, including disconnecting it.',+ admin: 'Runs the household: invites, roles, standing allowances. Cannot disconnect the home.',+ member: 'Lives here. Can control everything and approve unlocking a door. Cannot invite anyone.',+ guest: 'Visiting. Can control what you give them, and can never approve unlocking a door.',+ viewer: 'Can watch what you give them and change nothing. For a wall display or a screen at a desk.',+};++const ROLE_LABEL = {+ owner: 'Owner',+ admin: 'Admin',+ member: 'Member',+ guest: 'Guest',+ viewer: 'Viewer',+};++/**+ * The collapsed panel, fetching on first open.+ *+ * Deliberately not loaded with the page: somebody with six houses should not pay+ * six extra round trips to see a roster that in most homes is one line long.+ *+ * @param {object} home a row from GET /api/home+ * @returns {HTMLElement}+ */+export function householdPanel(home) {+ const wrap = el('details', 'hm-panel');+ wrap.style.marginTop = 'var(--space-sm)';+ wrap.style.background = 'transparent';++ const head = el('summary');+ head.style.cursor = 'pointer';+ head.append(el('span', '', 'Who can reach this home'));+ wrap.append(head);++ wrap.append(el('p', 'hm-hint', 'The people in this household, what each of them may do, and any invitation you have sent.'));++ const body = el('div');+ body.style.marginTop = 'var(--space-sm)';+ wrap.append(body);++ let loaded = false;+ const run = async () => {+ clear(body);+ const skeleton = el('div', 'hm-skeleton');+ skeleton.style.height = '3.4rem';+ body.append(skeleton);+ try {+ const data = await listHousehold(home.id);+ clear(body);+ body.append(renderHousehold(home, data, run));+ } catch (err) {+ clear(body);+ body.append(noticeEl({+ tone: 'error',+ title: 'We could not load this household.',+ body: err?.message || 'Try opening it again in a moment.',+ }));+ }+ };++ wrap.addEventListener('toggle', () => {+ if (!wrap.open || loaded) return;+ loaded = true;+ run();+ });+ return wrap;+}++function renderHousehold(home, data, rerender) {+ const frag = document.createDocumentFragment();+ const members = Array.isArray(data?.members) ? data.members : [];+ const invites = Array.isArray(data?.invites) ? data.invites : [];+ const assignable = Array.isArray(data?.assignable_roles) ? data.assignable_roles : [];+ const canAdminister = assignable.length > 0;++ frag.append(yourRoleLine(data?.role, data?.scope));++ const list = el('ul', 'hm-rows');+ for (const member of members) list.append(memberRow(home, member, { assignable, rerender }));+ frag.append(list);++ if (invites.length) {+ frag.append(el('p', 'hm-row-meta', invites.length === 1 ? 'One invitation is waiting to be used.' : `${invites.length} invitations are waiting to be used.`));+ const pending = el('ul', 'hm-rows');+ for (const invite of invites) pending.append(inviteRow(home, invite, { canAdminister, rerender }));+ frag.append(pending);+ }++ if (canAdminister) {+ frag.append(inviteForm(home, { assignable, rerender }));+ } else if (members.length === 1) {+ // The only person in the household, and no way to change that from here.+ // Saying who can is more useful than an empty panel.+ frag.append(emptyBlock(+ 'You are the only person here.',+ 'Whoever connected this home, or an admin they added, can invite somebody and choose exactly what that person may reach.',+ ));+ }++ return frag;+}++/** What this caller may do, said plainly, before the list of everybody else. */+function yourRoleLine(role, scope) {+ const wrap = el('div');+ wrap.style.marginBottom = 'var(--space-sm)';+ const line = el('p', 'hm-row-title');+ line.append(el('span', 'hm-tag', ROLE_LABEL[role] || role || 'Unknown'));+ line.append(document.createTextNode(' is your role in this home.'));+ wrap.append(line);+ wrap.append(el('p', 'hm-row-meta', ROLE_COPY[role] || 'Your access to this home is set by whoever connected it.'));+ if (scope && scope.mode === 'allow') wrap.append(el('p', 'hm-row-meta', scopeSentence(scope)));+ return wrap;+}++/** "The kitchen, and 2 individual devices." Never a raw JSON blob. */+function scopeSentence(scope) {+ const areas = Array.isArray(scope?.areas) ? scope.areas.length : 0;+ const entities = Array.isArray(scope?.entities) ? scope.entities.length : 0;+ if (!areas && !entities) return 'Nothing in this home has been shared yet.';+ const parts = [];+ if (areas) parts.push(areas === 1 ? '1 room' : `${areas} rooms`);+ if (entities) parts.push(entities === 1 ? '1 individual device' : `${entities} individual devices`);+ return `Limited to ${parts.join(' and ')}. Everything else in this home stays hidden.`;+}++function memberRow(home, member, { assignable, rerender }) {+ const li = el('li', 'hm-row');+ const main = el('div', 'hm-row-main');++ const title = el('p', 'hm-row-title');+ // Every one of these is a string somebody typed into a sign-up form.+ title.append(document.createTextNode(member.display_name || member.username || member.email || 'Someone'));+ title.append(document.createTextNode(' '));+ title.append(el('span', 'hm-tag', ROLE_LABEL[member.role] || member.role));+ main.append(title);++ if (member.email && member.display_name) main.append(el('p', 'hm-row-meta', member.email));+ main.append(el('p', 'hm-row-meta', ROLE_COPY[member.role] || ''));+ if (member.scoped) main.append(el('p', 'hm-row-meta', scopeSentence(member.scope)));++ // `can_manage` comes from the server. An owner row is never manageable, and an+ // admin cannot administer a peer admin, so this flag is the only thing the UI+ // consults rather than re-deriving the rank comparison and drifting from it.+ if (!member.can_manage) {+ li.append(main);+ return li;+ }++ const actions = el('div', 'hm-card-actions');++ const picker = el('select', 'hm-input');+ picker.style.width = 'auto';+ picker.setAttribute('aria-label', `Role for ${member.display_name || member.email || 'this person'}`);+ for (const role of assignable) {+ const option = el('option', '', ROLE_LABEL[role] || role);+ option.value = role;+ if (role === member.role) option.selected = true;+ picker.append(option);+ }+ picker.addEventListener('change', async () => {+ const next = picker.value;+ picker.disabled = true;+ try {+ await setHouseholdRole(home.id, { userId: member.user_id, role: next });+ rerender();+ } catch (err) {+ picker.disabled = false;+ picker.value = member.role;+ main.append(el('p', 'hm-row-meta', err?.message || 'That change did not go through.'));+ }+ });++ const remove = el('button', 'hm-btn hm-btn-danger', 'Remove');+ remove.type = 'button';+ remove.addEventListener('click', () => confirmRemove(li, main, home, member, rerender));++ actions.append(picker, remove);+ li.append(main, actions);+ return li;+}++/**+ * Removing somebody is not undoable and it revokes their standing allowances+ * with them, so the panel says exactly that before it happens rather than after.+ */+function confirmRemove(li, main, home, member, rerender) {+ if (li.querySelector('.hm-confirm')) return;+ const box = el('div', 'hm-confirm');+ box.style.marginTop = 'var(--space-sm)';+ box.append(el('p', 'hm-row-title', `Remove ${member.display_name || member.email || 'this person'} from this home?`));+ box.append(el('p', 'hm-row-meta', 'They lose access immediately, and any standing allowance they approved is withdrawn at the same moment. You can invite them again later.'));++ const actions = el('div', 'hm-card-actions');+ const yes = el('button', 'hm-btn hm-btn-danger', 'Remove them');+ yes.type = 'button';+ const no = el('button', 'hm-btn hm-btn-ghost', 'Keep them');+ no.type = 'button';+ no.addEventListener('click', () => box.remove());+ yes.addEventListener('click', async () => {+ yes.disabled = true;+ no.disabled = true;+ yes.textContent = 'Removing';+ try {+ const result = await removeFromHousehold(home.id, member.user_id);+ const revoked = Array.isArray(result?.grants_revoked) ? result.grants_revoked.length : 0;+ rerender();+ if (revoked) {+ main.append(el('p', 'hm-row-meta', revoked === 1+ ? 'Their standing allowance was withdrawn with them.'+ : `${revoked} standing allowances were withdrawn with them.`));+ }+ } catch (err) {+ yes.disabled = false;+ no.disabled = false;+ yes.textContent = 'Try again';+ box.append(el('p', 'hm-row-meta', err?.message || 'That did not go through.'));+ }+ });+ actions.append(yes, no);+ box.append(actions);+ li.append(box);+ yes.focus();+}++function inviteRow(home, invite, { canAdminister, rerender }) {+ const li = el('li', 'hm-row');+ const main = el('div', 'hm-row-main');++ const title = el('p', 'hm-row-title');+ title.append(document.createTextNode(invite.email));+ title.append(document.createTextNode(' '));+ title.append(el('span', 'hm-tag', ROLE_LABEL[invite.role] || invite.role));+ main.append(title);+ main.append(el('p', 'hm-row-meta', `Invited, not yet accepted. The link stops working ${relativeWhen(invite.expires_at)}.`));++ li.append(main);+ if (!canAdminister) return li;++ const withdraw = el('button', 'hm-btn hm-btn-danger', 'Withdraw');+ withdraw.type = 'button';+ withdraw.addEventListener('click', async () => {+ withdraw.disabled = true;+ withdraw.textContent = 'Withdrawing';+ try {+ await revokeHouseholdInvite(home.id, invite.id);+ rerender();+ } catch (err) {+ withdraw.disabled = false;+ withdraw.textContent = 'Try again';+ main.append(el('p', 'hm-row-meta', err?.message || 'That did not go through.'));+ }+ });+ li.append(withdraw);+ return li;+}++function inviteForm(home, { assignable, rerender }) {+ const form = el('form', 'hm-panel');+ form.style.marginTop = 'var(--space-sm)';+ form.style.background = 'transparent';+ form.append(el('h3', 'hm-panel-title', 'Invite somebody'));+ form.append(el('p', 'hm-panel-sub', 'They get a link that works once and expires. Accepting it needs a three.ws account; if they do not have one, the link walks them through making one and brings them straight back.'));++ const emailField = el('label', 'hm-field');+ emailField.append(el('span', 'hm-label', 'Their email address'));+ const email = el('input', 'hm-input');+ email.type = 'email';+ email.required = true;+ email.autocomplete = 'email';+ email.placeholder = '[email protected]';+ emailField.append(email);+ form.append(emailField);++ const roleField = el('label', 'hm-field');+ roleField.append(el('span', 'hm-label', 'What they may do'));+ const role = el('select', 'hm-input');+ // Weakest first: the safe choice should be the one nearest the top, and a+ // guest is the right answer for almost everybody who is not family.+ for (const value of [...assignable].reverse()) {+ const option = el('option', '', ROLE_LABEL[value] || value);+ option.value = value;+ role.append(option);+ }+ roleField.append(role);+ form.append(roleField);++ const explain = el('p', 'hm-row-meta', ROLE_COPY[role.value] || '');+ form.append(explain);+ role.addEventListener('change', () => {+ explain.textContent = ROLE_COPY[role.value] || '';+ });++ const submit = el('button', 'hm-btn hm-btn-primary', 'Send invitation');+ submit.type = 'submit';+ const actions = el('div', 'hm-card-actions');+ actions.append(submit);+ form.append(actions);++ const outcome = el('div');+ form.append(outcome);++ form.addEventListener('submit', async (event) => {+ event.preventDefault();+ clear(outcome);+ submit.disabled = true;+ submit.textContent = 'Sending';+ try {+ const result = await inviteToHousehold(home.id, { email: email.value.trim(), role: role.value });+ email.value = '';+ // The link is shown once, here, because the server keeps only a hash of+ // it. Telling somebody to "check the invitations list for the link"+ // would be a promise this system cannot keep.+ outcome.append(inviteLinkBlock(result?.invite_url));+ rerender();+ } catch (err) {+ outcome.append(noticeEl({+ tone: 'error',+ title: 'That invitation was not sent.',+ body: err?.message || 'Check the address and try again.',+ }));+ } finally {+ submit.disabled = false;+ submit.textContent = 'Send invitation';+ }+ });++ return form;+}++function inviteLinkBlock(url) {+ const wrap = el('div', 'hm-notice hm-notice-ok');+ wrap.setAttribute('role', 'status');+ const inner = el('div');+ inner.append(el('p', 'hm-row-title', 'Send them this link'));+ inner.append(el('p', 'hm-row-meta', 'It works once and then stops. We only keep a fingerprint of it, so this is the only time it can be shown.'));++ const field = el('div', 'hm-card-actions');+ const box = el('input', 'hm-input');+ box.readOnly = true;+ box.value = url || '';+ box.addEventListener('focus', () => box.select());+ const copy = el('button', 'hm-btn hm-btn-ghost', 'Copy');+ copy.type = 'button';+ copy.addEventListener('click', async () => {+ try {+ await navigator.clipboard.writeText(box.value);+ copy.textContent = 'Copied';+ } catch {+ // A browser that refuses clipboard access is not an error state: the+ // link is already on screen and selectable.+ box.focus();+ copy.textContent = 'Select and copy';+ }+ });+ field.append(box, copy);+ inner.append(field);+ wrap.append(inner);+ return wrap;+}++function emptyBlock(title, body) {+ const wrap = el('div', 'hm-empty');+ wrap.style.padding = 'var(--space-md) 0';+ wrap.append(el('p', 'hm-empty-title', title), el('p', 'hm-empty-body', body));+ return wrap;+}++/** "in 6 days", "today". An expiry nobody can read is an expiry nobody plans around. */+function relativeWhen(iso) {+ const at = Date.parse(iso || '');+ if (!Number.isFinite(at)) return 'soon';+ const days = Math.round((at - Date.now()) / 86_400_000);+ if (days <= 0) return 'today';+ if (days === 1) return 'tomorrow';+ return `in ${days} days`;+}diff --git a/src/home/scene-render.js b/src/home/scene-render.jsindex 02772be88..c0507b5ad 100644--- a/src/home/scene-render.js+++ b/src/home/scene-render.js@@ -660,6 +660,14 @@ export function createHomeScene(container, options = {}) {controls.update();}+ /**+ * Move the camera onto a room.+ *+ * Deliberately silent: this is the ANSWER to a focus request, not a new one.+ * Firing `onFocusRoom` from here meant the page's own handler called back+ * into it and the two recursed until the stack ran out, which is exactly what+ * clicking a room in the rail did.+ */function focusRoom(roomId) {const record = rooms.get(roomId);if (!record || !model) return;@@ -668,7 +676,6 @@ export function createHomeScene(container, options = {}) {const distance = Math.max(room.w, room.d) * 1.9;camera.position.set(room.x + distance * 0.55, room.y + distance * 0.72, room.z + distance);controls.update();- options.onFocusRoom?.(roomId);}function makeLabel() {diff --git a/tests/e2e/home-connect.spec.js b/tests/e2e/home-connect.spec.jsindex cf5f53221..076dfbd7d 100644--- a/tests/e2e/home-connect.spec.js+++ b/tests/e2e/home-connect.spec.js@@ -1,62 +1,280 @@/**- * Journeys 1, 9 and 10: getting a house connected, keeping what you drew on it,- * and the refusal that costs nothing.+ * /smart-home, the connect flow, driven in a real browser.*- * Real page, real API, real Home Assistant. See tests/e2e/home-support.js for- * why nothing in this lane is stubbed.+ * This page has no single "content" state. It resolves who is asking, what they+ * have already connected, and what the house said, then renders exactly one of+ * twelve screens. Every defect asserted below is invisible to a unit test,+ * because it only exists once the browser has run the flow:+ *+ * - The private-host refusal has to cost ZERO network calls. It is the whole+ * reason the reachability rules are duplicated into the browser: a+ * 192.168.x.x address is unreachable by definition, and waiting fifteen+ * seconds to say so is a worse version of a sentence we could say on the+ * keystroke. A unit test can assert the predicate; only a browser can prove+ * nothing was sent.+ * - A rejected token must return focus to the token field. Sending a keyboard+ * user back to the top of the form to walk it again is the difference+ * between a designed failure and a dead end, and focus is not observable+ * without a real document.+ * - The access token must not survive anywhere in the browser. Asserting+ * "we never call localStorage.setItem" is a proxy; asserting the token is+ * absent from localStorage, sessionStorage, the URL and every response body+ * after a real submit is the actual promise.+ * - Every string that came from a house is rendered as text. A label+ * containing markup has to appear as characters, not as elements.+ *+ * The session and the API are fulfilled at the Playwright route layer, the way+ * the other flow specs in this directory do it, so the run needs no account and+ * no Home Assistant. Everything between the response and the assertion is the+ * shipped client code in src/home/.*/import { expect, test } from '@playwright/test';-import { connectHome, homeInstance, recordRequests, signUp } from './home-support.js';+const PAGE = '/smart-home';+const LIST = '**/api/home';+const CSRF = '**/api/csrf-token';-test.describe.configure({ mode: 'serial' });+// First hit transforms this page's module graph through the dev server.+const SLOW = 60_000;-test('journey 1: connect a home, see the rooms, disconnect', async ({ page }) => {- const instance = homeInstance();- await signUp(page);- const label = await connectHome(page, { label: 'Journey one' });+const HOME = {+ id: '2b0d4c7e-1f8a-4c3d-9e11-7a6b5c4d3e2f',+ label: 'Home',+ base_url: 'https://home.example.com',+ transport: 'direct',+ relay_id: null,+ status: 'connected',+ status_detail: null,+ capabilities: { websocket: true, entityCount: 120, areaCount: 3, floorCount: 1, macroCount: 2, haVersion: '2026.9.0', mcp: false, mcpToolCount: 0 },+ last_ok_at: new Date().toISOString(),+ last_error_at: null,+ created_at: new Date().toISOString(),+ updated_at: new Date().toISOString(),+ revoked_at: null,+};- // The house is read, not assumed: the page must show a room that exists in- // the real registry, so a hardcoded room list could not pass this.- const rooms = await fetch(`${instance.baseUrl}/api/states`, {- headers: { authorization: `Bearer ${instance.token}` },- }).then((r) => r.json());- expect(rooms.length).toBeGreaterThan(0);+function json(body, status = 200) {+ return { status, contentType: 'application/json', body: JSON.stringify(body) };+}- await expect(page.getByText(label, { exact: false }).first()).toBeVisible();+/** Everything the page reads, with the home list under the caller's control. */+async function stub(page, { homes = [], onConnect } = {}) {+ await page.route(CSRF, (route) => route.fulfill(json({ token: 'csrf-test-token', data: { token: 'csrf-test-token' } })));+ await page.route(LIST, async (route) => {+ if (route.request().method() === 'POST') {+ const body = JSON.parse(route.request().postData() || '{}');+ return route.fulfill(onConnect ? onConnect(body) : json({ home: HOME, capabilities: HOME.capabilities }, 201));+ }+ return route.fulfill(json({ homes }));+ });+}- // Disconnecting destroys the credential. The page has to end up somewhere- // that offers connecting again, not on a dead end.- const disconnect = page.getByRole('button', { name: /disconnect|remove|revoke/i }).first();- await expect(disconnect).toBeVisible({ timeout: 30_000 });- await disconnect.click();+const state = (page) => page.locator('#hm-root');- const confirm = page.getByRole('button', { name: /^(disconnect|remove|revoke|yes)/i }).last();- if (await confirm.isVisible().catch(() => false)) await confirm.click();+test.describe('/smart-home connect flow', () => {+ test('signed out offers a way in rather than a dead form', async ({ page }) => {+ await page.route(LIST, (route) => route.fulfill(json({ error: 'unauthorized' }, 401)));+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'signed_out', { timeout: SLOW });- await expect(page.locator('#hm-url')).toBeVisible({ timeout: 60_000 });-});+ // A disabled form would look broken and explain nothing.+ await expect(page.locator('#hm-url')).toHaveCount(0);+ await expect(page.getByRole('link', { name: /sign in/i })).toBeVisible();+ });++ test('the empty state carries the connect card and where to mint a token', async ({ page }) => {+ await stub(page);+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });++ await expect(page.locator('#hm-url')).toBeVisible();+ // The token instructions are inline: nobody should have to go and search.+ await expect(page.getByText(/long-lived access tokens/i)).toBeVisible();+ });++ test('a private address is refused with no network call at all', async ({ page }) => {+ await stub(page);+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });++ const sent = [];+ page.on('request', (r) => { if (r.url().includes('/api/')) sent.push(`${r.method()} ${r.url()}`); });++ await page.fill('#hm-label', 'Home');+ await page.fill('#hm-url', 'http://192.168.1.10:8123');+ await page.fill('#hm-token', 'a-token-that-must-never-be-sent');+ await page.click('button[type="submit"]');++ await expect(state(page)).toHaveAttribute('data-state', 'private_host');+ expect(sent, 'a LAN address must be refused before the network, not after a timeout').toEqual([]);++ // And it must name the two real ways round it, not just say no.+ await expect(page.getByText(/remote https address/i)).toBeVisible();+ await expect(page.getByText(/add-on/i)).toBeVisible();+ });++ test('a rejected token says so and puts focus back in the token field', async ({ page }) => {+ await stub(page, {+ onConnect: () => json({ error: 'auth', code: 'auth', message: 'Home Assistant rejected that access token.' }, 400),+ });+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });++ await page.fill('#hm-url', 'https://home.example.com');+ await page.fill('#hm-token', 'wrong');+ await page.click('button[type="submit"]');++ await expect(state(page)).toHaveAttribute('data-state', 'auth_failed');+ // The URL was fine, so the user must not be sent back to re-check it.+ await expect(page.locator('#hm-token')).toBeFocused();+ await expect(page.locator('#hm-url')).toHaveValue('https://home.example.com');+ });++ test('an unreachable house distinguishes itself from a wrong address', async ({ page }) => {+ await stub(page, {+ onConnect: () => json({ error: 'unreachable', code: 'unreachable', message: 'Could not reach https://home.example.com.' }, 502),+ });+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });++ await page.fill('#hm-url', 'https://home.example.com');+ await page.fill('#hm-token', 'a-plausible-token');+ await page.click('button[type="submit"]');++ await expect(state(page)).toHaveAttribute('data-state', 'unreachable');+ await expect(page.getByText(/check the house is online/i)).toBeVisible();+ });++ test('the plan ceiling offers the upgrade, not a form that would fail again', async ({ page }) => {+ await stub(page, {+ onConnect: () => json({+ error: 'quota_exceeded',+ code: 'quota_exceeded',+ message: 'Your plan covers 1 home.',+ quota: { dimension: 'homes', limit: 1, used: 1, tier: 'free', upgrade: '/pricing' },+ }, 402),+ });+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });++ await page.fill('#hm-url', 'https://home.example.com');+ await page.fill('#hm-token', 'a-plausible-token');+ await page.click('button[type="submit"]');++ await expect(state(page)).toHaveAttribute('data-state', 'quota_reached');+ // Re-submitting the same house would hit the same wall, so there is no form.+ await expect(page.locator('#hm-url')).toHaveCount(0);+ await expect(page.getByRole('link', { name: /see the plans/i })).toHaveAttribute('href', '/pricing');+ });++ test('a successful connect shows the measured house and drops the token', async ({ page }) => {+ let listed = [];+ await page.route(CSRF, (route) => route.fulfill(json({ token: 'csrf-test-token' })));+ await page.route(LIST, async (route) => {+ if (route.request().method() === 'POST') {+ listed = [HOME];+ return route.fulfill(json({ home: HOME, capabilities: HOME.capabilities }, 201));+ }+ return route.fulfill(json({ homes: listed }));+ });+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });++ await page.fill('#hm-url', 'https://home.example.com');+ await page.fill('#hm-token', 'a-real-looking-token');+ await page.click('button[type="submit"]');++ await expect(state(page)).toHaveAttribute('data-state', 'connected');+ // Measured, not assumed: the numbers came back from the house.+ await expect(page.getByText('120')).toBeVisible();+ await expect(page.getByText('2026.9.0')).toBeVisible();+ // The form is gone, and with it the field that held the credential.+ await expect(page.locator('#hm-token')).toHaveCount(0);+ });++ test('the token reaches no browser storage, no URL and no response body', async ({ page }) => {+ const CANARY = 'CANARY-TOKEN-do-not-store-me';+ const bodies = [];+ await stub(page, {+ onConnect: () => json({ error: 'unreachable', code: 'unreachable', message: 'Could not reach it.' }, 502),+ });+ page.on('response', async (r) => {+ if (!r.url().includes('/api/')) return;+ bodies.push(await r.text().catch(() => ''));+ });++ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });+ await page.fill('#hm-url', 'https://home.example.com');+ await page.fill('#hm-token', CANARY);+ await page.click('button[type="submit"]');+ await expect(state(page)).toHaveAttribute('data-state', 'unreachable');++ const found = await page.evaluate((canary) => {+ const dump = (s) => Array.from({ length: s.length }, (_, i) => s.getItem(s.key(i)) || '').join('\n');+ return {+ local: dump(localStorage).includes(canary),+ session: dump(sessionStorage).includes(canary),+ url: location.href.includes(canary),+ };+ }, CANARY);++ expect(found.local, 'the token must never be written to localStorage').toBe(false);+ expect(found.session, 'the token must never be written to sessionStorage').toBe(false);+ expect(found.url, 'the token must never appear in a URL').toBe(false);+ expect(bodies.some((b) => b.includes(CANARY)), 'the API must never echo the token back').toBe(false);+ });++ test('a label from a house is rendered as text, never as markup', async ({ page }) => {+ const hostile = '<img src=x onerror="window.__xss=1">Kitchen';+ await stub(page, { homes: [{ ...HOME, label: hostile }] });+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'connected', { timeout: SLOW });++ // The characters are on the page; the element is not, and nothing ran.+ await expect(page.locator('.hm-card-label')).toHaveText(hostile);+ await expect(page.locator('.hm-card-label img')).toHaveCount(0);+ expect(await page.evaluate(() => window.__xss)).toBeUndefined();+ });++ test('the token field is a password field with a working reveal toggle', async ({ page }) => {+ await stub(page);+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });-test('journey 10: a private host is refused in the browser, with no network call', async ({ page }) => {- await signUp(page);- await page.goto('/smart-home', { waitUntil: 'domcontentloaded' });- await expect(page.locator('#hm-url')).toBeVisible({ timeout: 60_000 });+ const field = page.locator('#hm-token');+ await expect(field).toHaveAttribute('type', 'password');+ await expect(field).toHaveAttribute('autocomplete', 'off');- // Record only the calls that would mean we tried to reach the house. The- // claim being proved is about what did NOT happen.- const attempts = recordRequests(page, (req) => /\/api\/home(\/|$|\?)/.test(new URL(req.url()).pathname + '?'));- attempts.length = 0;+ await page.getByRole('button', { name: 'Show' }).click();+ await expect(field).toHaveAttribute('type', 'text');+ await page.getByRole('button', { name: 'Hide' }).click();+ await expect(field).toHaveAttribute('type', 'password');+ });- await page.fill('#hm-label', 'The LAN house');- await page.fill('#hm-url', 'http://homeassistant.local:8123');- await page.fill('#hm-token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.not-a-real-token');+ test('the whole connect is completable from the keyboard alone', async ({ page }) => {+ await stub(page, {+ onConnect: () => json({ error: 'unreachable', code: 'unreachable', message: 'Could not reach it.' }, 502),+ });+ await page.goto(PAGE);+ await expect(state(page)).toHaveAttribute('data-state', 'empty', { timeout: SLOW });- const before = attempts.length;- await page.getByRole('button', { name: 'Connect this home' }).click();+ await page.locator('#hm-label').focus();+ await page.keyboard.type('Home');+ await page.keyboard.press('Tab');+ await expect(page.locator('#hm-url')).toBeFocused();+ await page.keyboard.type('https://home.example.com');+ await page.keyboard.press('Tab');+ await expect(page.locator('#hm-token')).toBeFocused();+ await page.keyboard.type('a-token');+ // Tab reaches the reveal toggle, then the submit button.+ await page.keyboard.press('Tab');+ await expect(page.getByRole('button', { name: 'Show' })).toBeFocused();+ await page.keyboard.press('Tab');+ await expect(page.getByRole('button', { name: /connect this home/i })).toBeFocused();+ await page.keyboard.press('Enter');- // The refusal names the host and says why, rather than timing out into a- // vaguer version of the same sentence.- await expect(page.getByText(/only on your home network|cannot be reached/i).first()).toBeVisible({ timeout: 20_000 });- expect(attempts.slice(before), 'a refused private host must cost no request').toEqual([]);+ await expect(state(page)).toHaveAttribute('data-state', 'unreachable');+ });});