@m13v/s4l 1.6.199 → 1.6.200

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.
package/mcp/dist/index.js CHANGED
@@ -240,13 +240,76 @@ function ensurePlist(p, xml) {
240
240
  fs.writeFileSync(p, xml, "utf-8");
241
241
  return true;
242
242
  }
243
+ // Per-label failure backoff for launchd loads. Karol's box (2026-07-03) looped
244
+ // `bootstrap -> Input/output error 5` + `load -> error 5` several times per heal
245
+ // tick for HOURS, with no label, no stderr detail, and no cooldown: pure log
246
+ // flood, zero diagnosis. launchd's error 5 is a catch-all; the most common
247
+ // FIXABLE cause is the service being disabled in the gui domain, so loadPlist
248
+ // now (a) best-effort `launchctl enable`s the label first, (b) on double
249
+ // failure emits ONE structured relay line carrying the label, plist, both
250
+ // stderr tails, and whether the label appears in the domain's disabled list,
251
+ // and (c) backs off for 6 hours after 3 consecutive failures per label.
252
+ const plistLoadFailures = new Map();
243
253
  async function loadPlist(label, plistPath, uid) {
254
+ const back = plistLoadFailures.get(label);
255
+ if (back && back.skipUntil > Date.now()) {
256
+ return {
257
+ code: 1,
258
+ stdout: "",
259
+ stderr: `launchd-load backoff: ${label} failed ${back.count}x; next attempt after ${new Date(back.skipUntil).toISOString()}`,
260
+ };
261
+ }
262
+ // Clears a disabled override when that's the blocker; harmless otherwise.
263
+ await run("launchctl", ["enable", `gui/${uid}/${label}`], { timeoutMs: 15_000, noTee: true });
244
264
  let res = await run("launchctl", ["bootstrap", `gui/${uid}`, plistPath], { timeoutMs: 15_000 });
265
+ const bootstrapErr = res.code !== 0 ? lastLine(res.stderr || res.stdout) : "";
245
266
  if (res.code !== 0) {
246
267
  res = await run("launchctl", ["load", plistPath], { timeoutMs: 15_000 });
247
268
  }
269
+ if (res.code !== 0) {
270
+ const loadErr = lastLine(res.stderr || res.stdout);
271
+ let disabledEntry = "unknown";
272
+ try {
273
+ const disabled = await run("launchctl", ["print-disabled", `gui/${uid}`], {
274
+ timeoutMs: 15_000,
275
+ noTee: true,
276
+ });
277
+ disabledEntry =
278
+ (disabled.stdout || "")
279
+ .split("\n")
280
+ .find((l) => l.includes(label))
281
+ ?.trim() || "not-listed";
282
+ }
283
+ catch {
284
+ /* diagnostic only */
285
+ }
286
+ const detail = JSON.stringify({
287
+ label,
288
+ plist: plistPath,
289
+ bootstrap_err: bootstrapErr,
290
+ load_err: loadErr,
291
+ disabled_entry: disabledEntry,
292
+ });
293
+ console.error(`[launchd-load] failed: ${detail}`);
294
+ logLine("stderr", detail, "launchd-load");
295
+ const prev = plistLoadFailures.get(label) ?? { count: 0, skipUntil: 0 };
296
+ prev.count += 1;
297
+ if (prev.count >= 3) {
298
+ prev.skipUntil = Date.now() + 6 * 3600_000;
299
+ const msg = JSON.stringify({ label, backoff_hours: 6, consecutive_failures: prev.count });
300
+ console.error(`[launchd-load] backing off: ${msg}`);
301
+ logLine("stderr", `backing off: ${msg}`, "launchd-load");
302
+ }
303
+ plistLoadFailures.set(label, prev);
304
+ }
305
+ else {
306
+ plistLoadFailures.delete(label);
307
+ }
248
308
  return res;
249
309
  }
310
+ function lastLine(s) {
311
+ return (s || "").trim().split("\n").slice(-1)[0] || "";
312
+ }
250
313
  async function unloadPlist(label, plistPath, uid) {
251
314
  let res = await run("launchctl", ["bootout", `gui/${uid}/${label}`], { timeoutMs: 15_000 });
252
315
  if (res.code !== 0) {
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.6.199",
3
- "installedAt": "2026-07-03T23:40:49.471Z"
2
+ "version": "1.6.200",
3
+ "installedAt": "2026-07-04T00:00:21.537Z"
4
4
  }
package/mcp/manifest.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "dxt_version": "0.1",
3
3
  "name": "social-autoposter",
4
4
  "display_name": "S4L",
5
- "version": "1.6.199",
5
+ "version": "1.6.200",
6
6
  "description": "Draft, review, approve, and autopilot X/Twitter posts.",
7
7
  "long_description": "## **⚠️ The disclaimer above is generic Claude boilerplate.** Anthropic shows the same warning on every plugin regardless of what it does; any plugin has the same level of access as any app you download from the internet.\n\nS4L is an open source product developed by Mediar.ai Incorporated, a VC-backed San Francisco-based startup.\n\nTo get started:\n\n1\\. Copy this prompt: **Set me up on S4L plugin end to end**\n\n2\\. Quit with CMD+Q, reopen Claude, paste into a new chat.\n\nWhat happens next:\n\n* About every 5 minutes S4L scans X for posts that match your topics and drafts replies in your voice.\n* Drafts show up as review cards, usually the first within a few minutes. Nothing is posted automatically; you approve each one.\n* Posting autopilot stays off until you explicitly turn it on.",
8
8
  "author": {
package/mcp/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/s4l-mcp",
3
- "version": "1.6.199",
3
+ "version": "1.6.200",
4
4
  "private": true,
5
5
  "description": "Desktop MCP client for social-autoposter (X/Twitter rail): manual draft/review/approve loop, autopilot control, and stats. Thin wrapper over the existing pipeline scripts.",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/s4l",
3
- "version": "1.6.199",
3
+ "version": "1.6.200",
4
4
  "description": "Automated social posting pipeline for Reddit, X/Twitter, LinkedIn, and Moltbook. Install as a Claude Code agent skill.",
5
5
  "bin": {
6
6
  "social-autoposter": "bin/cli.js",
@@ -696,6 +696,7 @@ def build_summary() -> dict[str, Any]:
696
696
  "app_version": _app_version(),
697
697
  "claude_desktop_version": claude_desktop_version(),
698
698
  "reaper": reaper_status(),
699
+ "twitter_cycle": twitter_cycle_status(),
699
700
  "process_count": len(rows),
700
701
  "mem": {
701
702
  "total_mb": total,
@@ -796,6 +797,9 @@ def reaper_status() -> dict[str, Any] | None:
796
797
  "worker_probe_seen": ds.get("worker_probe_seen"),
797
798
  "reapable_workers": ds.get("reapable_workers"),
798
799
  "unparsed_worker_procs": ds.get("unparsed_worker_procs"),
800
+ "unparsed_samples": ds.get("unparsed_samples"),
801
+ "cwd_fallback_admitted": ds.get("cwd_fallback_admitted"),
802
+ "s4l_worker_cwd_seen": ds.get("s4l_worker_cwd_seen"),
799
803
  "macos_mcp_seen": ds.get("macos_mcp_seen"),
800
804
  "leaked_groups": ds.get("leaked_groups"),
801
805
  "ps_timed_out": ds.get("ps_timed_out"),
@@ -805,6 +809,33 @@ def reaper_status() -> dict[str, Any] | None:
805
809
  return None
806
810
 
807
811
 
812
+ def twitter_cycle_status() -> dict[str, Any] | None:
813
+ """Tail of the newest twitter-cycle log, carried on the heartbeat.
814
+
815
+ The launchd-driven run-twitter-cycle.sh logs ONLY to a local file, so the
816
+ cycle's phase progress was invisible centrally: the 2026-07-03 Karol
817
+ first-draft investigation had a 27-minute blind window (cycle start 22:30 ->
818
+ cards 22:57) with no way to see which phase the time went to. This block
819
+ makes "where is the cycle right now" a one-query answer. Best-effort."""
820
+ try:
821
+ logs = sorted(
822
+ (REPO_DIR / "skill" / "logs").glob("twitter-cycle-20*.log"),
823
+ key=lambda p: p.stat().st_mtime,
824
+ reverse=True,
825
+ )
826
+ if not logs:
827
+ return None
828
+ p = logs[0]
829
+ lines = [ln.strip() for ln in _tail_lines(p, 8) if ln.strip()]
830
+ return {
831
+ "log": p.name,
832
+ "age_sec": round(time.time() - p.stat().st_mtime, 1),
833
+ "last_lines": [ln[:200] for ln in lines[-3:]],
834
+ }
835
+ except Exception:
836
+ return None
837
+
838
+
808
839
  def _tail_lines(path: Path, n: int, approx_line_bytes: int = 4096) -> list[str]:
809
840
  """Return the last `n` lines of a possibly-large file without reading it all.
810
841
  Reads a bounded tail window (n * approx_line_bytes) from the end. Best-effort."""
@@ -407,6 +407,8 @@ def snapshot():
407
407
  "worker_probe_seen": 0, # procs that look like a claude-code agent worker
408
408
  "reapable_workers": 0, # metadata-confirmed SAPS worker procs (=len(procs))
409
409
  "unparsed_worker_procs": 0, # probe-positive but NOT reapable (regex/sig miss)
410
+ "unparsed_samples": [], # up to 3 truncated cmdlines of unparsed procs
411
+ "cwd_fallback_admitted": 0, # unparsed procs rescued via the ~/.s4l-worker cwd proof
410
412
  "metadata_spared_nonworkers": 0,
411
413
  "metadata_unknown": 0,
412
414
  "cwd_confirmed_workers": 0,
@@ -465,18 +467,42 @@ def snapshot():
465
467
  if is_probe:
466
468
  stats["worker_probe_seen"] += 1
467
469
  # (b) claude agent-mode worker sessions — the REAPABLE set.
468
- if not all(tok in cmd for tok in SIG_REQUIRED):
469
- if is_probe:
470
- stats["unparsed_worker_procs"] += 1 # looks like a worker, sig miss
471
- continue
472
- if any(tok in cmd for tok in SIG_EXCLUDED):
473
- continue
474
- u = UUID_RE.search(cmd)
475
- if not u:
476
- # Full signature but the session path shape defeated UUID_RE THE Karol
477
- # blind spot. Count it so the leak is never invisible again.
470
+ sig_ok = all(tok in cmd for tok in SIG_REQUIRED) and not any(
471
+ tok in cmd for tok in SIG_EXCLUDED
472
+ )
473
+ u = UUID_RE.search(cmd) if sig_ok else None
474
+ if not sig_ok or not u:
475
+ # Probe-positive but the full signature / UUID path shape missed — the
476
+ # signature-drift blind spot. Karol leak #2 (2026-07-03): a newer Claude
477
+ # Desktop shipped a cmdline shape that defeated SIG_REQUIRED/UUID_RE, all
478
+ # 46+ workers counted as "unparsed", the reaper killed nothing, and the box
479
+ # climbed to 98 claude procs / 13.7 GB in under 2 hours. Two responses:
480
+ # 1. VISIBILITY: keep a few truncated sample cmdlines so the central
481
+ # telemetry shows the NEW shape and the signature can be fixed blind.
482
+ # 2. CWD-PROOF FALLBACK: a probe-positive process whose cwd is the
483
+ # dedicated ~/.s4l-worker dir is OURS regardless of cmdline shape
484
+ # (interactive sessions never run there). Admit it to the reapable
485
+ # set under a synthetic uuid group; the type-driven rule downstream
486
+ # still spares claim-holders and newborns, so this can only remove
487
+ # provably-idle husks.
478
488
  if is_probe:
479
489
  stats["unparsed_worker_procs"] += 1
490
+ if len(stats["unparsed_samples"]) < 3:
491
+ stats["unparsed_samples"].append(cmd[:240])
492
+ cwd = cwd_index.get(pid) or ""
493
+ if cwd == S4L_WORKER_CWD or cwd.startswith(S4L_WORKER_CWD + os.sep):
494
+ procs.append({
495
+ "pid": pid,
496
+ "ppid": ppid,
497
+ "age": age,
498
+ "uuid": "cwd-fallback",
499
+ "cmd": cmd,
500
+ "resume_id": None,
501
+ "session_paths": [],
502
+ "scheduled_task_ids": ["probe-cwd-fallback"],
503
+ "metadata_source": "probe_cwd_fallback",
504
+ })
505
+ stats["cwd_fallback_admitted"] += 1
480
506
  continue
481
507
  worker_meta, reason = worker_session_meta(cmd, session_index)
482
508
  if not worker_meta:
@@ -821,6 +847,8 @@ def main() -> int:
821
847
  "worker_probe_seen": stats["worker_probe_seen"],
822
848
  "reapable_workers": stats["reapable_workers"],
823
849
  "unparsed_worker_procs": stats["unparsed_worker_procs"],
850
+ "unparsed_samples": stats["unparsed_samples"],
851
+ "cwd_fallback_admitted": stats["cwd_fallback_admitted"],
824
852
  "metadata_spared_nonworkers": stats["metadata_spared_nonworkers"],
825
853
  "metadata_unknown": stats["metadata_unknown"],
826
854
  "cwd_confirmed_workers": stats["cwd_confirmed_workers"],