Skip to content

Client Reference

The primary interface for interacting with a HEBBS server. All methods return Promises.

new HebbsClient(
address?: string,
options?: HebbsClientOptions,
)
ParameterTypeDescription
addressstringServer gRPC address in host:port format. Default: localhost:6380.
options.apiKeystring | undefinedAPI key for authentication (hb_...). Falls back to process.env.HEBBS_API_KEY if not provided.
options.tenantIdstring | undefinedExplicit tenant ID. Normally derived from the API key by the server.
options.channelOptionsRecord<string, unknown> | undefinedAdditional gRPC channel options.

Call connect() to open the channel, and close() when done:

const client = new HebbsClient('localhost:6380', { apiKey: 'hb_...' });
await client.connect();
// ... use client ...
await client.close();

remember(params: RememberParams): Promise<Memory>

Section titled “remember(params: RememberParams): Promise<Memory>”

Store a new memory in the engine.

ParameterTypeDescription
contentstringThe memory content to store
importancenumber | undefinedImportance score (0.0—1.0). Default: engine-assigned.
contextRecord<string, unknown> | undefinedStructured key-value metadata (used by analogical recall for structural matching)
entityIdstring | undefinedEntity scope for the memory
edgesEdge[] | undefinedRelationships to other memories (e.g. FOLLOWED_BY, CAUSED_BY)

Returns: Memory

import { EdgeType } from '@hebbs/sdk';
const mem1 = await client.remember({
content: 'CTO expressed interest in our API',
entityId: 'initech',
});
const mem2 = await client.remember({
content: 'Requested a technical deep-dive meeting',
entityId: 'initech',
edges: [{
targetId: mem1.id,
edgeType: EdgeType.FOLLOWED_BY,
confidence: 0.95,
}],
});

Also supports positional arguments: remember(content, importance?, context?, entityId?, edges?).


Retrieve a single memory by its ID.

ParameterTypeDescription
memoryIdBufferThe 16-byte memory identifier

Returns: Memory

Throws: HebbsNotFoundError if the memory does not exist.


recall(params: RecallParams): Promise<RecallOutput>

Section titled “recall(params: RecallParams): Promise<RecallOutput>”

Query the engine for relevant memories using one or more recall strategies.

ParameterTypeDescription
cuestringNatural language query
strategies(string | RecallStrategyConfig)[] | undefinedOne or more strategy names or config objects. You can mix both. Default: ['similarity'].
topKnumber | undefinedMaximum number of results. Default: 10.
entityIdstring | undefinedEntity scope to search within
scoringWeightsScoringWeights | undefinedOverride composite scoring weights. Default: (0.5, 0.2, 0.2, 0.1).
cueContextRecord<string, unknown> | undefinedStructured context for analogical recall’s structural similarity matching. Not stored.

Returns: RecallOutput

Each result includes both score (composite) and per-strategy strategyDetails with raw relevance.

Basic usage — pass strategy names as strings:

const results = await client.recall({
cue: 'Acme meeting',
strategies: ['similarity'],
entityId: 'acme',
});

Multi-strategy — combine strategies:

const results = await client.recall({
cue: 'What is Initech doing?',
strategies: ['similarity', 'temporal'],
entityId: 'initech',
topK: 5,
});

Advanced usage — per-strategy tuning with RecallStrategyConfig:

import { EdgeType } from '@hebbs/sdk';
const results = await client.recall({
cue: 'What led to the pricing pushback?',
strategies: [{
strategy: 'causal',
seedMemoryId: seed.id,
maxDepth: 3,
edgeTypes: [EdgeType.CAUSED_BY, EdgeType.FOLLOWED_BY],
}],
});

Mixed — strings and configs together:

const results = await client.recall({
cue: 'Initech evaluation',
strategies: [
'temporal',
{ strategy: 'similarity', topK: 3, efSearch: 200 },
],
entityId: 'initech',
});

Also supports positional arguments: recall(cue, strategies?, topK?, entityId?, scoringWeights?, cueContext?).

Per-strategy tuning parameters. All fields except strategy are optional and use smart engine defaults. Most users never need this — pass strategy names as strings instead.

FieldTypeDefaultUsed ByDescription
strategystring(required)all'similarity', 'temporal', 'causal', or 'analogical'
entityIdstring | undefinedundefinedallOverride entity scope for this strategy
topKnumber | undefinedundefinedallPer-strategy result limit
efSearchnumber | undefined50similarityHNSW candidate count. Higher = more accurate, slower.
timeRange[number, number] | undefinedundefinedtemporal[startUs, endUs] in microseconds. Unbounded when omitted.
seedMemoryIdBuffer | undefinedundefinedcausalStarting node for graph traversal. Auto-detected when omitted.
maxDepthnumber | undefined5causalMax hops in traversal. Hard cap: 10.
edgeTypesEdgeType[] | undefinedundefinedcausalRestrict traversal to specific edge types. All types when omitted.
analogicalAlphanumber | undefined0.5analogicalBlend weight: 0.0 = pure structural similarity, 1.0 = pure embedding similarity.

prime(params: PrimeParams): Promise<PrimeOutput>

Section titled “prime(params: PrimeParams): Promise<PrimeOutput>”

Pre-load session context for an entity, blending temporal and similarity recall.

ParameterTypeDescription
entityIdstringEntity whose context to load
maxMemoriesnumber | undefinedMaximum total memories to return. Default: 20.
similarityCuestring | undefinedOptional cue for the similarity component. When omitted, the engine builds a synthetic cue from entity history.
scoringWeightsScoringWeights | undefinedOverride composite scoring weights.

Returns: PrimeOutput (includes results, temporalCount, similarityCount)

const prime = await client.prime({
entityId: 'initech',
maxMemories: 50,
similarityCue: 'enterprise evaluation',
});
console.log(`Temporal: ${prime.temporalCount}, Similarity: ${prime.similarityCount}`);

Also supports positional arguments: prime(entityId, maxMemories?, similarityCue?, scoringWeights?).


revise(memoryId: Buffer, params: ReviseParams): Promise<Memory>

Section titled “revise(memoryId: Buffer, params: ReviseParams): Promise<Memory>”

Update an existing memory. The memory’s kind changes to revision.

ParameterTypeDescription
memoryIdBufferID of the memory to revise
params.contentstring | undefinedUpdated content
params.importancenumber | undefinedUpdated importance score
params.contextRecord<string, unknown> | undefinedUpdated context metadata
params.entityIdstring | undefinedUpdated entity scope

Returns: Memory (the revised version)

const revised = await client.revise(mem.id, {
content: 'Deal size expanded to 350 seats',
importance: 0.95,
context: { deal_size: '350 seats', stage: 'negotiation' },
});

forget(params: ForgetParams): Promise<ForgetResult>

Section titled “forget(params: ForgetParams): Promise<ForgetResult>”

Erase memories permanently (GDPR-compliant cryptographic erasure). Pass entityId for entity-wide deletion, or memoryIds for targeted deletion.

ParameterTypeDescription
entityIdstring | undefinedDelete all memories for this entity
memoryIdsBuffer[] | undefinedSpecific memory IDs to delete

Returns: ForgetResult (includes forgottenCount, cascadeCount, tombstoneCount)

// Forget everything for an entity
const result = await client.forget({ entityId: 'gdpr-user-123' });
// Forget specific memories
const result = await client.forget({ memoryIds: [mem1.id, mem2.id] });

setPolicy(params: SetPolicyParams): Promise<boolean>

Section titled “setPolicy(params: SetPolicyParams): Promise<boolean>”

Configure tenant-level policy parameters.

ParameterTypeDescription
maxSnapshotsPerMemorynumber | undefinedMaximum revision snapshots to retain per memory
autoForgetThresholdnumber | undefinedDecay score below which memories are auto-forgotten
decayHalfLifeDaysnumber | undefinedHalf-life for memory decay in days

Returns: boolean (true on success)


reflect(params?: ReflectParams): Promise<ReflectResult>

Section titled “reflect(params?: ReflectParams): Promise<ReflectResult>”

Trigger the reflection pipeline to generate insights from memory clusters. Uses the LLM configured on the server (e.g. OpenAI GPT-4o).

ParameterTypeDescription
entityIdstring | undefinedScope reflection to a specific entity. All entities when omitted.

Returns: ReflectResult (includes insightsCreated, clustersFound, clustersProcessed, memoriesProcessed)


insights(params?: InsightsParams): Promise<Memory[]>

Section titled “insights(params?: InsightsParams): Promise<Memory[]>”

Retrieve insights generated by the reflection pipeline.

ParameterTypeDescription
entityIdstring | undefinedFilter insights by entity
maxResultsnumber | undefinedMaximum number of insights to return

Returns: Memory[] (insights are stored as kind = MemoryKind.INSIGHT memories)


reflectPrepare(params?: ReflectPrepareParams): Promise<ReflectPrepareResult> (Deprecated)

Section titled “reflectPrepare(params?: ReflectPrepareParams): Promise<ReflectPrepareResult> (Deprecated)”

Agent-driven reflection: get cluster prompts without calling any LLM. The agent reasons over the clusters and commits insights via reflectCommit.

ParameterTypeDescription
entityIdstring | undefinedScope to a specific entity. All entities when omitted.

Returns: ReflectPrepareResult (includes sessionId, memoriesProcessed, clusters, existingInsightCount)


reflectCommit(params: ReflectCommitParams): Promise<ReflectCommitResult> (Deprecated)

Section titled “reflectCommit(params: ReflectCommitParams): Promise<ReflectCommitResult> (Deprecated)”

Commit agent-produced insights from a previous reflectPrepare session.

ParameterTypeDescription
sessionIdstringSession ID from reflectPrepare output
insightsProducedInsightInput[]Insights to commit

Returns: ReflectCommitResult (includes insightsCreated)


contradictionPrepare(): Promise<PendingContradiction[]> (Deprecated)

Section titled “contradictionPrepare(): Promise<PendingContradiction[]> (Deprecated)”

Retrieve pending contradiction candidates. In the previous architecture, these were flagged by a heuristic classifier and required external agent review. HEBBS now resolves contradictions autonomously using its built-in LLM.

Returns: PendingContradiction[]

Each PendingContradiction includes pendingId, memoryIdA, memoryIdB, contentASnippet, contentBSnippet, classifierScore, classifierMethod, similarity, createdAt.

const pending = await client.contradictionPrepare();
for (const p of pending) {
console.log(`${p.pendingId}: ${p.contentASnippet} vs ${p.contentBSnippet}`);
}

contradictionCommit(verdicts: ContradictionVerdictInput[]): Promise<ContradictionCommitResult> (Deprecated)

Section titled “contradictionCommit(verdicts: ContradictionVerdictInput[]): Promise<ContradictionCommitResult> (Deprecated)”

Commit agent-reviewed verdicts for pending contradiction candidates.

ParameterTypeDescription
verdictsContradictionVerdictInput[]Verdicts for each candidate

Each ContradictionVerdictInput requires pendingId, verdict ('contradiction', 'revision', or 'dismiss'), confidence, and optional reasoning.

Returns: ContradictionCommitResult (includes contradictionsConfirmed, revisionsCreated, dismissed)

const result = await client.contradictionCommit(
pending.map(p => ({
pendingId: p.pendingId,
verdict: 'contradiction' as const,
confidence: 0.9,
reasoning: 'Direct conflict in reliability assessment',
}))
);

subscribe(params?: SubscribeParams): Promise<Subscription>

Section titled “subscribe(params?: SubscribeParams): Promise<Subscription>”

Open a real-time subscription for memory surfacing.

ParameterTypeDescription
entityIdstring | undefinedEntity scope
confidenceThresholdnumberMinimum confidence for pushes. Default: 0.5.

Returns: Subscription

The Subscription object supports:

  • feed(text) — send text to the stream for matching
  • close() — close the subscription
  • Async iteration — for await (const push of sub) to receive SubscribePush events

See Subscribe Streaming for full usage.


Check server health and readiness. This endpoint does not require authentication.

Returns: HealthStatus (includes serving, version, memoryCount, uptimeSeconds)


Return the total number of memories stored (via the health endpoint).

Returns: number


The HebbsRestClient provides file upload for enterprise server deployments. It connects over HTTP/REST instead of gRPC.

import { HebbsRestClient } from '@hebbs/sdk';
const hb = new HebbsRestClient("https://your-server:8080", { apiKey: "hb_live_sk_..." });
const result = await hb.index([
{ name: "call-notes.md", content: new Uint8Array(await fs.readFile("./docs/call-notes.md")) },
{ name: "proposal.md", content: new Uint8Array(await fs.readFile("./docs/proposal.md")) },
]);
console.log(`Uploaded ${result.uploaded} files`);
await hb.close();

index(files: FileInput[]): Promise<RestUploadResult>

Section titled “index(files: FileInput[]): Promise<RestUploadResult>”

Upload files for server-side indexing. Files are uploaded via multipart POST to /v1/upload. Unchanged files are skipped on the server via checksum comparison.

ParameterTypeDescription
files{ name: string; content: Uint8Array }[]Array of files with name and binary content

Returns: RestUploadResult with uploaded (count) and files (list of filenames)

The HebbsRestClient also supports remember(), recall(), prime(), forget(), and insights() over REST, with the same signatures as the gRPC HebbsClient.