The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(orchestration): gate wallet-requiring identity reads on wallet status
M3gA-Mind97cd06170e26
diff --git a/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx b/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsxindex 7d8862d2c0..c89ed13dd2 100644--- a/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx+++ b/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx@@ -38,6 +38,12 @@ vi.mock('../../lib/orchestration/orchestrationClient', async importOriginal => {};});+// The #5805 wallet gate runs before the identity fetch; mock it to a configured+// wallet so these cases exercise the same path they always did.+vi.mock('../../services/walletApi', () => ({+ fetchWalletStatus: vi.fn().mockResolvedValue({ configured: true }),+}));+vi.mock('../../services/socketService', () => {return { socketService: { on: vi.fn(), off: vi.fn(), getSocket: vi.fn(() => null) } };});diff --git a/app/src/components/intelligence/TinyPlaceOrchestrationTab.tsx b/app/src/components/intelligence/TinyPlaceOrchestrationTab.tsxindex 877f05a5d7..6861fb6a4d 100644--- a/app/src/components/intelligence/TinyPlaceOrchestrationTab.tsx+++ b/app/src/components/intelligence/TinyPlaceOrchestrationTab.tsx@@ -1,6 +1,7 @@import debugFactory from 'debug';import { type FormEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';+import { resolveWalletConfigured } from '../../hooks/useWalletConfigured';import { apiClient } from '../../lib/agentworld/apiClient';import { type PairingSnapshot, PaymentRequiredError } from '../../lib/agentworld/invokeApiClient';import { useT } from '../../lib/i18n/I18nContext';@@ -128,17 +129,28 @@ export default function TinyPlaceOrchestrationTab() {// wallet), but relayInfo() only reads the configured base URL and must// stay visible regardless. Settle them separately so one failure never// hides the other. Neither failure may break the chat surface.+ // Gate the wallet-requiring half on wallet status: with no wallet,+ // selfIdentity() can only reject with the core's wallet-not-configured+ // error, so skip it rather than provoke an error-level report (#5805).+ // relayInfo() reads a configured base URL and needs no wallet, so it runs+ // either way — preserving the "one failure never hides the other" property+ // above. Only a positive `no` skips; `unknown` falls through and the core+ // boundary classifier handles anything that follows.+ const skipIdentity = (await resolveWalletConfigured()) === 'no';const [identityResult, relayResult] = await Promise.allSettled([- orchestrationClient.selfIdentity(),+ // `null` marks "not asked", which is distinct from "asked and failed".+ skipIdentity ? Promise.resolve(null) : orchestrationClient.selfIdentity(),orchestrationClient.relayInfo(),]);if (!mountedRef.current) return;if (identityResult.status === 'fulfilled') {- debug(- '[tinyplace-orchestration] identity load ok discoverable=%s',- identityResult.value.discoverable- );- setSelfIdentity(identityResult.value);+ const identity = identityResult.value;+ if (identity === null) {+ debug('[tinyplace-orchestration] identity skipped: no wallet configured');+ } else {+ debug('[tinyplace-orchestration] identity load ok discoverable=%s', identity.discoverable);+ setSelfIdentity(identity);+ }} else {const reason = identityResult.reason;const message = reason instanceof Error ? reason.message : String(reason);diff --git a/app/src/components/orchestration/DiscoverPanel.tsx b/app/src/components/orchestration/DiscoverPanel.tsxindex 5193b27be6..095fe784b7 100644--- a/app/src/components/orchestration/DiscoverPanel.tsx+++ b/app/src/components/orchestration/DiscoverPanel.tsx@@ -8,6 +8,7 @@*/import { type FormEvent, useCallback, useEffect, useMemo, useState } from 'react';+import { resolveWalletConfigured } from '../../hooks/useWalletConfigured';import { apiClient } from '../../lib/agentworld/apiClient';import { useT } from '../../lib/i18n/I18nContext';import {@@ -32,15 +33,29 @@ export default function DiscoverPanel() {useEffect(() => {let cancelled = false;- void Promise.allSettled([- orchestrationClient.selfIdentity(),- orchestrationClient.relayInfo(),- ]).then(([id, rel]) => {- if (cancelled) return;- if (id.status === 'fulfilled') setIdentity(id.value);- if (rel.status === 'fulfilled') setRelay(rel.value);- setIdentityLoading(false);- });+ // Gate the wallet-requiring read: selfIdentity() derives a tiny.place+ // signer from the wallet, so with none configured it can only reject with+ // the core's wallet-not-configured error — an expected state that still+ // travels as an Err and lands as an error-level report (#5805). Ask+ // wallet_status, which answers the same question without erroring, and skip+ // only on a positive `no`. relayInfo() needs no wallet and always runs.+ void resolveWalletConfigured()+ .then(configured =>+ Promise.allSettled([+ configured === 'no'+ ? Promise.resolve(null)+ : orchestrationClient.selfIdentity(),+ orchestrationClient.relayInfo(),+ ])+ )+ .then(([id, rel]) => {+ if (cancelled) return;+ // `null` is the skipped case — leave `identity` null, exactly as a+ // failed fetch would, so the render path is unchanged.+ if (id.status === 'fulfilled' && id.value !== null) setIdentity(id.value);+ if (rel.status === 'fulfilled') setRelay(rel.value);+ setIdentityLoading(false);+ });return () => {cancelled = true;};diff --git a/app/src/components/orchestration/__tests__/DiscoverPanel.test.tsx b/app/src/components/orchestration/__tests__/DiscoverPanel.test.tsxindex 911c1baf81..23143f8789 100644--- a/app/src/components/orchestration/__tests__/DiscoverPanel.test.tsx+++ b/app/src/components/orchestration/__tests__/DiscoverPanel.test.tsx@@ -19,6 +19,12 @@ vi.mock('../../../lib/orchestration/usePairing', () => ({ usePairing: () => pairconst selfIdentity = vi.hoisted(() => vi.fn());const relayInfo = vi.hoisted(() => vi.fn().mockResolvedValue({ baseUrl: 'x', network: 'prod' }));+// The #5805 wallet gate runs before the identity fetch; mock it to a configured+// wallet so these cases exercise the same path they always did.+vi.mock('../../../services/walletApi', () => ({+ fetchWalletStatus: vi.fn().mockResolvedValue({ configured: true }),+}));+vi.mock('../../../lib/orchestration/orchestrationClient', () => ({orchestrationClient: { selfIdentity, relayInfo },}));diff --git a/app/src/hooks/useTinyPlaceIdentity.test.ts b/app/src/hooks/useTinyPlaceIdentity.test.tsindex 2ed4ec5490..b77aedb449 100644--- a/app/src/hooks/useTinyPlaceIdentity.test.ts+++ b/app/src/hooks/useTinyPlaceIdentity.test.ts@@ -8,9 +8,19 @@ vi.mock('../lib/orchestration/orchestrationClient', () => ({orchestrationClient: { selfIdentity: () => selfIdentity() },}));+// The wallet gate (#5805) runs before every identity fetch. Mock it here so the+// pre-existing cases below are deterministic rather than depending on a real+// `wallet_status` RPC failing into the `unknown` fall-through; `beforeEach`+// defaults it to a configured wallet, which is the path they were written for.+const fetchWalletStatus = vi.fn();+vi.mock('../services/walletApi', () => ({+ fetchWalletStatus: () => fetchWalletStatus(),+}));+describe('useTinyPlaceIdentity (#5424)', () => {beforeEach(() => {vi.clearAllMocks();+ fetchWalletStatus.mockResolvedValue({ configured: true });__resetTinyPlaceIdentityForTests();});@@ -19,6 +29,34 @@ describe('useTinyPlaceIdentity (#5424)', () => {vi.useRealTimers();});+ // #5805 — `selfIdentity()` derives a tiny.place signer from the wallet, so a+ // wallet-less user could only ever get a rejection, which the retry ladder+ // then repeated: 55 error-level reports in 72 minutes on one session.+ // `wallet_status` answers the same question without erroring, so the call is+ // never made.+ it('never calls selfIdentity when no wallet is configured', async () => {+ fetchWalletStatus.mockResolvedValue({ configured: false });+ const { result } = renderHook(() => useTinyPlaceIdentity());++ await waitFor(() => expect(result.current.status).toBe('ready'));+ expect(result.current.hasIdentity).toBe(false);+ expect(selfIdentity).not.toHaveBeenCalled();+ });++ // The gate fires only on a POSITIVE "no wallet". If `wallet_status` itself+ // fails we cannot prove the wallet is absent, so the call must still go out —+ // otherwise a transport blip would hide a real identity. The core boundary+ // classifier stays as defense-in-depth for whatever comes back.+ it('still calls selfIdentity when wallet status is inconclusive', async () => {+ fetchWalletStatus.mockRejectedValue(new Error('rpc transport failed'));+ selfIdentity.mockResolvedValue({ agentId: 'agent-123', handles: [], discoverable: true });+ const { result } = renderHook(() => useTinyPlaceIdentity());++ await waitFor(() => expect(result.current.status).toBe('ready'));+ expect(selfIdentity).toHaveBeenCalledTimes(1);+ expect(result.current.hasIdentity).toBe(true);+ });+it('reports an identity when the RPC returns a non-empty agentId', async () => {selfIdentity.mockResolvedValue({ agentId: 'agent-123', handles: [], discoverable: true });const { result } = renderHook(() => useTinyPlaceIdentity());diff --git a/app/src/hooks/useTinyPlaceIdentity.ts b/app/src/hooks/useTinyPlaceIdentity.tsindex 4582812cfc..f2c7ec02c9 100644--- a/app/src/hooks/useTinyPlaceIdentity.ts+++ b/app/src/hooks/useTinyPlaceIdentity.ts@@ -26,6 +26,8 @@ import { useEffect, useState } from 'react';import { orchestrationClient } from '../lib/orchestration/orchestrationClient';+import { resolveWalletConfigured } from './useWalletConfigured';+export interface TinyPlaceIdentityState {/** `loading` until the RPC first settles; `ready` once we have an answer. */status: 'loading' | 'ready';@@ -51,6 +53,23 @@ async function attemptLoad(attempt: number) {if (resolved || inFlight) return;inFlight = true;try {+ // Gate on wallet status before the wallet-requiring call. `selfIdentity()`+ // builds the tiny.place client from a wallet-derived seed, so for a user+ // with no wallet it can only reject — and the retry ladder below then+ // repeats that rejection, which is how one wallet-less session produced 55+ // error-level reports in 72 minutes (#5805). `wallet_status` answers the+ // same question and resolves normally, so ask it instead of provoking the+ // error. Only a positive `no` skips: `unknown` (status fetch itself failed)+ // falls through so a transport blip never hides a real identity.+ //+ // Deliberately does NOT set `resolved` — that flag ends retrying forever,+ // and a user who sets up a wallet later in the session must still be picked+ // up by the next `ensureLoad()`. Returning without scheduling a retry is+ // enough to stop the ladder.+ if ((await resolveWalletConfigured()) === 'no') {+ publish({ status: 'ready', hasIdentity: false });+ return;+ }const identity = await orchestrationClient.selfIdentity();resolved = true;if (retryTimer) {diff --git a/app/src/hooks/useWalletConfigured.ts b/app/src/hooks/useWalletConfigured.tsnew file mode 100644index 0000000000..072805c740--- /dev/null+++ b/app/src/hooks/useWalletConfigured.ts@@ -0,0 +1,88 @@+/**+ * Shared wallet-configured gate for wallet-requiring RPCs.+ *+ * ## Why this exists+ *+ * Several core RPCs derive a key from the local wallet before they can run+ * (the tiny.place signer seed, EVM signing, balances, deBridge quotes). When no+ * wallet is set up they reject with the core's `WALLET_NOT_CONFIGURED_MESSAGE`.+ * That is an *expected* state — a wallet is optional and most users never+ * create one — but it still travels as an `Err`, so every such call becomes an+ * error the boundary has to classify.+ *+ * The core-side classifier (`ExpectedErrorKind::WalletNotConfigured`) keeps+ * those out of Sentry, and it is deliberately kept as defense-in-depth. This+ * hook is the other half: **do not make the call at all when we have a positive+ * signal that no wallet exists.** `openhuman.wallet_status` answers the same+ * question and resolves normally for a wallet-less user, so the gate costs one+ * non-erroring RPC and removes an erroring one.+ *+ * This pairs prevention-at-source with boundary classification, which is the+ * shape the same bug was fixed in for the tiny.place home feed in #3964+ * (commits `1d42c766e` + `02f9769bc`). That gate lived privately inside+ * `agentworld/pages/FeedSection.tsx` and was deleted wholesale with the+ * `agentworld` module in `779aa2f3a`, leaving only the classifier half — which+ * is part of why the same class recurred as #5805. It is shared here so the+ * next wallet-gated caller inherits it instead of re-deriving it.+ *+ * ## The `unknown` state is load-bearing+ *+ * Gate only on a **positive** "no wallet". If `wallet_status` itself fails we+ * cannot prove the wallet is absent, so we return `unknown` and the caller+ * proceeds — a transport blip must not render a configured wallet as missing.+ * Any wallet error that follows is then handled by the boundary classifier.+ *+ * ## Deliberately not cached+ *+ * Resolution runs per mount. A user who sets up a wallet mid-session must be+ * picked up on the next mount, and a cached `no` would strand them until+ * restart. `wallet_status` is a cheap local RPC that does not error, so there+ * is nothing to save by caching it.+ */+import { useEffect, useState } from 'react';++import { fetchWalletStatus } from '../services/walletApi';++/**+ * - `resolving` — `wallet_status` still in flight. Callers must NOT fire+ * wallet-requiring RPCs yet.+ * - `no` — resolved, and no wallet is configured. The only state that carries a+ * positive lever to skip a wallet-gated call.+ * - `yes` — a wallet is configured; proceed.+ * - `unknown` — the `wallet_status` fetch itself failed. Proceed, and let the+ * boundary classifier handle any wallet error that follows.+ */+export type WalletConfigured = 'resolving' | 'no' | 'yes' | 'unknown';++/**+ * Resolve the wallet-configured state once, outside React.+ *+ * Exposed for callers that are not components — `useTinyPlaceIdentity` drives a+ * module-level singleton and cannot use a hook. Never rejects: a failed status+ * fetch becomes `unknown`, so a caller can always `await` it inline before+ * deciding whether to make its wallet-gated call.+ */+export async function resolveWalletConfigured(): Promise<Exclude<WalletConfigured, 'resolving'>> {+ try {+ const status = await fetchWalletStatus();+ return status.configured ? 'yes' : 'no';+ } catch {+ // Cannot prove absence — see "The `unknown` state is load-bearing" above.+ return 'unknown';+ }+}++/** React binding over {@link resolveWalletConfigured}; `resolving` until settled. */+export function useWalletConfigured(): WalletConfigured {+ const [configured, setConfigured] = useState<WalletConfigured>('resolving');+ useEffect(() => {+ let cancelled = false;+ void resolveWalletConfigured().then(next => {+ if (!cancelled) setConfigured(next);+ });+ return () => {+ cancelled = true;+ };+ }, []);+ return configured;+}