Files
buzz/desktop/src/shared/api/tauriAgentOwnership.ts
Taylor Ho d7402d5946 feat(agents): gate activity by relay ownership
- Add a relay ownership endpoint backed by agent_owner_pubkey and is_agent_owner so desktop activity visibility uses the same source of truth as observer telemetry authorization.
- Add a Tauri ownership command, frontend API wrapper, and useCanViewAgentActivity hook with local managed-agent optimism only while relay ownership is loading.
- Replace profile popover, profile panel, and members sidebar activity gates so owned agents can open activity across different builds and worktrees without relying on local managed-agent lists.
- Refactor channel agent session candidate resolution so owned agents can keep an activity panel open when channel metadata is stale, while preserving local-only lifecycle controls.
- Add focused desktop unit coverage for the ownership predicate and stale-metadata session resolution path, plus E2E bridge support for ownership mocks.
2026-06-15 15:35:51 -07:00

35 lines
955 B
TypeScript

import { invokeTauri } from "@/shared/api/tauri";
export type AgentOwnershipStatus = {
/** Lowercase hex pubkey of the queried agent. */
agentPubkey: string;
/** Lowercase hex owner pubkey from relay `agent_owner_pubkey`, if set. */
ownerPubkey: string | null;
/** True iff the current workspace identity is the relay-recorded 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.
*/
export async function resolveAgentOwnership(
agentPubkey: string,
): Promise<AgentOwnershipStatus> {
const raw = await invokeTauri<RawAgentOwnershipStatus>(
"resolve_agent_ownership",
{ agentPubkey },
);
return {
agentPubkey: raw.agent_pubkey,
ownerPubkey: raw.owner_pubkey,
isOwner: raw.is_owner,
};
}