Installation
Requires Node.js 20+ and a running Membrane daemon (default:
localhost:9090).Quick start
Exports
The package exports the following from the top-level@gustycube/membrane entry point:
| Export | Kind | Description |
|---|---|---|
MembraneClient | class | Main client class |
MembraneError | class | Error thrown by failed RPCs |
Sensitivity | const enum | Sensitivity level values |
MemoryType | const enum | Memory type values |
OutcomeStatus | const enum | Outcome status values |
DecayCurve | const enum | Decay curve values |
DeletionPolicy | const enum | Deletion policy values |
RevisionStatus | const enum | Revision status values |
ValidityMode | const enum | Validity mode values |
TaskState | const enum | Task state values |
AuditAction | const enum | Audit action values |
ProvenanceKind | const enum | Provenance kind values |
EdgeKind | const enum | Plan graph edge kind values |
createDefaultTrustContext | function | Creates a default TrustContext |
TrustContext | type | Trust context interface |
MemoryRecord | type | Memory record interface |
RetrieveResult | type | Result from retrieveWithSelection |
SelectionResult | type | Selector metadata |
MembraneClientOptions | type | Constructor options |
IngestEventOptions | type | Options for ingestEvent |
IngestToolOutputOptions | type | Options for ingestToolOutput |
IngestObservationOptions | type | Options for ingestObservation |
IngestOutcomeOptions | type | Options for ingestOutcome |
IngestWorkingStateOptions | type | Options for ingestWorkingState |
RetrieveOptions | type | Options for retrieve / retrieveWithSelection |
MembraneClient
Constructor
gRPC server address in
host:port format. Defaults to "localhost:9090".Optional configuration object.
MembraneClientOptions
Enable TLS transport. Defaults to
false.Path to a PEM-encoded CA certificate for server verification. Implies TLS.
Bearer token sent as
authorization metadata on every RPC.Default RPC timeout in milliseconds. No timeout if omitted.
TLS and authentication example
Ingestion methods
ingestEvent
Create an episodic record from an event.
Kind of event, e.g.
"file_edit", "tool_call", "error".Reference identifier for the event source.
Human-readable summary of the event.
Sensitivity classification. Defaults to
"low".Provenance source identifier. Defaults to
"typescript-client".Tags for categorization and retrieval filtering.
Visibility scope for the record.
RFC 3339 timestamp. Defaults to now.
ingestToolOutput
Create an episodic record from a tool invocation.
Name of the tool that produced output.
Arguments passed to the tool, JSON-serializable.
Result returned by the tool, JSON-serializable.
IDs of records this output depends on.
Sensitivity classification. Defaults to
"low".ingestObservation
Create a semantic record from a subject-predicate-object triple.
The subject of the observation.
The predicate relating subject to object.
The object value (any JSON-serializable value).
ingestOutcome
Attach an outcome to an existing episodic record.
ID of the record to attach the outcome to.
One of
"success", "failure", or "partial".ingestWorkingState
Create a working memory snapshot for a task thread.
Identifier for the task thread.
Current task state:
"planning", "executing", "blocked", "waiting", or "done".Planned next steps.
Unresolved questions.
Human-readable summary of current context.
Active constraints as JSON-serializable objects.
Retrieval methods
retrieve
Retrieve memory records relevant to a task descriptor.
Natural-language description of the current task.
Trust context controlling record access. Defaults to a minimal context with
Sensitivity.LOW.Filter by memory types:
"episodic", "working", "semantic", "competence", "plan_graph".Minimum salience threshold. Defaults to
0.Maximum records to return. Defaults to
10.retrieveWithSelection
Retrieve records plus selector metadata (ranked candidates, confidence).
RetrieveResult with records and an optional selection field:
retrieveById
Fetch a single record by its ID.
Revision methods
supersede
Replace a record with a new version, creating an audit trail.
fork
Create a conditional variant of a record.
retract
Soft-delete a record. The record remains in the store but is marked as retracted.
merge
Combine multiple records into a single consolidated record.
contest
Mark a record as contested due to conflicting evidence.
Reinforcement methods
reinforce
Boost a record’s salience score.
penalize
Reduce a record’s salience score.
getMetrics
Retrieve a point-in-time metrics snapshot from the daemon.
close
Close the underlying gRPC channel. Always call this when done.
Core types
Sensitivity
Controls access during retrieval. Records above the caller’s max_sensitivity are returned in redacted form (metadata only).
| Value | String |
|---|---|
Sensitivity.PUBLIC | "public" |
Sensitivity.LOW | "low" |
Sensitivity.MEDIUM | "medium" |
Sensitivity.HIGH | "high" |
Sensitivity.HYPER | "hyper" |
TrustContext
createDefaultTrustContext() to get a zero-value context (Sensitivity.LOW, unauthenticated).
MemoryRecord
MemoryType
| Value | String |
|---|---|
MemoryType.EPISODIC | "episodic" |
MemoryType.WORKING | "working" |
MemoryType.SEMANTIC | "semantic" |
MemoryType.COMPETENCE | "competence" |
MemoryType.PLAN_GRAPH | "plan_graph" |
Error handling
Failed RPCs throwMembraneError. It exposes a stable shape regardless of the underlying gRPC status.
LLM integration pattern
The common runtime pattern is: ingest execution traces, retrieve relevant memory, build a prompt, then reinforce useful records.Snake_case aliases
Every camelCase method has a snake_case alias for ergonomics in mixed-language codebases:| camelCase | snake_case |
|---|---|
ingestEvent | ingest_event |
ingestToolOutput | ingest_tool_output |
ingestObservation | ingest_observation |
ingestOutcome | ingest_outcome |
ingestWorkingState | ingest_working_state |
retrieveWithSelection | retrieve_with_selection |
retrieveById | retrieve_by_id |
getMetrics | get_metrics |