@m13v/s4l 1.7.2-rc.6 → 1.7.2-rc.8

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
@@ -2244,7 +2244,17 @@ tool("post_drafts", {
2244
2244
  return;
2245
2245
  }
2246
2246
  c.terminal = true;
2247
- c.terminal_reason = "rejected";
2247
+ // Preserve a more specific reason the menu bar already stamped locally
2248
+ // (store_stamp_decision writes "human_rejected" for a card reject,
2249
+ // discard_all_pending writes "human_discarded_all" for the bulk-discard
2250
+ // button) BEFORE this loopback call ever fires, so by the time it lands
2251
+ // here the local reason is already the more informative one. Only
2252
+ // default to "rejected" when nothing more specific got there first
2253
+ // (e.g. a reject driven straight from chat, with no menu-bar card
2254
+ // involved at all).
2255
+ if (!c.terminal_reason) {
2256
+ c.terminal_reason = "rejected";
2257
+ }
2248
2258
  c.approved = false;
2249
2259
  rejected.push(n);
2250
2260
  });
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.7.2-rc.6",
3
- "installedAt": "2026-07-09T01:53:09.637Z"
2
+ "version": "1.7.2-rc.8",
3
+ "installedAt": "2026-07-09T02:48:04.544Z"
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.7.2-rc.6",
5
+ "version": "1.7.2-rc.8",
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": {
@@ -2930,12 +2930,17 @@ class S4LMenuBar(rumps.App):
2930
2930
  self._alert("Discard failed", str(e)[:200])
2931
2931
  return
2932
2932
  ns = [d.get("n") for d in drafts if d.get("n") is not None]
2933
+ cids = [d.get("candidate_id") for d in drafts if d.get("candidate_id") is not None]
2933
2934
 
2934
2935
  def _persist_discard():
2935
2936
  try:
2936
2937
  st.post_drafts(batch, reject=ns, timeout=60)
2937
2938
  except Exception:
2938
2939
  pass
2940
+ try:
2941
+ st.flip_discarded_candidates_skipped(cids)
2942
+ except Exception:
2943
+ pass
2939
2944
 
2940
2945
  threading.Thread(target=_persist_discard, daemon=True).start()
2941
2946
  try:
@@ -803,6 +803,45 @@ def discard_all_pending(drafts):
803
803
  return _store_update(mutate) or 0
804
804
 
805
805
 
806
+ def flip_discarded_candidates_skipped(candidate_ids):
807
+ """Flip each bulk-discarded candidate's twitter_candidates row to
808
+ status='skipped', skip_reason='human_discarded_all' — the same DB effect a
809
+ normal reject gets for free as a side effect of its review-events insert
810
+ (see review-events/route.ts). The bulk-discard path deliberately never
811
+ ships a review event (that's the whole point — it must not reach the
812
+ feedback digest), so without this direct call the row would stay
813
+ 'pending' until the independent age-based freshness gate happens to expire
814
+ it, wide open to re-discovery/re-drafting of the exact draft a human just
815
+ discarded. One PATCH per candidate via the SAME direct-HTTP path
816
+ flush_review_events already uses (http_api), so this never touches
817
+ review_events. Best-effort: a candidate that already expired/posted by the
818
+ time this runs (404, no longer 'pending') is a no-op, not a failure."""
819
+ if not candidate_ids:
820
+ return
821
+ try:
822
+ from http_api import api_patch
823
+ except Exception as err:
824
+ sys.stderr.write(
825
+ f"[s4l-state] flip_discarded_candidates_skipped: http_api unavailable "
826
+ f"({type(err).__name__}: {err}); {len(candidate_ids)} candidate(s) left 'pending'\n"
827
+ )
828
+ sys.stderr.flush()
829
+ return
830
+ for cid in candidate_ids:
831
+ try:
832
+ api_patch(
833
+ "/api/v1/twitter-candidates/by-id",
834
+ {"id": cid, "action": "mark_skipped", "reason": "human_discarded_all"},
835
+ ok_on_404=True,
836
+ )
837
+ except Exception as err:
838
+ sys.stderr.write(
839
+ f"[s4l-state] flip_discarded_candidates_skipped: PATCH failed for "
840
+ f"candidate_id={cid} ({type(err).__name__}: {err})\n"
841
+ )
842
+ sys.stderr.flush()
843
+
844
+
806
845
  def store_mark_post_failed(batch, n, candidate_id=None, error=None):
807
846
  """A decided post that FAILED surfaces via notification/dashboard, not by
808
847
  re-presenting the card and not by endless resume retries."""
package/mcp/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/s4l-mcp",
3
- "version": "1.7.2-rc.6",
3
+ "version": "1.7.2-rc.8",
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.7.2-rc.6",
3
+ "version": "1.7.2-rc.8",
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",
@@ -18,10 +18,14 @@ Safe by construction:
18
18
  - Best-effort: any single failure is logged and skipped; never raises.
19
19
 
20
20
  Degradation vs a normal cycle: salvaged candidates skip the cycle's post-provider
21
- top-N selection (so MORE cards, which is fine) and lack the tail-link / experiments
22
- arm stamp that run-twitter-cycle.sh's plan writer adds after the provider returns.
23
- The reply text itself is complete. A salvaged card is strictly better than a lost
24
- draft.
21
+ top-N selection (so MORE cards, which is fine), lack the tail-link / experiments
22
+ arm stamp that run-twitter-cycle.sh's plan writer adds after the provider returns,
23
+ and (two-draft schema only) lack assigned_style/assigned_mode, which live in the
24
+ cycle's shell variables, not the model output. The reply text itself IS complete
25
+ end-to-end (_mirror_two_draft_fields backfills reply_text/drafts from
26
+ draft_a_text/draft_b_text for the post-2026-07-07/08 two-draft schema, since the
27
+ model output alone has no reply_text field to check for completeness). A salvaged
28
+ card is strictly better than a lost draft.
25
29
 
26
30
  Usage:
27
31
  python3 scripts/salvage_orphaned_prep_results.py # automated (safe age gate)
@@ -59,6 +63,52 @@ except Exception: # standalone fallbacks
59
63
  pass
60
64
 
61
65
 
66
+ def _mirror_two_draft_fields(candidates):
67
+ """Backfill reply_text/drafts for two-draft-schema candidates (2026-07-07/08
68
+ redesign) that reach salvage. The normal cycle path (run-twitter-cycle.sh)
69
+ mirrors draft_a_text onto reply_text/engagement_style/drafts right after the
70
+ model returns, but salvage bypasses that shell-side step entirely, so an
71
+ orphaned post-redesign result reached review cards with NEITHER field set.
72
+ The menubar card (s4l_card.py) reads d.get("drafts") first, then falls back
73
+ to d.get("reply_text") or "", so those cards rendered the thread with a
74
+ completely empty editable reply box despite draft_a_text/draft_b_text
75
+ holding real, already-drafted content (root-caused 2026-07-09 via
76
+ candidate 374925 and 4 siblings, all missing 'experiments' too, confirming
77
+ they came through this salvage path rather than a normal cycle write).
78
+
79
+ assigned_style/assigned_mode are deliberately left OUT (not set to None,
80
+ just absent): the picker's per-cycle style assignment lives only in
81
+ run-twitter-cycle.sh's shell variables, not in the model's JSON output, so
82
+ it can't be recovered here. twitter_post_plan.py already has a documented
83
+ fallback for that ("assigned_mode key absent" -> use the plan-level
84
+ assignment, itself None for a salvaged plan), so leaving the keys out is
85
+ the safe, already-supported degradation, same class as the existing
86
+ no-experiments-stamp degradation.
87
+ """
88
+ for c in candidates:
89
+ if not isinstance(c, dict) or "draft_a_text" not in c or "reply_text" in c:
90
+ continue
91
+ c["reply_text"] = c.get("draft_a_text") or ""
92
+ c["engagement_style"] = c.get("draft_a_style") or ""
93
+ c["new_style"] = c.get("draft_a_new_style")
94
+ if c.get("draft_a_text_en"):
95
+ c["reply_text_en"] = c["draft_a_text_en"]
96
+ draft_b_text = c.get("draft_b_text")
97
+ if not c.get("is_reused_draft") and draft_b_text:
98
+ c["drafts"] = [
99
+ {
100
+ "variant": "a", "text": c.get("draft_a_text") or "",
101
+ "style": c.get("draft_a_style") or "",
102
+ "text_en": c.get("draft_a_text_en"),
103
+ },
104
+ {
105
+ "variant": "b", "text": draft_b_text,
106
+ "style": c.get("draft_b_style") or "",
107
+ "text_en": c.get("draft_b_text_en"),
108
+ },
109
+ ]
110
+
111
+
62
112
  def _is_prep_result(obj):
63
113
  """True iff obj looks like a twitter-prep result (drafted candidates).
64
114
 
@@ -142,6 +192,7 @@ def main():
142
192
  pass
143
193
  continue
144
194
 
195
+ _mirror_two_draft_fields(obj["candidates"])
145
196
  n = len(obj["candidates"])
146
197
  age_min = (now - st.st_mtime) / 60.0
147
198
  _plog(f"[salvage] ORPHAN prep result job {job_id}: producer never consumed it "