@m13v/s4l 1.7.9-rc.2 → 1.7.10-rc.1

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.
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.7.9-rc.2",
3
- "installedAt": "2026-08-09T00:22:23.419Z"
2
+ "version": "1.7.10-rc.1",
3
+ "installedAt": "2026-08-11T03:23:51.302Z"
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.9-rc.2",
5
+ "version": "1.7.10-rc.1",
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": {
@@ -10,14 +10,17 @@
10
10
  "email": "i@m13v.com",
11
11
  "url": "https://s4l.ai"
12
12
  },
13
+ "compatibility": {
14
+ "platforms": [
15
+ "darwin"
16
+ ]
17
+ },
13
18
  "server": {
14
19
  "type": "node",
15
20
  "entry_point": "dist/index.js",
16
21
  "mcp_config": {
17
- "command": "${__dirname}/vendor/node-darwin-arm64/bin/node",
18
- "args": [
19
- "${__dirname}/dist/index.js"
20
- ],
22
+ "command": "${__dirname}/launch.js",
23
+ "args": [],
21
24
  "env": {
22
25
  "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
23
26
  }
@@ -158,14 +158,12 @@ class _Worker(threading.Thread):
158
158
  # unaffected (CDP is offscreen-raster + synthetic input; the occlusion
159
159
  # flags keep hidden tabs painting).
160
160
  # DEFAULT ON (user decision 2026-08-07, reverses the 2026-07-30 default-off
161
- # call): the guard hides an offscreen harness that steals the foreground
162
- # unless explicitly opted out. Two knobs, by design:
163
- # S4L_NO_HARNESS_HIDE -> HARD override, force off, checked FIRST so it
164
- # always wins (this is the one-time interactive-login escape hatch).
165
- # S4L_HARNESS_HIDE=0 -> SOFT opt-out for a machine that wants it off.
166
- # Unset or any non-"0" value => hide is active (the new default).
167
- if os.environ.get("S4L_NO_HARNESS_HIDE"):
168
- return
161
+ # call). ONE flag by design (2026-08-08 — the old S4L_NO_HARNESS_HIDE
162
+ # override was removed to end the double-flag confusion):
163
+ # S4L_HARNESS_HIDE unset / any value except "0" => hide active (default)
164
+ # S4L_HARNESS_HIDE=0 => disabled — the single
165
+ # off switch (e.g. to keep a harness window visible for a one-time
166
+ # interactive login, then set it back to 1 / unset it).
169
167
  if os.environ.get("S4L_HARNESS_HIDE", "1") == "0":
170
168
  return
171
169
  pos = details.get("window_position") or ""
package/mcp/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/s4l-mcp",
3
- "version": "1.7.9-rc.2",
3
+ "version": "1.7.10-rc.1",
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.9-rc.2",
3
+ "version": "1.7.10-rc.1",
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",
@@ -16,8 +16,14 @@ docs/codex-port-design.md):
16
16
  (_run_codex_exec; gpt-5.6-sol default, schema rides
17
17
  the prompt — OpenAI strict schema mode rejects our
18
18
  lenient schemas).
19
-
20
- All three return byte-identical claude `--output-format json` envelopes and
19
+ gemini-api answer inline via the Gemini generateContent REST API
20
+ (_run_gemini_api; gemini-pro-latest default with a
21
+ one-shot flash downgrade on 404, schema rides the
22
+ prompt for the same lenient-schema reason). The
23
+ hosted-lane provider: key-authenticated, no local
24
+ app, runs headless on Linux.
25
+
26
+ All four return byte-identical claude `--output-format json` envelopes and
21
27
  the same 0/1/79 exit semantics, so callers can't tell them apart. The queue
22
28
  machinery below (next/result, worker notes, heartbeats) only runs for the
23
29
  default provider; the inline providers skip it entirely, which also means no
@@ -897,6 +903,160 @@ def _run_codex_exec(ns, qtype: str, prompt: str, schema_text: str | None) -> int
897
903
  _disarm_deathwatch(job_id)
898
904
 
899
905
 
906
+ def _run_gemini_api(ns, qtype: str, prompt: str, schema_text: str | None) -> int:
907
+ """gemini-api provider: answer the turn inline via the Gemini
908
+ generateContent REST API. Key-authenticated, fully headless: this is the
909
+ hosted-lane provider (no Claude Desktop, no ChatGPT app, runs on Linux).
910
+ Same envelope, same 0/1/79 exit semantics as the other inline providers.
911
+
912
+ Schema rides the prompt (not responseSchema): Gemini's structured-output
913
+ schema dialect is an OpenAPI subset that rejects parts of our lenient
914
+ claude-style schemas, so _validate_against_schema stays the single gate,
915
+ matching the codex-exec precedent. responseMimeType application/json still
916
+ forces bare-JSON output for schema'd jobs; schemaless jobs (link-tail)
917
+ stay plain text.
918
+ """
919
+ import urllib.error
920
+ import urllib.request
921
+
922
+ key = draft_provider.gemini_api_key()
923
+ if not key:
924
+ _plog(f"gemini-api provider active but no GEMINI_API_KEY / keychain gemini-api-key; failing {qtype}")
925
+ return 1
926
+
927
+ batch = (os.environ.get("BATCH_ID") or os.environ.get("SA_CYCLE_ID") or "-").strip() or "-"
928
+ job_id = uuid.uuid4().hex
929
+ _arm_deathwatch(job_id, qtype, batch)
930
+ _act_write(qtype)
931
+ try:
932
+ if schema_text:
933
+ prompt = (
934
+ f"{prompt}\n\n"
935
+ "FINAL ANSWER FORMAT: reply with ONLY a JSON value matching this "
936
+ "JSON Schema. No prose, no markdown fences, nothing else:\n"
937
+ f"{schema_text}"
938
+ )
939
+ # Model default mirrors codex-exec's probe-by-use pattern: try the pro
940
+ # alias first (drafting quality is the product), downgrade ONCE to the
941
+ # flash alias on a model-not-found 404 and log it loudly. The -latest
942
+ # aliases are Google-maintained so this never pins a dead model id.
943
+ model = os.environ.get("S4L_GEMINI_MODEL", "").strip() or "gemini-pro-latest"
944
+ fallback_model = "gemini-flash-latest"
945
+ gen_config = {"temperature": 0.7, "maxOutputTokens": 16384}
946
+ if schema_text:
947
+ gen_config["responseMimeType"] = "application/json"
948
+ body = json.dumps(
949
+ {
950
+ "contents": [{"role": "user", "parts": [{"text": prompt}]}],
951
+ "generationConfig": gen_config,
952
+ }
953
+ ).encode()
954
+
955
+ budget = max(60, ns.timeout - 60)
956
+ _plog(f"gemini-api start {qtype} job {job_id} batch={batch} model={model} timeout={budget}s")
957
+ started = time.time()
958
+ resp_obj = None
959
+ for attempt_model in (model, fallback_model if fallback_model != model else None):
960
+ if not attempt_model:
961
+ break
962
+ url = (
963
+ "https://generativelanguage.googleapis.com/v1beta/models/"
964
+ f"{attempt_model}:generateContent"
965
+ )
966
+ req = urllib.request.Request(
967
+ url,
968
+ data=body,
969
+ headers={"Content-Type": "application/json", "x-goog-api-key": key},
970
+ method="POST",
971
+ )
972
+ try:
973
+ with urllib.request.urlopen(
974
+ req, timeout=max(60, budget - int(time.time() - started))
975
+ ) as resp:
976
+ resp_obj = json.loads(resp.read().decode())
977
+ break
978
+ except urllib.error.HTTPError as e:
979
+ tail = ""
980
+ try:
981
+ tail = e.read().decode()[-400:]
982
+ except Exception:
983
+ pass
984
+ if e.code == 404 and attempt_model == model:
985
+ _plog(
986
+ f"gemini-api model {attempt_model} not found (404); "
987
+ f"retrying job {job_id} with {fallback_model}"
988
+ )
989
+ continue
990
+ _act_clear()
991
+ _plog(f"gemini-api HTTP {e.code} on job {job_id} ({qtype}); tail: {tail}")
992
+ return 1
993
+ except TimeoutError:
994
+ _act_clear()
995
+ _plog(f"gemini-api timed out after {budget}s on job {job_id} ({qtype})")
996
+ return 79 # mirror the queue path's "blocked, skip cleanly"
997
+ except Exception as e:
998
+ _act_clear()
999
+ _plog(f"gemini-api request failed on job {job_id} ({qtype}): {e}")
1000
+ return 1
1001
+ if resp_obj is None:
1002
+ _act_clear()
1003
+ _plog(f"gemini-api no response on job {job_id} ({qtype})")
1004
+ return 1
1005
+
1006
+ try:
1007
+ cand = resp_obj["candidates"][0]
1008
+ text = "".join(
1009
+ p.get("text", "") for p in cand.get("content", {}).get("parts", [])
1010
+ ).strip()
1011
+ finish = cand.get("finishReason", "?")
1012
+ except (KeyError, IndexError, TypeError):
1013
+ _act_clear()
1014
+ block = (resp_obj.get("promptFeedback") or {}).get("blockReason", "?")
1015
+ _plog(f"gemini-api no candidates on job {job_id} ({qtype}); blockReason={block}")
1016
+ return 1
1017
+ if not text:
1018
+ _act_clear()
1019
+ _plog(f"gemini-api empty answer on job {job_id} ({qtype}); finishReason={finish}")
1020
+ return 1
1021
+
1022
+ # Same lenient parse as codex-exec: JSON when it parses, fenced JSON
1023
+ # unwrapped, otherwise the raw text as a plain string (link-tail jobs).
1024
+ obj = None
1025
+ parsed = False
1026
+ for candidate in (text, re.sub(r"^```(?:json)?\s*|\s*```$", "", text).strip()):
1027
+ try:
1028
+ obj = json.loads(candidate)
1029
+ parsed = True
1030
+ break
1031
+ except Exception:
1032
+ continue
1033
+ if not parsed:
1034
+ obj = text
1035
+
1036
+ err = _validate_against_schema(obj, schema_text)
1037
+ if err:
1038
+ _act_clear()
1039
+ _plog(f"gemini-api result rejected for job {job_id} ({qtype}): {err}")
1040
+ return 1
1041
+
1042
+ _emit_envelope(obj)
1043
+ _mark_drain_success()
1044
+ _stamp_heartbeat("gemini-api", qtype)
1045
+ usage = resp_obj.get("usageMetadata") or {}
1046
+ tokens = usage.get("totalTokenCount", "?")
1047
+ try:
1048
+ _ncand = len(obj.get("candidates")) if isinstance(obj, dict) and isinstance(obj.get("candidates"), list) else "?"
1049
+ except Exception:
1050
+ _ncand = "?"
1051
+ _plog(
1052
+ f"gemini-api done job {job_id} batch={batch} ({qtype}) in {int(time.time() - started)}s "
1053
+ f"tokens={tokens} finish={finish}; {_ncand} candidates -> producer assembles the plan"
1054
+ )
1055
+ return 0
1056
+ finally:
1057
+ _disarm_deathwatch(job_id)
1058
+
1059
+
900
1060
  def _run_claude_p(ns, qtype: str, prompt: str, schema_text: str | None) -> int:
901
1061
  """claude-p provider: answer the turn inline via the real `claude -p`
902
1062
  (Claude Code CLI, subscription-authenticated). No queue, no worker, no
@@ -999,6 +1159,8 @@ def cmd_provider(ns) -> int:
999
1159
  return _run_codex_exec(ns, qtype, prompt, schema_text)
1000
1160
  if _prov == "claude-p":
1001
1161
  return _run_claude_p(ns, qtype, prompt, schema_text)
1162
+ if _prov == "gemini-api":
1163
+ return _run_gemini_api(ns, qtype, prompt, schema_text)
1002
1164
 
1003
1165
  job_id = uuid.uuid4().hex
1004
1166
  created = time.time()
@@ -18,6 +18,11 @@ Providers:
18
18
  (headless, subscription-authenticated). Requires the
19
19
  ChatGPT app installed and logged in. No queue, no
20
20
  worker, no app-open requirement.
21
+ gemini-api answer inline via the Gemini generateContent REST API
22
+ (key-authenticated, no local app at all). The hosted
23
+ lane's provider: works headless on any Linux box.
24
+ Key: $GEMINI_API_KEY, else macOS keychain
25
+ `gemini-api-key`.
21
26
 
22
27
  CLI:
23
28
  python3 scripts/draft_provider.py get -> prints the active provider
@@ -32,7 +37,7 @@ import os
32
37
  import sys
33
38
  import time
34
39
 
35
- VALID_PROVIDERS = ("claude-desktop-queue", "claude-p", "codex-exec")
40
+ VALID_PROVIDERS = ("claude-desktop-queue", "claude-p", "codex-exec", "gemini-api")
36
41
  DEFAULT_PROVIDER = "claude-desktop-queue"
37
42
 
38
43
  # The npm @openai/codex install is unreliable on macOS (XProtect false-positives
@@ -89,6 +94,27 @@ def codex_bin() -> str | None:
89
94
  return None
90
95
 
91
96
 
97
+ def gemini_api_key() -> str | None:
98
+ """Resolved Gemini API key, or None. Env wins (the hosted/Linux path);
99
+ macOS keychain `gemini-api-key` is the operator-Mac fallback."""
100
+ key = os.environ.get("GEMINI_API_KEY", "").strip()
101
+ if key:
102
+ return key
103
+ try:
104
+ import subprocess
105
+
106
+ out = subprocess.run(
107
+ ["security", "find-generic-password", "-s", "gemini-api-key", "-w"],
108
+ capture_output=True,
109
+ text=True,
110
+ timeout=10,
111
+ )
112
+ key = (out.stdout or "").strip()
113
+ return key or None
114
+ except Exception:
115
+ return None
116
+
117
+
92
118
  def main() -> int:
93
119
  if len(sys.argv) < 2 or sys.argv[1] not in ("get", "set", "codex-bin"):
94
120
  print(__doc__, file=sys.stderr)
@@ -32,7 +32,12 @@ log() { echo "[s4l-install] $*"; }
32
32
  die() { echo "[s4l-install] ERROR: $*" >&2; exit 1; }
33
33
 
34
34
  [ "$(uname -s)" = "Darwin" ] || die "macOS only for now."
35
- [ "$(uname -m)" = "arm64" ] || die "Apple Silicon only for now (the bundle vendors a darwin-arm64 Node)."
35
+ # The bundle vendors both darwin-arm64 and darwin-x64 Node binaries (1.7.9+);
36
+ # pick the one matching this machine.
37
+ case "$(uname -m)" in
38
+ x86_64|amd64) NODE_ARCH="x64" ;;
39
+ *) NODE_ARCH="arm64" ;;
40
+ esac
36
41
 
37
42
  URL="$STABLE_URL"
38
43
  [ "${S4L_CHANNEL:-}" = "staging" ] && URL="$STAGING_URL"
@@ -45,7 +50,9 @@ log "downloading $URL"
45
50
  mkdir -p "$TMP/app"
46
51
  /usr/bin/unzip -q "$TMP/s4l.mcpb" -d "$TMP/app" || die "unzip failed"
47
52
  [ -f "$TMP/app/dist/index.js" ] || die "bundle missing dist/index.js (bad download?)"
48
- [ -x "$TMP/app/vendor/node-darwin-arm64/bin/node" ] || die "bundle missing vendored node"
53
+ # Older bundles (pre-1.7.9) only vendor arm64; accept either so a staging box
54
+ # pinned to an old release still installs on Apple Silicon.
55
+ [ -x "$TMP/app/vendor/node-darwin-$NODE_ARCH/bin/node" ] || [ -x "$TMP/app/vendor/node-darwin-arm64/bin/node" ] || die "bundle missing vendored node for $NODE_ARCH"
49
56
 
50
57
  mkdir -p "$STATE_DIR"
51
58
  rm -rf "$APP_DIR.new"
@@ -55,7 +62,8 @@ mv "$APP_DIR.new" "$APP_DIR"
55
62
  rm -rf "$APP_DIR.old"
56
63
  log "installed bundle to $APP_DIR"
57
64
 
58
- NODE="$APP_DIR/vendor/node-darwin-arm64/bin/node"
65
+ NODE="$APP_DIR/vendor/node-darwin-$NODE_ARCH/bin/node"
66
+ [ -x "$NODE" ] || NODE="$APP_DIR/vendor/node-darwin-arm64/bin/node"
59
67
  SERVER="$APP_DIR/dist/index.js"
60
68
  SAFE_PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
61
69