New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@tencentdb-agent-memory/memory-sdk-ts-v2

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tencentdb-agent-memory/memory-sdk-ts-v2

TypeScript SDK for TencentDB Agent Memory v2/v3 API (incl. /v3/skill/*)

latest
npmnpm
Version
1.0.0-beta.1
Version published
Weekly downloads
789
45.84%
Maintainers
5
Weekly downloads
 
Created
Source

@tencentdb-agent-memory/memory-sdk-ts

TypeScript SDK for TencentDB Agent Memory, supporting both the v2 compatibility API and the v3 strict-isolation data-plane API.

  • Default MemoryClient remains v2-compatible for existing code.
  • New code should prefer @tencentdb-agent-memory/memory-sdk-ts/v3.
  • The root entry also exports V3MemoryClient for environments that cannot use subpath imports.

Install

npm install @tencentdb-agent-memory/memory-sdk-ts

Quick Start

v3 differences:

  • paths use /v3/*;
  • constructor requires teamId, agentId, and userId;
  • sessionId is optional:
    • present: L0/L1 are scoped to one session;
    • omitted or cleared with withIsolation({ sessionId: null }): L0/L1 aggregate across sessions for the same team+agent+user;
    • L2/L3 are team+agent profile data and do not consume sessionId;
  • Offload and COS artifact reading remain on the v2 client.
import { MemoryClient } from "@tencentdb-agent-memory/memory-sdk-ts/v3";

const client = new MemoryClient({
  endpoint: "http://127.0.0.1:8420",
  apiKey: "your-gateway-api-key",
  serviceId: "your-memory-instance-id",
  teamId: "team-xxx",
  agentId: "agt-xxx",
  userId: "usr-xxx",
  sessionId: "sess-1",
});

await client.addConversation({
  messages: [
    { role: "user", content: "Hello" },
    { role: "assistant", content: "Hi!" },
  ],
});

const l0 = await client.queryConversation({ limit: 20, offset: 0 });
const allSessions = await client.withIsolation({ sessionId: null }).queryConversation({ limit: 20 });
const l1 = await client.searchAtomic({ query: "user preferences", limit: 5 });
const scene = await client.readScenario({ path: "work.md" });
const core = await client.readCore();

Root import variant:

import { V3MemoryClient } from "@tencentdb-agent-memory/memory-sdk-ts";

v2 compatibility

import { MemoryClient } from "@tencentdb-agent-memory/memory-sdk-ts";

const client = new MemoryClient({
  endpoint: "http://127.0.0.1:8420",
  apiKey: "your-gateway-api-key",
  serviceId: "your-memory-instance-id",
});

await client.addConversation({
  session_id: "sess-1",
  messages: [{ role: "user", content: "Hello" }],
});

API Methods

v3 data plane

LayerMethodEndpoint
L0addConversation()POST /v3/conversation/add
L0queryConversation()POST /v3/conversation/query
L0searchConversation()POST /v3/conversation/search
L0deleteConversation()POST /v3/conversation/delete
L0countConversation()POST /v3/conversation/count
L1updateAtomic()POST /v3/atomic/update
L1queryAtomic()POST /v3/atomic/query
L1searchAtomic()POST /v3/atomic/search
L1deleteAtomic()POST /v3/atomic/delete
L1countAtomic()POST /v3/atomic/count
L2listScenarios()POST /v3/scenario/ls
L2readScenario()POST /v3/scenario/read
L2writeScenario()POST /v3/scenario/write
L2rmScenario()POST /v3/scenario/rm
L2countScenario()POST /v3/scenario/count
L3readCore()POST /v3/core/read
L3writeCore()POST /v3/core/write
L3countCore()POST /v3/core/count

v2 compatibility data plane

The root MemoryClient still maps to /v2/* for L0-L3 and Offload, preserving existing integrations.

MetadataClient (v3 management plane)

MetadataClient wraps the gateway's v3 metadata management endpoints (/v3/meta/* — 54 routes aligned with Panel META_ACTIONS, including user-key/*) plus /v3/knowledge/* Knowledge CRUD (5 routes). Auth: Bearer + x-tdai-service-id, optional x-tdai-user-key.

import { MetadataClient } from "@tencentdb-agent-memory/memory-sdk-ts";

const meta = new MetadataClient({
  endpoint: "http://127.0.0.1:8420",
  apiKey: "verify-token",        // gateway Bearer (KERNEL_AUTH_TOKEN)
  serviceId: "knowledge-debug",  // x-tdai-service-id
  // userKey: "...",             // optional; needed by system_admin endpoints (user/create, user/delete)
});

Knowledge management (/v3/knowledge/*)

Manage Knowledge entity metadata (types: wiki | code-graph). These are management-plane CRUD — metadata only. Actually searching wiki content, reading pages, or syncing repos is the Knowledge Service data-plane's job, not this client.

MethodEndpointNotes
createKnowledge()POST /v3/knowledge/createupsert metadata (idempotent; re-post overwrites)
getKnowledge(id, teamId?)POST /v3/knowledge/getget one by id
updateKnowledge()POST /v3/knowledge/updatepartial update (name/summary/service_url/repo_url/branch)
deleteKnowledge(ids, teamId?)POST /v3/knowledge/deletebatch delete (≤100)
listKnowledge()POST /v3/knowledge/listlist by team_id, optional type filter / batch id lookup
// Register a wiki knowledge source
const k = await meta.createKnowledge({
  knowledge_id: "wiki-docs",
  type: "wiki",
  service_url: "http://127.0.0.1:8421/v3",  // Knowledge Service data-plane URL
  name: "Team Docs Wiki",
  summary: "Internal tech docs",
  team_id: "team-1",
  user_id: "usr-1",
});
console.log(k.knowledge_id, k.type, k.created_at);

// List all code-graphs under a team
const list = await meta.listKnowledge({ team_id: "team-1", type: "code-graph" });
console.log(list.items, list.total);

// Rename / change service_url
await meta.updateKnowledge({ knowledge_id: "wiki-docs", name: "Renamed Wiki" });

// Batch delete
await meta.deleteKnowledge(["wiki-docs", "cg-repo-1"], "team-1");

Return types: KnowledgeEntity / KnowledgeListResult { items, total } / BatchDeleteResult { deleted_ids, failed }.

Error Handling

All non-zero code responses throw TDAMError:

import { TDAMError } from "@tencentdb-agent-memory/memory-sdk-ts";

try {
  await client.readCore();
} catch (e) {
  if (e instanceof TDAMError) {
    console.error(`code=${e.code} message=${e.message} request_id=${e.requestId}`);
  }
}

Build & Pack

npm run build
npm test
npm pack

License

MIT

FAQs

Package last updated on 21 Jul 2026

Related posts