Commit Graph

70 Commits

Author SHA1 Message Date
Pavan Kumar Gondhi 17ceca86d6 Redact persisted secret-shaped payloads [AI] (#79006)
* fix: redact persisted secret-shaped payloads

* docs: add changelog entry for PR merge
2026-05-11 12:52:32 +05:30
Peter Steinberger f87cca5959 test: tighten launchd assertions 2026-05-11 05:50:22 +01:00
Bryan Pearson a2b8f2aef0 fix(launchd): set ProcessType=Interactive to prevent macOS App Nap
The gateway launchd plist does not set ProcessType, so macOS treats it as a background process eligible for App Nap. When the system is idle, App Nap can suspend the process and freeze setTimeout-based heartbeat timers.

Setting ProcessType to Interactive tells launchd the process needs timely execution.

Fixes #58061; refs #62294 and #66992.
2026-05-09 16:39:27 +05:30
Val Alexander fa79e9754e fix(gateway): harden macOS update restart lifecycle
Summary:
- Clear stale SIGUSR1 restart state before rejected or externally allowed restart handling can leave an in-flight token stuck.
- Verify the live gateway version after macOS package-update service refreshes and skip redundant restarts when the refreshed LaunchAgent already serves the expected version.
- Set generated LaunchAgents to a 10s throttle plus 20s shutdown window and widen gateway bind retries around supervisor-owned restarts.

Fixes #79577. Refs #78699 and #60885.

Verification:
- pnpm test src/cli/gateway-cli/run-loop.test.ts src/infra/infra-runtime.test.ts
- pnpm test src/cli/update-cli.test.ts src/daemon/launchd.test.ts src/gateway/server/http-listen.test.ts
- pnpm exec oxfmt --check --threads=1 src/cli/gateway-cli/run-loop.ts src/cli/gateway-cli/run-loop.test.ts
- pnpm check:changed
- Crabbox/Blacksmith wrapper smoke passed focused tests plus pnpm check:changed: https://github.com/openclaw/openclaw/actions/runs/25595985603
- PR CI was green before upstream main advanced; the latest rebased heads hit unrelated broad lint failures also reproduced on current main CI (for example https://github.com/openclaw/openclaw/actions/runs/25598671666). No failing lint diagnostics referenced this gateway/update diff.
2026-05-09 05:21:17 -05:00
Shakker e2d8b78b69 test: tighten daemon infra array assertions 2026-05-09 05:56:26 +01:00
Peter Steinberger aa34ce41a1 test: avoid single result filter assertions 2026-05-08 22:19:50 +01:00
Peter Steinberger c94641c08b test: clarify launchd command assertions 2026-05-08 09:09:16 +01:00
Peter Steinberger 1f88cb2ce5 fix(gateway): persist macOS stop disable after bootout
Summary:
- carry forward #78412's macOS LaunchAgent bootout-by-default stop behavior and repair guard
- fix the remaining `gateway stop --disable` tail when the service is already not loaded after bootout
- add lifecycle regressions, docs, and changelog

Verification:
- pnpm install
- pnpm test src/cli/daemon-cli/lifecycle-core.test.ts src/cli/daemon-cli/lifecycle.test.ts src/daemon/launchd.test.ts
- pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/cli/daemon-cli/lifecycle-core.ts src/cli/daemon-cli/lifecycle.ts src/cli/daemon-cli/lifecycle-core.test.ts src/cli/daemon-cli/lifecycle.test.ts docs/cli/gateway.md docs/gateway/index.md src/daemon/launchd.ts src/daemon/launchd.test.ts src/cli/daemon-cli/register-service-commands.ts src/cli/daemon-cli/types.ts src/daemon/service-types.ts
- git diff --check origin/main...HEAD
- pnpm build
- Parallels macOS Tahoe VM reproduce/fix proof in PR body
- PR checks green: Real behavior proof, auto-response, dispatch, label, label-issues

Co-authored-by: wdeveloper16 <25180374+wdeveloper16@users.noreply.github.com>
2026-05-08 05:35:21 +01:00
Peter Steinberger 1ace6a0d6a fix: avoid launchd kickstart after fresh bootstrap 2026-05-03 21:49:53 +01:00
Peter Steinberger b726214cf3 fix: avoid fresh launchd repair kickstart 2026-05-03 21:04:48 +01:00
Peter Steinberger a6141a5a41 fix: harden macOS gateway updates 2026-04-28 05:58:05 +01:00
Vincent Koc 60d4d5e1fa fix(daemon): reconcile macOS LaunchAgent supervision state (#72616) 2026-04-26 22:39:15 -07:00
Vincent Koc d7c173b694 fix(gateway): harden macOS launchd service startup 2026-04-26 17:18:49 -07:00
Peter Steinberger 017252e4f8 test(daemon): remove duplicate launchd read mock 2026-04-25 07:12:17 +01:00
Peter Steinberger 33d5ebbff7 test(daemon): read launchd fixture files 2026-04-25 07:11:33 +01:00
Peter Steinberger 07cf1dd65c test: remove duplicate launchd read mock 2026-04-25 07:10:32 +01:00
Peter Steinberger 85cab8b516 test: fix launchd restart mock state 2026-04-25 07:09:47 +01:00
Peter Steinberger 22aa402b64 test(daemon): mock launchd plist reads 2026-04-25 07:08:36 +01:00
Peter Steinberger d957401c7e test(daemon): type launchd kickstart code fake 2026-04-25 07:08:36 +01:00
Vincent Koc f5868ad1f8 fix(daemon): refresh launchd plist before restart bootstrap (#71421) 2026-04-24 22:59:21 -07:00
Peter Steinberger cde7ae8809 test: share launchd test helpers 2026-04-20 18:30:53 +01:00
Vincent Koc d5b1329bf3 test(perf): speed up slow launchd and sessions specs 2026-04-14 23:34:09 +01:00
Peter Steinberger f3c143f0cd fix(daemon): honor launchd running state without pid 2026-04-10 22:19:37 +01:00
Nimrod Gutman 4d2fdb9f71 test(daemon): cover launchd compatibility scenarios 2026-04-10 22:19:37 +01:00
Nimrod Gutman eebad7a372 refactor(daemon): simplify launchd stop lifecycle 2026-04-10 22:19:37 +01:00
Nimrod Gutman affffddf04 fix(daemon): keep launchd enable scoped to owned stops 2026-04-10 22:19:37 +01:00
Nimrod Gutman c0ddcf6630 fix(daemon): confirm launchd stop state before success 2026-04-10 22:19:37 +01:00
Nimrod Gutman 23d9a100c4 fix(daemon): keep launchd stop persistent without reinstall 2026-04-10 22:19:37 +01:00
Peter Steinberger 67ae576b9e test: remove redundant launchd conversions 2026-04-10 21:58:40 +01:00
Peter Steinberger 48653c2031 fix: recover launchd restart and restore prompt-cache gate 2026-04-05 17:47:07 +09:00
Peter Steinberger aa497e9c52 refactor: extract daemon launchd recovery helper 2026-04-05 09:16:44 +01:00
Peter Steinberger fd968bfb2d fix: recover unloaded macOS launch agents (#43766) 2026-04-05 17:06:22 +09:00
Peter Steinberger 45a6f769bb test: trim core partial mocks 2026-04-03 19:28:19 +01:00
Sally O'Malley 8db6fcca77 fix(gateway/cli): relax local backend self-pairing and harden launchd restarts (#46290)
Signed-off-by: sallyom <somalley@redhat.com>
2026-03-14 14:27:52 -04:00
Peter Steinberger ea82458290 refactor: share launchd bootstrap assertions 2026-03-13 20:19:39 +00:00
Peter Steinberger cba07a400a refactor: share launchd bootstrap ordering assertions 2026-03-13 20:19:39 +00:00
Peter Steinberger 80e7da92ce fix: stabilize macos daemon onboarding 2026-03-13 13:47:09 +00:00
Robin Waslander 841ee24340 fix(daemon): address clanker review findings for kickstart restart
Bug 1 (high): replace fixed sleep 1 with caller-PID polling in both
kickstart and start-after-exit handoff modes. The helper now waits until
kill -0 $caller_pid fails before issuing launchctl kickstart -k.

Bug 2 (medium): gate enable+bootstrap fallback on isLaunchctlNotLoaded().
Only attempt re-registration when kickstart -k fails because the job is
absent; all other kickstart failures now re-throw the original error.

Follows up on 3c0fd3dffe.
Fixes #43311, #43406, #43035, #43049
2026-03-12 02:16:24 +01:00
Robin Waslander 3c0fd3dffe fix(daemon): replace bootout with kickstart -k for launchd restarts on macOS
On macOS, launchctl bootout permanently unloads the LaunchAgent plist.
Even with KeepAlive: true, launchd cannot respawn a service whose plist
has been removed from its registry. This left users with a dead gateway
requiring manual 'openclaw gateway install' to recover.

Affected trigger paths:
- openclaw gateway restart from an agent session (#43311)
- SIGTERM on config reload (#43406)
- Gateway self-restart via SIGTERM (#43035)
- Hot reload on channel config change (#43049)

Switch restartLaunchAgent() to launchctl kickstart -k, which force-kills
and restarts the service without unloading the plist. When the restart
originates from inside the launchd-managed process tree, delegate to a
new detached handoff helper (launchd-restart-handoff.ts) to avoid the
caller being killed mid-command. Self-restart paths in process-respawn.ts
now schedule the detached start-after-exit handoff before exiting instead
of relying on exit/KeepAlive timing.

Fixes #43311, #43406, #43035, #43049
2026-03-12 01:16:49 +01:00
Peter Steinberger ce9e91fdfc fix(launchd): harden macOS launchagent install permissions 2026-03-09 08:14:46 +00:00
scoootscooob 44beb7be1f fix(daemon): also enable LaunchAgent in repairLaunchAgentBootstrap
The repair/recovery path had the same missing `enable` guard as
`restartLaunchAgent`.  If launchd persists a "disabled" state after a
previous `bootout`, the `bootstrap` call in `repairLaunchAgentBootstrap`
fails silently, leaving the gateway unloaded in the recovery flow.

Add the same `enable` guard before `bootstrap` that was already applied
to `installLaunchAgent` and (in this PR) `restartLaunchAgent`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 05:36:27 +00:00
scoootscooob 69cd376e3b fix(daemon): enable LaunchAgent before bootstrap on restart
restartLaunchAgent was missing the launchctl enable call that
installLaunchAgent already performs. launchd can persist a "disabled"
state after bootout, causing bootstrap to silently fail and leaving the
gateway unloaded until a manual reinstall.

Fixes #39211

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 05:36:27 +00:00
Peter Steinberger 2646739d23 refactor: centralize strict numeric parsing 2026-03-08 03:02:25 +00:00
Peter Steinberger 7f44bc5e94 fix: reject launchd pid sentinel values
Landed from contributor PR #39281 by @mvanhorn.

Co-authored-by: Matt Van Horn <mvanhorn@gmail.com>
2026-03-08 02:44:02 +00:00
liuxiaopai-ai c9558cdcd7 fix(launchd): set restrictive umask in gateway plist 2026-03-02 18:38:56 +00:00
Mark L 718d418b32 fix(daemon): harden launchd plist with umask 077 (#31919)
* fix(daemon): add launchd umask hardening

* fix: finalize launchd umask changelog + thanks (#31919) (thanks @liuxiaopai-ai)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-03-02 18:13:41 +00:00
Gustavo Madeira Santana c0ce125512 fix(gateway): shorten manual reinstall/restart delays
LaunchAgent plist hardcodes ThrottleInterval to 60 in src/daemon/launchd-plist.ts

That means every restart/install path that terminates the launchd-managed gateway gets delayed by launchd’s one-minute relaunch throttle. The CLI restart path in src/daemon/launchd.ts is doing the expected supervisor actions, but the plist policy makes those actions look hung.

In src/daemon/launchd-plist.ts:
- added LAUNCH_AGENT_THROTTLE_INTERVAL_SECONDS
- reduced the LaunchAgent ThrottleInterval from 60 to 1
2026-02-28 20:46:11 -05: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 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: b08797a995
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