npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@redis-iris/agent-memory

v1.1.1

Published

Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@redis-iris/agent-memory* API.

Readme

@redis-iris/agent-memory

Developer-friendly & type-safe Typescript SDK specifically catered to leverage @redis-iris/agent-memory API.

Built by Speakeasy License: MIT

Summary

Redis Agent Memory Data Plane API: API for storing, retrieving, and searching Redis Agent Memory session memory and long-term memory.

Authentication depends on your deployment. Use the credential issued for your Agent Memory service or store. For self-managed deployments, see the self-managed Agent Memory guide for authentication options.

Documentation

Control and data plane clients

One installation of @redis-iris/agent-memory provides two independently configured clients. AgentMemoryService manages stores and their extractors through the control-plane API. AgentMemory reads and writes the memories of one store through the data-plane API.

import { AgentMemory, AgentMemoryService } from "@redis-iris/agent-memory";

const service = new AgentMemoryService({
  serverURL: process.env.AGENT_MEMORY_CONTROL_PLANE_URL!,
  token: process.env.AGENT_MEMORY_SERVICE_TOKEN,
});
const stores = await service.listStores();

const memory = new AgentMemory({
  serverURL: process.env.AGENT_MEMORY_DATA_PLANE_URL!,
  apiKey: process.env.AGENT_MEMORY_API_KEY,
  storeId: process.env.AGENT_MEMORY_STORE_ID,
});
const sessions = await memory.listSessions();

Supply the appropriate URL and credential for each plane. The SDK does not derive a data-plane URL or credential from a control-plane response. Control-plane methods take storeId per call. If omitted, the CP credential is read from AGENT_MEMORY_SERVICE_TOKEN; it never falls back to AGENT_MEMORY_API_KEY. CP models and errors are under the @redis-iris/agent-memory/controlplane/models subpaths; existing DP imports are unchanged.

Account databases, the EULA, network information, store models, and clearing a store's content with clearStore are cloud only and return 404 on-prem. Their generated documentation is labeled Cloud only.

Store metrics are on the data-plane client: call getStoreMetrics on AgentMemory. They are also cloud only and return 404 on-prem.

The bearer token works against on-prem today: pass the admin token or an operator JWT, with serverURL pointing at the control plane service (port 9100). The UI gateway's /api/memory route passes the token through only with SSO off; with SSO on it requires a UI session. The cloud control plane does not accept a programmatic credential yet.

Recent changes

Unified Iris API (0.4.0). Data-plane calls go to /iris/data/v1/agent-memory/stores/{storeId}/... and control-plane calls to /iris/v1/agent-memory/.... Sessions live under sessions and long-term memories under memories. Search takes query and minScore (formerly text and similarityThreshold). Lists return items and nextCursor; pass nextCursor back as cursor (formerly pageToken). Namespace bindings and filters use namespaceId (formerly namespaceRef). A long-term memory filter carries its own conjunction in op (ALL or ANY), replacing the request-level filterOp. Records name their IDs memoryId, viewId, namespaceId, and so on. Server-generated IDs are typed: st_, ns_, sv_, ex_ or ing_ followed by 32 lowercase hex characters. Enum values are upper case, such as LONG_TERM, READY, ACCEPT and ASC.

Namespace resources (since 0.3.0). Create and manage namespaces with listNamespaces, createNamespace, getNamespace, updateNamespace, and deleteNamespace. Bind a session or long-term memory to a namespace resource with namespaceId.

Namespace routing (0.4.0). Define a store-wide policy with putNamespaceRouting to organize long-term memories in shared namespaces. ACCEPT rules select a destination; REJECT rules can block a memory from entering that destination, even when a caller names it explicitly. The policy only targets shared namespaces. To route a memory that is already in a shared namespace, call moveLongTermMemories({ memoryIds: ["mem-1"] }) without namespaceId. Memories in personal namespaces or no namespace are not eligible for automatic routing. A new memory with neither namespace field remains unnamespaced.

Document ingestion (MemoryETL, 0.4.0). Generate long-term memories from documents, such as policies, before an agent has any sessions. This complements extraction from session events. Configure a document Extractor, submit a revision with createDocumentIngestion, then check its asynchronous status and list the memories it produced. Pass document content as a base64-encoded UTF-8 string.

Summary Views (0.4.0). Materialize summaries of long-term memories. The server assigns ownerId. Visibility defaults to private; set SHARED to publish a view of shared memories to store-authorized callers. Filter sources with namespaceId, and group by owner, session, namespace ID, or memory type. A result read uses that same scope. The service checks the contributing records and withholds invalid output while repair is pending. Choose text or structured output, then refresh on demand or use continuous refresh. Summary Views must be enabled in the deployment.

Ordering. Filter-only long-term search accepts sortBy (createdAt or updatedAt) and sortOrder (ASC or DESC). Do not combine sort with query. listSessions and listNamespaces accept the same kind of sort; listNamespaces defaults to id ascending. Pass sortBy and sortOrder (and the listSessions namespaceId filter) after request options so existing positional arguments stay in place.

Sessions. createSession creates a session with its first event and refuses an existing sessionId with 409; addSessionEvent appends to an existing session. listSessions returns session rows with owner, timestamps, and namespace ID, replacing listSessionSummaries.

Ingestion hooks. When a store selects an input hook, memory and document writes require idempotencyKey. A stopped hook returns HTTP 422, and a retryable hook returns HTTP 503. Read one decision with getIngestionHookStatus, or list them with listIngestionHookStatuses.

Source evidence. A memory source can be a document or a session. Page the evidence for one source with listMemorySourceEvidence.

Namespace labels removed. Memories and sessions no longer take the deprecated flat namespace string or the namespaceRef object. Use namespaceId for writes, filters, Summary View grouping and result scope.

HTTP 424. When a memory or model-provider dependency cannot complete the request, the SDK raises FailedDependencyErrorResponseContent. MemoryFailedDependencyErrorResponseContent is gone.

Table of Contents

SDK Installation

The SDK can be installed with either npm, pnpm, bun or yarn package managers.

NPM

npm add @redis-iris/agent-memory

PNPM

pnpm add @redis-iris/agent-memory

Bun

bun add @redis-iris/agent-memory

Yarn

yarn add @redis-iris/agent-memory

[!NOTE] This package is published with CommonJS and ES Modules (ESM) support.

Requirements

For supported JavaScript runtimes, please consult RUNTIMES.md.

SDK Example Usage

Create a namespace

Create a shared root namespace. Replace ns_0123456789abcdef0123456789abcdef in the following examples with the returned namespace ID.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.createNamespace({
    name: "product",
    scope: "SHARED",
  });

  console.log(result);
}

run();

Add a session event

Append a chat turn. The server extracts long-term memory from the session asynchronously. Optionally bind the session with namespaceId so extracted memories land in that namespace.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.addSessionEvent("session-user42-20240315", {
    actorId: "user-42",
    content: [
      {
        text: "What were the action items from last week's meeting?",
      },
    ],
    createdAt: new Date("2024-03-15T10:00:00Z"),
    namespaceId: "ns_0123456789abcdef0123456789abcdef",
    role: "USER",
  });

  console.log(result);
}

run();

Get session memory

Read the conversation for a session. It should contain the messages you added:

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.getSessionMemory("session-user42-20240315");

  console.log(result);
}

run();

Search long-term memory

Search long-term memory the server extracted or you created manually. In this example, we limit the search to one namespace with a namespaceId filter.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.searchLongTermMemory({
    filter: {
      namespaceId: {
        eq: "ns_0123456789abcdef0123456789abcdef",
      },
    },
    query: "preferred theme",
  });

  console.log(result);
}

run();

Create long-term memories

Optionally write long-term memories yourself instead of waiting for extraction.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.bulkCreateLongTermMemories({
    memories: [
      {
        memoryId: "mem-1",
        namespaceId: "ns_0123456789abcdef0123456789abcdef",
        ownerId: "user-1",
        text: "The user prefers dark mode",
      },
    ],
  });

  console.log(result);
}

run();

Move long-term memories

Optionally move existing memories into a namespace. Omit namespaceId to auto-route memories already in a shared namespace when store routing is enabled.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.moveLongTermMemories({
    memoryIds: [
      "mem-1",
    ],
    namespaceId: "ns_0123456789abcdef0123456789abcdef",
  });

  console.log(result);
}

run();

Set namespace routing policy

Replace the store routing policy. Accept rules pick a shared namespace from memory text. Reject rules can veto that destination, including explicit placements.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.putNamespaceRouting({
    policy: {
      enabled: true,
      rules: [
        {
          action: "ACCEPT",
          destinationNamespaceId: "ns_0123456789abcdef0123456789abcdef",
          enabled: true,
          id: "invoices",
          strategies: [
            {
              kind: "MATCHER_SPEC",
              matcher: {
                kind: "REGEX",
                regex: {
                  pattern: "invoice",
                },
              },
            },
          ],
        },
      ],
    },
  });

  console.log(result);
}

run();

Get namespace routing policy

Read the store routing policy. An empty disabled policy is returned when none has been saved.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.getNamespaceRouting();

  console.log(result);
}

run();

Submit a document for extraction

Use an Extractor configured for documents in the control plane. The response accepts an asynchronous job; poll its status before reading outputs. Reuse the idempotency key only for the same submission.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.createDocumentIngestion({
    content: "Q3VzdG9tZXIgcHJlZmVycyBlbWFpbCB1cGRhdGVzLg==",
    documentId: "customer-preferences",
    extractorId: "ex_0123456789abcdef0123456789abcdef",
    idempotencyKey: "customer-preferences-v1",
    mediaType: "text/plain",
    ownerId: "user-123",
    revision: "v1",
  });

  console.log(result);
}

run();

Check document ingestion

Replace the ingestion ID with the ID returned by submission. Wait for a terminal status before listing the extracted memories.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.getDocumentIngestion(
    "ing_0123456789abcdef0123456789abcdef",
  );

  console.log(result);
}

run();

Read document ingestion outputs

List the memories created by an ingestion. Pass the returned nextCursor as cursor to read more pages.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.listDocumentIngestionOutputs(
    "ing_0123456789abcdef0123456789abcdef",
  );

  console.log(result);
}

run();

Create a Summary View

Create an owner-grouped view of long-term memories. Summary Views must be enabled in the deployment.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.createSummaryView({
    groupBy: [
      "ownerId",
    ],
    name: "Customer preferences",
    output: {
      format: "TEXT",
      instructions: "Summarize the customer's preferences.",
    },
    refreshPolicy: {
      mode: "MANUAL",
    },
    source: "LONG_TERM",
  });

  console.log(result);
}

run();

Refresh a Summary View

Queue a refresh for one owner. Replace the view ID with the ID returned when creating the view.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.refreshSummaryView(
    "sv_0123456789abcdef0123456789abcdef",
    {
      scope: {
        ownerId: "user-123",
      },
      target: "PARTITION",
    },
  );

  console.log(result);
}

run();

Read a Summary View result

Read the latest result for the same owner scope. Refresh runs asynchronously, so inspect the returned status.

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.getSummaryViewResult(
    "sv_0123456789abcdef0123456789abcdef",
    "user-123",
  );

  console.log(result);
}

run();

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

| Name | Type | Scheme | Environment Variable | | -------- | ---- | ----------- | ---------------------- | | apiKey | http | HTTP Bearer | AGENT_MEMORY_API_KEY |

To authenticate with the API the apiKey parameter must be set when initializing the SDK client instance. For example:

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.getServiceLiveness();

  console.log(result);
}

run();

Available Resources and Operations

AgentMemory SDK

  • getServiceLiveness - Reports that this API process can answer requests, independently of downstream dependencies.
  • getServiceReadiness - Evaluates the same serving dependencies as the operational readiness probe. Returns 503 without dependency details when the service cannot serve requests.
  • createDocumentIngestion - Submit one revisioned document for extraction.
  • getDocumentIngestion
  • listDocumentIngestionOutputs
  • storeHealth - Returns read-only health for applicable store-scoped Agent Memory features.
  • listIngestionHookStatuses - List hook decisions in stable newest-first order. Pages can be empty after owner filtering; continue while nextCursor is present.
  • getIngestionHookStatus - Read a hook decision and application status. Requires authenticated store access and, when enforced, matching owner scope. Content and secrets are never returned.
  • bulkCreateLongTermMemories - Creates long-term memories in bulk. A memoryId that already exists is rejected for that record (reported in errors) and the stored memory is left unchanged; change a memory with UpdateLongTermMemory. Records without namespaceId stay un-namespaced. Automatic routing does not place them in a shared namespace. An explicit namespaceId must pass destination admission and is never rerouted. Admission failures are reported per record in errors.
  • bulkDeleteLongTermMemories - Deletes long-term memories in bulk by their IDs.
  • moveLongTermMemories - Moves long-term memories to an explicit namespaceId, or automatically routes a memory that is already in a shared namespace when namespaceId is omitted. Personal and un-namespaced memories are not automatic-routing candidates and keep their current placement with a per-item error. If routing is disabled or no shared destination qualifies, the memory also keeps its current placement and receives a per-item error. An explicit destination must pass admission and is never rerouted. Returns 409 when the explicit destination is archived; automatic routing and admission failures are reported per item in errors.
  • searchLongTermMemory - Runs a semantic search on long-term memory with filtering options.
  • getLongTermMemory - Returns a long-term memory by its ID.
  • updateLongTermMemory - Partially updates a long-term memory by its ID. The merged record must pass admission at its destination. Updates never select a different destination automatically. Namespace-only updates preserve the current expiration and are allowed for document-managed memories; their extracted content remains protected.
  • upsertLongTermMemory - Creates or fully replaces one manually managed memory, including custom attributes. Omitted optional fields are cleared; memoryType defaults to semantic. Replacement preserves creation time and restarts the store TTL. Destination admission and ownership checks apply. A concurrent write can return a conflict or not-found error; retry after reading the current record. An idempotencyKey replays the saved result during the retry window (at most 24 hours, capped by the store memory TTL); expectedRevision guards replacement against concurrent changes.
  • updateLongTermMemoryFields - Atomically updates a custom-typed long-term memory's text and/or attributes, scoped to the caller's bound memory type. New text must pass destination admission before the update is applied.
  • listMemorySourceLinks - Pages source links for one long-term memory. Tokens bind this query and expire.
  • listMemorySourceEvidence - Pages extraction evidence for one source of a memory, in append order. Tokens bind the store, current owner, memory and source, and expire.
  • getStoreMetrics - Redis Cloud only. Get metrics for a memory store. Returns latency and request count metrics for short-term and long-term memory operations.
  • getNamespaceRouting - Returns the store's namespace routing policy. An empty disabled policy is returned when none has been saved.
  • putNamespaceRouting - Replaces the store's namespace routing policy.
  • listNamespaces - Lists namespace roots or direct children.
  • createNamespace - Creates a namespace resource as a root, direct child, or explicit hierarchy path. Returns 409 when an active or archived namespace already occupies the requested location.
  • deleteNamespace - Deletes an empty leaf namespace. Returns 409 when the namespace has children or memory placements, or when it changed concurrently.
  • getNamespace - Gets one namespace by its canonical ID.
  • updateNamespace - Renames or archives a namespace. Returns 409 when the namespace changed concurrently, an active or archived sibling already uses the requested name, or the namespace is archived.
  • listSessions - Returns paginated session rows with metadata and caller-selected order.
  • createSession - Creates a session with its first event. If sessionId is omitted, the server generates one. A sessionId that already exists is refused with 409 and the session is left unchanged; use AddSessionEvent to append to an existing session.
  • deleteSessionMemory - Deletes the session memory for a session.
  • getSessionMemory - Returns the session memory for a session.
  • addSessionEvent - Appends a single event to a session. Creates the session if it does not exist.
  • deleteSessionEvent - Deletes a single event from a session by event ID.
  • getSessionEvent - Returns a single event from a session by event ID.
  • listSourceMemories - Pages memories linked to one source. A source link does not grant access to a memory in another owner or namespace.
  • listSummaryViews - Lists Summary View definitions and high-level state. Partition values are not included.
  • createSummaryView - Creates a Summary View definition and asynchronously enqueues its initial reconciliation.
  • deleteSummaryView - Marks a Summary View deleting and asynchronously removes its schedule and materializations in bounded batches. Repeated requests are idempotent.
  • getSummaryView - Returns one Summary View definition without partition values.
  • updateSummaryView - Updates mutable Summary View fields. Source is immutable. Material changes increment definitionVersion; name- or description-only changes do not enqueue refresh work.
  • refreshSummaryView - Asynchronously enqueues one exact partition refresh or a complete view reconciliation. It never performs generation synchronously.
  • getSummaryViewResult - Returns one authorized exact Summary View partition after validating its contributing source records. Invalid output is withheld while repair is pending.

Standalone functions

All the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.

To read more about standalone functions, check FUNCTIONS.md.

  • addSessionEvent - Appends a single event to a session. Creates the session if it does not exist.
  • bulkCreateLongTermMemories - Creates long-term memories in bulk. A memoryId that already exists is rejected for that record (reported in errors) and the stored memory is left unchanged; change a memory with UpdateLongTermMemory. Records without namespaceId stay un-namespaced. Automatic routing does not place them in a shared namespace. An explicit namespaceId must pass destination admission and is never rerouted. Admission failures are reported per record in errors.
  • bulkDeleteLongTermMemories - Deletes long-term memories in bulk by their IDs.
  • createDocumentIngestion - Submit one revisioned document for extraction.
  • createNamespace - Creates a namespace resource as a root, direct child, or explicit hierarchy path. Returns 409 when an active or archived namespace already occupies the requested location.
  • createSession - Creates a session with its first event. If sessionId is omitted, the server generates one. A sessionId that already exists is refused with 409 and the session is left unchanged; use AddSessionEvent to append to an existing session.
  • createSummaryView - Creates a Summary View definition and asynchronously enqueues its initial reconciliation.
  • deleteNamespace - Deletes an empty leaf namespace. Returns 409 when the namespace has children or memory placements, or when it changed concurrently.
  • deleteSessionEvent - Deletes a single event from a session by event ID.
  • deleteSessionMemory - Deletes the session memory for a session.
  • deleteSummaryView - Marks a Summary View deleting and asynchronously removes its schedule and materializations in bounded batches. Repeated requests are idempotent.
  • getDocumentIngestion
  • getIngestionHookStatus - Read a hook decision and application status. Requires authenticated store access and, when enforced, matching owner scope. Content and secrets are never returned.
  • getLongTermMemory - Returns a long-term memory by its ID.
  • getNamespace - Gets one namespace by its canonical ID.
  • getNamespaceRouting - Returns the store's namespace routing policy. An empty disabled policy is returned when none has been saved.
  • getServiceLiveness - Reports that this API process can answer requests, independently of downstream dependencies.
  • getServiceReadiness - Evaluates the same serving dependencies as the operational readiness probe. Returns 503 without dependency details when the service cannot serve requests.
  • getSessionEvent - Returns a single event from a session by event ID.
  • getSessionMemory - Returns the session memory for a session.
  • getStoreMetrics - Redis Cloud only. Get metrics for a memory store. Returns latency and request count metrics for short-term and long-term memory operations.
  • getSummaryView - Returns one Summary View definition without partition values.
  • getSummaryViewResult - Returns one authorized exact Summary View partition after validating its contributing source records. Invalid output is withheld while repair is pending.
  • listDocumentIngestionOutputs
  • listIngestionHookStatuses - List hook decisions in stable newest-first order. Pages can be empty after owner filtering; continue while nextCursor is present.
  • listMemorySourceEvidence - Pages extraction evidence for one source of a memory, in append order. Tokens bind the store, current owner, memory and source, and expire.
  • listMemorySourceLinks - Pages source links for one long-term memory. Tokens bind this query and expire.
  • listNamespaces - Lists namespace roots or direct children.
  • listSessions - Returns paginated session rows with metadata and caller-selected order.
  • listSourceMemories - Pages memories linked to one source. A source link does not grant access to a memory in another owner or namespace.
  • listSummaryViews - Lists Summary View definitions and high-level state. Partition values are not included.
  • moveLongTermMemories - Moves long-term memories to an explicit namespaceId, or automatically routes a memory that is already in a shared namespace when namespaceId is omitted. Personal and un-namespaced memories are not automatic-routing candidates and keep their current placement with a per-item error. If routing is disabled or no shared destination qualifies, the memory also keeps its current placement and receives a per-item error. An explicit destination must pass admission and is never rerouted. Returns 409 when the explicit destination is archived; automatic routing and admission failures are reported per item in errors.
  • putNamespaceRouting - Replaces the store's namespace routing policy.
  • refreshSummaryView - Asynchronously enqueues one exact partition refresh or a complete view reconciliation. It never performs generation synchronously.
  • searchLongTermMemory - Runs a semantic search on long-term memory with filtering options.
  • storeHealth - Returns read-only health for applicable store-scoped Agent Memory features.
  • updateLongTermMemory - Partially updates a long-term memory by its ID. The merged record must pass admission at its destination. Updates never select a different destination automatically. Namespace-only updates preserve the current expiration and are allowed for document-managed memories; their extracted content remains protected.
  • updateLongTermMemoryFields - Atomically updates a custom-typed long-term memory's text and/or attributes, scoped to the caller's bound memory type. New text must pass destination admission before the update is applied.
  • updateNamespace - Renames or archives a namespace. Returns 409 when the namespace changed concurrently, an active or archived sibling already uses the requested name, or the namespace is archived.
  • updateSummaryView - Updates mutable Summary View fields. Source is immutable. Material changes increment definitionVersion; name- or description-only changes do not enqueue refresh work.
  • upsertLongTermMemory - Creates or fully replaces one manually managed memory, including custom attributes. Omitted optional fields are cleared; memoryType defaults to semantic. Replacement preserves creation time and restarts the store TTL. Destination admission and ownership checks apply. A concurrent write can return a conflict or not-found error; retry after reading the current record. An idempotencyKey replays the saved result during the retry window (at most 24 hours, capped by the store memory TTL); expectedRevision guards replacement against concurrent changes.

Global Parameters

A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.

For example, you can set storeId to "<id>" at SDK initialization and then you do not have to pass the same value on calls to operations like createDocumentIngestion. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.

Available Globals

The following global parameter is available. Global parameters can also be set via environment variable.

| Name | Type | Description | Environment | | ------- | ------ | ---------------------- | --------------------- | | storeId | string | The storeId parameter. | AGENT_MEMORY_STORE_ID |

Example

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  storeId: "<id>",
  apiKey: "<AGENT_MEMORY_API_KEY>",
});

async function run() {
  const result = await agentMemory.createDocumentIngestion({
    content: "Q3VzdG9tZXIgcHJlZmVycyBlbWFpbCB1cGRhdGVzLg==",
    documentId: "customer-preferences",
    extractorId: "ex_0123456789abcdef0123456789abcdef",
    idempotencyKey: "customer-preferences-v1",
    mediaType: "text/plain",
    ownerId: "user-123",
    revision: "v1",
  });

  console.log(result);
}

run();

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
});

async function run() {
  const result = await agentMemory.getServiceLiveness({
    retries: {
      strategy: "backoff",
      backoff: {
        initialInterval: 1,
        maxInterval: 50,
        exponent: 1.1,
        maxElapsedTime: 100,
      },
      retryConnectionErrors: false,
    },
  });

  console.log(result);
}

run();

If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:

import { AgentMemory } from "@redis-iris/agent-memory";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
  retryConfig: {
    strategy: "backoff",
    backoff: {
      initialInterval: 1,
      maxInterval: 50,
      exponent: 1.1,
      maxElapsedTime: 100,
    },
    retryConnectionErrors: false,
  },
});

async function run() {
  const result = await agentMemory.getServiceLiveness();

  console.log(result);
}

run();

Error Handling

AgentMemoryError is the base class for all HTTP error responses. It has the following properties:

| Property | Type | Description | | ------------------- | ---------- | --------------------------------------------------------------------------------------- | | error.message | string | Error message | | error.statusCode | number | HTTP response status code eg 404 | | error.headers | Headers | HTTP response headers | | error.body | string | HTTP body. Can be empty string if no body is returned. | | error.rawResponse | Response | Raw HTTP response | | error.data$ | | Optional. Some errors may contain structured data. See Error Classes. |

Example

import { AgentMemory } from "@redis-iris/agent-memory";
import * as errors from "@redis-iris/agent-memory/models/errors";

const agentMemory = new AgentMemory({
  serverURL: "https://api.example.com",
});

async function run() {
  try {
    const result = await agentMemory.getServiceLiveness();

    console.log(result);
  } catch (error) {
    // The base class for HTTP error responses
    if (error instanceof errors.AgentMemoryError) {
      console.log(error.message);
      console.log(error.statusCode);
      console.log(error.body);
      console.log(error.headers);

      // Depending on the method different errors may be thrown
      if (error instanceof errors.PayloadTooLargeErrorResponseContent) {
        console.log(error.data$.detail); // string
        console.log(error.data$.instance); // string
        console.log(error.data$.status); // number
        console.log(error.data$.title); // string
        console.log(error.data$.type); // models.PayloadTooLargeErrorType
      }
    }
  }
}

run();

Error Classes

Primary errors:

  • AgentMemoryError: The base class for HTTP error responses.
    • PayloadTooLargeErrorResponseContent: The request payload exceeds the maximum supported size. Status code 413.
    • BadRequestErrorResponseContent: Request validation or input decoding failed. Status code 400. *
    • AuthenticationErrorResponseContent: Authentication credentials are missing, malformed, or invalid. Status code 401. *
    • ForbiddenErrorResponseContent: The caller is authenticated but not allowed to access the requested resource. Status code 403. *
    • FailedDependencyErrorResponseContent: A dependent resource required to process the request is unavailable or unhealthy. Status code 424. *
    • UnexpectedErrorResponseContent: The service failed with an unexpected internal error. Status code 500. *
    • NotFoundErrorResponseContent: The requested resource does not exist. Status code 404. *
    • TimeoutErrorResponseContent: The request timed out before the service could complete it. Status code 408. *

Network errors:

  • ConnectionError: HTTP client was unable to make a request to a server.
  • RequestTimeoutError: HTTP request timed out due to an AbortSignal signal.
  • RequestAbortedError: HTTP request was aborted by the client.
  • InvalidRequestError: Any input used to create a request is invalid.
  • UnexpectedClientError: Unrecognised or unexpected error.

Inherit from AgentMemoryError:

  • ResourceSuspendedErrorResponseContent: The requested resource exists but is suspended by an administrator. Status code 423. Applicable to 32 of 41 methods.*
  • TooManyRequestsErrorResponseContent: The service rejected the request because rate limits were exceeded. Status code 429. Applicable to 28 of 41 methods.*
  • ConflictErrorResponseContent: The request conflicts with the current state of the resource. Status code 409. Applicable to 16 of 41 methods.*
  • IngestionHookStoppedErrorResponseContent: The ingestion hook stopped this operation without applying unapproved content. Status code 422. Applicable to 7 of 41 methods.*
  • IngestionHookRetryErrorResponseContent: A saved ingestion hook decision is waiting for its next bounded attempt. Status code 503. Applicable to 7 of 41 methods.*
  • PreconditionFailedErrorResponseContent: The write named an expected revision (expectedRevision or If-Match) that is no longer current. Read the resource again and retry. Status code 412. Applicable to 3 of 41 methods.*
  • SummaryViewQuotaErrorResponseContent: A Summary View operation exceeded an enabled store quota. Exact limits depend on the deployment. Status code 429. Applicable to 3 of 41 methods.*
  • ServiceUnavailableErrorResponseContent: ServiceUnavailableError 503 response. Status code 503. Applicable to 3 of 41 methods.*
  • ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. See error.rawValue for the raw value and error.pretty() for a nicely formatted multi-line string.

* Check the method documentation to see if the error is applicable.

Custom HTTP Client

The TypeScript SDK makes API calls using an HTTPClient that wraps the native Fetch API. This client is a thin wrapper around fetch and provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle errors and response.

The HTTPClient constructor takes an optional fetcher argument that can be used to integrate a third-party HTTP client or when writing tests to mock out the HTTP client and feed in fixtures.

The following example shows how to:

  • route requests through a proxy server using undici's ProxyAgent
  • use the "beforeRequest" hook to add a custom header and a timeout to requests
  • use the "requestError" hook to log errors
import { AgentMemory } from "@redis-iris/agent-memory";
import { ProxyAgent } from "undici";
import { HTTPClient } from "@redis-iris/agent-memory/lib/http";

const dispatcher = new ProxyAgent("http://proxy.example.com:8080");

const httpClient = new HTTPClient({
  // 'fetcher' takes a function that has the same signature as native 'fetch'.
  fetcher: (input, init) =>
    // 'dispatcher' is specific to undici and not part of the standard Fetch API.
    fetch(input, { ...init, dispatcher } as RequestInit),
});

httpClient.addHook("beforeRequest", (request) => {
  const nextRequest = new Request(request, {
    signal: request.signal || AbortSignal.timeout(5000)
  });

  nextRequest.headers.set("x-custom-header", "custom value");

  return nextRequest;
});

httpClient.addHook("requestError", (error, request) => {
  console.group("Request Error");
  console.log("Reason:", `${error}`);
  console.log("Endpoint:", `${request.method} ${request.url}`);
  console.groupEnd();
});

const sdk = new AgentMemory({ httpClient: httpClient });

Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.

You can pass a logger that matches console's interface as an SDK option.

[!WARNING] Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.

import { AgentMemory } from "@redis-iris/agent-memory";

const sdk = new AgentMemory({ debugLogger: console });

You can also enable a default debug logger by setting an environment variable AGENT_MEMORY_DEBUG to true.

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy