@mrrlin-dev/mcp 0.4.219 → 0.4.220

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 +66 -64
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -89031,64 +89031,60 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
89031
89031
  }
89032
89032
  }
89033
89033
  }
89034
- let filedQuestionCount = 0;
89035
- if (toFile.length > 0) {
89036
- if (taskId) {
89037
- const scopeId = taskId;
89038
- const prefix = result.evaluatedClarificationKey ? mixedCodeClarificationIdPrefix(scopeId, result.evaluatedClarificationKey) : `II-${scopeId}-gate-`;
89039
- const groupId = toFile.length > 1 ? `${prefix}group-${(0, import_node_crypto10.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
89040
- for (const clarification of toFile) {
89041
- const id = `${prefix}${(0, import_node_crypto10.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
89042
- try {
89043
- const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
89044
- await ctx.client.createInboxItem(input.projectSlug, {
89045
- id,
89046
- kind: "question",
89047
- taskId: scopeId,
89048
- body: humanizeClarificationBody(clarification),
89049
- origin: "gate",
89050
- questionOptions,
89051
- ...groupId ? { groupId } : {}
89052
- });
89053
- } catch (err) {
89054
- const errObj = err;
89055
- const isConflict = errObj?.status === 409 || errObj?.statusCode === 409 || errObj?.code === "23505" || String(errObj?.message ?? "").includes("already exists") || String(errObj?.message ?? "").includes("duplicate key");
89056
- if (!isConflict) {
89057
- throw err;
89058
- }
89059
- }
89034
+ const confirmedQuestionIds = /* @__PURE__ */ new Set();
89035
+ let clarificationDeliveryIncomplete = false;
89036
+ const scopeId = taskId ?? planId;
89037
+ if (toFile.length > 0 && scopeId) {
89038
+ const clarificationKey = taskId ? result.evaluatedClarificationKey : void 0;
89039
+ const prefix = clarificationKey ? mixedCodeClarificationIdPrefix(scopeId, clarificationKey) : `II-${scopeId}-gate-`;
89040
+ const groupId = toFile.length > 1 ? `${prefix}group-${(0, import_node_crypto10.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
89041
+ const questions = toFile.map((clarification) => ({
89042
+ id: `${prefix}${(0, import_node_crypto10.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`,
89043
+ kind: "question",
89044
+ ...taskId ? { taskId } : { planId: scopeId },
89045
+ body: humanizeClarificationBody(clarification),
89046
+ origin: "gate",
89047
+ questionOptions: buildGateQuestionOptions(clarification.rawQuestion, clarification.category),
89048
+ ...groupId ? { groupId } : {}
89049
+ }));
89050
+ const matchesQuestion = (item, question) => {
89051
+ if (!item?.id || item.projectSlug !== input.projectSlug || item.kind !== "question" || item.origin !== "gate" || item.status !== "pending" || item.taskId !== taskId || item.planId !== planId || item.body !== question.body) return false;
89052
+ if (taskId && mixedCodeClarificationKeyFromId(taskId, item.id) !== clarificationKey) return false;
89053
+ const expected = question.questionOptions;
89054
+ const stored = item.questionOptions;
89055
+ if (!expected) return stored === null || stored === void 0;
89056
+ return stored?.length === expected.length && expected.every((option) => stored.some((actual) => actual.answer === option.answer && actual.label === option.label && actual.description === option.description));
89057
+ };
89058
+ const uncertain = [];
89059
+ for (const question of questions) {
89060
+ let item;
89061
+ try {
89062
+ item = await ctx.client.createInboxItem(input.projectSlug, question);
89063
+ } catch {
89064
+ uncertain.push(question);
89065
+ continue;
89060
89066
  }
89061
- filedQuestionCount = toFile.length;
89062
- } else if (planId) {
89063
- const scopeId = planId;
89064
- const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto10.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
89065
- for (const clarification of toFile) {
89066
- const id = `II-${scopeId}-gate-${(0, import_node_crypto10.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
89067
- try {
89068
- const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
89069
- await ctx.client.createInboxItem(input.projectSlug, {
89070
- id,
89071
- kind: "question",
89072
- planId: scopeId,
89073
- body: humanizeClarificationBody(clarification),
89074
- origin: "gate",
89075
- questionOptions,
89076
- ...groupId ? { groupId } : {}
89077
- });
89078
- } catch (err) {
89079
- const errObj = err;
89080
- const isConflict = errObj?.status === 409 || errObj?.statusCode === 409 || errObj?.code === "23505" || String(errObj?.message ?? "").includes("already exists") || String(errObj?.message ?? "").includes("duplicate key");
89081
- if (!isConflict) {
89082
- throw err;
89083
- }
89084
- }
89067
+ if (matchesQuestion(item, question)) confirmedQuestionIds.add(item.id);
89068
+ else clarificationDeliveryIncomplete = true;
89069
+ }
89070
+ if (uncertain.length > 0) {
89071
+ const pending = await ctx.client.listInboxItems(input.projectSlug, {
89072
+ ...taskId ? { taskId } : {},
89073
+ kind: "question",
89074
+ status: "pending",
89075
+ limit: 100
89076
+ }).catch(() => []);
89077
+ for (const question of uncertain) {
89078
+ const item = pending.find((candidate) => matchesQuestion(candidate, question));
89079
+ if (item) confirmedQuestionIds.add(item.id);
89080
+ else clarificationDeliveryIncomplete = true;
89085
89081
  }
89086
- filedQuestionCount = toFile.length;
89087
89082
  }
89088
89083
  }
89084
+ const filedQuestionCount = confirmedQuestionIds.size;
89089
89085
  const existingQuestionCount = result.pendingReviewQuestionIds?.length ?? 0;
89090
89086
  let gateBlockQuestionAvailable;
89091
- if (filedQuestionCount === 0 && existingQuestionCount === 0 && diagnostics.length === 0 && taskId && page) {
89087
+ if (!clarificationDeliveryIncomplete && filedQuestionCount === 0 && existingQuestionCount === 0 && diagnostics.length === 0 && taskId && page) {
89092
89088
  const domain2 = await resolveSpecDomain(ctx.client, input.projectSlug, {
89093
89089
  id: page.id,
89094
89090
  taskId: page.taskId ?? null
@@ -89125,7 +89121,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
89125
89121
  }
89126
89122
  }
89127
89123
  let error51;
89128
- if (filedQuestionCount > 0) {
89124
+ if (clarificationDeliveryIncomplete) {
89125
+ error51 = filedQuestionCount === 0 ? "No open clarification questions could be confirmed in the Inbox." : `Confirmed ${filedQuestionCount} open clarification question${filedQuestionCount === 1 ? "" : "s"} in the Inbox. Some questions could not be confirmed.`;
89126
+ } else if (filedQuestionCount > 0) {
89129
89127
  error51 = `Consensus blocked on ${filedQuestionCount} clarification(s); filed as operator question(s).`;
89130
89128
  } else if (existingQuestionCount > 0) {
89131
89129
  error51 = `Consensus still needs ${existingQuestionCount} pending clarification(s) answered in the spec.`;
@@ -89146,17 +89144,19 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
89146
89144
  if (gateBlockQuestionAvailable === false) {
89147
89145
  error51 += " No open decision question could be confirmed in the Inbox.";
89148
89146
  }
89149
- if (result.escalation && gateBlockQuestionAvailable !== false) {
89147
+ if (result.escalation && !clarificationDeliveryIncomplete && gateBlockQuestionAvailable !== false) {
89150
89148
  error51 += ` (reason: ${result.escalation.diagnosis})`;
89151
89149
  }
89152
89150
  const isRelationshipDiagnostic = isSeedAbsence || result.diagnostics?.some((d) => d.kind === "spec_identity_mismatch") || result.escalation?.diagnosis === "spec_identity_mismatch";
89153
- const deliveryTaskId = gateBlockQuestionAvailable === void 0 ? resolvedTaskId : taskId;
89151
+ const attemptedClarifications = Boolean(scopeId && toFile.length > 0);
89152
+ const deliveryTaskId = attemptedClarifications || gateBlockQuestionAvailable !== void 0 ? taskId : resolvedTaskId;
89154
89153
  return {
89155
89154
  kind: "failed",
89156
89155
  failureReason: "consensus_blocked",
89157
89156
  error: error51,
89158
- filedQuestionCount: filedQuestionCount || existingQuestionCount,
89159
- ...gateBlockQuestionAvailable ? { gateBlockQuestionAvailable } : {},
89157
+ filedQuestionCount: attemptedClarifications ? filedQuestionCount : existingQuestionCount,
89158
+ ...clarificationDeliveryIncomplete ? { clarificationDeliveryIncomplete } : {},
89159
+ ...gateBlockQuestionAvailable !== void 0 ? { gateBlockQuestionAvailable } : {},
89160
89160
  finalReviewedHash: isRelationshipDiagnostic ? null : result.evaluatedReviewHash ?? result.evaluatedSnapshot?.contentHash ?? null,
89161
89161
  ...deliveryTaskId ? { taskId: deliveryTaskId } : {}
89162
89162
  };
@@ -89303,7 +89303,7 @@ async function run2(ctx, input, builders = defaultNativeSpecGateBuilders) {
89303
89303
  };
89304
89304
  }
89305
89305
  }
89306
- function onComplete(outcome, input) {
89306
+ function onComplete(outcome, input, context) {
89307
89307
  if (outcome.kind === "superseded") {
89308
89308
  return {
89309
89309
  kind: "info",
@@ -89343,7 +89343,7 @@ ${findings.map((f) => `\u2022 ${f}`).join("\n")}` : "";
89343
89343
  body: taskRef ? `The reviewers agreed on this spec \u2014 ${roster}.${findingsBlock}` : `The reviewers agreed on this spec (Specs/${input.pageId}) \u2014 ${roster}.${findingsBlock}`
89344
89344
  };
89345
89345
  }
89346
- if (outcome.kind === "failed" && (outcome.filedQuestionCount ?? 0) > 0) {
89346
+ if (outcome.kind === "failed" && !outcome.clarificationDeliveryIncomplete && (outcome.filedQuestionCount ?? 0) > 0) {
89347
89347
  const n = outcome.filedQuestionCount ?? 0;
89348
89348
  return {
89349
89349
  kind: "info",
@@ -89361,10 +89361,11 @@ ${findings.map((f) => `\u2022 ${f}`).join("\n")}` : "";
89361
89361
  };
89362
89362
  }
89363
89363
  const handoffTaskRef = taskRef ? ` (${taskRef})` : "";
89364
- const revisionSuffix = "finalReviewedHash" in outcome && outcome.finalReviewedHash ? outcome.finalReviewedHash.slice(0, 8) : "init";
89364
+ const incompleteDelivery = outcome.kind === "failed" && (outcome.clarificationDeliveryIncomplete || outcome.gateBlockQuestionAvailable === false);
89365
+ const handoffSuffix = incompleteDelivery && context ? `job-${(0, import_node_crypto10.createHash)("sha256").update(JSON.stringify([context.projectSlug, context.jobId, context.createdAt])).digest("hex").slice(0, 32)}` : "finalReviewedHash" in outcome && outcome.finalReviewedHash ? outcome.finalReviewedHash.slice(0, 8) : "init";
89365
89366
  return {
89366
89367
  kind: "handoff",
89367
- id: `II-SPEC-STOPPED-${input.pageId}-${revisionSuffix}`,
89368
+ id: `II-SPEC-STOPPED-${input.pageId}-${handoffSuffix}`,
89368
89369
  ...taskId ? { taskId } : {},
89369
89370
  body: `The spec review stopped for Specs/${input.pageId}${handoffTaskRef}. ${outcome.error} Review the spec or consult the Director to update it.`
89370
89371
  };
@@ -99672,7 +99673,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
99672
99673
  }
99673
99674
 
99674
99675
  // src/_generated/version.ts
99675
- var PKG_VERSION = "0.4.219";
99676
+ var PKG_VERSION = "0.4.220";
99676
99677
 
99677
99678
  // src/bridge-allowed-origins.ts
99678
99679
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -108783,6 +108784,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
108783
108784
  if (reportAction && (claimed?.leaseId !== ownedClaim?.leaseId || claimed?.status !== "running")) return;
108784
108785
  if (shutdown?.aborted || !claimed || !claimed.leaseId) return;
108785
108786
  const leaseId = claimed.leaseId;
108787
+ const completionContext = { projectSlug: claimed.projectSlug, jobId: claimed.id, createdAt: claimed.createdAt };
108786
108788
  const ownership = reportAction ? new AbortController() : void 0;
108787
108789
  if (ownership) shutdown = shutdown ? AbortSignal.any([shutdown, ownership.signal]) : ownership.signal;
108788
108790
  let validUntil = claimStart + (ownedClaim?.leaseRemainingMs ?? 0);
@@ -108909,7 +108911,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
108909
108911
  beginning = true;
108910
108912
  if (heartbeatPending) await heartbeatPending;
108911
108913
  if (!checkOwnership()) return;
108912
- const delivery2 = outcome.kind === "superseded" ? void 0 : descriptor2.onComplete(outcome, input);
108914
+ const delivery2 = outcome.kind === "superseded" ? void 0 : descriptor2.onComplete(outcome, input, completionContext);
108913
108915
  if (delivery2 && !delivery2.suppressInbox && delivery2.kind !== "info" && delivery2.kind !== "handoff") {
108914
108916
  throw new Error("Unsupported report evidence delivery kind");
108915
108917
  }
@@ -108966,7 +108968,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
108966
108968
  }
108967
108969
  }
108968
108970
  if (shutdown?.aborted) return;
108969
- const delivery = descriptor2.onComplete(outcome, input);
108971
+ const delivery = descriptor2.onComplete(outcome, input, completionContext);
108970
108972
  if (!delivery.suppressInbox) {
108971
108973
  await deps.client.createInboxItem(projectSlug, {
108972
108974
  id: delivery.id ?? `II-${import_node_crypto27.default.randomUUID()}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.219",
3
+ "version": "0.4.220",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"