Commit Graph

151 Commits

Author SHA1 Message Date
Ayaan Zaidi
9d52dcf1f4 fix: stabilize launchd CA env tests (#27915) (thanks @Lukavyi) 2026-02-27 08:11:16 +05:30
clawdbot
6b59c87570 fix: add missing closing brace in proxy env test 2026-02-27 08:11:16 +05:30
Clawborn
d33f24c4e9 Fix NODE_EXTRA_CA_CERTS missing from LaunchAgent environment on macOS
launchd services do not inherit the shell environment, so Node's undici/fetch
cannot locate the macOS system CA bundle (/etc/ssl/cert.pem). This causes TLS
verification failures for all HTTPS requests (e.g. Telegram, webhooks) when the
gateway runs as a LaunchAgent, while the same gateway works fine in a terminal.

Add NODE_EXTRA_CA_CERTS defaulting to /etc/ssl/cert.pem on macOS in both
buildServiceEnvironment and buildNodeServiceEnvironment. User-supplied
NODE_EXTRA_CA_CERTS is always respected and takes precedence.

Fixes #22856

Co-authored-by: Clawborn <tianrun.yang103@gmail.com>
2026-02-27 08:11:16 +05:30
Peter Steinberger
5dd264d2fb refactor(daemon): unify runtime binary detection 2026-02-26 22:39:05 +01:00
Peter Steinberger
262bca9bdd fix: restore dm command and self-chat auth behavior 2026-02-26 18:49:16 +01:00
Kevin Shenghui
16ccd5a874 fix(gateway): add ThrottleInterval to launchd plist to prevent restart loop 2026-02-26 15:31:04 +00:00
Gustavo Madeira Santana
39d725f4d3 Daemon tests: guard undefined runtime status 2026-02-26 03:24:48 -05:00
Gustavo Madeira Santana
4ebefe647a fix(daemon): keep launchd KeepAlive while preserving restart hardening 2026-02-26 02:52:00 -05:00
Frank Yang
b975711429 fix(daemon): stabilize LaunchAgent restart and proxy env passthrough (#27276)
Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: b08797a99561f3d849443f77fda4fe086c508b49
Co-authored-by: frankekn <4488090+frankekn@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
2026-02-26 02:40:48 -05:00
青雲
dc8423f2c0 fix: back up existing systemd unit before overwriting on update (#24350) (#24937)
When `openclaw update` regenerates the systemd service file, any user
customizations to ExecStart (e.g. proxychains4 wrapper) are silently
lost. Now the existing unit file is copied to `.bak` before writing
the new one, so users can restore their customizations.

The backup path is printed in the install output so users are aware.

Co-authored-by: echoVic <AkiraVic@outlook.com>
2026-02-24 03:22:55 +00:00
Phineas1500
8a8faf066e doctor: clean up legacy Linux gateway services (#21188)
* Doctor: clean up legacy Linux gateway services

* doctor: refactor legacy service cleanup flow

* doctor: fix legacy systemd cleanup map key typing

* doctor: add changelog entry for legacy Linux service cleanup

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-02-22 19:18:59 -05:00
Peter Steinberger
06b0a60bef refactor(daemon): share runtime and service probe helpers 2026-02-22 21:19:09 +00:00
Peter Steinberger
34ea33f057 refactor: dedupe core config and runtime helpers 2026-02-22 17:11:54 +00:00
Peter Steinberger
50c0616278 test(daemon): use lightweight clears in systemd mocks 2026-02-22 08:01:16 +00:00
Peter Steinberger
b109fa53ea refactor(core): dedupe gateway runtime and config tests 2026-02-22 07:44:57 +00:00
Peter Steinberger
c394c5fa99 test(daemon): dedupe schtasks install fixture and cover empty env omission 2026-02-21 21:40:39 +00:00
Shadow
61f646c41f Daemon: harden systemd unit env rendering 2026-02-20 12:51:14 -06:00
Peter Steinberger
035832b4c5 refactor(daemon): extract windows cmd argv helpers 2026-02-19 16:22:28 +01:00
Peter Steinberger
280c6b117b fix(daemon): harden windows schtasks script quoting 2026-02-19 16:16:51 +01:00
Peter Steinberger
bc6f983f85 fix(ci): resolve format drift and acp mock typing 2026-02-19 15:11:27 +00:00
Peter Steinberger
e1059e95aa refactor(daemon): extract schtasks cmd-set codec helpers 2026-02-19 16:07:15 +01:00
Peter Steinberger
dafe52e8cf fix(daemon): escape schtasks environment assignments 2026-02-19 15:52:13 +01:00
mahanandhi
fb35635c10 Security: use execFileSync instead of execSync with shell strings (#20655)
Replace execSync (which spawns a shell) with execFileSync (which
invokes the binary directly with an argv array). This eliminates
command injection risk from interpolated arguments.

Co-authored-by: sirishacyd <sirishacyd@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 03:19:09 -08:00
Peter Steinberger
da341bfbe1 test(daemon): dedupe service path cases and bootstrap failures 2026-02-19 10:17:48 +00:00
Peter Steinberger
771af40913 chore(ci): fix main check blockers and stabilize tests 2026-02-19 10:15:25 +00:00
Peter Steinberger
1b46f7d0ba refactor(daemon): simplify gateway service backend delegates 2026-02-19 10:04:19 +00:00
Peter Steinberger
70900feaa7 refactor(daemon): share service arg types across backends 2026-02-19 10:04:19 +00:00
Vincent Koc
be7462af1e Gateway: clarify launchctl domain bootstrap error (#13795) 2026-02-19 02:03:23 -08:00
Clawborn
2bb8ead187 Fix LaunchAgent missing TMPDIR causing SQLITE_CANTOPEN on macOS (#20512)
Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 25ba59765d04d4113cf46ba930de26d4369b89c2
Co-authored-by: Clawborn <261310391+Clawborn@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
2026-02-18 21:42:35 -05:00
Peter Steinberger
2709c0ba51 refactor(daemon): dedupe install output line writing 2026-02-18 23:58:05 +00:00
Peter Steinberger
f830261c40 test(daemon): dedupe schtasks fixtures and cover state-dir override 2026-02-18 18:54:51 +00:00
Peter Steinberger
9fd810e3a6 refactor(daemon): share systemd service action flow 2026-02-18 18:25:25 +00:00
Peter Steinberger
b8b43175c5 style: align formatting with oxfmt 0.33 2026-02-18 01:34:35 +00:00
Peter Steinberger
31f9be126c style: run oxfmt and fix gate failures 2026-02-18 01:29:02 +00:00
Sebastian
11fcbadec8 fix(daemon): guard preferred node selection 2026-02-17 10:01:54 -05:00
cpojer
d0cb8c19b2 chore: wtf. 2026-02-17 13:36:48 +09:00
Sebastian
ed11e93cf2 chore(format) 2026-02-16 23:20:16 -05:00
cpojer
90ef2d6bdf chore: Update formatting. 2026-02-17 09:18:40 +09:00
Peter Steinberger
c55e017c19 refactor(daemon): dedupe user bin path assembly helpers 2026-02-16 23:48:43 +00:00
Peter Steinberger
eaa2f7a7bf fix(ci): restore main lint/typecheck after direct merges 2026-02-16 23:26:11 +00:00
Operative-001
d6e85aa6ba fix(daemon): warn on token drift during restart (#18018)
When the gateway token in config differs from the token embedded in the
service plist/unit file, restart will not apply the new token. This can
cause silent auth failures after OAuth token switches.

Changes:
- Add checkTokenDrift() to service-audit.ts
- Call it in runServiceRestart() before restarting
- Warn user with suggestion to run 'openclaw gateway install --force'

Closes #18018
2026-02-16 23:59:50 +01:00
Yao
3ec936d1b4 fix(daemon): prefer current node and add macOS version manager paths to service PATH 2026-02-16 23:53:41 +01:00
Yao
1a8548df18 fix(daemon): prefer current node (process.execPath) and add macOS version manager paths to service PATH
On macOS, `openclaw gateway install` hardcodes the system node
(/opt/homebrew/bin/node) in the launchd plist, ignoring the node from
version managers (fnm/nvm/volta). This causes the Gateway to run a
different node version than the user's shell environment.

Two fixes:

1. `resolvePreferredNodePath` now checks `process.execPath` first.
   If the currently running node is a supported version, use it directly.
   This respects the user's active version manager selection.

2. `buildMinimalServicePath` now includes version manager bin directories
   on macOS (fnm, nvm, volta, pnpm, bun), matching the existing Linux
   behavior.

Fixes #18090
Related: #6061, #6064
2026-02-16 23:53:41 +01:00
norunners
d799a3994f fix(doctor): reconcile gateway service token drift after re-pair
`openclaw doctor` audited gateway service runtime/path settings but did not
check whether the daemon's `OPENCLAW_GATEWAY_TOKEN` matched
`gateway.auth.token` in `openclaw.json`.

After re-pairing or token rotation, the config token and service env token can
drift. The daemon may keep running with a stale service token, leading to
unauthorized handshake failures for cron/tool clients.

Add a gateway service audit check for token drift and pass
`cfg.gateway.auth.token` into service audits so doctor treats config as the
source of truth when deciding whether to reinstall the service.

Key design decisions:
- Use `gateway.auth.token` from `openclaw.json` as the authority for service
  token drift detection
- Only flag mismatch when an authoritative config token exists
- Keep fix in existing doctor service-repair flow (no separate migration step)
- Add focused tests for both audit mismatch behavior and doctor wiring

Fixes #18175
2026-02-16 23:51:16 +01:00
Peter Steinberger
f717a13039 refactor(agent): dedupe harness and command workflows 2026-02-16 14:59:30 +00:00
Peter Steinberger
a69c06e3cc test: remove duplicate daemon profile trim wrappers 2026-02-16 06:53:13 +00:00
Peter Steinberger
1ec0f3b81d test: drop redundant daemon profile normalization wrappers 2026-02-16 06:36:15 +00:00
Peter Steinberger
6c3e7896c5 test: remove duplicate lowercase default profile daemon path cases 2026-02-16 06:34:05 +00:00
Peter Steinberger
2a5fa426f2 test: remove redundant schtasks command parsing cases 2026-02-16 06:32:59 +00:00
Peter Steinberger
29203884c2 test: consolidate gateway profile normalization coverage 2026-02-16 06:31:36 +00:00