@mrrlin-dev/mcp 0.4.192 → 0.4.198

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 +99 -16
  2. package/package.json +2 -2
package/dist/bin.cjs CHANGED
@@ -67646,6 +67646,16 @@ var mrrlinExecutionRunSchema = external_exports.object({
67646
67646
  outcomeAcceptedAt: external_exports.string().datetime().nullable().default(null),
67647
67647
  resumedOnQuestionId: external_exports.string().nullable().default(null)
67648
67648
  });
67649
+ var compactExecutionTouchResponseSchema = external_exports.object({
67650
+ data: mrrlinExecutionRunSchema.pick({ projectSlug: true, id: true, leaseId: true, leaseRemainingMs: true }).extend({
67651
+ leaseId: external_exports.string().min(1),
67652
+ status: external_exports.literal("running"),
67653
+ executorBearer: external_exports.string().min(1).optional()
67654
+ }).strict()
67655
+ }).strict();
67656
+ var compactAsyncTouchResponseSchema = external_exports.object({
67657
+ data: external_exports.object({ applied: external_exports.literal(true) }).strict()
67658
+ }).strict();
67649
67659
  var mrrlinTaskStateSchema = external_exports.object({
67650
67660
  projectSlug: mrrlinProjectSlugSchema,
67651
67661
  taskId: mrrlinTaskIdSchema,
@@ -69871,6 +69881,30 @@ function createMrrlinClient(config2) {
69871
69881
  });
69872
69882
  return executionRunResponseSchema.parse(body).data;
69873
69883
  },
69884
+ async touchExecutionRunLease(projectSlug, runId, leaseId) {
69885
+ try {
69886
+ const response = await request(`${projectPath(projectSlug)}/execution-runs/${encodeURIComponent(runId)}/touch-lease`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ leaseId }) });
69887
+ const data = compactExecutionTouchResponseSchema.parse(response).data;
69888
+ if (data.projectSlug !== projectSlug || data.id !== runId || data.leaseId !== leaseId || data.executorBearer === void 0 !== (data.leaseRemainingMs === void 0)) {
69889
+ throw new Error("Compact heartbeat returned a different execution lease");
69890
+ }
69891
+ return data;
69892
+ } catch (error51) {
69893
+ if (error51 instanceof MrrlinApiError && error51.status === 409 && error51.code !== "EXECUTION_LEASE_EFFECT_BUSY" && error51.code !== "COMPACT_HEARTBEAT_UNREPRESENTABLE")
69894
+ return null;
69895
+ throw error51;
69896
+ }
69897
+ },
69898
+ async touchAsyncJobLease(projectSlug, jobId, leaseId) {
69899
+ try {
69900
+ const response = await request(`${projectPath(projectSlug)}/async-jobs/${encodeURIComponent(jobId)}/touch-lease`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ leaseId }) });
69901
+ return compactAsyncTouchResponseSchema.parse(response).data.applied;
69902
+ } catch (error51) {
69903
+ if (error51 instanceof MrrlinApiError && error51.status === 409)
69904
+ return false;
69905
+ throw error51;
69906
+ }
69907
+ },
69874
69908
  async touchExecutionRun(projectSlug, runId, leaseId) {
69875
69909
  try {
69876
69910
  const body = await request(`${projectPath(projectSlug)}/execution-runs/${encodeURIComponent(runId)}/touch`, {
@@ -97200,7 +97234,7 @@ function createOwnedStreamingFetch(scope, origin) {
97200
97234
  throw new TypeError("Invalid streaming transport origin");
97201
97235
  }
97202
97236
  return async (input) => {
97203
- const { deadlineAt, signal, method } = input;
97237
+ const { deadlineAt, deadlineSignal, signal, method } = input;
97204
97238
  const url2 = new URL(input.url);
97205
97239
  if (url2.origin !== expected.origin || url2.username || url2.password || url2.hash || !["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"].includes(method) || input.body !== void 0 && (typeof input.body !== "string" && !(input.body instanceof Uint8Array) || method === "GET" || method === "HEAD")) {
97206
97240
  throw new TypeError("Unsupported streaming request");
@@ -97212,7 +97246,14 @@ function createOwnedStreamingFetch(scope, origin) {
97212
97246
  if (!Number.isFinite(remaining) || remaining <= 0 || remaining > 2147483647 || signal?.aborted) throw aborted2();
97213
97247
  let onDeadline = expire;
97214
97248
  const timer = setTimeout(() => onDeadline(), Math.ceil(remaining));
97215
- const caller = signal ? (0, import_node_events3.addAbortListener)(signal, expire) : void 0;
97249
+ let canceledBeforeDeadline = false;
97250
+ const caller = signal ? (0, import_node_events3.addAbortListener)(signal, () => {
97251
+ if (deadlineSignal?.aborted && signal.reason === deadlineSignal.reason) onDeadline();
97252
+ else {
97253
+ canceledBeforeDeadline = performance.now() < deadlineAt;
97254
+ expire();
97255
+ }
97256
+ }) : void 0;
97216
97257
  let retained = false;
97217
97258
  const cleanup = () => {
97218
97259
  clearTimeout(timer);
@@ -97227,7 +97268,7 @@ function createOwnedStreamingFetch(scope, origin) {
97227
97268
  });
97228
97269
  let waitingForHeaders = false;
97229
97270
  const rotate = () => {
97230
- if (waitingForHeaders) input.rotateOnHeaderTimeout?.rotate(operation.generation);
97271
+ if (waitingForHeaders && !canceledBeforeDeadline) input.rotateOnHeaderTimeout?.rotate(operation.generation);
97231
97272
  };
97232
97273
  onDeadline = () => {
97233
97274
  rotate();
@@ -97989,8 +98030,9 @@ function createOwnedSdkOperation(options) {
97989
98030
  const authenticate = createScopedTokenRefresh(options, "ordinary");
97990
98031
  return (session) => {
97991
98032
  const deadlineAt = session?.deadlineAt ?? performance.now() + options.timeoutMs;
98033
+ const deadlineSignal = AbortSignal.timeout(Math.max(0, Math.ceil(deadlineAt - performance.now())));
97992
98034
  return {
97993
- signal: AbortSignal.timeout(Math.max(0, Math.ceil(deadlineAt - performance.now()))),
98035
+ signal: deadlineSignal,
97994
98036
  headers: async (authSignal) => ({
97995
98037
  authorization: "Bearer " + (session?.token ?? await authenticate(authSignal, deadlineAt))
97996
98038
  }),
@@ -98004,6 +98046,7 @@ function createOwnedSdkOperation(options) {
98004
98046
  url: url2,
98005
98047
  method,
98006
98048
  deadlineAt,
98049
+ deadlineSignal,
98007
98050
  rotateOnHeaderTimeout: options.generations,
98008
98051
  signal: init?.signal ?? void 0,
98009
98052
  headers: Object.fromEntries(new Headers(init?.headers)),
@@ -99206,7 +99249,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
99206
99249
  }
99207
99250
 
99208
99251
  // src/_generated/version.ts
99209
- var PKG_VERSION = "0.4.192";
99252
+ var PKG_VERSION = "0.4.198";
99210
99253
 
99211
99254
  // src/bridge-allowed-origins.ts
99212
99255
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -104388,6 +104431,8 @@ async function runHasLease(deps, projectSlug, runId, leaseId) {
104388
104431
  }
104389
104432
  var MIXED_CODE_APPROVAL_POLL_MS = 2e3;
104390
104433
  var MIXED_CODE_APPROVAL_REQUEST_MS = 3e3;
104434
+ var ReservedLocalDeliveryFailure = class extends Error {
104435
+ };
104391
104436
  var MixedCodeApprovalError = class extends Error {
104392
104437
  constructor(code, message) {
104393
104438
  super(`${code}: ${message}`);
@@ -105239,7 +105284,6 @@ ${renderTaskStateSection(taskState)}`;
105239
105284
  let resolvedDefaultBranch = null;
105240
105285
  let useExecutor = false;
105241
105286
  let coldWorkReserved = false;
105242
- let freshThreadPublished = false;
105243
105287
  let skipRunWrites = false;
105244
105288
  const parkUnconfirmedWork = async (stopExecutor = deps.activeLease !== void 0) => {
105245
105289
  if (stopExecutor) disposeRunAgent();
@@ -105817,7 +105861,6 @@ ${coldClosureInstruction}` : workInstruction;
105817
105861
  if (useExecutor) await noteDeliverySkipped(deps, projectSlug, task.id, runId);
105818
105862
  return;
105819
105863
  }
105820
- freshThreadPublished = true;
105821
105864
  }
105822
105865
  if (isNearContextLimit(outcome.telemetry.usage, outcome.telemetry.contextWindow)) {
105823
105866
  console.warn(
@@ -105967,6 +106010,7 @@ ${coldClosureInstruction}` : workInstruction;
105967
106010
  }
105968
106011
  if (f67BackgroundGateEnabled && !await backgroundTransitionAllowed("delivery")) return;
105969
106012
  if (localGitMode) {
106013
+ const holdOnFailure = coldWorkReserved;
105970
106014
  const deliveryWorktree = worktreePath;
105971
106015
  const deliveryTask = readiness.task;
105972
106016
  const deliveryKey = deliveryLockKey(localCheckoutRealPath ?? checkout?.path ?? deliveryWorktree);
@@ -105982,11 +106026,13 @@ ${coldClosureInstruction}` : workInstruction;
105982
106026
  deliveryKey,
105983
106027
  async () => {
105984
106028
  if (!await runHasLease(deps, projectSlug, runId, leaseId)) {
106029
+ if (holdOnFailure) throw new WorkLeaseUnavailableError();
105985
106030
  await noteDeliverySkipped(deps, projectSlug, task.id, runId);
105986
106031
  return;
105987
106032
  }
105988
106033
  await guard?.check();
105989
106034
  const integrated = await integrateBeforeReceipt(deps, {
106035
+ holdOnFailure,
105990
106036
  projectSlug,
105991
106037
  task: deliveryTask,
105992
106038
  runId,
@@ -106006,6 +106052,7 @@ ${coldClosureInstruction}` : workInstruction;
106006
106052
  const delivery = { settled: false };
106007
106053
  try {
106008
106054
  await deliverLocalRun(deps, {
106055
+ holdOnFailure,
106009
106056
  projectSlug,
106010
106057
  task: deliveryTask,
106011
106058
  runId,
@@ -106020,9 +106067,15 @@ ${coldClosureInstruction}` : workInstruction;
106020
106067
  });
106021
106068
  } catch (error51) {
106022
106069
  const merge2 = integrated.integration;
106023
- if (delivery.settled || !merge2?.mergeSha) throw error51;
106070
+ if (delivery.settled || error51 instanceof WorkLeaseUnavailableError) throw error51;
106071
+ if (holdOnFailure) {
106072
+ if (error51 instanceof MixedCodeApprovalError) throw error51;
106073
+ throw new ReservedLocalDeliveryFailure("local_delivery_failed");
106074
+ }
106075
+ if (!merge2?.mergeSha) throw error51;
106024
106076
  const message = error51 instanceof Error ? error51.message : String(error51);
106025
- const approvalFailure = error51 instanceof MixedCodeApprovalError;
106077
+ const approvalFailure = guard?.signal.reason instanceof MixedCodeApprovalError ? guard.signal.reason : error51 instanceof MixedCodeApprovalError ? error51 : void 0;
106078
+ if (approvalFailure && coldWorkReserved) throw approvalFailure;
106026
106079
  const acted = !approvalFailure && await failRun(deps, projectSlug, deliveryTask, runId, leaseId, `local_delivery_failed: ${message}`);
106027
106080
  const state = await readSettlementState(deps, projectSlug, deliveryTask.id, runId, 1);
106028
106081
  const settledElsewhere = !state || state.runDone || state.taskTerminal;
@@ -106266,10 +106319,21 @@ ${coldClosureInstruction}` : workInstruction;
106266
106319
  skipRunWrites = true;
106267
106320
  return;
106268
106321
  }
106269
- const approvalError = guard?.signal.reason ?? error51;
106270
- if (approvalError instanceof MixedCodeApprovalError) disposeRunAgent();
106271
- if (approvalError instanceof MixedCodeApprovalError && (!coldWorkReserved || freshThreadPublished)) {
106272
- await reportMixedApprovalFailure(approvalError);
106322
+ const approvalError = guard?.signal.reason instanceof MixedCodeApprovalError ? guard.signal.reason : error51 instanceof MixedCodeApprovalError ? error51 : void 0;
106323
+ if (approvalError) {
106324
+ if (coldWorkReserved) {
106325
+ skipRunWrites = true;
106326
+ console.warn(JSON.stringify({ event: "executor_cold_work_approval_lost", projectSlug, runId, code: approvalError.code }));
106327
+ await parkUnconfirmedWork(true);
106328
+ } else {
106329
+ disposeRunAgent();
106330
+ await reportMixedApprovalFailure(approvalError);
106331
+ }
106332
+ return;
106333
+ }
106334
+ if (error51 instanceof ReservedLocalDeliveryFailure) {
106335
+ skipRunWrites = true;
106336
+ await parkUnconfirmedWork(true);
106273
106337
  return;
106274
106338
  }
106275
106339
  if (coldWorkReserved) {
@@ -106871,7 +106935,7 @@ async function integrateBeforeReceipt(deps, ctx) {
106871
106935
  let branchSeen = null;
106872
106936
  const readRunTip = async () => gitOutput(worktreePath, ["rev-parse", "--verify", "-q", `refs/heads/${worktreeBranch(runId)}`]).catch(() => null);
106873
106937
  const restore2 = () => {
106874
- if (!preMergeHead || !branchSeen) return;
106938
+ if (ctx.holdOnFailure || !preMergeHead || !branchSeen) return;
106875
106939
  const restored = restoreRunBranch({
106876
106940
  worktreePath,
106877
106941
  runId,
@@ -106886,6 +106950,7 @@ async function integrateBeforeReceipt(deps, ctx) {
106886
106950
  try {
106887
106951
  const onBranch = await gitOutput(worktreePath, ["rev-parse", "--abbrev-ref", "HEAD"]);
106888
106952
  if (onBranch !== worktreeBranch(runId)) {
106953
+ if (ctx.holdOnFailure) throw new ReservedLocalDeliveryFailure("local_integration_failed");
106889
106954
  await failRun(
106890
106955
  deps,
106891
106956
  projectSlug,
@@ -106896,11 +106961,17 @@ async function integrateBeforeReceipt(deps, ctx) {
106896
106961
  );
106897
106962
  return { proceed: false };
106898
106963
  }
106899
- if (!await runHasLease(deps, projectSlug, runId, leaseId)) return { proceed: false };
106964
+ if (!await runHasLease(deps, projectSlug, runId, leaseId)) {
106965
+ if (ctx.holdOnFailure) throw new WorkLeaseUnavailableError();
106966
+ return { proceed: false };
106967
+ }
106900
106968
  await ctx.guard?.check();
106901
106969
  commitUncommittedWork({ worktreePath, runId });
106902
106970
  if (countOwnCommits({ worktreePath, baseSha: ctx.baseSha }) === 0) return { proceed: true };
106903
- if (!await runHasLease(deps, projectSlug, runId, leaseId)) return { proceed: false };
106971
+ if (!await runHasLease(deps, projectSlug, runId, leaseId)) {
106972
+ if (ctx.holdOnFailure) throw new WorkLeaseUnavailableError();
106973
+ return { proceed: false };
106974
+ }
106904
106975
  await ctx.guard?.check();
106905
106976
  const hooksDir = prepareDisabledGitHooksDir(deps.locksDir ?? "/tmp/mrrlin-locks", runId);
106906
106977
  const result = integrateDefaultBranch({ worktreePath, defaultBranch, runId, hooksDir });
@@ -106922,6 +106993,7 @@ async function integrateBeforeReceipt(deps, ctx) {
106922
106993
  const noBudget = `local_integration_conflict: ${defaultBranch} and ${runId} conflict in ${files}; no turn budget was left to resolve them. ${options}`;
106923
106994
  const budget = Math.min(completionTurnBudgetMs(), ctx.remainingTurnBudgetMs());
106924
106995
  if (isCompletionTurnDisabled() || budget < completionTurnMinBudgetMs()) {
106996
+ if (ctx.holdOnFailure) throw new ReservedLocalDeliveryFailure("local_integration_failed");
106925
106997
  restore2();
106926
106998
  await failRun(deps, projectSlug, task, runId, leaseId, noBudget);
106927
106999
  return { proceed: false };
@@ -106941,12 +107013,14 @@ async function integrateBeforeReceipt(deps, ctx) {
106941
107013
  );
106942
107014
  branchSeen = await readRunTip();
106943
107015
  if (!turn.ok) {
107016
+ if (ctx.holdOnFailure) throw new ReservedLocalDeliveryFailure("local_integration_failed");
106944
107017
  await resetWedgedThread(deps, projectSlug, task.id, turn.interruptFailed);
106945
107018
  restore2();
106946
107019
  await failRun(deps, projectSlug, task, runId, leaseId, `${noBudget} Turn error: ${turn.error}`);
106947
107020
  return { proceed: false };
106948
107021
  }
106949
107022
  if (!await runHasLease(deps, projectSlug, runId, leaseId)) {
107023
+ if (ctx.holdOnFailure) throw new WorkLeaseUnavailableError();
106950
107024
  restore2();
106951
107025
  return { proceed: false };
106952
107026
  }
@@ -106964,6 +107038,7 @@ async function integrateBeforeReceipt(deps, ctx) {
106964
107038
  });
106965
107039
  branchSeen = await readRunTip();
106966
107040
  if (!verdict.ok) {
107041
+ if (ctx.holdOnFailure) throw new ReservedLocalDeliveryFailure("local_integration_failed");
106967
107042
  restore2();
106968
107043
  await failRun(
106969
107044
  deps,
@@ -106986,6 +107061,10 @@ async function integrateBeforeReceipt(deps, ctx) {
106986
107061
  await recordIntegration(record2);
106987
107062
  return { proceed: true, integration: record2 };
106988
107063
  } catch (error51) {
107064
+ if (ctx.holdOnFailure) {
107065
+ if (error51 instanceof MixedCodeApprovalError || error51 instanceof WorkLeaseUnavailableError) throw error51;
107066
+ throw new ReservedLocalDeliveryFailure("local_integration_failed");
107067
+ }
106989
107068
  try {
106990
107069
  if (preMergeHead) restore2();
106991
107070
  else abortIntegration({ worktreePath });
@@ -107007,6 +107086,7 @@ async function integrateBeforeReceipt(deps, ctx) {
107007
107086
  async function deliverLocalRun(deps, input) {
107008
107087
  const { projectSlug, task, runId, leaseId } = input;
107009
107088
  const restoreForLostLease = async () => {
107089
+ if (input.holdOnFailure) throw new WorkLeaseUnavailableError();
107010
107090
  if (!input.integration?.mergeSha) return;
107011
107091
  const settledNow = await readSettlementState(deps, projectSlug, task.id, runId, 1);
107012
107092
  if (!settledNow || settledNow.runDone || settledNow.taskTerminal) {
@@ -107037,6 +107117,8 @@ async function deliverLocalRun(deps, input) {
107037
107117
  }
107038
107118
  };
107039
107119
  const handOff = async (reason) => {
107120
+ if (input.guard?.signal.reason instanceof MixedCodeApprovalError) throw input.guard.signal.reason;
107121
+ if (input.holdOnFailure) throw new ReservedLocalDeliveryFailure("local_delivery_failed");
107040
107122
  if (!await runHasLease(deps, projectSlug, runId, leaseId)) {
107041
107123
  await restoreForLostLease();
107042
107124
  return;
@@ -107074,6 +107156,7 @@ async function deliverLocalRun(deps, input) {
107074
107156
  }
107075
107157
  deps.activeLease?.watch.assertActive();
107076
107158
  if (!outcome.ok) {
107159
+ if (input.holdOnFailure) throw new ReservedLocalDeliveryFailure("local_delivery_failed");
107077
107160
  if (outcome.evidence) {
107078
107161
  await deps.client.updateExecutionRun(projectSlug, runId, { headSha: outcome.evidence.headSha }).catch(() => {
107079
107162
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.192",
3
+ "version": "0.4.198",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"
@@ -40,10 +40,10 @@
40
40
  "esbuild": "^0.24.2",
41
41
  "tsx": "^4.19.1",
42
42
  "typescript": "^5.5.4",
43
- "@mrrlin/agent-client": "0.0.0",
44
43
  "@mrrlin/client": "0.0.0",
45
44
  "@mrrlin/director-e2e": "0.0.0",
46
45
  "@mrrlin/schemas": "0.0.0",
46
+ "@mrrlin/agent-client": "0.0.0",
47
47
  "@mrrlin/tsconfig": "0.0.0",
48
48
  "@mrrlin/wiki": "0.0.0"
49
49
  },