@bendyline/gezel-mcp 1.2.3 → 1.2.4
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/server.js +325 -44
- package/package.json +3 -3
package/dist/server.js
CHANGED
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
WriteTaskNoteInputSchema,
|
|
42
42
|
findGezelInRoster,
|
|
43
43
|
findProjectByReference,
|
|
44
|
+
formatMediaClock,
|
|
44
45
|
gezelNotFoundMessage,
|
|
45
46
|
gezelRosterHint,
|
|
46
47
|
normalizeArtifactPath,
|
|
@@ -59,6 +60,7 @@ import {
|
|
|
59
60
|
NpmPackageNameSchema,
|
|
60
61
|
NpmRegistryVersionSchema,
|
|
61
62
|
ProviderNameSchema,
|
|
63
|
+
RETRIEVAL_SOURCES,
|
|
62
64
|
StepGateUnionSchema,
|
|
63
65
|
addGezelToProjectText,
|
|
64
66
|
advanceGateFailureText,
|
|
@@ -114,6 +116,7 @@ import {
|
|
|
114
116
|
taskOwnedPrefixes,
|
|
115
117
|
taskScopedWriteDeniedMessage,
|
|
116
118
|
uniqueStepId,
|
|
119
|
+
unknownTaskStepText,
|
|
117
120
|
workspaceDrawerPrefix,
|
|
118
121
|
writeTaskNoteText
|
|
119
122
|
} from "@bendyline/gezel";
|
|
@@ -365,7 +368,11 @@ function inferCraftbookJobParams(args) {
|
|
|
365
368
|
});
|
|
366
369
|
}
|
|
367
370
|
function suggestedCraftbookInvocation(args) {
|
|
368
|
-
const
|
|
371
|
+
const query = args.query.trim();
|
|
372
|
+
const userRequest = args.jobDescription?.trim();
|
|
373
|
+
const description = userRequest && userRequest !== query ? `${userRequest}
|
|
374
|
+
|
|
375
|
+
Task context from craftbook search: ${query}` : query;
|
|
369
376
|
const params = inferCraftbookJobParams({
|
|
370
377
|
paramSchema: args.paramSchema,
|
|
371
378
|
jobDescription: description
|
|
@@ -373,9 +380,23 @@ function suggestedCraftbookInvocation(args) {
|
|
|
373
380
|
return {
|
|
374
381
|
craftbookId: args.craftbookId,
|
|
375
382
|
description,
|
|
383
|
+
...args.project ? { project: args.project } : {},
|
|
376
384
|
...Object.keys(params).length > 0 ? { params } : {}
|
|
377
385
|
};
|
|
378
386
|
}
|
|
387
|
+
function craftbookSuggestionGuidance(invocation) {
|
|
388
|
+
const { project: searchProject, ...recipe } = invocation;
|
|
389
|
+
return [
|
|
390
|
+
"Compare these candidates with the full user request; choose a lower match or reject all of them if none fits.",
|
|
391
|
+
"Preserve the requested project: for a new project, use start_project; for an existing project, pass its id explicitly.",
|
|
392
|
+
"Keep the full task brief, deliverable destination, and acceptance criteria. If no candidate fits, use a generic build-loop task in the requested project.",
|
|
393
|
+
`
|
|
394
|
+
|
|
395
|
+
Candidate recipe details (not a launch call): ${JSON.stringify(recipe)}`,
|
|
396
|
+
`${searchProject ? `Search scope: ${JSON.stringify(searchProject)}. ` : ""}The search scope does not select a destination. Resolve the destination from the user request before launching; never copy the search scope into a launch call by default.`,
|
|
397
|
+
"Invocation installs exact trusted zero-configuration bundled dependencies; remaining setup blocks task creation."
|
|
398
|
+
].join(" ");
|
|
399
|
+
}
|
|
379
400
|
function normalizeCraftbookInvocationParams(params, outputPath) {
|
|
380
401
|
const merged = {
|
|
381
402
|
...params ?? {},
|
|
@@ -604,11 +625,11 @@ var GitToolOutputSchema = ExecutionToolOutputSchema.extend({
|
|
|
604
625
|
});
|
|
605
626
|
var MemorySaveToolOutputSchema = ToolResultSummarySchema.extend({
|
|
606
627
|
status: z2.enum(["saved", "duplicate"]),
|
|
607
|
-
scope: z2.enum(["gezel", "project"]),
|
|
628
|
+
scope: z2.enum(["gezel", "project", "user"]),
|
|
608
629
|
indexed: z2.boolean().optional()
|
|
609
630
|
});
|
|
610
631
|
var MemoryListToolOutputSchema = ToolResultSummarySchema.extend({
|
|
611
|
-
scope: z2.enum(["gezel", "project"]),
|
|
632
|
+
scope: z2.enum(["gezel", "project", "user"]),
|
|
612
633
|
days: z2.number().int().positive(),
|
|
613
634
|
content: z2.string()
|
|
614
635
|
});
|
|
@@ -821,6 +842,8 @@ var READ_ONLY_TOOLS = /* @__PURE__ */ new Set([
|
|
|
821
842
|
"search_images",
|
|
822
843
|
"find_similar_images",
|
|
823
844
|
"describe_folder",
|
|
845
|
+
"list_photos",
|
|
846
|
+
"photo_groups",
|
|
824
847
|
"find_entity",
|
|
825
848
|
"list_entity_mentions",
|
|
826
849
|
"list_archive",
|
|
@@ -1797,6 +1820,38 @@ function quantizeImageSize(size) {
|
|
|
1797
1820
|
return Math.max(SIZE_MULTIPLE, Math.min(AGENT_IMAGE_MAX_SIDE_PX, rounded));
|
|
1798
1821
|
}
|
|
1799
1822
|
|
|
1823
|
+
// src/installed-script-miss.ts
|
|
1824
|
+
var SCRIPT_DIRS = ["", "scripts/", "src/", "bin/", "tools/"];
|
|
1825
|
+
var SCRIPT_EXTS = [".mjs", ".js", ".ts", ".cjs"];
|
|
1826
|
+
function scriptFileCandidates(name) {
|
|
1827
|
+
const bare = name.trim();
|
|
1828
|
+
if (!/^[\w.-]+$/.test(bare)) return [];
|
|
1829
|
+
const stem = bare.replace(/\.(?:mjs|cjs|js|ts)$/i, "");
|
|
1830
|
+
return SCRIPT_DIRS.flatMap((dir) => SCRIPT_EXTS.map((ext) => `${dir}${stem}${ext}`));
|
|
1831
|
+
}
|
|
1832
|
+
function isPathShapedScriptName(name) {
|
|
1833
|
+
return /[/\\]/.test(name) || /\.(mjs|cjs|js|ts|py|sh)$/i.test(name);
|
|
1834
|
+
}
|
|
1835
|
+
function installedScriptMissHint(opts) {
|
|
1836
|
+
const { name, written, canRunFiles, canDerive, canWriteFiles = false } = opts;
|
|
1837
|
+
const file = written ?? (isPathShapedScriptName(name) ? name : void 0);
|
|
1838
|
+
const lead = isPathShapedScriptName(name) ? `"${name}" looks like a file path, but run_installed_script runs only scripts installed in the project (see list_scripts).` : written ? `"${name}" is not an installed script, but the project has \`${written}\`, a file you wrote.` : `run_installed_script only runs scripts installed in the project (see list_scripts), and "${name}" is not one.`;
|
|
1839
|
+
const steps = [];
|
|
1840
|
+
if (canRunFiles) {
|
|
1841
|
+
steps.push(
|
|
1842
|
+
file ? `Run that file with run_nodejs_script({ path: "${file}" }).` : "To run a script file you wrote, use run_nodejs_script({ path })."
|
|
1843
|
+
);
|
|
1844
|
+
}
|
|
1845
|
+
if (canDerive && !file) steps.push("To build a data file from other files, use derive_file.");
|
|
1846
|
+
if (canWriteFiles) {
|
|
1847
|
+
steps.push(
|
|
1848
|
+
canRunFiles ? "If run_nodejs_script is not in your tool list this turn, write the output file directly with write_file." : "Write the output file directly with write_file instead."
|
|
1849
|
+
);
|
|
1850
|
+
}
|
|
1851
|
+
const again = "Calling run_installed_script again with this name will fail the same way.";
|
|
1852
|
+
return [lead, ...steps, again].join(" ");
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1800
1855
|
// src/linked-workspace.ts
|
|
1801
1856
|
function isLinkedWorkspacePath(inputPath) {
|
|
1802
1857
|
const normalized = inputPath.replaceAll("\\", "/").replace(/\/{2,}/g, "/");
|
|
@@ -2686,6 +2741,9 @@ function staleTaskStepRefusal(err) {
|
|
|
2686
2741
|
const { error, hint } = details;
|
|
2687
2742
|
return error === "stale_task_step" && typeof hint === "string" && hint.trim() ? hint : null;
|
|
2688
2743
|
}
|
|
2744
|
+
function sessionReboundToCurrentPass(args) {
|
|
2745
|
+
return args.activeStepId === args.sessionStepId && !!args.activeStepActivation && args.sessionActivation === args.activeStepActivation;
|
|
2746
|
+
}
|
|
2689
2747
|
|
|
2690
2748
|
// src/validate.ts
|
|
2691
2749
|
import ts2 from "typescript";
|
|
@@ -3754,10 +3812,29 @@ var linkedApi = new GezelClient({ baseUrl, token, fetch: linkedFetchImpl });
|
|
|
3754
3812
|
var sessionStepCompleted = false;
|
|
3755
3813
|
var sessionStepCompletion = "unknown";
|
|
3756
3814
|
var sessionStepCheckedArtifacts = [];
|
|
3815
|
+
async function reboundToCurrentPass() {
|
|
3816
|
+
if (!sessionId) return false;
|
|
3817
|
+
try {
|
|
3818
|
+
const parsed = await parseRef(sessionTaskRef);
|
|
3819
|
+
const [task, session] = await Promise.all([
|
|
3820
|
+
api.getTask(parsed.projectId, parsed.num),
|
|
3821
|
+
api.getChatSession(sessionId)
|
|
3822
|
+
]);
|
|
3823
|
+
return sessionReboundToCurrentPass({
|
|
3824
|
+
sessionStepId,
|
|
3825
|
+
activeStepId: task.activeStepId,
|
|
3826
|
+
activeStepActivation: task.craftbook.steps.find((s) => s.id === task.activeStepId)?.lastActivatedAt,
|
|
3827
|
+
sessionActivation: session.stepActivationId
|
|
3828
|
+
});
|
|
3829
|
+
} catch {
|
|
3830
|
+
return false;
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3757
3833
|
async function staleStepMutationResult() {
|
|
3758
3834
|
if (!sessionTaskRef || !sessionStepId) return null;
|
|
3759
3835
|
sessionStepCompletion = "unknown";
|
|
3760
3836
|
sessionStepCheckedArtifacts = [];
|
|
3837
|
+
if (sessionStepCompleted && await reboundToCurrentPass()) sessionStepCompleted = false;
|
|
3761
3838
|
let activeStepId;
|
|
3762
3839
|
let activeStepOwnedBySession = false;
|
|
3763
3840
|
if (!sessionStepCompleted) {
|
|
@@ -3881,6 +3958,19 @@ function editClient(target) {
|
|
|
3881
3958
|
}
|
|
3882
3959
|
return draftEditApi(client, diffpackId);
|
|
3883
3960
|
}
|
|
3961
|
+
async function proposeDraftOperation(target, op) {
|
|
3962
|
+
if (target.kind === "linked") {
|
|
3963
|
+
throw new Error(
|
|
3964
|
+
`Cannot change ${target.displayPath} while drafting a change proposal \u2014 a proposal covers one project.`
|
|
3965
|
+
);
|
|
3966
|
+
}
|
|
3967
|
+
const res = await workspaceClient(target).proposeDiffpackDraftOperation(
|
|
3968
|
+
target.projectId,
|
|
3969
|
+
diffpackId,
|
|
3970
|
+
op
|
|
3971
|
+
);
|
|
3972
|
+
return res.message;
|
|
3973
|
+
}
|
|
3884
3974
|
async function readWorkspaceFile(path) {
|
|
3885
3975
|
const target = await concreteWorkspaceTarget(path);
|
|
3886
3976
|
const client = isDrafting && target.kind === "current" ? draftEditApi(workspaceClient(target), diffpackId) : workspaceClient(target);
|
|
@@ -4110,6 +4200,9 @@ server.tool(
|
|
|
4110
4200
|
}
|
|
4111
4201
|
}
|
|
4112
4202
|
);
|
|
4203
|
+
function memoryScopeId(scope) {
|
|
4204
|
+
return scope === "gezel" ? gezelId : scope === "project" ? projectId : "user";
|
|
4205
|
+
}
|
|
4113
4206
|
server.tool(
|
|
4114
4207
|
"save_memory",
|
|
4115
4208
|
GEZEL_TOOL_DESCRIPTIONS2.save_memory,
|
|
@@ -4124,9 +4217,10 @@ server.tool(
|
|
|
4124
4217
|
},
|
|
4125
4218
|
body: JSON.stringify({
|
|
4126
4219
|
scope,
|
|
4127
|
-
id: scope
|
|
4220
|
+
id: memoryScopeId(scope),
|
|
4128
4221
|
text: normalizeMarkdown(text),
|
|
4129
|
-
...kind ? { kind } : {}
|
|
4222
|
+
...kind ? { kind } : {},
|
|
4223
|
+
source: { project: projectId, gezel: gezelId }
|
|
4130
4224
|
})
|
|
4131
4225
|
});
|
|
4132
4226
|
if (!res.ok) {
|
|
@@ -4153,14 +4247,14 @@ server.tool(
|
|
|
4153
4247
|
);
|
|
4154
4248
|
server.tool(
|
|
4155
4249
|
"list_memories",
|
|
4156
|
-
"List recent memory entries
|
|
4250
|
+
"List recent memory entries: yours, the project\u2019s, or what you know about the person you work for.",
|
|
4157
4251
|
{
|
|
4158
|
-
scope: z5.enum(["gezel", "project"]).describe(
|
|
4252
|
+
scope: z5.enum(["gezel", "project", "user"]).describe('Which memory to list: "gezel" (yours), "project", or "user" (about the person)'),
|
|
4159
4253
|
days: z5.number().int().positive().optional().describe("How many days back to look (default 7)")
|
|
4160
4254
|
},
|
|
4161
4255
|
async ({ scope, days }) => {
|
|
4162
4256
|
try {
|
|
4163
|
-
const id = scope
|
|
4257
|
+
const id = memoryScopeId(scope);
|
|
4164
4258
|
const res = await fetchImpl(
|
|
4165
4259
|
`${baseUrl}/api/memory/recent?scope=${scope}&id=${encodeURIComponent(id)}&days=${days ?? 7}`,
|
|
4166
4260
|
{ headers: { Authorization: `Bearer ${token}` } }
|
|
@@ -5651,6 +5745,10 @@ server.tool(
|
|
|
5651
5745
|
if (scoped) return scoped;
|
|
5652
5746
|
try {
|
|
5653
5747
|
const target = await concreteWorkspaceTarget(path);
|
|
5748
|
+
if (isDrafting) {
|
|
5749
|
+
const proposed = await proposeDraftOperation(target, { op: "mkdir", to: target.path });
|
|
5750
|
+
return { content: [{ type: "text", text: proposed }] };
|
|
5751
|
+
}
|
|
5654
5752
|
await workspaceClient(target).mkdirProjectWorkspace(target.projectId, {
|
|
5655
5753
|
path: target.path,
|
|
5656
5754
|
...gezelId ? { gezelId } : {},
|
|
@@ -5689,6 +5787,14 @@ server.tool(
|
|
|
5689
5787
|
"rename cannot move files across project roots; read the source, write the destination, then delete the source explicitly"
|
|
5690
5788
|
);
|
|
5691
5789
|
}
|
|
5790
|
+
if (isDrafting) {
|
|
5791
|
+
const proposed = await proposeDraftOperation(fromTarget, {
|
|
5792
|
+
op: "move",
|
|
5793
|
+
from: fromTarget.path,
|
|
5794
|
+
to: toTarget.path
|
|
5795
|
+
});
|
|
5796
|
+
return { content: [{ type: "text", text: proposed }] };
|
|
5797
|
+
}
|
|
5692
5798
|
await workspaceClient(fromTarget).renameProjectWorkspacePath(fromTarget.projectId, {
|
|
5693
5799
|
fromPath: fromTarget.path,
|
|
5694
5800
|
toPath: toTarget.path,
|
|
@@ -5704,6 +5810,51 @@ server.tool(
|
|
|
5704
5810
|
}
|
|
5705
5811
|
}
|
|
5706
5812
|
);
|
|
5813
|
+
server.tool(
|
|
5814
|
+
"copy_path",
|
|
5815
|
+
"Copy a file or folder to a new path within the project with `copy_path({ fromPath, toPath })`. Never replaces an existing file: pick a destination nothing has.",
|
|
5816
|
+
{
|
|
5817
|
+
fromPath: z5.string().describe("The file or folder to copy, relative to the project root."),
|
|
5818
|
+
toPath: z5.string().describe("Where the copy goes, relative to the project root.")
|
|
5819
|
+
},
|
|
5820
|
+
async ({ fromPath, toPath }) => {
|
|
5821
|
+
const stale = await staleStepMutationResult();
|
|
5822
|
+
if (stale) return stale;
|
|
5823
|
+
const scoped = await taskScopedWriteRefusal(toPath, "workspace");
|
|
5824
|
+
if (scoped) return scoped;
|
|
5825
|
+
try {
|
|
5826
|
+
const [fromTarget, toTarget] = await Promise.all([
|
|
5827
|
+
concreteWorkspaceTarget(fromPath),
|
|
5828
|
+
concreteWorkspaceTarget(toPath)
|
|
5829
|
+
]);
|
|
5830
|
+
if (fromTarget.projectId !== toTarget.projectId) {
|
|
5831
|
+
throw new Error(
|
|
5832
|
+
"copy_path cannot copy across project roots; read the source and write the destination instead"
|
|
5833
|
+
);
|
|
5834
|
+
}
|
|
5835
|
+
if (isDrafting) {
|
|
5836
|
+
const proposed = await proposeDraftOperation(fromTarget, {
|
|
5837
|
+
op: "copy",
|
|
5838
|
+
from: fromTarget.path,
|
|
5839
|
+
to: toTarget.path
|
|
5840
|
+
});
|
|
5841
|
+
return { content: [{ type: "text", text: proposed }] };
|
|
5842
|
+
}
|
|
5843
|
+
await workspaceClient(fromTarget).copyProjectWorkspacePath(fromTarget.projectId, {
|
|
5844
|
+
fromPath: fromTarget.path,
|
|
5845
|
+
toPath: toTarget.path,
|
|
5846
|
+
...gezelId ? { gezelId } : {},
|
|
5847
|
+
...sessionId ? { sessionId } : {}
|
|
5848
|
+
});
|
|
5849
|
+
return { content: [{ type: "text", text: `Copied ${fromPath} \u2192 ${toPath}` }] };
|
|
5850
|
+
} catch (err) {
|
|
5851
|
+
return {
|
|
5852
|
+
content: [{ type: "text", text: explainWriteFailure(err) }],
|
|
5853
|
+
isError: true
|
|
5854
|
+
};
|
|
5855
|
+
}
|
|
5856
|
+
}
|
|
5857
|
+
);
|
|
5707
5858
|
server.tool(
|
|
5708
5859
|
"npm_install",
|
|
5709
5860
|
"Install one or more npm packages into the project workspace so you can `import` them from your scripts. Uses `pnpm add --ignore-scripts` under the hood. **ALWAYS BATCH**: list every package you need in a single `packages` array \u2014 each call that includes a package outside the pre-vetted list creates a user approval prompt, so calling this tool N times for N packages makes the user click N times. Common packages (zod, chalk, typescript, commander, date-fns, yaml, cheerio, marked, playwright-core, pino, tsx, undici, nanoid, mime-types) install immediately; unknown ones return `pending-approval` per package (all grouped into one question). When any package is pending, your turn ends; a follow-up message arrives once the user answers. Do NOT hallucinate package names \u2014 if you're not sure a package exists or does what you expect, ask the user first with `ask_user_question`.",
|
|
@@ -6737,7 +6888,7 @@ server.tool(
|
|
|
6737
6888
|
);
|
|
6738
6889
|
server.tool(
|
|
6739
6890
|
"run_playwright_script",
|
|
6740
|
-
"Run a Playwright script from the project's artifacts. **This is the main way gezels automate the browser.** The shape: call `write_artifact` to save a `.ts` file under `tests/` (test-runner mode, `*.spec.ts`) or `scripts/` (bare-script mode via Node's strip-types), then call this tool with the same path to run it. Use it for end-to-end tests, data extraction, multi-step automation, anything you'd want to re-run or tweak. The live `browser_navigate` / `browser_snapshot` tools exist too for quick interactive reads, but writing a short script and running it is usually the better shape \u2014 it leaves an artifact the team can build on.",
|
|
6891
|
+
"Run a Playwright script from the project's artifacts. **This is the main way gezels automate the browser.** The shape: call `write_artifact` to save a `.ts` file under `tests/` (test-runner mode, `*.spec.ts`) or `scripts/` (bare-script mode via Node's strip-types), then call this tool with the same path to run it. Use it for end-to-end tests, data extraction, multi-step automation, anything you'd want to re-run or tweak. The live `browser_navigate` / `browser_snapshot` tools exist too for quick interactive reads, but writing a short script and running it is usually the better shape \u2014 it leaves an artifact the team can build on. SECURITY: the script runs outside the script sandbox (it drives a real browser with network access), so the user approves each new or edited script before it runs; the approval covers that exact script and the local files it imports.",
|
|
6741
6892
|
{
|
|
6742
6893
|
path: z5.string().describe(
|
|
6743
6894
|
'Script path relative to the artifacts root, e.g. "tests/home.spec.ts" or "scripts/scrape.ts".'
|
|
@@ -6747,7 +6898,28 @@ server.tool(
|
|
|
6747
6898
|
)
|
|
6748
6899
|
},
|
|
6749
6900
|
async ({ path, mode }) => {
|
|
6750
|
-
const res = await api.runPlaywrightScript(projectId, {
|
|
6901
|
+
const res = await api.runPlaywrightScript(projectId, {
|
|
6902
|
+
path,
|
|
6903
|
+
...mode ? { mode } : {},
|
|
6904
|
+
...gezelId ? { gezelId } : {},
|
|
6905
|
+
...sessionId ? { sessionId } : {}
|
|
6906
|
+
});
|
|
6907
|
+
if (res.approvalPending) {
|
|
6908
|
+
const text2 = `Running ${path} needs user approval. Your turn ends here; a follow-up message arrives once the user answers. Don't retry in the meantime.`;
|
|
6909
|
+
return okResult(
|
|
6910
|
+
ExecutionToolOutputSchema,
|
|
6911
|
+
{
|
|
6912
|
+
summary: text2,
|
|
6913
|
+
state: "approval_pending",
|
|
6914
|
+
ok: false,
|
|
6915
|
+
approvalPending: true,
|
|
6916
|
+
...res.questionId ? { questionId: res.questionId } : {},
|
|
6917
|
+
output: { path, ...mode ? { mode } : {} }
|
|
6918
|
+
},
|
|
6919
|
+
{ text: text2 }
|
|
6920
|
+
);
|
|
6921
|
+
}
|
|
6922
|
+
if (res.declined) return errorResult(res.declined);
|
|
6751
6923
|
const heading = res.ok ? `\u2713 ${path} completed successfully.` : `\u2717 ${path} failed${res.error ? ` (${res.error})` : ""}.`;
|
|
6752
6924
|
const locallyTruncated = res.log.length > 3e4;
|
|
6753
6925
|
const tail = locallyTruncated ? res.log.slice(-3e4) : res.log;
|
|
@@ -7378,6 +7550,7 @@ async function launchCraftbookTask(args) {
|
|
|
7378
7550
|
...resolvedAssignee ? { assignee: resolvedAssignee } : {},
|
|
7379
7551
|
...args.craftbookInvocationKey ? { craftbookInvocationKey: args.craftbookInvocationKey } : {},
|
|
7380
7552
|
...gezelId ? { createdBy: { kind: "gezel", gezelId } } : {},
|
|
7553
|
+
...args.tonight ? { nightShift: { enabled: true } } : {},
|
|
7381
7554
|
dispatchEntry: true
|
|
7382
7555
|
});
|
|
7383
7556
|
return {
|
|
@@ -7470,7 +7643,7 @@ server.tool(
|
|
|
7470
7643
|
content: [
|
|
7471
7644
|
{
|
|
7472
7645
|
type: "text",
|
|
7473
|
-
text: 'No craftbook matched.
|
|
7646
|
+
text: 'No craftbook matched. Preserve the full user request and its destination: for a new project use start_project; for an existing project, invoke the generic "build-loop" procedure with that project id and the full task brief. Do not claim work started until the action call succeeds.'
|
|
7474
7647
|
}
|
|
7475
7648
|
]
|
|
7476
7649
|
};
|
|
@@ -7483,17 +7656,18 @@ server.tool(
|
|
|
7483
7656
|
return `${i + 1}. ${s.name} (id: ${s.id}) [${s.source}, ${s.stepCount} step(s), ${pct}% match]${setup}${desc}`;
|
|
7484
7657
|
}).join("\n");
|
|
7485
7658
|
const top = res.suggestions[0];
|
|
7486
|
-
const topMissing = projectCraftbooks?.missingToolsets[top.id] ?? [];
|
|
7487
7659
|
const topManifest = projectCraftbooks?.items.find(
|
|
7488
7660
|
(item) => item.manifest.kind === "craftbook-template" && item.manifest.id === top.id
|
|
7489
7661
|
);
|
|
7662
|
+
const rootTurn = await currentRootTurnContext();
|
|
7490
7663
|
const nextInvocation = suggestedCraftbookInvocation({
|
|
7491
7664
|
craftbookId: top.id,
|
|
7492
7665
|
query,
|
|
7666
|
+
jobDescription: rootTurn?.userText,
|
|
7667
|
+
project: resolvedProject,
|
|
7493
7668
|
paramSchema: topManifest?.manifest.kind === "craftbook-template" ? topManifest.manifest.paramSchema : void 0
|
|
7494
7669
|
});
|
|
7495
|
-
const
|
|
7496
|
-
const nextAction = topMissing.length > 0 ? `Next call: ${nextCall}. It will install any exact trusted zero-configuration bundled dependency; if setup still remains, it returns a hard error and creates no task. Preserve the supplied description and params; do not call suggest_craftbook again with a rephrased query, switch to a generic project/job kickoff, or delegate the job raw.` : `Next call: ${nextCall} \u2014 send it now unless a lower match clearly fits the job better. Preserve the supplied description and params; do not call suggest_craftbook again with a rephrased query, switch to a generic project/job kickoff, delegate the job raw, or hand-write task steps; the recipe's gated steps already handle assignment and quality checks.`;
|
|
7670
|
+
const nextAction = craftbookSuggestionGuidance(nextInvocation);
|
|
7497
7671
|
return {
|
|
7498
7672
|
content: [
|
|
7499
7673
|
{
|
|
@@ -7597,7 +7771,9 @@ server.tool(
|
|
|
7597
7771
|
"Spawn and dispatch a task from a craftbook template \u2014 the procedure-first shorthand for create_task with a craftbookId. Exact trusted zero-configuration bundled dependencies install automatically at project scope; other zero-configuration MCP dependencies request the user's approval in chat. Dependencies that need credentials/configuration return a hard SETUP REQUIRED error and create no task. Invocation params are carried into recipe placeholders such as {{outputPath}}. Returns the new task ref.",
|
|
7598
7772
|
{
|
|
7599
7773
|
craftbookId: z5.string().describe('Craftbook id from list_craftbooks (e.g. "pull-request-review", "ship").'),
|
|
7600
|
-
project: z5.string().optional().describe(
|
|
7774
|
+
project: z5.string().optional().describe(
|
|
7775
|
+
"Existing project id or name. Defaults to the current project; this tool does not create a new project. Use start_project when the user requests a new project."
|
|
7776
|
+
),
|
|
7601
7777
|
title: z5.string().optional().describe("Optional task title. Defaults to the craftbook name."),
|
|
7602
7778
|
description: z5.string().optional().describe(
|
|
7603
7779
|
"Optional task description \u2014 the job-to-be-done. Falls back to the craftbook description when omitted."
|
|
@@ -7607,9 +7783,22 @@ server.tool(
|
|
|
7607
7783
|
params: CraftbookInvocationParamsArgSchema,
|
|
7608
7784
|
outputPath: z5.string().optional().describe(
|
|
7609
7785
|
"Convenience alias for params.outputPath. Preserves the requested project-workspace filename for document-production craftbooks."
|
|
7786
|
+
),
|
|
7787
|
+
tonight: z5.boolean().optional().describe(
|
|
7788
|
+
"Run it in tonight's Night Shift instead of now. Use only when the user asks for it tonight or overnight."
|
|
7610
7789
|
)
|
|
7611
7790
|
},
|
|
7612
|
-
async ({
|
|
7791
|
+
async ({
|
|
7792
|
+
craftbookId,
|
|
7793
|
+
project,
|
|
7794
|
+
title,
|
|
7795
|
+
description,
|
|
7796
|
+
version,
|
|
7797
|
+
assignee,
|
|
7798
|
+
params,
|
|
7799
|
+
outputPath,
|
|
7800
|
+
tonight
|
|
7801
|
+
}) => {
|
|
7613
7802
|
const resolvedProject = project ? await resolveProjectId(project) : projectId;
|
|
7614
7803
|
try {
|
|
7615
7804
|
const rootTurn = await currentRootTurnContext();
|
|
@@ -7622,7 +7811,8 @@ server.tool(
|
|
|
7622
7811
|
description: effectiveDescription,
|
|
7623
7812
|
version,
|
|
7624
7813
|
assignee,
|
|
7625
|
-
params: invocationParams
|
|
7814
|
+
params: invocationParams,
|
|
7815
|
+
...tonight ? { tonight: true } : {}
|
|
7626
7816
|
};
|
|
7627
7817
|
const rootTurnId = rootTurn?.rootTurnId ?? null;
|
|
7628
7818
|
const launchInvocation = rootTurnId ? {
|
|
@@ -8885,6 +9075,7 @@ server.tool(
|
|
|
8885
9075
|
...effectiveTaskRef ? { taskRef: effectiveTaskRef } : {},
|
|
8886
9076
|
...documentPath ? { documentPath } : {}
|
|
8887
9077
|
});
|
|
9078
|
+
if (res.declined) return { content: [{ type: "text", text: res.declined }] };
|
|
8888
9079
|
const colleague = toolIsAuthorizedForThisSession("message_gezel") ? await questionColleague(body) : void 0;
|
|
8889
9080
|
return {
|
|
8890
9081
|
content: [
|
|
@@ -9967,6 +10158,9 @@ server.tool(
|
|
|
9967
10158
|
fanout: fanoutArg,
|
|
9968
10159
|
dispatch: z5.boolean().optional().describe(
|
|
9969
10160
|
"Hand the entry step to its assignee immediately as a task-scoped handoff (single-channel kickoff). Invalid on drafts and cron/fanout hosts."
|
|
10161
|
+
),
|
|
10162
|
+
tonight: z5.boolean().optional().describe(
|
|
10163
|
+
"Run it in tonight's Night Shift instead of now. Use only when the user asks for it tonight or overnight."
|
|
9970
10164
|
)
|
|
9971
10165
|
}).shape,
|
|
9972
10166
|
async ({
|
|
@@ -9984,12 +10178,14 @@ server.tool(
|
|
|
9984
10178
|
cron,
|
|
9985
10179
|
cronOverlap,
|
|
9986
10180
|
fanout,
|
|
9987
|
-
dispatch
|
|
10181
|
+
dispatch,
|
|
10182
|
+
tonight
|
|
9988
10183
|
}) => {
|
|
9989
10184
|
try {
|
|
9990
10185
|
const projectId2 = await resolveProjectId(project);
|
|
9991
10186
|
const resolvedAssignee = await resolveAssigneeArg(assignee);
|
|
9992
10187
|
const created = await api.createTask(projectId2, {
|
|
10188
|
+
...tonight ? { nightShift: { enabled: true } } : {},
|
|
9993
10189
|
...sessionTaskNamingMode,
|
|
9994
10190
|
title,
|
|
9995
10191
|
description,
|
|
@@ -10588,15 +10784,12 @@ async function explainAdvanceFailure(err, parsed, stepId, next) {
|
|
|
10588
10784
|
}
|
|
10589
10785
|
if (steps.length === 0) return base;
|
|
10590
10786
|
const ids = steps.map((s) => s.id);
|
|
10591
|
-
|
|
10592
|
-
if (next && next !== "next" && !ids.includes(next)) {
|
|
10593
|
-
return `${base}
|
|
10594
|
-
This task has no step "${next}". Its steps are: ${roster}. Pass one of those ids as \`next\`, or omit \`next\` to advance to the following step in order.`;
|
|
10595
|
-
}
|
|
10596
|
-
if (!ids.includes(stepId)) {
|
|
10787
|
+
if (next && next !== "next" && !ids.includes(next))
|
|
10597
10788
|
return `${base}
|
|
10598
|
-
|
|
10599
|
-
}
|
|
10789
|
+
${unknownTaskStepText("next", next, steps)}`;
|
|
10790
|
+
if (!ids.includes(stepId)) return `${base}
|
|
10791
|
+
${unknownTaskStepText("stepId", stepId, steps)}`;
|
|
10792
|
+
const roster = steps.map((s) => s.name ? `"${s.id}" (${s.name})` : `"${s.id}"`).join(", ");
|
|
10600
10793
|
return `${base}
|
|
10601
10794
|
The task's steps are: ${roster}.`;
|
|
10602
10795
|
}
|
|
@@ -11823,9 +12016,7 @@ server.tool(
|
|
|
11823
12016
|
catalogs: z5.array(KnowledgeIdSchema).optional().describe(
|
|
11824
12017
|
'Search only these knowledge catalogs. Implies sources: ["knowledge"] unless sources is given.'
|
|
11825
12018
|
),
|
|
11826
|
-
sources: z5.array(
|
|
11827
|
-
z5.enum(["workspace", "artifacts", "project-memory", "gezel-memory", "shared", "knowledge"])
|
|
11828
|
-
).optional().describe("Optional corpus filter. Omit to search all knowledge available to this project."),
|
|
12019
|
+
sources: z5.array(z5.enum(RETRIEVAL_SOURCES)).optional().describe("Optional corpus filter. Omit to search all knowledge available to this project."),
|
|
11829
12020
|
maxResults: z5.number().int().positive().max(100).optional().describe(
|
|
11830
12021
|
"Maximum results to request (default 30). The rendered text may show fewer when output is budgeted to the context window."
|
|
11831
12022
|
),
|
|
@@ -12197,18 +12388,21 @@ ${fmt(res.sinks)}`
|
|
|
12197
12388
|
);
|
|
12198
12389
|
server.tool(
|
|
12199
12390
|
"search_images",
|
|
12200
|
-
|
|
12391
|
+
'Find images in the workspace by what they show (e.g. "whiteboard with a sprint plan", "red bicycle"), or by filename or caption. Set kinds to also find moments in audio and video files. Returns paths with width/height/format, a caption when the index has one, and for audio/video the matching time window. Use describe_folder for a folder overview, find_similar_images for visual lookalikes.',
|
|
12201
12392
|
{
|
|
12202
|
-
query: z5.string().min(1).describe("
|
|
12203
|
-
maxResults: z5.number().int().positive().max(100).optional()
|
|
12393
|
+
query: z5.string().min(1).describe("What to find \u2014 a description of the content, or filename/caption words."),
|
|
12394
|
+
maxResults: z5.number().int().positive().max(100).optional(),
|
|
12395
|
+
kinds: z5.array(z5.enum(["image", "audio", "video"])).min(1).optional().describe('Media to search (default ["image"]).')
|
|
12204
12396
|
},
|
|
12205
12397
|
async (args) => {
|
|
12206
12398
|
try {
|
|
12207
12399
|
const res = await api.toolSearchImages(projectId, args);
|
|
12400
|
+
const clock = formatMediaClock;
|
|
12208
12401
|
const lines = res.results.map(
|
|
12209
|
-
(r) => `${r.path}${r.width ? ` (${r.width}x${r.height} ${r.format ?? ""})` : ""}${r.caption ? ` \u2014 ${r.caption}` : ""}`
|
|
12402
|
+
(r) => `${r.path}${r.kind && r.kind !== "image" ? ` [${r.kind}${r.startMs !== void 0 ? ` ${clock(r.startMs)}${r.endMs !== void 0 ? `\u2013${clock(r.endMs)}` : ""}` : ""}]` : ""}${r.width ? ` (${r.width}x${r.height} ${r.format ?? ""})` : ""}${r.caption ? ` \u2014 ${r.caption}` : ""}`
|
|
12210
12403
|
);
|
|
12211
|
-
const
|
|
12404
|
+
const noun = args.kinds?.some((k) => k !== "image") ? "match" : "image";
|
|
12405
|
+
const summary = `${res.results.length} ${noun}${res.results.length === 1 ? "" : noun === "match" ? "es" : "s"} (engine=${res.engine}${res.truncated ? ", truncated" : ""})`;
|
|
12212
12406
|
return okResult(
|
|
12213
12407
|
SearchToolOutputSchema,
|
|
12214
12408
|
{
|
|
@@ -12229,7 +12423,7 @@ ${lines.join("\n") || "(none)"}` }
|
|
|
12229
12423
|
);
|
|
12230
12424
|
server.tool(
|
|
12231
12425
|
"find_similar_images",
|
|
12232
|
-
"Find images visually similar to a given image (
|
|
12426
|
+
"Find images visually similar to a given image (on-device image embeddings). The visual index fills in the background as images are indexed; returns engine=unavailable until this image has been embedded.",
|
|
12233
12427
|
{
|
|
12234
12428
|
path: z5.string().min(1).describe("Workspace-relative path of the reference image."),
|
|
12235
12429
|
maxResults: z5.number().int().positive().max(100).optional()
|
|
@@ -12293,6 +12487,80 @@ server.tool(
|
|
|
12293
12487
|
}
|
|
12294
12488
|
}
|
|
12295
12489
|
);
|
|
12490
|
+
server.tool(
|
|
12491
|
+
"list_photos",
|
|
12492
|
+
"List photos in the workspace from the index, newest first, with when each was taken, the camera, size and a caption once described. Filter by folder, date range (YYYY, YYYY-MM or YYYY-MM-DD), camera, screenshots, or nearness to a place. Reads no files.",
|
|
12493
|
+
{
|
|
12494
|
+
path: z5.string().optional().describe("Folder to scope to (optional)."),
|
|
12495
|
+
from: z5.string().optional().describe("Taken on or after: YYYY, YYYY-MM or YYYY-MM-DD."),
|
|
12496
|
+
to: z5.string().optional().describe("Taken on or before: YYYY, YYYY-MM or YYYY-MM-DD."),
|
|
12497
|
+
camera: z5.string().optional().describe("Camera make or model, any part."),
|
|
12498
|
+
screenshots: z5.boolean().optional().describe("true for only screenshots, false to leave them out."),
|
|
12499
|
+
near: z5.object({ lat: z5.number(), lon: z5.number(), km: z5.number().optional() }).optional().describe("Within km (default 5) of a place."),
|
|
12500
|
+
limit: z5.number().int().positive().max(500).optional()
|
|
12501
|
+
},
|
|
12502
|
+
async (args) => {
|
|
12503
|
+
try {
|
|
12504
|
+
const res = await api.toolListPhotos(projectId, args);
|
|
12505
|
+
const lines = res.photos.map(
|
|
12506
|
+
(p) => [
|
|
12507
|
+
p.path,
|
|
12508
|
+
p.takenAt?.replace("T", " ").slice(0, 16),
|
|
12509
|
+
p.camera,
|
|
12510
|
+
p.width && p.height ? `${p.width}x${p.height}` : void 0,
|
|
12511
|
+
p.screenshot ? "screenshot" : void 0,
|
|
12512
|
+
p.cloudOnly ? "in the cloud" : void 0,
|
|
12513
|
+
p.location ? `${p.location.lat.toFixed(4)},${p.location.lon.toFixed(4)}` : void 0,
|
|
12514
|
+
p.caption ? `"${p.caption.slice(0, 140)}"` : void 0
|
|
12515
|
+
].filter(Boolean).join(" \xB7 ")
|
|
12516
|
+
);
|
|
12517
|
+
const head = `${res.total} photo${res.total === 1 ? "" : "s"}${res.truncated ? ` (showing ${res.photos.length})` : ""}${res.locationWithheld ? "; locations withheld for this session" : ""}`;
|
|
12518
|
+
return { content: [{ type: "text", text: [head, ...lines].join("\n") }] };
|
|
12519
|
+
} catch (err) {
|
|
12520
|
+
return {
|
|
12521
|
+
content: [{ type: "text", text: `list_photos failed: ${unwrapApiError(err)}` }],
|
|
12522
|
+
isError: true
|
|
12523
|
+
};
|
|
12524
|
+
}
|
|
12525
|
+
}
|
|
12526
|
+
);
|
|
12527
|
+
server.tool(
|
|
12528
|
+
"photo_groups",
|
|
12529
|
+
'Group the photos from the index: by "event" (taken together, apart from screenshots), "duplicate" (byte-identical copies, with the space the extra copies take) or "similar" (bursts and retakes that look alike; needs image embeddings). Use it to propose albums or clean-ups; it changes nothing.',
|
|
12530
|
+
{
|
|
12531
|
+
by: z5.enum(["event", "duplicate", "similar"]).describe("How to group."),
|
|
12532
|
+
path: z5.string().optional().describe("Folder to scope to (optional)."),
|
|
12533
|
+
limit: z5.number().int().positive().max(200).optional()
|
|
12534
|
+
},
|
|
12535
|
+
async (args) => {
|
|
12536
|
+
try {
|
|
12537
|
+
const res = await api.toolPhotoGroups(projectId, args);
|
|
12538
|
+
if (res.engine === "unavailable") {
|
|
12539
|
+
return {
|
|
12540
|
+
content: [
|
|
12541
|
+
{
|
|
12542
|
+
type: "text",
|
|
12543
|
+
text: 'No lookalike groups yet: the photos have no image embeddings. Try by "event" or "duplicate".'
|
|
12544
|
+
}
|
|
12545
|
+
]
|
|
12546
|
+
};
|
|
12547
|
+
}
|
|
12548
|
+
const lines = res.groups.map((g, i) => {
|
|
12549
|
+
const span = g.from ? `${g.from.slice(0, 16).replace("T", " ")} to ${g.to?.slice(0, 16).replace("T", " ")}` : "";
|
|
12550
|
+
const bytes = g.bytes ? ` \xB7 ${(g.bytes / 1048576).toFixed(1)} MB in extra copies` : "";
|
|
12551
|
+
return `${i + 1}. ${g.count} photos${span ? ` \xB7 ${span}` : ""}${bytes}
|
|
12552
|
+
${g.paths.join("\n ")}`;
|
|
12553
|
+
});
|
|
12554
|
+
const head = `${res.groups.length} ${res.by} group${res.groups.length === 1 ? "" : "s"}${res.truncated ? " (more not shown)" : ""}`;
|
|
12555
|
+
return { content: [{ type: "text", text: [head, ...lines].join("\n") }] };
|
|
12556
|
+
} catch (err) {
|
|
12557
|
+
return {
|
|
12558
|
+
content: [{ type: "text", text: `photo_groups failed: ${unwrapApiError(err)}` }],
|
|
12559
|
+
isError: true
|
|
12560
|
+
};
|
|
12561
|
+
}
|
|
12562
|
+
}
|
|
12563
|
+
);
|
|
12296
12564
|
server.tool(
|
|
12297
12565
|
"find_entity",
|
|
12298
12566
|
"List entities the index has resolved across files \u2014 email senders, document parties, etc. \u2014 with how many files mention each. Pass a query to filter by name, or a kind (person|party). Follow up with list_entity_mentions to see where an entity appears.",
|
|
@@ -12634,7 +12902,7 @@ server.tool(
|
|
|
12634
12902
|
);
|
|
12635
12903
|
server.tool(
|
|
12636
12904
|
"run_git",
|
|
12637
|
-
"Run a restricted git subcommand in the project workspace. Allowed subcommands: `status`, `log`, `diff`, `show`, `blame`, `branch`, `rev-parse`, `ls-files`. Most are inspections, but `branch` arguments can create, rename, or delete local refs; use `branch` with no args for inspection, and only pass mutation args when the user explicitly requested that change. Args use a structured argv array rather than a shell
|
|
12905
|
+
"Run a restricted git subcommand in the project workspace. Allowed subcommands: `status`, `log`, `diff`, `show`, `blame`, `branch`, `rev-parse`, `ls-files`. Most are inspections, but `branch` arguments can create, rename, or delete local refs; use `branch` with no args for inspection, and only pass mutation args when the user explicitly requested that change. Args use a structured argv array rather than a shell. Each subcommand accepts only its common inspection options (e.g. `--oneline`, `-n`, `--stat`, `--format=`, `--short`, `--porcelain`), spelled out in full; options that write or read files outside the repository are refused, and paths must be relative to the workspace without `..`.",
|
|
12638
12906
|
{
|
|
12639
12907
|
subcommand: z5.enum([
|
|
12640
12908
|
"status",
|
|
@@ -12708,15 +12976,16 @@ server.tool(
|
|
|
12708
12976
|
GEZEL_TOOL_DESCRIPTIONS2.run_installed_script,
|
|
12709
12977
|
RunInstalledScriptInputSchema.shape,
|
|
12710
12978
|
async ({ project, name, scope, input }) => {
|
|
12711
|
-
const
|
|
12712
|
-
|
|
12979
|
+
const hintFor = (written) => installedScriptMissHint({
|
|
12980
|
+
name,
|
|
12981
|
+
...written ? { written } : {},
|
|
12982
|
+
canRunFiles: toolIsAuthorizedForThisSession("run_nodejs_script"),
|
|
12983
|
+
canDerive: toolIsAuthorizedForThisSession("derive_file"),
|
|
12984
|
+
canWriteFiles: toolIsAuthorizedForThisSession("write_file")
|
|
12985
|
+
});
|
|
12986
|
+
if (isPathShapedScriptName(name)) {
|
|
12713
12987
|
return {
|
|
12714
|
-
content: [
|
|
12715
|
-
{
|
|
12716
|
-
type: "text",
|
|
12717
|
-
text: `"${name}" looks like a file path, but run_installed_script takes the NAME of a script already installed in the project (see list_scripts). To run a script file you wrote yourself, use run_nodejs_script instead. To build a derived data file from other files, derive_file is usually better still.`
|
|
12718
|
-
}
|
|
12719
|
-
],
|
|
12988
|
+
content: [{ type: "text", text: hintFor() }],
|
|
12720
12989
|
isError: true
|
|
12721
12990
|
};
|
|
12722
12991
|
}
|
|
@@ -12731,6 +13000,18 @@ server.tool(
|
|
|
12731
13000
|
return formatScriptRunResult(res);
|
|
12732
13001
|
} catch (err) {
|
|
12733
13002
|
const msg = unwrapApiError(err);
|
|
13003
|
+
if (/not found/i.test(msg)) {
|
|
13004
|
+
let written;
|
|
13005
|
+
for (const candidate of scriptFileCandidates(name)) {
|
|
13006
|
+
const stat = await statWorkspacePath(candidate).catch(() => null);
|
|
13007
|
+
if (stat?.kind === "file") {
|
|
13008
|
+
written = candidate;
|
|
13009
|
+
break;
|
|
13010
|
+
}
|
|
13011
|
+
}
|
|
13012
|
+
return errorResult(`run_installed_script failed: ${msg}
|
|
13013
|
+
${hintFor(written)}`);
|
|
13014
|
+
}
|
|
12734
13015
|
return errorResult(`run_installed_script failed: ${msg}`);
|
|
12735
13016
|
}
|
|
12736
13017
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-mcp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
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.2.
|
|
59
|
-
"@bendyline/gezel-client": "1.2.
|
|
58
|
+
"@bendyline/gezel": "1.2.4",
|
|
59
|
+
"@bendyline/gezel-client": "1.2.4",
|
|
60
60
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
61
61
|
"typescript": "^6.0.3",
|
|
62
62
|
"zod": "^4.4.3"
|