@bendyline/gezel-mcp 1.0.7 → 1.1.0

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/index.d.ts CHANGED
@@ -53,8 +53,8 @@ declare const CONDITIONALLY_REGISTERED_TOOLS: {
53
53
  readonly modelFacing: false;
54
54
  };
55
55
  readonly craftbook_update_step: {
56
- readonly envVar: "GEZEL_CRAFTBOOK_ID";
57
- readonly envValue: "*";
56
+ readonly envVar: "GEZEL_CRAFTBOOK_STEP_EDITING";
57
+ readonly envValue: "1";
58
58
  readonly modelFacing: true;
59
59
  };
60
60
  readonly request_tool_permission: {
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/tool-inventory.ts
4
+ import { resolveDistributionProfile } from "@bendyline/gezel";
4
5
  var ALWAYS_REGISTERED_TOOLS = [
5
6
  // Memory
6
7
  "search_memory",
@@ -228,11 +229,13 @@ var CONDITIONALLY_REGISTERED_TOOLS = {
228
229
  modelFacing: false
229
230
  },
230
231
  // The large surgical-step schema is useful in the explicit craftbook
231
- // editor, but wasteful on every ordinary coordinator turn. `*` means any
232
- // non-empty GEZEL_CRAFTBOOK_ID enables it.
232
+ // editor and in task-scoped plan authoring, but wasteful on every ordinary
233
+ // coordinator turn. The chat manager enables this MCP-side registration
234
+ // for those session types; its exact per-turn allowlist still decides
235
+ // whether the schema reaches the model.
233
236
  craftbook_update_step: {
234
- envVar: "GEZEL_CRAFTBOOK_ID",
235
- envValue: "*",
237
+ envVar: "GEZEL_CRAFTBOOK_STEP_EDITING",
238
+ envValue: "1",
236
239
  modelFacing: true
237
240
  },
238
241
  request_tool_permission: {
@@ -16,6 +16,7 @@ async function loadBuiltinToolContracts() {
16
16
  "GEZEL_MCP_TOOL_NAMING",
17
17
  "GEZEL_SCRIPT_TOOLS",
18
18
  "GEZEL_CRAFTBOOK_ID",
19
+ "GEZEL_CRAFTBOOK_STEP_EDITING",
19
20
  "GEZEL_MAIL_ENABLED",
20
21
  "GEZEL_SOCIAL_ENABLED",
21
22
  "GEZEL_CONNECTORS_ENABLED",
@@ -30,6 +31,7 @@ async function loadBuiltinToolContracts() {
30
31
  delete process.env.GEZEL_MCP_TOOL_NAMING;
31
32
  delete process.env.GEZEL_SCRIPT_TOOLS;
32
33
  process.env.GEZEL_CRAFTBOOK_ID = "schema-lint-craftbook";
34
+ process.env.GEZEL_CRAFTBOOK_STEP_EDITING = "1";
33
35
  process.env.GEZEL_MAIL_ENABLED = "1";
34
36
  process.env.GEZEL_SOCIAL_ENABLED = "1";
35
37
  process.env.GEZEL_CONNECTORS_ENABLED = "1";
package/dist/server.js CHANGED
@@ -181,6 +181,58 @@ function normalizeAssigneeArg(raw) {
181
181
  return { kind: "gezel", ref: trimmed };
182
182
  }
183
183
 
184
+ // src/browser-page-elements.ts
185
+ var INTERACTIVE_ROLES = [
186
+ "button",
187
+ "link",
188
+ "textbox",
189
+ "searchbox",
190
+ "combobox",
191
+ "checkbox",
192
+ "radio",
193
+ "switch",
194
+ "slider",
195
+ "menuitem",
196
+ "menuitemcheckbox",
197
+ "menuitemradio",
198
+ "tab",
199
+ "option",
200
+ "spinbutton"
201
+ ];
202
+ var ELEMENT_REF_RE = new RegExp(
203
+ String.raw`^\s*- (` + INTERACTIVE_ROLES.join("|") + String.raw`)\s+"([^"]+)"\s+\[ref=(e\d+)\]`
204
+ );
205
+ function extractPageElementsFromYaml(yaml) {
206
+ const out = [];
207
+ const seen = /* @__PURE__ */ new Set();
208
+ for (const line of yaml.split("\n")) {
209
+ const match = line.match(ELEMENT_REF_RE);
210
+ if (!match) continue;
211
+ const role = match[1];
212
+ const name = match[2];
213
+ const ref = match[3];
214
+ if (!role || !name || !ref) continue;
215
+ const key = `${ref}:${role}:${name}`;
216
+ if (seen.has(key)) continue;
217
+ seen.add(key);
218
+ out.push({ role, name, ref });
219
+ }
220
+ return out;
221
+ }
222
+ function scorePageElementMatch(element, description, role) {
223
+ const desc = description.toLowerCase().trim();
224
+ const elementRole = element.role.toLowerCase();
225
+ const elementName = element.name.toLowerCase();
226
+ let score = 0;
227
+ if (role && elementRole === role.toLowerCase()) score += 10;
228
+ if (desc.length > 0 && elementName.includes(desc)) score += 5;
229
+ if (desc.length > 0 && elementRole.includes(desc)) score += 1;
230
+ for (const word of desc.split(/\s+/).filter(Boolean)) {
231
+ if (elementName.includes(word) || elementRole.includes(word)) score += 1;
232
+ }
233
+ return score;
234
+ }
235
+
184
236
  // src/command-result.ts
185
237
  function commandResultIsError(result) {
186
238
  return !result.ok && result.approvalPending !== true;
@@ -833,6 +885,7 @@ import { z as z5 } from "zod";
833
885
  import { z as z4 } from "zod";
834
886
 
835
887
  // src/tool-inventory.ts
888
+ import { resolveDistributionProfile } from "@bendyline/gezel";
836
889
  var ALWAYS_REGISTERED_TOOLS = [
837
890
  // Memory
838
891
  "search_memory",
@@ -1060,11 +1113,13 @@ var CONDITIONALLY_REGISTERED_TOOLS = {
1060
1113
  modelFacing: false
1061
1114
  },
1062
1115
  // The large surgical-step schema is useful in the explicit craftbook
1063
- // editor, but wasteful on every ordinary coordinator turn. `*` means any
1064
- // non-empty GEZEL_CRAFTBOOK_ID enables it.
1116
+ // editor and in task-scoped plan authoring, but wasteful on every ordinary
1117
+ // coordinator turn. The chat manager enables this MCP-side registration
1118
+ // for those session types; its exact per-turn allowlist still decides
1119
+ // whether the schema reaches the model.
1065
1120
  craftbook_update_step: {
1066
- envVar: "GEZEL_CRAFTBOOK_ID",
1067
- envValue: "*",
1121
+ envVar: "GEZEL_CRAFTBOOK_STEP_EDITING",
1122
+ envValue: "1",
1068
1123
  modelFacing: true
1069
1124
  },
1070
1125
  request_tool_permission: {
@@ -1098,6 +1153,9 @@ var CONDITIONALLY_REGISTERED_TOOLS = {
1098
1153
  modelFacing: true
1099
1154
  }
1100
1155
  };
1156
+ function distributionWithheldTools(env = process.env) {
1157
+ return resolveDistributionProfile(env).allowNpmInstalls ? [] : ["npm_install"];
1158
+ }
1101
1159
  var HOST_CALLBACK_TOOLS = Object.freeze(
1102
1160
  /* @__PURE__ */ new Set(["request_tool_permission"])
1103
1161
  );
@@ -3384,7 +3442,8 @@ var excludedToolNames = new Set(
3384
3442
  // `GEZEL_MCP_SCHEMA_LINT` registers the whole corpus regardless of what
3385
3443
  // this host can actually sandbox, so schema lints and tool-response
3386
3444
  // tests see the same tools everywhere.
3387
- ...process.env.GEZEL_MCP_SCHEMA_LINT === "1" ? [] : unavailableToolsForPlatform(process.platform)
3445
+ ...process.env.GEZEL_MCP_SCHEMA_LINT === "1" ? [] : unavailableToolsForPlatform(process.platform),
3446
+ ...distributionWithheldTools()
3388
3447
  ].map(canonicalToolName)
3389
3448
  );
3390
3449
  if (process.env.GEZEL_MCP_LEGACY_TOOLS !== "1") {
@@ -3398,7 +3457,9 @@ if (process.env.GEZEL_MCP_LEGACY_TOOLS !== "1") {
3398
3457
  excludedToolNames.add(name);
3399
3458
  }
3400
3459
  }
3401
- if (!sessionCraftbookId) excludedToolNames.add("craftbook_update_step");
3460
+ if (process.env.GEZEL_CRAFTBOOK_STEP_EDITING !== "1") {
3461
+ excludedToolNames.add("craftbook_update_step");
3462
+ }
3402
3463
  var allowEnv = process.env.GEZEL_MCP_ALLOW;
3403
3464
  var allowedToolNames = allowEnv === void 0 ? null : new Set(
3404
3465
  allowEnv.split(",").map((s) => s.trim()).filter(Boolean).map(canonicalToolName)
@@ -6110,56 +6171,6 @@ ${res.candidates.map((p) => ` \u2022 ${p}`).join("\n")}`
6110
6171
  };
6111
6172
  }
6112
6173
  );
6113
- var PAGE_ELEMENT_INTERACTIVE_ROLES = [
6114
- "button",
6115
- "link",
6116
- "textbox",
6117
- "searchbox",
6118
- "combobox",
6119
- "checkbox",
6120
- "radio",
6121
- "switch",
6122
- "slider",
6123
- "menuitem",
6124
- "menuitemcheckbox",
6125
- "menuitemradio",
6126
- "tab",
6127
- "option",
6128
- "spinbutton"
6129
- ];
6130
- var PAGE_ELEMENT_REF_RE = new RegExp(
6131
- String.raw`^\s*- (` + PAGE_ELEMENT_INTERACTIVE_ROLES.join("|") + String.raw`)\s+"([^"]+)"\s+\[ref=(e\d+)\]`
6132
- );
6133
- function extractPageElementsFromYaml(yaml) {
6134
- const out = [];
6135
- const seen = /* @__PURE__ */ new Set();
6136
- for (const line of yaml.split("\n")) {
6137
- const m = line.match(PAGE_ELEMENT_REF_RE);
6138
- if (!m) continue;
6139
- const role = m[1];
6140
- const name = m[2];
6141
- const ref = m[3];
6142
- if (!role || !name || !ref) continue;
6143
- const key = `${ref}:${role}:${name}`;
6144
- if (seen.has(key)) continue;
6145
- seen.add(key);
6146
- out.push({ role, name, ref });
6147
- }
6148
- return out;
6149
- }
6150
- function scorePageElementMatch(el, description, role) {
6151
- const desc = description.toLowerCase().trim();
6152
- const elRole = el.role.toLowerCase();
6153
- const elName = el.name.toLowerCase();
6154
- let score = 0;
6155
- if (role && elRole === role.toLowerCase()) score += 10;
6156
- if (desc.length > 0 && elName.includes(desc)) score += 5;
6157
- if (desc.length > 0 && elRole.includes(desc)) score += 1;
6158
- for (const word of desc.split(/\s+/).filter(Boolean)) {
6159
- if (elName.includes(word) || elRole.includes(word)) score += 1;
6160
- }
6161
- return score;
6162
- }
6163
6174
  async function findLatestSnapshotPath() {
6164
6175
  try {
6165
6176
  const res = await api.listProjectArtifacts(projectId, "auto/browser_snapshot", true);
@@ -7906,7 +7917,7 @@ server.tool(
7906
7917
  );
7907
7918
  server.tool(
7908
7919
  "message_gezel",
7909
- 'Send a message to another gezel (status check, nudge, broadcast, or file handoff). This is async fire-and-forget: it drops the message into their active project session and their reply surfaces automatically in your next turn. Use this for fan-out and ambient updates; for explicit consultations where you need an inline answer before continuing, use `ask_gezel`. For substantial multi-step work, use tasks + `advance_task_step`. Do NOT just say \'I\'ll talk to Maya\' in chat; that does nothing. Call this tool. When the message asks them to produce a long-form file deliverable (a review, a report, an analysis, a written design), pass `expectedDeliverable: { kind: "file", filePath: "<path>" }` \u2014 the target will be steered to `write_file` the deliverable and reply with just the path + a short precis, instead of pasting the full text into chat (the matrix #2 squisq-review failure mode).',
7920
+ 'Send a message to another gezel (status check, nudge, broadcast, or file handoff). This is async fire-and-forget: it drops the message into their active project session and their reply surfaces automatically in a later turn. After a successful call, END YOUR TURN immediately \u2014 remaining alive can keep the recipient parked and occupies a provider slot. Use this for fan-out and ambient updates; emit every fan-out call in the same tool-call batch before ending. For explicit consultations where you need an inline answer before continuing, use `ask_gezel`. For substantial multi-step work, use tasks + `advance_task_step`. Do NOT just say \'I\'ll talk to Maya\' in chat; that does nothing. Call this tool. When the message asks them to produce a long-form file deliverable (a review, a report, an analysis, a written design), pass `expectedDeliverable: { kind: "file", filePath: "<path>" }` \u2014 the target will be steered to `write_file` the deliverable and reply with just the path + a short precis, instead of pasting the full text into chat (the matrix #2 squisq-review failure mode).',
7910
7921
  {
7911
7922
  gezel: z6.string().optional().describe("Target gezel id or display name"),
7912
7923
  // `gezelId` is the spelling models reach for; without it the slip
@@ -7961,7 +7972,9 @@ ${expectedDeliverable?.kind === "file" ? expectedDeliverable.filePath ?? "" : ""
7961
7972
  }
7962
7973
  const deliverableText = expectedDeliverable?.kind === "file" ? ` They have been asked to write ${expectedDeliverable.filePath ? `\`${expectedDeliverable.filePath}\`` : "the file"} before replying.` : "";
7963
7974
  const responseWasDeduplicated = res.deduplicated;
7964
- const responseText = responseWasDeduplicated ? `An identical file handoff is already pending with ${res.toGezelName}; joined it instead of queueing another message.` : `Pinged ${res.toGezelName}.${deliverableText} Their reply will land in your next turn.`;
7975
+ const deliveryState = messageGezelDeliveryState(res);
7976
+ const releaseInstruction = asyncHandoffReleaseInstruction(res.toGezelName, deliveryState);
7977
+ const responseText = responseWasDeduplicated ? `An identical file handoff is already pending with ${res.toGezelName}; joined it instead of creating another message. ${releaseInstruction}` : deliveryState === "parked" ? `Accepted the message for ${res.toGezelName}.${deliverableText} ${releaseInstruction}` : `Dispatched the message to ${res.toGezelName}.${deliverableText} ${releaseInstruction}`;
7965
7978
  return {
7966
7979
  content: [
7967
7980
  {
@@ -7972,6 +7985,15 @@ ${expectedDeliverable?.kind === "file" ? expectedDeliverable.filePath ?? "" : ""
7972
7985
  };
7973
7986
  }
7974
7987
  );
7988
+ function messageGezelDeliveryState(response) {
7989
+ return response.deliveryState === "dispatched" ? "dispatched" : "parked";
7990
+ }
7991
+ function asyncHandoffReleaseInstruction(recipientName, deliveryState) {
7992
+ if (deliveryState === "parked") {
7993
+ return `The handoff is durably parked and has NOT entered ${recipientName}'s provider queue because your current turn still holds its slot. END YOUR TURN NOW \u2014 do not call more tools or wait \u2014 so this turn releases the slot and ${recipientName}'s turn can dispatch. Their reply will arrive asynchronously in a later turn.`;
7994
+ }
7995
+ return `${recipientName}'s turn has entered the provider queue. END YOUR TURN NOW \u2014 do not call more tools or wait \u2014 so your turn releases its provider slot. Their reply will arrive asynchronously in a later turn.`;
7996
+ }
7975
7997
  function normalizeFileHandoffMessage(message, expectedDeliverable) {
7976
7998
  if (expectedDeliverable?.kind !== "file" || !expectedDeliverable.filePath) return message;
7977
7999
  const filePath = expectedDeliverable.filePath;
@@ -8316,7 +8338,7 @@ var DELEGATION_ROLE_SPECS = [
8316
8338
  for (const { slug, jobTitle, label, hint } of DELEGATION_ROLE_SPECS) {
8317
8339
  server.tool(
8318
8340
  `delegate_${slug}`,
8319
- `Hand a task to a project's ${label} (${hint}) \u2014 ASYNC. Auto-creates a ${label} if none exists; their reply lands in your next turn. The target IS this tool, so you never pick a name. For work in a project you created from Default, pass \`project\` so files land in that project. For a quick synchronous question instead, use \`consult_${slug}\`.`,
8341
+ `Hand a task to a project's ${label} (${hint}) \u2014 ASYNC. Auto-creates a ${label} if none exists; their reply lands in a later turn. After a successful call, END YOUR TURN immediately so the recipient can dispatch and your provider slot is released. The target IS this tool, so you never pick a name. For work in a project you created from Default, pass \`project\` so files land in that project. For a quick synchronous question instead, use \`consult_${slug}\`.`,
8320
8342
  {
8321
8343
  task: z6.string().min(1).describe(
8322
8344
  `What you want the ${label} to do. Be specific \u2014 they only see this message, not your conversation.`
@@ -8362,11 +8384,13 @@ ${expectedDeliverable?.kind === "file" ? expectedDeliverable.filePath ?? "" : ""
8362
8384
  ...expectedDeliverable ? { expectedDeliverable } : {}
8363
8385
  });
8364
8386
  const responseWasDeduplicated = res.deduplicated;
8387
+ const deliveryState = messageGezelDeliveryState(res);
8388
+ const releaseInstruction = asyncHandoffReleaseInstruction(res.toGezelName, deliveryState);
8365
8389
  return {
8366
8390
  content: [
8367
8391
  {
8368
8392
  type: "text",
8369
- text: responseWasDeduplicated ? `An identical file handoff is already pending with ${res.toGezelName} (${label}); joined it instead of queueing another message.` : `Handed off to ${res.toGezelName} (${label}) in project "${resolvedProject}". Their reply will arrive in your next turn. [hint: ${res.toGezelName} is now on that project; the user can switch to their chat for follow-ups.]`
8393
+ text: responseWasDeduplicated ? `An identical file handoff is already pending with ${res.toGezelName} (${label}); joined it instead of creating another message. ${releaseInstruction}` : `${deliveryState === "parked" ? "Accepted the handoff for" : "Dispatched the handoff to"} ${res.toGezelName} (${label}) in project "${resolvedProject}". ${releaseInstruction} [hint: ${res.toGezelName} is now on that project; the user can switch to their chat for follow-ups.]`
8370
8394
  }
8371
8395
  ]
8372
8396
  };
@@ -10375,12 +10399,16 @@ server.tool(
10375
10399
  }
10376
10400
  const { task, gate } = advanced;
10377
10401
  if (gate) {
10378
- const pausedNote = gate.infrastructureError ? " The gate itself could not run, so the task is PAUSED and no deliverable attempt was consumed. Do not rewrite the deliverable; report the gate/runtime problem." : gate.paused ? " The rejection budget is exhausted \u2014 the task is now PAUSED for the user; summarize where you got stuck and what you tried." : " Address these specifically, then call `advance_task_step` again.";
10402
+ const exitHookFailed = gate.hook === "onExit";
10403
+ const pausedNote = exitHookFailed ? " The lifecycle script could not finish, so the task is PAUSED and the step remains incomplete. Do not retry or rewrite the deliverable; report the script/runtime problem." : gate.infrastructureError ? " The gate itself could not run, so the task is PAUSED and no deliverable attempt was consumed. Do not rewrite the deliverable; report the gate/runtime problem." : gate.paused ? " The rejection budget is exhausted \u2014 the task is now PAUSED for the user; summarize where you got stuck and what you tried." : " Address these specifically, then call `advance_task_step` again.";
10379
10404
  const failedRun = gate.scriptRuns?.find((run) => run.error || run.runId);
10380
10405
  const diagnosticNote = failedRun ? `
10381
10406
  Script diagnostic: ${failedRun.scriptName}${failedRun.runId ? ` (run ${failedRun.runId})` : ""}${failedRun.error ? ` \u2014 ${failedRun.error}` : ""}. Full redacted logs are in the task note.` : "";
10382
10407
  return errorResult(
10383
- gate.infrastructureError ? `Step "${stepId}" on ${ref} was NOT completed because its gate could not run:
10408
+ exitHookFailed ? `Step "${stepId}" on ${ref} was NOT completed because its onExit script failed:
10409
+
10410
+ ${gate.message}
10411
+ ${pausedNote}${diagnosticNote}` : gate.infrastructureError ? `Step "${stepId}" on ${ref} was NOT completed because its gate could not run:
10384
10412
 
10385
10413
  ${gate.message}
10386
10414
  ${pausedNote}${diagnosticNote}` : `Step "${stepId}" on ${ref} was NOT completed \u2014 its gate rejected the work (attempt ${gate.attempt}/${gate.maxAttempts}):
@@ -10388,7 +10416,7 @@ ${pausedNote}${diagnosticNote}` : `Step "${stepId}" on ${ref} was NOT completed
10388
10416
  ${gate.message}
10389
10417
  ${pausedNote}`,
10390
10418
  {
10391
- code: gate.infrastructureError ? "gate_infrastructure_error" : "gate_rejected",
10419
+ code: exitHookFailed ? "step_exit_script_failed" : gate.infrastructureError ? "gate_infrastructure_error" : "gate_rejected",
10392
10420
  retryable: !gate.paused && !gate.infrastructureError
10393
10421
  }
10394
10422
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-mcp",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
4
  "description": "Gezel MCP server — gives agents access to memory, workspace, artifacts, and tools.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -55,8 +55,8 @@
55
55
  "!dist/**/*.map"
56
56
  ],
57
57
  "dependencies": {
58
- "@bendyline/gezel": "1.0.7",
59
- "@bendyline/gezel-client": "1.0.7",
58
+ "@bendyline/gezel": "1.1.0",
59
+ "@bendyline/gezel-client": "1.1.0",
60
60
  "@modelcontextprotocol/sdk": "^1.29.0",
61
61
  "typescript": "^6.0.3",
62
62
  "zod": "^4.4.3"