Skip to content

fix: add better-sqlite3 and koffi to onlyBuiltDependencies allowlist - #7

Draft
Secret297-CODER-SOURCE with Copilot wants to merge 3 commits into
mainfrom
copilot/add-better-sqlite3-to-allowlist
Draft

fix: add better-sqlite3 and koffi to onlyBuiltDependencies allowlist#7
Secret297-CODER-SOURCE with Copilot wants to merge 3 commits into
mainfrom
copilot/add-better-sqlite3-to-allowlist

Conversation

Copilot AI commented Mar 10, 2026

Copy link
Copy Markdown

better-sqlite3 was absent from pnpm-workspace.yaml's onlyBuiltDependencies allowlist, causing pnpm to silently skip its native binding compilation. Result: telegram-manager failed to load at gateway start with Cannot find module 'better-sqlite3' / missing better_sqlite3.node.

Summary

  • Problem: better-sqlite3 not in onlyBuiltDependencies → pnpm skips its install script → native .node binding never built → telegram-manager plugin crashes on load
  • Why it matters: telegram-manager is completely non-functional without the binding; error is silent and confusing (no build-time warning, only a runtime crash)
  • What changed: Added better-sqlite3 and koffi to onlyBuiltDependencies in pnpm-workspace.yaml. koffi already ran its install script successfully per logs but was undeclared — added for correctness.
  • What did NOT change: No code, no deps, no lockfile — config-only, one file

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Related #

User-visible / Behavior Changes

telegram-manager plugin loads successfully after pnpm install. Previously crashed gateway startup with a native binding error.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? NoonlyBuiltDependencies is an allowlist; adding entries permits already-present packages to run their own declared install scripts, not arbitrary code
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: macOS (darwin/arm64)
  • Runtime/container: Node v22
  • Model/provider: N/A
  • Integration/channel (if any): telegram-manager extension
  • Relevant config (redacted): N/A

Steps

  1. pnpm install
  2. openclaw gateway run

Expected

  • telegram-manager plugin loads; no binding errors in gateway log

Actual (before fix)

  • [plugins] telegram-manager failed to load: Error: Cannot find module 'better-sqlite3'

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets — error reproduced in problem statement logs; fix resolves the missing install script execution
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: pnpm-workspace.yaml diff is minimal and correct; koffi confirmed already running install script in logs prior to this fix
  • Edge cases checked: alphabetical ordering maintained in list; no duplicate entries introduced
  • What you did not verify: full pnpm install + gateway boot cycle in this environment (no native build toolchain available in sandbox)

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? Yes — users must run pnpm install once after pulling to trigger the better-sqlite3 native build

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert pnpm-workspace.yaml; run pnpm install
  • Files/config to restore: pnpm-workspace.yaml
  • Known bad symptoms: if better-sqlite3 build fails on a platform, gateway will log a native binding error on telegram-manager load (same as before — no regression, just no improvement on that platform)

Risks and Mitigations

  • Risk: better-sqlite3 native build fails on a platform (e.g. missing Python/node-gyp)
    • Mitigation: Failure is isolated to telegram-manager plugin load; gateway continues running. No worse than the current state.
Original prompt

Problem

The telegram-manager extension fails to load with:

Error: Cannot find module 'better-sqlite3'
Require stack:
- extensions/telegram-manager/src/storage/TelegramStorage.ts

This happens because pnpm-workspace.yaml has an onlyBuiltDependencies allowlist that controls which packages are allowed to run install/build scripts. better-sqlite3 is missing from this list, so pnpm never compiles its native .node binding for the current platform (darwin/arm64, Node v22).

Root Cause

In pnpm-workspace.yaml:

onlyBuiltDependencies:
  - "@lydell/node-pty"
  - "@matrix-org/matrix-sdk-crypto-nodejs"
  - "@napi-rs/canvas"
  - "@whiskeysockets/baileys"
  - authenticate-pam
  - esbuild
  - node-llama-cpp
  - protobufjs
  - sharp

better-sqlite3 is not in this list. pnpm's onlyBuiltDependencies is a security allowlist — if a package is not on it, its install/postinstall build scripts are silently skipped. Without those scripts, the native .node binding (better_sqlite3.node) is never compiled, so Node.js cannot require('better-sqlite3').

Fix

Add better-sqlite3 to the onlyBuiltDependencies list in pnpm-workspace.yaml:

packages:
  - .
  - ui
  - packages/*
  - extensions/*

onlyBuiltDependencies:
  - "@lydell/node-pty"
  - "@matrix-org/matrix-sdk-crypto-nodejs"
  - "@napi-rs/canvas"
  - "@whiskeysockets/baileys"
  - authenticate-pam
  - better-sqlite3
  - esbuild
  - koffi
  - node-llama-cpp
  - protobufjs
  - sharp

Note: koffi is also added since it already runs its install script successfully (visible in the logs) — it should be in the list too for consistency and correctness.

After this change, the user must run:

pnpm install

to trigger the native build for better-sqlite3.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: zsh: command not found: #
Now using node v22.22.1 (npm v10.9.4)
zsh: command not found: #
worker@MacBook-Air-Worker openclaw % # Ensure Node 22
nvm use 22

Remove old modules and lockfile

rm -rf node_modules pnpm-lock.yaml

Reinstall everything

pnpm install -w

Rebuild native modules

pnpm rebuild

Build the Control UI

pnpm ui:build
zsh: command not found: #
Now using node v22.22.1 (npm v10.9.4)
zsh: command not found: #
zsh: command not found: #
 WARN  15 deprecated subdependencies found: are-we-there-yet@2.0.0, are-we-there-yet@3.0.1, form-data@2.5.4, gauge@3.0.2, gauge@4.0.4, glob@10.5.0, glob@7.2.3, has-own@1.0.1, inflight@1.0.6, node-domexception@1.0.0, npmlog@5.0.1, npmlog@6.0.2, prebuild-install@7.1.3, rimraf@3.0.2, yaeti@0.0.6
Progress: resolved 1264, reused 1, downloaded 0, added 0, done
 WARN  Issues with peer dependencies found
.
└─┬ oxlint 1.52.0
└── ✕ unmet peer oxlint-tsgolint@>=0.15.0: found 0.14.2

extensions/matrix
└─┬ @vector-im/matrix-bot-sdk 0.8.0-element.3
└─┬ @cypress/request-promise 5.0.0
└─┬ request-promise-core 1.1.3
└── ✕ unmet peer request@^2.34: found 3.0.10

extensions/telegram-manager
└─┬ openclaw 2026.3.8
├── ✕ unmet peer node-llama-cpp@3.16.2: found 3.15.1
└─┬ @buape/carbon 0.0.0-beta-20260216184201
└─┬ @discordjs/voice 0.19.0
└─┬ prism-media 1.3.5
└── ✕ unmet peer opusscript@^0.0.8: found 0.1.1 in openclaw
Packages: +825
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
. prepare$ command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1 && git config core.hooksPath git-hooks || exit 0
└─ Done in 58ms
Done in 16.1s using pnpm v10.23.0
zsh: command not found: #
node_modules/.pnpm/koffi@2.15.1/node_modules/koffi: Running install script, done in 338ms
node_modules/.pnpm/esbuild@0.27.3/node_modules/esbuild: Running postinstall script, done in 337ms
node_modules/.pnpm/protobufjs@7.5.4/node_modules/protobufjs: Running postinstall script, done in 32ms
node_modules/.pnpm/protobufjs@6.8.8/node_modules/protobufjs: Running postinstall script, done in 30ms
node_modules/.pnpm/sharp@0.34.5/node_modules/sharp: Running install script, done in 1.1s
node_modules/.pnpm/@WhiskeySockets+baileys@7.0.0-rc.9_bufferutil@4.1.0_sharp@0.34.5_utf-8-validate@5.0.10/node_modules/@whiskeysockets/baileys: Running preinstall script, done in 33ms
node_modules/.pnpm/node-llama-cpp@3.15.1_typescript@5.9.3/node_modules/node-llama-cpp: Running postinstall script, done in 1.8s
. prepare$ command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1 && git config core.hooksPath git-hooks || exit 0
└─ Done in 55ms
zsh: command not found: #

openclaw@2026.2.23 ui:build /Users/worker/Documents/GitHub/openclaw
node scripts/ui.js build

Scope: all 36 workspace projects
✔ The modules directories will be removed and reinstalled from scratch. Proceed? (Y/n) · true
Recreating /Users/worker/Documents/GitHub/openclaw/ui/node_modules
.. ...

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…rkspace.yaml

Co-authored-by: Secret297-CODER-SOURCE <73541046+Secret297-CODER-SOURCE@users.noreply.github.com>
Copilot AI changed the title [WIP] Add better-sqlite3 to pnpm allowlist for native builds fix: add better-sqlite3 and koffi to onlyBuiltDependencies allowlist Mar 10, 2026
Adds the native better-sqlite3 package to package.json dependencies. Run your package manager (npm/yarn) to install the new dependency after pulling this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants