@mrrlin-dev/mcp 0.4.133 → 0.4.135
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/dist/bin.cjs +48 -4
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -63643,7 +63643,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
63643
63643
|
}
|
|
63644
63644
|
|
|
63645
63645
|
// src/_generated/version.ts
|
|
63646
|
-
var PKG_VERSION = "0.4.
|
|
63646
|
+
var PKG_VERSION = "0.4.135";
|
|
63647
63647
|
|
|
63648
63648
|
// src/bridge-allowed-origins.ts
|
|
63649
63649
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -69619,12 +69619,17 @@ async function deliverLocalRun(deps, input) {
|
|
|
69619
69619
|
await restoreForLostLease();
|
|
69620
69620
|
return;
|
|
69621
69621
|
}
|
|
69622
|
+
const finalizeUnanswered = { seen: false };
|
|
69622
69623
|
try {
|
|
69623
69624
|
await orchestrateSettlementClosure(
|
|
69624
69625
|
{
|
|
69625
69626
|
prepareSettlementCandidate: (slug, params) => deps.client.prepareSettlementCandidate(slug, params),
|
|
69626
69627
|
signingProvider: deps.signingProvider,
|
|
69627
|
-
finalizeSettlementReceipt: (slug, params) =>
|
|
69628
|
+
finalizeSettlementReceipt: (slug, params) => finalizeWithReplay(
|
|
69629
|
+
deps,
|
|
69630
|
+
{ projectSlug, runId, taskId: task.id, unanswered: finalizeUnanswered },
|
|
69631
|
+
() => deps.client.finalizeSettlementReceipt(slug, params)
|
|
69632
|
+
)
|
|
69628
69633
|
},
|
|
69629
69634
|
{
|
|
69630
69635
|
projectSlug,
|
|
@@ -69637,8 +69642,20 @@ async function deliverLocalRun(deps, input) {
|
|
|
69637
69642
|
);
|
|
69638
69643
|
} catch (error51) {
|
|
69639
69644
|
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
69640
|
-
const
|
|
69641
|
-
if (!
|
|
69645
|
+
const settlement = await readSettlementState(deps, projectSlug, task.id, runId, SETTLEMENT_READBACK_ATTEMPTS);
|
|
69646
|
+
if (!settlement || settlement.taskStatus !== "closed_done" || !settlement.runDone) {
|
|
69647
|
+
if (!settlement && finalizeUnanswered.seen) {
|
|
69648
|
+
console.warn(JSON.stringify({
|
|
69649
|
+
event: "settlement_outcome_unknown",
|
|
69650
|
+
projectSlug,
|
|
69651
|
+
runId,
|
|
69652
|
+
taskId: task.id,
|
|
69653
|
+
headSha: outcome.evidence.headSha,
|
|
69654
|
+
deliveryRef: outcome.deliveryRef,
|
|
69655
|
+
error: message,
|
|
69656
|
+
next: `Once the API answers: if ${task.id} is closed_done, ask the Director to apply run ${runId} (apply_local_run); otherwise the run is handed off or requeued as usual.`
|
|
69657
|
+
}));
|
|
69658
|
+
}
|
|
69642
69659
|
await handOff(`local_delivery_settlement_failed: ${message}`);
|
|
69643
69660
|
return;
|
|
69644
69661
|
}
|
|
@@ -69724,6 +69741,33 @@ async function deliverLocalRun(deps, input) {
|
|
|
69724
69741
|
});
|
|
69725
69742
|
}
|
|
69726
69743
|
var SETTLEMENT_READBACK_ATTEMPTS = 3;
|
|
69744
|
+
var SETTLEMENT_FINALIZE_RETRY_DELAYS_MS = [1e3, 2e3, 4e3, 8e3, 15e3, 15e3];
|
|
69745
|
+
function isUnansweredFinalizeError(error51) {
|
|
69746
|
+
return !(error51 instanceof MrrlinApiError && error51.status >= 400 && error51.status < 500);
|
|
69747
|
+
}
|
|
69748
|
+
async function finalizeWithReplay(deps, ctx, finalize2) {
|
|
69749
|
+
const sleep = deps.settlementRetrySleep ?? delayMs;
|
|
69750
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
69751
|
+
try {
|
|
69752
|
+
return await finalize2();
|
|
69753
|
+
} catch (error51) {
|
|
69754
|
+
if (!isUnansweredFinalizeError(error51)) throw error51;
|
|
69755
|
+
ctx.unanswered.seen = true;
|
|
69756
|
+
const waitMs = SETTLEMENT_FINALIZE_RETRY_DELAYS_MS[attempt - 1];
|
|
69757
|
+
if (waitMs === void 0) throw error51;
|
|
69758
|
+
console.warn(JSON.stringify({
|
|
69759
|
+
event: "settlement_finalize_retry",
|
|
69760
|
+
projectSlug: ctx.projectSlug,
|
|
69761
|
+
runId: ctx.runId,
|
|
69762
|
+
taskId: ctx.taskId,
|
|
69763
|
+
attempt,
|
|
69764
|
+
waitMs,
|
|
69765
|
+
error: error51 instanceof Error ? error51.message : String(error51)
|
|
69766
|
+
}));
|
|
69767
|
+
await sleep(waitMs);
|
|
69768
|
+
}
|
|
69769
|
+
}
|
|
69770
|
+
}
|
|
69727
69771
|
async function readSettlementState(deps, projectSlug, taskId, runId, attempts) {
|
|
69728
69772
|
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
69729
69773
|
try {
|