@bendyline/gezel-mcp 1.3.1 → 1.3.3

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/harness.js CHANGED
@@ -90,7 +90,7 @@ import { z as z3 } from "zod";
90
90
 
91
91
  // src/harness/docblocks-tools.json
92
92
  var docblocks_tools_default = {
93
- docblocksVersion: "2.7.13",
93
+ docblocksVersion: "2.7.16",
94
94
  tools: [
95
95
  {
96
96
  name: "convert_document",
package/dist/server.js CHANGED
@@ -128,6 +128,7 @@ import {
128
128
  stepOwnerGezelId as stepOwnerGezelId2,
129
129
  taskOwnedPrefixes,
130
130
  taskPersonNoun,
131
+ taskReadsArtifactAt,
131
132
  taskScopedWriteDeniedMessage,
132
133
  uniqueStepId,
133
134
  unknownTaskStepText,
@@ -1687,10 +1688,10 @@ function binaryMediaReadResult(requestedTool, path, ext) {
1687
1688
  structuredContent: { requestedTool, requestedPath: path, binary: true, extension: ext }
1688
1689
  };
1689
1690
  }
1690
- async function rerouteBinaryDocumentRead(dependencies, path, surface) {
1691
+ async function rerouteBinaryDocumentRead(dependencies, path, surface, batch = false) {
1691
1692
  const { api: api2, projectId: projectId2, toolIsAuthorized, unwrapApiError: unwrapApiError2 } = dependencies;
1692
1693
  const artifact = surface === "artifact";
1693
- const requestedTool = artifact ? "read_artifact" : "read_file";
1694
+ const requestedTool = artifact ? batch ? "read_artifacts" : "read_artifact" : batch ? "read_files" : "read_file";
1694
1695
  const media = binaryMediaExtension(path);
1695
1696
  if (media) return binaryMediaReadResult(requestedTool, path, media);
1696
1697
  if (!isBinaryDocumentPath2(path)) return null;
@@ -1916,13 +1917,19 @@ ${body}` }],
1916
1917
  const rangeError = workspaceReadRangeError(request);
1917
1918
  if (rangeError) throw new Error(`${request.path}: ${rangeError}`);
1918
1919
  }
1919
- const response = await readWorkspaceFiles2(requests);
1920
- const results = await Promise.all(
1920
+ const binaryReads = await Promise.all(
1921
+ requests.map(
1922
+ (request) => rerouteBinaryDocumentRead(dependencies, request.path, "workspace", true)
1923
+ )
1924
+ );
1925
+ const textRequests = requests.filter((_, index2) => !binaryReads[index2]);
1926
+ const response = textRequests.length > 0 ? await readWorkspaceFiles2(textRequests) : { results: [] };
1927
+ const textResults = await Promise.all(
1921
1928
  response.results.map(async (result, index2) => {
1922
1929
  if (result.status !== "error" || result.code !== "path-not-found") {
1923
1930
  return { ...result, resolvedSurface: "workspace", rerouted: false };
1924
1931
  }
1925
- const request = requests[index2];
1932
+ const request = textRequests[index2];
1926
1933
  const collision = await artifactCollisionForWorkspacePath(dependencies, request.path);
1927
1934
  if (!collision) {
1928
1935
  return { ...result, resolvedSurface: "workspace", rerouted: false };
@@ -1990,65 +1997,26 @@ ${body}` }],
1990
1997
  }
1991
1998
  })
1992
1999
  );
1993
- const index = results.map((result, index2) => {
1994
- if (result.status === "error") {
1995
- return `${index2 + 1} ERROR ${result.path} [${result.code}] ${result.error}`;
1996
- }
1997
- const next = result.nextStartLine ? ` nextStartLine=${result.nextStartLine}` : "";
1998
- const route = result.rerouted ? ` rerouted=artifact:${result.resolvedPath}` : "";
1999
- return `${index2 + 1} OK ${result.path} ${workspaceReadRangeLabel(result)}${result.completeFile ? " complete" : ""}${next}${route}`;
2000
+ let nextText = 0;
2001
+ const entries = requests.map((request, position) => {
2002
+ const binary = binaryReads[position];
2003
+ if (binary) return binaryBatchEntry("workspace", request.path, binary);
2004
+ return textBatchEntry(textResults[nextText++]);
2000
2005
  });
2001
- const sections = results.map((result) => {
2002
- if (result.status === "error") {
2003
- return `--- ${result.path} [ERROR: ${result.code}] ---
2004
- ${result.error}`;
2005
- }
2006
- const range = workspaceReadRangeLabel(result);
2007
- const body = withLineNumbers(result.content, result.startLine) || "(no lines returned)";
2008
- const hint = workspaceReadHint(result);
2009
- const notice = result.rerouted ? `${reroutedReadNotice("read_files", "read_artifact", "artifact", result.resolvedPath)}
2010
- ` : "";
2011
- return `--- ${result.path} (${range}) ---
2012
- ${notice}${body}${hint}`;
2013
- });
2014
- const allFailed = results.length > 0 && results.every((result) => result.status === "error");
2006
+ const index = entries.map((entry, position) => `${position + 1} ${entry.line}`);
2007
+ const okCount = entries.filter((entry) => entry.structured.status === "ok").length;
2008
+ const allFailed = entries.length > 0 && okCount === 0;
2015
2009
  return {
2016
2010
  content: [
2017
2011
  {
2018
2012
  type: "text",
2019
- text: `[read_files requested=${results.length} ok=${results.filter((result) => result.status === "ok").length} errors=${results.filter((result) => result.status === "error").length}]
2013
+ text: `[read_files requested=${entries.length} ok=${okCount} errors=${entries.length - okCount}]
2020
2014
  ${index.join("\n")}
2021
2015
 
2022
- ${sections.join("\n\n")}`
2016
+ ${entries.map((entry) => entry.section).join("\n\n")}`
2023
2017
  }
2024
2018
  ],
2025
- structuredContent: {
2026
- results: results.map(
2027
- (result) => result.status === "ok" ? {
2028
- path: result.path,
2029
- status: result.status,
2030
- content: result.content,
2031
- startLine: result.startLine,
2032
- endLine: result.endLine,
2033
- completeFile: result.completeFile,
2034
- totalLines: result.totalLines,
2035
- hasMore: result.hasMore,
2036
- nextStartLine: result.nextStartLine,
2037
- resolvedSurface: result.resolvedSurface,
2038
- rerouted: result.rerouted,
2039
- ..."resolvedPath" in result ? { resolvedPath: result.resolvedPath } : {}
2040
- } : {
2041
- path: result.path,
2042
- status: result.status,
2043
- code: result.code,
2044
- error: result.error,
2045
- ..."requestedPath" in result ? { requestedPath: result.requestedPath } : {},
2046
- ..."resolvedPath" in result ? { resolvedPath: result.resolvedPath } : {},
2047
- resolvedSurface: result.resolvedSurface,
2048
- rerouted: result.rerouted
2049
- }
2050
- )
2051
- },
2019
+ structuredContent: { results: entries.map((entry) => entry.structured) },
2052
2020
  ...allFailed ? { isError: true } : {}
2053
2021
  };
2054
2022
  } catch (error) {
@@ -2060,6 +2028,88 @@ ${sections.join("\n\n")}`
2060
2028
  }
2061
2029
  );
2062
2030
  }
2031
+ function binaryBatchEntry(surface, path, read) {
2032
+ const text = read.content.map((item) => item.text).join("\n");
2033
+ const converted = read.structuredContent?.rerouted === true;
2034
+ if (!converted) {
2035
+ return {
2036
+ line: `ERROR ${path} [binary-file] not text; not read`,
2037
+ section: `--- ${path} [ERROR: binary-file] ---
2038
+ ${text}`,
2039
+ structured: {
2040
+ path,
2041
+ status: "error",
2042
+ code: "binary-file",
2043
+ error: text,
2044
+ resolvedSurface: surface,
2045
+ rerouted: false
2046
+ }
2047
+ };
2048
+ }
2049
+ const markdown = String(read.structuredContent?.content ?? "");
2050
+ const lines = markdown.split("\n").length;
2051
+ const truncated = read.structuredContent?.truncated === true;
2052
+ const ext = binaryDocumentExtension2(path)?.toUpperCase() ?? "document";
2053
+ return {
2054
+ line: `OK ${path} lines=1-${lines} converted=read_doc_as_markdown${truncated ? " truncated" : " complete"}`,
2055
+ section: `--- ${path} (lines=1-${lines} converted from ${ext}) ---
2056
+ ${text}`,
2057
+ structured: {
2058
+ path,
2059
+ status: "ok",
2060
+ content: markdown,
2061
+ startLine: 1,
2062
+ endLine: lines,
2063
+ completeFile: !truncated,
2064
+ resolvedSurface: surface,
2065
+ rerouted: true
2066
+ }
2067
+ };
2068
+ }
2069
+ function textBatchEntry(result) {
2070
+ if (result.status === "error") {
2071
+ return {
2072
+ line: `ERROR ${result.path} [${result.code}] ${result.error}`,
2073
+ section: `--- ${result.path} [ERROR: ${result.code}] ---
2074
+ ${result.error}`,
2075
+ structured: {
2076
+ path: result.path,
2077
+ status: result.status,
2078
+ code: result.code,
2079
+ error: result.error,
2080
+ ...result.requestedPath !== void 0 ? { requestedPath: result.requestedPath } : {},
2081
+ ...result.resolvedPath !== void 0 ? { resolvedPath: result.resolvedPath } : {},
2082
+ resolvedSurface: result.resolvedSurface,
2083
+ rerouted: result.rerouted
2084
+ }
2085
+ };
2086
+ }
2087
+ const range = workspaceReadRangeLabel(result);
2088
+ const next = result.nextStartLine ? ` nextStartLine=${result.nextStartLine}` : "";
2089
+ const route = result.rerouted ? ` rerouted=artifact:${result.resolvedPath}` : "";
2090
+ const body = withLineNumbers(result.content, result.startLine) || "(no lines returned)";
2091
+ const notice = result.rerouted ? `${reroutedReadNotice("read_files", "read_artifact", "artifact", result.resolvedPath ?? result.path)}
2092
+ ` : "";
2093
+ return {
2094
+ line: `OK ${result.path} ${range}${result.completeFile ? " complete" : ""}${next}${route}`,
2095
+ section: `--- ${result.path} (${range}) ---
2096
+ ${notice}${body}${workspaceReadHint(result)}`,
2097
+ structured: {
2098
+ path: result.path,
2099
+ status: result.status,
2100
+ content: result.content,
2101
+ startLine: result.startLine,
2102
+ endLine: result.endLine,
2103
+ completeFile: result.completeFile,
2104
+ totalLines: result.totalLines,
2105
+ hasMore: result.hasMore,
2106
+ nextStartLine: result.nextStartLine,
2107
+ resolvedSurface: result.resolvedSurface,
2108
+ rerouted: result.rerouted,
2109
+ ...result.resolvedPath !== void 0 ? { resolvedPath: result.resolvedPath } : {}
2110
+ }
2111
+ };
2112
+ }
2063
2113
  function registerArtifactReadTools(dependencies) {
2064
2114
  const {
2065
2115
  server: server2,
@@ -2278,8 +2328,19 @@ ${result.candidates.map((candidate) => ` \u2022 ${candidate}`).join("\n")}`
2278
2328
  const rangeError = workspaceReadRangeError(request);
2279
2329
  if (rangeError) return errorResult(`read_artifacts failed: ${request.path}: ${rangeError}`);
2280
2330
  }
2331
+ const binaryReads = await Promise.all(
2332
+ requests.map(
2333
+ (request) => rerouteBinaryDocumentRead(
2334
+ dependencies,
2335
+ normalizeArtifactPath2(request.path),
2336
+ "artifact",
2337
+ true
2338
+ )
2339
+ )
2340
+ );
2341
+ const textRequests = requests.filter((_, index) => !binaryReads[index]);
2281
2342
  const results = await Promise.all(
2282
- requests.map(async (request) => {
2343
+ textRequests.map(async (request) => {
2283
2344
  const clean = normalizeArtifactPath2(request.path);
2284
2345
  try {
2285
2346
  const artifact = await api2.readProjectArtifactSlice(
@@ -2387,38 +2448,47 @@ ${result.candidates.map((candidate) => ` \u2022 ${candidate}`).join("\n")}`
2387
2448
  }
2388
2449
  })
2389
2450
  );
2390
- const index = results.map((result, index2) => {
2451
+ const textEntry = (result) => {
2391
2452
  if (result.status === "error") {
2392
- return `${index2 + 1} ERROR ${result.path} [${result.code}] ${result.error}`;
2453
+ return {
2454
+ line: `ERROR ${result.path} [${result.code}] ${result.error}`,
2455
+ section: `--- ${result.path} [ERROR: ${result.code}] ---
2456
+ ${result.error}`,
2457
+ structured: result
2458
+ };
2393
2459
  }
2394
2460
  const route = result.rerouted ? ` rerouted=workspace:${result.resolvedPath}` : "";
2395
2461
  const next = result.nextStartLine ? ` nextStartLine=${result.nextStartLine}` : "";
2396
- return `${index2 + 1} OK ${result.path} lines=${result.startLine}-${result.endLine}${result.totalLines !== void 0 ? ` totalLines=${result.totalLines}` : ""}${result.completeFile ? " complete" : ""}${next}${route}`;
2397
- });
2398
- const sections = results.map((result) => {
2399
- if (result.status === "error") {
2400
- return `--- ${result.path} [ERROR: ${result.code}] ---
2401
- ${result.error}`;
2402
- }
2403
2462
  const notice = result.rerouted ? `${reroutedReadNotice("read_artifacts", "read_file", "workspace", result.resolvedPath)}
2404
2463
  ` : "";
2405
2464
  const fuzzy = result.fuzzy ? `(matched ${result.resolvedPath} by basename)
2406
2465
  ` : "";
2407
- return `--- ${result.path} (lines=${result.startLine}-${result.endLine}) ---
2408
- ${notice}${fuzzy}${result.content}`;
2466
+ return {
2467
+ line: `OK ${result.path} lines=${result.startLine}-${result.endLine}${result.totalLines !== void 0 ? ` totalLines=${result.totalLines}` : ""}${result.completeFile ? " complete" : ""}${next}${route}`,
2468
+ section: `--- ${result.path} (lines=${result.startLine}-${result.endLine}) ---
2469
+ ${notice}${fuzzy}${result.content}`,
2470
+ structured: result
2471
+ };
2472
+ };
2473
+ let nextText = 0;
2474
+ const entries = requests.map((request, position) => {
2475
+ const binary = binaryReads[position];
2476
+ if (binary) return binaryBatchEntry("artifact", request.path, binary);
2477
+ return textEntry(results[nextText++]);
2409
2478
  });
2410
- const allFailed = results.length > 0 && results.every((result) => result.status === "error");
2479
+ const okCount = entries.filter((entry) => entry.structured.status === "ok").length;
2480
+ const allFailed = entries.length > 0 && okCount === 0;
2411
2481
  return {
2412
2482
  content: [
2413
2483
  {
2414
2484
  type: "text",
2415
- text: `[read_artifacts requested=${results.length} ok=${results.filter((result) => result.status === "ok").length} errors=${results.filter((result) => result.status === "error").length}]
2416
- ${index.join("\n")}
2485
+ text: `[read_artifacts requested=${entries.length} ok=${okCount} errors=${entries.length - okCount}]
2486
+ ${entries.map((entry, position) => `${position + 1} ${entry.line}`).join("\n")}
2417
2487
 
2418
- ${sections.join("\n\n")}`
2488
+ ${entries.map((entry) => entry.section).join("\n\n")}`
2419
2489
  }
2420
2490
  ],
2421
- structuredContent: { results },
2491
+ structuredContent: { results: entries.map((entry) => entry.structured) },
2422
2492
  ...allFailed ? { isError: true } : {}
2423
2493
  };
2424
2494
  }
@@ -7305,6 +7375,15 @@ function classifyArtifactPath(cleanPath) {
7305
7375
  if (WORKSPACE_LIKELY_EXTENSIONS.has(ext)) return { ok: false, extension: ext };
7306
7376
  return { ok: true };
7307
7377
  }
7378
+ async function sessionTaskReadsArtifactAt(cleanPath) {
7379
+ if (!sessionTaskRef) return false;
7380
+ try {
7381
+ const parsed = await parseRef(sessionTaskRef);
7382
+ return taskReadsArtifactAt(await api.getTask(parsed.projectId, parsed.num), cleanPath);
7383
+ } catch {
7384
+ return false;
7385
+ }
7386
+ }
7308
7387
  async function workspaceCollisionForArtifactPath(cleanPath) {
7309
7388
  try {
7310
7389
  const stat = await api.statProjectWorkspacePath(projectId, cleanPath);
@@ -7753,9 +7832,13 @@ async function writeArtifactToolCall({
7753
7832
  };
7754
7833
  }
7755
7834
  }
7835
+ let workspaceTwinNote = "";
7756
7836
  if (!force) {
7757
7837
  const workspaceCollision = await workspaceCollisionForArtifactPath(clean);
7758
- if (workspaceCollision) {
7838
+ if (workspaceCollision && await sessionTaskReadsArtifactAt(clean)) {
7839
+ workspaceTwinNote = `
7840
+ The task reads ${clean} from the artifacts drawer, so this is the copy it checks. The workspace ${workspaceCollision.kind} at the same path was left as it is.`;
7841
+ } else if (workspaceCollision) {
7759
7842
  return {
7760
7843
  content: [
7761
7844
  {
@@ -7798,7 +7881,11 @@ async function writeArtifactToolCall({
7798
7881
  const completionHint = sessionTaskRef && sessionStepId ? artifactCompletionHint(sessionStepCompletion, {
7799
7882
  checkedByStep: sessionStepCheckedArtifacts.includes(clean)
7800
7883
  }) : "";
7801
- return { content: [{ type: "text", text: `Wrote ${clean}${completionHint}` }] };
7884
+ return {
7885
+ content: [
7886
+ { type: "text", text: `Wrote ${clean}${workspaceTwinNote}${completionHint}` }
7887
+ ]
7888
+ };
7802
7889
  }
7803
7890
  server.tool(
7804
7891
  "run_playwright_script",
@@ -12720,7 +12807,7 @@ function installedVideoAnimates() {
12720
12807
  if (!videoAnimatesCache || now - videoAnimatesCache.at > 6e4) {
12721
12808
  videoAnimatesCache = {
12722
12809
  at: now,
12723
- value: api.listInstalledVideoModels().then((res) => res.defaultImageToVideoModel !== void 0).catch(() => false)
12810
+ value: api.videoAnimates().then((res) => res.animates === true).catch(() => false)
12724
12811
  };
12725
12812
  }
12726
12813
  return videoAnimatesCache.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-mcp",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Gezel's Model Context Protocol server: gives gezels and other MCP clients access to memory, workspace files, artifacts, tasks, and team tools.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -56,8 +56,8 @@
56
56
  "!dist/**/*.map"
57
57
  ],
58
58
  "dependencies": {
59
- "@bendyline/gezel": "1.3.1",
60
- "@bendyline/gezel-client": "1.3.1",
59
+ "@bendyline/gezel": "1.3.3",
60
+ "@bendyline/gezel-client": "1.3.3",
61
61
  "@modelcontextprotocol/sdk": "1.32.2",
62
62
  "typescript": "^6.0.3",
63
63
  "zod": "4.6.7"