@mrrlin-dev/mcp 0.4.207 → 0.4.209

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 +88 -48
  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
+ getDraftLinkV1: "getDraftLinkV1",
64316
64317
  getTaskBlockerStatusV1: "getTaskBlockerStatusV1",
64317
64318
  listTaskEvents: "listTaskEvents",
64318
64319
  listTaxonomy: "listTaxonomy",
@@ -66513,6 +66514,15 @@ var blockerStatusResponseSchema = external_exports.object({
66513
66514
  contract: external_exports.literal("task-blocker-status-v1"),
66514
66515
  active: external_exports.boolean()
66515
66516
  }).strict();
66517
+ var draftLinkPageIdSchema = external_exports.string().min(4).max(128).refine((id) => id.startsWith("WK-") && !/[^0-9]/u.test(id.slice(3)), "Invalid wiki page ID");
66518
+ var draftLinkResponseSchema = external_exports.discriminatedUnion("kind", [
66519
+ external_exports.object({
66520
+ contract: external_exports.literal("draft-link-v1"),
66521
+ kind: external_exports.literal("found"),
66522
+ specWikiPageId: draftLinkPageIdSchema.nullable()
66523
+ }).strict(),
66524
+ external_exports.object({ contract: external_exports.literal("draft-link-v1"), kind: external_exports.literal("missing") }).strict()
66525
+ ]);
66516
66526
  var linkedTaskPageIdSchema = mrrlinWikiPageIdSchema.max(128);
66517
66527
  var linkedTaskResponseSchema = external_exports.object({
66518
66528
  contract: external_exports.literal("spec-linked-task-v1"),
@@ -68912,7 +68922,7 @@ function buildTaskListPath(projectSlug, filters, view) {
68912
68922
  view: view ?? filters.view
68913
68923
  });
68914
68924
  }
68915
- function withinBlockerStatusDeadline(operation, signal) {
68925
+ function withinBoundedReadDeadline(operation, signal) {
68916
68926
  return new Promise((resolve3, reject) => {
68917
68927
  const aborted2 = () => reject(signal.reason);
68918
68928
  signal.addEventListener("abort", aborted2, { once: true });
@@ -68921,25 +68931,25 @@ function withinBlockerStatusDeadline(operation, signal) {
68921
68931
  void operation.then(resolve3, reject).finally(() => signal.removeEventListener("abort", aborted2));
68922
68932
  });
68923
68933
  }
68924
- async function readBlockerStatus(response, signal) {
68934
+ async function readBoundedJson(response, signal, maxBytes) {
68925
68935
  const reader = response.body?.getReader();
68926
68936
  if (!reader)
68927
- throw new TypeError("Missing blocker status response body");
68928
- const bytes3 = new Uint8Array(52);
68937
+ throw new TypeError("Missing bounded response body");
68938
+ const bytes3 = new Uint8Array(maxBytes);
68929
68939
  let length = 0;
68930
68940
  try {
68931
68941
  while (true) {
68932
- const { done, value } = await withinBlockerStatusDeadline(reader.read(), signal);
68942
+ const { done, value } = await withinBoundedReadDeadline(reader.read(), signal);
68933
68943
  if (done)
68934
68944
  break;
68935
68945
  if (value.byteLength > bytes3.length - length)
68936
- throw new RangeError("Blocker status response too large");
68946
+ throw new RangeError("Bounded response too large");
68937
68947
  bytes3.set(value, length);
68938
68948
  length += value.byteLength;
68939
68949
  }
68940
68950
  signal.throwIfAborted();
68941
68951
  const body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes3.subarray(0, length)));
68942
- return blockerStatusResponseSchema.parse(body).active;
68952
+ return body;
68943
68953
  } finally {
68944
68954
  void reader.cancel().catch(() => {
68945
68955
  });
@@ -69132,6 +69142,35 @@ function createMrrlinClient(config2) {
69132
69142
  message
69133
69143
  });
69134
69144
  }
69145
+ async function requestBoundedJson(path40, maxBytes, caller) {
69146
+ const deadline = AbortSignal.timeout(3e4);
69147
+ const callerSignal = caller ? AbortSignal.any([caller, deadline]) : deadline;
69148
+ const scope = createFetchScope(callerSignal);
69149
+ const signal = scope.signal ?? callerSignal;
69150
+ signal.throwIfAborted();
69151
+ const pending = executeFetch(path40, { cache: "no-store" }, scope);
69152
+ void pending.then((response2) => {
69153
+ if (signal.aborted)
69154
+ void response2.body?.cancel().catch(() => {
69155
+ });
69156
+ }, () => {
69157
+ });
69158
+ const response = await withinBoundedReadDeadline(pending, signal);
69159
+ if (response.status !== 200) {
69160
+ void response.body?.cancel().catch(() => {
69161
+ });
69162
+ throw new MrrlinApiError({
69163
+ code: `HTTP_${response.status}`,
69164
+ status: response.status,
69165
+ method: "GET",
69166
+ path: path40,
69167
+ message: `Bounded read request failed: ${response.status}`,
69168
+ responseBody: "",
69169
+ violations: null
69170
+ });
69171
+ }
69172
+ return readBoundedJson(response, signal, maxBytes);
69173
+ }
69135
69174
  async function request(path40, init) {
69136
69175
  const method = init?.method ?? "GET";
69137
69176
  const response = await executeFetch(path40, init);
@@ -69338,33 +69377,12 @@ function createMrrlinClient(config2) {
69338
69377
  const ids = blockerTaskIdsSchema.parse(taskIds);
69339
69378
  const query = new URLSearchParams(ids.map((id) => ["taskId", id]));
69340
69379
  const path40 = `${projectPath(projectSlug)}/task-blocker-status/v1?${query}`;
69341
- const deadline = AbortSignal.timeout(3e4);
69342
- const callerSignal = options?.signal ? AbortSignal.any([options.signal, deadline]) : deadline;
69343
- const scope = createFetchScope(callerSignal);
69344
- const signal = scope.signal ?? callerSignal;
69345
- signal.throwIfAborted();
69346
- const pending = executeFetch(path40, { cache: "no-store" }, scope);
69347
- void pending.then((response2) => {
69348
- if (signal.aborted)
69349
- void response2.body?.cancel().catch(() => {
69350
- });
69351
- }, () => {
69352
- });
69353
- const response = await withinBlockerStatusDeadline(pending, signal);
69354
- if (response.status !== 200) {
69355
- void response.body?.cancel().catch(() => {
69356
- });
69357
- throw new MrrlinApiError({
69358
- code: `HTTP_${response.status}`,
69359
- status: response.status,
69360
- method: "GET",
69361
- path: path40,
69362
- message: `Blocker status request failed: ${response.status}`,
69363
- responseBody: "",
69364
- violations: null
69365
- });
69366
- }
69367
- return readBlockerStatus(response, signal);
69380
+ const body = await requestBoundedJson(path40, 52, options?.signal);
69381
+ return blockerStatusResponseSchema.parse(body).active;
69382
+ },
69383
+ async getDraftLinkV1(projectSlug, taskId, options) {
69384
+ const path40 = `${projectPath(projectSlug)}/tasks/${encodeURIComponent(taskId)}/draft-link/v1`;
69385
+ return draftLinkResponseSchema.parse(await requestBoundedJson(path40, 256, options?.signal));
69368
69386
  },
69369
69387
  async getWikiPageLinkedTaskV1(projectSlug, pageId) {
69370
69388
  const path40 = `${projectPath(projectSlug)}/wiki/${encodeURIComponent(pageId)}/linked-task/v1`;
@@ -89713,6 +89731,11 @@ async function runDraftSpec(ctx, input, deps) {
89713
89731
  }
89714
89732
  if (hasActiveBlocker) return skipped("blocked_by_active");
89715
89733
  }
89734
+ const draftLinkFlag = ctx.boundDraftCommit ? void 0 : process.env.MRRLIN_MCP_DRAFT_LINK_V1?.trim().toLowerCase();
89735
+ if (draftLinkFlag && draftLinkFlag !== "1" && draftLinkFlag !== "0" && draftLinkFlag !== "false") {
89736
+ return { kind: "retry", failureReason: "provider_unavailable", error: "Invalid MRRLIN_MCP_DRAFT_LINK_V1" };
89737
+ }
89738
+ const useDraftLinkV1 = draftLinkFlag === "1";
89716
89739
  const autoDeploy = task.autoDeploy ?? "off";
89717
89740
  let topology = null;
89718
89741
  let deploySkippedReason = null;
@@ -89910,27 +89933,44 @@ async function runDraftSpec(ctx, input, deps) {
89910
89933
  })
89911
89934
  };
89912
89935
  }
89913
- let fresh;
89914
- try {
89915
- fresh = await client.getTask(projectSlug, taskId);
89916
- } catch (error51) {
89917
- if (error51 instanceof MrrlinApiError && error51.status === 404) {
89918
- return { kind: "failed", failureReason: "zero_output", error: `task ${taskId} disappeared before linking` };
89936
+ let linkedPageId;
89937
+ if (useDraftLinkV1) {
89938
+ try {
89939
+ const fresh = await client.getDraftLinkV1(projectSlug, taskId, { signal: ctx.signal });
89940
+ if (fresh.kind === "missing") {
89941
+ return { kind: "failed", failureReason: "zero_output", error: `task ${taskId} disappeared before linking` };
89942
+ }
89943
+ linkedPageId = fresh.specWikiPageId;
89944
+ } catch (error51) {
89945
+ return {
89946
+ kind: "retry",
89947
+ failureReason: "provider_unavailable",
89948
+ error: `pre-link draft lookup failed for ${taskId}: ${errMessage3(error51)}`
89949
+ };
89950
+ }
89951
+ } else {
89952
+ try {
89953
+ linkedPageId = (await client.getTask(projectSlug, taskId)).specWikiPageId;
89954
+ } catch (error51) {
89955
+ if (error51 instanceof MrrlinApiError && error51.status === 404) {
89956
+ return { kind: "failed", failureReason: "zero_output", error: `task ${taskId} disappeared before linking` };
89957
+ }
89958
+ return {
89959
+ kind: "retry",
89960
+ failureReason: "provider_unavailable",
89961
+ error: `pre-link task re-fetch failed for ${taskId}: ${errMessage3(error51)}`
89962
+ };
89919
89963
  }
89920
- return {
89921
- kind: "retry",
89922
- failureReason: "provider_unavailable",
89923
- error: `pre-link task re-fetch failed for ${taskId}: ${errMessage3(error51)}`
89924
- };
89925
89964
  }
89926
- if (fresh.specWikiPageId) {
89927
- return skipped("lost_link_race", { pageId, linkedPageId: fresh.specWikiPageId });
89965
+ if (linkedPageId) {
89966
+ return skipped("lost_link_race", { pageId, linkedPageId });
89928
89967
  }
89929
89968
  const linkPatch = { specWikiPageId: pageId };
89930
89969
  if (deployTargets !== void 0 && deployTargets.length > 0) {
89931
89970
  linkPatch.deployTargets = deployTargets;
89932
89971
  }
89933
89972
  try {
89973
+ if (useDraftLinkV1) ctx.signal?.throwIfAborted();
89934
89974
  await client.updateTask(projectSlug, taskId, linkPatch);
89935
89975
  } catch (error51) {
89936
89976
  return {
@@ -99414,7 +99454,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
99414
99454
  }
99415
99455
 
99416
99456
  // src/_generated/version.ts
99417
- var PKG_VERSION = "0.4.207";
99457
+ var PKG_VERSION = "0.4.209";
99418
99458
 
99419
99459
  // src/bridge-allowed-origins.ts
99420
99460
  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.207",
3
+ "version": "0.4.209",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"