macsync/@packages/shared/Sources/MacSyncShared/Transport/Shared.swift
Natalie 242d7cd1a8 feat(send-queue): burst-friendly outbound send-rate cap (default 10/5min)
The /client/imessage/send-queue/pending endpoint released up to 50 queued
sends per poll, so an enqueued burst all fired at once. Add a configurable
release cap: the endpoint now returns at most (maxSends − sent-in-window)
queued items, so a burst queues and drips out at the configured rate.

- macsync.send_rate_config single-row table, default max_sends=10,
  window_seconds=300 (10 per 5 min).
- entities/send-queue repo: getSendRateConfig / setSendRateConfig /
  countSentWithin.
- Admin control: GET/PUT /admin/send-rate-limit (service-token auth) so the
  cap is adjustable at runtime (wired to MCP via quinn.api separately).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 15:35:18 -04:00

15 lines
830 B
Swift

import Foundation
import LilithAgentCore
/// Single shared keychain where the device auth token is stored.
/// All three sync modules (iMessage, iPhoto, iMail) look here for the Bearer token.
/// The device token belongs to one hardware device it is not per-module.
public let macSyncSharedKeychain = KeychainHelper(service: "com.lilith.mac-sync")
/// Read `serverURL` from UserDefaults, falling back to localhost for local development.
/// `ConfigFile.load()` merges `~/.config/com.lilith.mac-sync/config.json` into UserDefaults
/// at every launch, so this reflects the most recent config file value.
/// For deployed setups the install script (or config file) sets the remote server URL.
public func macSyncResolveServerURL() -> String {
UserDefaults.standard.string(forKey: "serverURL") ?? "http://localhost:3201"
}