@mrrlin-dev/mcp 0.4.151 → 0.4.153

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 +101 -29
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -40362,8 +40362,16 @@ var mrrlinInboxItemActionPayloadSchema = external_exports.object({
40362
40362
  codeExecution: external_exports.boolean().optional(),
40363
40363
  // Optional scheduler recovery action carried by an info item.
40364
40364
  retryToolName: external_exports.string().min(1).optional(),
40365
- retryDedupKey: external_exports.string().min(1).optional()
40366
- });
40365
+ retryDedupKey: external_exports.string().min(1).optional(),
40366
+ capability: external_exports.string().optional(),
40367
+ capabilityPayload: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
40368
+ permitId: external_exports.string().optional(),
40369
+ scopeId: external_exports.string().optional(),
40370
+ serverId: external_exports.string().optional(),
40371
+ specRevision: external_exports.string().optional(),
40372
+ specWikiPageId: external_exports.string().optional(),
40373
+ toolName: external_exports.string().optional()
40374
+ }).passthrough();
40367
40375
  var mrrlinInboxQuestionOptionSchema = external_exports.object({
40368
40376
  answer: external_exports.string().trim().min(1),
40369
40377
  description: external_exports.string().trim().min(1),
@@ -40418,6 +40426,7 @@ var mrrlinInboxItemSchema = external_exports.object({
40418
40426
  id: mrrlinInboxItemIdSchema,
40419
40427
  kind: mrrlinInboxItemKindSchema,
40420
40428
  origin: external_exports.string().nullable().optional(),
40429
+ payloadDigest: external_exports.string().nullable().optional(),
40421
40430
  planId: mrrlinPlanIdSchema.nullable().default(null),
40422
40431
  projectSlug: mrrlinProjectSlugSchema,
40423
40432
  questionOptions: mrrlinInboxQuestionOptionsSchema.nullable().default(null),
@@ -40443,6 +40452,7 @@ var mrrlinInboxItemCreateSchema = external_exports.object({
40443
40452
  id: mrrlinInboxItemIdSchema,
40444
40453
  kind: mrrlinInboxItemKindSchema,
40445
40454
  origin: external_exports.string().min(1).optional(),
40455
+ payloadDigest: external_exports.string().min(1).nullable().optional(),
40446
40456
  planId: mrrlinPlanIdSchema.nullable().optional(),
40447
40457
  questionOptions: mrrlinInboxQuestionOptionsSchema.nullable().optional(),
40448
40458
  taskId: mrrlinTaskIdSchema.nullable().optional()
@@ -40458,6 +40468,7 @@ var mrrlinInboxItemCreateSchema = external_exports.object({
40458
40468
  var mrrlinInboxItemDecideSchema = external_exports.object({
40459
40469
  answer: external_exports.string().min(1).optional(),
40460
40470
  decidedBy: external_exports.string().min(1),
40471
+ expectedPayloadDigest: external_exports.string().min(1).optional(),
40461
40472
  reason: external_exports.string().min(1).optional(),
40462
40473
  verdict: external_exports.enum(["approved", "rejected", "acknowledged"])
40463
40474
  }).superRefine((value, context) => {
@@ -40481,6 +40492,7 @@ var mrrlinInboxItemSummarySchema = external_exports.object({
40481
40492
  id: mrrlinInboxItemIdSchema,
40482
40493
  kind: mrrlinInboxItemKindSchema,
40483
40494
  origin: external_exports.string().nullable().optional(),
40495
+ payloadDigest: external_exports.string().nullable().optional(),
40484
40496
  planId: mrrlinPlanIdSchema.nullable().default(null),
40485
40497
  projectSlug: mrrlinProjectSlugSchema,
40486
40498
  readAt: external_exports.string().datetime().nullable(),
@@ -40539,7 +40551,10 @@ var inboxItemsMarkReadResponseSchema = external_exports.object({
40539
40551
  readAt: external_exports.string().datetime()
40540
40552
  })
40541
40553
  });
40542
- var inboxItemResponseSchema = external_exports.object({ data: mrrlinInboxItemSchema });
40554
+ var inboxItemResponseSchema = external_exports.object({
40555
+ data: mrrlinInboxItemSchema,
40556
+ replayed: external_exports.boolean().optional()
40557
+ });
40543
40558
  var inboxItemListResponseSchema = external_exports.object({ data: external_exports.array(mrrlinInboxItemSchema) });
40544
40559
  var inboxItemSummaryListResponseSchema = external_exports.object({ data: external_exports.array(mrrlinInboxItemSummarySchema) });
40545
40560
  var capabilityServerIdSchema = external_exports.string().trim().min(1).max(200);
@@ -48622,14 +48637,16 @@ function renderCriteriaBlock(criteria) {
48622
48637
  return criteria.map((c, i) => `${i + 1}. [ ] ${c}`).join("\n");
48623
48638
  }
48624
48639
  async function buildDeliverableGateDeps(args) {
48625
- const { client, projectSlug, deliverablePageId, attemptOutcome, codexExecutable, runId, seat, stateDir } = args;
48640
+ const { client, projectSlug, deliverablePageId, attemptOutcome, codexExecutable, runId, seat, providerId, stateDir } = args;
48626
48641
  const consensusProvider = process.env.MRRLIN_CONSENSUS_PROVIDER?.trim().toLowerCase() || void 0;
48627
- const execProvider = consensusProvider ?? seat?.id;
48642
+ const execProvider = consensusProvider ?? providerId ?? seat?.id;
48643
+ const compatibleSeat = !consensusProvider && (!providerId || providerId === seat?.id) ? seat : void 0;
48644
+ const arbiterModel = compatibleSeat?.model ?? compatibleSeat?.models?.strong;
48628
48645
  const recordCost = gateCallRecorder({
48629
48646
  stateDir,
48630
48647
  projectSlug,
48631
48648
  gate: "deliverable",
48632
- provider: consensusProvider ?? seat?.id ?? null
48649
+ provider: execProvider ?? null
48633
48650
  });
48634
48651
  const rounds = Number(process.env["MRRLIN_CONSENSUS_ROUNDS"] ?? 5);
48635
48652
  const timeoutMs = Number(process.env["MRRLIN_CONSENSUS_HEAD_TIMEOUT_MS"] ?? 15e4);
@@ -48720,12 +48737,12 @@ ${persona}`,
48720
48737
  codexExecutable,
48721
48738
  // model-tier-planning-and-arbiter task 2.5 (D1): the arbiter is pinned to the seat's
48722
48739
  // default model.
48723
- model: consensusProvider ? void 0 : seat?.model ?? seat?.models?.strong
48740
+ model: arbiterModel
48724
48741
  },
48725
48742
  void 0,
48726
48743
  execProvider
48727
48744
  );
48728
- recordCost("arbiter", "arbiter", seat?.model ?? seat?.models?.strong ?? null, startedAt, result);
48745
+ recordCost("arbiter", "arbiter", arbiterModel ?? null, startedAt, result);
48729
48746
  return result;
48730
48747
  },
48731
48748
  async runReviser(artifact, accepted) {
@@ -55059,7 +55076,7 @@ var RepoHostRouteUnavailableError = class extends Error {
55059
55076
  };
55060
55077
  var NoGrantForServerError = class extends RepoHostRouteUnavailableError {
55061
55078
  };
55062
- async function proceedToDestination(client, route, resolvedToolName, input) {
55079
+ async function proceedToDestination(client, route, resolvedToolName, input, approvalItemId, boundPermitId) {
55063
55080
  const taskless = !input.taskId;
55064
55081
  if (taskless && !MRRLIN_API_CAPABILITIES.has(route.capability)) {
55065
55082
  await recordUse(client, route, resolvedToolName, input, "refused");
@@ -55081,7 +55098,16 @@ async function proceedToDestination(client, route, resolvedToolName, input) {
55081
55098
  if (input.taskId && client.issueCapabilityPermit && client.redeemCapabilityPermit) {
55082
55099
  try {
55083
55100
  const payloadDigest = import_node_crypto5.default.createHash("sha256").update(JSON.stringify(input.payload ?? null)).digest("hex");
55084
- const permit = await client.issueCapabilityPermit(input.taskProjectSlug, {
55101
+ const targetInvocationId = approvalItemId ? `inv_${approvalItemId}` : void 0;
55102
+ let effectivePermitId = boundPermitId;
55103
+ if (!effectivePermitId && targetInvocationId && client.getCapabilityInvocation) {
55104
+ try {
55105
+ const existingInv = await client.getCapabilityInvocation(input.taskProjectSlug, targetInvocationId);
55106
+ if (existingInv) effectivePermitId = existingInv.permitId;
55107
+ } catch {
55108
+ }
55109
+ }
55110
+ const permitId = effectivePermitId ?? (await client.issueCapabilityPermit(input.taskProjectSlug, {
55085
55111
  projectSlug: input.taskProjectSlug,
55086
55112
  taskId: input.taskId,
55087
55113
  serverId: route.serverId,
@@ -55089,12 +55115,13 @@ async function proceedToDestination(client, route, resolvedToolName, input) {
55089
55115
  toolName: resolvedToolName,
55090
55116
  operationClass: resolveOperationClass(route, "reversible"),
55091
55117
  payloadDigest
55092
- });
55093
- const idempotencyKey = `deliver:${input.taskProjectSlug}:${permit.id}`;
55118
+ })).id;
55119
+ const idempotencyKey = approvalItemId ? `deliver:approval:${approvalItemId}` : `deliver:${input.taskProjectSlug}:${permitId}`;
55094
55120
  const redemption = await client.redeemCapabilityPermit(input.taskProjectSlug, {
55095
- permitId: permit.id,
55121
+ permitId,
55096
55122
  idempotencyKey,
55097
- payloadDigest
55123
+ payloadDigest,
55124
+ invocationId: targetInvocationId
55098
55125
  });
55099
55126
  invocationId = redemption.id;
55100
55127
  if (redemption.replayed) {
@@ -55224,8 +55251,10 @@ async function handleApproval(client, route, resolvedToolName, input) {
55224
55251
  if (scopeId === null) {
55225
55252
  return refuse(client, route, resolvedToolName, input);
55226
55253
  }
55227
- const groupId = `capability:approval:${scopeId}:${route.serverId}:${resolvedToolName}`;
55228
- const id = `II-capability-approval-${scopeId}-${route.serverId}-${resolvedToolName}`;
55254
+ const payloadDigest = import_node_crypto5.default.createHash("sha256").update(JSON.stringify(input.payload ?? null)).digest("hex");
55255
+ const digestPrefix = payloadDigest.slice(0, 16);
55256
+ const groupId = `capability:approval:${scopeId}:${route.serverId}:${resolvedToolName}:${digestPrefix}`;
55257
+ const id = `II-capability-approval-${scopeId}-${route.serverId}-${resolvedToolName}-${digestPrefix}`;
55229
55258
  let items;
55230
55259
  try {
55231
55260
  items = await client.listInboxItems(input.taskProjectSlug, { groupId });
@@ -55237,26 +55266,56 @@ async function handleApproval(client, route, resolvedToolName, input) {
55237
55266
  try {
55238
55267
  await client.createInboxItem(input.taskProjectSlug, {
55239
55268
  id,
55240
- kind: "question",
55269
+ kind: "proposal",
55241
55270
  origin: "capability",
55242
55271
  groupId,
55243
- body: `Approve ${resolvedToolName} on ${route.serverId}?`,
55244
- taskId: input.taskId
55272
+ body: `Approve ${resolvedToolName} on ${route.serverId}?
55273
+
55274
+ Payload:
55275
+ \`\`\`json
55276
+ ${JSON.stringify(input.payload ?? {}, null, 2)}
55277
+ \`\`\``,
55278
+ taskId: input.taskId,
55279
+ payloadDigest,
55280
+ actionPayload: {
55281
+ actor: "agent",
55282
+ provider: "mcp",
55283
+ runId: input.runId ?? (input.taskId ? `ER-${input.taskId}` : "ER-CAP-APPROVAL"),
55284
+ codeExecution: false,
55285
+ capabilityPayload: input.payload ?? {},
55286
+ serverId: route.serverId,
55287
+ toolName: resolvedToolName,
55288
+ scopeId,
55289
+ capability: route.capability
55290
+ }
55245
55291
  });
55246
55292
  } catch {
55247
55293
  }
55248
55294
  return refuse(client, route, resolvedToolName, input);
55249
55295
  }
55250
- if (existing.status !== "approved") {
55296
+ if (!existing.payloadDigest || existing.payloadDigest !== payloadDigest) {
55297
+ return refuse(client, route, resolvedToolName, input);
55298
+ }
55299
+ const isApproved = existing.status === "approved";
55300
+ if (!isApproved) {
55251
55301
  return refuse(client, route, resolvedToolName, input);
55252
55302
  }
55253
55303
  if (existing.decidedAt === null) {
55254
55304
  return refuse(client, route, resolvedToolName, input);
55255
55305
  }
55256
- if (await alreadyConsumed(client, route, resolvedToolName, input, existing.decidedAt)) {
55306
+ const invocationId = `inv_${existing.id}`;
55307
+ let existingInv = null;
55308
+ if (client.getCapabilityInvocation) {
55309
+ try {
55310
+ existingInv = await client.getCapabilityInvocation(input.taskProjectSlug, invocationId);
55311
+ } catch {
55312
+ }
55313
+ }
55314
+ if (!existingInv && await alreadyConsumed(client, route, resolvedToolName, input, existing.decidedAt)) {
55257
55315
  return refuse(client, route, resolvedToolName, input);
55258
55316
  }
55259
- return proceedToDestination(client, route, resolvedToolName, input);
55317
+ const boundPermitId = existingInv?.permitId ?? existing.actionPayload?.permitId;
55318
+ return proceedToDestination(client, route, resolvedToolName, input, existing.id, boundPermitId);
55260
55319
  }
55261
55320
  async function handleWindow(client, route, resolvedToolName, input) {
55262
55321
  if (input.taskId === null) {
@@ -63960,7 +64019,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
63960
64019
  }
63961
64020
 
63962
64021
  // src/_generated/version.ts
63963
- var PKG_VERSION = "0.4.151";
64022
+ var PKG_VERSION = "0.4.153";
63964
64023
 
63965
64024
  // src/bridge-allowed-origins.ts
63966
64025
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -68420,7 +68479,18 @@ async function driveRun(deps, projectSlug, runId) {
68420
68479
  const isPureCode = runDomains.length === 1 && runDomains[0] === "code";
68421
68480
  if (!isPureCode) {
68422
68481
  const runDomain = runDomains[0] ?? "code";
68423
- await driveNonCodeRun(deps, projectSlug, runId, leaseId, task, runDomain, rawProject);
68482
+ let providerId = claimed.agentSeat;
68483
+ if (providerId == null) {
68484
+ const seat = await mintResolvedSeat(resolveProvider(process.env, getSelectedProvider()));
68485
+ void notifyPinRetirementIfRetired(seat);
68486
+ providerId = seat.id;
68487
+ await deps.client.updateExecutionRun(projectSlug, runId, { agentSeat: providerId }).catch((err) => {
68488
+ console.warn(
68489
+ JSON.stringify({ event: "agent_seat_persist_failed", projectSlug, runId, error: String(err) })
68490
+ );
68491
+ });
68492
+ }
68493
+ await driveNonCodeRun(deps, projectSlug, runId, leaseId, task, runDomain, providerId, rawProject);
68424
68494
  return;
68425
68495
  }
68426
68496
  const compactEnabled = (process.env.MRRLIN_MCP_COMPACT_DISABLE ?? "").trim() !== "1";
@@ -69416,7 +69486,7 @@ async function writeNegativeResultEvidencePage(client, projectSlug, task, input)
69416
69486
  }
69417
69487
  throw new Error(`could not allocate negative-result evidence page for ${task.id} (last conflict: ${lastConflict})`);
69418
69488
  }
69419
- async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2, project) {
69489
+ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2, providerId, project) {
69420
69490
  let rawProject = project;
69421
69491
  if (!rawProject) {
69422
69492
  try {
@@ -69496,7 +69566,7 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
69496
69566
  );
69497
69567
  return;
69498
69568
  }
69499
- const runExec = deps.runDeliverableExec ?? runAgentExec;
69569
+ const runExec = deps.runDeliverableExec ?? ((input, provider) => runAgentExec(input, void 0, provider));
69500
69570
  const touchTimer = setInterval(() => {
69501
69571
  void deps.client.touchExecutionRun(projectSlug, runId, leaseId).catch(() => {
69502
69572
  });
@@ -69512,7 +69582,7 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
69512
69582
  sandbox: "read-only",
69513
69583
  codexExecutable: deps.codexExecutable,
69514
69584
  mcpConfig: deps.mcpConfigPath
69515
- });
69585
+ }, providerId);
69516
69586
  if (!exec.ok) {
69517
69587
  await failRun(deps, projectSlug, task, runId, leaseId, `deliverable_authoring_failed: ${exec.error}`);
69518
69588
  return;
@@ -69572,6 +69642,7 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
69572
69642
  taskId: task.id,
69573
69643
  runId,
69574
69644
  deliverablePageId: pageId,
69645
+ providerId,
69575
69646
  attemptOutcome: parsedResult.outcome
69576
69647
  });
69577
69648
  } catch (error51) {
@@ -79762,12 +79833,13 @@ async function startDirectorBridge() {
79762
79833
  // ADR 0020 Phase 2: run the deliverable-gate over a non-code run's authored Deliverables page.
79763
79834
  // Builds the gate deps (resolving domain/heads/criteria from the page's task + spec) and runs the
79764
79835
  // same convergence loop the spec-gate uses. runId is threaded for verdict provenance (decision 10).
79765
- // Authoring uses the defaults (runAgentExec + loadPersona) — no extra wiring needed for those.
79766
- runDeliverableGate: async ({ projectSlug, runId, deliverablePageId, attemptOutcome }) => {
79836
+ // Authoring uses the consumer’s explicit provider adapter; review inherits the same run pin.
79837
+ runDeliverableGate: async ({ projectSlug, runId, deliverablePageId, attemptOutcome, providerId }) => {
79767
79838
  const gateDeps = await buildDeliverableGateDeps({
79768
79839
  client,
79769
79840
  projectSlug,
79770
79841
  deliverablePageId,
79842
+ providerId,
79771
79843
  attemptOutcome,
79772
79844
  cwd: config2.codexCwd ?? process.cwd(),
79773
79845
  codexExecutable: config2.codexExecutable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.151",
3
+ "version": "0.4.153",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"