@m13v/s4l 1.7.1-rc.15 → 1.7.1-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/bin/cli.js +0 -23
  2. package/mcp/dist/index.js +22 -306
  3. package/mcp/dist/onboarding.js +10 -3
  4. package/mcp/dist/panel.html +31 -42
  5. package/mcp/dist/product-link.html +1 -1
  6. package/mcp/dist/runtime.js +1 -101
  7. package/mcp/dist/telemetry.js +3 -80
  8. package/mcp/dist/version.json +2 -2
  9. package/mcp/manifest.json +1 -9
  10. package/mcp/menubar/dashboard_server.py +0 -12
  11. package/mcp/menubar/s4l_card.py +21 -18
  12. package/mcp/menubar/s4l_menubar.py +24 -254
  13. package/mcp/menubar/s4l_state.py +23 -162
  14. package/mcp/package.json +1 -1
  15. package/mcp/shared/doctor.cjs +0 -8
  16. package/mcp/shared/onboarding-ledger.cjs +0 -1
  17. package/package.json +1 -3
  18. package/scripts/active_users.py +6 -3
  19. package/scripts/autopilot_stall_watch.py +16 -200
  20. package/scripts/claude_job.py +0 -6
  21. package/scripts/identity.py +0 -26
  22. package/scripts/link_tail.py +91 -167
  23. package/scripts/memory_snapshot.py +0 -35
  24. package/scripts/pick_twitter_thread_target.py +1 -1
  25. package/scripts/release-mcpb.sh +0 -48
  26. package/scripts/reset-test-machine.sh +3 -85
  27. package/scripts/scheduled_tasks_snapshot.py +0 -107
  28. package/scripts/sentry_digest.py +189 -81
  29. package/scripts/sentry_init.py +15 -43
  30. package/scripts/setup_twitter_auth.py +38 -76
  31. package/scripts/snapshot.py +0 -20
  32. package/scripts/twitter_post_plan.py +1 -7
  33. package/skill/dm-outreach-twitter.sh +0 -19
  34. package/skill/engage-twitter.sh +0 -27
  35. package/skill/sentry-digest.sh +12 -125
  36. package/scripts/get-latest-staging-mcpb.sh +0 -50
  37. package/scripts/mark_event.py +0 -128
  38. package/scripts/send_gmail_report.py +0 -76
package/bin/cli.js CHANGED
@@ -823,29 +823,6 @@ function installMcp() {
823
823
  } catch (e) {
824
824
  console.warn(' WARNING: could not stamp MCP version:', e && e.message);
825
825
  }
826
- // Auto-opt a fresh install into the staging channel when the version being
827
- // installed is itself a pre-release (-rc.N) — e.g. `npx social-autoposter@
828
- // X.Y.Z-rc.N init`. Without this, channel.json stays absent, which
829
- // scripts/s4l_channel.py's fail-safe default reads as "stable", so the box
830
- // would install this one rc and then silently stop tracking staging (never
831
- // pick up the next rc). Mirrors the same one-time write in
832
- // mcp/src/runtime.ts's provision() for the .mcpb (Desktop) install path.
833
- // Only writes when no channel marker exists yet — never overrides an
834
- // existing preference (e.g. a user who already opted back out).
835
- try {
836
- const pkgVersion = require('../package.json').version;
837
- if (pkgVersion.includes('-rc.')) {
838
- const stateDir = process.env.S4L_STATE_DIR || path.join(os.homedir(), '.social-autoposter-mcp');
839
- const channelPath = path.join(stateDir, 'channel.json');
840
- if (!fs.existsSync(channelPath)) {
841
- fs.mkdirSync(stateDir, { recursive: true });
842
- fs.writeFileSync(channelPath, JSON.stringify({ channel: 'staging' }, null, 2) + '\n');
843
- console.log(' pre-release install detected -> opted into the staging channel');
844
- }
845
- }
846
- } catch (e) {
847
- console.warn(' WARNING: could not set staging channel:', e && e.message);
848
- }
849
826
  console.log(' installing MCP runtime deps (npm install --omit=dev in mcp/)');
850
827
  const npmRes = spawnSync('npm', ['install', '--omit=dev', '--no-audit', '--no-fund'], {
851
828
  cwd: mcpDest,
package/mcp/dist/index.js CHANGED
@@ -22,10 +22,10 @@ import fs from "node:fs";
22
22
  import { repoDir, runPython, run, readPlan, writePlan, planPath, } from "./repo.js";
23
23
  import { applySetup, resolveProject, personaReady, listManagedProjectStatus, listProjectSettings, ensureShortLinksDefault, ensurePersonaProject, findPersonaProject, REQUIRED_FIELDS, RECOMMENDED_FIELDS, configPath, normalizeStringList, } from "./setup.js";
24
24
  import { xStatus, xConnect, xDetectSources, xScanProfile, summarizeXAuth } from "./twitterAuth.js";
25
- import { startProvisioning, isProvisioning, readProgress, runtimeReady, readRuntime, resolvePython, resolveChrome, ensureMenubar, menubarRunning, clearMenubarStop, ensurePipelineCurrent, ensureRuntimeProvisioned, retryProvisionIfStalled, } from "./runtime.js";
25
+ import { startProvisioning, isProvisioning, readProgress, runtimeReady, readRuntime, resolvePython, resolveChrome, ensureMenubar, menubarRunning, clearMenubarStop, ensurePipelineCurrent, ensureRuntimeProvisioned, } from "./runtime.js";
26
26
  import { blockOnboardingMilestone, completeOnboardingMilestone, ensureDoctorPhase, onboardingLedger, onboardingSnapshot, recordOnboardingAttempt, runDoctorPhase, } from "./onboarding.js";
27
27
  import { VERSION, versionStatus, latestPublishedVersion } from "./version.js";
28
- import { initSentry, sendHeartbeat, sendStateSnapshot, captureError, captureMessage, flushSentry, startLogStreaming, flushLogs, logLine, checkVersionChange } from "./telemetry.js";
28
+ import { initSentry, sendHeartbeat, sendStateSnapshot, captureError, flushSentry, startLogStreaming, flushLogs, logLine } from "./telemetry.js";
29
29
  import { registerAppTool, registerAppResource, RESOURCE_MIME_TYPE, getUiCapability, } from "@modelcontextprotocol/ext-apps/server";
30
30
  import { fileURLToPath } from "node:url";
31
31
  import http from "node:http";
@@ -1181,21 +1181,10 @@ async function postApproved(batchId, plan) {
1181
1181
  }
1182
1182
  // Post failures are HANDLED in the pipeline (it returns a count, never throws),
1183
1183
  // so they never reach Sentry on their own. Capture an explicit event whenever
1184
- // the run exited non-zero OR a REAL failure happened. This is the only
1185
- // telemetry channel that reaches a customer .mcpb install (their cycle log
1186
- // lives on their machine). install_id/hostname are auto-tagged.
1187
- //
1188
- // Gated on failure_reasons (not just realPosted < approved.length): the
1189
- // Python pipeline already reports every shortfall to Sentry itself
1190
- // (twitter_post_plan.py's capture_message), including benign skips like a
1191
- // deleted target tweet. Re-reporting the SAME benign skip here as a second,
1192
- // independently-fingerprinted `Error` (this capture group) doubled every
1193
- // such event into two distinct Sentry issues. Only add this Node-side
1194
- // capture when there's a real failure_reasons entry or a non-zero exit,
1195
- // i.e. something the Python capture wouldn't already have flagged as an
1196
- // actionable error on its own.
1197
- const hasRealFailure = res.code !== 0 || Boolean(summObj?.failure_reasons);
1198
- if (hasRealFailure) {
1184
+ // the run exited non-zero OR fewer drafts posted than were approved. This is
1185
+ // the only telemetry channel that reaches a customer .mcpb install (their cycle
1186
+ // log lives on their machine). install_id/hostname are auto-tagged.
1187
+ if (res.code !== 0 || realPosted < approved.length) {
1199
1188
  captureError(new Error(`post_drafts: ${realPosted}/${approved.length} posted (exit=${res.code})`), {
1200
1189
  component: "post",
1201
1190
  exit_code: String(res.code),
@@ -1605,10 +1594,7 @@ tool("engagement_mode", {
1605
1594
  // persona is seeded. (2026-06-30) Skipped when promotion-only, since the
1606
1595
  // product project isn't configured yet (it stays gated until project_config).
1607
1596
  let kickerInstall = null;
1608
- if (personalBrand && isPaused()) {
1609
- kickerInstall = { ok: false, detail: "skip (paused)" };
1610
- }
1611
- else if (personalBrand) {
1597
+ if (personalBrand) {
1612
1598
  try {
1613
1599
  kickerInstall = await ensureQueueKickerInstalled();
1614
1600
  console.error(`[engagement_mode] launchd kicker: ${kickerInstall.ok ? "ok" : "skip"} (${kickerInstall.detail})`);
@@ -1849,18 +1835,6 @@ tool("project_config", {
1849
1835
  // as expected. Once connect_x succeeds, run the full phase immediately
1850
1836
  // to verify persistence, CDP, and the durable cookie mirror.
1851
1837
  doctorReport = await runDoctorPhase("full");
1852
- // Only mark x_verified once doctor confirms all X checks pass (session valid,
1853
- // cookies persisted, CDP responding, keychain accessible). This prevents the
1854
- // autopilot from starting if X connection didn't actually persist.
1855
- if (doctorReport?.ok) {
1856
- completeOnboardingMilestone("x_verified", {
1857
- x_session: doctorReport.checks?.find(c => c.id === "x_session")?.status,
1858
- x_cookies: doctorReport.checks?.find(c => c.id === "x_cookie_sqlite")?.status,
1859
- });
1860
- }
1861
- else {
1862
- recordOnboardingAttempt("x_verified", { doctor_ok: false });
1863
- }
1864
1838
  }
1865
1839
  else {
1866
1840
  blockOnboardingMilestone("x_connected", `x_${r.state || "not_connected"}`, r.error || r.note || summarizeXAuth(r), { state: r.state || "not_connected" });
@@ -2102,10 +2076,7 @@ tool("project_config", {
2102
2076
  // persona-aware, so calling it from both setup paths is safe. Best-effort:
2103
2077
  // a kicker hiccup never fails setup. (2026-06-30)
2104
2078
  let kickerInstall = null;
2105
- if (result.ready && isPaused()) {
2106
- kickerInstall = { ok: false, detail: "skip (paused)" };
2107
- }
2108
- else if (result.ready) {
2079
+ if (result.ready) {
2109
2080
  try {
2110
2081
  kickerInstall = await ensureQueueKickerInstalled();
2111
2082
  console.error(`[project_config] launchd kicker: ${kickerInstall.ok ? "ok" : "skip"} (${kickerInstall.detail})`);
@@ -2482,26 +2453,16 @@ tool("runtime", {
2482
2453
  });
2483
2454
  }
2484
2455
  // ---- status (default): runtime install snapshot -----------------------
2485
- let snapshot = runtimeSnapshot();
2456
+ const snapshot = runtimeSnapshot();
2486
2457
  if (snapshot.runtime_ready) {
2487
2458
  completeOnboardingMilestone("runtime_ready");
2488
2459
  }
2489
2460
  else if (snapshot.progress?.done && !snapshot.progress.ok) {
2490
- // A prior provision failed. Kick a bounded auto-retry so status polling
2491
- // self-heals a transient failure instead of parking until the next boot;
2492
- // the provisioner cleans its own partial artifacts, so a retry is safe.
2493
- // Only surface the failure to the onboarding ledger once retries are spent.
2494
- if (retryProvisionIfStalled()) {
2495
- snapshot = runtimeSnapshot(); // reflect the restarted, in-flight run
2496
- }
2497
- else {
2498
- blockOnboardingMilestone("runtime_ready", "runtime_install_failed", snapshot.progress.error || "Runtime installation failed", { outcome: "failed" });
2499
- }
2461
+ blockOnboardingMilestone("runtime_ready", "runtime_install_failed", snapshot.progress.error || "Runtime installation failed", { outcome: "failed" });
2500
2462
  }
2501
2463
  return jsonContent({
2502
2464
  ...snapshot,
2503
2465
  menubar_running: await menubarRunning(),
2504
- paused: isPaused(),
2505
2466
  onboarding: onboardingSnapshot(),
2506
2467
  });
2507
2468
  });
@@ -2532,37 +2493,6 @@ tool("restart_menubar", {
2532
2493
  menubar_running: running,
2533
2494
  });
2534
2495
  });
2535
- // ---- pause_s4l: temporarily stop drafting/posting, reversibly --------------
2536
- // The lighter alternative to Quit: unloads only the launchd jobs that scan,
2537
- // draft, and post (plus their support daemons), leaving Claude Desktop, the
2538
- // S4L tray, X connection, and the draft schedule registration untouched.
2539
- // Fully reversible — action:'resume' reinstalls the exact same daemons via the
2540
- // same idempotent ensure*Installed() functions boot uses. NOT "autopilot": S4L
2541
- // is draft-first (a human approves every post), so this pauses/resumes the
2542
- // draft pipeline itself, not some autonomous posting mode.
2543
- tool("pause_s4l", {
2544
- title: "Pause or resume S4L",
2545
- description: "Pause temporarily stops S4L's own draft pipeline (the launchd kicker that scans/drafts/posts, " +
2546
- "plus its reaper/stall-watch/memory-snapshot support jobs) WITHOUT touching Claude Desktop, the " +
2547
- "S4L tray, your X connection, or the draft schedule registration — nothing is deleted, so it " +
2548
- "survives a Claude Desktop restart and Resume brings it right back. Use when the user asks to " +
2549
- "pause, stop, or temporarily disable S4L, or to resume/unpause it. This is NOT the same as Quit " +
2550
- "(which kills and restarts Claude Desktop and removes the draft schedule) — Pause is the lighter, " +
2551
- "fully reversible option. action:'status' (default) reports whether it's currently paused.",
2552
- inputSchema: {
2553
- action: z.enum(["status", "pause", "resume"]).optional(),
2554
- },
2555
- }, async ({ action }) => {
2556
- if (action === "pause") {
2557
- const res = await pauseS4L();
2558
- return jsonContent({ action: "pause", paused: isPaused(), ...res });
2559
- }
2560
- if (action === "resume") {
2561
- const res = await resumeS4L();
2562
- return jsonContent({ action: "resume", paused: isPaused(), ...res });
2563
- }
2564
- return jsonContent({ action: "status", paused: isPaused() });
2565
- });
2566
2496
  // ---- report_diagnosis: ship a field diagnosis to the developers -------------
2567
2497
  // First-class MCP wrapper over scripts/send_diagnostic_report.py (the same
2568
2498
  // Sentry lane the menubar "Diagnose & fix" prompt uses). Before this existed
@@ -2601,29 +2531,6 @@ tool("report_diagnosis", {
2601
2531
  return jsonContent({ ok: false, detail: String(e?.message || e).slice(0, 300) });
2602
2532
  }
2603
2533
  });
2604
- // ---- client_event: lightweight UI telemetry ping from the dashboard panel --
2605
- // The panel iframe is a browser context with no Sentry SDK and no server-side
2606
- // telemetry access of its own. Before this, a panel button click (e.g. "Set up
2607
- // draft schedule") had NO record anywhere — report_diagnosis needs a full
2608
- // markdown report from an agent turn, which doesn't fit a plain click, so the
2609
- // panel's rearm button silently had zero telemetry while its menu-bar sibling
2610
- // did (see s4l_menubar.py _capture_msg). Not for agent use: the panel calls
2611
- // this directly via app.callServerTool, never through chat.
2612
- tool("client_event", {
2613
- title: "Log a lightweight client UI event",
2614
- description: "Internal telemetry hook for the dashboard panel to report a UI event (e.g. a button click). " +
2615
- "Not intended for the agent to call from chat.",
2616
- inputSchema: {
2617
- event: z.string().describe("Short event name, e.g. rearm_clicked"),
2618
- surface: z.string().optional().describe("UI surface the event came from, e.g. panel"),
2619
- },
2620
- }, async ({ event, surface }) => {
2621
- captureMessage(`S4L client event: ${event}`, {
2622
- level: "info",
2623
- tags: { component: "panel", event, surface: surface || "panel" },
2624
- });
2625
- return jsonContent({ ok: true });
2626
- });
2627
2534
  function runtimeSnapshot() {
2628
2535
  const rt = readRuntime();
2629
2536
  const progress = readProgress();
@@ -3318,18 +3225,6 @@ async function ensureQueueKickerInstalled() {
3318
3225
  detail: "no ready project or active persona yet",
3319
3226
  };
3320
3227
  }
3321
- // Additional gate: X must be connected and verified before autopilot starts.
3322
- // This prevents wasted cycles against a logged-out x.com if X connection didn't
3323
- // persist after import/login. x_verified milestone only completes after doctor
3324
- // confirms X session and cookies are valid.
3325
- const onboardingState = onboardingSnapshot();
3326
- const xVerified = onboardingState?.milestones?.some((m) => m.id === "x_verified" && m.status === "complete");
3327
- if (!xVerified) {
3328
- return {
3329
- ok: false,
3330
- detail: "X not yet verified (awaiting explicit pre-flight confirmation)",
3331
- };
3332
- }
3333
3228
  const logDir = path.join(repoDir(), "skill", "logs");
3334
3229
  try {
3335
3230
  fs.mkdirSync(logDir, { recursive: true });
@@ -3625,76 +3520,6 @@ async function ensureMemorySnapshotInstalled() {
3625
3520
  return { ok: false, detail: e?.message || String(e) };
3626
3521
  }
3627
3522
  }
3628
- // ---- pause/resume: stop drafting/posting without touching Claude Desktop ---
3629
- // Unlike Quit (which kills + relaunches Claude Desktop and deletes the draft
3630
- // schedule), Pause only unloads the launchd jobs that actually DO work — the
3631
- // kicker that scans/drafts/posts (TWITTER_AUTOPILOT_LABEL) plus its reaper,
3632
- // stall-watch, and memory-snapshot support daemons — while leaving Claude
3633
- // Desktop, the tray, and the Claude-native s4l-worker scheduled task alone.
3634
- // The scheduled task still fires on its own cadence; claude_job.py's `next`
3635
- // checks the same flag file and reports "no work" instantly instead of
3636
- // draining the queue, so nothing drafts or posts while paused even if a
3637
- // worker session wakes up mid-pause. A flag file (nothing is deleted) is what
3638
- // makes Resume a plain reinstall of the same 4 daemons — see resumeS4L.
3639
- function pauseFlagPath() {
3640
- return path.join(s4lStateDir(), "paused.flag");
3641
- }
3642
- function isPaused() {
3643
- try {
3644
- return fs.existsSync(pauseFlagPath());
3645
- }
3646
- catch {
3647
- return false;
3648
- }
3649
- }
3650
- const PAUSE_TARGETS = [
3651
- { label: TWITTER_AUTOPILOT_LABEL, plist: TWITTER_AUTOPILOT_PLIST },
3652
- { label: REAPER_LABEL, plist: REAPER_PLIST },
3653
- { label: STALL_WATCH_LABEL, plist: STALL_WATCH_PLIST },
3654
- { label: MEMORY_SNAPSHOT_LABEL, plist: MEMORY_SNAPSHOT_PLIST },
3655
- ];
3656
- async function pauseS4L() {
3657
- if (isPaused())
3658
- return { ok: true, detail: "already paused" };
3659
- try {
3660
- fs.mkdirSync(path.dirname(pauseFlagPath()), { recursive: true });
3661
- fs.writeFileSync(pauseFlagPath(), `paused at ${new Date().toISOString()}\n`, "utf-8");
3662
- }
3663
- catch (e) {
3664
- return { ok: false, detail: `could not write pause flag: ${e?.message || e}` };
3665
- }
3666
- const uid = process.getuid ? process.getuid() : 0;
3667
- const results = [];
3668
- for (const { label, plist } of PAUSE_TARGETS) {
3669
- try {
3670
- const res = await unloadPlist(label, plist, uid);
3671
- results.push(`${label}: unloaded (rc=${res.code})`);
3672
- }
3673
- catch (e) {
3674
- results.push(`${label}: ${e?.message || e}`);
3675
- }
3676
- }
3677
- return { ok: true, detail: results.join("; ") };
3678
- }
3679
- async function resumeS4L() {
3680
- try {
3681
- fs.rmSync(pauseFlagPath(), { force: true });
3682
- }
3683
- catch {
3684
- /* best-effort */
3685
- }
3686
- const kicker = await ensureQueueKickerInstalled();
3687
- const reaper = await ensureClaudeReaperInstalled();
3688
- const stall = await ensureStallWatchInstalled();
3689
- const mem = await ensureMemorySnapshotInstalled();
3690
- const detail = [
3691
- `kicker: ${kicker.ok ? "ok" : "skip"} (${kicker.detail})`,
3692
- `reaper: ${reaper.ok ? "ok" : "skip"} (${reaper.detail})`,
3693
- `stall-watch: ${stall.ok ? "ok" : "skip"} (${stall.detail})`,
3694
- `memory-snapshot: ${mem.ok ? "ok" : "skip"} (${mem.detail})`,
3695
- ].join("; ");
3696
- return { ok: true, detail };
3697
- }
3698
3523
  // Install/refresh the on-screen overlay watcher launchd job. Promotes the
3699
3524
  // harness status overlay from a best-effort, fired-from-other-tools nicety to a
3700
3525
  // first-class self-healing job. We run `harness_overlay.py watch` directly in
@@ -3762,73 +3587,6 @@ async function ensureOverlayWatchInstalled() {
3762
3587
  return { ok: false, detail: e?.message || String(e) };
3763
3588
  }
3764
3589
  }
3765
- // Install/refresh the daily self-updater launchd job. This used to be bundled
3766
- // into the now-deleted `autopilot` MCP tool (removed 2026-06-19, 88bd1cb9):
3767
- // calling `autopilot enable` installed this job as a side effect, so removing
3768
- // the tool silently orphaned it — UPDATER_LABEL/UPDATER_PLIST and the
3769
- // auto_update_on status check survived (buildSnapshot still reports them), but
3770
- // nothing has installed the plist since, on ANY box provisioned after that
3771
- // commit (auto_update_on reads false forever). Restored here as its own
3772
- // deterministic boot-time job, same pattern as its five siblings above.
3773
- //
3774
- // Points at scripts/s4l_box_update.sh, NOT skill/social-autoposter-update.sh:
3775
- // the latter is the npm-lane updater (npm view + npx update) and is a silent
3776
- // no-op on a .mcpb box, which has no npm/npx on PATH (see version.ts). The
3777
- // .mcpb-lane equivalent downloads the .mcpb directly from the channel-resolved
3778
- // GitHub release and unpacks it over the extension dir — see that script's own
3779
- // header for the channel/no-downgrade/retry guards. Default mode there
3780
- // downloads + unpacks + restarts Claude Desktop with NO human in the loop,
3781
- // matching the original bundled updater's intent ("keeps a headless install
3782
- // current"); RunAtLoad so a box that boots already-behind checks promptly.
3783
- async function ensureUpdaterInstalled() {
3784
- try {
3785
- if (process.platform !== "darwin")
3786
- return { ok: false, detail: "not macOS" };
3787
- if ((process.env.S4L_AUTO_UPDATE) === "0")
3788
- return { ok: false, detail: "disabled (S4L_AUTO_UPDATE=0)" };
3789
- const logDir = path.join(repoDir(), "skill", "logs");
3790
- try {
3791
- fs.mkdirSync(logDir, { recursive: true });
3792
- }
3793
- catch {
3794
- /* best-effort */
3795
- }
3796
- const xml = plistXml({
3797
- label: UPDATER_LABEL,
3798
- programArgs: ["/bin/bash", path.join(repoDir(), "scripts", "s4l_box_update.sh")],
3799
- intervalSecs: 86_400,
3800
- runAtLoad: true,
3801
- stdoutLog: path.join(logDir, "launchd-self-update-stdout.log"),
3802
- stderrLog: path.join(logDir, "launchd-self-update-stderr.log"),
3803
- });
3804
- const uid = process.getuid ? process.getuid() : 0;
3805
- let cur = null;
3806
- try {
3807
- cur = fs.readFileSync(UPDATER_PLIST, "utf-8");
3808
- }
3809
- catch {
3810
- cur = null;
3811
- }
3812
- let detail;
3813
- if (cur === xml) {
3814
- const res = await loadPlist(UPDATER_LABEL, UPDATER_PLIST, uid);
3815
- detail = `current (load rc=${res.code})`;
3816
- }
3817
- else {
3818
- if (cur !== null) {
3819
- await unloadPlist(UPDATER_LABEL, UPDATER_PLIST, uid);
3820
- }
3821
- fs.mkdirSync(path.dirname(UPDATER_PLIST), { recursive: true });
3822
- fs.writeFileSync(UPDATER_PLIST, xml, "utf-8");
3823
- const res = await loadPlist(UPDATER_LABEL, UPDATER_PLIST, uid);
3824
- detail = cur === null ? "installed + loaded" : `rewritten + reloaded (rc=${res.code})`;
3825
- }
3826
- return { ok: true, detail };
3827
- }
3828
- catch (e) {
3829
- return { ok: false, detail: e?.message || String(e) };
3830
- }
3831
- }
3832
3590
  // Is the draft schedule registered AND running for the LIVE account?
3833
3591
  // 'ok' — worker tasks present+enabled and FIRING (host actively running).
3834
3592
  // 'disabled' — present but a worker task is disabled.
@@ -3890,7 +3648,6 @@ async function buildSnapshot() {
3890
3648
  // (it's a launchctl check the Node side owns), so layer it on here. The panel
3891
3649
  // uses it to offer a one-click "restart menu bar" when the tray was quit.
3892
3650
  snap.menubar_running = await menubarRunning();
3893
- snap.paused = isPaused();
3894
3651
  await ensureDoctorPhase(snap.x_connected ? "full" : "pre_connect");
3895
3652
  if (snap.runtime_ready)
3896
3653
  completeOnboardingMilestone("runtime_ready");
@@ -4876,15 +4633,6 @@ async function drainApprovedBacklog() {
4876
4633
  }
4877
4634
  async function main() {
4878
4635
  initSentry();
4879
- // Detect a self-update (old_version -> new_version) as the very first thing
4880
- // after Sentry is up, before anything else that could restart/exit. See
4881
- // checkVersionChange's own docstring for why this exists.
4882
- try {
4883
- checkVersionChange();
4884
- }
4885
- catch (e) {
4886
- console.error("[social-autoposter-mcp] version-change check failed:", e?.message || e);
4887
- }
4888
4636
  // Tee the verbatim stdout/stderr of every pipeline subprocess to the s4l
4889
4637
  // Cloud Run relay (-> Cloud Logging) so we can troubleshoot/rescue any user
4890
4638
  // scenario (silent stalls, partial onboarding) without asking them to ship a
@@ -4926,31 +4674,16 @@ async function main() {
4926
4674
  catch (e) {
4927
4675
  console.error(`[queue-worker] could not create worker folder: ${e?.message || e}`);
4928
4676
  }
4929
- // The 4 pipeline daemons (kicker, reaper, stall-watch, memory-snapshot) are
4930
- // skipped at boot while paused.flag is present, so a Claude Desktop restart
4931
- // during a Pause doesn't silently un-pause the pipeline — see pauseS4L/
4932
- // resumeS4L. Feedback-digest is NOT gated: it only distills past review
4933
- // decisions, not drafting/posting, so it's harmless to keep running.
4934
- if (!isPaused()) {
4935
- void ensureQueueKickerInstalled()
4936
- .then((r) => console.error(`[queue-worker] launchd kicker: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4937
- .catch((e) => console.error("[queue-worker] kicker install failed:", e?.message || e));
4938
- }
4939
- else {
4940
- console.error("[queue-worker] launchd kicker: skip (paused)");
4941
- }
4677
+ void ensureQueueKickerInstalled()
4678
+ .then((r) => console.error(`[queue-worker] launchd kicker: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4679
+ .catch((e) => console.error("[queue-worker] kicker install failed:", e?.message || e));
4942
4680
  // Self-healing reaper for the agent-mode session leak the queue autopilot
4943
4681
  // produces (finished `claude` worker sessions Desktop never tears down). A
4944
4682
  // standalone guardrail; install unconditionally so it caps memory even on a
4945
4683
  // box whose project isn't ready yet. Best-effort; must never block boot.
4946
- if (!isPaused()) {
4947
- void ensureClaudeReaperInstalled()
4948
- .then((r) => console.error(`[claude-reaper] launchd reaper: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4949
- .catch((e) => console.error("[claude-reaper] reaper install failed:", e?.message || e));
4950
- }
4951
- else {
4952
- console.error("[claude-reaper] launchd reaper: skip (paused)");
4953
- }
4684
+ void ensureClaudeReaperInstalled()
4685
+ .then((r) => console.error(`[claude-reaper] launchd reaper: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4686
+ .catch((e) => console.error("[claude-reaper] reaper install failed:", e?.message || e));
4954
4687
  // Feedback digest: hourly distillation of the user's card approve/reject
4955
4688
  // decisions into learned_preferences (see scripts/feedback_digest.py).
4956
4689
  // Best-effort; a box with no review events runs a no-op.
@@ -4960,25 +4693,15 @@ async function main() {
4960
4693
  // Autopilot stall watchdog: fleet-side Sentry alert when the draft routines stop
4961
4694
  // draining (most often an account switch orphaning them). The menu bar shows the
4962
4695
  // user the Re-arm action; this is the part we see. Best-effort; never blocks boot.
4963
- if (!isPaused()) {
4964
- void ensureStallWatchInstalled()
4965
- .then((r) => console.error(`[stall-watch] launchd watchdog: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4966
- .catch((e) => console.error("[stall-watch] watchdog install failed:", e?.message || e));
4967
- }
4968
- else {
4969
- console.error("[stall-watch] launchd watchdog: skip (paused)");
4970
- }
4696
+ void ensureStallWatchInstalled()
4697
+ .then((r) => console.error(`[stall-watch] launchd watchdog: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4698
+ .catch((e) => console.error("[stall-watch] watchdog install failed:", e?.message || e));
4971
4699
  // Periodic host-resource sampler (memory/process snapshot -> local JSONL). Gives
4972
4700
  // us per-box resource history to diagnose RAM blowups (e.g. the agent-mode
4973
4701
  // session leak). Best-effort; never blocks boot. Disable with S4L_MEMORY_SNAPSHOT=0.
4974
- if (!isPaused()) {
4975
- void ensureMemorySnapshotInstalled()
4976
- .then((r) => console.error(`[memory-snapshot] launchd sampler: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4977
- .catch((e) => console.error("[memory-snapshot] sampler install failed:", e?.message || e));
4978
- }
4979
- else {
4980
- console.error("[memory-snapshot] launchd sampler: skip (paused)");
4981
- }
4702
+ void ensureMemorySnapshotInstalled()
4703
+ .then((r) => console.error(`[memory-snapshot] launchd sampler: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4704
+ .catch((e) => console.error("[memory-snapshot] sampler install failed:", e?.message || e));
4982
4705
  // On-screen overlay watcher supervisor. The harness status overlay only renders
4983
4706
  // while the watcher process is alive, and that watcher had no supervisor — when
4984
4707
  // it died nothing respawned it and the overlay silently vanished. Install it as
@@ -4987,13 +4710,6 @@ async function main() {
4987
4710
  void ensureOverlayWatchInstalled()
4988
4711
  .then((r) => console.error(`[overlay-watch] launchd supervisor: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4989
4712
  .catch((e) => console.error("[overlay-watch] supervisor install failed:", e?.message || e));
4990
- // Daily self-updater: restored 2026-07-08 after 88bd1cb9 ("Remove autopilot
4991
- // tool") silently dropped its only install path (it used to be bundled into
4992
- // the deleted `autopilot enable` action). Best-effort; never blocks boot.
4993
- // Disable with S4L_AUTO_UPDATE=0.
4994
- void ensureUpdaterInstalled()
4995
- .then((r) => console.error(`[self-update] launchd updater: ${r.ok ? "ok" : "skip"} (${r.detail})`))
4996
- .catch((e) => console.error("[self-update] updater install failed:", e?.message || e));
4997
4713
  // Heal installs onboarded before short_links_live defaulted to false: such a
4998
4714
  // project wraps short links against the customer's own domain, which has no
4999
4715
  // /r/[code] resolver, so every minted link 404s. Re-point them at the s4l.ai
@@ -10,11 +10,18 @@ import { createRequire } from "node:module";
10
10
  import { repoDir, run } from "./repo.js";
11
11
  import { resolvePython } from "./runtime.js";
12
12
  const require = createRequire(import.meta.url);
13
+ export const ONBOARDING_MILESTONES = [
14
+ "environment_checked",
15
+ "runtime_ready",
16
+ "x_connected",
17
+ "profile_scanned",
18
+ "mode_chosen",
19
+ "project_ready",
20
+ "topics_seeded",
21
+ "tasks_scheduled",
22
+ ];
13
23
  const ledgerApi = require("../shared/onboarding-ledger.cjs");
14
24
  const doctorApi = require("../shared/doctor.cjs");
15
- // Re-export of the ONE runtime array (see the comment above the imports): this
16
- // is not a second list, just a typed alias for ledgerApi.MILESTONES.
17
- export const ONBOARDING_MILESTONES = ledgerApi.MILESTONES;
18
25
  export function onboardingSnapshot() {
19
26
  return ledgerApi.publicSnapshot();
20
27
  }