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

memory-gateway-sync

v0.13.0

Published

Memory 双写插件:fs.watch 感知变化后同步到外部 Gateway

Readme

OpenClaw 插件侧方案

插件信息

| 项目 | 值 | |------|----| | 插件 ID | memory-gateway-sync | | kind | generic(不替换 memory slot) | | 安装路径 | /home/node/.openclaw/extensions/memory-gateway-sync/ | | 作用 | 监听 MEMORY.md / memory/*.md 变化,POST 到 Gateway |

目录结构(部署到容器内)

memory-gateway-sync/
├── openclaw.plugin.json
├── package.json
└── src/
    └── index.ts

openclaw.plugin.json

{
  "id": "memory-gateway-sync",
  "name": "Memory Gateway Sync",
  "description": "fs.watch 监听 MEMORY 文件变化,双写到外部 Gateway",
  "configSchema": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
      "gatewayUrl": {
        "type": "string",
        "description": "Gateway POST 地址"
      },
      "gatewayToken": {
        "type": "string",
        "description": "Bearer Token"
      },
      "debounceMs": {
        "type": "number",
        "default": 1500,
        "description": "防抖延迟毫秒数"
      },
      "agentId": {
        "type": "string",
        "description": "当前 agent 标识,写入 Gateway 时携带"
      }
    }
  }
}

package.json

{
  "name": "@openclaw/memory-gateway-sync",
  "version": "0.1.0",
  "type": "module",
  "openclaw": {
    "extensions": ["./src/index.ts"]
  }
}

openclaw.json 配置(在容器内 /home/node/.openclaw/openclaw.json 中添加)

"plugins": {
  "entries": {
    "memory-gateway-sync": {
      "enabled": true,
      "config": {
        "gatewayUrl": "http://172.22.39.89:8765/api/memory/ingest",
        "gatewayToken": "your-secret-token",
        "debounceMs": 1500,
        "agentId": "main"
      }
    }
  }
}

核心逻辑说明(src/index.ts)

启动时

  1. 从插件配置读取 gatewayUrlgatewayTokendebounceMs
  2. 计算 workspace 路径:~/.openclaw/workspace/
  3. 确保 MEMORY.mdmemory/ 目录存在
  4. 分别挂载 fs.watch

文件变化时

  1. 记录文件路径,启动防抖计时(同一文件 debounceMs 内只处理一次)
  2. 计时结束后:读取文件完整内容
  3. 构造 payload:{ path, content, agentId, syncedAt }
  4. fetch POST 到 Gateway
  5. 成功:打 info 日志;失败:打 warn 日志,不抛异常

不处理的情况

  • .md 文件的变化
  • memory/ 二级子目录(暂不递归,可后续扩展)
  • 文件删除事件(只关心写入)

关键约束

  • Gateway 失败不能影响 OpenClaw 正常运行(所有 Gateway 调用都 try/catch)
  • 不替换 memory-core,不干预读取链路
  • 只监听两个位置:MEMORY.mdmemory/,不监听其他文件