Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
78 changes: 78 additions & 0 deletions sdk/typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# @engram/client

TypeScript client for the [Engram](https://github.com/Dipraise1/Engram) decentralized vector database.

Mirrors the Python `engram.sdk` API so JS/TS agent stacks can use Engram for semantic memory.

## Install

```bash
npm install @engram/client
```

## Quick Start

```typescript
import { EngramClient } from "@engram/client";

const client = new EngramClient({
minerUrl: "http://127.0.0.1:8091",
});

// Store a memory
const cid = await client.ingest("The transformer architecture changed everything.");
console.log("Stored:", cid);

// Search
const results = await client.query("attention mechanisms in deep learning", {
topK: 5,
});
for (const r of results) {
console.log(r.cid, r.score);
}
```

## API

### `new EngramClient(options?)`

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `minerUrl` | `string` | `"http://127.0.0.1:8091"` | Miner HTTP endpoint |
| `timeout` | `number` | `30000` | Request timeout (ms) |
| `namespace` | `string` | — | Private namespace name |
| `namespaceKey` | `string` | — | Namespace encryption key |

### Methods

- **`ingest(text, metadata?)`** — Store text, returns CID
- **`ingestEmbedding(vector, metadata?)`** — Store a pre-computed embedding
- **`query(text, options?)`** — Semantic search, returns `QueryResult[]`
- **`queryByVector(vector, topK?)`** — Search by vector
- **`get(cid)`** — Retrieve a memory by CID
- **`delete(cid)`** — Delete a memory
- **`list(options?)`** — List memories with optional filter
- **`ingestConversation(messages, options?)`** — Store a conversation
- **`health()`** — Check miner liveness
- **`isOnline()`** — Boolean health check

### Errors

All errors extend `EngramError`:

- `MinerOfflineError` — miner unreachable
- `IngestError` — storage failed
- `QueryError` — search failed
- `InvalidCIDError` — malformed CID from miner

## Development

```bash
npm install
npm run build
npm test
```

## License

MIT
48 changes: 48 additions & 0 deletions sdk/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions sdk/typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@engram/client",
"version": "0.1.0",
"description": "TypeScript client for the Engram decentralized vector database",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"test": "node --test test/*.test.js",
"prepublishOnly": "npm run build"
},
"keywords": ["engram", "vector", "database", "bittensor", "semantic", "memory"],
"license": "MIT",
"devDependencies": {
"typescript": "^5.4.0",
"@types/node": "^20.0.0"
},
"files": ["dist", "README.md"]
}
Loading