Skip to content

ProjectErebyx/erebyx-sdk-node

@erebyx/sdk

Native Node.js SDK for the EREBYX memory substrate. Built on the Rust SDK via napi-rs. Persistent AI memory across every AI you use.

License: MIT OR Apache-2.0 Version npm


Install in 5 lines

npm install @erebyx/sdk
export EREBYX_API_KEY="<YOUR_API_KEY>"   # get one at https://app.erebyx.com/keys
import { Memory } from '@erebyx/sdk'
const memory = Memory.fromEnv()
const res = await memory.save('Anchor retrieval improves recall by 40%', 'insight')
console.log('saved', res.memoryId, 'hints:', res.hints)

That's the whole loop: install -> save. Memory is encrypted in transit (TLS 1.3) and at rest using XChaCha20-Poly1305 envelope encryption (AES-256-GCM legacy supported on existing rows) with per-tenant Key Encryption Keys wrapped under a server-held master KEK. Per-user zero-knowledge encryption (passphrase-derived keys, EREBYX cannot decrypt) ships in v0.2.


What it is

@erebyx/sdk is the Node.js / TypeScript client for the EREBYX memory substrate. It wraps the Rust erebyx-sdk crate via napi-rs — same circuit breaker, same wire protocol, same lifecycle hint surface, native performance.

It exposes the v0.1.1 cognitive surface as five async methods:

Method Purpose
restoreIdentity() Wake up — load identity at session start
loadContext({ anchors }) Resume — load handoff + recent work
save(content, category, opts) Store a memory worth keeping
search(query, opts) Find what you know by meaning (the remember verb)
wrapUp(whatWeBuilt, whatsNext, opts) Create a session handoff at the end

All processing — memory understanding, recall, organization, encryption — lives behind the API — you never need to think about it.


Quickstart

import { Memory } from '@erebyx/sdk'

const memory = new Memory(process.env.EREBYX_API_KEY!, {
  apiUrl: 'https://core.erebyx.com',
  instanceId: 'my-app',
})

// Save
await memory.save('User prefers dark mode', 'knowledge', {
  anchors: ['preferences', 'ui'],
  importance: 0.7,
})

// Search
const results = await memory.search('user preferences', { limit: 5 })
for (const m of results.memories) {
  console.log(m.id, m.content)
}

// Session handoff
await memory.wrapUp('Wired the SDK', 'Add streaming search', {
  anchors: ['sdk', 'node'],
  energy: 'systematic',
})

Or use Memory.fromEnv() to read everything from env vars:

const memory = Memory.fromEnv()

Configuration

# Required
export EREBYX_API_KEY="<YOUR_API_KEY>"

# Required for tenants registered at v0.1.1+ (Argon2id-default-on).
# Find it in your dashboard recovery panel. At v0.1.1, EREBYX holds a
# server-side master KEK and can decrypt for support/backup/recovery —
# this is NOT zero-knowledge. When per-user zero-knowledge ships in v0.2,
# your passphrase + BIP39 recovery seed become the ONLY keys to your
# memory; losing both will be unrecoverable by design. Keep both safe.
export EREBYX_PASSPHRASE="<YOUR_PASSPHRASE>"

# Optional (defaults shown)
export EREBYX_API_URL="https://core.erebyx.com"
export EREBYX_INSTANCE_ID="default"

Get your API key at app.erebyx.com/keys. The dashboard surfaces the matching EREBYX_PASSPHRASE value at registration; both are required for new tenants.


X-Erebyx-Hint — lifecycle signals for free

Every SDK call surfaces the substrate's lifecycle hints (X-Erebyx-Hint response header) and any tools the substrate auto-fired (X-Erebyx-Auto-Fired). Both are typed string arrays on every response:

import { Hint } from '@erebyx/sdk/types'

const response = await memory.save('...', 'insight')

for (const hint of response.hints as Hint[]) {
  switch (hint) {
    case 'wrap_up_recommended':       /* call wrapUp at next natural break */ break
    case 'restore_identity_recommended': /* identity drift; re-anchor */ break
    case 'load_context_recommended':  /* call loadContext to refresh */ break
    case 'compact_imminent':          /* consolidate before context fills */ break
  }
}

// First call against a fresh (instanceId, sessionId) tuple typically
// reports ['restore_identity', 'load_context']; empty thereafter.
console.log('auto-fired this call:', response.autoFired)

Hint values:

  • wrap_up_recommended — substrate sees a natural consolidation boundary
  • restore_identity_recommended — voice drift detected
  • load_context_recommended — retrieval scores trending low
  • compact_imminent — sustained save volume; consolidate before context fills

Honoring hints is optional. Disable globally with EREBYX_HINTS_DISABLED=1. Full hint protocol at DEV_QUICKSTART.md.


Reliability

Built-in circuit breaker — after 3 consecutive failures, the SDK refuses calls for 30s, then attempts a half-open retry. Memory failures degrade gracefully and never crash your app.

Wrap your Memory instance with withErebyxErrors to get typed errors with stable string code values:

import { Memory } from '@erebyx/sdk'
import { withErebyxErrors, ErebyxError } from '@erebyx/sdk/errors'

const memory = withErebyxErrors(Memory.fromEnv())

try {
  await memory.save('...', 'insight')
} catch (e) {
  if (e instanceof ErebyxError && e.code === 'CIRCUIT_OPEN') {
    // Substrate degraded; backed off. Don't block the user.
    console.warn('erebyx circuit open; skipping save')
  } else {
    throw e
  }
}

Stable code values: AUTH, CIRCUIT_OPEN, RATE_LIMITED, NETWORK, SERVER, VALIDATION, NOT_FOUND, CONFIG, SERIALIZATION. See @erebyx/sdk/errors for the full type definition.


Native binaries

v0.1.1 ships a prebuilt native binary for macOS arm64 (Apple Silicon). Every other platform — macOS x64, Linux arm64, Linux x64, Windows x64 — builds from source on install (requires Rust 1.77+).

Per-platform prebuilds land in v0.1.2 once the cross-compile CI is wired. If you don't have Rust installed, rustup is the one-line install: https://rustup.rs.


How to upgrade

Track releases in CHANGELOG.md. Backward compatibility is a hard guarantee within v0.1.x — every release lists explicit breaking changes (none expected before v0.2).

npm install @erebyx/sdk@latest

Build from source

git clone https://github.com/ProjectErebyx/erebyx-sdk-node.git
cd erebyx-sdk-node
npm install
npm run build

Requires Rust 1.77+ and Node.js 18+. The native build is driven by napi build --platform --release.


See also


Contributing

Pull requests welcome. DCO sign-off required (git commit -s). See CONTRIBUTING.md.

Security

Vulnerability reports → legal@erebyx.com. See SECURITY.md.

License

Dual-licensed under MIT or Apache-2.0 at your option. See LICENSE-MIT, LICENSE-APACHE-2.0, and NOTICE.


Built by EREBYX, LLChttps://erebyx.com

About

EREBYX Node SDK (@erebyx/sdk-node) — napi-rs binding over the Rust erebyx-sdk crate. Engine private, client surface dual-licensed MIT/Apache-2.0 per Lock 12+28+42.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE-2.0
MIT
LICENSE-MIT

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors