Skip to content

Add macOS support#4

Open
laprasoc wants to merge 1 commit intochrysb:mainfrom
laprasoc:codex/macos-support
Open

Add macOS support#4
laprasoc wants to merge 1 commit intochrysb:mainfrom
laprasoc:codex/macos-support

Conversation

@laprasoc
Copy link
Copy Markdown

@laprasoc laprasoc commented Mar 9, 2026

Summary

  • add shared platform-aware sync scheduling so Linux keeps /etc/cron.d while macOS runs the saved five-field cron schedule from AlphaClaw's managed in-process scheduler
  • update startup to install gog and shim binaries into AlphaClaw's managed internal bin on macOS instead of assuming /usr/local/bin
  • fix AlphaClaw startup ordering so ALPHACLAW_ROOT_DIR and PORT are resolved before server constants are imported, which makes local macOS roots and ports behave correctly
  • cover the macOS onboarding/system scheduling flows in tests and update the README platform note

Testing

  • npm test -- tests/server/routes-system.test.js tests/server/routes-onboarding.test.js
  • live-tested node bin/alphaclaw.js --root-dir /tmp/alphaclaw-live-test start against an existing local .openclaw on macOS
  • live-tested AlphaClaw against a persistent local root and verified the UI served successfully on the configured port without modifying the host crontab

@laprasoc laprasoc force-pushed the codex/macos-support branch from 899a7d0 to 9513ea6 Compare March 9, 2026 05:16

installHourlyGitSyncScript({ fs, openclawDir: OPENCLAW_DIR });
await installHourlyGitSyncCron({ fs, openclawDir: OPENCLAW_DIR });
await installHourlyGitSyncCron({
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS, the managed scheduler only starts during process startup in bin/alphaclaw.js when the sync script already exists. In a fresh onboarding flow, we create the script/config here, but never start the scheduler in-process afterward, so hourly sync will not run until the service restarts. Can we start the managed scheduler after successful cron config install on darwin (or have installHourlyGitSyncCron do that) so onboarding is immediately effective?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I wanted to contribute MacOS porting patches, but I found open PR's here, so i rebased on top of those first.

Fixed in 2d3cd2c:

fresh macOS onboarding installs the cron config and script but never
starts the in-process managed scheduler, so hourly sync would not run
until the next service restart.

Fix: call startManagedScheduler() in installHourlyGitSyncCron() after a
successful install. startManagedScheduler() is a no-op on Linux
(normalizeCronPlatform guard), so the linux/docker path is unchanged.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2d3cd2c. Added startManagedScheduler({ fs, openclawDir, platform }) inside installHourlyGitSyncCron() (lib/server/onboarding/cron.js) after status.installed returns true. Placed the call in onboarding/cron.js rather than onboarding/index.js so the responsibility stays with the cron module — per your suggestion. startManagedScheduler has its own normalizeCronPlatform !== "darwin" guard so the linux/docker path is unchanged.

const normalizeCronPlatform = (platform = os.platform()) =>
platform === "darwin" ? "darwin" : "linux";

const isValidCronSchedule = (value) =>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isValidCronSchedule currently accepts any 5-token expression, but the managed scheduler matcher below only supports numeric tokens (*, ranges, steps, comma lists). Schedules like 0 9 * * MON will be accepted/saved but can never match on macOS, so sync silently never runs. Can we either tighten validation to supported syntax or add parser support for named day/month tokens?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, I wanted to contribute MacOS porting patches, but I found open PR's here, so i rebased on top of those first.

Fixed in 2d3cd2c:

isValidCronSchedule() accepted any 5-token expression including named
weekday/month tokens (MON, SUN, JAN, etc.).

The managed scheduler parser uses Number.parseInt() which returns NaN
for named tokens, causing cronMatchesDate() to always return false,
sync silently never runs.

Fix: tighten validation to numeric tokens only (digits, *, -, /, comma).
Named tokens are now rejected at save time rather than silently failing at runtime.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2d3cd2c. Tightened isValidCronSchedule to reject any token containing letters — each field must now match [\d,*/\-]+. Named tokens like 0 9 * * MON are rejected at save time rather than accepted and silently failing at runtime. Parser support for named tokens would require a translation table (MON→1, etc.) and feels out of scope here — the validation fix is the safer boundary. If named token support is wanted later it can be added independently.

Copy link
Copy Markdown
Owner

@chrysb chrysb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great direction overall on macOS support and shared cron plumbing. I'm requesting changes for two blockers:

  1. On fresh macOS onboarding, the managed scheduler is not started after cron/script install, so hourly sync does not run until a restart.
  2. Cron validation accepts schedules the managed parser cannot execute (e.g. named weekdays), which can silently disable sync on macOS.

I left inline comments on both code paths with suggested fixes.

@diazMelgarejo
Copy link
Copy Markdown

I opened a new PR: #63

Targeting: https://github.com/chrysb/alphaclaw/tree/pr-4-macos

Thanks!

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.

3 participants