@mrrlin-dev/mcp 0.4.268 → 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 +220 -44
- 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
|
@@ -20859,8 +20859,15 @@ var init_dist = __esm({
|
|
|
20859
20859
|
// design.md D5 step 6 hint (task 3.16): the deploy gate's own bookkeeping write when the
|
|
20860
20860
|
// fingerprint moved but the topology still maps the label to the same workflow. Never sent
|
|
20861
20861
|
// by any other caller.
|
|
20862
|
-
reverifyRequested: external_exports.boolean().optional()
|
|
20863
|
-
|
|
20862
|
+
reverifyRequested: external_exports.boolean().optional(),
|
|
20863
|
+
// Dogfood N25: the operator changed what this task should deliver in a later chat message. The
|
|
20864
|
+
// server appends the operator's NEWEST transcript message, dated, to operator_seed_request, so
|
|
20865
|
+
// the spec gate judges the spec against the latest instruction rather than only the original
|
|
20866
|
+
// request. As with propose_task, the caller cannot choose which words are bound.
|
|
20867
|
+
// A plain boolean, not literal(true): `false` is a harmless no-op rather than a validation error
|
|
20868
|
+
// an LLM caller has to recover from (compare dogfood N24's unsatisfiable literal).
|
|
20869
|
+
recordOperatorInstruction: external_exports.boolean().optional().describe("Set true in the same turn as the operator's chat message that changed what this task should deliver. The server appends that message, dated, to the task's operator request, so the spec review judges the spec against it.")
|
|
20870
|
+
}).refine((value) => value.assignee !== void 0 || value.autoDeploy !== void 0 || value.declaredOutcome !== void 0 || value.domains !== void 0 || value.autonomyLevel !== void 0 || value.autonomyReason !== void 0 || value.category !== void 0 || value.directorThreadId !== void 0 || value.directorThreadProvider !== void 0 || value.dueDate !== void 0 || value.followUpAt !== void 0 || value.impact !== void 0 || value.notes !== void 0 || value.journalMarkdown !== void 0 || value.planId !== void 0 || value.specApproved !== void 0 || value.specWikiPageId !== void 0 || value.status !== void 0 || value.subcategory !== void 0 || value.tags !== void 0 || value.title !== void 0 || value.type !== void 0 || value.verificationDueAt !== void 0 || value.deployTargets !== void 0 || value.reverifyRequested !== void 0 || value.recordOperatorInstruction === true, { message: "TaskUpdate requires at least one field" }).superRefine((value, context) => {
|
|
20864
20871
|
if (value.journalMarkdown !== void 0 && value.expectedUpdatedAt === void 0) {
|
|
20865
20872
|
context.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Journal replacement requires expectedUpdatedAt", path: ["expectedUpdatedAt"] });
|
|
20866
20873
|
}
|
|
@@ -81651,7 +81658,7 @@ function specHeadIntentBlock(taskId, title, seed, impact, adjudicated) {
|
|
|
81651
81658
|
TASK ${taskId}: ${title ?? ""}
|
|
81652
81659
|
|
|
81653
81660
|
` : "";
|
|
81654
|
-
const intent = seed ? `--- OPERATOR INTENT (the operator's own words \u2014 judge the spec against THIS) ---
|
|
81661
|
+
const intent = seed ? `--- OPERATOR INTENT (the operator's own words in the order they said them, oldest first and newest last \u2014 judge the spec against THIS; where a later instruction changes an earlier one, the LATEST instruction wins and the spec following it is correct, not a contradiction) ---
|
|
81655
81662
|
${seed}
|
|
81656
81663
|
|
|
81657
81664
|
` : "";
|
|
@@ -101881,7 +101888,7 @@ var mcpToolDescriptions = {
|
|
|
101881
101888
|
[mcpToolNames.searchWikiPages]: "Search project Wiki pages using ranked full-text search. Returns excerpts suitable for grounding Director decisions.",
|
|
101882
101889
|
[mcpToolNames.searchKnowledge]: "Search the rendered Mrrlin docs wiki using the lexical RAG index. Returns cited chunks with stable wiki_url fields.",
|
|
101883
101890
|
[mcpToolNames.updatePlan]: "Update a plan/epic.",
|
|
101884
|
-
[mcpToolNames.updateTask]: `Update a task. Honors DB invariants: closed_no_result requires linked Evidence wiki pages. Set directorThreadId here to persist the worker's resumable provider thread handle. declaredOutcome is an object {sentence, requires, verification} stating what must exist when the task is done; the Director sets it itself when writing the spec. Approving or skipping the spec (specApproved "approved"/"skipped") is the operator's tap on the task page and is refused for the Director: write the spec, set declaredOutcome, mark it ready, then ask the operator to approve. requires holds one kind; verification is "machine" for page, code_change or message, "human_tap" for document, file_set or structured_data.`,
|
|
101891
|
+
[mcpToolNames.updateTask]: `Update a task. Honors DB invariants: closed_no_result requires linked Evidence wiki pages. Set directorThreadId here to persist the worker's resumable provider thread handle. declaredOutcome is an object {sentence, requires, verification} stating what must exist when the task is done; the Director sets it itself when writing the spec. Approving or skipping the spec (specApproved "approved"/"skipped") is the operator's tap on the task page and is refused for the Director: write the spec, set declaredOutcome, mark it ready, then ask the operator to approve. requires holds one kind; verification is "machine" for page, code_change or message, "human_tap" for document, file_set or structured_data. When the operator's latest chat message changes what an existing task should deliver, pass recordOperatorInstruction: true in that same turn, before rewriting its spec: the server appends that message to the task's operator request, so the spec review follows the latest instruction instead of the original one.`,
|
|
101885
101892
|
[mcpToolNames.resetDirectorThread]: "Clear a task's persisted Director execution thread handle so the next execution run starts a fresh provider thread. Records a director_thread_reset task event.",
|
|
101886
101893
|
[mcpToolNames.archiveTask]: "Archive a task: hides it from default reads, removes it from plan progress and scheduler consideration, cancels its non-terminal execution runs, and closes its open inbox items. Reversible \u2014 the project owner can restore it with unarchive_task. Records an 'archived' task event.",
|
|
101887
101894
|
[mcpToolNames.unarchiveTask]: "Restore an archived task to its original status and visibility. Owner-only \u2014 refused with NOT_PROJECT_OWNER for any other caller. Does not resurrect the execution runs or inbox items that were cancelled/closed when the task was archived. Records a 'restored' task event.",
|
|
@@ -106603,8 +106610,9 @@ function resolveBinPath(opts) {
|
|
|
106603
106610
|
}
|
|
106604
106611
|
return { path: opts.argv1 || "", source: "fallback" };
|
|
106605
106612
|
}
|
|
106606
|
-
var DEFAULT_INTERVAL_MS =
|
|
106613
|
+
var DEFAULT_INTERVAL_MS = 60 * 1e3;
|
|
106607
106614
|
var DEFAULT_IDLE_MS = 2e3;
|
|
106615
|
+
var DEFAULT_DRAIN_POLL_MS = 5 * 1e3;
|
|
106608
106616
|
var DEFAULT_REGISTRY_POLL_MS = 6 * 60 * 60 * 1e3;
|
|
106609
106617
|
var DEFAULT_STARTUP_JITTER_MS = 30 * 1e3;
|
|
106610
106618
|
var DEFAULT_COOLDOWN_MS = 48 * 60 * 60 * 1e3;
|
|
@@ -106613,6 +106621,7 @@ var REGISTRY_URL_DEFAULT = "https://registry.npmjs.org/@mrrlin-dev/mcp/latest";
|
|
|
106613
106621
|
var STRICT_SEMVER = /^\d+\.\d+\.\d+(-[A-Za-z0-9.-]+)?(\+[A-Za-z0-9.-]+)?$/;
|
|
106614
106622
|
var MAX_VERSION_LENGTH = 64;
|
|
106615
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.";
|
|
106616
106625
|
function isDisabled() {
|
|
106617
106626
|
return process.env.MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE === "0";
|
|
106618
106627
|
}
|
|
@@ -106633,6 +106642,7 @@ function startSelfUpdate(deps) {
|
|
|
106633
106642
|
const clearIntervalFn = deps.clearIntervalImpl ?? clearInterval;
|
|
106634
106643
|
const intervalMs = deps.intervalMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS", DEFAULT_INTERVAL_MS);
|
|
106635
106644
|
const idleThresholdMs = deps.idleThresholdMs ?? DEFAULT_IDLE_MS;
|
|
106645
|
+
const drainPollMs = deps.drainPollMs ?? DEFAULT_DRAIN_POLL_MS;
|
|
106636
106646
|
const setTimeoutFn = deps.setTimeoutImpl ?? setTimeout;
|
|
106637
106647
|
const clearTimeoutFn = deps.clearTimeoutImpl ?? clearTimeout;
|
|
106638
106648
|
const fetchFn = deps.fetchImpl ?? globalThis.fetch;
|
|
@@ -106650,7 +106660,9 @@ function startSelfUpdate(deps) {
|
|
|
106650
106660
|
const disabled = isDisabled();
|
|
106651
106661
|
let drainOnQuiet = false;
|
|
106652
106662
|
let drainSource = null;
|
|
106663
|
+
let driftConfirmed = false;
|
|
106653
106664
|
let shutdownCalled = false;
|
|
106665
|
+
let stopped = false;
|
|
106654
106666
|
let latestVersion = null;
|
|
106655
106667
|
let lastUpdateMentionAt = null;
|
|
106656
106668
|
let lastAuthBlockMentionAt = null;
|
|
@@ -106738,7 +106750,7 @@ This turn, at a natural pause, RAISE this with the operator IN THEIR LANGUAGE (m
|
|
|
106738
106750
|
|
|
106739
106751
|
ASK the operator first - do NOT install without explicit confirmation.
|
|
106740
106752
|
|
|
106741
|
-
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}
|
|
106742
106754
|
|
|
106743
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.
|
|
106744
106756
|
|
|
@@ -106827,17 +106839,38 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106827
106839
|
const rt = registryTimer;
|
|
106828
106840
|
if (rt && typeof rt.unref === "function") rt.unref();
|
|
106829
106841
|
}
|
|
106830
|
-
let
|
|
106831
|
-
|
|
106832
|
-
|
|
106833
|
-
|
|
106834
|
-
|
|
106835
|
-
|
|
106836
|
-
|
|
106837
|
-
|
|
106838
|
-
|
|
106839
|
-
|
|
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;
|
|
106840
106871
|
}
|
|
106872
|
+
}
|
|
106873
|
+
if (!signalTrusted && !driftConfirmed && startupBinSha) {
|
|
106841
106874
|
let currentBinSha;
|
|
106842
106875
|
try {
|
|
106843
106876
|
currentBinSha = sha2562(readFile10(deps.binPath));
|
|
@@ -106845,47 +106878,63 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106845
106878
|
return;
|
|
106846
106879
|
}
|
|
106847
106880
|
if (currentBinSha !== startupBinSha) {
|
|
106881
|
+
driftConfirmed = true;
|
|
106848
106882
|
if (!drainOnQuiet) {
|
|
106849
106883
|
drainOnQuiet = true;
|
|
106850
106884
|
drainSource = drainSource ?? "hash";
|
|
106851
|
-
|
|
106852
|
-
|
|
106853
|
-
|
|
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)
|
|
106854
106907
|
});
|
|
106855
106908
|
}
|
|
106909
|
+
return;
|
|
106856
106910
|
}
|
|
106857
|
-
|
|
106858
|
-
|
|
106859
|
-
const canExit = signalTrusted || driftConfirmed;
|
|
106860
|
-
if (drainOnQuiet && canExit && !shutdownCalled) {
|
|
106861
|
-
const active = deps.getActiveTurnCount();
|
|
106862
|
-
const idle = deps.getIdleMs();
|
|
106863
|
-
const resumable = deps.getResumableTurnCount ? deps.getResumableTurnCount() : 0;
|
|
106864
|
-
if (active === 0 && resumable === 0 && idle >= idleThresholdMs) {
|
|
106865
|
-
shutdownCalled = true;
|
|
106866
|
-
log2("info", "bridge.self_update.self_exit_for_reload", {});
|
|
106867
|
-
try {
|
|
106868
|
-
deps.shutdown();
|
|
106869
|
-
} catch (e) {
|
|
106870
|
-
log2("error", "bridge.self_update.shutdown_threw", {
|
|
106871
|
-
err: String(e?.message ?? e)
|
|
106872
|
-
});
|
|
106873
|
-
}
|
|
106874
|
-
} else if (canExit && active === 0 && idle >= idleThresholdMs && resumable > 0) {
|
|
106911
|
+
if (active === 0 && idle >= idleThresholdMs && resumable > 0) {
|
|
106912
|
+
if (lastDeferredResumable !== resumable) {
|
|
106875
106913
|
log2("info", "bridge.self_update.reload_deferred_resumable_turn", { resumable });
|
|
106876
106914
|
}
|
|
106915
|
+
lastDeferredResumable = resumable;
|
|
106916
|
+
} else {
|
|
106917
|
+
lastDeferredResumable = null;
|
|
106877
106918
|
}
|
|
106878
|
-
|
|
106879
|
-
log2("error", "bridge.self_update.tick_threw", {
|
|
106880
|
-
err: String(e?.message ?? e)
|
|
106881
|
-
});
|
|
106919
|
+
ensureDrainPoll();
|
|
106882
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();
|
|
106883
106931
|
}, intervalMs);
|
|
106884
106932
|
const t = timer;
|
|
106885
106933
|
if (t && typeof t.unref === "function") t.unref();
|
|
106886
106934
|
}
|
|
106887
106935
|
return {
|
|
106888
106936
|
stop: () => {
|
|
106937
|
+
stopped = true;
|
|
106889
106938
|
if (timer) {
|
|
106890
106939
|
clearIntervalFn(timer);
|
|
106891
106940
|
timer = null;
|
|
@@ -106898,17 +106947,19 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106898
106947
|
clearTimeoutFn(startupPollTimer);
|
|
106899
106948
|
startupPollTimer = null;
|
|
106900
106949
|
}
|
|
106950
|
+
stopDrainPoll();
|
|
106901
106951
|
},
|
|
106902
106952
|
requestDrain: () => {
|
|
106903
106953
|
if (disabled) {
|
|
106904
106954
|
log2("warn", "bridge.self_update.signal_ignored_disabled", {});
|
|
106905
106955
|
return;
|
|
106906
106956
|
}
|
|
106957
|
+
log2("info", "bridge.self_update.signal_received", { signal: "SIGUSR2", alreadyPending: drainOnQuiet });
|
|
106907
106958
|
if (!drainOnQuiet) {
|
|
106908
106959
|
drainOnQuiet = true;
|
|
106909
106960
|
drainSource = "signal";
|
|
106910
|
-
log2("info", "bridge.self_update.signal_received", { signal: "SIGUSR2" });
|
|
106911
106961
|
}
|
|
106962
|
+
tick();
|
|
106912
106963
|
},
|
|
106913
106964
|
getDrainOnQuiet: () => drainOnQuiet,
|
|
106914
106965
|
getLatestVersion: () => latestVersion,
|
|
@@ -106919,7 +106970,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106919
106970
|
}
|
|
106920
106971
|
|
|
106921
106972
|
// src/_generated/version.ts
|
|
106922
|
-
var PKG_VERSION = "0.4.
|
|
106973
|
+
var PKG_VERSION = "0.4.270";
|
|
106923
106974
|
|
|
106924
106975
|
// src/bridge-allowed-origins.ts
|
|
106925
106976
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -125328,6 +125379,8 @@ function buildThreadStartParams(msg, config2, desiredModel) {
|
|
|
125328
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.",
|
|
125329
125380
|
"- Spec pages in folder Specs must contain `## Acceptance criteria` followed by `- [ ]` items.",
|
|
125330
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.",
|
|
125331
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.",
|
|
125332
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.",
|
|
125333
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.",
|
|
@@ -125441,6 +125494,8 @@ function buildThreadStartParams(msg, config2, desiredModel) {
|
|
|
125441
125494
|
"or ready before the operator confirmed them: say they are waiting for the operator's confirmation",
|
|
125442
125495
|
"in the chat. Proposals bind to the operator's latest message, so propose in the same turn as the",
|
|
125443
125496
|
"request \u2014 a later operator message makes an unconfirmed proposal stale.",
|
|
125497
|
+
"If the operator changes what an existing task delivers, pass recordOperatorInstruction: true to",
|
|
125498
|
+
"update_task in that turn, before rewriting its spec, or its review judges the old request.",
|
|
125444
125499
|
"When referring to created tasks or where to view them, use natural, human-friendly language with a markdown link",
|
|
125445
125500
|
"to the Tasks page (e.g. 'on the [Tasks page](/tasks)', '[Tasks board](/tasks)', or in Ukrainian '\u043D\u0430 [\u0441\u0442\u043E\u0440\u0456\u043D\u0446\u0456 \u0437\u0430\u0434\u0430\u0447](/tasks)').",
|
|
125446
125501
|
"Never output raw technical URL fragments like '\u043D\u0430 /tasks' or 'on /tasks', and never use developer database",
|
|
@@ -127874,8 +127929,10 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
127874
127929
|
getIdleMs: () => Date.now() - lastTurnEndedAt,
|
|
127875
127930
|
pkgVersion: PKG_VERSION,
|
|
127876
127931
|
shutdown: () => {
|
|
127932
|
+
const fn = shutdownHolder.fn;
|
|
127933
|
+
if (!fn) throw new Error("self_update shutdown is not wired yet (bridge still starting)");
|
|
127877
127934
|
try {
|
|
127878
|
-
void
|
|
127935
|
+
void fn();
|
|
127879
127936
|
} catch (e) {
|
|
127880
127937
|
process.stderr.write(
|
|
127881
127938
|
`[mrrlin-mcp director-bridge] error self_update shutdown threw: ${String(
|
|
@@ -132091,6 +132148,91 @@ Missing required flag(s): ${missing.join(
|
|
|
132091
132148
|
};
|
|
132092
132149
|
}
|
|
132093
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
|
+
|
|
132094
132236
|
// src/bin.ts
|
|
132095
132237
|
function augmentProcessPathWithCommonDirs() {
|
|
132096
132238
|
const isWin = process.platform === "win32";
|
|
@@ -132477,6 +132619,16 @@ Usage:
|
|
|
132477
132619
|
disposable worktree cwd; set
|
|
132478
132620
|
MRRLIN_DIRECTOR_BRIDGE_CODEX_CWD to override.
|
|
132479
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
|
+
|
|
132480
132632
|
mrrlin-mcp start-after-restart
|
|
132481
132633
|
Start the helper after a restart (macOS: the
|
|
132482
132634
|
per-user LaunchAgent; Windows: the Startup
|
|
@@ -132691,6 +132843,30 @@ async function main() {
|
|
|
132691
132843
|
process.exitCode = await runDoctor({ json: rest.includes("--json"), logs: rest.includes("--logs") }, realDoctorDeps());
|
|
132692
132844
|
return;
|
|
132693
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
|
+
}
|
|
132694
132870
|
// Dogfood v4 N19: the same start-after-restart hook `connect` sets up, without a setup code, so
|
|
132695
132871
|
// a missing hook (doctor's "restart" line) is fixed in place instead of with a second code.
|
|
132696
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
|
}
|