@dbx-tools/appkit-memory

中文文档
0.9.206发布于 2026/11/11Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 5532

AppKit durable memory tools with Databricks managed memory and lazy Graphiti fallback

原始使用文档
文档目录5 节
  1. Register the plugin
  2. Add the tools to a Mastra agent
  3. Configure the backends
  4. Run Graphiti directly
  5. Understand memory limits

@dbx-tools/appkit-memory

Add durable, actor-scoped memory tools to an AppKit application. The plugin checks Databricks Agent Memory first and starts its Graphiti sidecar only when the current actor cannot access the configured managed-memory store.

Register the plugin

import { createApp, server } from "@databricks/appkit";
import { memory } from "@dbx-tools/appkit-memory";

await createApp({
  plugins: [
    server(),
    memory({
      databricks: { memoryStore: "support-memory" },
      graphiti: { modelClass: "chat-fast" },
    }),
  ],
});

The plugin is beta. It publishes two tools:

  • remember saves non-empty content at a stable absolute path, such as /preferences/response.md.
  • recall_memory searches memory for the current actor and returns up to 100 results.

A 403 or 404 from the Databricks store selects Graphiti. Other Databricks errors remain errors, which prevents a transient outage from splitting one actor's memory between backends.

databricks defaults to "auto". Set it to true to require managed-memory access for every caller or false to disable the managed backend. The object form accepts memoryStore and mode: "auto" | "required".

Add the tools to a Mastra agent

Request the toolkit from an agent:

import { createApp, server } from "@databricks/appkit";
import { agents, mastra } from "@dbx-tools/appkit-mastra";
import { memory } from "@dbx-tools/appkit-memory";

const support = agents.createAgent({
  name: "Support",
  instructions: "Help the user.",
  async tools(plugins) {
    return (await plugins.memory?.toolkit()) ?? {};
  },
});

await createApp({
  plugins: [server(), mastra({ agents: { support } }), memory()],
});

Mastra continues to store threads and messages in its configured PostgresStore and semantic recall in PgVector. saveTurns defaults to "auto", which attaches the memory plugin's output processor when both Mastra and Graphiti are registered. Set it to true to require attachment at startup or false to disable it. Auto mode mirrors completed turns only after another memory operation has already started Graphiti, so an ordinary chat turn does not pay the sidecar startup cost. saveTurns: true may start Graphiti solely to mirror a turn. Managed-memory session extraction is not used.

Configure the backends

memory() accepts the following backend and turn-saving settings:

OptionDefaultBehavior
databricks"auto"Uses Databricks managed memory when the actor can access the store. A 403 or 404 selects Graphiti.
databricks.memoryStoreProject-derived store nameSelects an existing memory store by ID or resource name.
databricks.mode"auto"Set to "required" to fail instead of selecting Graphiti.
graphititrueEnables the lazy Graphiti fallback. Pass a Graphiti options object to override its model, database, listener, or authentication settings.
saveTurns"auto"Attaches a Mastra output processor but starts Graphiti only when set to true; auto mode reuses an already-running fallback.

At least one backend must remain enabled. saveTurns: true requires both a registered Mastra plugin and the Graphiti backend. databricks: true requires managed-memory access for every caller.

Run Graphiti directly

The Graphiti fallback is imported and started on the first operation that needs it. Concurrent first operations share one startup. Configure PYTHON to use an installed runtime or let the package provision the matching Python package through uv.

Standalone Graphiti callers and the dbx CLI use the public subpath:

import { runtime as graphiti } from "@dbx-tools/appkit-memory/graphiti";

await graphiti.runGraphiti({ profile: "MY-PROFILE" });

runGraphiti() blocks until the process exits. Use it for a standalone Graphiti server or CLI integration. AppKit applications don't need to call it because the plugin supervises the fallback process.

Understand memory limits

  • Memory is partitioned by the trusted AppKit request identity. An actor_id is a storage key, not an authorization mechanism.
  • Graphiti starts only after an explicit memory operation cannot use Databricks managed memory, or when completed-turn saving is explicitly set to true. Registering the plugin doesn't start Python or PostgreSQL.
  • The plugin stops a Graphiti process that it started when AppKit shuts down.
  • Mastra thread storage and PgVector semantic recall remain separate from these durable memory tools.
  • Graphiti needs either a PostgreSQL or Lakebase database URL, or the optional embedded PostgreSQL runtime.

For Graphiti server, database, and queue behavior, see dbx-tools-graphiti.

版本与发布记录

@dbx-tools/appkit-memory 共发布 52 个版本,首次发布于 2026/10/15;过去 12 个月发布了 52 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.206latest2026/11/11今天
0.9.2052026/11/111 天前
0.9.2032026/11/074 天前
0.9.2022026/11/065 天前
0.9.2012026/11/056 天前
0.9.2002026/11/056 天前

关于 @dbx-tools/appkit-memory 的常见问题

@dbx-tools/appkit-memory 是什么?

AppKit durable memory tools with Databricks managed memory and lazy Graphiti fallback

如何安装 @dbx-tools/appkit-memory?

在项目目录运行 npm install @dbx-tools/appkit-memory,或使用 pnpm add / yarn add / bun add。

@dbx-tools/appkit-memory 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dbx-tools/appkit-memory 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dbx-tools/appkit-memory 可以商用吗?

@dbx-tools/appkit-memory 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dbx-tools/appkit-memory 的下载量有多少?

根据 npm 官方下载统计,@dbx-tools/appkit-memory 在 2026/10/12 – 2026/11/10 这 30 天内被下载 5,532 次,日均约 184 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dbx-tools/appkit-memory 还在维护吗?

最新版本 0.9.206 发布于 2026/11/11(今天);至今共发布 52 个版本,其中过去 12 个月发布了 52 个;首次发布于 2026/10/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。