@m13v/s4l 1.7.6-rc.18 → 1.7.6-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.
- package/mcp/dist/index.js +60 -237
- package/mcp/dist/telemetry.js +1 -2
- package/mcp/dist/version.json +2 -2
- package/mcp/manifest.json +1 -1
- package/mcp/menubar/s4l_card.py +18 -144
- package/mcp/menubar/s4l_card_canvas.py +14 -135
- package/mcp/menubar/s4l_menubar.py +73 -216
- package/mcp/menubar/s4l_state.py +130 -45
- package/mcp/package.json +1 -1
- package/package.json +1 -1
- package/scripts/autopilot_stall_watch.py +1 -8
- package/scripts/cdp_ready_check.py +50 -81
- package/scripts/draft_prompt_core.py +17 -104
- package/scripts/engagement_styles.py +98 -88
- package/scripts/merge_review_queue.py +129 -192
- package/scripts/platform_strike_events.py +5 -54
- package/scripts/post_reddit.py +0 -10
- package/scripts/reap_stale_claude_sessions.py +6 -7
- package/scripts/release-mcpb.sh +7 -38
- package/scripts/setup_twitter_auth.py +1 -14
- package/scripts/strike_alert.py +12 -161
- package/scripts/top_performers.py +0 -24
- package/skill/archive-old-logs.sh +0 -24
- package/skill/lib/reddit-backend.sh +0 -1
- package/skill/run-twitter-cycle.sh +66 -169
- package/scripts/preview_reddit_card.py +0 -38
- package/scripts/reddit_ban_check.py +0 -220
- package/scripts/store_patch.py +0 -111
- package/scripts/test_stall_watch_batch_progression.py +0 -99
package/mcp/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { screencast, bringBrowserToFront } from "./screencast.js";
|
|
|
19
19
|
import os from "node:os";
|
|
20
20
|
import path from "node:path";
|
|
21
21
|
import fs from "node:fs";
|
|
22
|
-
import { repoDir, runPython, run, readPlan, writePlan, planPath,
|
|
22
|
+
import { repoDir, runPython, run, readPlan, writePlan, planPath, } from "./repo.js";
|
|
23
23
|
import { applySetup, resolveProject, hasReadyProject, personaReady, listManagedProjectStatus, listProjectSettings, ensureShortLinksDefault, ensurePersonaProject, findPersonaProject, REQUIRED_FIELDS, RECOMMENDED_FIELDS, configPath, ensureConfigInStateDir, normalizeStringList, recordRedditAccount, } from "./setup.js";
|
|
24
24
|
import { xStatus, xConnect, xDetectSources, xScanProfile, summarizeXAuth } from "./twitterAuth.js";
|
|
25
25
|
import { redditStatus, redditConnect, redditDetectSources, summarizeRedditAuth, } from "./redditAuth.js";
|
|
@@ -909,57 +909,12 @@ async function ensureTwitterBrowserForPost() {
|
|
|
909
909
|
// thread still exists. Without this override, a card approved while (or just
|
|
910
910
|
// before) the sync stamped it is refused as already-decided and the approval
|
|
911
911
|
// silently no-ops (2 of 3 approvals lost on 2026-07-10).
|
|
912
|
-
// Give-up bound for approved cards whose post attempts keep failing
|
|
913
|
-
// transiently (browser lock contention, timeouts). 5 attempts spans several
|
|
914
|
-
// drain cycles — plenty for genuine transients to clear — while guaranteeing
|
|
915
|
-
// no card can retry forever (2026-07-17 zombie-card incident).
|
|
916
|
-
const MAX_POST_ATTEMPTS = 5;
|
|
917
912
|
function expiredStampOverridable(c) {
|
|
918
913
|
return (c.terminal === true &&
|
|
919
914
|
c.posted !== true &&
|
|
920
915
|
c.discard_reason === "backend_status_expired");
|
|
921
916
|
}
|
|
922
|
-
|
|
923
|
-
// carry experiments.sandbox=true; older sandbox rows predate that stamp but all
|
|
924
|
-
// use the synthetic >=900,000,000 id range twitter_prompt_sandbox.py assigns.
|
|
925
|
-
function isSandboxCandidate(c) {
|
|
926
|
-
const exps = c.experiments;
|
|
927
|
-
if (exps && typeof exps === "object" && exps.sandbox)
|
|
928
|
-
return true;
|
|
929
|
-
const id = Number(c.candidate_id);
|
|
930
|
-
return Number.isFinite(id) && id >= 900_000_000;
|
|
931
|
-
}
|
|
932
|
-
// Write field patches into the review-queue store UNDER ITS LOCK by shelling
|
|
933
|
-
// to scripts/store_patch.py, which takes the same fcntl.flock the menubar's
|
|
934
|
-
// _store_update and merge_review_queue.py hold around their read-modify-write.
|
|
935
|
-
// Node has no native flock, and this process writing the store directly was
|
|
936
|
-
// the last unlocked writer (the race that erased posted stamps on 2026-07-17).
|
|
937
|
-
// Returns false on any failure so callers can fall back to the legacy write.
|
|
938
|
-
async function patchReviewStore(patches) {
|
|
939
|
-
if (!patches.length)
|
|
940
|
-
return true;
|
|
941
|
-
const tmp = path.join(TMP_DIR, `s4l-store-patches-${process.pid}-${Date.now()}.json`);
|
|
942
|
-
try {
|
|
943
|
-
fs.writeFileSync(tmp, JSON.stringify({ patches }), "utf-8");
|
|
944
|
-
const res = await runPython("scripts/store_patch.py", [tmp], {
|
|
945
|
-
timeoutMs: 30_000,
|
|
946
|
-
env: { S4L_REPO_DIR: repoDir(), PATH: pipelinePath() },
|
|
947
|
-
});
|
|
948
|
-
return res.code === 0;
|
|
949
|
-
}
|
|
950
|
-
catch {
|
|
951
|
-
return false;
|
|
952
|
-
}
|
|
953
|
-
finally {
|
|
954
|
-
try {
|
|
955
|
-
fs.unlinkSync(tmp);
|
|
956
|
-
}
|
|
957
|
-
catch {
|
|
958
|
-
/* best effort */
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
async function mergeApprovedStampsIntoStore(batchId, plan, stamped) {
|
|
917
|
+
function mergeApprovedStampsIntoStore(batchId, plan, stamped) {
|
|
963
918
|
// Merge posted/terminal stamps into a FRESH read of the store instead of
|
|
964
919
|
// rewriting the whole plan from the copy taken minutes ago. The old
|
|
965
920
|
// whole-file write was last-writer-wins: while a batch posted, the menubar
|
|
@@ -971,106 +926,28 @@ async function mergeApprovedStampsIntoStore(batchId, plan, stamped) {
|
|
|
971
926
|
// overwrites a fresh `posted=true`. Fallback: candidates without a
|
|
972
927
|
// candidate_id can't be matched into the fresh copy, so keep the legacy
|
|
973
928
|
// whole-plan write for those older plans.
|
|
974
|
-
//
|
|
975
|
-
// Review-queue store: go through the LOCKED patch path (store_patch.py)
|
|
976
|
-
// first. The fresh-read merge below closes most of the race window but not
|
|
977
|
-
// all of it — a menubar decision landing between our readPlan and writePlan
|
|
978
|
-
// still gets erased. The locked path holds the store's flock for the whole
|
|
979
|
-
// read-mutate-replace, applies to every sibling row sharing a candidate_id,
|
|
980
|
-
// and enforces the same posted-sticky rules. Legacy path stays as the
|
|
981
|
-
// fallback and for per-batch /tmp plans (single writer, no lock needed).
|
|
982
|
-
try {
|
|
983
|
-
const mergeableForPatch = stamped.every((c) => c.candidate_id !== undefined && c.candidate_id !== null);
|
|
984
|
-
if (batchId === REVIEW_QUEUE_ID && mergeableForPatch) {
|
|
985
|
-
const patches = stamped.map((c) => {
|
|
986
|
-
const set = {};
|
|
987
|
-
const unset = [];
|
|
988
|
-
if (c.posted === true) {
|
|
989
|
-
set.posted = true;
|
|
990
|
-
set.terminal = false;
|
|
991
|
-
if (c.our_url)
|
|
992
|
-
set.our_url = c.our_url;
|
|
993
|
-
// Clear a stale failure stamp too: the menubar's per-card call can
|
|
994
|
-
// see posted=0 (the batch drain posted it under a different call)
|
|
995
|
-
// and stamp post_failed on a card that IS live (seen on 565462,
|
|
996
|
-
// 2026-07-17). posted is the settled truth; the residue just adds a
|
|
997
|
-
// false "didn't post" signal to dashboards/notifications.
|
|
998
|
-
unset.push("discard_reason", "post_failed", "post_error");
|
|
999
|
-
}
|
|
1000
|
-
else if (c.terminal === true) {
|
|
1001
|
-
set.terminal = true;
|
|
1002
|
-
set.terminal_reason = c.terminal_reason ?? null;
|
|
1003
|
-
// See the zombie-card note in the legacy branch below: a terminal
|
|
1004
|
-
// from a real post attempt must clear the overridable expiry stamp.
|
|
1005
|
-
unset.push("discard_reason");
|
|
1006
|
-
}
|
|
1007
|
-
if (typeof c.post_attempts === "number")
|
|
1008
|
-
set.post_attempts = c.post_attempts;
|
|
1009
|
-
return { candidate_id: c.candidate_id, set, unset };
|
|
1010
|
-
});
|
|
1011
|
-
if (await patchReviewStore(patches))
|
|
1012
|
-
return;
|
|
1013
|
-
console.error("[post] store_patch.py failed; falling back to unlocked stamp merge");
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
catch {
|
|
1017
|
-
/* fall through to the legacy write */
|
|
1018
|
-
}
|
|
1019
929
|
try {
|
|
1020
930
|
const mergeable = stamped.every((c) => c.candidate_id !== undefined && c.candidate_id !== null);
|
|
1021
931
|
const fresh = mergeable ? readPlan(batchId) : null;
|
|
1022
932
|
if (fresh && Array.isArray(fresh.candidates)) {
|
|
1023
|
-
// candidate_id is NOT unique in the review-queue store: sandbox reruns
|
|
1024
|
-
// and re-merged drafts append sibling rows with the same id. Stamping
|
|
1025
|
-
// only one sibling (the old Map single-slot) left the others matching
|
|
1026
|
-
// the drain's approved && !posted && !terminal filter, so the backlog
|
|
1027
|
-
// re-drained the same candidate every heartbeat forever (2026-07-17
|
|
1028
|
-
// incident: 23-card loop at 60s cadence). Stamp EVERY row with the id.
|
|
1029
933
|
const freshById = new Map();
|
|
1030
934
|
fresh.candidates.forEach((c) => {
|
|
1031
|
-
if (c.candidate_id !== undefined && c.candidate_id !== null)
|
|
1032
|
-
|
|
1033
|
-
const list = freshById.get(key);
|
|
1034
|
-
if (list)
|
|
1035
|
-
list.push(c);
|
|
1036
|
-
else
|
|
1037
|
-
freshById.set(key, [c]);
|
|
1038
|
-
}
|
|
935
|
+
if (c.candidate_id !== undefined && c.candidate_id !== null)
|
|
936
|
+
freshById.set(String(c.candidate_id), c);
|
|
1039
937
|
});
|
|
1040
938
|
for (const c of stamped) {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
delete f.post_error;
|
|
1054
|
-
}
|
|
1055
|
-
else if (c.terminal === true && f.posted !== true) {
|
|
1056
|
-
f.terminal = true;
|
|
1057
|
-
f.terminal_reason = c.terminal_reason;
|
|
1058
|
-
// CRITICAL (2026-07-17 Nhat zombie-card incident, 438 retries over
|
|
1059
|
-
// 5 days): a stale discard_reason="backend_status_expired" left on
|
|
1060
|
-
// the fresh copy makes expiredStampOverridable() treat THIS
|
|
1061
|
-
// post-outcome terminal as overridable, so every later drain
|
|
1062
|
-
// resurrects the card, re-posts, dedup-skips, and re-stamps —
|
|
1063
|
-
// forever. A terminal that came from an actual post attempt is
|
|
1064
|
-
// final; delete the expiry stamp so the override can never fire
|
|
1065
|
-
// on it again. (The drain's own `delete c.discard_reason` happens
|
|
1066
|
-
// on an in-memory copy that is never the write source; this line
|
|
1067
|
-
// is the one that persists.)
|
|
1068
|
-
delete f.discard_reason;
|
|
1069
|
-
}
|
|
1070
|
-
// Carry the retry counter so the give-up bound survives across
|
|
1071
|
-
// drains (each drain reads the store fresh).
|
|
1072
|
-
if (typeof c.post_attempts === "number" && c.post_attempts > (f.post_attempts || 0))
|
|
1073
|
-
f.post_attempts = c.post_attempts;
|
|
939
|
+
const f = freshById.get(String(c.candidate_id));
|
|
940
|
+
if (!f)
|
|
941
|
+
continue;
|
|
942
|
+
if (c.posted === true) {
|
|
943
|
+
f.posted = true;
|
|
944
|
+
f.terminal = false;
|
|
945
|
+
if (c.our_url)
|
|
946
|
+
f.our_url = c.our_url;
|
|
947
|
+
}
|
|
948
|
+
else if (c.terminal === true && f.posted !== true) {
|
|
949
|
+
f.terminal = true;
|
|
950
|
+
f.terminal_reason = c.terminal_reason;
|
|
1074
951
|
}
|
|
1075
952
|
}
|
|
1076
953
|
writePlan(batchId, fresh);
|
|
@@ -1166,12 +1043,7 @@ async function postApproved(batchId, plan) {
|
|
|
1166
1043
|
// and the stamp is cleared so every downstream terminal check agrees it's live.
|
|
1167
1044
|
const approved = (plan.candidates || []).filter((c) => c.approved === true &&
|
|
1168
1045
|
c.posted !== true &&
|
|
1169
|
-
(c.terminal !== true || expiredStampOverridable(c))
|
|
1170
|
-
// Prompt-sandbox replays can never post (twitter_post_plan.py post_one()
|
|
1171
|
-
// hard-refuses them), so draining one is pure churn: it burns a browser
|
|
1172
|
-
// lock turn and, if its terminal stamp later loses a store-write race,
|
|
1173
|
-
// loops forever. Exclude them here regardless of stamp state.
|
|
1174
|
-
!isSandboxCandidate(c));
|
|
1046
|
+
(c.terminal !== true || expiredStampOverridable(c)));
|
|
1175
1047
|
for (const c of approved) {
|
|
1176
1048
|
if (c.terminal === true) {
|
|
1177
1049
|
c.terminal = false;
|
|
@@ -1369,7 +1241,7 @@ async function postApproved(batchId, plan) {
|
|
|
1369
1241
|
};
|
|
1370
1242
|
}
|
|
1371
1243
|
if (approvedReddit.length)
|
|
1372
|
-
|
|
1244
|
+
mergeApprovedStampsIntoStore(batchId, plan, approvedReddit);
|
|
1373
1245
|
return {
|
|
1374
1246
|
attempted: approvedReddit.length,
|
|
1375
1247
|
posted: redditPosted,
|
|
@@ -1610,21 +1482,6 @@ async function postApproved(batchId, plan) {
|
|
|
1610
1482
|
// here (found 2026-07-16) silently and permanently discarded 7 real
|
|
1611
1483
|
// approved drafts on nothing worse than lock contention — Reddit's
|
|
1612
1484
|
// equivalent transient failures self-healed on the very next drain.
|
|
1613
|
-
//
|
|
1614
|
-
// BOUNDED (2026-07-17): sticky is right, sticky-forever is not — an
|
|
1615
|
-
// unbounded retry is a zombie generator (one card retried 438 times
|
|
1616
|
-
// over 5 days on the Nhat install). Count the transient failures and
|
|
1617
|
-
// give up loudly after MAX_POST_ATTEMPTS; the terminal_reason keeps
|
|
1618
|
-
// the last failure visible so the give-up is diagnosable, and the
|
|
1619
|
-
// on-disk post-events trail records it for forensics.
|
|
1620
|
-
const attempts = (typeof c.post_attempts === "number" ? c.post_attempts : 0) + 1;
|
|
1621
|
-
c.post_attempts = attempts;
|
|
1622
|
-
if (attempts >= MAX_POST_ATTEMPTS) {
|
|
1623
|
-
c.terminal = true;
|
|
1624
|
-
c.terminal_reason = `gave_up_after_${attempts}_failed_attempts:${r.reason || "failed"}`;
|
|
1625
|
-
console.error(`[post] giving up on candidate ${r.candidate_id} after ${attempts} failed attempts (last: ${r.reason || "failed"})`);
|
|
1626
|
-
logPostEvent(`retry_budget_exhausted candidate=${r.candidate_id} attempts=${attempts} last=${r.reason || "failed"}`);
|
|
1627
|
-
}
|
|
1628
1485
|
touchedPlan = true;
|
|
1629
1486
|
}
|
|
1630
1487
|
});
|
|
@@ -1639,7 +1496,7 @@ async function postApproved(batchId, plan) {
|
|
|
1639
1496
|
// Reddit stamps (set in the reddit drain above) merge alongside the twitter
|
|
1640
1497
|
// ones: `approved` here spans both platforms.
|
|
1641
1498
|
if (touchedPlan || redditPosted || redditFailed) {
|
|
1642
|
-
|
|
1499
|
+
mergeApprovedStampsIntoStore(batchId, plan, approved);
|
|
1643
1500
|
}
|
|
1644
1501
|
// Post failures are HANDLED in the pipeline (it returns a count, never throws),
|
|
1645
1502
|
// so they never reach Sentry on their own. Capture an explicit event whenever
|
|
@@ -2884,16 +2741,6 @@ tool("post_drafts", {
|
|
|
2884
2741
|
const total = candidates.length;
|
|
2885
2742
|
const warnings = [];
|
|
2886
2743
|
const inRange = (n) => n >= 1 && n <= total;
|
|
2887
|
-
// Review-queue store: snapshot every row now so the write below can be a
|
|
2888
|
-
// field-level DIFF applied under the store lock (store_patch.py) instead
|
|
2889
|
-
// of an unlocked whole-file replace. This function holds its in-memory
|
|
2890
|
-
// plan across user think-time; a whole-file write here erased any menubar
|
|
2891
|
-
// decision or merge that landed in between (the 2026-07-17 truth-loss
|
|
2892
|
-
// family). Non-store batches keep the plain write: single writer.
|
|
2893
|
-
const isStoreBatch = batch_id === REVIEW_QUEUE_ID;
|
|
2894
|
-
const rowsBefore = isStoreBatch
|
|
2895
|
-
? candidates.map((c) => JSON.stringify(c))
|
|
2896
|
-
: [];
|
|
2897
2744
|
// ---- Rejections: durable + final --------------------------------------
|
|
2898
2745
|
// A rejected draft is marked terminal so it NEVER re-appears for review and is
|
|
2899
2746
|
// never posted. A reject overrides any earlier approve on the same card.
|
|
@@ -3030,40 +2877,7 @@ tool("post_drafts", {
|
|
|
3030
2877
|
if (c)
|
|
3031
2878
|
c.approved = true;
|
|
3032
2879
|
});
|
|
3033
|
-
|
|
3034
|
-
// snapshot and apply only the changed fields under the store lock, so a
|
|
3035
|
-
// concurrent menubar decision or merge is never erased. Anything else
|
|
3036
|
-
// (per-batch /tmp plans): plain write, single writer.
|
|
3037
|
-
let storeWriteDone = false;
|
|
3038
|
-
if (isStoreBatch) {
|
|
3039
|
-
const patches = [];
|
|
3040
|
-
candidates.forEach((c, i) => {
|
|
3041
|
-
const beforeRaw = rowsBefore[i];
|
|
3042
|
-
const afterRaw = JSON.stringify(c);
|
|
3043
|
-
if (beforeRaw === afterRaw)
|
|
3044
|
-
return;
|
|
3045
|
-
const before = JSON.parse(beforeRaw ?? "{}");
|
|
3046
|
-
const after = JSON.parse(afterRaw);
|
|
3047
|
-
const set = {};
|
|
3048
|
-
const unset = [];
|
|
3049
|
-
for (const k of new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
3050
|
-
if (!(k in after) || after[k] === undefined) {
|
|
3051
|
-
if (k in before)
|
|
3052
|
-
unset.push(k);
|
|
3053
|
-
}
|
|
3054
|
-
else if (JSON.stringify(before[k]) !== JSON.stringify(after[k])) {
|
|
3055
|
-
set[k] = after[k];
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
if (Object.keys(set).length || unset.length)
|
|
3059
|
-
patches.push({ candidate_id: c.candidate_id ?? null, n: i + 1, set, unset });
|
|
3060
|
-
});
|
|
3061
|
-
storeWriteDone = await patchReviewStore(patches);
|
|
3062
|
-
if (!storeWriteDone)
|
|
3063
|
-
console.error("[post_drafts] store_patch.py failed; falling back to unlocked plan write");
|
|
3064
|
-
}
|
|
3065
|
-
if (!storeWriteDone)
|
|
3066
|
-
writePlan(batch_id, plan);
|
|
2880
|
+
writePlan(batch_id, plan);
|
|
3067
2881
|
if (approve.size === 0) {
|
|
3068
2882
|
return jsonContent({
|
|
3069
2883
|
batch_id,
|
|
@@ -3654,8 +3468,8 @@ async function autopilotLoaded() {
|
|
|
3654
3468
|
// fires every minute, claims ONE job, runs the pipeline's own prompt as its
|
|
3655
3469
|
// Claude turn, writes the result back, and stops.
|
|
3656
3470
|
// ===========================================================================
|
|
3657
|
-
const QUEUE_WORKER_PROMPT_VERSION =
|
|
3658
|
-
//
|
|
3471
|
+
const QUEUE_WORKER_PROMPT_VERSION = 8; // v8: worker polls internally (claude_job.py next --wait-seconds) instead of single-shot check-then-die. Empirically verified (2026-07-06) that a single long-running Bash call survives well past the host's ~90s between-tool-call inactivity kill — that timer only fires on MODEL silence, not on one in-flight tool call — so one Bash call can safely poll for QUEUE_WORKER_POLL_SECONDS before giving up. This cuts the every-minute spin-up-empty-then-die husk cycle down to roughly one session per poll window instead of one per cron tick. v7: universal type-blind worker. ONE task claims `--type any`; per-type execution notes (e.g. the v6 incremental-draft pacing for twitter-prep) moved into claude_job.py TYPE_TO_WORKER_NOTES and ride the prompt sidecar, so the worker prompt never mentions job types. Legacy per-type tasks get this same body on refresh and become interchangeable universal workers.
|
|
3472
|
+
// v9 (PLANNED, NOT IMPLEMENTED): delegate the actual drafting to a fresh
|
|
3659
3473
|
// sub-agent per claimed job (claim -> delegate -> wait -> claim next, looped
|
|
3660
3474
|
// within one continuous worker session) instead of drafting inline. Validated
|
|
3661
3475
|
// via throwaway probe tasks 2026-07-07/08 (10 loop iterations, ~210s of real
|
|
@@ -3664,26 +3478,19 @@ const QUEUE_WORKER_PROMPT_VERSION = 9; // v9 (2026-07-17): poll window widened 2
|
|
|
3664
3478
|
// notification) or the host kills the whole parent+child chain in 1-3 min.
|
|
3665
3479
|
// Never live-fire tested against a real production job. Full design, what's
|
|
3666
3480
|
// validated vs not, and the implementation steps: docs/queue-worker-delegation-plan.md
|
|
3667
|
-
// Bump this constant to
|
|
3481
|
+
// Bump this constant to 9 only once that plan is actually implemented.
|
|
3668
3482
|
const QUEUE_WORKER_PROMPT_MARKER = "s4l_queue_worker_prompt_version";
|
|
3669
3483
|
// How long ONE `next --wait-seconds` call polls before giving up and exiting.
|
|
3670
|
-
//
|
|
3671
|
-
//
|
|
3672
|
-
//
|
|
3673
|
-
//
|
|
3674
|
-
//
|
|
3675
|
-
// session instead of paying a fresh spin-up, and MCP boot side effects
|
|
3676
|
-
// (backfill checks, backlog drains) run 1/15min instead of 1/5min. Watch
|
|
3677
|
-
// point: 900s has zero margin below the verified ceiling — if workers start
|
|
3678
|
-
// dying mid-poll with no reaper kill recorded, the host clipped the call;
|
|
3679
|
-
// back off to 600s. The cron's `* * * * *` cadence remains the outer safety
|
|
3680
|
-
// net for whatever the poll window doesn't catch.
|
|
3484
|
+
// 240s (4 min): comfortably inside the 900s single-Bash-call survival verified
|
|
3485
|
+
// live on 2026-07-06, and covers a meaningful chunk of the ~8min average
|
|
3486
|
+
// real job inter-arrival gap measured on the box, while still keeping each
|
|
3487
|
+
// worker session bounded. The cron's `* * * * *` cadence remains the outer
|
|
3488
|
+
// safety net for whatever the poll window doesn't catch.
|
|
3681
3489
|
// COUPLING: scripts/reap_stale_claude_sessions.py's S4L_REAPER_CLAIM_GRACE_SEC
|
|
3682
3490
|
// default MUST stay >= this value + margin — a claimless session inside this
|
|
3683
3491
|
// poll window is legitimately still working, not a husk, and a too-tight
|
|
3684
3492
|
// claim_grace would SIGTERM it mid-poll before it ever gets to claim.
|
|
3685
|
-
|
|
3686
|
-
const QUEUE_WORKER_POLL_SECONDS = 900;
|
|
3493
|
+
const QUEUE_WORKER_POLL_SECONDS = 240;
|
|
3687
3494
|
// One spec per worker task. queueType MUST match scripts/claude_job.py TAG_TO_TYPE.
|
|
3688
3495
|
const QUEUE_WORKERS = [
|
|
3689
3496
|
{ taskId: WORKER_TASK_ID, queueType: "any", human: "universal queue" },
|
|
@@ -5877,18 +5684,30 @@ registerAppResource(server, "S4L product link", PRODUCT_LINK_URI, { mimeType: RE
|
|
|
5877
5684
|
},
|
|
5878
5685
|
],
|
|
5879
5686
|
}));
|
|
5880
|
-
//
|
|
5881
|
-
//
|
|
5882
|
-
//
|
|
5883
|
-
//
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5687
|
+
// Post any cards the user APPROVED that never landed — e.g. a restart killed the
|
|
5688
|
+
// batch mid-way. "Proceed to post the already-approved items." postApproved is
|
|
5689
|
+
// idempotent (it filters posted/terminal), so this only drains the genuine
|
|
5690
|
+
// backlog and never double-posts. Best-effort; never throws.
|
|
5691
|
+
async function drainApprovedBacklog() {
|
|
5692
|
+
try {
|
|
5693
|
+
const plan = readPlan(REVIEW_QUEUE_ID);
|
|
5694
|
+
const cands = plan?.candidates || [];
|
|
5695
|
+
const backlog = cands.filter((c) => c.approved === true &&
|
|
5696
|
+
c.posted !== true &&
|
|
5697
|
+
(c.terminal !== true || expiredStampOverridable(c)));
|
|
5698
|
+
if (!backlog.length)
|
|
5699
|
+
return;
|
|
5700
|
+
console.error(`[post] draining ${backlog.length} approved-but-unposted card(s) left from before`);
|
|
5701
|
+
await postApproved(REVIEW_QUEUE_ID, plan);
|
|
5702
|
+
}
|
|
5703
|
+
catch (e) {
|
|
5704
|
+
console.error("[post] drainApprovedBacklog error:", e?.message || e);
|
|
5705
|
+
// Same reasoning as the other postApproved call site: don't let an
|
|
5706
|
+
// escaped exception leave the cross-instance posting flag stuck true.
|
|
5707
|
+
postingActive = false;
|
|
5708
|
+
stopPostingFlagHeartbeat();
|
|
5709
|
+
}
|
|
5710
|
+
}
|
|
5892
5711
|
async function main() {
|
|
5893
5712
|
initSentry();
|
|
5894
5713
|
// Detect a self-update (old_version -> new_version) as the very first thing
|
|
@@ -6064,9 +5883,13 @@ async function main() {
|
|
|
6064
5883
|
void startLocalPanel()
|
|
6065
5884
|
.then((url) => console.error(`[social-autoposter-mcp] panel loopback ready at ${url}`))
|
|
6066
5885
|
.catch((e) => console.error("[social-autoposter-mcp] panel loopback start failed:", e?.message || e));
|
|
6067
|
-
//
|
|
6068
|
-
//
|
|
6069
|
-
|
|
5886
|
+
// Resume posting any approved-but-unposted cards a prior run/restart left behind.
|
|
5887
|
+
// Delayed so the runtime + harness Chrome have settled; never blocks boot.
|
|
5888
|
+
{
|
|
5889
|
+
const t = setTimeout(() => void drainApprovedBacklog(), 30_000);
|
|
5890
|
+
if (typeof t.unref === "function")
|
|
5891
|
+
t.unref();
|
|
5892
|
+
}
|
|
6070
5893
|
// Ensure the macOS menu bar mini-dashboard is installed + running. Idempotent
|
|
6071
5894
|
// and cheap when already present, so existing installs pick it up on the next
|
|
6072
5895
|
// Claude restart without re-provisioning. Best-effort: never blocks boot.
|
package/mcp/dist/telemetry.js
CHANGED
|
@@ -301,8 +301,7 @@ function collectStateSnapshot() {
|
|
|
301
301
|
["install_progress", "install-progress.json", 64_000],
|
|
302
302
|
["onboarding_progress", "onboarding-progress.json", 256_000],
|
|
303
303
|
["review_queue", "review-queue.json", 256_000],
|
|
304
|
-
|
|
305
|
-
// store is the only local decision record.
|
|
304
|
+
["approved_queue", "approved-queue.json", 256_000],
|
|
306
305
|
];
|
|
307
306
|
for (const [key, file, cap] of stateFiles) {
|
|
308
307
|
const val = readJsonCapped(path.join(stateDir, file), cap);
|
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.7.6-rc.
|
|
5
|
+
"version": "1.7.6-rc.2",
|
|
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": {
|