@pipeline-moe/client-core
v0.1.13
Published
Framework-agnostic client for a pipeline-moe server: typed REST surface, pure SSE reducer, and an effectful room store. Consumed by the web and terminal clients.
Maintainers
Readme
@pipeline-moe/client-core
Framework-agnostic client library for a
pipeline-moe server — the shared
core behind both official clients (the
pmoe TUI and the bundled
web UI).
What's inside
- Typed REST surface —
createApi(apiBase)wraps every server endpoint (rooms, messages, lineup, presets, providers) with typed requests/responses. - Pure SSE reducer —
reduce(state, event) -> { state, effects }turns the server's event stream into room state deterministically; trivially unit testable. - Effectful room store —
createRoomStorebinds the reducer to a liveEventSource, with subscribe/notify semantics that plug straight intouseSyncExternalStore(web) or any render loop (TUI). - Injectable
EventSourceFactory— the browser uses the globalEventSource; Node clients inject one (e.g. theeventsourcepackage).
Ships as plain ESM with type declarations — no framework, no build-tool assumptions.
Install
npm i @pipeline-moe/client-coreUsage sketch
import { createRoomStore } from "@pipeline-moe/client-core"
const store = createRoomStore({
apiBase: "http://localhost:5300",
roomId: "default",
// In the browser, omit eventSourceFactory (global EventSource is used).
// In Node, inject one built on the `eventsource` package:
eventSourceFactory: nodeEventSourceFactory,
})
const unsubscribe = store.subscribe(() => {
const state = store.getSnapshot() // roster, transcript, streaming buffers…
})
store.start() // loads the snapshot and opens the SSE streamA Node factory is ~10 lines over the EventSourceFactory seam — see
packages/tui/src/nodeEventSource.ts
for the reference implementation.
License
MIT — see the repository.
