@mrrlin-dev/mcp 0.4.269 → 0.4.273
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 +299 -56
- 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
|
@@ -100244,7 +100244,9 @@ function localLandingNote(outcome, ctx) {
|
|
|
100244
100244
|
const { taskId, title, defaultBranch: d, detail } = ctx;
|
|
100245
100245
|
const prefix = `${taskId} (${title})`;
|
|
100246
100246
|
const bodies = {
|
|
100247
|
-
|
|
100247
|
+
// Dogfood R2-18: this is what a non-technical owner reads when their task finishes. No git words
|
|
100248
|
+
// and no dev-server advice: most projects have none, and a running one reloads on its own.
|
|
100249
|
+
applied: `${prefix} \u2014 Done. The changes are saved in your project folder.`,
|
|
100248
100250
|
already_applied: `${prefix} \u2014 Already applied to ${d}. No changes needed.`,
|
|
100249
100251
|
uncommitted_changes: `${prefix} \u2014 Can't apply: you have uncommitted changes in your project folder. Commit or stash them, then ask the Director to apply ${taskId} again.`,
|
|
100250
100252
|
would_overwrite_files: `${prefix} \u2014 Can't apply: local files (${detail}) would be overwritten. Move them aside, then ask the Director to apply ${taskId} again.`,
|
|
@@ -100276,7 +100278,8 @@ async function fileLocalLandingNote(client, projectSlug, outcome, ctx) {
|
|
|
100276
100278
|
error: error51 instanceof Error ? error51.message : String(error51)
|
|
100277
100279
|
})
|
|
100278
100280
|
);
|
|
100279
|
-
|
|
100281
|
+
const kind = outcome === "applied" ? "completed" : "info";
|
|
100282
|
+
await client.createInboxItem(projectSlug, { id: note.id, kind, taskId: ctx.taskId, body: note.body }).catch(logFailure("inbox_note"));
|
|
100280
100283
|
await client.appendExecutionArtifact(projectSlug, ctx.runId, {
|
|
100281
100284
|
id: `EA-${import_node_crypto21.default.randomUUID()}`,
|
|
100282
100285
|
kind: "checkpoint",
|
|
@@ -101625,6 +101628,24 @@ var runSpecConsensusInputSchema = external_exports.object({
|
|
|
101625
101628
|
'Opt-in reviewer personas to add on top of the fixed four (plan-reviewer, architect, security-analyst, scope-analyst). "researcher" \u2014 for specs that reference external libraries, frameworks, or APIs; validates dependency/version/behavior claims. "debugger" \u2014 for root-cause/investigation specs; stress-tests hypotheses, evidence, and repro steps. Both are OFF by default.'
|
|
101626
101629
|
)
|
|
101627
101630
|
});
|
|
101631
|
+
var TERMINAL_TASK_STATUSES = new Set(mrrlinTerminalTaskStatuses);
|
|
101632
|
+
async function refuseSpecReviewOfNonSpec(client, projectSlug, pageId) {
|
|
101633
|
+
const page = await client.getWikiPage(projectSlug, pageId);
|
|
101634
|
+
if (page.folder !== "Specs") {
|
|
101635
|
+
throw new McpToolCodedError(
|
|
101636
|
+
"SPEC_REVIEW_NOT_A_SPEC",
|
|
101637
|
+
`${pageId} is in the ${page.folder} folder, not Specs, so it is not a spec and was not reviewed. If this is the spec you meant, move it into the Specs folder; otherwise check the page id.`
|
|
101638
|
+
);
|
|
101639
|
+
}
|
|
101640
|
+
if (!page.taskId) return;
|
|
101641
|
+
const task = await client.getTask(projectSlug, page.taskId).catch(() => null);
|
|
101642
|
+
if (task && TERMINAL_TASK_STATUSES.has(task.status)) {
|
|
101643
|
+
throw new McpToolCodedError(
|
|
101644
|
+
"SPEC_REVIEW_TASK_CLOSED",
|
|
101645
|
+
`${pageId} is the spec of ${task.id}, which is closed, so it was not reviewed. Check the page id; to change finished work, propose a new task.`
|
|
101646
|
+
);
|
|
101647
|
+
}
|
|
101648
|
+
}
|
|
101628
101649
|
var runCodeReviewerGateInputSchema = external_exports.object({
|
|
101629
101650
|
projectSlug: external_exports.string().min(1),
|
|
101630
101651
|
baseRef: external_exports.string().min(1),
|
|
@@ -101863,7 +101884,7 @@ var mcpToolDescriptions = {
|
|
|
101863
101884
|
[mcpToolNames.createTaxonomyEntry]: "Create an allowed category/subcategory pair.",
|
|
101864
101885
|
[mcpToolNames.renameTaxonomyEntry]: "Rename a category/subcategory pair; cascades to every task that uses it.",
|
|
101865
101886
|
[mcpToolNames.deleteTaxonomyEntry]: "Delete a category/subcategory pair (rejected while tasks still use it).",
|
|
101866
|
-
[mcpToolNames.listProjectMembers]: "List a project's teammates
|
|
101887
|
+
[mcpToolNames.listProjectMembers]: "List a project's teammates. The owner is not a row here (derived from github.operator) but is always a member: an empty list means the owner works alone, never that the project has no members.",
|
|
101867
101888
|
[mcpToolNames.addProjectMember]: "Add a teammate to a project by email (owner-only).",
|
|
101868
101889
|
[mcpToolNames.removeProjectMember]: "Remove a teammate from a project by email (owner-only); returns the updated list.",
|
|
101869
101890
|
[mcpToolNames.appendTaskJournal]: "Append a progress entry to the task journal. Generate one operationId UUID per logical entry and reuse it for retries; the same UUID with different text is rejected.",
|
|
@@ -102737,6 +102758,7 @@ function createMrrlinTools(options) {
|
|
|
102737
102758
|
"Unable to enqueue spec consensus.",
|
|
102738
102759
|
async (c, { projectSlug, pageId, extraHeads }) => {
|
|
102739
102760
|
await checkTenantBoundary(projectSlug, "spec consensus");
|
|
102761
|
+
await refuseSpecReviewOfNonSpec(c, projectSlug, pageId);
|
|
102740
102762
|
const result = await enqueueAsyncTool(c, consensusDescriptor, { projectSlug, pageId, extraHeads });
|
|
102741
102763
|
if (result.status === "queued") pingAsyncWorkerDispatch(projectSlug, result.jobId);
|
|
102742
102764
|
return result;
|
|
@@ -106610,8 +106632,9 @@ function resolveBinPath(opts) {
|
|
|
106610
106632
|
}
|
|
106611
106633
|
return { path: opts.argv1 || "", source: "fallback" };
|
|
106612
106634
|
}
|
|
106613
|
-
var DEFAULT_INTERVAL_MS =
|
|
106635
|
+
var DEFAULT_INTERVAL_MS = 60 * 1e3;
|
|
106614
106636
|
var DEFAULT_IDLE_MS = 2e3;
|
|
106637
|
+
var DEFAULT_DRAIN_POLL_MS = 5 * 1e3;
|
|
106615
106638
|
var DEFAULT_REGISTRY_POLL_MS = 6 * 60 * 60 * 1e3;
|
|
106616
106639
|
var DEFAULT_STARTUP_JITTER_MS = 30 * 1e3;
|
|
106617
106640
|
var DEFAULT_COOLDOWN_MS = 48 * 60 * 60 * 1e3;
|
|
@@ -106620,6 +106643,7 @@ var REGISTRY_URL_DEFAULT = "https://registry.npmjs.org/@mrrlin-dev/mcp/latest";
|
|
|
106620
106643
|
var STRICT_SEMVER = /^\d+\.\d+\.\d+(-[A-Za-z0-9.-]+)?(\+[A-Za-z0-9.-]+)?$/;
|
|
106621
106644
|
var MAX_VERSION_LENGTH = 64;
|
|
106622
106645
|
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.";
|
|
106646
|
+
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
106647
|
function isDisabled() {
|
|
106624
106648
|
return process.env.MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE === "0";
|
|
106625
106649
|
}
|
|
@@ -106640,6 +106664,7 @@ function startSelfUpdate(deps) {
|
|
|
106640
106664
|
const clearIntervalFn = deps.clearIntervalImpl ?? clearInterval;
|
|
106641
106665
|
const intervalMs = deps.intervalMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS", DEFAULT_INTERVAL_MS);
|
|
106642
106666
|
const idleThresholdMs = deps.idleThresholdMs ?? DEFAULT_IDLE_MS;
|
|
106667
|
+
const drainPollMs = deps.drainPollMs ?? DEFAULT_DRAIN_POLL_MS;
|
|
106643
106668
|
const setTimeoutFn = deps.setTimeoutImpl ?? setTimeout;
|
|
106644
106669
|
const clearTimeoutFn = deps.clearTimeoutImpl ?? clearTimeout;
|
|
106645
106670
|
const fetchFn = deps.fetchImpl ?? globalThis.fetch;
|
|
@@ -106657,7 +106682,9 @@ function startSelfUpdate(deps) {
|
|
|
106657
106682
|
const disabled = isDisabled();
|
|
106658
106683
|
let drainOnQuiet = false;
|
|
106659
106684
|
let drainSource = null;
|
|
106685
|
+
let driftConfirmed = false;
|
|
106660
106686
|
let shutdownCalled = false;
|
|
106687
|
+
let stopped = false;
|
|
106661
106688
|
let latestVersion = null;
|
|
106662
106689
|
let lastUpdateMentionAt = null;
|
|
106663
106690
|
let lastAuthBlockMentionAt = null;
|
|
@@ -106745,7 +106772,7 @@ This turn, at a natural pause, RAISE this with the operator IN THEIR LANGUAGE (m
|
|
|
106745
106772
|
|
|
106746
106773
|
ASK the operator first - do NOT install without explicit confirmation.
|
|
106747
106774
|
|
|
106748
|
-
If the operator confirms you should do it: immediately run \`npm install -g @mrrlin-dev/mcp@latest\` via your shell tool
|
|
106775
|
+
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
106776
|
|
|
106750
106777
|
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
106778
|
|
|
@@ -106834,17 +106861,38 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106834
106861
|
const rt = registryTimer;
|
|
106835
106862
|
if (rt && typeof rt.unref === "function") rt.unref();
|
|
106836
106863
|
}
|
|
106837
|
-
let
|
|
106838
|
-
|
|
106839
|
-
|
|
106840
|
-
|
|
106841
|
-
|
|
106842
|
-
|
|
106843
|
-
|
|
106844
|
-
|
|
106845
|
-
|
|
106846
|
-
|
|
106864
|
+
let drainTimer = null;
|
|
106865
|
+
let lastDeferredResumable = null;
|
|
106866
|
+
function stopDrainPoll() {
|
|
106867
|
+
if (drainTimer) {
|
|
106868
|
+
clearIntervalFn(drainTimer);
|
|
106869
|
+
drainTimer = null;
|
|
106870
|
+
}
|
|
106871
|
+
}
|
|
106872
|
+
function ensureDrainPoll() {
|
|
106873
|
+
if (drainTimer || shutdownCalled || stopped || disabled) return;
|
|
106874
|
+
drainTimer = setIntervalFn(() => {
|
|
106875
|
+
tick();
|
|
106876
|
+
}, drainPollMs);
|
|
106877
|
+
const dt = drainTimer;
|
|
106878
|
+
if (dt && typeof dt.unref === "function") dt.unref();
|
|
106879
|
+
log2("info", "bridge.self_update.reload_pending", { drainPollMs });
|
|
106880
|
+
}
|
|
106881
|
+
function tick() {
|
|
106882
|
+
if (shutdownCalled || stopped) {
|
|
106883
|
+
stopDrainPoll();
|
|
106884
|
+
return;
|
|
106885
|
+
}
|
|
106886
|
+
try {
|
|
106887
|
+
const signalTrusted = drainSource === "signal" && deps.binPathSource === "fallback";
|
|
106888
|
+
if (!signalTrusted && !startupBinSha) {
|
|
106889
|
+
try {
|
|
106890
|
+
startupBinSha = sha2562(readFile10(deps.binPath));
|
|
106891
|
+
} catch {
|
|
106892
|
+
return;
|
|
106847
106893
|
}
|
|
106894
|
+
}
|
|
106895
|
+
if (!signalTrusted && !driftConfirmed && startupBinSha) {
|
|
106848
106896
|
let currentBinSha;
|
|
106849
106897
|
try {
|
|
106850
106898
|
currentBinSha = sha2562(readFile10(deps.binPath));
|
|
@@ -106852,47 +106900,63 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106852
106900
|
return;
|
|
106853
106901
|
}
|
|
106854
106902
|
if (currentBinSha !== startupBinSha) {
|
|
106903
|
+
driftConfirmed = true;
|
|
106855
106904
|
if (!drainOnQuiet) {
|
|
106856
106905
|
drainOnQuiet = true;
|
|
106857
106906
|
drainSource = drainSource ?? "hash";
|
|
106858
|
-
|
|
106859
|
-
|
|
106860
|
-
|
|
106907
|
+
}
|
|
106908
|
+
log2("info", "bridge.self_update.hash_drift_detected", {
|
|
106909
|
+
startupBinSha: startupBinSha.slice(0, 12),
|
|
106910
|
+
currentBinSha: currentBinSha.slice(0, 12)
|
|
106911
|
+
});
|
|
106912
|
+
}
|
|
106913
|
+
}
|
|
106914
|
+
const canExit = signalTrusted || driftConfirmed;
|
|
106915
|
+
if (drainOnQuiet && canExit && !shutdownCalled) {
|
|
106916
|
+
const active = deps.getActiveTurnCount();
|
|
106917
|
+
const idle = deps.getIdleMs();
|
|
106918
|
+
const resumable = deps.getResumableTurnCount ? deps.getResumableTurnCount() : 0;
|
|
106919
|
+
if (active === 0 && resumable === 0 && idle >= idleThresholdMs) {
|
|
106920
|
+
shutdownCalled = true;
|
|
106921
|
+
stopDrainPoll();
|
|
106922
|
+
log2("info", "bridge.self_update.self_exit_for_reload", {});
|
|
106923
|
+
try {
|
|
106924
|
+
deps.shutdown();
|
|
106925
|
+
} catch (e) {
|
|
106926
|
+
shutdownCalled = false;
|
|
106927
|
+
log2("error", "bridge.self_update.shutdown_threw", {
|
|
106928
|
+
err: String(e?.message ?? e)
|
|
106861
106929
|
});
|
|
106862
106930
|
}
|
|
106931
|
+
return;
|
|
106863
106932
|
}
|
|
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) {
|
|
106933
|
+
if (active === 0 && idle >= idleThresholdMs && resumable > 0) {
|
|
106934
|
+
if (lastDeferredResumable !== resumable) {
|
|
106882
106935
|
log2("info", "bridge.self_update.reload_deferred_resumable_turn", { resumable });
|
|
106883
106936
|
}
|
|
106937
|
+
lastDeferredResumable = resumable;
|
|
106938
|
+
} else {
|
|
106939
|
+
lastDeferredResumable = null;
|
|
106884
106940
|
}
|
|
106885
|
-
|
|
106886
|
-
log2("error", "bridge.self_update.tick_threw", {
|
|
106887
|
-
err: String(e?.message ?? e)
|
|
106888
|
-
});
|
|
106941
|
+
ensureDrainPoll();
|
|
106889
106942
|
}
|
|
106943
|
+
} catch (e) {
|
|
106944
|
+
log2("error", "bridge.self_update.tick_threw", {
|
|
106945
|
+
err: String(e?.message ?? e)
|
|
106946
|
+
});
|
|
106947
|
+
}
|
|
106948
|
+
}
|
|
106949
|
+
let timer = null;
|
|
106950
|
+
if (!disabled) {
|
|
106951
|
+
timer = setIntervalFn(() => {
|
|
106952
|
+
tick();
|
|
106890
106953
|
}, intervalMs);
|
|
106891
106954
|
const t = timer;
|
|
106892
106955
|
if (t && typeof t.unref === "function") t.unref();
|
|
106893
106956
|
}
|
|
106894
106957
|
return {
|
|
106895
106958
|
stop: () => {
|
|
106959
|
+
stopped = true;
|
|
106896
106960
|
if (timer) {
|
|
106897
106961
|
clearIntervalFn(timer);
|
|
106898
106962
|
timer = null;
|
|
@@ -106905,17 +106969,19 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106905
106969
|
clearTimeoutFn(startupPollTimer);
|
|
106906
106970
|
startupPollTimer = null;
|
|
106907
106971
|
}
|
|
106972
|
+
stopDrainPoll();
|
|
106908
106973
|
},
|
|
106909
106974
|
requestDrain: () => {
|
|
106910
106975
|
if (disabled) {
|
|
106911
106976
|
log2("warn", "bridge.self_update.signal_ignored_disabled", {});
|
|
106912
106977
|
return;
|
|
106913
106978
|
}
|
|
106979
|
+
log2("info", "bridge.self_update.signal_received", { signal: "SIGUSR2", alreadyPending: drainOnQuiet });
|
|
106914
106980
|
if (!drainOnQuiet) {
|
|
106915
106981
|
drainOnQuiet = true;
|
|
106916
106982
|
drainSource = "signal";
|
|
106917
|
-
log2("info", "bridge.self_update.signal_received", { signal: "SIGUSR2" });
|
|
106918
106983
|
}
|
|
106984
|
+
tick();
|
|
106919
106985
|
},
|
|
106920
106986
|
getDrainOnQuiet: () => drainOnQuiet,
|
|
106921
106987
|
getLatestVersion: () => latestVersion,
|
|
@@ -106926,7 +106992,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106926
106992
|
}
|
|
106927
106993
|
|
|
106928
106994
|
// src/_generated/version.ts
|
|
106929
|
-
var PKG_VERSION = "0.4.
|
|
106995
|
+
var PKG_VERSION = "0.4.273";
|
|
106930
106996
|
|
|
106931
106997
|
// src/bridge-allowed-origins.ts
|
|
106932
106998
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -115484,7 +115550,15 @@ function buildDeliverableAuthorPrompt(task, specMarkdown, project, journalMarkdo
|
|
|
115484
115550
|
`- negative_result: the work was actually attempted and valid evidence shows the requested positive result did not materialize.`,
|
|
115485
115551
|
``,
|
|
115486
115552
|
`The markdown body must justify the declared outcome and satisfy every applicable item in the spec's`,
|
|
115487
|
-
`"## Acceptance criteria" checklist. Do not add commentary before the opening delimiter
|
|
115553
|
+
`"## Acceptance criteria" checklist. Do not add commentary before the opening delimiter.`,
|
|
115554
|
+
// Dogfood v4 R2-1: GT-1's deliverable told the operator to "tap Approve on the task page", a button
|
|
115555
|
+
// that did not exist. Name the review exactly as the task page offers it.
|
|
115556
|
+
...task.autonomyLevel === "human_review" ? [
|
|
115557
|
+
``,
|
|
115558
|
+
`This task needs the operator's sign-off: when it finishes, it waits on its task page, where the operator`,
|
|
115559
|
+
`chooses Accept or Request changes. If you mention that review, name exactly those two actions; never`,
|
|
115560
|
+
`invent other buttons, links or steps.`
|
|
115561
|
+
] : []
|
|
115488
115562
|
].join("\n");
|
|
115489
115563
|
}
|
|
115490
115564
|
async function writeDeliverablePage(client, projectSlug, task, markdown) {
|
|
@@ -116390,6 +116464,26 @@ async function deliverLocalRun(deps, input) {
|
|
|
116390
116464
|
return;
|
|
116391
116465
|
}
|
|
116392
116466
|
const landingClient = deps.activeLease?.landingClient ?? deps.client;
|
|
116467
|
+
const settledTask = await landingClient.getTask(projectSlug, task.id).catch(() => null);
|
|
116468
|
+
if (settledTask?.status !== "closed_done") {
|
|
116469
|
+
console.warn(JSON.stringify({
|
|
116470
|
+
event: "landing_held_for_operator",
|
|
116471
|
+
projectSlug,
|
|
116472
|
+
runId,
|
|
116473
|
+
taskId: task.id,
|
|
116474
|
+
taskStatus: settledTask?.status ?? null
|
|
116475
|
+
}));
|
|
116476
|
+
if (settledTask?.status === "awaiting_verification") {
|
|
116477
|
+
await landingClient.createInboxItem(projectSlug, {
|
|
116478
|
+
id: `II-local-review-${runId}`,
|
|
116479
|
+
kind: "info",
|
|
116480
|
+
taskId: task.id,
|
|
116481
|
+
body: `${task.id} (${task.title}) \u2014 the change is built and checked on branch mrrlin/run-${runId}. It lands on ${input.defaultBranch} only after you accept it: open the task and choose Accept or Request changes.`
|
|
116482
|
+
}).catch(() => {
|
|
116483
|
+
});
|
|
116484
|
+
}
|
|
116485
|
+
return;
|
|
116486
|
+
}
|
|
116393
116487
|
const locksDir = deps.locksDir ?? "/tmp/mrrlin-locks";
|
|
116394
116488
|
const headSha = verifiedSettlement ? verifiedSettlement.git.head_oid : outcome.evidence.headSha;
|
|
116395
116489
|
const expectedOldSha = verifiedSettlement ? verifiedSettlement.git.base_oid : input.integration ? input.integration.defaultTipSha : void 0;
|
|
@@ -125143,6 +125237,14 @@ function toDeclinedProposalContext(proposals) {
|
|
|
125143
125237
|
};
|
|
125144
125238
|
});
|
|
125145
125239
|
}
|
|
125240
|
+
function resolveOperatorTimeZone() {
|
|
125241
|
+
try {
|
|
125242
|
+
const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
125243
|
+
return typeof zone === "string" && zone.trim() ? zone.trim() : null;
|
|
125244
|
+
} catch {
|
|
125245
|
+
return null;
|
|
125246
|
+
}
|
|
125247
|
+
}
|
|
125146
125248
|
var COMPACT_REQUEST_HISTORY_MAX_ITEMS = 500;
|
|
125147
125249
|
function isValidChatHistoryMessage(value) {
|
|
125148
125250
|
if (!value || typeof value !== "object") return false;
|
|
@@ -125330,11 +125432,15 @@ function buildThreadStartParams(msg, config2, desiredModel) {
|
|
|
125330
125432
|
"- QUESTION LIFECYCLE: every question you asked must end in exactly one state \u2014 answered by the operator, assumed (you state the default you took), or blocker (you state what it blocks). The open-question list in the turn context is authoritative: resolve each item explicitly and never drop one silently.",
|
|
125331
125433
|
"Core guards:",
|
|
125332
125434
|
"- Never claim a deliverable, file, test result, or running execution exists unless a tool actually produced it. Never claim autopilot is running unless an execution run is active; for a human_review task say it waits in To Do for your approval.",
|
|
125435
|
+
// Dogfood R2-10: GT-2's journal said all 24 spec checks ran and passed; the Director said it had not run them.
|
|
125436
|
+
"- Report a task's checks from its record (get_task journalMarkdown, run artifacts): if they say checks ran, report that and the result; never call them not run because you did not run them in this chat.",
|
|
125333
125437
|
"- Mention a GT- or WK- id only if a tool returned it in this conversation (server-authoritative receipts).",
|
|
125334
125438
|
"- Reply in the operator's language for the whole turn (questions, task scopes, summaries).",
|
|
125335
125439
|
"- 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
125440
|
"- Spec pages in folder Specs must contain `## Acceptance criteria` followed by `- [ ]` items.",
|
|
125337
|
-
"- 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
|
|
125441
|
+
"- 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 (human_review: after Accept), 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.",
|
|
125442
|
+
// Dogfood N28: a free-text "update the bridge" got an improvised install and a promised restart.
|
|
125443
|
+
"- 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
125444
|
"- 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
125445
|
"- 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
125446
|
"- 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.",
|
|
@@ -125740,19 +125846,17 @@ function buildThreadStartParams(msg, config2, desiredModel) {
|
|
|
125740
125846
|
" or they explicitly ask to set up the project), OR when a request clearly needs missing",
|
|
125741
125847
|
" project context \u2014 in which case OFFER to onboard once. Do NOT turn every turn on an",
|
|
125742
125848
|
" un-onboarded project into an interrogation.",
|
|
125743
|
-
|
|
125744
|
-
"
|
|
125745
|
-
|
|
125849
|
+
// Dogfood R2-15: setup ran one question per turn (~6 round-trips) while the goal sat unplanned.
|
|
125850
|
+
"- Ask every setup question still needed in ONE message, numbered, each with a default the operator",
|
|
125851
|
+
' can accept with "ok" \u2014 never one per turn. Skip what their messages or project state already answer.',
|
|
125852
|
+
" Setup never blocks stated work: if they said what they want, start on it in the same turn.",
|
|
125853
|
+
' "None yet", "local only" or "skip" is a complete answer: record it, never list it as open again.',
|
|
125746
125854
|
`- Write the answers into a wiki page at path \`${PROJECT_CONSTITUTION_PAGE.path}\` (folder`,
|
|
125747
125855
|
` \`${PROJECT_CONSTITUTION_PAGE.folder}\`, title \`${PROJECT_CONSTITUTION_PAGE.title}\`) via`,
|
|
125748
125856
|
" `create_wiki_page` if it does not exist yet, else `update_wiki_page` \u2014 never create a",
|
|
125749
|
-
" duplicate.
|
|
125750
|
-
"-
|
|
125751
|
-
"
|
|
125752
|
-
' close the item with `decide_inbox_item` `verdict="acknowledged"` + `answer`; `reject` (with',
|
|
125753
|
-
" a reason) any that become moot. Never leave stale pending onboarding questions.",
|
|
125754
|
-
"- v1 captures the domain as prose in the constitution page (no structured domain field, no",
|
|
125755
|
-
" web research) \u2014 just record what the operator tells you."
|
|
125857
|
+
" duplicate. It is project memory, not a spec: never list it among the specs.",
|
|
125858
|
+
"- An empty `list_project_members` means the owner works alone: the owner is always a member.",
|
|
125859
|
+
" If an onboarding question was banked in the Inbox, close it with `decide_inbox_item` once answered."
|
|
125756
125860
|
].join("\n");
|
|
125757
125861
|
return {
|
|
125758
125862
|
// No project checkout for this turn → run in a dedicated EMPTY scratch dir, never the bridge's own
|
|
@@ -126023,6 +126127,15 @@ async function recoverSingleLanding(client, checkoutPath, projectSlug, runId, re
|
|
|
126023
126127
|
});
|
|
126024
126128
|
return success2;
|
|
126025
126129
|
}
|
|
126130
|
+
async function landingAuthorized(client, projectSlug, runId, receiptId) {
|
|
126131
|
+
try {
|
|
126132
|
+
const run5 = await client.getExecutionRun(projectSlug, runId);
|
|
126133
|
+
const task = await client.getTask(projectSlug, run5.taskId);
|
|
126134
|
+
return task.status === "closed_done" && (task.terminalReceiptId == null || task.terminalReceiptId === receiptId);
|
|
126135
|
+
} catch {
|
|
126136
|
+
return false;
|
|
126137
|
+
}
|
|
126138
|
+
}
|
|
126026
126139
|
async function recoverPendingSettlementJournals(client, opts) {
|
|
126027
126140
|
const stateDir = resolveStateDir(process.env);
|
|
126028
126141
|
const pendingJournals = listPendingSettlementJournalsSync(stateDir);
|
|
@@ -126038,6 +126151,7 @@ async function recoverPendingSettlementJournals(client, opts) {
|
|
|
126038
126151
|
}
|
|
126039
126152
|
}
|
|
126040
126153
|
if (!journal.receipt) continue;
|
|
126154
|
+
if (!await landingAuthorized(client, journal.projectSlug, journal.runId, journal.receipt.receiptId)) continue;
|
|
126041
126155
|
try {
|
|
126042
126156
|
await recoverSingleLanding(
|
|
126043
126157
|
client,
|
|
@@ -126069,6 +126183,7 @@ async function recoverPendingSettlementJournals(client, opts) {
|
|
|
126069
126183
|
if (!lookup || !("data" in lookup) || !("receipt" in lookup.data)) continue;
|
|
126070
126184
|
const settlement = lookup.data;
|
|
126071
126185
|
const journal = journals.find((j) => j.receipt?.receiptId === settlement.receipt.receiptId);
|
|
126186
|
+
if (!await landingAuthorized(client, project.slug, landing.runId, settlement.receipt.receiptId)) continue;
|
|
126072
126187
|
try {
|
|
126073
126188
|
await recoverSingleLanding(
|
|
126074
126189
|
client,
|
|
@@ -127195,6 +127310,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
127195
127310
|
answeredQuestions,
|
|
127196
127311
|
declinedProposals,
|
|
127197
127312
|
openQuestions: presentedLedger.shown.length ? presentedLedger.shown : void 0,
|
|
127313
|
+
operatorTimeZone: resolveOperatorTimeZone() ?? void 0,
|
|
127198
127314
|
clarifications: msg.context?.clarifications ?? (presentedLedger.shown.some((i) => i.id) ? presentedLedger.shown.map(({ id, round, ordinal, question, status, answer, actor }) => ({
|
|
127199
127315
|
id,
|
|
127200
127316
|
round,
|
|
@@ -127883,8 +127999,10 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
127883
127999
|
getIdleMs: () => Date.now() - lastTurnEndedAt,
|
|
127884
128000
|
pkgVersion: PKG_VERSION,
|
|
127885
128001
|
shutdown: () => {
|
|
128002
|
+
const fn = shutdownHolder.fn;
|
|
128003
|
+
if (!fn) throw new Error("self_update shutdown is not wired yet (bridge still starting)");
|
|
127886
128004
|
try {
|
|
127887
|
-
void
|
|
128005
|
+
void fn();
|
|
127888
128006
|
} catch (e) {
|
|
127889
128007
|
process.stderr.write(
|
|
127890
128008
|
`[mrrlin-mcp director-bridge] error self_update shutdown threw: ${String(
|
|
@@ -129273,7 +129391,13 @@ function renderContextPrefix(context) {
|
|
|
129273
129391
|
}
|
|
129274
129392
|
if (openQuestions && !context?.clarifications?.length) {
|
|
129275
129393
|
parts.push(
|
|
129276
|
-
|
|
129394
|
+
'[OPEN QUESTIONS] `openQuestions` lists questions you asked earlier in this chat. For each one with status `open` or `reasked`, state in this reply whether it is answered (by the operator), assumed (say the default you took) or a blocker (say what it blocks). Any reply that settles it counts as an answer, including "none yet", "not now", "local only" or "skip" -- say it is answered. Do not mention items with any other status again: they are closed. Do not ask a question again unless the answer would change the architecture or the deliverable.'
|
|
129395
|
+
);
|
|
129396
|
+
}
|
|
129397
|
+
const operatorTimeZone = context?.operatorTimeZone?.trim();
|
|
129398
|
+
if (operatorTimeZone) {
|
|
129399
|
+
parts.push(
|
|
129400
|
+
`[LOCAL TIME] The operator's time zone is ${operatorTimeZone}. Tool timestamps are UTC: convert any clock time to this zone before you state it, or say how long ago it was. Never quote a raw UTC clock time.`
|
|
129277
129401
|
);
|
|
129278
129402
|
}
|
|
129279
129403
|
return parts.join("\n\n");
|
|
@@ -132100,6 +132224,91 @@ Missing required flag(s): ${missing.join(
|
|
|
132100
132224
|
};
|
|
132101
132225
|
}
|
|
132102
132226
|
|
|
132227
|
+
// src/restart-service.ts
|
|
132228
|
+
var PREFIX2 = "[mrrlin-mcp restart-service]";
|
|
132229
|
+
function isOnlineBridge(entry) {
|
|
132230
|
+
if (!entry || typeof entry !== "object") return false;
|
|
132231
|
+
const e = entry;
|
|
132232
|
+
const env = e.pm2_env ?? {};
|
|
132233
|
+
if (env.status !== "online") return false;
|
|
132234
|
+
if (e.name === "mrrlin-bridge") return true;
|
|
132235
|
+
const args = env.args;
|
|
132236
|
+
if (typeof args === "string") return args.split(/\s+/).includes("director-bridge");
|
|
132237
|
+
if (Array.isArray(args)) return args.includes("director-bridge");
|
|
132238
|
+
return false;
|
|
132239
|
+
}
|
|
132240
|
+
function runRestartService(deps) {
|
|
132241
|
+
const { print, installedVersion } = deps;
|
|
132242
|
+
const manual = "run `pm2 restart mrrlin-bridge` yourself once nothing is running in Mrrlin";
|
|
132243
|
+
const done = (exitCode, outcome) => ({ exitCode, outcome });
|
|
132244
|
+
print(`${PREFIX2} installed version on disk: ${installedVersion}`);
|
|
132245
|
+
const jlist = deps.runPm2Jlist();
|
|
132246
|
+
if (jlist.status !== 0) {
|
|
132247
|
+
if (jlist.errorCode === "ENOENT") {
|
|
132248
|
+
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.`);
|
|
132249
|
+
return done(1, "no_pm2");
|
|
132250
|
+
}
|
|
132251
|
+
print(`${PREFIX2} \`pm2 jlist\` failed (status ${jlist.status ?? "none"}), so the bridge was NOT asked to reload. To restart it, ${manual}.`);
|
|
132252
|
+
return done(1, "pm2_failed");
|
|
132253
|
+
}
|
|
132254
|
+
let entries;
|
|
132255
|
+
try {
|
|
132256
|
+
const parsed = JSON.parse(jlist.stdout || "[]");
|
|
132257
|
+
entries = Array.isArray(parsed) ? parsed : [];
|
|
132258
|
+
} catch {
|
|
132259
|
+
print(`${PREFIX2} \`pm2 jlist\` returned output that is not JSON, so the bridge was NOT asked to reload. To restart it, ${manual}.`);
|
|
132260
|
+
return done(1, "pm2_failed");
|
|
132261
|
+
}
|
|
132262
|
+
const bridges = entries.filter(isOnlineBridge).filter((e) => typeof e.pid === "number" && Number.isInteger(e.pid) && e.pid > 0);
|
|
132263
|
+
if (bridges.length === 0) {
|
|
132264
|
+
print(`${PREFIX2} no running mrrlin-bridge found under pm2. Start it with: mrrlin-mcp install-service`);
|
|
132265
|
+
return done(1, "no_bridge");
|
|
132266
|
+
}
|
|
132267
|
+
const ownReal = deps.ownBinPath ? deps.realpath(deps.ownBinPath) : null;
|
|
132268
|
+
const isElsewhere = (b) => {
|
|
132269
|
+
const exec = b.pm2_env?.pm_exec_path;
|
|
132270
|
+
if (!ownReal || typeof exec !== "string" || exec === "") return false;
|
|
132271
|
+
const execReal = deps.realpath(exec);
|
|
132272
|
+
return execReal !== null && execReal !== ownReal;
|
|
132273
|
+
};
|
|
132274
|
+
const elsewhere = bridges.filter(isElsewhere);
|
|
132275
|
+
const sameCopy = bridges.filter((b) => !isElsewhere(b));
|
|
132276
|
+
if (elsewhere.length > 0) {
|
|
132277
|
+
const where = elsewhere.map((b) => `pid ${b.pid}: ${String(b.pm2_env?.pm_exec_path)}`).join("; ");
|
|
132278
|
+
print(
|
|
132279
|
+
`${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.`
|
|
132280
|
+
);
|
|
132281
|
+
if (sameCopy.length === 0) return done(1, "different_install");
|
|
132282
|
+
}
|
|
132283
|
+
if (deps.platform === "win32") {
|
|
132284
|
+
print(
|
|
132285
|
+
`${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}.`
|
|
132286
|
+
);
|
|
132287
|
+
return done(1, "signal_unsupported");
|
|
132288
|
+
}
|
|
132289
|
+
const failed = [];
|
|
132290
|
+
const signalled = [];
|
|
132291
|
+
for (const bridge of sameCopy) {
|
|
132292
|
+
const pid = bridge.pid;
|
|
132293
|
+
try {
|
|
132294
|
+
deps.kill(pid, "SIGUSR2");
|
|
132295
|
+
signalled.push(pid);
|
|
132296
|
+
} catch (e) {
|
|
132297
|
+
failed.push(`pid ${pid}: ${e?.message ?? String(e)}`);
|
|
132298
|
+
}
|
|
132299
|
+
}
|
|
132300
|
+
if (signalled.length === 0) {
|
|
132301
|
+
print(`${PREFIX2} could not signal the bridge (${failed.join("; ")}). It is still running the old version. To restart it, ${manual}.`);
|
|
132302
|
+
return done(1, "signal_failed");
|
|
132303
|
+
}
|
|
132304
|
+
print(
|
|
132305
|
+
`${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.`
|
|
132306
|
+
);
|
|
132307
|
+
if (failed.length > 0) print(`${PREFIX2} could not signal: ${failed.join("; ")}`);
|
|
132308
|
+
if (elsewhere.length > 0 || failed.length > 0) return done(0, "partial");
|
|
132309
|
+
return done(0, "signalled");
|
|
132310
|
+
}
|
|
132311
|
+
|
|
132103
132312
|
// src/bin.ts
|
|
132104
132313
|
function augmentProcessPathWithCommonDirs() {
|
|
132105
132314
|
const isWin = process.platform === "win32";
|
|
@@ -132486,6 +132695,16 @@ Usage:
|
|
|
132486
132695
|
disposable worktree cwd; set
|
|
132487
132696
|
MRRLIN_DIRECTOR_BRIDGE_CODEX_CWD to override.
|
|
132488
132697
|
|
|
132698
|
+
mrrlin-mcp restart-service Ask the running pm2 bridge to reload onto the
|
|
132699
|
+
version installed on disk (run it after
|
|
132700
|
+
'npm install -g @mrrlin-dev/mcp@latest'; a
|
|
132701
|
+
recent npm skips the package's own restart
|
|
132702
|
+
script). Graceful: if the copy on disk differs
|
|
132703
|
+
from the one it runs, the bridge finishes any
|
|
132704
|
+
running reply or task first, then restarts.
|
|
132705
|
+
Exit 1 when no bridge could be signalled (no
|
|
132706
|
+
pm2, no bridge, another copy, Windows).
|
|
132707
|
+
|
|
132489
132708
|
mrrlin-mcp start-after-restart
|
|
132490
132709
|
Start the helper after a restart (macOS: the
|
|
132491
132710
|
per-user LaunchAgent; Windows: the Startup
|
|
@@ -132700,6 +132919,30 @@ async function main() {
|
|
|
132700
132919
|
process.exitCode = await runDoctor({ json: rest.includes("--json"), logs: rest.includes("--logs") }, realDoctorDeps());
|
|
132701
132920
|
return;
|
|
132702
132921
|
}
|
|
132922
|
+
// Dogfood N28: the update path's explicit reload nudge; see restart-service.ts.
|
|
132923
|
+
case "restart-service": {
|
|
132924
|
+
process.exitCode = runRestartService({
|
|
132925
|
+
runPm2Jlist: () => {
|
|
132926
|
+
const r = spawnSyncCommand("pm2", ["jlist"], { encoding: "utf8", timeout: 8e3, maxBuffer: 32 * 1024 * 1024 });
|
|
132927
|
+
const errorCode = r.error?.code;
|
|
132928
|
+
return { status: r.status, stdout: r.stdout ?? "", ...errorCode ? { errorCode } : {} };
|
|
132929
|
+
},
|
|
132930
|
+
kill: (pid, signal) => process.kill(pid, signal),
|
|
132931
|
+
platform: process.platform,
|
|
132932
|
+
installedVersion: PKG_VERSION,
|
|
132933
|
+
ownBinPath: process.argv[1] ?? "",
|
|
132934
|
+
realpath: (p) => {
|
|
132935
|
+
try {
|
|
132936
|
+
return (0, import_node_fs46.realpathSync)(p);
|
|
132937
|
+
} catch {
|
|
132938
|
+
return null;
|
|
132939
|
+
}
|
|
132940
|
+
},
|
|
132941
|
+
print: (line) => process.stdout.write(`${line}
|
|
132942
|
+
`)
|
|
132943
|
+
}).exitCode;
|
|
132944
|
+
return;
|
|
132945
|
+
}
|
|
132703
132946
|
// Dogfood v4 N19: the same start-after-restart hook `connect` sets up, without a setup code, so
|
|
132704
132947
|
// a missing hook (doctor's "restart" line) is fixed in place instead of with a second code.
|
|
132705
132948
|
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
|
}
|