From 4bfc7613ec2a4f0d501df18cf4ac7cdbd32b44c1 Mon Sep 17 00:00:00 2001 From: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co> Date: Mon, 22 Jun 2026 16:45:19 -0700 Subject: [PATCH] refactor(desktop): make resolveAgentOwnership a thin wrapper over resolveOaOwner Drop the custom relay ownership endpoint call (resolve_agent_ownership) in favor of the live kind:0 NIP-OA proof path (resolveOaOwner), the same authority the relay now gates observer-frame delivery on. Adapter shape (agentPubkey, ownerPubkey, isOwner) is preserved so both consumers -- useCanViewAgentActivity and useChannelAgentSessions -- keep reading .isOwner unchanged. An agent with no kind:0, no auth tag, or a failing tag resolves to { ownerPubkey: null, isOwner: false }. Co-authored-by: Taylor Ho Signed-off-by: Taylor Ho --- desktop/src/shared/api/tauriAgentOwnership.ts | 51 +++++++------------ 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/desktop/src/shared/api/tauriAgentOwnership.ts b/desktop/src/shared/api/tauriAgentOwnership.ts index f66265ec65..851d401a12 100644 --- a/desktop/src/shared/api/tauriAgentOwnership.ts +++ b/desktop/src/shared/api/tauriAgentOwnership.ts @@ -1,48 +1,33 @@ -import { invokeTauri } from "@/shared/api/tauri"; import { resolveOaOwner } from "@/shared/api/tauriIdentityArchive"; export type AgentOwnershipStatus = { /** Lowercase hex pubkey of the queried agent. */ agentPubkey: string; - /** Lowercase hex owner pubkey from relay `agent_owner_pubkey`, if set. */ + /** Lowercase hex owner pubkey from the agent's live `kind:0` NIP-OA `auth` tag, if any. */ ownerPubkey: string | null; - /** True iff the current workspace identity is the relay-recorded owner. */ + /** True iff the current workspace identity is the verified kind:0 owner. */ isOwner: boolean; }; -type RawAgentOwnershipStatus = { - agent_pubkey: string; - owner_pubkey: string | null; - is_owner: boolean; -}; - /** - * Resolve whether the current identity owns `agentPubkey` per relay DB. - * Authoritative gate for observer activity visibility. + * Resolve whether the current identity owns `agentPubkey`. + * + * Authority is the agent's live `kind:0` NIP-OA `auth` tag, verified locally + * via {@link resolveOaOwner} — the same proof the relay now gates observer-frame + * delivery on. This is a thin wrapper that adapts {@link OwnerOfAgent} to the + * stable {@link AgentOwnershipStatus} shape consumed by `useCanViewAgentActivity` + * and `useChannelAgentSessions`. + * + * An agent with no kind:0, no `auth` tag, or a tag that fails verification + * resolves to `{ ownerPubkey: null, isOwner: false }`. */ export async function resolveAgentOwnership( agentPubkey: string, ): Promise { - try { - const raw = await invokeTauri( - "resolve_agent_ownership", - { agentPubkey }, - ); - return { - agentPubkey: raw.agent_pubkey, - ownerPubkey: raw.owner_pubkey, - isOwner: raw.is_owner, - }; - } catch (error) { - const owner = await resolveOaOwner(agentPubkey).catch(() => null); - if (!owner) { - throw error; - } - - return { - agentPubkey: agentPubkey.toLowerCase(), - ownerPubkey: owner.owner, - isOwner: owner.isMe, - }; - } + const owner = await resolveOaOwner(agentPubkey); + return { + agentPubkey: agentPubkey.toLowerCase(), + ownerPubkey: owner?.owner ?? null, + isOwner: owner?.isMe ?? false, + }; }