@mrrlin-dev/mcp 0.4.230 → 0.4.233

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.
Files changed (2) hide show
  1. package/dist/bin.cjs +75 -39
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -26080,8 +26080,9 @@ function runAgyExec(input, deps) {
26080
26080
  child.kill("SIGKILL");
26081
26081
  finish({ ok: false, error: `${executable} exec timed out after ${input.timeoutMs}ms` });
26082
26082
  }, input.timeoutMs);
26083
+ const decoder = new import_node_string_decoder3.StringDecoder("utf8");
26083
26084
  child.stdout?.on("data", (chunk) => {
26084
- stdout += chunk.toString();
26085
+ stdout += typeof chunk === "string" ? chunk : decoder.write(chunk);
26085
26086
  });
26086
26087
  child.stderr?.on("data", () => {
26087
26088
  });
@@ -26095,7 +26096,7 @@ function runAgyExec(input, deps) {
26095
26096
  finish({ ok: false, error: `${executable} exec exited with code ${code ?? "null"}` });
26096
26097
  return;
26097
26098
  }
26098
- finish(extractOneShotResult2(stdout));
26099
+ finish(extractOneShotResult2(stdout + decoder.end()));
26099
26100
  });
26100
26101
  });
26101
26102
  }
@@ -26127,11 +26128,12 @@ function extractOneShotResult2(stdout) {
26127
26128
  }
26128
26129
  };
26129
26130
  }
26130
- var import_node_child_process9, AGY_READ_ONLY_NOTICE, AGY_CANNOT_EDIT_ERROR;
26131
+ var import_node_child_process9, import_node_string_decoder3, AGY_READ_ONLY_NOTICE, AGY_CANNOT_EDIT_ERROR;
26131
26132
  var init_exec3 = __esm({
26132
26133
  "../../packages/agent-client/dist/providers/agy/exec.js"() {
26133
26134
  "use strict";
26134
26135
  import_node_child_process9 = require("node:child_process");
26136
+ import_node_string_decoder3 = require("node:string_decoder");
26135
26137
  init_execution_child();
26136
26138
  init_models2();
26137
26139
  init_windows_command();
@@ -81118,12 +81120,15 @@ function telemetryDay(now = /* @__PURE__ */ new Date()) {
81118
81120
  return now.toISOString().slice(0, 10);
81119
81121
  }
81120
81122
 
81123
+ // src/kill-switch.ts
81124
+ function killSwitchOn(value) {
81125
+ const raw = (value ?? "").trim().toLowerCase();
81126
+ return !(raw === "0" || raw === "false");
81127
+ }
81128
+
81121
81129
  // src/consensus/resolve-gated-task.ts
81122
81130
  function useLinkedTaskLookupV1(value = process.env.MRRLIN_MCP_LINKED_TASK_V1) {
81123
- const flag2 = value?.trim().toLowerCase();
81124
- if (!flag2 || flag2 === "0" || flag2 === "false") return false;
81125
- if (flag2 === "1") return true;
81126
- throw new Error("Invalid MRRLIN_MCP_LINKED_TASK_V1");
81131
+ return killSwitchOn(value);
81127
81132
  }
81128
81133
  async function resolveGatedTaskId(client, projectSlug, page, useV1 = useLinkedTaskLookupV1()) {
81129
81134
  let linkingId;
@@ -96246,6 +96251,7 @@ var deliverableConsensusDescriptor = {
96246
96251
  var import_node_crypto14 = require("node:crypto");
96247
96252
  init_dist();
96248
96253
  init_dist2();
96254
+ var BLOCKER_STATUS_CHUNK = 16;
96249
96255
  var DRAFT_SPEC_TOOL_NAME = "draft_task_spec";
96250
96256
  var SPECS_FOLDER = "Specs";
96251
96257
  var DRAFT_SPEC_TLDR_MAX_CHARS = 300;
@@ -96464,7 +96470,7 @@ async function runDraftSpec(ctx, input, deps) {
96464
96470
  const client = ctx.client;
96465
96471
  let task;
96466
96472
  try {
96467
- const bounded = process.env.MRRLIN_MCP_DRAFT_INITIAL_TASK_BOUNDED?.trim() === "1";
96473
+ const bounded = killSwitchOn(process.env.MRRLIN_MCP_DRAFT_INITIAL_TASK_BOUNDED);
96468
96474
  task = bounded ? await client.getTask(projectSlug, taskId, { boundedResponse: true, signal: ctx.signal }) : await client.getTask(projectSlug, taskId);
96469
96475
  } catch (error51) {
96470
96476
  if (error51 instanceof MrrlinResponseTooLargeError) {
@@ -96484,15 +96490,16 @@ async function runDraftSpec(ctx, input, deps) {
96484
96490
  if ((task.blockedBy ?? []).length > 0) {
96485
96491
  let hasActiveBlocker;
96486
96492
  try {
96487
- const flag2 = process.env.MRRLIN_MCP_DRAFT_BLOCKER_STATUS_V1?.trim().toLowerCase();
96488
- if (flag2 === "1") {
96489
- const ids = blockerTaskIdsSchema.parse([...new Set(task.blockedBy)]);
96490
- hasActiveBlocker = await client.getTaskBlockerStatusV1(projectSlug, ids, { signal: ctx.signal });
96491
- if (typeof hasActiveBlocker !== "boolean") throw new Error("Invalid blocker status result");
96492
- } else {
96493
- if (flag2 && flag2 !== "0" && flag2 !== "false") {
96494
- throw new Error("Invalid MRRLIN_MCP_DRAFT_BLOCKER_STATUS_V1");
96493
+ if (killSwitchOn(process.env.MRRLIN_MCP_DRAFT_BLOCKER_STATUS_V1)) {
96494
+ const unique = [...new Set(task.blockedBy)];
96495
+ hasActiveBlocker = false;
96496
+ for (let start = 0; start < unique.length && !hasActiveBlocker; start += BLOCKER_STATUS_CHUNK) {
96497
+ const ids = blockerTaskIdsSchema.parse(unique.slice(start, start + BLOCKER_STATUS_CHUNK));
96498
+ const active = await client.getTaskBlockerStatusV1(projectSlug, ids, { signal: ctx.signal });
96499
+ if (typeof active !== "boolean") throw new Error("Invalid blocker status result");
96500
+ hasActiveBlocker = active;
96495
96501
  }
96502
+ } else {
96496
96503
  const blockers = await client.listTasks(projectSlug);
96497
96504
  hasActiveBlocker = getActiveBlockedByIds(task.blockedBy, blockers).length > 0;
96498
96505
  }
@@ -96505,11 +96512,7 @@ async function runDraftSpec(ctx, input, deps) {
96505
96512
  }
96506
96513
  if (hasActiveBlocker) return skipped("blocked_by_active");
96507
96514
  }
96508
- const draftLinkFlag = ctx.boundDraftCommit ? void 0 : process.env.MRRLIN_MCP_DRAFT_LINK_V1?.trim().toLowerCase();
96509
- if (draftLinkFlag && draftLinkFlag !== "1" && draftLinkFlag !== "0" && draftLinkFlag !== "false") {
96510
- return { kind: "retry", failureReason: "provider_unavailable", error: "Invalid MRRLIN_MCP_DRAFT_LINK_V1" };
96511
- }
96512
- const useDraftLinkV1 = draftLinkFlag === "1";
96515
+ const useDraftLinkV1 = !ctx.boundDraftCommit && killSwitchOn(process.env.MRRLIN_MCP_DRAFT_LINK_V1);
96513
96516
  const autoDeploy = task.autoDeploy ?? "off";
96514
96517
  let topology = null;
96515
96518
  let deploySkippedReason = null;
@@ -96554,7 +96557,7 @@ async function runDraftSpec(ctx, input, deps) {
96554
96557
  };
96555
96558
  }
96556
96559
  let constitution = null;
96557
- const boundedConstitution = process.env.MRRLIN_MCP_DRAFT_CONSTITUTION_BOUNDED?.trim() === "1";
96560
+ const boundedConstitution = killSwitchOn(process.env.MRRLIN_MCP_DRAFT_CONSTITUTION_BOUNDED);
96558
96561
  if (boundedConstitution) {
96559
96562
  try {
96560
96563
  const result = await client.getDraftConstitutionV1(projectSlug, { signal: ctx.signal });
@@ -96562,7 +96565,10 @@ async function runDraftSpec(ctx, input, deps) {
96562
96565
  if (result.kind === "found") constitution = result.markdownBody;
96563
96566
  } catch (error51) {
96564
96567
  ctx.signal?.throwIfAborted();
96565
- return { kind: "retry", failureReason: "provider_unavailable", error: `constitution lookup failed for ${projectSlug}: ${errMessage3(error51)}` };
96568
+ const definitelyAbsent = error51 instanceof MrrlinResponseTooLargeError || error51 instanceof MrrlinApiError && error51.status === 404;
96569
+ if (!definitelyAbsent) {
96570
+ return { kind: "retry", failureReason: "provider_unavailable", error: `constitution lookup failed for ${projectSlug}: ${errMessage3(error51)}` };
96571
+ }
96566
96572
  }
96567
96573
  } else {
96568
96574
  try {
@@ -106448,7 +106454,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
106448
106454
  }
106449
106455
 
106450
106456
  // src/_generated/version.ts
106451
- var PKG_VERSION = "0.4.230";
106457
+ var PKG_VERSION = "0.4.233";
106452
106458
 
106453
106459
  // src/bridge-allowed-origins.ts
106454
106460
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -111060,6 +111066,7 @@ init_dist();
111060
111066
  var ANSWERED_QUESTION_RESTARTED_BY = "bridge:answered-question";
111061
111067
  var LOG_PREFIX = "[mrrlin] answered-question resume";
111062
111068
  var PARKED_STATUSES = ["handoff_queued", "handoff_requested"];
111069
+ var RESUME_QUESTION_WINDOW = 50;
111063
111070
  function log(message) {
111064
111071
  process.stderr.write(`${LOG_PREFIX}: ${message}
111065
111072
  `);
@@ -111081,7 +111088,11 @@ async function resumeRunsWithAnsweredQuestions(client, projectSlug) {
111081
111088
  if (run5.blockingReason === "operator_stopped") continue;
111082
111089
  let linked;
111083
111090
  try {
111084
- const items = await client.listInboxItems(projectSlug, { kind: "question", taskId: run5.taskId });
111091
+ const items = await client.listInboxItems(projectSlug, {
111092
+ kind: "question",
111093
+ taskId: run5.taskId,
111094
+ limit: RESUME_QUESTION_WINDOW
111095
+ });
111085
111096
  linked = items.filter((item) => item.askingRunId === run5.id && item.origin == null);
111086
111097
  } catch (error51) {
111087
111098
  log(`listing questions of ${run5.taskId} failed: ${describe4(error51)}`);
@@ -111095,12 +111106,23 @@ async function resumeRunsWithAnsweredQuestions(client, projectSlug) {
111095
111106
  if (!newest || newest.status !== "acknowledged" || !newest.answer?.trim()) continue;
111096
111107
  if (newest.id === run5.resumedOnQuestionId) continue;
111097
111108
  try {
111098
- const task = await client.getTask(projectSlug, run5.taskId);
111109
+ const task = await client.getTask(projectSlug, run5.taskId, { boundedResponse: true });
111099
111110
  if (mrrlinTerminalTaskStatuses.includes(task.status)) continue;
111100
111111
  } catch (error51) {
111101
111112
  log(`reading task ${run5.taskId} failed: ${describe4(error51)}`);
111102
111113
  continue;
111103
111114
  }
111115
+ try {
111116
+ await client.restartExecutionRun(projectSlug, run5.id, {
111117
+ restartedBy: ANSWERED_QUESTION_RESTARTED_BY,
111118
+ answeredQuestionId: newest.id
111119
+ });
111120
+ restarted.push(run5.id);
111121
+ log(`restarted ${run5.id} on the answer to ${newest.id}`);
111122
+ } catch (error51) {
111123
+ log(`restarting ${run5.id} failed: ${describe4(error51)}`);
111124
+ continue;
111125
+ }
111104
111126
  for (const older of ordered.slice(1)) {
111105
111127
  if (older.status !== "pending") continue;
111106
111128
  try {
@@ -111113,16 +111135,6 @@ async function resumeRunsWithAnsweredQuestions(client, projectSlug) {
111113
111135
  log(`superseding ${older.id} failed: ${describe4(error51)}`);
111114
111136
  }
111115
111137
  }
111116
- try {
111117
- await client.restartExecutionRun(projectSlug, run5.id, {
111118
- restartedBy: ANSWERED_QUESTION_RESTARTED_BY,
111119
- answeredQuestionId: newest.id
111120
- });
111121
- restarted.push(run5.id);
111122
- log(`restarted ${run5.id} on the answer to ${newest.id}`);
111123
- } catch (error51) {
111124
- log(`restarting ${run5.id} failed: ${describe4(error51)}`);
111125
- }
111126
111138
  }
111127
111139
  return restarted;
111128
111140
  }
@@ -112254,6 +112266,10 @@ async function driveTurn(deps, codex, projectSlug, runId, leaseId, threadId, inp
112254
112266
  async function lockColdWorkWorktreeWithGit(worktreePath, signal) {
112255
112267
  await gitOutput(worktreePath, ["worktree", "lock", "--reason", "F74 cold work recovery", worktreePath], signal);
112256
112268
  }
112269
+ async function unlockColdWorkWorktreeWithGit(worktreePath, signal) {
112270
+ await gitOutput(worktreePath, ["worktree", "unlock", worktreePath], signal);
112271
+ }
112272
+ var COLD_WORK_RECONCILED_STATUSES = /* @__PURE__ */ new Set(["done", "failed", "cancelled", "pull_request", "dev_deploy", "prod_deploy", "handoff_queued"]);
112257
112273
  function defaultDrainSupervisor() {
112258
112274
  const endpoint = readDrainServiceEndpoint();
112259
112275
  if (!endpoint) return null;
@@ -113067,6 +113083,23 @@ ${renderTaskStateSection(taskState)}`;
113067
113083
  console.warn(JSON.stringify({ event: "executor_cold_work_recovery_pending", projectSlug, runId }));
113068
113084
  }
113069
113085
  };
113086
+ const releaseReconciledColdWorktree = async () => {
113087
+ if (!coldWorkReserved || !worktreePath) return;
113088
+ const run5 = await deps.client.getExecutionRun(projectSlug, runId).catch(() => null);
113089
+ if (!run5 || run5.coldWorkReconciliationId || !COLD_WORK_RECONCILED_STATUSES.has(run5.status)) return;
113090
+ const worktreeRoot = deps.worktreeRoot ?? "/tmp/mrrlin-worktrees";
113091
+ const supervisionId = deps.attemptSupervision?.supervisionId;
113092
+ if (supervisionId && listWorktreePins(worktreeRoot).some((pin) => pin.supervisionId === supervisionId)) {
113093
+ const check2 = verifyWorktreePin(worktreeRoot, supervisionId);
113094
+ if (!check2.ok) {
113095
+ console.warn(JSON.stringify({ event: "cold_work_worktree_kept", projectSlug, runId, reason: check2.reason }));
113096
+ return;
113097
+ }
113098
+ removeWorktreePin(worktreeRoot, check2.pin);
113099
+ }
113100
+ await (deps.unlockColdWorkWorktree ?? unlockColdWorkWorktreeWithGit)(worktreePath, AbortSignal.timeout(3e4)).catch(() => {
113101
+ });
113102
+ };
113070
113103
  let backgroundThreadId;
113071
113104
  const backgroundTransitionAllowed = async (phase) => {
113072
113105
  if (!f67BackgroundGateEnabled || !useExecutor || !coldWorkReserved) return true;
@@ -114111,6 +114144,7 @@ ${coldClosureInstruction}` : workInstruction;
114111
114144
  contentHash: `ch-${runId}`
114112
114145
  });
114113
114146
  }
114147
+ await releaseReconciledColdWorktree();
114114
114148
  if (useExecutor && worktreePath && checkout) {
114115
114149
  await removeWtFn({
114116
114150
  checkout: checkout.path,
@@ -114169,6 +114203,8 @@ ${coldClosureInstruction}` : workInstruction;
114169
114203
  leaseSignal?.removeEventListener("abort", disposeRunAgent);
114170
114204
  if (!deps.activeLease && !skipRunWrites) await persistRunReport();
114171
114205
  disposeRunAgent();
114206
+ await releaseReconciledColdWorktree().catch(() => {
114207
+ });
114172
114208
  }
114173
114209
  }
114174
114210
  async function writeServerOwnedTaskState(deps, projectSlug, taskId, runId, leaseId) {
@@ -124311,13 +124347,13 @@ function buildThreadStartParams(msg, config2, desiredModel) {
124311
124347
  // Dogfood v2 F-28: asked about GT-4, the Director repeated stop reasons that no longer held, offered no
124312
124348
  // restart, and sent the non-technical operator to "a technical person" for the task's human review.
124313
124349
  // The rule states what to do, never which past fixes made a reason stale: such a list rots.
124314
- "Parked runs (handoff_queued/handoff_requested): if asked or the blocker may be gone, re-check each stop reason now.",
124350
+ "Parked runs (handoff_queued/handoff_requested): if asked or the blocker may be gone, re-check each stop reason now; never repeat an earlier one unchecked.",
124315
124351
  "If none holds and `restart_execution_run` lists the reason as yours, restart and say it is queued again.",
124316
124352
  "Otherwise offer a restart in plain words; the operator's yes is the explicit ask. Never delegate a restart.",
124317
- "Keep a run parked while its blocker holds and explain what is missing. For human review, explain the change",
124353
+ "Keep a run parked while its blocker holds; say what is missing. For human review, explain the change",
124318
124354
  "and risk plainly, ask for approval and record it with `append_task_event`; restart on yes, park on no.",
124319
124355
  "Never send the operator to a technical person. Approval never clears independent review (the run re-runs it)",
124320
- "or restarts `operator_stopped` (operator only). The operator answers deploy approvals in Inbox, never in chat.",
124356
+ "or restarts `operator_stopped` (operator only). The operator answers deploy approvals in Inbox, never in chat or by you.",
124321
124357
  // Dogfood v2 F-46: the operator accepted GT-5 in chat; a note on GT-5 reached nothing GT-6's executor
124322
124358
  // reads, and rewriting GT-6's notes let a model decide what the acceptance lifts. It is state now.
124323
124359
  "When the operator accepts a task's result, record it with `record_task_acceptance` in their words: runs of",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.230",
3
+ "version": "0.4.233",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"