@bendyline/gezel-mcp 1.0.0 → 1.0.2

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
@@ -18,7 +18,7 @@
18
18
  * whose names come from the applied type's manifest, not from this frozen
19
19
  * contract. Registration guards them against colliding with these names.
20
20
  */
21
- declare const ALWAYS_REGISTERED_TOOLS: readonly ["search_memory", "save_memory", "list_memories", "list_dir", "read_file", "read_files", "stat", "write_file", "append_to_file", "replace_in_file", "replace_lines", "apply_patch", "insert_at_marker", "delete_path", "make_dir", "rename", "copy_artifact_to_workspace", "validate", "npm_install", "list_package_scripts", "run_package_script", "run_npx", "run_nodejs_script", "derive_file", "list_packages", "run_playwright_script", "list_artifacts", "read_artifact", "write_artifact", "grep_artifact", "browser_find_page_element", "list_documents", "read_document", "write_document", "delete_document", "search_documents", "list_gezels", "create_gezel", "list_gilde", "list_project_types", "apply_project_type", "start_project_from_type", "export_project_type", "import_project_type", "ensure_gezel", "update_gezel", "message_gezel", "ask_gezel", "ask_specialist", "delegate_developer", "consult_developer", "delegate_designer", "consult_designer", "delegate_reviewer", "consult_reviewer", "delegate_planner", "consult_planner", "delegate_researcher", "consult_researcher", "delegate_builder", "consult_builder", "delegate_writer", "consult_writer", "delegate_image_generator", "consult_image_generator", "delegate_voorman", "consult_voorman", "delegate_meester", "consult_meester", "ask_user_question", "list_projects", "start_project", "fetch_repo", "fetch_diff", "update_project", "list_project_gezels", "add_gezel_to_project", "remove_gezel_from_project", "list_suggested_work", "enable_suggested_work", "disable_suggested_work", "list_tasks", "get_task", "create_task", "start_plan", "update_task", "set_outcomes", "verify_outcome", "add_verification_step", "spawn_task_instances", "list_task_children", "set_task_status", "activate_task", "assign_task", "add_task_step", "advance_task_step", "read_task_notes", "write_task_note", "search_history", "search_sessions", "how_do_i", "render_image", "generate_image", "describe_image", "read_image_metadata", "generate_video", "transcribe_audio", "synthesize_speech", "fetch_url", "web_search", "wikipedia_search", "grep_files", "find_files", "diff_files", "read_image_as_base64", "outline_file", "find_symbol", "read_symbol", "find_references", "map_repo", "search_code", "file_review", "list_file_issues", "security_scan", "security_overview", "scan_findings", "map_attack_surface", "list_dependencies", "trace_taint", "search_docs", "read_doc_as_markdown", "search_images", "find_similar_images", "describe_folder", "find_entity", "list_entity_mentions", "list_archive", "extract_archive", "run_git", "list_scripts", "run_installed_script", "get_script_run", "list_craftbooks", "suggest_craftbook", "invoke_craftbook", "import_skill", "craftbook_read", "craftbook_write", "craftbook_add_step", "set_step_deliverable", "craftbook_remove_step", "craftbook_reorder_steps", "craftbook_set_entry", "craftbook_update", "export_task_craftbook", "github_pr_list", "github_pr_view", "github_pr_files", "github_pr_diff", "github_pr_comments", "github_pr_comment", "github_pr_create", "github_workflow_runs", "github_check_status"];
21
+ declare const ALWAYS_REGISTERED_TOOLS: readonly ["search_memory", "save_memory", "list_memories", "list_dir", "read_file", "read_files", "stat", "write_file", "append_to_file", "replace_in_file", "replace_lines", "apply_patch", "insert_at_marker", "delete_path", "make_dir", "rename", "copy_artifact_to_workspace", "validate", "npm_install", "list_package_scripts", "run_package_script", "run_npx", "run_nodejs_script", "derive_file", "list_packages", "run_playwright_script", "list_artifacts", "read_artifact", "write_artifact", "grep_artifact", "browser_find_page_element", "list_documents", "read_document", "write_document", "delete_document", "search_documents", "list_gezels", "create_gezel", "list_gilde", "list_project_types", "apply_project_type", "start_project_from_type", "export_project_type", "import_project_type", "ensure_gezel", "update_gezel", "message_gezel", "ask_gezel", "ask_specialist", "delegate_developer", "consult_developer", "delegate_designer", "consult_designer", "delegate_reviewer", "consult_reviewer", "delegate_planner", "consult_planner", "delegate_researcher", "consult_researcher", "delegate_builder", "consult_builder", "delegate_writer", "consult_writer", "delegate_image_generator", "consult_image_generator", "delegate_voorman", "consult_voorman", "delegate_meester", "consult_meester", "ask_user_question", "list_projects", "start_project", "fetch_repo", "fetch_diff", "update_project", "list_project_gezels", "add_gezel_to_project", "remove_gezel_from_project", "list_suggested_work", "enable_suggested_work", "disable_suggested_work", "list_tasks", "get_task", "create_task", "start_plan", "update_task", "set_outcomes", "verify_outcome", "add_verification_step", "spawn_task_instances", "list_task_children", "set_task_status", "activate_task", "assign_task", "add_task_step", "advance_task_step", "read_task_notes", "write_task_note", "search_history", "search_sessions", "how_do_i", "render_image", "generate_image", "describe_image", "read_image_metadata", "generate_video", "transcribe_audio", "synthesize_speech", "fetch_url", "web_search", "wikipedia_search", "grep_files", "find_files", "diff_files", "read_image_as_base64", "outline_file", "find_symbol", "read_symbol", "find_references", "map_repo", "search_code", "file_review", "list_file_issues", "get_file_issue", "set_file_issue_status", "security_scan", "security_overview", "scan_findings", "map_attack_surface", "list_dependencies", "trace_taint", "search_docs", "read_doc_as_markdown", "search_images", "find_similar_images", "describe_folder", "find_entity", "list_entity_mentions", "list_archive", "extract_archive", "run_git", "list_scripts", "run_installed_script", "get_script_run", "list_craftbooks", "suggest_craftbook", "invoke_craftbook", "import_skill", "craftbook_read", "craftbook_write", "craftbook_add_step", "set_step_deliverable", "craftbook_remove_step", "craftbook_reorder_steps", "craftbook_set_entry", "craftbook_update", "export_task_craftbook", "github_pr_list", "github_pr_view", "github_pr_files", "github_pr_diff", "github_pr_comments", "github_pr_comment", "github_pr_create", "github_workflow_runs", "github_check_status"];
22
22
  /**
23
23
  * Tools registered only when their feature or session-context gate is set
24
24
  * in the env. Keep contextual/compatibility tools here so inventory users
@@ -75,6 +75,21 @@ declare const CONDITIONALLY_REGISTERED_TOOLS: {
75
75
  readonly envValue: "1";
76
76
  readonly modelFacing: true;
77
77
  };
78
+ readonly draft_post: {
79
+ readonly envVar: "GEZEL_SOCIAL_ENABLED";
80
+ readonly envValue: "1";
81
+ readonly modelFacing: true;
82
+ };
83
+ readonly queue_post: {
84
+ readonly envVar: "GEZEL_SOCIAL_ENABLED";
85
+ readonly envValue: "1";
86
+ readonly modelFacing: true;
87
+ };
88
+ readonly publish_post: {
89
+ readonly envVar: "GEZEL_SOCIAL_ENABLED";
90
+ readonly envValue: "1";
91
+ readonly modelFacing: true;
92
+ };
78
93
  readonly draft_connector_action: {
79
94
  readonly envVar: "GEZEL_CONNECTORS_ENABLED";
80
95
  readonly envValue: "1";
package/dist/index.js CHANGED
@@ -145,6 +145,8 @@ var ALWAYS_REGISTERED_TOOLS = [
145
145
  "search_code",
146
146
  "file_review",
147
147
  "list_file_issues",
148
+ "get_file_issue",
149
+ "set_file_issue_status",
148
150
  // Security intelligence (static security analysis over the index)
149
151
  "security_scan",
150
152
  "security_overview",
@@ -240,6 +242,11 @@ var CONDITIONALLY_REGISTERED_TOOLS = {
240
242
  draft_email: { envVar: "GEZEL_MAIL_ENABLED", envValue: "1", modelFacing: true },
241
243
  queue_email: { envVar: "GEZEL_MAIL_ENABLED", envValue: "1", modelFacing: true },
242
244
  send_email: { envVar: "GEZEL_MAIL_ENABLED", envValue: "1", modelFacing: true },
245
+ // Social post write tools — registered only for projects with a social-type
246
+ // connector binding (the chat manager sets GEZEL_SOCIAL_ENABLED).
247
+ draft_post: { envVar: "GEZEL_SOCIAL_ENABLED", envValue: "1", modelFacing: true },
248
+ queue_post: { envVar: "GEZEL_SOCIAL_ENABLED", envValue: "1", modelFacing: true },
249
+ publish_post: { envVar: "GEZEL_SOCIAL_ENABLED", envValue: "1", modelFacing: true },
243
250
  // Generic connector writes are draft-only and appear only for projects
244
251
  // with at least one connector binding.
245
252
  draft_connector_action: {
@@ -17,6 +17,7 @@ async function loadBuiltinToolContracts() {
17
17
  "GEZEL_SCRIPT_TOOLS",
18
18
  "GEZEL_CRAFTBOOK_ID",
19
19
  "GEZEL_MAIL_ENABLED",
20
+ "GEZEL_SOCIAL_ENABLED",
20
21
  "GEZEL_CONNECTORS_ENABLED",
21
22
  "GEZEL_PERMISSION_PROMPT"
22
23
  ];
@@ -30,6 +31,7 @@ async function loadBuiltinToolContracts() {
30
31
  delete process.env.GEZEL_SCRIPT_TOOLS;
31
32
  process.env.GEZEL_CRAFTBOOK_ID = "schema-lint-craftbook";
32
33
  process.env.GEZEL_MAIL_ENABLED = "1";
34
+ process.env.GEZEL_SOCIAL_ENABLED = "1";
33
35
  process.env.GEZEL_CONNECTORS_ENABLED = "1";
34
36
  process.env.GEZEL_PERMISSION_PROMPT = "1";
35
37
  try {
package/dist/server.js CHANGED
@@ -469,6 +469,19 @@ function unavailableToolsForPlatform(platform, options = {}) {
469
469
  return DENY_NET_TOOLS;
470
470
  }
471
471
 
472
+ // src/question-prompt.ts
473
+ function composeQuestionPrompt(parts) {
474
+ const unique = [];
475
+ for (const value of [parts.question, parts.prompt, parts.description]) {
476
+ const trimmed = value?.trim();
477
+ if (trimmed && !unique.includes(trimmed)) unique.push(trimmed);
478
+ }
479
+ return unique.join("\n\n");
480
+ }
481
+ function resolveQuestionTaskRef(explicitTaskRef, sessionTaskRef2) {
482
+ return explicitTaskRef ?? (sessionTaskRef2.trim() || void 0);
483
+ }
484
+
472
485
  // src/reanchor.ts
473
486
  var REANCHOR_CONTEXT_LINES = 4;
474
487
  var REANCHOR_MAX_CHARS = 1400;
@@ -716,6 +729,8 @@ var ALWAYS_REGISTERED_TOOLS = [
716
729
  "search_code",
717
730
  "file_review",
718
731
  "list_file_issues",
732
+ "get_file_issue",
733
+ "set_file_issue_status",
719
734
  // Security intelligence (static security analysis over the index)
720
735
  "security_scan",
721
736
  "security_overview",
@@ -811,6 +826,11 @@ var CONDITIONALLY_REGISTERED_TOOLS = {
811
826
  draft_email: { envVar: "GEZEL_MAIL_ENABLED", envValue: "1", modelFacing: true },
812
827
  queue_email: { envVar: "GEZEL_MAIL_ENABLED", envValue: "1", modelFacing: true },
813
828
  send_email: { envVar: "GEZEL_MAIL_ENABLED", envValue: "1", modelFacing: true },
829
+ // Social post write tools — registered only for projects with a social-type
830
+ // connector binding (the chat manager sets GEZEL_SOCIAL_ENABLED).
831
+ draft_post: { envVar: "GEZEL_SOCIAL_ENABLED", envValue: "1", modelFacing: true },
832
+ queue_post: { envVar: "GEZEL_SOCIAL_ENABLED", envValue: "1", modelFacing: true },
833
+ publish_post: { envVar: "GEZEL_SOCIAL_ENABLED", envValue: "1", modelFacing: true },
814
834
  // Generic connector writes are draft-only and appear only for projects
815
835
  // with at least one connector binding.
816
836
  draft_connector_action: {
@@ -1128,6 +1148,9 @@ var TOOL_OUTPUT_SCHEMAS = {
1128
1148
  draft_email: ActionToolOutputSchema,
1129
1149
  queue_email: ActionToolOutputSchema,
1130
1150
  send_email: ActionToolOutputSchema,
1151
+ draft_post: ActionToolOutputSchema,
1152
+ queue_post: ActionToolOutputSchema,
1153
+ publish_post: ActionToolOutputSchema,
1131
1154
  draft_connector_action: ActionToolOutputSchema
1132
1155
  };
1133
1156
  function outputSchemaForTool(name) {
@@ -1202,6 +1225,7 @@ var READ_ONLY_TOOLS = /* @__PURE__ */ new Set([
1202
1225
  "search_code",
1203
1226
  "file_review",
1204
1227
  "list_file_issues",
1228
+ "get_file_issue",
1205
1229
  "security_overview",
1206
1230
  "scan_findings",
1207
1231
  "map_attack_surface",
@@ -1279,6 +1303,8 @@ var NON_DESTRUCTIVE_MUTATIONS = /* @__PURE__ */ new Set([
1279
1303
  "github_pr_create",
1280
1304
  "draft_email",
1281
1305
  "queue_email",
1306
+ "draft_post",
1307
+ "queue_post",
1282
1308
  "draft_connector_action",
1283
1309
  "request_tool_permission"
1284
1310
  ]);
@@ -1331,6 +1357,9 @@ var OPEN_WORLD_TOOLS = /* @__PURE__ */ new Set([
1331
1357
  "draft_email",
1332
1358
  "queue_email",
1333
1359
  "send_email",
1360
+ "draft_post",
1361
+ "queue_post",
1362
+ "publish_post",
1334
1363
  "draft_connector_action",
1335
1364
  "request_tool_permission"
1336
1365
  ]);
@@ -3016,6 +3045,147 @@ function registerEmailTools() {
3016
3045
  if (process.env.GEZEL_MAIL_ENABLED === "1") {
3017
3046
  registerEmailTools();
3018
3047
  }
3048
+ var SOCIAL_TYPE_PREFIXES = ["bluesky-", "x-", "instagram-", "linkedin-"];
3049
+ async function resolveSocialBinding(accountId) {
3050
+ const { ok, data } = await connectorActionApi("", "GET");
3051
+ if (!ok) throw new Error(String(data.error ?? "failed to list connector bindings"));
3052
+ const bindings = data.bindings ?? [];
3053
+ const social = bindings.filter(
3054
+ (b) => typeof b.type === "string" && SOCIAL_TYPE_PREFIXES.some((prefix) => b.type.startsWith(prefix))
3055
+ );
3056
+ if (accountId) {
3057
+ const match = social.find((b) => b.id === accountId)?.id;
3058
+ if (!match) throw new Error(`social connector binding "${accountId}" was not found`);
3059
+ return match;
3060
+ }
3061
+ return social[0]?.id ?? null;
3062
+ }
3063
+ function registerSocialTools() {
3064
+ server.tool(
3065
+ "draft_post",
3066
+ "Compose a social post draft and save it for review. This does NOT publish \u2014 it stages a publish action under the social connector's corpus. Use queue_post to stage it for approval and publish_post to publish. Works with any connected social account: Bluesky, X, and LinkedIn publish directly once the user enables publishing on the connection; Instagram additionally requires a publicly hosted https image URL (Meta's servers fetch the media). Every publish clears the user's consent gate.",
3067
+ {
3068
+ text: z5.string().describe("The post text (Bluesky limit: 300 characters)"),
3069
+ replyToUri: z5.string().optional().describe("at:// URI of the post being replied to, to thread the reply"),
3070
+ langs: z5.array(z5.string()).optional().describe('BCP-47 language codes for the post, e.g. ["en"]'),
3071
+ images: z5.array(
3072
+ z5.object({
3073
+ path: z5.string().describe(
3074
+ "Project-relative image path, resolved against the project's artifacts directory first, then its workspace"
3075
+ ),
3076
+ alt: z5.string().optional().describe("Alt text describing the image for accessibility")
3077
+ })
3078
+ ).max(4).optional().describe(
3079
+ "Up to 4 images to embed (png/jpg/jpeg/webp/gif, at most 1,000,000 bytes each; paths resolve against project artifacts first, then the workspace). ALWAYS write meaningful alt text for every image \u2014 never leave it blank."
3080
+ ),
3081
+ accountId: z5.string().optional().describe("Which social connector binding to post from (defaults to the first)")
3082
+ },
3083
+ async (args) => {
3084
+ try {
3085
+ const bindingId = await resolveSocialBinding(args.accountId);
3086
+ if (!bindingId) return errorResult("This project has no linked social connector.");
3087
+ const { accountId: _drop, ...input } = args;
3088
+ const { ok, data } = await connectorActionApi(
3089
+ `${encodeURIComponent(bindingId)}/actions`,
3090
+ "POST",
3091
+ { action: "publish", input }
3092
+ );
3093
+ if (!ok) return errorResult(String(data.error ?? "Post draft failed."));
3094
+ const draftId = typeof data.draftId === "string" ? data.draftId : void 0;
3095
+ const relPath = typeof data.relPath === "string" ? data.relPath : void 0;
3096
+ const summary = `Draft saved${draftId ? ` (id: ${draftId})` : ""}${relPath ? ` at ${relPath}` : ""}. Review it, then call queue_post then publish_post.`;
3097
+ return okResult(
3098
+ ActionToolOutputSchema,
3099
+ {
3100
+ summary,
3101
+ status: "drafted",
3102
+ ...draftId ? { draftId } : {},
3103
+ ...relPath ? { relPath } : {}
3104
+ },
3105
+ { text: summary }
3106
+ );
3107
+ } catch (err) {
3108
+ return errorResult(`draft_post failed: ${unwrapApiError(err)}`);
3109
+ }
3110
+ }
3111
+ );
3112
+ server.tool(
3113
+ "queue_post",
3114
+ "Stage a saved post draft for publishing by moving it to the outbox. Does not publish.",
3115
+ { draftId: z5.string().describe("The draft id returned by draft_post") },
3116
+ async ({ draftId }) => {
3117
+ try {
3118
+ const { ok, data } = await connectorActionApi(
3119
+ `actions/${encodeURIComponent(draftId)}/queue`,
3120
+ "POST"
3121
+ );
3122
+ if (!ok) return errorResult(String(data.error ?? "Post queue failed."));
3123
+ const relPath = typeof data.relPath === "string" ? data.relPath : void 0;
3124
+ const summary = `Queued draft ${draftId}${relPath ? ` (${relPath})` : ""}.`;
3125
+ return okResult(
3126
+ ActionToolOutputSchema,
3127
+ {
3128
+ summary,
3129
+ status: "queued",
3130
+ draftId,
3131
+ ...relPath ? { relPath } : {}
3132
+ },
3133
+ { text: summary }
3134
+ );
3135
+ } catch (err) {
3136
+ return errorResult(`queue_post failed: ${unwrapApiError(err)}`);
3137
+ }
3138
+ }
3139
+ );
3140
+ server.tool(
3141
+ "publish_post",
3142
+ "Publish a drafted/queued social post. The daemon enforces per-binding publish consent (publishing must be enabled on the connector, and each publish clears the social-publish consent scope) and will NOT publish during night shift (the post is staged for daytime approval instead).",
3143
+ { draftId: z5.string().describe("The draft id to publish") },
3144
+ async ({ draftId }) => {
3145
+ try {
3146
+ const { ok, data } = await connectorActionApi(
3147
+ `actions/${encodeURIComponent(draftId)}/commit`,
3148
+ "POST"
3149
+ );
3150
+ if (!ok) {
3151
+ const message = String(data.error ?? "Post publish failed.");
3152
+ const hint = /publishing is disabled/i.test(message) ? "Ask the user to enable 'Allow publishing' on the connector's settings." : void 0;
3153
+ return errorResult(message, { ...hint ? { hint } : {} });
3154
+ }
3155
+ if (data.status === "queued-night-shift") {
3156
+ const relPath = typeof data.relPath === "string" ? data.relPath : void 0;
3157
+ const summary2 = `Night shift is active \u2014 not publishing unattended. The post is staged in the outbox${relPath ? ` (${relPath})` : ""} and will require explicit approval.`;
3158
+ return okResult(
3159
+ ActionToolOutputSchema,
3160
+ {
3161
+ summary: summary2,
3162
+ status: "queued-night-shift",
3163
+ draftId,
3164
+ ...relPath ? { relPath } : {}
3165
+ },
3166
+ { text: summary2 }
3167
+ );
3168
+ }
3169
+ const result = data.result ?? {};
3170
+ const summary = `Published.${result.permalink ? ` ${result.permalink}` : result.uri ? ` ${result.uri}` : ""}`;
3171
+ return okResult(
3172
+ ActionToolOutputSchema,
3173
+ {
3174
+ summary,
3175
+ status: "published",
3176
+ draftId
3177
+ },
3178
+ { text: summary }
3179
+ );
3180
+ } catch (err) {
3181
+ return errorResult(`publish_post failed: ${unwrapApiError(err)}`);
3182
+ }
3183
+ }
3184
+ );
3185
+ }
3186
+ if (process.env.GEZEL_SOCIAL_ENABLED === "1") {
3187
+ registerSocialTools();
3188
+ }
3019
3189
  if (process.env.GEZEL_SCRIPT_TOOLS) {
3020
3190
  registerScriptTools(server, parseScriptToolSpecs(process.env.GEZEL_SCRIPT_TOOLS), {
3021
3191
  api,
@@ -3400,7 +3570,12 @@ server.tool(
3400
3570
  ]
3401
3571
  };
3402
3572
  } catch (err) {
3403
- const message = err instanceof Error ? err.message : String(err);
3573
+ let message = unwrapApiError(err);
3574
+ if (/artifact not found/i.test(message) && source.includes("://")) {
3575
+ message += `
3576
+
3577
+ \`source\` must be a path inside the artifacts drawer, not a tool-returned URI like "${source}". Call \`list_artifacts\` to see the real paths, then retry with the one you saved (e.g. \`deliverables/d-day.pptx\`). Do not write the file by hand instead \u2014 \`write_file\` corrupts binaries.`;
3578
+ }
3404
3579
  return {
3405
3580
  content: [{ type: "text", text: message }],
3406
3581
  isError: true
@@ -3667,7 +3842,7 @@ server.tool(
3667
3842
  newProjectId = project.id;
3668
3843
  resolvedName = project.name;
3669
3844
  } catch (err) {
3670
- const message = err instanceof Error ? err.message : String(err);
3845
+ const message = unwrapApiError(err);
3671
3846
  return {
3672
3847
  content: [{ type: "text", text: `fetch_diff: createProject failed: ${message}` }],
3673
3848
  isError: true
@@ -3693,7 +3868,7 @@ server.tool(
3693
3868
  ]
3694
3869
  };
3695
3870
  } catch (err) {
3696
- const message = err instanceof Error ? err.message : String(err);
3871
+ const message = unwrapApiError(err);
3697
3872
  return {
3698
3873
  content: [
3699
3874
  {
@@ -7205,8 +7380,10 @@ server.tool(
7205
7380
  // Common slip-ups some models reach for when they see an
7206
7381
  // "ask-a-question" tool — accept them so a naming mistake doesn't
7207
7382
  // surface as "technical error" to the user.
7208
- prompt: z5.string().optional().describe("Alias for `question`."),
7209
- description: z5.string().optional().describe("Alias for `question`."),
7383
+ prompt: z5.string().optional().describe(
7384
+ "Alias for `question`; when both are supplied, this explanatory text is preserved."
7385
+ ),
7386
+ description: z5.string().optional().describe("Alias for `question`; distinct text is preserved below the question."),
7210
7387
  choices: coerceJsonArray(
7211
7388
  z5.array(z5.string()).max(20).optional().describe(
7212
7389
  'Preset answer choices. **Always pass these when the answer is bounded** (pick a color, pick yes/no, pick one of three options). Omit only for genuinely open-ended questions. Must be an actual JSON array `["a","b"]`, not a stringified array.'
@@ -7215,7 +7392,7 @@ server.tool(
7215
7392
  allowWriteIn: z5.boolean().optional().describe("Allow free-text alongside the choices. Default true."),
7216
7393
  multiSelect: z5.boolean().optional().describe("Let the user pick more than one choice. Default false."),
7217
7394
  taskRef: TaskRefSchema.optional().describe(
7218
- 'Approval-flow context: a task this question is about, in `projectId/num` form. The UI renders the task header above the prompt with an "Open task" link.'
7395
+ 'Approval-flow context: a task this question is about, in `projectId/num` form. The current task is attached automatically in task sessions; pass this only to override it. The UI renders the task header above the prompt with an "Open task" link.'
7219
7396
  ),
7220
7397
  documentPath: z5.string().optional().describe(
7221
7398
  "Approval-flow context: a file this question is about. Accepts any of: a path under the global documents library; a path under the current project's `documents/` folder (pass just the relative path \u2014 the UI prepends the project prefix); or a path under the project's `artifacts/` folder. The server resolves in that order \u2014 you don't need to know which bucket the file lives in. The UI renders a collapsed preview + \"Open \u2026\" link with the kind chip matching what actually resolved."
@@ -7231,7 +7408,7 @@ server.tool(
7231
7408
  taskRef,
7232
7409
  documentPath
7233
7410
  }) => {
7234
- const body = (question ?? prompt ?? description ?? "").trim();
7411
+ const body = composeQuestionPrompt({ question, prompt, description });
7235
7412
  if (!body) {
7236
7413
  return {
7237
7414
  content: [
@@ -7253,6 +7430,7 @@ server.tool(
7253
7430
  };
7254
7431
  }
7255
7432
  try {
7433
+ const effectiveTaskRef = resolveQuestionTaskRef(taskRef, sessionTaskRef);
7256
7434
  const res = await api.askUserQuestion({
7257
7435
  projectId,
7258
7436
  gezelId,
@@ -7261,7 +7439,7 @@ server.tool(
7261
7439
  ...choices ? { choices } : {},
7262
7440
  ...allowWriteIn !== void 0 ? { allowWriteIn } : {},
7263
7441
  ...multiSelect !== void 0 ? { multiSelect } : {},
7264
- ...taskRef ? { taskRef } : {},
7442
+ ...effectiveTaskRef ? { taskRef: effectiveTaskRef } : {},
7265
7443
  ...documentPath ? { documentPath } : {}
7266
7444
  });
7267
7445
  if (res.deduped) {
@@ -7287,7 +7465,7 @@ The runtime posted the card (id ${res.questionId}). The user sees it in chat, on
7287
7465
  ]
7288
7466
  };
7289
7467
  } catch (err) {
7290
- const message = err instanceof Error ? err.message : String(err);
7468
+ const message = unwrapApiError(err);
7291
7469
  return errorResult(
7292
7470
  `ask_user_question failed: ${message}. Retry the call with corrected arguments \u2014 \`question\` must be a non-empty string and \`choices\` (when used) must be a real JSON array like \`["A","B","C"]\` (not a stringified one). Do NOT fall back to asking the question in prose; the user's notification depends on this tool firing.`,
7293
7471
  { retryable: true }
@@ -9362,7 +9540,7 @@ To embed this in HTML at \`workspace/<name>.html\`, use:
9362
9540
  ]
9363
9541
  };
9364
9542
  } catch (err) {
9365
- const msg = err instanceof Error ? err.message : String(err);
9543
+ const msg = unwrapApiError(err);
9366
9544
  return errorResult(
9367
9545
  `Render failed: ${msg}. Check that Chromium has finished installing (it downloads in the background on first boot).`,
9368
9546
  { retryable: true }
@@ -9661,7 +9839,7 @@ server.tool(
9661
9839
 
9662
9840
  ${body}` }] };
9663
9841
  } catch (err) {
9664
- const msg = err instanceof Error ? err.message : String(err);
9842
+ const msg = unwrapApiError(err);
9665
9843
  return {
9666
9844
  content: [{ type: "text", text: `fetch_url failed: ${msg}` }],
9667
9845
  isError: true
@@ -9684,7 +9862,7 @@ server.tool(
9684
9862
  const res = await api.toolWebSearch(projectId, args);
9685
9863
  return { content: [{ type: "text", text: formatWebSearchResponse(res) }] };
9686
9864
  } catch (err) {
9687
- const msg = err instanceof Error ? err.message : String(err);
9865
+ const msg = unwrapApiError(err);
9688
9866
  return {
9689
9867
  content: [{ type: "text", text: `web_search failed: ${msg}` }],
9690
9868
  isError: true
@@ -9707,7 +9885,7 @@ server.tool(
9707
9885
  const res = await api.toolWikipediaSearch(projectId, args);
9708
9886
  return { content: [{ type: "text", text: formatWebSearchResponse(res) }] };
9709
9887
  } catch (err) {
9710
- const msg = err instanceof Error ? err.message : String(err);
9888
+ const msg = unwrapApiError(err);
9711
9889
  return {
9712
9890
  content: [{ type: "text", text: `wikipedia_search failed: ${msg}` }],
9713
9891
  isError: true
@@ -9806,7 +9984,7 @@ ${res.files.join("\n") || "(none)"}${truncation}` }
9806
9984
  ${lines.join("\n") || "(no matches)"}${truncation}` }
9807
9985
  );
9808
9986
  } catch (err) {
9809
- const msg = err instanceof Error ? err.message : String(err);
9987
+ const msg = unwrapApiError(err);
9810
9988
  return errorResult(`grep_files failed: ${msg}`);
9811
9989
  }
9812
9990
  }
@@ -9837,7 +10015,7 @@ server.tool(
9837
10015
  ${res.files.join("\n") || "(none)"}` }
9838
10016
  );
9839
10017
  } catch (err) {
9840
- const msg = err instanceof Error ? err.message : String(err);
10018
+ const msg = unwrapApiError(err);
9841
10019
  return errorResult(`find_files failed: ${msg}`);
9842
10020
  }
9843
10021
  }
@@ -9872,7 +10050,7 @@ health ${res.review.health}/10 \u2014 ${res.review.healthReason} (${tail})`;
9872
10050
  return { content: [{ type: "text", text: `${head}${summary}${health}
9873
10051
  ${body}` }] };
9874
10052
  } catch (err) {
9875
- const msg = err instanceof Error ? err.message : String(err);
10053
+ const msg = unwrapApiError(err);
9876
10054
  return {
9877
10055
  content: [{ type: "text", text: `outline_file failed: ${msg}` }],
9878
10056
  isError: true
@@ -9890,13 +10068,29 @@ server.tool(
9890
10068
  try {
9891
10069
  const res = await api.toolFileReview(projectId, args);
9892
10070
  if (!res.found || !res.review) {
10071
+ if (res.trackedIssues?.length) {
10072
+ const tracked = res.trackedIssues.map(
10073
+ (issue) => `${issue.ref} [${issue.status}]${issue.stale ? " [needs recheck]" : ""} ${issue.category} \u2014 ${issue.message}${issue.line ? ` (${issue.stale ? "previously " : ""}L${issue.line})` : ""}${issue.taskRef ? ` \u2014 task ${issue.taskRef}` : ""}`
10074
+ );
10075
+ return {
10076
+ content: [
10077
+ {
10078
+ type: "text",
10079
+ text: `${res.path} has no current review, but its durable tracked issues remain:
10080
+ ${tracked.join("\n")}`
10081
+ }
10082
+ ]
10083
+ };
10084
+ }
9893
10085
  const why = res.eligible === false ? "this file type is not reviewed (no rubric covers its kind \u2014 e.g. data files, caches, media)" : res.pending ? "the boekwachter has not reviewed this file yet (it studies files when idle or during Night Shift)" : "file is not in the index";
9894
10086
  return {
9895
10087
  content: [{ type: "text", text: `file_review: no review \u2014 ${why}.` }]
9896
10088
  };
9897
10089
  }
9898
10090
  const r = res.review;
9899
- const issues = r.issues.map(
10091
+ const issues = res.trackedIssues?.length ? res.trackedIssues.map(
10092
+ (i) => `${i.ref} [${i.status}]${i.stale ? " [needs recheck]" : ""} [${i.severity}] ${i.category} \u2014 ${i.message}${i.line ? ` (${i.stale ? "previously " : ""}L${i.line})` : ""}${i.taskRef ? ` \u2014 task ${i.taskRef}` : ""}`
10093
+ ) : r.issues.map(
9900
10094
  (i) => `[${i.severity}] ${i.category} \u2014 ${i.message}${i.line ? ` (L${i.line})` : ""}`
9901
10095
  );
9902
10096
  const provenance = formatReviewProvenance(r);
@@ -9911,7 +10105,7 @@ ${issues.join("\n")}` : "issues: none",
9911
10105
  ].join("\n");
9912
10106
  return { content: [{ type: "text", text }] };
9913
10107
  } catch (err) {
9914
- const msg = err instanceof Error ? err.message : String(err);
10108
+ const msg = unwrapApiError(err);
9915
10109
  return {
9916
10110
  content: [{ type: "text", text: `file_review failed: ${msg}` }],
9917
10111
  isError: true
@@ -9919,6 +10113,66 @@ ${issues.join("\n")}` : "issues: none",
9919
10113
  }
9920
10114
  }
9921
10115
  );
10116
+ server.tool(
10117
+ "get_file_issue",
10118
+ "Retrieve the durable metadata for one Boekwachter issue by its BW reference: path, previous/current line state, lifecycle, read state, and linked task. Use this when a prompt or task mentions BW-N.",
10119
+ {
10120
+ ref: z5.string().regex(/^BW-[1-9]\d*$/).describe("Project-scoped reference, e.g. BW-17.")
10121
+ },
10122
+ async (args) => {
10123
+ try {
10124
+ const { issue } = await api.getBoekwachterIssue(projectId, args);
10125
+ const location = issue.line ? `${issue.path}:${issue.line}${issue.stale ? " (previous anchor; needs recheck)" : ""}` : issue.path;
10126
+ return {
10127
+ content: [
10128
+ {
10129
+ type: "text",
10130
+ text: [
10131
+ `${issue.ref} \u2014 ${issue.status} \u2014 ${location}`,
10132
+ `[${issue.severity}] ${issue.category} \u2014 ${issue.message}`,
10133
+ `read: ${issue.seen ? "yes" : "no"}${issue.taskRef ? ` \u2014 task: ${issue.taskRef}` : ""}`
10134
+ ].join("\n")
10135
+ }
10136
+ ]
10137
+ };
10138
+ } catch (err) {
10139
+ const msg = unwrapApiError(err);
10140
+ return {
10141
+ content: [{ type: "text", text: `get_file_issue failed: ${msg}` }],
10142
+ isError: true
10143
+ };
10144
+ }
10145
+ }
10146
+ );
10147
+ server.tool(
10148
+ "set_file_issue_status",
10149
+ "Update a tracked Boekwachter issue by BW reference. Read/unread is independent of lifecycle. Use dismissed + not_an_issue only after verifying that the review lead is invalid; task completion normally resolves issues automatically.",
10150
+ {
10151
+ ref: z5.string().regex(/^BW-[1-9]\d*$/).describe("Project-scoped reference, e.g. BW-17."),
10152
+ status: z5.enum(["open", "in_progress", "resolved", "dismissed"]).optional(),
10153
+ seen: z5.boolean().optional().describe("true marks read; false marks unread."),
10154
+ dismissalReason: z5.enum(["not_an_issue", "duplicate", "wont_fix"]).optional()
10155
+ },
10156
+ async (args) => {
10157
+ try {
10158
+ const { issue } = await api.updateBoekwachterIssue(projectId, args);
10159
+ return {
10160
+ content: [
10161
+ {
10162
+ type: "text",
10163
+ text: `${issue.ref} is ${issue.status} and ${issue.seen ? "read" : "unread"}${issue.taskRef ? ` (task ${issue.taskRef})` : ""}.`
10164
+ }
10165
+ ]
10166
+ };
10167
+ } catch (err) {
10168
+ const msg = unwrapApiError(err);
10169
+ return {
10170
+ content: [{ type: "text", text: `set_file_issue_status failed: ${msg}` }],
10171
+ isError: true
10172
+ };
10173
+ }
10174
+ }
10175
+ );
9922
10176
  server.tool(
9923
10177
  "find_symbol",
9924
10178
  "Find where a function/class/type is DEFINED across the workspace (go-to-definition). Returns path + lineStart/lineEnd; follow with read_symbol or read_file({path,startLine:lineStart,endLine:lineEnd}). Use this instead of grepping for a definition.",
@@ -9944,7 +10198,7 @@ ${lines.join("\n") || "(none \u2014 index may still be building)"}`
9944
10198
  ]
9945
10199
  };
9946
10200
  } catch (err) {
9947
- const msg = err instanceof Error ? err.message : String(err);
10201
+ const msg = unwrapApiError(err);
9948
10202
  return {
9949
10203
  content: [{ type: "text", text: `find_symbol failed: ${msg}` }],
9950
10204
  isError: true
@@ -9972,7 +10226,7 @@ server.tool(
9972
10226
  ---
9973
10227
  ${res.source ?? ""}` }] };
9974
10228
  } catch (err) {
9975
- const msg = err instanceof Error ? err.message : String(err);
10229
+ const msg = unwrapApiError(err);
9976
10230
  return {
9977
10231
  content: [{ type: "text", text: `read_symbol failed: ${msg}` }],
9978
10232
  isError: true
@@ -10000,7 +10254,7 @@ ${lines.join("\n") || "(no references)"}` }
10000
10254
  ]
10001
10255
  };
10002
10256
  } catch (err) {
10003
- const msg = err instanceof Error ? err.message : String(err);
10257
+ const msg = unwrapApiError(err);
10004
10258
  return {
10005
10259
  content: [{ type: "text", text: `find_references failed: ${msg}` }],
10006
10260
  isError: true
@@ -10041,7 +10295,7 @@ server.tool(
10041
10295
  ].join("\n");
10042
10296
  return { content: [{ type: "text", text }] };
10043
10297
  } catch (err) {
10044
- const msg = err instanceof Error ? err.message : String(err);
10298
+ const msg = unwrapApiError(err);
10045
10299
  return {
10046
10300
  content: [{ type: "text", text: `map_repo failed: ${msg}` }],
10047
10301
  isError: true
@@ -10081,7 +10335,7 @@ ${lines.join("\n") || "(no results \u2014 index may still be enriching; use grep
10081
10335
  }
10082
10336
  );
10083
10337
  } catch (err) {
10084
- const msg = err instanceof Error ? err.message : String(err);
10338
+ const msg = unwrapApiError(err);
10085
10339
  return errorResult(`search_code failed: ${msg}`);
10086
10340
  }
10087
10341
  }
@@ -10111,7 +10365,7 @@ server.tool(
10111
10365
  ].join("\n");
10112
10366
  return { content: [{ type: "text", text }] };
10113
10367
  } catch (err) {
10114
- const msg = err instanceof Error ? err.message : String(err);
10368
+ const msg = unwrapApiError(err);
10115
10369
  return {
10116
10370
  content: [{ type: "text", text: `security_scan failed: ${msg}` }],
10117
10371
  isError: true
@@ -10146,7 +10400,7 @@ ${themes || " (none recurring across \u22653 files)"}`
10146
10400
  ].join("\n");
10147
10401
  return { content: [{ type: "text", text }] };
10148
10402
  } catch (err) {
10149
- const msg = err instanceof Error ? err.message : String(err);
10403
+ const msg = unwrapApiError(err);
10150
10404
  return {
10151
10405
  content: [{ type: "text", text: `security_overview failed: ${msg}` }],
10152
10406
  isError: true
@@ -10183,7 +10437,7 @@ ${lines.join("\n") || "(none matched)"}` }
10183
10437
  ]
10184
10438
  };
10185
10439
  } catch (err) {
10186
- const msg = err instanceof Error ? err.message : String(err);
10440
+ const msg = unwrapApiError(err);
10187
10441
  return {
10188
10442
  content: [{ type: "text", text: `scan_findings failed: ${msg}` }],
10189
10443
  isError: true
@@ -10198,19 +10452,21 @@ server.tool(
10198
10452
  severity: z5.enum(["info", "minor", "major"]).optional(),
10199
10453
  category: z5.string().optional().describe("e.g. bug, smell, error-handling, grammar, clarity."),
10200
10454
  path: z5.string().optional().describe("Restrict to a path prefix."),
10455
+ status: z5.enum(["open", "in_progress", "resolved", "dismissed"]).optional(),
10456
+ includeClosed: z5.boolean().optional().describe("Include resolved and dismissed history."),
10201
10457
  maxResults: z5.number().int().positive().max(1e3).optional()
10202
10458
  },
10203
10459
  async (args) => {
10204
10460
  try {
10205
10461
  const res = await api.toolListFileIssues(projectId, args);
10206
- if (!res.indexed) {
10462
+ if (!res.indexed && res.counts.total === 0) {
10207
10463
  return {
10208
10464
  content: [{ type: "text", text: "list_file_issues: index not built yet." }]
10209
10465
  };
10210
10466
  }
10211
10467
  const head = `${res.counts.total} issue${res.counts.total === 1 ? "" : "s"} across ${res.reviewedFiles}/${res.eligibleFiles} reviewed files${res.truncated ? " (truncated)" : ""}`;
10212
10468
  const lines = res.issues.map(
10213
- (i) => `${i.path}${i.line ? `:${i.line}` : ""} [${i.severity}] ${i.category} \u2014 ${i.message}`
10469
+ (i) => `${i.ref} ${i.path}${i.line ? `:${i.line}${i.stale ? " (previous)" : ""}` : ""} [${i.status}]${i.stale ? " [needs recheck]" : ""} [${i.severity}] ${i.category} \u2014 ${i.message}${i.taskRef ? ` \u2014 task ${i.taskRef}` : ""}`
10214
10470
  );
10215
10471
  const tail = res.reviewedFiles < res.eligibleFiles ? "\n(review sweep still in progress \u2014 coverage grows when the machine is idle or during Night Shift)" : "";
10216
10472
  const reviewers = (res.reviewers ?? []).filter((r) => r.model).map(
@@ -10228,7 +10484,7 @@ ${lines.join("\n") || "(none matched)"}${reviewerLine}${tail}`
10228
10484
  ]
10229
10485
  };
10230
10486
  } catch (err) {
10231
- const msg = err instanceof Error ? err.message : String(err);
10487
+ const msg = unwrapApiError(err);
10232
10488
  return {
10233
10489
  content: [{ type: "text", text: `list_file_issues failed: ${msg}` }],
10234
10490
  isError: true
@@ -10258,7 +10514,7 @@ server.tool(
10258
10514
  ].join("\n");
10259
10515
  return { content: [{ type: "text", text }] };
10260
10516
  } catch (err) {
10261
- const msg = err instanceof Error ? err.message : String(err);
10517
+ const msg = unwrapApiError(err);
10262
10518
  return {
10263
10519
  content: [{ type: "text", text: `map_attack_surface failed: ${msg}` }],
10264
10520
  isError: true
@@ -10292,7 +10548,7 @@ server.tool(
10292
10548
  ${lines.join("\n") || "(none)"}` }]
10293
10549
  };
10294
10550
  } catch (err) {
10295
- const msg = err instanceof Error ? err.message : String(err);
10551
+ const msg = unwrapApiError(err);
10296
10552
  return {
10297
10553
  content: [{ type: "text", text: `list_dependencies failed: ${msg}` }],
10298
10554
  isError: true
@@ -10327,7 +10583,7 @@ ${fmt(res.sinks)}`
10327
10583
  ].join("\n");
10328
10584
  return { content: [{ type: "text", text }] };
10329
10585
  } catch (err) {
10330
- const msg = err instanceof Error ? err.message : String(err);
10586
+ const msg = unwrapApiError(err);
10331
10587
  return {
10332
10588
  content: [{ type: "text", text: `trace_taint failed: ${msg}` }],
10333
10589
  isError: true
@@ -10354,7 +10610,7 @@ server.tool(
10354
10610
  ${lines.join("\n") || "(none)"}` }]
10355
10611
  };
10356
10612
  } catch (err) {
10357
- const msg = err instanceof Error ? err.message : String(err);
10613
+ const msg = unwrapApiError(err);
10358
10614
  return {
10359
10615
  content: [{ type: "text", text: `search_images failed: ${msg}` }],
10360
10616
  isError: true
@@ -10393,7 +10649,7 @@ ${lines.join("\n") || "(none)"}`
10393
10649
  ]
10394
10650
  };
10395
10651
  } catch (err) {
10396
- const msg = err instanceof Error ? err.message : String(err);
10652
+ const msg = unwrapApiError(err);
10397
10653
  return {
10398
10654
  content: [{ type: "text", text: `find_similar_images failed: ${msg}` }],
10399
10655
  isError: true
@@ -10420,7 +10676,7 @@ server.tool(
10420
10676
  ].join("\n");
10421
10677
  return { content: [{ type: "text", text }] };
10422
10678
  } catch (err) {
10423
- const msg = err instanceof Error ? err.message : String(err);
10679
+ const msg = unwrapApiError(err);
10424
10680
  return {
10425
10681
  content: [{ type: "text", text: `describe_folder failed: ${msg}` }],
10426
10682
  isError: true
@@ -10450,7 +10706,7 @@ ${lines.join("\n") || "(none \u2014 index may have no structured metadata yet)"}
10450
10706
  ]
10451
10707
  };
10452
10708
  } catch (err) {
10453
- const msg = err instanceof Error ? err.message : String(err);
10709
+ const msg = unwrapApiError(err);
10454
10710
  return {
10455
10711
  content: [{ type: "text", text: `find_entity failed: ${msg}` }],
10456
10712
  isError: true
@@ -10483,7 +10739,7 @@ server.tool(
10483
10739
  return { content: [{ type: "text", text: `${head}
10484
10740
  ${lines.join("\n")}` }] };
10485
10741
  } catch (err) {
10486
- const msg = err instanceof Error ? err.message : String(err);
10742
+ const msg = unwrapApiError(err);
10487
10743
  return {
10488
10744
  content: [{ type: "text", text: `list_entity_mentions failed: ${msg}` }],
10489
10745
  isError: true
@@ -10510,7 +10766,7 @@ ${lines.join("\n") || "(no matches)"}` }
10510
10766
  ]
10511
10767
  };
10512
10768
  } catch (err) {
10513
- const msg = err instanceof Error ? err.message : String(err);
10769
+ const msg = unwrapApiError(err);
10514
10770
  return {
10515
10771
  content: [{ type: "text", text: `search_docs failed: ${msg}` }],
10516
10772
  isError: true
@@ -10538,7 +10794,7 @@ server.tool(
10538
10794
  ---
10539
10795
  ${res.markdown ?? ""}` }] };
10540
10796
  } catch (err) {
10541
- const msg = err instanceof Error ? err.message : String(err);
10797
+ const msg = unwrapApiError(err);
10542
10798
  return {
10543
10799
  content: [{ type: "text", text: `read_doc_as_markdown failed: ${msg}` }],
10544
10800
  isError: true
@@ -10575,7 +10831,7 @@ server.tool(
10575
10831
  }
10576
10832
  return { content: [{ type: "text", text: res.diff }] };
10577
10833
  } catch (err) {
10578
- const msg = err instanceof Error ? err.message : String(err);
10834
+ const msg = unwrapApiError(err);
10579
10835
  return {
10580
10836
  content: [{ type: "text", text: `diff_files failed: ${msg}` }],
10581
10837
  isError: true
@@ -10603,7 +10859,7 @@ server.tool(
10603
10859
  ]
10604
10860
  };
10605
10861
  } catch (err) {
10606
- const msg = err instanceof Error ? err.message : String(err);
10862
+ const msg = unwrapApiError(err);
10607
10863
  return {
10608
10864
  content: [{ type: "text", text: `read_image_as_base64 failed: ${msg}` }],
10609
10865
  isError: true
@@ -10652,7 +10908,7 @@ server.tool(
10652
10908
  }
10653
10909
  return { content: [{ type: "text", text: parts.join("\n") }] };
10654
10910
  } catch (err) {
10655
- const msg = err instanceof Error ? err.message : String(err);
10911
+ const msg = unwrapApiError(err);
10656
10912
  return {
10657
10913
  content: [{ type: "text", text: `describe_image failed: ${msg}` }],
10658
10914
  isError: true
@@ -10701,7 +10957,7 @@ server.tool(
10701
10957
  }
10702
10958
  return { content: [{ type: "text", text: lines.join("\n") }] };
10703
10959
  } catch (err) {
10704
- const msg = err instanceof Error ? err.message : String(err);
10960
+ const msg = unwrapApiError(err);
10705
10961
  return {
10706
10962
  content: [{ type: "text", text: `read_image_metadata failed: ${msg}` }],
10707
10963
  isError: true
@@ -10726,7 +10982,7 @@ server.tool(
10726
10982
  return { content: [{ type: "text", text: `${header}
10727
10983
  ${lines.join("\n")}` }] };
10728
10984
  } catch (err) {
10729
- const msg = err instanceof Error ? err.message : String(err);
10985
+ const msg = unwrapApiError(err);
10730
10986
  return {
10731
10987
  content: [{ type: "text", text: `list_archive failed: ${msg}` }],
10732
10988
  isError: true
@@ -10736,7 +10992,7 @@ ${lines.join("\n")}` }] };
10736
10992
  );
10737
10993
  server.tool(
10738
10994
  "extract_archive",
10739
- "Extract a `.zip`, `.tar`, or `.tar.gz` archive into a directory inside the project workspace. Destination is created if it does not exist. Requires the workspace to be writable (internal workspace or `project.allowGezelWrites` on external).",
10995
+ "Extract a `.zip`, `.tar`, or `.tar.gz` archive into a directory inside the project workspace. Destination is created if it does not exist. Requires Gezel-managed workspace writes to be allowed.",
10740
10996
  {
10741
10997
  path: z5.string().min(1),
10742
10998
  outputPath: z5.string().min(1)
@@ -10753,7 +11009,7 @@ server.tool(
10753
11009
  ]
10754
11010
  };
10755
11011
  } catch (err) {
10756
- const msg = err instanceof Error ? err.message : String(err);
11012
+ const msg = unwrapApiError(err);
10757
11013
  return {
10758
11014
  content: [{ type: "text", text: `extract_archive failed: ${msg}` }],
10759
11015
  isError: true
@@ -10807,7 +11063,7 @@ ${res.stderr}` : ""}`;
10807
11063
  { text }
10808
11064
  );
10809
11065
  } catch (err) {
10810
- const msg = err instanceof Error ? err.message : String(err);
11066
+ const msg = unwrapApiError(err);
10811
11067
  return errorResult(`run_git failed: ${msg}`);
10812
11068
  }
10813
11069
  }
@@ -10882,7 +11138,7 @@ server.tool(
10882
11138
  });
10883
11139
  return formatScriptRunResult(res);
10884
11140
  } catch (err) {
10885
- const msg = err instanceof Error ? err.message : String(err);
11141
+ const msg = unwrapApiError(err);
10886
11142
  return errorResult(`run_installed_script failed: ${msg}`);
10887
11143
  }
10888
11144
  }
@@ -10915,7 +11171,7 @@ server.tool(
10915
11171
  ${JSON.stringify(run, null, 2)}` }
10916
11172
  );
10917
11173
  } catch (err) {
10918
- const msg = err instanceof Error ? err.message : String(err);
11174
+ const msg = unwrapApiError(err);
10919
11175
  return errorResult(`get_script_run failed: ${msg}`);
10920
11176
  }
10921
11177
  }
@@ -10949,7 +11205,7 @@ server.tool(
10949
11205
  });
10950
11206
  return { content: [{ type: "text", text: lines.join("\n\n") }] };
10951
11207
  } catch (err) {
10952
- const msg = err instanceof Error ? err.message : String(err);
11208
+ const msg = unwrapApiError(err);
10953
11209
  return {
10954
11210
  content: [{ type: "text", text: `github_pr_list failed: ${msg}` }],
10955
11211
  isError: true
@@ -10980,7 +11236,7 @@ server.tool(
10980
11236
  ];
10981
11237
  return { content: [{ type: "text", text: lines.join("\n") }] };
10982
11238
  } catch (err) {
10983
- const msg = err instanceof Error ? err.message : String(err);
11239
+ const msg = unwrapApiError(err);
10984
11240
  return {
10985
11241
  content: [{ type: "text", text: `github_pr_view failed: ${msg}` }],
10986
11242
  isError: true
@@ -11011,7 +11267,7 @@ ${f.patch}
11011
11267
  });
11012
11268
  return { content: [{ type: "text", text: blocks.join("\n\n") }] };
11013
11269
  } catch (err) {
11014
- const msg = err instanceof Error ? err.message : String(err);
11270
+ const msg = unwrapApiError(err);
11015
11271
  return {
11016
11272
  content: [{ type: "text", text: `github_pr_files failed: ${msg}` }],
11017
11273
  isError: true
@@ -11032,7 +11288,7 @@ server.tool(
11032
11288
  const res = await api.getProjectGitHubPullDiff(resolved, number);
11033
11289
  return { content: [{ type: "text", text: res.diff || "(empty diff)" }] };
11034
11290
  } catch (err) {
11035
- const msg = err instanceof Error ? err.message : String(err);
11291
+ const msg = unwrapApiError(err);
11036
11292
  return {
11037
11293
  content: [{ type: "text", text: `github_pr_diff failed: ${msg}` }],
11038
11294
  isError: true
@@ -11061,7 +11317,7 @@ ${c.body}`;
11061
11317
  });
11062
11318
  return { content: [{ type: "text", text: lines.join("\n\n---\n\n") }] };
11063
11319
  } catch (err) {
11064
- const msg = err instanceof Error ? err.message : String(err);
11320
+ const msg = unwrapApiError(err);
11065
11321
  return {
11066
11322
  content: [{ type: "text", text: `github_pr_comments failed: ${msg}` }],
11067
11323
  isError: true
@@ -11085,7 +11341,7 @@ server.tool(
11085
11341
  content: [{ type: "text", text: `Posted comment ${res.id} \u2014 ${res.url}` }]
11086
11342
  };
11087
11343
  } catch (err) {
11088
- const msg = err instanceof Error ? err.message : String(err);
11344
+ const msg = unwrapApiError(err);
11089
11345
  return {
11090
11346
  content: [{ type: "text", text: `github_pr_comment failed: ${msg}` }],
11091
11347
  isError: true
@@ -11118,7 +11374,7 @@ server.tool(
11118
11374
  content: [{ type: "text", text: `Opened PR #${res.number} \u2014 ${res.url}` }]
11119
11375
  };
11120
11376
  } catch (err) {
11121
- const msg = err instanceof Error ? err.message : String(err);
11377
+ const msg = unwrapApiError(err);
11122
11378
  return {
11123
11379
  content: [{ type: "text", text: `github_pr_create failed: ${msg}` }],
11124
11380
  isError: true
@@ -11149,7 +11405,7 @@ server.tool(
11149
11405
  );
11150
11406
  return { content: [{ type: "text", text: lines.join("\n\n") }] };
11151
11407
  } catch (err) {
11152
- const msg = err instanceof Error ? err.message : String(err);
11408
+ const msg = unwrapApiError(err);
11153
11409
  return {
11154
11410
  content: [{ type: "text", text: `github_workflow_runs failed: ${msg}` }],
11155
11411
  isError: true
@@ -11182,7 +11438,7 @@ No checks reported for ${ref}.` }]
11182
11438
  return { content: [{ type: "text", text: `${header}
11183
11439
  ${lines.join("\n")}` }] };
11184
11440
  } catch (err) {
11185
- const msg = err instanceof Error ? err.message : String(err);
11441
+ const msg = unwrapApiError(err);
11186
11442
  return {
11187
11443
  content: [{ type: "text", text: `github_check_status failed: ${msg}` }],
11188
11444
  isError: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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.0",
59
- "@bendyline/gezel-client": "1.0.0",
58
+ "@bendyline/gezel": "1.0.2",
59
+ "@bendyline/gezel-client": "1.0.2",
60
60
  "@modelcontextprotocol/sdk": "^1.29.0",
61
61
  "typescript": "^6.0.3",
62
62
  "zod": "^4.4.3"