@mrrlin-dev/mcp 0.4.212 → 0.4.213
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 +69 -16
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -68931,31 +68931,37 @@ function withinBoundedReadDeadline(operation, signal) {
|
|
|
68931
68931
|
void operation.then(resolve3, reject).finally(() => signal.removeEventListener("abort", aborted2));
|
|
68932
68932
|
});
|
|
68933
68933
|
}
|
|
68934
|
-
async function
|
|
68934
|
+
async function readBoundedBody(response, signal, maxBytes) {
|
|
68935
68935
|
const reader = response.body?.getReader();
|
|
68936
68936
|
if (!reader)
|
|
68937
68937
|
throw new TypeError("Missing bounded response body");
|
|
68938
68938
|
const bytes3 = new Uint8Array(maxBytes);
|
|
68939
68939
|
let length = 0;
|
|
68940
68940
|
try {
|
|
68941
|
+
signal.throwIfAborted();
|
|
68941
68942
|
while (true) {
|
|
68942
68943
|
const { done, value } = await withinBoundedReadDeadline(reader.read(), signal);
|
|
68943
68944
|
if (done)
|
|
68944
68945
|
break;
|
|
68945
68946
|
if (value.byteLength > bytes3.length - length)
|
|
68946
|
-
throw new
|
|
68947
|
+
throw new MrrlinResponseTooLargeError(maxBytes);
|
|
68947
68948
|
bytes3.set(value, length);
|
|
68948
68949
|
length += value.byteLength;
|
|
68949
68950
|
}
|
|
68950
68951
|
signal.throwIfAborted();
|
|
68951
|
-
|
|
68952
|
-
return body;
|
|
68952
|
+
return bytes3.subarray(0, length);
|
|
68953
68953
|
} finally {
|
|
68954
68954
|
void reader.cancel().catch(() => {
|
|
68955
68955
|
});
|
|
68956
68956
|
reader.releaseLock();
|
|
68957
68957
|
}
|
|
68958
68958
|
}
|
|
68959
|
+
var MrrlinResponseTooLargeError = class extends RangeError {
|
|
68960
|
+
constructor(maxBytes) {
|
|
68961
|
+
super(`Bounded response too large (limit: ${maxBytes} decoded bytes)`);
|
|
68962
|
+
this.name = "MrrlinResponseTooLargeError";
|
|
68963
|
+
}
|
|
68964
|
+
};
|
|
68959
68965
|
var MrrlinApiError = class extends Error {
|
|
68960
68966
|
code;
|
|
68961
68967
|
method;
|
|
@@ -69111,7 +69117,9 @@ function createMrrlinClient(config2) {
|
|
|
69111
69117
|
throw new Error(`Failed to execute ${method} ${path40}`);
|
|
69112
69118
|
}
|
|
69113
69119
|
async function handleResponseError(response, method, path40) {
|
|
69114
|
-
|
|
69120
|
+
return throwResponseError(response, method, path40, await response.text());
|
|
69121
|
+
}
|
|
69122
|
+
function throwResponseError(response, method, path40, body) {
|
|
69115
69123
|
let code = `HTTP_${response.status}`;
|
|
69116
69124
|
let violations = null;
|
|
69117
69125
|
let message = `Mrrlin API ${method} ${path40} failed: ${response.status}`;
|
|
@@ -69142,20 +69150,27 @@ function createMrrlinClient(config2) {
|
|
|
69142
69150
|
message
|
|
69143
69151
|
});
|
|
69144
69152
|
}
|
|
69145
|
-
|
|
69153
|
+
function startBoundedGet(path40, caller, init) {
|
|
69154
|
+
const deadlineAt = performance.now() + 3e4;
|
|
69146
69155
|
const deadline = AbortSignal.timeout(3e4);
|
|
69147
69156
|
const callerSignal = caller ? AbortSignal.any([caller, deadline]) : deadline;
|
|
69148
69157
|
const scope = createFetchScope(callerSignal);
|
|
69149
69158
|
const signal = scope.signal ?? callerSignal;
|
|
69159
|
+
const operationDeadlineAt = scope.operation?.deadlineAt ?? Number.POSITIVE_INFINITY;
|
|
69160
|
+
const expired = () => performance.now() >= Math.min(deadlineAt, operationDeadlineAt) || deadline.aborted || signal.aborted && signal.reason instanceof DOMException && signal.reason.name === "TimeoutError";
|
|
69150
69161
|
signal.throwIfAborted();
|
|
69151
|
-
const pending = executeFetch(path40,
|
|
69152
|
-
void pending.then((
|
|
69162
|
+
const pending = executeFetch(path40, init, scope);
|
|
69163
|
+
void pending.then((response) => {
|
|
69153
69164
|
if (signal.aborted)
|
|
69154
|
-
void
|
|
69165
|
+
void response.body?.cancel().catch(() => {
|
|
69155
69166
|
});
|
|
69156
69167
|
}, () => {
|
|
69157
69168
|
});
|
|
69158
|
-
|
|
69169
|
+
return { pending: withinBoundedReadDeadline(pending, signal), signal, expired };
|
|
69170
|
+
}
|
|
69171
|
+
async function requestBoundedJson(path40, maxBytes, caller) {
|
|
69172
|
+
const { pending, signal } = startBoundedGet(path40, caller, { cache: "no-store" });
|
|
69173
|
+
const response = await pending;
|
|
69159
69174
|
if (response.status !== 200) {
|
|
69160
69175
|
void response.body?.cancel().catch(() => {
|
|
69161
69176
|
});
|
|
@@ -69169,7 +69184,8 @@ function createMrrlinClient(config2) {
|
|
|
69169
69184
|
violations: null
|
|
69170
69185
|
});
|
|
69171
69186
|
}
|
|
69172
|
-
|
|
69187
|
+
const bytes3 = await readBoundedBody(response, signal, maxBytes);
|
|
69188
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes3));
|
|
69173
69189
|
}
|
|
69174
69190
|
async function request(path40, init) {
|
|
69175
69191
|
const method = init?.method ?? "GET";
|
|
@@ -69369,9 +69385,41 @@ function createMrrlinClient(config2) {
|
|
|
69369
69385
|
const body = await request(`${projectPath(projectSlug)}/snapshot`);
|
|
69370
69386
|
return projectSnapshotResponseSchema.parse(body).data;
|
|
69371
69387
|
},
|
|
69372
|
-
async getTask(projectSlug, taskId) {
|
|
69373
|
-
const
|
|
69374
|
-
|
|
69388
|
+
async getTask(projectSlug, taskId, options) {
|
|
69389
|
+
const path40 = `${projectPath(projectSlug)}/tasks/${encodeURIComponent(taskId)}`;
|
|
69390
|
+
if (!options?.boundedResponse)
|
|
69391
|
+
return taskResponseSchema.parse(await request(path40)).data;
|
|
69392
|
+
const { pending, signal, expired } = startBoundedGet(path40, options.signal);
|
|
69393
|
+
let response;
|
|
69394
|
+
try {
|
|
69395
|
+
response = await pending;
|
|
69396
|
+
} catch (error51) {
|
|
69397
|
+
options.signal?.throwIfAborted();
|
|
69398
|
+
if (expired())
|
|
69399
|
+
throw new DOMException("Bounded read deadline expired", "TimeoutError");
|
|
69400
|
+
throw error51;
|
|
69401
|
+
}
|
|
69402
|
+
const maxBytes = response.ok ? 8 * 1024 * 1024 : 64 * 1024;
|
|
69403
|
+
let body = "";
|
|
69404
|
+
try {
|
|
69405
|
+
if (response.body)
|
|
69406
|
+
body = new TextDecoder().decode(await readBoundedBody(response, signal, maxBytes));
|
|
69407
|
+
signal.throwIfAborted();
|
|
69408
|
+
if (expired())
|
|
69409
|
+
throw new DOMException("Bounded read deadline expired", "TimeoutError");
|
|
69410
|
+
} catch (error51) {
|
|
69411
|
+
options.signal?.throwIfAborted();
|
|
69412
|
+
const timedOut = expired();
|
|
69413
|
+
if (!response.ok && (error51 instanceof MrrlinResponseTooLargeError || timedOut)) {
|
|
69414
|
+
throwResponseError(response, "GET", path40, "");
|
|
69415
|
+
}
|
|
69416
|
+
if (timedOut)
|
|
69417
|
+
throw new DOMException("Bounded read deadline expired", "TimeoutError");
|
|
69418
|
+
throw error51;
|
|
69419
|
+
}
|
|
69420
|
+
if (!response.ok)
|
|
69421
|
+
throwResponseError(response, "GET", path40, body);
|
|
69422
|
+
return taskResponseSchema.parse(JSON.parse(body)).data;
|
|
69375
69423
|
},
|
|
69376
69424
|
async getTaskBlockerStatusV1(projectSlug, taskIds, options) {
|
|
69377
69425
|
const ids = blockerTaskIdsSchema.parse(taskIds);
|
|
@@ -89694,8 +89742,12 @@ async function runDraftSpec(ctx, input, deps) {
|
|
|
89694
89742
|
const client = ctx.client;
|
|
89695
89743
|
let task;
|
|
89696
89744
|
try {
|
|
89697
|
-
|
|
89745
|
+
const bounded = process.env.MRRLIN_MCP_DRAFT_INITIAL_TASK_BOUNDED?.trim() === "1";
|
|
89746
|
+
task = bounded ? await client.getTask(projectSlug, taskId, { boundedResponse: true, signal: ctx.signal }) : await client.getTask(projectSlug, taskId);
|
|
89698
89747
|
} catch (error51) {
|
|
89748
|
+
if (error51 instanceof MrrlinResponseTooLargeError) {
|
|
89749
|
+
return { kind: "failed", failureReason: "zero_output", error: `initial task fetch for ${projectSlug}/${taskId}: ${error51.message}` };
|
|
89750
|
+
}
|
|
89699
89751
|
if (error51 instanceof MrrlinApiError && error51.status === 404) {
|
|
89700
89752
|
return { kind: "failed", failureReason: "zero_output", error: `task ${projectSlug}/${taskId} not found` };
|
|
89701
89753
|
}
|
|
@@ -98296,6 +98348,7 @@ function createOwnedSdkOperation(options) {
|
|
|
98296
98348
|
const deadlineSignal = AbortSignal.timeout(Math.max(0, Math.ceil(deadlineAt - performance.now())));
|
|
98297
98349
|
return {
|
|
98298
98350
|
signal: deadlineSignal,
|
|
98351
|
+
deadlineAt,
|
|
98299
98352
|
headers: async (authSignal) => ({
|
|
98300
98353
|
authorization: "Bearer " + (session?.token ?? await authenticate(authSignal, deadlineAt))
|
|
98301
98354
|
}),
|
|
@@ -99512,7 +99565,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
99512
99565
|
}
|
|
99513
99566
|
|
|
99514
99567
|
// src/_generated/version.ts
|
|
99515
|
-
var PKG_VERSION = "0.4.
|
|
99568
|
+
var PKG_VERSION = "0.4.213";
|
|
99516
99569
|
|
|
99517
99570
|
// src/bridge-allowed-origins.ts
|
|
99518
99571
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|