@highflame/codeoid-core
v0.4.1
Published
Framework-agnostic Codeoid client core — WebSocket transport (auth handshake, reconnect, heartbeat), message store semantics, resume cursors, and display helpers. Shared by the web UI and the mobile client.
Downloads
65
Keywords
Readme
@highflame/codeoid-core
Framework-agnostic client core for the Codeoid daemon — everything a frontend needs except the pixels:
CodeoidClient— the WebSocket transport: auth handshake (token + protocol version + capability declaration), request/response correlation, liveness heartbeat, exponential-backoff reconnect with full jitter. Needs only a WHATWGWebSocketglobal (browsers, React Native, Bun, Node ≥ 22). All timing is injectable. Native hosts callreconnectNow()from their own resume signal (e.g. React NativeAppState).MessageStore+ kernels (mergeDeltaInto,dedupeReplay) — the single source of truth for transcript accumulation: upsert-by-messageId, streaming delta merges, snapshot vs chunked vs incremental replay routing (ingest()), per-message versions and per-session epochs.ResumeCursors—replay.resumecursor tracking so reconnects fetch only the tail mutated since, not the whole scrollback.- Display helpers shared across frontends: usage formatters (
formatTokens,formatCostUsd, …), identity/provenance labels (shortSub,identityLabel, …), approval scanning, slash-command parsing.
import { CodeoidClient, MessageStore, ResumeCursors } from "@highflame/codeoid-core";
import { CAPABILITIES } from "@highflame/codeoid-protocol";
const store = new MessageStore();
const cursors = new ResumeCursors();
const client = new CodeoidClient({
url: "ws://localhost:7400",
token,
capabilities: [CAPABILITIES.PARTS, CAPABILITIES.CHUNKED_REPLAY, CAPABILITIES.SEQ_RESUME],
clientName: "my-frontend/1.0",
});
client.onMessage((msg) => store.ingest(msg, cursors));
await client.connect();Ships TypeScript source (every consumer transpiles TS — Bun, Vite, Metro).
@highflame/codeoid-protocol is a peer dependency.
