@petersr/claude-pty-web-harness-protocol
v0.5.0
Published
Shared wire types for the claude-pty-web-harness (zero runtime).
Maintainers
Readme
@petersr/claude-pty-web-harness-protocol
The shared wire contract for the
claude-pty-web-harness:
TypeScript types only, zero runtime. Every consumer (the core/server backend,
the React hook, or a completely different UI) imports these so they agree on one
ChatEvent / SessionSummary / ServerMessage / ClientMessage shape.
Install
npm i @petersr/claude-pty-web-harness-protocolRequires Node >= 20. Types-only, so it adds nothing to your runtime bundle.
Usage
import type {
ChatEvent,
ContentPart,
SessionStatus,
SessionSummary,
ServerMessage,
ClientMessage,
} from "@petersr/claude-pty-web-harness-protocol";ChatEventis a discriminated union onkind:user,assistant_text,thinking,tool_use,tool_result,system,result. Theuser,assistant_text, andtool_resultvariants carry an optionalparts: aContentPart[], the lossless ordered breakdown of that message/tool result's content blocks (text, image, or anunknownblock this library doesn't recognize). It's additive -textstays exactly as it always was, a flattened text-only summary - and only present when there's something beyond plain text to say.ContentPartis a discriminated union ontype:text({text}),image({blobId, mediaType, bytes}- fetch the bytes from the server's blob route), andunknown({blockType}, so an unrecognized content-block type surfaces visibly instead of silently vanishing).SessionStatusis"starting" | "ready" | "exited" | "failed"; a"failed"session carries aStartupFailurereason inSessionSummary.error.ServerMessage/ClientMessageare the WebSocket frames in each direction.
See the project README, the wire protocol, and USAGE.md for the full picture.
License
MIT
