@m13v/s4l 1.6.199 → 1.6.201
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 +63 -0
- package/mcp/dist/version.json +2 -2
- package/mcp/manifest.json +1 -1
- package/mcp/package.json +1 -1
- package/package.json +1 -1
- package/scripts/autopilot_stall_watch.py +3 -1
- package/scripts/memory_snapshot.py +31 -0
- package/scripts/reap_stale_claude_sessions.py +38 -10
- package/scripts/scheduled_tasks_snapshot.py +16 -2
- package/scripts/snapshot.py +16 -2
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) {
|
package/mcp/dist/version.json
CHANGED
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.
|
|
5
|
+
"version": "1.6.201",
|
|
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.
|
|
3
|
+
"version": "1.6.201",
|
|
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
|
@@ -57,7 +57,9 @@ RUNNING_STALL_SECONDS = 900
|
|
|
57
57
|
# At StartInterval 120 that is ~6 min of continuous stall.
|
|
58
58
|
ALERT_AFTER = 3
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
# Includes the current universal worker id; legacy phase pair kept for old
|
|
61
|
+
# installs (same stale-checker drift fix as scheduled_tasks_snapshot.py, 2026-07-03).
|
|
62
|
+
WORKER_TASK_IDS = ("s4l-worker", "saps-worker", "saps-phase1-query", "saps-phase2b-draft")
|
|
61
63
|
|
|
62
64
|
|
|
63
65
|
def _state_dir() -> str:
|
|
@@ -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
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
if
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
#
|
|
477
|
-
#
|
|
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"],
|
|
@@ -27,7 +27,15 @@ import os
|
|
|
27
27
|
import sys
|
|
28
28
|
|
|
29
29
|
# --- Kept in sync with mcp/menubar/s4l_menubar.py ---------------------------
|
|
30
|
-
|
|
30
|
+
# Current installs run ONE universal worker task (s4l-worker). The phase pair
|
|
31
|
+
# is the retired legacy shape kept only so old installs still report. Checking
|
|
32
|
+
# ONLY the legacy names made every current install scream
|
|
33
|
+
# missing_worker_tasks=[saps-phase1-query, saps-phase2b-draft] forever while
|
|
34
|
+
# the real s4l-worker task fired every minute and wasn't even LISTED (Karol,
|
|
35
|
+
# 2026-07-03 — this false alarm derailed the whole onboarding investigation).
|
|
36
|
+
WORKER_TASK_IDS = ("s4l-worker", "saps-worker", "saps-phase1-query", "saps-phase2b-draft")
|
|
37
|
+
CURRENT_WORKER_TASK_IDS = ("s4l-worker", "saps-worker")
|
|
38
|
+
LEGACY_WORKER_TASK_IDS = ("saps-phase1-query", "saps-phase2b-draft")
|
|
31
39
|
DEPRECATED_TASK_IDS = ("social-autoposter-autopilot",)
|
|
32
40
|
WORKER_CWD = os.path.join(os.path.expanduser("~"), ".s4l-worker")
|
|
33
41
|
# "Claude*": the host app can run with a custom --user-data-dir (per-account
|
|
@@ -88,11 +96,17 @@ def build_summary() -> dict:
|
|
|
88
96
|
})
|
|
89
97
|
|
|
90
98
|
mislocated = sum(1 for t in tasks if not t["in_worker_dir"])
|
|
99
|
+
# "Missing" means NO viable worker lane at all: neither a current universal
|
|
100
|
+
# task nor the complete legacy pair. Naming every absent id was wrong once
|
|
101
|
+
# the id set spanned generations (a healthy current install always "misses"
|
|
102
|
+
# the legacy pair and vice versa).
|
|
103
|
+
have_current = bool(seen_ids & set(CURRENT_WORKER_TASK_IDS))
|
|
104
|
+
have_legacy = set(LEGACY_WORKER_TASK_IDS) <= seen_ids
|
|
91
105
|
return {
|
|
92
106
|
"worker_dir_tail": _cwd_tail(WORKER_CWD),
|
|
93
107
|
"registries": registries,
|
|
94
108
|
"worker_tasks": len(tasks),
|
|
95
|
-
"missing_worker_tasks":
|
|
109
|
+
"missing_worker_tasks": [] if (have_current or have_legacy) else ["s4l-worker"],
|
|
96
110
|
"mislocated": mislocated,
|
|
97
111
|
# all_in_worker_dir is False when there are zero worker tasks too, since
|
|
98
112
|
# "no autopilot registered" is itself a state worth seeing centrally.
|
package/scripts/snapshot.py
CHANGED
|
@@ -62,7 +62,13 @@ REQUIRED_FIELDS = ["name", "website", "description", "icp", "voice", "search_top
|
|
|
62
62
|
# only setup can NEVER report setup_complete (any_ready requires a managed product),
|
|
63
63
|
# leaving the menu bar stuck on "project not set up". (2026-06-30)
|
|
64
64
|
PERSONA_REQUIRED_FIELDS = ["name", "description", "voice", "search_topics"]
|
|
65
|
-
|
|
65
|
+
# Current installs run ONE universal worker task (s4l-worker); the phase pair
|
|
66
|
+
# is the retired legacy shape. Checking ONLY the legacy pair made every current
|
|
67
|
+
# install read "autopilot off" forever (Karol, 2026-07-03: worker fired every
|
|
68
|
+
# minute while this check reported the tasks missing). Keep in sync with
|
|
69
|
+
# scripts/schedule_state.py and mcp/menubar/s4l_menubar.py.
|
|
70
|
+
CURRENT_WORKER_TASK_IDS = ("s4l-worker", "saps-worker")
|
|
71
|
+
LEGACY_WORKER_TASK_IDS = ("saps-phase1-query", "saps-phase2b-draft")
|
|
66
72
|
UPDATER_LABEL = "com.m13v.social-autoposter-update"
|
|
67
73
|
AUTOPILOT_STALL_MS = 180_000
|
|
68
74
|
|
|
@@ -179,7 +185,15 @@ def _mode_chosen() -> bool:
|
|
|
179
185
|
def _autopilot_on() -> bool:
|
|
180
186
|
base = os.path.join(_claude_cfg_dir(), "scheduled-tasks")
|
|
181
187
|
try:
|
|
182
|
-
|
|
188
|
+
if any(
|
|
189
|
+
os.path.exists(os.path.join(base, t, "SKILL.md"))
|
|
190
|
+
for t in CURRENT_WORKER_TASK_IDS
|
|
191
|
+
):
|
|
192
|
+
return True
|
|
193
|
+
return all(
|
|
194
|
+
os.path.exists(os.path.join(base, t, "SKILL.md"))
|
|
195
|
+
for t in LEGACY_WORKER_TASK_IDS
|
|
196
|
+
)
|
|
183
197
|
except Exception:
|
|
184
198
|
return False
|
|
185
199
|
|