Provides the domain model for Scramjet Transform Hub: message serialization/deserialization, stream message handling, error types, and utility classes (ID provider, delayed stream). Forms the communication protocol layer between host, runner, and adapter processes.
- Message serialization:
MessageUtilities.serializeMessage/deserializeMessagehandles the typed message envelope protocol for runner/host communication.serializeMessageusesstructuredClonefor safe body cloning.deserializeMessagevalidates array format andRunnerMessageCodemembership. - Stream handler:
StreamHandlermanages bidirectional communication channels — monitoring message handlers, control message handlers, upstream/downstream stream configuration for the runner process protocol. - Message extraction:
getMessage()/checkMessage()provide typed message reconstruction from raw data with runtime type guards (isStopSequenceMessage, isKeepAliveMessage, isMonitoringRateMessage, etc.). - Error hierarchy: Domain error classes (
AppError,HostError,RunnerError,CSIError,InstanceAdapterError,SequenceAdapterError) provide typed error propagation across components. - ID generation:
IDProviderutility for generating unique identifiers. - Delayed stream:
DelayedStreambuffers stream data until a destination is attached.
| File/Directory | Role |
|---|---|
stream-handler.ts |
StreamHandler — bidirectional message and stream channel handling for runner protocol. |
messages-utils.ts |
Message serialization/deserialization utilities with structuredClone. |
get-message.ts |
Message extraction helpers with runtime type guards. |
errors/ |
Domain error classes: AppError, CSIError, HostError, InstanceAdapterError, RunnerError, SequenceAdapterError. |
utils/id-provider.ts |
IDProvider — unique ID generation. |
utils/delayed-stream.ts |
DelayedStream — buffered stream container. |
- Depends on
@scramjet/obj-logger,@scramjet/symbols,@scramjet/types. MessageUtilitiesobject re-exported for convenient import.- Consumed by host, runner, and adapter packages for communication protocol implementation.
StreamHandleris the primary integration point for runtime wrapper packages (runner-node,runner-bun,runner-python).