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

go-codex-notify

v1.3.4

Published

Multi-channel notifier for OpenAI Codex notify hooks

Readme

go-codex-notify

npm version npm downloads GitHub release release downloads CI node license

这是一个给 Codex 发完成通知的小工具。

你把它接到 Codex 的完成钩子上后,任务停下来的时候,它会自动把结果发到你常用的地方,比如 Telegram、OpeniLink Hub,或者你自己的 Hermes Webhook。

它是通知型 hook:成功时不会向 stdout 输出内容,避免 Codex 把通知工具的输出误当成下一轮上下文。

你会收到什么

默认会发一段中文通知,大致长这样:

父亲,Codex 任务已完成。

客户端:codex-tui
会话:...
轮次:...
项目目录:...
模型:...
权限模式:...
转写记录:...
目标:...
工具:...
工具调用:...
任务:...
状态:...
消息:...
Codex 回应:...

如果这次任务里设置了 goal,通知里还会自动带上目标摘要。

怎么用

1)安装

推荐直接运行:

npx -y go-codex-notify

也可以全局安装:

npm install -g go-codex-notify

安装完成后,postinstall 会自动把当前平台的原生二进制放到稳定路径:

  • macOS / Linux:~/.codex/bin/go-codex-notify
  • Windows:C:\Users\你的用户名\.codex\bin\go-codex-notify.exe

后面的 Codex 配置统一建议指向这个固定路径,不再直接依赖 npx*.cmd

2)配置通知渠道

任选一种或几种都行。配置了哪个,就往哪个发。

Telegram

export TELEGRAM_BOT_TOKEN="123456789:xxxxxx"
export TELEGRAM_CHAT_ID="123456789"

OpeniLink Hub

export OPENILINK_HUB_URL="https://hub.011f.com/bot/v1/message/send"
export OPENILINK_HUB_TOKEN="app_xxxxxxxxxxxxxxxxxxxx"

Hermes Webhook

export HERMES_WEBHOOK_URL="https://your-server:8644/webhooks/codex-notify"
export HERMES_WEBHOOK_SECRET="your-hermes-webhook-secret"

HERMES_WEBHOOK_SECRET 可选;设置后会给请求体签名。

3)接到 Codex 上

Codex 配置写在:

~/.codex/config.toml

新版 Codex hooks:macOS / Linux

优先使用安装脚本写入的稳定路径:

[features]
codex_hooks = true

[[hooks.Stop]]

[[hooks.Stop.hooks]]
type = "command"
command = "/Users/你的用户名/.codex/bin/go-codex-notify"
timeout = 30
statusMessage = "Sending notification"

如果你更喜欢自己管理路径,也可以改成你机器上的实际绝对路径。

新版 Codex hooks:Windows

Windows 上同样建议直接写稳定路径,不要把 npx.cmd.cmd 或整条命令字符串塞进 commandhooks.Stop.hooks 在 Windows 下更稳的方式就是直接指向原生 .exe

[features]
codex_hooks = true

[[hooks.Stop]]

[[hooks.Stop.hooks]]
type = "command"
command = 'C:\Users\你的用户名\.codex\bin\go-codex-notify.exe'
timeout = 30
statusMessage = "Sending notification"

注意不要写成 [[hooks]],否则 Codex 会报:invalid type: sequence, expected struct HooksToml in hookshooks 本身是普通表,只有 hooks.Stophooks.Stop.hooks 是数组表。

新版 Stop hook 会通过 stdin 传入 JSON,例如 session_idturn_idtranscript_pathcwdmodelpermission_modelast_assistant_messagego-codex-notify 会原样读取这些字段;成功时 stdout 为空,只在失败时向 stderr 写错误并返回非零退出码。

如果你想手动刷新这个稳定路径,可以重新执行一次:

node scripts/install.js

旧版 Codex notify

如果你的 Codex 还不支持 hooks,才用旧的 notify 写法。这里也建议直接指向同一个稳定路径:

notify = ["/Users/你的用户名/.codex/bin/go-codex-notify"]

Windows 旧版 notify 可以写成:

notify = [
    'C:\Users\你的用户名\.codex\bin\go-codex-notify.exe',
]

配置文件

如果你不想全放环境变量,也可以用配置文件。

默认路径:

~/.codex/notify-telegram.json

你也可以自己指定:

export CODEX_NOTIFY_CONFIG="/path/to/notify-telegram.json"

示例:

{
  "bot_token": "123456789:xxxxxx",
  "chat_id": "123456789",
  "openilink_hub_url": "https://hub.011f.com/bot/v1/message/send",
  "openilink_hub_token": "app_xxxxxxxxxxxxxxxxxxxx",
  "hermes_webhook_url": "https://your-server:8644/webhooks/codex-notify",
  "hermes_webhook_secret": "your-hermes-webhook-secret"
}

给 Hermes 的内容

如果你接的是 Hermes Webhook,请求体里会带上中文正文和一些结构化信息。你可以直接把 {message} 原样转发出去,也可以自己再做二次加工。

示例:

{
  "event_type": "codex_notify",
  "message": "渲染后的中文通知正文",
  "client": "codex-tui",
  "hook_event_name": "Stop",
  "session_id": "...",
  "turn_id": "...",
  "cwd": "...",
  "transcript_path": "...",
  "model": "...",
  "permission_mode": "...",
  "last_assistant_message": "...",
  "tool_name": "...",
  "tool_use_id": "...",
  "goal": {
    "objective": "...",
    "status": "active",
    "token_budget": "200000",
    "tokens_used": "12345",
    "time_used": "90",
    "created_at": "1776272400",
    "updated_at": "1776272490",
    "thread_id": "...",
    "turn_id": "..."
  }
}

没有对应上下文时,omitempty 字段不会出现在请求体里。

兼容性说明

  • 新版 Codex:优先使用 [features] codex_hooks = true[[hooks.Stop]] / [[hooks.Stop.hooks]]
  • 旧版 Codex:继续使用 notify = [...]
  • 多个通知通道同时配置时,会一起发送