mirror of
https://github.com/stablyai/orca.git
synced 2026-09-30 08:03:12 +00:00
src/relay/relay-frame-decoder.ts and src/main/ssh/relay-frame-decoder.ts were 264 identical lines apart from one default: the relay logs decode faults to stderr when no handler is supplied, the SSH side stays silent. Two copies of framing logic is exactly where a wire-format fix lands in one and not the other. The decoder's contract and buffer already live in src/shared, so the class joins them there. The relay keeps a thin subclass that supplies its stderr default, preserving behaviour for the call sites that omit onError. The SSH copy is deleted and relay-protocol.ts points at shared directly. Verified: pnpm typecheck, 102 tests across the 9 framing/backpressure/ handshake suites, and `pnpm build:relay` for all six platform targets plus the WSL hook relay — the standalone bundle has no new dependencies.
33 lines
1012 B
TypeScript
33 lines
1012 B
TypeScript
import { FrameDecoder as SharedFrameDecoder } from '../shared/relay-frame-decoder'
|
|
import type { DecodedFrame, FrameDecoderOptions } from '../shared/relay-frame-decoder-contract'
|
|
|
|
export {
|
|
HEADER_LENGTH,
|
|
MAX_MESSAGE_SIZE,
|
|
FRAME_DECODER_MAX_FRAMES_PER_TURN,
|
|
FRAME_DECODER_MAX_BYTES_PER_TURN,
|
|
FRAME_DECODER_MAX_TURN_MS,
|
|
FRAME_DECODER_MAX_RETAINED_BYTES
|
|
} from '../shared/relay-frame-decoder'
|
|
export {
|
|
FrameDecoderContinuationError,
|
|
type DecodedFrame,
|
|
type FrameDecoderOptions
|
|
} from '../shared/relay-frame-decoder-contract'
|
|
|
|
// Why: the relay runs standalone on remote hosts with no renderer to surface
|
|
// decode faults, so an omitted handler must still reach stderr.
|
|
export class FrameDecoder extends SharedFrameDecoder {
|
|
constructor(
|
|
onFrame: (frame: DecodedFrame) => void,
|
|
onError?: (err: Error) => void,
|
|
options: FrameDecoderOptions = {}
|
|
) {
|
|
super(
|
|
onFrame,
|
|
onError ?? ((error) => process.stderr.write(`[relay] ${error.message}\n`)),
|
|
options
|
|
)
|
|
}
|
|
}
|