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
/**
 * Spotify Sync Scheduler (#2152)
 *
 * Registers an interval job that periodically runs the incremental Spotify
 * recently-played ingestion (see spotifySync.js). Shape shared with the
 * iMessage/Signal/YouTube schedulers via `createSyncScheduler`
 * (server/services/createSettingsGatedSyncScheduler.js).
 *
 * OFF by default: the scheduler is only registered when the user has connected
 * Spotify AND opted in via Settings → Spotify (`settings.spotify.enabled`). The
 * ~25-min default cadence beats the API's 50-track recently-played window so no
 * plays are missed. The interval value is locked 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 user
 * intent + a completed OAuth connection.
 */

import { createSyncScheduler } from './createSettingsGatedSyncScheduler.js';
import { getSpotifyConfig, runSync, readSyncState } from './spotifySync.js';

/**
 * Start the Spotify sync scheduler. No-ops when disabled in settings.
 */
export const startSpotifyScheduler = createSyncScheduler({
  id: 'spotify-sync',
  label: 'Spotify',
  icon: '🎧',
  source: 'spotifyScheduler',
  getConfig: getSpotifyConfig,
  runSync,
  getLastRunAt: async () => (await readSyncState()).lastRunAt,
});