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
7 changes: 7 additions & 0 deletions engram-client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
dist/
.DS_Store
*.tsbuildinfo
package-lock.json
yarn.lock
pnpm-lock.yaml
21 changes: 21 additions & 0 deletions engram-client/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Engram Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 68 additions & 0 deletions engram-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# @engram/client

TypeScript SDK for Engram — the decentralized AI memory layer on Bittensor.
Mirrors the Python SDK so JS/TS agent stacks can ingest, query, and manage private namespaces on the Engram subnet.

## Install

npm install @engram/client

Requires Node 18+.

## Quick Start

```typescript
import { EngramClient } from "@engram/client";
const client = new EngramClient({ minerUrl: "http://127.0.0.1:8091" });
const { cid } = await client.ingest("The transformer architecture changed everything.");
const results = await client.query("attention mechanisms", { topK: 5 });
```

## API Methods

**EngramClient**

- `ingest(text, opts?)` - Store text in the network
- `ingestEmbedding(vector, metadata?, opts?)` - Store a pre-computed embedding
- `query(text, opts?)` - Search by text
- `queryByVector(vector, opts?)` - Search by embedding vector
- `get(cid)` - Retrieve by content ID
- `delete(cid)` - Delete by content ID
- `list(opts?)` - List entries
- `health()` - Get miner health info
- `isOnline()` - Quick miner reachability check
- `ingestUrl(url)` - Ingest content from a URL
- `ingestConversation(messages, opts?)` - Ingest a chat conversation
- `ingestImage(source, altText?, opts?)` - Ingest an image
- `ingestPdf(source)` - Ingest a PDF document
- `batchIngestFile(content)` - Batch-ingest lines or paragraphs
- `distributeKeyShares(urls, secret, threshold)` - Distribute a secret across miners
- `collectKeyShares(urls)` - Reconstruct a secret from miner shares

## Error Types

- `EngramError` - Base error class
- `MinerOfflineError` - Miner unreachable
- `IngestError` - Miner rejects ingest
- `QueryError` - Miner returns query error
- `InvalidCIDError` - Malformed content ID
- `NamespaceAuthError` - Namespace auth misconfiguration

## Private Namespaces

```typescript
const client = new EngramClient({
minerUrl: "http://127.0.0.1:8091",
namespace: "my-secret-space",
namespaceKey: "your-256-bit-hex-key",
});
```

## License

MIT

## Bounty

This SDK was built as part of the TypeScript SDK bounty (Issue #22).
Contact the Engram team via the collaboration template to claim the reward.
21 changes: 21 additions & 0 deletions engram-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@engram/client",
"version": "0.1.0",
"description": "TypeScript SDK for Engram — decentralized AI memory layer on Bittensor",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist"],
"scripts": {
"build": "tsc",
"prepare": "npm run build"
},
"keywords": ["engram", "bittensor", "vector-database", "ai-memory", "decentralized"],
"license": "MIT",
"dependencies": {},
"peerDependencies": {
"@polkadot/util-crypto": "^12.0.0",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1"
},
"engines": { "node": ">=18" }
}
Loading