@mrrlin-dev/mcp 0.4.212 → 0.4.214

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 +95 -21
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -64313,6 +64313,7 @@ var openApiOperationIds = {
64313
64313
  listProjects: "listProjects",
64314
64314
  listTaskDependencies: "listTaskDependencies",
64315
64315
  listTasks: "listTasks",
64316
+ getDraftConstitutionV1: "getDraftConstitutionV1",
64316
64317
  getDraftLinkV1: "getDraftLinkV1",
64317
64318
  getTaskBlockerStatusV1: "getTaskBlockerStatusV1",
64318
64319
  listTaskEvents: "listTaskEvents",
@@ -66523,6 +66524,10 @@ var draftLinkResponseSchema = external_exports.discriminatedUnion("kind", [
66523
66524
  }).strict(),
66524
66525
  external_exports.object({ contract: external_exports.literal("draft-link-v1"), kind: external_exports.literal("missing") }).strict()
66525
66526
  ]);
66527
+ var draftConstitutionResponseSchema = external_exports.discriminatedUnion("kind", [
66528
+ external_exports.object({ contract: external_exports.literal("draft-constitution-v1"), kind: external_exports.literal("missing") }).strict(),
66529
+ external_exports.object({ contract: external_exports.literal("draft-constitution-v1"), kind: external_exports.literal("found"), markdownBody: external_exports.string() }).strict()
66530
+ ]);
66526
66531
  var linkedTaskPageIdSchema = mrrlinWikiPageIdSchema.max(128);
66527
66532
  var linkedTaskResponseSchema = external_exports.object({
66528
66533
  contract: external_exports.literal("spec-linked-task-v1"),
@@ -68931,31 +68936,37 @@ function withinBoundedReadDeadline(operation, signal) {
68931
68936
  void operation.then(resolve3, reject).finally(() => signal.removeEventListener("abort", aborted2));
68932
68937
  });
68933
68938
  }
68934
- async function readBoundedJson(response, signal, maxBytes) {
68939
+ async function readBoundedBody(response, signal, maxBytes) {
68935
68940
  const reader = response.body?.getReader();
68936
68941
  if (!reader)
68937
68942
  throw new TypeError("Missing bounded response body");
68938
68943
  const bytes3 = new Uint8Array(maxBytes);
68939
68944
  let length = 0;
68940
68945
  try {
68946
+ signal.throwIfAborted();
68941
68947
  while (true) {
68942
68948
  const { done, value } = await withinBoundedReadDeadline(reader.read(), signal);
68943
68949
  if (done)
68944
68950
  break;
68945
68951
  if (value.byteLength > bytes3.length - length)
68946
- throw new RangeError("Bounded response too large");
68952
+ throw new MrrlinResponseTooLargeError(maxBytes);
68947
68953
  bytes3.set(value, length);
68948
68954
  length += value.byteLength;
68949
68955
  }
68950
68956
  signal.throwIfAborted();
68951
- const body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes3.subarray(0, length)));
68952
- return body;
68957
+ return bytes3.subarray(0, length);
68953
68958
  } finally {
68954
68959
  void reader.cancel().catch(() => {
68955
68960
  });
68956
68961
  reader.releaseLock();
68957
68962
  }
68958
68963
  }
68964
+ var MrrlinResponseTooLargeError = class extends RangeError {
68965
+ constructor(maxBytes) {
68966
+ super(`Bounded response too large (limit: ${maxBytes} decoded bytes)`);
68967
+ this.name = "MrrlinResponseTooLargeError";
68968
+ }
68969
+ };
68959
68970
  var MrrlinApiError = class extends Error {
68960
68971
  code;
68961
68972
  method;
@@ -69111,7 +69122,9 @@ function createMrrlinClient(config2) {
69111
69122
  throw new Error(`Failed to execute ${method} ${path40}`);
69112
69123
  }
69113
69124
  async function handleResponseError(response, method, path40) {
69114
- const body = await response.text();
69125
+ return throwResponseError(response, method, path40, await response.text());
69126
+ }
69127
+ function throwResponseError(response, method, path40, body) {
69115
69128
  let code = `HTTP_${response.status}`;
69116
69129
  let violations = null;
69117
69130
  let message = `Mrrlin API ${method} ${path40} failed: ${response.status}`;
@@ -69142,20 +69155,27 @@ function createMrrlinClient(config2) {
69142
69155
  message
69143
69156
  });
69144
69157
  }
69145
- async function requestBoundedJson(path40, maxBytes, caller) {
69158
+ function startBoundedGet(path40, caller, init) {
69159
+ const deadlineAt = performance.now() + 3e4;
69146
69160
  const deadline = AbortSignal.timeout(3e4);
69147
69161
  const callerSignal = caller ? AbortSignal.any([caller, deadline]) : deadline;
69148
69162
  const scope = createFetchScope(callerSignal);
69149
69163
  const signal = scope.signal ?? callerSignal;
69164
+ const operationDeadlineAt = scope.operation?.deadlineAt ?? Number.POSITIVE_INFINITY;
69165
+ const expired = () => performance.now() >= Math.min(deadlineAt, operationDeadlineAt) || deadline.aborted || signal.aborted && signal.reason instanceof DOMException && signal.reason.name === "TimeoutError";
69150
69166
  signal.throwIfAborted();
69151
- const pending = executeFetch(path40, { cache: "no-store" }, scope);
69152
- void pending.then((response2) => {
69167
+ const pending = executeFetch(path40, init, scope);
69168
+ void pending.then((response) => {
69153
69169
  if (signal.aborted)
69154
- void response2.body?.cancel().catch(() => {
69170
+ void response.body?.cancel().catch(() => {
69155
69171
  });
69156
69172
  }, () => {
69157
69173
  });
69158
- const response = await withinBoundedReadDeadline(pending, signal);
69174
+ return { pending: withinBoundedReadDeadline(pending, signal), signal, expired };
69175
+ }
69176
+ async function requestBoundedJson(path40, maxBytes, caller) {
69177
+ const { pending, signal } = startBoundedGet(path40, caller, { cache: "no-store" });
69178
+ const response = await pending;
69159
69179
  if (response.status !== 200) {
69160
69180
  void response.body?.cancel().catch(() => {
69161
69181
  });
@@ -69169,7 +69189,8 @@ function createMrrlinClient(config2) {
69169
69189
  violations: null
69170
69190
  });
69171
69191
  }
69172
- return readBoundedJson(response, signal, maxBytes);
69192
+ const bytes3 = await readBoundedBody(response, signal, maxBytes);
69193
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes3));
69173
69194
  }
69174
69195
  async function request(path40, init) {
69175
69196
  const method = init?.method ?? "GET";
@@ -69369,9 +69390,41 @@ function createMrrlinClient(config2) {
69369
69390
  const body = await request(`${projectPath(projectSlug)}/snapshot`);
69370
69391
  return projectSnapshotResponseSchema.parse(body).data;
69371
69392
  },
69372
- async getTask(projectSlug, taskId) {
69373
- const body = await request(`${projectPath(projectSlug)}/tasks/${encodeURIComponent(taskId)}`);
69374
- return taskResponseSchema.parse(body).data;
69393
+ async getTask(projectSlug, taskId, options) {
69394
+ const path40 = `${projectPath(projectSlug)}/tasks/${encodeURIComponent(taskId)}`;
69395
+ if (!options?.boundedResponse)
69396
+ return taskResponseSchema.parse(await request(path40)).data;
69397
+ const { pending, signal, expired } = startBoundedGet(path40, options.signal);
69398
+ let response;
69399
+ try {
69400
+ response = await pending;
69401
+ } catch (error51) {
69402
+ options.signal?.throwIfAborted();
69403
+ if (expired())
69404
+ throw new DOMException("Bounded read deadline expired", "TimeoutError");
69405
+ throw error51;
69406
+ }
69407
+ const maxBytes = response.ok ? 8 * 1024 * 1024 : 64 * 1024;
69408
+ let body = "";
69409
+ try {
69410
+ if (response.body)
69411
+ body = new TextDecoder().decode(await readBoundedBody(response, signal, maxBytes));
69412
+ signal.throwIfAborted();
69413
+ if (expired())
69414
+ throw new DOMException("Bounded read deadline expired", "TimeoutError");
69415
+ } catch (error51) {
69416
+ options.signal?.throwIfAborted();
69417
+ const timedOut = expired();
69418
+ if (!response.ok && (error51 instanceof MrrlinResponseTooLargeError || timedOut)) {
69419
+ throwResponseError(response, "GET", path40, "");
69420
+ }
69421
+ if (timedOut)
69422
+ throw new DOMException("Bounded read deadline expired", "TimeoutError");
69423
+ throw error51;
69424
+ }
69425
+ if (!response.ok)
69426
+ throwResponseError(response, "GET", path40, body);
69427
+ return taskResponseSchema.parse(JSON.parse(body)).data;
69375
69428
  },
69376
69429
  async getTaskBlockerStatusV1(projectSlug, taskIds, options) {
69377
69430
  const ids = blockerTaskIdsSchema.parse(taskIds);
@@ -69380,6 +69433,10 @@ function createMrrlinClient(config2) {
69380
69433
  const body = await requestBoundedJson(path40, 52, options?.signal);
69381
69434
  return blockerStatusResponseSchema.parse(body).active;
69382
69435
  },
69436
+ async getDraftConstitutionV1(projectSlug, options) {
69437
+ const path40 = `${projectPath(projectSlug)}/draft-constitution/v1`;
69438
+ return draftConstitutionResponseSchema.parse(await requestBoundedJson(path40, 256 * 1024, options?.signal));
69439
+ },
69383
69440
  async getDraftLinkV1(projectSlug, taskId, options) {
69384
69441
  const path40 = `${projectPath(projectSlug)}/tasks/${encodeURIComponent(taskId)}/draft-link/v1`;
69385
69442
  return draftLinkResponseSchema.parse(await requestBoundedJson(path40, 256, options?.signal));
@@ -89694,8 +89751,12 @@ async function runDraftSpec(ctx, input, deps) {
89694
89751
  const client = ctx.client;
89695
89752
  let task;
89696
89753
  try {
89697
- task = await client.getTask(projectSlug, taskId);
89754
+ const bounded = process.env.MRRLIN_MCP_DRAFT_INITIAL_TASK_BOUNDED?.trim() === "1";
89755
+ task = bounded ? await client.getTask(projectSlug, taskId, { boundedResponse: true, signal: ctx.signal }) : await client.getTask(projectSlug, taskId);
89698
89756
  } catch (error51) {
89757
+ if (error51 instanceof MrrlinResponseTooLargeError) {
89758
+ return { kind: "failed", failureReason: "zero_output", error: `initial task fetch for ${projectSlug}/${taskId}: ${error51.message}` };
89759
+ }
89699
89760
  if (error51 instanceof MrrlinApiError && error51.status === 404) {
89700
89761
  return { kind: "failed", failureReason: "zero_output", error: `task ${projectSlug}/${taskId} not found` };
89701
89762
  }
@@ -89780,11 +89841,23 @@ async function runDraftSpec(ctx, input, deps) {
89780
89841
  };
89781
89842
  }
89782
89843
  let constitution = null;
89783
- try {
89784
- const memoryPages = await client.listWikiPages(projectSlug, { folder: PROJECT_CONSTITUTION_PAGE.folder });
89785
- constitution = memoryPages.find((page) => page.path === PROJECT_CONSTITUTION_PAGE.path)?.markdownBody ?? null;
89786
- } catch {
89787
- constitution = null;
89844
+ const boundedConstitution = process.env.MRRLIN_MCP_DRAFT_CONSTITUTION_BOUNDED?.trim() === "1";
89845
+ if (boundedConstitution) {
89846
+ try {
89847
+ const result = await client.getDraftConstitutionV1(projectSlug, { signal: ctx.signal });
89848
+ ctx.signal?.throwIfAborted();
89849
+ if (result.kind === "found") constitution = result.markdownBody;
89850
+ } catch (error51) {
89851
+ ctx.signal?.throwIfAborted();
89852
+ return { kind: "retry", failureReason: "provider_unavailable", error: `constitution lookup failed for ${projectSlug}: ${errMessage3(error51)}` };
89853
+ }
89854
+ } else {
89855
+ try {
89856
+ const memoryPages = await client.listWikiPages(projectSlug, { folder: PROJECT_CONSTITUTION_PAGE.folder });
89857
+ constitution = memoryPages.find((page) => page.path === PROJECT_CONSTITUTION_PAGE.path)?.markdownBody ?? null;
89858
+ } catch {
89859
+ constitution = null;
89860
+ }
89788
89861
  }
89789
89862
  const deployPromptContext = autoDeploy !== "off" && topology ? topology.entries.length > 0 ? { kind: "closed_menu", entries: topology.entries } : { kind: "derive", snapshot: topology.snapshot ?? [] } : null;
89790
89863
  const prompt = buildDraftSpecPrompt(task, constitution, deployPromptContext);
@@ -98296,6 +98369,7 @@ function createOwnedSdkOperation(options) {
98296
98369
  const deadlineSignal = AbortSignal.timeout(Math.max(0, Math.ceil(deadlineAt - performance.now())));
98297
98370
  return {
98298
98371
  signal: deadlineSignal,
98372
+ deadlineAt,
98299
98373
  headers: async (authSignal) => ({
98300
98374
  authorization: "Bearer " + (session?.token ?? await authenticate(authSignal, deadlineAt))
98301
98375
  }),
@@ -99512,7 +99586,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
99512
99586
  }
99513
99587
 
99514
99588
  // src/_generated/version.ts
99515
- var PKG_VERSION = "0.4.212";
99589
+ var PKG_VERSION = "0.4.214";
99516
99590
 
99517
99591
  // src/bridge-allowed-origins.ts
99518
99592
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.212",
3
+ "version": "0.4.214",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"