Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

1.4 KB
Raw Blame
/**
 * iMessage Sync Scheduler (#2151)
 *
 * Registers an interval job that periodically runs the incremental iMessage
 * ingestion (see imessageSync.js). Shape shared with the Signal/Spotify/YouTube
 * schedulers via `createSyncScheduler` (server/services/createSettingsGatedSyncScheduler.js).
 *
 * OFF by default: the scheduler is only registered when the user has opted in via
 * the iMessage Settings drawer on Comms → Messages → iMessage
 * (`settings.imessage.enabled`). Reading chat.db needs macOS Full Disk Access,
 * so we never poll it silently. The interval value is locked in
 * at registration (changing it needs a restart), but the `enabled` toggle is
 * re-read on every tick so disabling from settings stops runs without a restart.
 *
 * No LLM calls happen on this path — ingestion is deterministic — so the
 * no-cold-bootstrap AI policy does not gate it; the opt-in is purely about Full
 * Disk Access + user intent.
 */

import { createSyncScheduler } from './createSettingsGatedSyncScheduler.js';
import { getImessageConfig, runSync, readSyncState } from './imessageSync.js';

/**
 * Start the iMessage sync scheduler. No-ops when disabled in settings.
 */
export const startImessageScheduler = createSyncScheduler({
  id: 'imessage-sync',
  label: 'iMessage',
  icon: '💬',
  source: 'imessageScheduler',
  getConfig: getImessageConfig,
  runSync,
  getLastRunAt: async () => (await readSyncState()).lastRunAt,
});