Skip to content

feat(cli-tools): Binary publish#3282

Merged
teogeb merged 14 commits into
mainfrom
cli-tools-binary-format
Dec 11, 2025
Merged

feat(cli-tools): Binary publish#3282
teogeb merged 14 commits into
mainfrom
cli-tools-binary-format

Conversation

@teogeb

@teogeb teogeb commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Added a --binary flag to the stream subscribe and stream publish commands. When this flag is enabled, the commands read and write binary bytes instead of normal JSON or hex strings. If the --with-metadata flag is also used, the bytes represent the protobuf-encoded StreamMessage objects.

All messages use a length-prefixed frame format: each item is prefixed with a 4-byte header indicating the frame length.

A new --raw flag was added to stream publish, allowing protobuf binary messages to be sent exactly as provided. Currently this flag is supported only when both --binary and --with-metadata are used, since raw publishing requires StreamMessage objects as input.

Helpers

These existing helpers may be useful when working with the new features introduced in this PR:

  • convertStreamMessageToBytes() and convertBytesToStreamMessage() from @streamr/sdk can be used to convert between StreamMessage objects and their protobuf byte form
  • toLengthPrefixedFrame() and LengthPrefixedFrameDecoder from @streamr/utils can be used to create and parse length-prefixed frames

Related changes

Added MessageSigner export to the SDK. This class is required in stream-publish.test.ts.

Refactored the CLI tool’s startCommand test utilities so that they can capture either text or binary output.

Future improvements

We could support --raw publishing without the --binary flag by constructing StreamMessage instances directly in the CLI tool. See stream-publish.test.ts for an example of how to create messages.

@github-actions github-actions Bot added cli-tools Related to CLI Tools Package sdk labels Dec 9, 2025
@github-actions github-actions Bot added the docs label Dec 9, 2025
@teogeb teogeb requested a review from juslesan December 9, 2025 20:38
@teogeb teogeb changed the title feat(sdk): Binary publish feat(cli-tools): Binary publish Dec 9, 2025
Base automatically changed from sdk-raw-publish to main December 10, 2025 23:34
@teogeb teogeb merged commit bde94c9 into main Dec 11, 2025
42 of 43 checks passed
@teogeb teogeb deleted the cli-tools-binary-format branch December 11, 2025 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli-tools Related to CLI Tools Package docs sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants