Route ACP observer traffic over relay (#421)

Signed-off-by: Tyler Longwell <tlongwell@squareup.com>
Co-authored-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com>
Co-authored-by: Tyler Longwell <tlongwell@squareup.com>
This commit is contained in:
Bradley Axen
2026-04-30 06:34:37 -07:00
committed by GitHub
parent 0e9c02da2d
commit fcec10547d
38 changed files with 2270 additions and 687 deletions

View File

@@ -0,0 +1,32 @@
import { buildObserverControlEvent } from "@/shared/api/tauriObserver";
import type { RelayEvent } from "@/shared/api/types";
import { KIND_AGENT_OBSERVER_FRAME } from "@/shared/constants/kinds";
import { relayClient } from "./relayClient";
export function subscribeToAgentObserverFrames(
ownerPubkey: string,
onEvent: (event: RelayEvent) => void,
) {
return relayClient.subscribeLive(
{
kinds: [KIND_AGENT_OBSERVER_FRAME],
"#p": [ownerPubkey],
limit: 0,
since: Math.floor(Date.now() / 1_000),
},
onEvent,
);
}
export async function sendAgentObserverControl(
agentPubkey: string,
payload: unknown,
) {
await relayClient.preconnect();
const event = await buildObserverControlEvent({ agentPubkey, payload });
await relayClient.publishEvent(
event,
"Timed out while sending the agent control command.",
"Failed to send the agent control command.",
);
}