mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
feat(serverless): run channels, DMs, messages, and agents against a generic Nostr relay
Adds a 'serverless' workspace mode that points the desktop app at any generic public Nostr relay (e.g. wss://relay.damus.io) with zero Sprout server infrastructure — no Postgres, no HTTP /query|/events bridge, no NIP-98 auth. Reuses Sprout's native event kinds (39000 channel metadata, 39002 membership, kind 9 messages, h-tag scoping); 'serverless' is purely a transport + auth concern, so the server-mode path is untouched. Transport: reads/writes go over plain WebSocket (REQ/EOSE, EVENT/OK) instead of the HTTP bridge; NIP-42 AUTH is answered only if the relay challenges. Desktop backend: - AppState.serverless flag + is_serverless(); apply_workspace gains a flag - ws_relay.rs: query_relay_ws / submit_event_ws / publish_signed_event_ws - relay.rs: query_relay/submit_event + agent profile sync branch to WS - events.rs: build_channel_metadata_serverless (39000) + members (39002) - create_channel/open_dm publish those events directly (DM ids = UUIDv5 over sorted participants so both sides converge without a server) - managed agents inherit SPROUT_SERVERLESS into the ACP subprocess env Agents (full support, not a follow-up): - sprout-acp: RestClient + HarnessRelay gain serverless mode; query/submit use plain WS, NIP-42 handshake skipped on (re)connect; SPROUT_SERVERLESS env/arg - sprout-cli: SproutClient serverless WS query/submit; --serverless flag, to_ws_url helper, NetworkMsg error variant - npub respond-to permissions are in-process and work unchanged Frontend: - Workspace.mode + workspaceMode()/isServerlessWorkspace() helpers - relayClient.setServerless() skips the AUTH-wait on connect; late challenges still answered so writes succeed on relays that require auth - ServerlessContext/useIsServerless() hides search, pulse, projects, workflows - Serverless toggle in the Add Workspace dialog and Welcome screen Docs: docs/SPROUT_LITE_MODE.md updated with the implementation + testing steps.
This commit is contained in:
@@ -11,7 +11,7 @@ import { clearSearchHitEventCache } from "@/app/navigation/searchHitEventCache";
|
||||
import { clearAllDrafts } from "@/features/messages/lib/useDrafts";
|
||||
import { resetAgentObserverStore } from "@/features/agents/observerRelayStore";
|
||||
|
||||
import { initFirstWorkspace } from "./workspaceStorage";
|
||||
import { initFirstWorkspace, isServerlessWorkspace } from "./workspaceStorage";
|
||||
import type { Workspace } from "./types";
|
||||
|
||||
/**
|
||||
@@ -124,11 +124,19 @@ export function useWorkspaceInit(
|
||||
// and re-applied it on every reload, which silently overwrote any
|
||||
// imported key. `loadWorkspaces()` strips lingering `nsec` fields from
|
||||
// legacy entries; this site refuses to apply one even if present.
|
||||
const serverless = isServerlessWorkspace(activeWorkspace);
|
||||
|
||||
// Tell the relay client singleton which transport to use *before*
|
||||
// AppShell mounts and calls preconnect(). In serverless mode the connect
|
||||
// handshake skips the NIP-42 AUTH wait.
|
||||
relayClient.setServerless(serverless);
|
||||
|
||||
try {
|
||||
await applyWorkspace(
|
||||
activeWorkspace.relayUrl,
|
||||
undefined,
|
||||
activeWorkspace.token,
|
||||
serverless,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to apply workspace to backend:", error);
|
||||
|
||||
Reference in New Issue
Block a user