mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
## Summary Agents using the CLI had no way to answer questions like "which channels is key X a member of" (kind 39002 with `#p`) without scanning channels one at a time, which runs into identity-adapter rate limits. This adds a small escape hatch that reuses the CLI's existing credentials (signing key, auth tag, federated identity assertion): - `buzz raw query <filter>`: send one filter object or an array of filters (or `-` for stdin) to the relay's `/query` endpoint and print the relay's JSON as-is (an event array, or an object for filters such as read-state snapshots). - `buzz raw publish`: build, sign and send an arbitrary event, either from `--kind`, repeatable `--tag` (JSON arrays, as in `social set-list`) and `--content`, or from a full `--event-json` template. Signing goes through `sign_event`, so the auth tag is attached as for every other command; a caller-supplied `auth` tag is refused. Ephemeral kinds (20000 to 29999) use the ephemeral publish path, except the NIP-43 leave request (28936), which goes over HTTP because the relay revokes the submitting socket on success. Gift wraps (1059) are refused, since they need NIP-59 signing with a throwaway key. Malformed input (bad JSON, a filter that isn't an object, a bad tag) exits 1 with the usual `user_error` JSON; the relay validates filter fields itself, and its rejection exits 2 as a relay error. A publish the relay refuses (`accepted:false`, over HTTP or the WebSocket) exits 2 with the event id and message. README and TESTING.md list the new commands and their limits (replaceable and addressable kinds replace the whole event; kind-scoped credentials can fail artifact revisions). ## Regressions None expected: this adds a new command group and does not change existing commands. `submit_event` now also gives the relay-admin kinds (9030 to 9033), identity archive and unarchive requests (9035, 9036) and the leave request (28936) the moderation retry policy (no blind resend after an ambiguous outcome). `agents archive` and `agents unarchive` send 9035 and 9036, so after a lost response they now report an unknown outcome instead of resending, which could re-archive over a later unarchive. ### Validation Tried against a live relay as a signed-in user: a kind 39002 `#p` query listed one key's channels, a two-filter array and an `ids` lookup returned the expected events, and `raw publish` sent a typing indicator, a reaction and a deletion of that reaction, all accepted. New tests in [`raw.rs`](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L202)) run against a local fake relay: [query](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L393)) sends the filters with the CLI's credentials and prints the relay's response; [publish](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L445)) signs the given kind, tags and content with exactly one auth tag, [keeps a `p` tag naming the signer](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L481)), [sends the NIP-43 leave request over HTTP](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L576)) and [prints the acknowledgement](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L589)); a relay refusal [is a relay error](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L604)) and [exits 2 from the CLI entry point](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L627)); and [bad input](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L549)) is a usage error that sends nothing. In [`client.rs`](489e0014a4/crates/buzz-cli/src/client.rs (L2123)), every no-dedup command kind, identity archive requests included, is submitted once and reports an unknown outcome on a [502](489e0014a4/crates/buzz-cli/src/client.rs (L2123)) or a [lost response body](489e0014a4/crates/buzz-cli/src/client.rs (L2147)). --------- Signed-off-by: Tom Brow <tomb@block.xyz>