@mrrlin-dev/mcp 0.4.269 → 0.4.270
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/README.md +8 -8
- package/dist/bin.cjs +207 -40
- package/package.json +1 -1
- package/scripts/postinstall-restart.cjs +5 -1
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@ CLI that runs the local Director bridge under PM2 and forwards chat turns to a l
|
|
|
4
4
|
|
|
5
5
|
## Self-update & process hygiene
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
On macOS and Linux the bridge picks up new `@mrrlin-dev/mcp` versions after `npm install -g` without a manual `pm2 restart`. The update command is `npm install -g @mrrlin-dev/mcp@latest && mrrlin-mcp configure bridge && mrrlin-mcp restart-service`.
|
|
8
8
|
|
|
9
9
|
### How it works
|
|
10
10
|
|
|
11
|
-
- **L1 (self-update loop):** every
|
|
12
|
-
- **L2 (
|
|
13
|
-
- **L3 (in-chat update offer):** every 6 hours the bridge checks `https://registry.npmjs.org/@mrrlin-dev/mcp/latest`. When a newer version is published, on your next chat turn the Director gives a short, generic reason to update (latest fixes/improvements) and offers a choice — let it run the update, or run `npm install -g @mrrlin-dev/mcp@latest` yourself. Say "yes" → Director runs the install itself. 48h cooldown if you decline. The offer hands the Director only the installed and latest version numbers from the registry check: it is told not to fetch the changelog or any other page, so no changelog text reaches the turn that can run the install. The
|
|
14
|
-
- **L3.3 (inbox mirror):** the same fire also files a persistent `question` in the active project's inbox ("A newer version of the mrrlin bridge is available…",
|
|
11
|
+
- **L1 (self-update loop):** every minute (env-tunable; was 15 minutes before dogfood N28) the bridge hashes its own `bin.cjs`. Once it differs from the bundle the process loaded, the bridge waits for quiet — no turn running, no turn still resumable, 2 s idle — re-checking every 5 s while a reload is pending, then exits via `bridgeShutdown`. PM2 restarts. New code loads. It never exits mid-turn.
|
|
12
|
+
- **L2 (explicit nudge):** `mrrlin-mcp restart-service` sends `SIGUSR2` to every running PM2 bridge, which makes it check its binary immediately instead of on the next L1 tick. It does not restart anything itself, so the Director can run it from inside its own turn; it prints the installed version and whether the bridge was signalled, and exits 1 when it could not be — including when pm2 runs a different copy of `mrrlin-mcp` than the one just installed, so the install never reached the bridge, and on Windows, which has no reload signal (there, run `pm2 restart mrrlin-bridge` after updating). The package's npm postinstall sends the same signal, but a recent npm skips install scripts that were not approved, so nothing relies on it (N28).
|
|
13
|
+
- **L3 (in-chat update offer):** every 6 hours the bridge checks `https://registry.npmjs.org/@mrrlin-dev/mcp/latest`. When a newer version is published, on your next chat turn the Director gives a short, generic reason to update (latest fixes/improvements) and offers a choice — let it run the update, or run `npm install -g @mrrlin-dev/mcp@latest` yourself. Say "yes" → Director runs the install itself. 48h cooldown if you decline. The offer hands the Director only the installed and latest version numbers from the registry check: it is told not to fetch the changelog or any other page, so no changelog text reaches the turn that can run the install. The inbox notice (L3.3) carries no link either: the repository changelog is private.
|
|
14
|
+
- **L3.3 (inbox mirror):** the same fire also files a persistent `question` in the active project's inbox ("A newer version of the mrrlin bridge is available…", no link), so the update isn't only an ephemeral per-turn aside. The body is version-agnostic on purpose: the inbox dedup collapses it to one open row per project (reused across versions), and it re-appears at most once per 48h cooldown after you decide it. It's an opportunistic per-project signal, not a guaranteed cross-project notice.
|
|
15
15
|
- **L4 (process hygiene):** the bridge refuses to start a second instance on the same port and warns about orphan `mrrlin-mcp director-bridge` processes at startup.
|
|
16
16
|
|
|
17
17
|
### Env tuning
|
|
@@ -19,7 +19,7 @@ The bridge auto-picks up new `@mrrlin-dev/mcp` versions after `npm install -g`.
|
|
|
19
19
|
| Env var | Default | Purpose |
|
|
20
20
|
|---|---|---|
|
|
21
21
|
| `MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE` | (unset = on) | Set `0` to disable L1 (and silence L2 SIGUSR2 effect). |
|
|
22
|
-
| `MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS` | `
|
|
22
|
+
| `MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS` | `60000` (1 min) | L1 hash-check interval. |
|
|
23
23
|
| `MRRLIN_DIRECTOR_BRIDGE_REGISTRY_POLL_INTERVAL_MS` | `21600000` (6 h) | L3.1 npm registry poll interval. |
|
|
24
24
|
| `MRRLIN_DIRECTOR_BRIDGE_UPDATE_COOLDOWN_MS` | `172800000` (48 h) | L3.2 in-chat update-offer cooldown. |
|
|
25
25
|
| `MRRLIN_MCP_POSTINSTALL_SKIP` | unset | Set `1` to skip the postinstall SIGUSR2 nudge. |
|
|
@@ -82,8 +82,8 @@ This is only needed for the legacy population (bridges started before this self-
|
|
|
82
82
|
When a newer `@mrrlin-dev/mcp` is published and your bridge polls (within 6h):
|
|
83
83
|
|
|
84
84
|
1. On your next chat turn, the Director weaves a yes/no question in: *"Бачу що bridge на X, на npm уже Y — оновити зараз? (запущу `npm install -g @mrrlin-dev/mcp@latest`)"*
|
|
85
|
-
2. You reply "yes" / "так" / "ага" → Director runs the install via its shell tool, reports
|
|
86
|
-
3. L1
|
|
85
|
+
2. You reply "yes" / "так" / "ага" → Director runs the install, then `mrrlin-mcp configure bridge && mrrlin-mcp restart-service` via its shell tool, and reports what they printed. It says the new version is installed but the bridge has not restarted yet — it cannot while that reply is running — and never promises a time. If the bridge could not be signalled it tells you to run `pm2 restart mrrlin-bridge`.
|
|
86
|
+
3. The L2 signal (or the next L1 tick) sees the new `bin.cjs` → drain-on-quiet after the reply → PM2 restart → web reconnects.
|
|
87
87
|
4. You reply "later" → Director acknowledges and drops it for 48h.
|
|
88
88
|
5. If the install fails (sudo, registry pin, network) → Director shows the error verbatim plus the manual command.
|
|
89
89
|
|
package/dist/bin.cjs
CHANGED
|
@@ -106610,8 +106610,9 @@ function resolveBinPath(opts) {
|
|
|
106610
106610
|
}
|
|
106611
106611
|
return { path: opts.argv1 || "", source: "fallback" };
|
|
106612
106612
|
}
|
|
106613
|
-
var DEFAULT_INTERVAL_MS =
|
|
106613
|
+
var DEFAULT_INTERVAL_MS = 60 * 1e3;
|
|
106614
106614
|
var DEFAULT_IDLE_MS = 2e3;
|
|
106615
|
+
var DEFAULT_DRAIN_POLL_MS = 5 * 1e3;
|
|
106615
106616
|
var DEFAULT_REGISTRY_POLL_MS = 6 * 60 * 60 * 1e3;
|
|
106616
106617
|
var DEFAULT_STARTUP_JITTER_MS = 30 * 1e3;
|
|
106617
106618
|
var DEFAULT_COOLDOWN_MS = 48 * 60 * 60 * 1e3;
|
|
@@ -106620,6 +106621,7 @@ var REGISTRY_URL_DEFAULT = "https://registry.npmjs.org/@mrrlin-dev/mcp/latest";
|
|
|
106620
106621
|
var STRICT_SEMVER = /^\d+\.\d+\.\d+(-[A-Za-z0-9.-]+)?(\+[A-Za-z0-9.-]+)?$/;
|
|
106621
106622
|
var MAX_VERSION_LENGTH = 64;
|
|
106622
106623
|
var UPDATE_INBOX_BODY = "A newer version of the mrrlin bridge is available. Updating pulls the latest fixes and improvements. Ask the Director to update, or run `npm install -g @mrrlin-dev/mcp@latest` yourself.";
|
|
106624
|
+
var AFTER_INSTALL_INSTRUCTIONS = "If the install succeeded, run `mrrlin-mcp configure bridge && mrrlin-mcp restart-service` next (the same chain as the Director's base rule), then report the outcome in chat from what the commands actually printed. Be exact about the state: the new version is installed on disk, but the bridge running this conversation is still the old version and cannot restart in the middle of this reply. Only if `mrrlin-mcp restart-service` reported that it asked the bridge to reload, say the bridge will reload itself once this reply has finished and nothing else is running, provided the version it runs is actually different; pass on what restart-service printed rather than making it stronger. Do NOT say the bridge has restarted, and do NOT promise a time. Do NOT run `pm2 restart` or `pm2 reload` yourself - it would cut this reply off. If `mrrlin-mcp restart-service` failed or says the bridge was NOT asked to reload, say the bridge is still on the old version and tell the operator what it printed, including running `pm2 restart mrrlin-bridge` themselves once this reply is done.";
|
|
106623
106625
|
function isDisabled() {
|
|
106624
106626
|
return process.env.MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE === "0";
|
|
106625
106627
|
}
|
|
@@ -106640,6 +106642,7 @@ function startSelfUpdate(deps) {
|
|
|
106640
106642
|
const clearIntervalFn = deps.clearIntervalImpl ?? clearInterval;
|
|
106641
106643
|
const intervalMs = deps.intervalMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS", DEFAULT_INTERVAL_MS);
|
|
106642
106644
|
const idleThresholdMs = deps.idleThresholdMs ?? DEFAULT_IDLE_MS;
|
|
106645
|
+
const drainPollMs = deps.drainPollMs ?? DEFAULT_DRAIN_POLL_MS;
|
|
106643
106646
|
const setTimeoutFn = deps.setTimeoutImpl ?? setTimeout;
|
|
106644
106647
|
const clearTimeoutFn = deps.clearTimeoutImpl ?? clearTimeout;
|
|
106645
106648
|
const fetchFn = deps.fetchImpl ?? globalThis.fetch;
|
|
@@ -106657,7 +106660,9 @@ function startSelfUpdate(deps) {
|
|
|
106657
106660
|
const disabled = isDisabled();
|
|
106658
106661
|
let drainOnQuiet = false;
|
|
106659
106662
|
let drainSource = null;
|
|
106663
|
+
let driftConfirmed = false;
|
|
106660
106664
|
let shutdownCalled = false;
|
|
106665
|
+
let stopped = false;
|
|
106661
106666
|
let latestVersion = null;
|
|
106662
106667
|
let lastUpdateMentionAt = null;
|
|
106663
106668
|
let lastAuthBlockMentionAt = null;
|
|
@@ -106745,7 +106750,7 @@ This turn, at a natural pause, RAISE this with the operator IN THEIR LANGUAGE (m
|
|
|
106745
106750
|
|
|
106746
106751
|
ASK the operator first - do NOT install without explicit confirmation.
|
|
106747
106752
|
|
|
106748
|
-
If the operator confirms you should do it: immediately run \`npm install -g @mrrlin-dev/mcp@latest\` via your shell tool
|
|
106753
|
+
If the operator confirms you should do it: immediately run \`npm install -g @mrrlin-dev/mcp@latest\` via your shell tool. ${AFTER_INSTALL_INSTRUCTIONS}
|
|
106749
106754
|
|
|
106750
106755
|
If the operator declines / says "later": acknowledge briefly and do not bring it up again this turn. The bridge has a cooldown and will re-offer in 48h.
|
|
106751
106756
|
|
|
@@ -106834,17 +106839,38 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106834
106839
|
const rt = registryTimer;
|
|
106835
106840
|
if (rt && typeof rt.unref === "function") rt.unref();
|
|
106836
106841
|
}
|
|
106837
|
-
let
|
|
106838
|
-
|
|
106839
|
-
|
|
106840
|
-
|
|
106841
|
-
|
|
106842
|
-
|
|
106843
|
-
|
|
106844
|
-
|
|
106845
|
-
|
|
106846
|
-
|
|
106842
|
+
let drainTimer = null;
|
|
106843
|
+
let lastDeferredResumable = null;
|
|
106844
|
+
function stopDrainPoll() {
|
|
106845
|
+
if (drainTimer) {
|
|
106846
|
+
clearIntervalFn(drainTimer);
|
|
106847
|
+
drainTimer = null;
|
|
106848
|
+
}
|
|
106849
|
+
}
|
|
106850
|
+
function ensureDrainPoll() {
|
|
106851
|
+
if (drainTimer || shutdownCalled || stopped || disabled) return;
|
|
106852
|
+
drainTimer = setIntervalFn(() => {
|
|
106853
|
+
tick();
|
|
106854
|
+
}, drainPollMs);
|
|
106855
|
+
const dt = drainTimer;
|
|
106856
|
+
if (dt && typeof dt.unref === "function") dt.unref();
|
|
106857
|
+
log2("info", "bridge.self_update.reload_pending", { drainPollMs });
|
|
106858
|
+
}
|
|
106859
|
+
function tick() {
|
|
106860
|
+
if (shutdownCalled || stopped) {
|
|
106861
|
+
stopDrainPoll();
|
|
106862
|
+
return;
|
|
106863
|
+
}
|
|
106864
|
+
try {
|
|
106865
|
+
const signalTrusted = drainSource === "signal" && deps.binPathSource === "fallback";
|
|
106866
|
+
if (!signalTrusted && !startupBinSha) {
|
|
106867
|
+
try {
|
|
106868
|
+
startupBinSha = sha2562(readFile10(deps.binPath));
|
|
106869
|
+
} catch {
|
|
106870
|
+
return;
|
|
106847
106871
|
}
|
|
106872
|
+
}
|
|
106873
|
+
if (!signalTrusted && !driftConfirmed && startupBinSha) {
|
|
106848
106874
|
let currentBinSha;
|
|
106849
106875
|
try {
|
|
106850
106876
|
currentBinSha = sha2562(readFile10(deps.binPath));
|
|
@@ -106852,47 +106878,63 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106852
106878
|
return;
|
|
106853
106879
|
}
|
|
106854
106880
|
if (currentBinSha !== startupBinSha) {
|
|
106881
|
+
driftConfirmed = true;
|
|
106855
106882
|
if (!drainOnQuiet) {
|
|
106856
106883
|
drainOnQuiet = true;
|
|
106857
106884
|
drainSource = drainSource ?? "hash";
|
|
106858
|
-
|
|
106859
|
-
|
|
106860
|
-
|
|
106885
|
+
}
|
|
106886
|
+
log2("info", "bridge.self_update.hash_drift_detected", {
|
|
106887
|
+
startupBinSha: startupBinSha.slice(0, 12),
|
|
106888
|
+
currentBinSha: currentBinSha.slice(0, 12)
|
|
106889
|
+
});
|
|
106890
|
+
}
|
|
106891
|
+
}
|
|
106892
|
+
const canExit = signalTrusted || driftConfirmed;
|
|
106893
|
+
if (drainOnQuiet && canExit && !shutdownCalled) {
|
|
106894
|
+
const active = deps.getActiveTurnCount();
|
|
106895
|
+
const idle = deps.getIdleMs();
|
|
106896
|
+
const resumable = deps.getResumableTurnCount ? deps.getResumableTurnCount() : 0;
|
|
106897
|
+
if (active === 0 && resumable === 0 && idle >= idleThresholdMs) {
|
|
106898
|
+
shutdownCalled = true;
|
|
106899
|
+
stopDrainPoll();
|
|
106900
|
+
log2("info", "bridge.self_update.self_exit_for_reload", {});
|
|
106901
|
+
try {
|
|
106902
|
+
deps.shutdown();
|
|
106903
|
+
} catch (e) {
|
|
106904
|
+
shutdownCalled = false;
|
|
106905
|
+
log2("error", "bridge.self_update.shutdown_threw", {
|
|
106906
|
+
err: String(e?.message ?? e)
|
|
106861
106907
|
});
|
|
106862
106908
|
}
|
|
106909
|
+
return;
|
|
106863
106910
|
}
|
|
106864
|
-
|
|
106865
|
-
|
|
106866
|
-
const canExit = signalTrusted || driftConfirmed;
|
|
106867
|
-
if (drainOnQuiet && canExit && !shutdownCalled) {
|
|
106868
|
-
const active = deps.getActiveTurnCount();
|
|
106869
|
-
const idle = deps.getIdleMs();
|
|
106870
|
-
const resumable = deps.getResumableTurnCount ? deps.getResumableTurnCount() : 0;
|
|
106871
|
-
if (active === 0 && resumable === 0 && idle >= idleThresholdMs) {
|
|
106872
|
-
shutdownCalled = true;
|
|
106873
|
-
log2("info", "bridge.self_update.self_exit_for_reload", {});
|
|
106874
|
-
try {
|
|
106875
|
-
deps.shutdown();
|
|
106876
|
-
} catch (e) {
|
|
106877
|
-
log2("error", "bridge.self_update.shutdown_threw", {
|
|
106878
|
-
err: String(e?.message ?? e)
|
|
106879
|
-
});
|
|
106880
|
-
}
|
|
106881
|
-
} else if (canExit && active === 0 && idle >= idleThresholdMs && resumable > 0) {
|
|
106911
|
+
if (active === 0 && idle >= idleThresholdMs && resumable > 0) {
|
|
106912
|
+
if (lastDeferredResumable !== resumable) {
|
|
106882
106913
|
log2("info", "bridge.self_update.reload_deferred_resumable_turn", { resumable });
|
|
106883
106914
|
}
|
|
106915
|
+
lastDeferredResumable = resumable;
|
|
106916
|
+
} else {
|
|
106917
|
+
lastDeferredResumable = null;
|
|
106884
106918
|
}
|
|
106885
|
-
|
|
106886
|
-
log2("error", "bridge.self_update.tick_threw", {
|
|
106887
|
-
err: String(e?.message ?? e)
|
|
106888
|
-
});
|
|
106919
|
+
ensureDrainPoll();
|
|
106889
106920
|
}
|
|
106921
|
+
} catch (e) {
|
|
106922
|
+
log2("error", "bridge.self_update.tick_threw", {
|
|
106923
|
+
err: String(e?.message ?? e)
|
|
106924
|
+
});
|
|
106925
|
+
}
|
|
106926
|
+
}
|
|
106927
|
+
let timer = null;
|
|
106928
|
+
if (!disabled) {
|
|
106929
|
+
timer = setIntervalFn(() => {
|
|
106930
|
+
tick();
|
|
106890
106931
|
}, intervalMs);
|
|
106891
106932
|
const t = timer;
|
|
106892
106933
|
if (t && typeof t.unref === "function") t.unref();
|
|
106893
106934
|
}
|
|
106894
106935
|
return {
|
|
106895
106936
|
stop: () => {
|
|
106937
|
+
stopped = true;
|
|
106896
106938
|
if (timer) {
|
|
106897
106939
|
clearIntervalFn(timer);
|
|
106898
106940
|
timer = null;
|
|
@@ -106905,17 +106947,19 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106905
106947
|
clearTimeoutFn(startupPollTimer);
|
|
106906
106948
|
startupPollTimer = null;
|
|
106907
106949
|
}
|
|
106950
|
+
stopDrainPoll();
|
|
106908
106951
|
},
|
|
106909
106952
|
requestDrain: () => {
|
|
106910
106953
|
if (disabled) {
|
|
106911
106954
|
log2("warn", "bridge.self_update.signal_ignored_disabled", {});
|
|
106912
106955
|
return;
|
|
106913
106956
|
}
|
|
106957
|
+
log2("info", "bridge.self_update.signal_received", { signal: "SIGUSR2", alreadyPending: drainOnQuiet });
|
|
106914
106958
|
if (!drainOnQuiet) {
|
|
106915
106959
|
drainOnQuiet = true;
|
|
106916
106960
|
drainSource = "signal";
|
|
106917
|
-
log2("info", "bridge.self_update.signal_received", { signal: "SIGUSR2" });
|
|
106918
106961
|
}
|
|
106962
|
+
tick();
|
|
106919
106963
|
},
|
|
106920
106964
|
getDrainOnQuiet: () => drainOnQuiet,
|
|
106921
106965
|
getLatestVersion: () => latestVersion,
|
|
@@ -106926,7 +106970,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106926
106970
|
}
|
|
106927
106971
|
|
|
106928
106972
|
// src/_generated/version.ts
|
|
106929
|
-
var PKG_VERSION = "0.4.
|
|
106973
|
+
var PKG_VERSION = "0.4.270";
|
|
106930
106974
|
|
|
106931
106975
|
// src/bridge-allowed-origins.ts
|
|
106932
106976
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -125335,6 +125379,8 @@ function buildThreadStartParams(msg, config2, desiredModel) {
|
|
|
125335
125379
|
"- Keep chat short and human. No code blocks, DDL, terminal output, local filesystem paths, internal job/inbox UUIDs or alert markers in chat \u2014 put long content into a wiki page and link it.",
|
|
125336
125380
|
"- Spec pages in folder Specs must contain `## Acceptance criteria` followed by `- [ ]` items.",
|
|
125337
125381
|
"- AGNOSTIC DELIVERY MANDATE: Mrrlin is an Agnostic Delivery Platform decoupled from mandatory GitHub. Delivery is routed strictly by artifact kind: (1) document -> wiki; (2) page -> publish (web pages, landing pages, interactive HTML previews); (3) file_set -> artifacts (file uploads, bundles, build zips); (4) message -> send (outbound webhooks, Slack, notifications); (5) code_change -> repo_host (no host: local repo; register_local_checkout w/o repo; init_local_repo after a yes; a done local run lands on main by itself, apply_local_run retries, get_execution_run's localLanding says if it landed; NEVER edit or commit code yourself, only a code run does). NEVER stall or refuse non-code tasks by demanding a Git repository. Non-code tasks deliver directly via page (Publish) or document (Wiki). A page goes live only via a publish route, and a new project has none until the operator adds a publisher on the Integrations page: never promise or give a live link until publishing has produced one.",
|
|
125382
|
+
// Dogfood N28: a free-text "update the bridge" got an improvised install and a promised restart.
|
|
125383
|
+
"- BRIDGE UPDATE: to update the Mrrlin bridge run `npm install -g @mrrlin-dev/mcp@latest && mrrlin-mcp configure bridge && mrrlin-mcp restart-service`, then say in plain words what it reported. You run inside that bridge, so it cannot restart during your reply: never say it restarted, never promise a time, never run `pm2 restart` yourself.",
|
|
125338
125384
|
"- 3-TIER COMMERCIAL SCOPE GOVERNANCE: Treat tasks by domain governance tier. (1) Tier 1 Core Tech Delivery (backend, frontend, SRE, databases): decompose autonomously into repository code changes (when a repo is bound) or code artifacts. (2) Tier 2 Planning & Content (landing pages, SEO, marketing): create actionable drafts; when details such as a phone number, brand name or copy are missing, do not loop on questions \u2014 create the task, record `## Placeholders: [NEED_INPUT: <item>]` in the Wiki spec, and set `autonomyLevel: 'human_review'`. (3) Tier 3 Guardrailed Advisory (high risk: privacy/GDPR, security/SOC 2, billing, production database migrations, infrastructure): always set `autonomyLevel: 'human_review'`, put the domain's standard safety controls into the spec, and state that irreversible actions need human sign-off.",
|
|
125339
125385
|
"- INBOX QUESTION RETIREMENT MANDATE \u2014 Retiring answered questions: Before creating a task/plan, retire only pending Inbox questions the operator actually answered. Call `decide_inbox_item(itemId: <exact id>, decidedBy: 'director', verdict: 'acknowledged', answer: <actual answer>)`. Use `verdict: 'rejected', reason: ...` only if moot. Never close an unrelated item.",
|
|
125340
125386
|
"- CHAT CLARIFICATIONS ARE IN CHAT ONLY: During synchronous interactive Director chat, ask clarifying questions directly in your chat response. DO NOT call `create_inbox_item(kind: 'question')` for routine conversational clarifications in Turn 1 \u2014 Inbox questions are reserved for autonomous background workers or asynchronous gate pauses that occur while the operator is away.",
|
|
@@ -127883,8 +127929,10 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
127883
127929
|
getIdleMs: () => Date.now() - lastTurnEndedAt,
|
|
127884
127930
|
pkgVersion: PKG_VERSION,
|
|
127885
127931
|
shutdown: () => {
|
|
127932
|
+
const fn = shutdownHolder.fn;
|
|
127933
|
+
if (!fn) throw new Error("self_update shutdown is not wired yet (bridge still starting)");
|
|
127886
127934
|
try {
|
|
127887
|
-
void
|
|
127935
|
+
void fn();
|
|
127888
127936
|
} catch (e) {
|
|
127889
127937
|
process.stderr.write(
|
|
127890
127938
|
`[mrrlin-mcp director-bridge] error self_update shutdown threw: ${String(
|
|
@@ -132100,6 +132148,91 @@ Missing required flag(s): ${missing.join(
|
|
|
132100
132148
|
};
|
|
132101
132149
|
}
|
|
132102
132150
|
|
|
132151
|
+
// src/restart-service.ts
|
|
132152
|
+
var PREFIX2 = "[mrrlin-mcp restart-service]";
|
|
132153
|
+
function isOnlineBridge(entry) {
|
|
132154
|
+
if (!entry || typeof entry !== "object") return false;
|
|
132155
|
+
const e = entry;
|
|
132156
|
+
const env = e.pm2_env ?? {};
|
|
132157
|
+
if (env.status !== "online") return false;
|
|
132158
|
+
if (e.name === "mrrlin-bridge") return true;
|
|
132159
|
+
const args = env.args;
|
|
132160
|
+
if (typeof args === "string") return args.split(/\s+/).includes("director-bridge");
|
|
132161
|
+
if (Array.isArray(args)) return args.includes("director-bridge");
|
|
132162
|
+
return false;
|
|
132163
|
+
}
|
|
132164
|
+
function runRestartService(deps) {
|
|
132165
|
+
const { print, installedVersion } = deps;
|
|
132166
|
+
const manual = "run `pm2 restart mrrlin-bridge` yourself once nothing is running in Mrrlin";
|
|
132167
|
+
const done = (exitCode, outcome) => ({ exitCode, outcome });
|
|
132168
|
+
print(`${PREFIX2} installed version on disk: ${installedVersion}`);
|
|
132169
|
+
const jlist = deps.runPm2Jlist();
|
|
132170
|
+
if (jlist.status !== 0) {
|
|
132171
|
+
if (jlist.errorCode === "ENOENT") {
|
|
132172
|
+
print(`${PREFIX2} pm2 is not installed here, so the bridge was NOT asked to reload. If you run the bridge some other way, restart it there.`);
|
|
132173
|
+
return done(1, "no_pm2");
|
|
132174
|
+
}
|
|
132175
|
+
print(`${PREFIX2} \`pm2 jlist\` failed (status ${jlist.status ?? "none"}), so the bridge was NOT asked to reload. To restart it, ${manual}.`);
|
|
132176
|
+
return done(1, "pm2_failed");
|
|
132177
|
+
}
|
|
132178
|
+
let entries;
|
|
132179
|
+
try {
|
|
132180
|
+
const parsed = JSON.parse(jlist.stdout || "[]");
|
|
132181
|
+
entries = Array.isArray(parsed) ? parsed : [];
|
|
132182
|
+
} catch {
|
|
132183
|
+
print(`${PREFIX2} \`pm2 jlist\` returned output that is not JSON, so the bridge was NOT asked to reload. To restart it, ${manual}.`);
|
|
132184
|
+
return done(1, "pm2_failed");
|
|
132185
|
+
}
|
|
132186
|
+
const bridges = entries.filter(isOnlineBridge).filter((e) => typeof e.pid === "number" && Number.isInteger(e.pid) && e.pid > 0);
|
|
132187
|
+
if (bridges.length === 0) {
|
|
132188
|
+
print(`${PREFIX2} no running mrrlin-bridge found under pm2. Start it with: mrrlin-mcp install-service`);
|
|
132189
|
+
return done(1, "no_bridge");
|
|
132190
|
+
}
|
|
132191
|
+
const ownReal = deps.ownBinPath ? deps.realpath(deps.ownBinPath) : null;
|
|
132192
|
+
const isElsewhere = (b) => {
|
|
132193
|
+
const exec = b.pm2_env?.pm_exec_path;
|
|
132194
|
+
if (!ownReal || typeof exec !== "string" || exec === "") return false;
|
|
132195
|
+
const execReal = deps.realpath(exec);
|
|
132196
|
+
return execReal !== null && execReal !== ownReal;
|
|
132197
|
+
};
|
|
132198
|
+
const elsewhere = bridges.filter(isElsewhere);
|
|
132199
|
+
const sameCopy = bridges.filter((b) => !isElsewhere(b));
|
|
132200
|
+
if (elsewhere.length > 0) {
|
|
132201
|
+
const where = elsewhere.map((b) => `pid ${b.pid}: ${String(b.pm2_env?.pm_exec_path)}`).join("; ");
|
|
132202
|
+
print(
|
|
132203
|
+
`${PREFIX2} a running bridge uses a different copy of mrrlin-mcp (${where}) than the one just installed (${ownReal}). The install did not update it, so it was NOT asked to reload and stays on its old version. Update that copy, or re-run \`mrrlin-mcp install-service\` with this one, then run \`pm2 restart mrrlin-bridge\` once nothing is running in Mrrlin.`
|
|
132204
|
+
);
|
|
132205
|
+
if (sameCopy.length === 0) return done(1, "different_install");
|
|
132206
|
+
}
|
|
132207
|
+
if (deps.platform === "win32") {
|
|
132208
|
+
print(
|
|
132209
|
+
`${PREFIX2} Windows cannot send the reload signal, so the bridge was NOT asked to reload. The running bridge (pid ${sameCopy.map((b) => b.pid).join(", ")}) is still the old version and may not notice the new one by itself. To switch to the new version, ${manual}.`
|
|
132210
|
+
);
|
|
132211
|
+
return done(1, "signal_unsupported");
|
|
132212
|
+
}
|
|
132213
|
+
const failed = [];
|
|
132214
|
+
const signalled = [];
|
|
132215
|
+
for (const bridge of sameCopy) {
|
|
132216
|
+
const pid = bridge.pid;
|
|
132217
|
+
try {
|
|
132218
|
+
deps.kill(pid, "SIGUSR2");
|
|
132219
|
+
signalled.push(pid);
|
|
132220
|
+
} catch (e) {
|
|
132221
|
+
failed.push(`pid ${pid}: ${e?.message ?? String(e)}`);
|
|
132222
|
+
}
|
|
132223
|
+
}
|
|
132224
|
+
if (signalled.length === 0) {
|
|
132225
|
+
print(`${PREFIX2} could not signal the bridge (${failed.join("; ")}). It is still running the old version. To restart it, ${manual}.`);
|
|
132226
|
+
return done(1, "signal_failed");
|
|
132227
|
+
}
|
|
132228
|
+
print(
|
|
132229
|
+
`${PREFIX2} asked the running bridge (pid ${signalled.join(", ")}) to reload onto ${installedVersion}. It has NOT restarted yet. If the copy on disk differs from the one it is running, it first lets any reply or task that is running finish, then restarts by itself; if it already runs this version, nothing changes. Anything said in the meantime is still handled by the running version.`
|
|
132230
|
+
);
|
|
132231
|
+
if (failed.length > 0) print(`${PREFIX2} could not signal: ${failed.join("; ")}`);
|
|
132232
|
+
if (elsewhere.length > 0 || failed.length > 0) return done(0, "partial");
|
|
132233
|
+
return done(0, "signalled");
|
|
132234
|
+
}
|
|
132235
|
+
|
|
132103
132236
|
// src/bin.ts
|
|
132104
132237
|
function augmentProcessPathWithCommonDirs() {
|
|
132105
132238
|
const isWin = process.platform === "win32";
|
|
@@ -132486,6 +132619,16 @@ Usage:
|
|
|
132486
132619
|
disposable worktree cwd; set
|
|
132487
132620
|
MRRLIN_DIRECTOR_BRIDGE_CODEX_CWD to override.
|
|
132488
132621
|
|
|
132622
|
+
mrrlin-mcp restart-service Ask the running pm2 bridge to reload onto the
|
|
132623
|
+
version installed on disk (run it after
|
|
132624
|
+
'npm install -g @mrrlin-dev/mcp@latest'; a
|
|
132625
|
+
recent npm skips the package's own restart
|
|
132626
|
+
script). Graceful: if the copy on disk differs
|
|
132627
|
+
from the one it runs, the bridge finishes any
|
|
132628
|
+
running reply or task first, then restarts.
|
|
132629
|
+
Exit 1 when no bridge could be signalled (no
|
|
132630
|
+
pm2, no bridge, another copy, Windows).
|
|
132631
|
+
|
|
132489
132632
|
mrrlin-mcp start-after-restart
|
|
132490
132633
|
Start the helper after a restart (macOS: the
|
|
132491
132634
|
per-user LaunchAgent; Windows: the Startup
|
|
@@ -132700,6 +132843,30 @@ async function main() {
|
|
|
132700
132843
|
process.exitCode = await runDoctor({ json: rest.includes("--json"), logs: rest.includes("--logs") }, realDoctorDeps());
|
|
132701
132844
|
return;
|
|
132702
132845
|
}
|
|
132846
|
+
// Dogfood N28: the update path's explicit reload nudge; see restart-service.ts.
|
|
132847
|
+
case "restart-service": {
|
|
132848
|
+
process.exitCode = runRestartService({
|
|
132849
|
+
runPm2Jlist: () => {
|
|
132850
|
+
const r = spawnSyncCommand("pm2", ["jlist"], { encoding: "utf8", timeout: 8e3, maxBuffer: 32 * 1024 * 1024 });
|
|
132851
|
+
const errorCode = r.error?.code;
|
|
132852
|
+
return { status: r.status, stdout: r.stdout ?? "", ...errorCode ? { errorCode } : {} };
|
|
132853
|
+
},
|
|
132854
|
+
kill: (pid, signal) => process.kill(pid, signal),
|
|
132855
|
+
platform: process.platform,
|
|
132856
|
+
installedVersion: PKG_VERSION,
|
|
132857
|
+
ownBinPath: process.argv[1] ?? "",
|
|
132858
|
+
realpath: (p) => {
|
|
132859
|
+
try {
|
|
132860
|
+
return (0, import_node_fs46.realpathSync)(p);
|
|
132861
|
+
} catch {
|
|
132862
|
+
return null;
|
|
132863
|
+
}
|
|
132864
|
+
},
|
|
132865
|
+
print: (line) => process.stdout.write(`${line}
|
|
132866
|
+
`)
|
|
132867
|
+
}).exitCode;
|
|
132868
|
+
return;
|
|
132869
|
+
}
|
|
132703
132870
|
// Dogfood v4 N19: the same start-after-restart hook `connect` sets up, without a setup code, so
|
|
132704
132871
|
// a missing hook (doctor's "restart" line) is fixed in place instead of with a second code.
|
|
132705
132872
|
case "start-after-restart": {
|
package/package.json
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
// - Skip when this is NOT a global install (e.g., local `pnpm install` in the
|
|
11
11
|
// monorepo): the postinstall fires in every workspace context otherwise.
|
|
12
12
|
// - Never exit non-zero — a failed nudge must not break the install itself.
|
|
13
|
+
//
|
|
14
|
+
// Not load-bearing (N28): a recent npm skips install scripts that were not approved, so this may
|
|
15
|
+
// never run. The update path runs `mrrlin-mcp restart-service` after the install instead
|
|
16
|
+
// (src/restart-service.ts), and the bridge's own check re-reads its binary every minute.
|
|
13
17
|
|
|
14
18
|
function runPostinstall() {
|
|
15
19
|
if (process.env.CI === "1" || process.env.MRRLIN_MCP_POSTINSTALL_SKIP === "1") {
|
|
@@ -27,7 +31,7 @@ function runPostinstall() {
|
|
|
27
31
|
if (jlist.error && jlist.error.code === "ENOENT") {
|
|
28
32
|
console.log(
|
|
29
33
|
"[mrrlin-mcp] PM2 not available; bridge will self-update via L1 " +
|
|
30
|
-
"(default
|
|
34
|
+
"(default 1min interval; tune via MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS)",
|
|
31
35
|
);
|
|
32
36
|
return;
|
|
33
37
|
}
|