Skip to content

Repository files navigation

AIngle Cortex SDK for JavaScript/TypeScript

The official JavaScript and TypeScript SDK for AIngle, the verifiable memory cortex for AI agents. AIngle is a semantic graph plus vector memory served over a REST API, so your agents can remember, recall, and reason over durable, queryable knowledge.

The SDK is a thin, typed HTTP client. It uses the native fetch available in Node.js 18 and later, and it ships with zero runtime dependencies.

Installation

npm install @apilium/aingle-sdk
# or
yarn add @apilium/aingle-sdk
# or
pnpm add @apilium/aingle-sdk

Quick Start

Construct a client, remember a note, then recall it.

import { AIngleClient } from '@apilium/aingle-sdk';

const client = new AIngleClient({
  baseUrl: 'http://127.0.0.1:19090',
});

// Remember a note.
const { id } = await client.remember('note', {
  text: 'The launch is scheduled for Friday.',
}, {
  tags: ['launch', 'planning'],
  importance: 0.8,
});

console.log(`Remembered entry: ${id}`);

// Recall it by text.
const results = await client.recall({
  text: 'When is the launch?',
  limit: 5,
});

for (const result of results) {
  console.log(result.relevance, result.data);
}

Configuration

Pass a config object to the constructor. Every field is optional.

Option Type Default Description
baseUrl string http://127.0.0.1:19090 Base URL of the AIngle Cortex server.
token string none Bearer token sent as Authorization: Bearer <token>.
timeoutMs number none Per-request timeout in milliseconds, enforced with AbortController.
const client = new AIngleClient({
  baseUrl: 'https://cortex.example.com',
  token: process.env.AINGLE_TOKEN,
  timeoutMs: 10_000,
});

API Reference

Health and stats

Method Description
health() Server health and component status.
stats() Graph and server statistics.

Memory

Method Description
remember(entryType, data, options?) Store a memory entry, returns { id }.
recall(options?) Recall entries by text, tags, type, or importance.
search(options) Vector search over an embedding, returns ranked results.
memoryStats() Short-term and long-term memory counters.
forget(id) Delete a memory entry by id.

Triples (semantic graph)

Method Description
createTriple(subject, predicate, object) Insert a single triple.
createTriples(triples) Batch insert triples.
listTriples(options?) List triples filtered by subject, predicate, or object.
getTriple(id) Fetch one triple by id.
deleteTriple(id) Delete a triple by id.

Query

Method Description
query(options?) Match triples against a subject, predicate, object pattern.
subjects(options?) List distinct subjects, optionally filtered by predicate.
predicates(options?) List distinct predicates, optionally filtered by subject.

The triple object value

A triple's object is an untagged union. Serialize it as the raw JSON value.

await client.createTriple('agent:1', 'name', 'Ada');        // string
await client.createTriple('agent:1', 'trust_score', 0.92);  // number
await client.createTriple('agent:1', 'is_verified', true);  // boolean
await client.createTriple('agent:1', 'knows', {             // node reference (IRI)
  node: 'http://example.org/agent/2',
});

Error handling

Any non-2xx response, timeout, or transport failure throws a typed AIngleError with a status (the HTTP status, or 0 for timeouts and network errors) and a message.

import { AIngleClient, AIngleError } from '@apilium/aingle-sdk';

try {
  await client.getTriple('does-not-exist');
} catch (err) {
  if (err instanceof AIngleError) {
    console.error(err.status, err.message);
  }
}

Development

# Install dependencies
npm install

# Type-check
npm run typecheck

# Build
npm run build

# Run tests
npm test

# Lint
npm run lint

License

Apache-2.0, see LICENSE.

Links

About

The official JavaScript / TypeScript client for AIngle, the memory cortex for AI agents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages