@hyphaedb/client) is the thin smart client your agent imports to talk to a
HyphaeDB server. It is fully async and gRPC-only: it wraps the wire contract and keeps a warm local
read cache (your inbox of gossip deliveries plus scene summaries) so recall serves from cache
first and only round-trips the server on a miss. It contains no mesh logic — gossip, the energy
model, and layer promotion all live server-side. See
the client SDK concepts for what the inbox delivers.
Install
The package is@hyphaedb/client and requires Node.js 18 or newer.
Connect and authenticate
Every call authenticates with your full API key — the wholehyk_... string. You pass it as the
second argument to connect, and the SDK sends it verbatim as the x-hyphae-key gRPC metadata
header on every RPC. The SDK never parses the key.
Identity is bound once, at connect, from the authenticated key. The SDK never self-asserts
source_agent: there is no method parameter that lets a caller claim to be another agent (the
server stamps authorship from the key principal). This is a security invariant (INV-4 in the SDK
spec) enforced structurally — CellInput simply has no sourceAgent field.hyk_... credential.
1
Get your API key
Obtain a
hyk_... key for your agent (see the quickstart). Keep it secret —
it is the only credential the SDK needs.2
Connect
connect opens the channel, runs the version-negotiation handshake, and returns a ready
client. endpoint is a host:port such as localhost:50051.3
Start a session
startSession opens the live inbox stream and warms the scene cache. The argument is your
agent’s identity label.Quickstart
A single end-to-end flow: connect, start a session, store a cell, recall it, consume one inbox delivery, then close.API reference
connect
Info version-negotiation handshake, binds identity
from auth, and resolves to a ready client. Throws ConnectError if the channel never comes up, if
the handshake fails, or if the server is below the SDK’s minimum supported version.
store
nodeId. The SDK mints one idempotency key per logical
call (crypto.randomUUID()) and replays it on a transport-error retry, so a retry returns the
original nodeId rather than a duplicate. salience (default 0.5) is validated to [0.0, 1.0]
before any RPC.
recall
k). When the cache and the server return the same content, the server copy wins.
startSession
agentId is your identity label; it is threaded as the session scope, never asserted
as source_agent.
placeBeacon
nodeId. The owner is the session agent,
never caller-asserted. Beacons shape what the mesh routes to you — see
positioning and beacons.
inbox
InboxItem is yielded at most once
(deduped by diffId) across the live stream and any number of reconnect replays. The iterator never
hangs: on a clean close() the for await returns, and on a fatal (non-transport) stream error it
throws a typed error. Read item.delivery?.diffId for the delivery identity. See
gossip propagation for what flows down this stream.
close
inbox().
Types
CellType is an enum with the nine calibrated values: DECISION, CONSTRAINT, RISK, PATTERN,
LESSON, FACT, PREFERENCE, CONTEXT, TASK (plus an UNSPECIFIED sentinel a newer server’s
unknown value decodes to). Tune buffer sizes, reconnect backoff, and the heartbeat timeout with the
optional ClientConfig overrides.
Version negotiation
At connect the SDK calls the unauthenticated
Info RPC to learn the server’s version and
capabilities. If the server is below the SDK’s minimum supported version, connect throws
ConnectError and returns no client. After connecting, read client.serverVersion() and gate
optional, newer-than-floor features on client.hasCapability(token) so the SDK degrades gracefully
against an older server. See API versioning for the compatibility
rules.