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

@uncaged/ograph-dispatcher

v0.1.0

Published

OGraph Dispatcher — polls projections and notifies OC when idle

Readme

OGraph Dispatcher

本地常驻进程,轮询 OGraph projection 变化,并在 OpenClaw (OC) 空闲时推送任务通知。

架构:双 Loop Actor

┌─ Loop A: Projection Watcher ──────────────┐
│  轮询 OGraph projection → diff → pending  │
│  无变化: 30s    有变化: 5s                 │
└──────────────┬────────────────────────────┘
               │ pending queue (合并缓冲)
               ▼
┌─ Loop B: OC Scheduler ───────────────────┐
│  轮询 OC 忙闲状态                         │
│  pending 空: 60s (低频)                   │
│  pending 有: 5s (高频,等空闲立刻推)      │
│  空闲 + pending → 推送 → 清 pending      │
└──────────────────────────────────────────┘

Loop A 持续 diff OGraph projections,合并变化到 pending queue(Map,按 projection name 去重合并)。

Loop B 持续查 OC session-status,发现空闲 + pending 非空时推送,推送后进入冷却期。

快速开始

cd packages/dispatcher
npm install
npm run build
node dist/index.js

配置

配置文件:~/.config/ograph/dispatcher.json

{
  "ograph": {
    "endpoint": "https://ograph.shazhou.workers.dev",
    "token": "your-ograph-token",
    "projections": ["my-projection", "another-projection"]
  },
  "oc": {
    "statusEndpoint": "http://localhost:18789/plugins/session-status/status",
    "statusToken": "ograph-status-token-2026",
    "minAvailable": 2
  },
  "intervals": {
    "watcherIdle": 30000,
    "watcherActive": 5000,
    "schedulerIdle": 60000,
    "schedulerActive": 5000,
    "cooldownAfterPush": 60000
  }
}

环境变量覆盖

| 变量 | 对应配置 | |------|----------| | OGRAPH_ENDPOINT | ograph.endpoint | | OGRAPH_TOKEN | ograph.token | | OGRAPH_PROJECTIONS | ograph.projections(逗号分隔) | | OC_STATUS_ENDPOINT | oc.statusEndpoint | | OC_STATUS_TOKEN | oc.statusToken | | OC_MIN_AVAILABLE | oc.minAvailable |

推送机制

当 OC 空闲且 pending 非空时,Scheduler 通过两种方式推送(均 best-effort):

  1. Dispatch 文件:写入 /tmp/ograph-dispatch.json,可被其他工具读取
  2. openclaw message send:通过 CLI 发送通知消息(需 openclaw 在 PATH)

文件结构

packages/dispatcher/
├── src/
│   ├── index.ts          # 入口,启动两个 loop
│   ├── watcher.ts        # Loop A: Projection Watcher
│   ├── scheduler.ts      # Loop B: OC Scheduler
│   ├── ograph-client.ts  # OGraph API 客户端
│   ├── oc-client.ts      # OC session-status API 客户端
│   ├── config.ts         # 配置加载
│   └── types.ts          # 类型定义
├── build.mjs             # esbuild 打包脚本
├── package.json
├── tsconfig.json
└── README.md

依赖

  • 零外部运行时依赖
  • 仅使用 Node.js 内置模块(fs, path, os, child_process)和全局 fetch(Node ≥ 18)
  • 构建时仅依赖 esbuild + typescript