@bendyline/gezel-mcp 1.2.8 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harness.js +2032 -61
- package/dist/server.js +319 -230
- package/package.json +4 -4
package/dist/server.js
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
MIN_TASK_DESCRIPTION_LENGTH,
|
|
26
26
|
ManageTaskInputSchema,
|
|
27
27
|
MessageGezelInputSchema,
|
|
28
|
+
OUTCOME_TEAMMATE_SLUGS,
|
|
28
29
|
ReadDocumentInputSchema,
|
|
29
30
|
ReadTaskNotesInputSchema,
|
|
30
31
|
ReplaceInFileInputSchema,
|
|
@@ -42,23 +43,18 @@ import {
|
|
|
42
43
|
WriteTaskNoteInputSchema,
|
|
43
44
|
craftbookInputParams as craftbookInputParams2,
|
|
44
45
|
fillProjectTypeParams,
|
|
45
|
-
findGezelInRoster,
|
|
46
|
-
findProjectByReference,
|
|
47
46
|
formatMediaClock,
|
|
48
47
|
gezelNamesInUse,
|
|
49
|
-
gezelNotFoundMessage,
|
|
50
|
-
gezelRosterHint,
|
|
51
48
|
isAnswerEnvelope,
|
|
52
49
|
isOrdinalWorkOptionId,
|
|
53
50
|
matchProjectTypeForBrief,
|
|
54
51
|
normalizeArtifactPath,
|
|
55
52
|
parseWorkOptionId,
|
|
53
|
+
plainRoleTitle,
|
|
56
54
|
projectNameFromRequest,
|
|
57
|
-
projectNotFoundMessage,
|
|
58
55
|
projectTypeNamedByBrief,
|
|
59
56
|
projectTypesMentionedByBrief,
|
|
60
57
|
renderSuggestWorkResult,
|
|
61
|
-
roleWithGloss,
|
|
62
58
|
routingRequestText
|
|
63
59
|
} from "@bendyline/gezel";
|
|
64
60
|
import { readFileSync } from "fs";
|
|
@@ -101,7 +97,6 @@ import {
|
|
|
101
97
|
inferDeliverableKind,
|
|
102
98
|
inferScriptScope,
|
|
103
99
|
isReservedShadowArtifactPath,
|
|
104
|
-
isSafeEntityId,
|
|
105
100
|
isTrustedConstrainedToolset,
|
|
106
101
|
listArtifactsText,
|
|
107
102
|
listDirMissingText,
|
|
@@ -129,6 +124,7 @@ import {
|
|
|
129
124
|
stepInsertionIndex,
|
|
130
125
|
stepOwnerGezelId,
|
|
131
126
|
taskOwnedPrefixes,
|
|
127
|
+
taskPersonNoun,
|
|
132
128
|
taskScopedWriteDeniedMessage,
|
|
133
129
|
uniqueStepId,
|
|
134
130
|
unknownTaskStepText,
|
|
@@ -1415,8 +1411,11 @@ function buildTypedKickoffStep(input) {
|
|
|
1415
1411
|
const tools = input.tools && input.tools.length > 0 ? ` Your tools for it: ${input.tools.map(
|
|
1416
1412
|
(t) => t.description ? `\`${t.name}\` (${t.description.replace(/\.$/, "")})` : `\`${t.name}\``
|
|
1417
1413
|
).join(", ")}. Call one for each piece rather than writing the file yourself.` : "";
|
|
1414
|
+
const setting = `setting up your ${input.typeName}`;
|
|
1418
1415
|
return {
|
|
1419
1416
|
name: "First draft",
|
|
1417
|
+
stage: "make",
|
|
1418
|
+
personLabel: setting.length <= 60 ? setting : "setting up your project",
|
|
1420
1419
|
description: `You lead this ${input.typeName} project for the person. Their goal: ${goal}${where}${tools}${known}${unsaid} Make what they asked for; if something more would help, offer it in your reply instead of adding it. Do the real work this turn rather than describing it, and finish it before you ask anything. Then reply in two or three sentences: what you made, and at most one question.`
|
|
1421
1420
|
};
|
|
1422
1421
|
}
|
|
@@ -2400,10 +2399,105 @@ ${sections.join("\n\n")}`
|
|
|
2400
2399
|
);
|
|
2401
2400
|
}
|
|
2402
2401
|
|
|
2402
|
+
// src/entity-resolvers.ts
|
|
2403
|
+
import {
|
|
2404
|
+
findGezelInRoster,
|
|
2405
|
+
findProjectByReference,
|
|
2406
|
+
gezelNotFoundMessage,
|
|
2407
|
+
gezelRosterHint,
|
|
2408
|
+
isSafeEntityId,
|
|
2409
|
+
projectNotFoundMessage
|
|
2410
|
+
} from "@bendyline/gezel";
|
|
2411
|
+
|
|
2412
|
+
// src/task-ref.ts
|
|
2413
|
+
function strictParseTaskRef(ref) {
|
|
2414
|
+
const idx = ref.lastIndexOf("/");
|
|
2415
|
+
if (idx < 0) return null;
|
|
2416
|
+
const projectId2 = ref.slice(0, idx).trim();
|
|
2417
|
+
const numStr = ref.slice(idx + 1).trim();
|
|
2418
|
+
if (!projectId2) return null;
|
|
2419
|
+
const num = Number.parseInt(numStr, 10);
|
|
2420
|
+
if (!Number.isFinite(num) || num <= 0 || String(num) !== numStr) return null;
|
|
2421
|
+
return { projectId: projectId2, num };
|
|
2422
|
+
}
|
|
2423
|
+
function normalizeTaskRef(ref) {
|
|
2424
|
+
return ref.replace(/[`'"]/g, "").replace(/\s+/g, "").replace(/[#:](?=\d+$)/, "/");
|
|
2425
|
+
}
|
|
2426
|
+
function resolveTaskRef(ref, sessionTaskRef2) {
|
|
2427
|
+
const session = sessionTaskRef2?.trim() ? strictParseTaskRef(sessionTaskRef2.trim()) : null;
|
|
2428
|
+
const raw = (ref ?? "").trim();
|
|
2429
|
+
if (raw) {
|
|
2430
|
+
const bare = raw.replace(/^#/, "");
|
|
2431
|
+
if (session && /^\d+$/.test(bare)) {
|
|
2432
|
+
const num = Number.parseInt(bare, 10);
|
|
2433
|
+
if (num > 0) return { projectId: session.projectId, num };
|
|
2434
|
+
}
|
|
2435
|
+
const parsed = strictParseTaskRef(raw) ?? strictParseTaskRef(normalizeTaskRef(raw));
|
|
2436
|
+
if (parsed) {
|
|
2437
|
+
if (!session || parsed.projectId === session.projectId) return parsed;
|
|
2438
|
+
return session;
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
if (session) return session;
|
|
2442
|
+
const hint = sessionTaskRef2?.trim() ? ` This session's task is "${sessionTaskRef2.trim()}".` : "";
|
|
2443
|
+
throw new Error(
|
|
2444
|
+
`invalid task ref "${ref ?? ""}" \u2014 expected projectId/num (e.g. "myproject/1").${hint}`
|
|
2445
|
+
);
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
// src/entity-resolvers.ts
|
|
2449
|
+
function createEntityResolvers(deps) {
|
|
2450
|
+
const { api: api2, projectId: projectId2, sessionTaskRef: sessionTaskRef2 } = deps;
|
|
2451
|
+
async function resolveProjectId2(input, recoveryTools = []) {
|
|
2452
|
+
try {
|
|
2453
|
+
const p = await api2.getProject(input);
|
|
2454
|
+
return p.id;
|
|
2455
|
+
} catch {
|
|
2456
|
+
}
|
|
2457
|
+
let all;
|
|
2458
|
+
try {
|
|
2459
|
+
all = (await api2.listProjects()).projects;
|
|
2460
|
+
} catch (err) {
|
|
2461
|
+
if (/\b403\b/.test(err instanceof Error ? err.message : String(err))) {
|
|
2462
|
+
return projectId2;
|
|
2463
|
+
}
|
|
2464
|
+
throw err;
|
|
2465
|
+
}
|
|
2466
|
+
const match = findProjectByReference(all, input);
|
|
2467
|
+
if (match) return match.id;
|
|
2468
|
+
throw new Error(projectNotFoundMessage(input, all, recoveryTools));
|
|
2469
|
+
}
|
|
2470
|
+
async function resolveGezelId2(input) {
|
|
2471
|
+
const all = (await api2.listGezels()).gezels;
|
|
2472
|
+
const match = findGezelInRoster(all, input);
|
|
2473
|
+
if (match) return match.id;
|
|
2474
|
+
try {
|
|
2475
|
+
const g = await api2.getGezel(input);
|
|
2476
|
+
return g.id;
|
|
2477
|
+
} catch {
|
|
2478
|
+
}
|
|
2479
|
+
throw new Error(gezelNotFoundMessage(input, all));
|
|
2480
|
+
}
|
|
2481
|
+
async function availableGezelsHint2() {
|
|
2482
|
+
try {
|
|
2483
|
+
return gezelRosterHint((await api2.listGezels()).gezels);
|
|
2484
|
+
} catch {
|
|
2485
|
+
return "Call `list_gezels` for the roster.";
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
async function parseRef2(ref) {
|
|
2489
|
+
const parsed = resolveTaskRef(ref, sessionTaskRef2);
|
|
2490
|
+
if (isSafeEntityId(parsed.projectId)) return parsed;
|
|
2491
|
+
return { ...parsed, projectId: await resolveProjectId2(parsed.projectId) };
|
|
2492
|
+
}
|
|
2493
|
+
return { resolveProjectId: resolveProjectId2, resolveGezelId: resolveGezelId2, availableGezelsHint: availableGezelsHint2, parseRef: parseRef2 };
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2403
2496
|
// src/generate-image-normalization.ts
|
|
2404
2497
|
var AGENT_IMAGE_MAX_SIDE_PX = 1024;
|
|
2405
2498
|
var SIZE_MULTIPLE = 64;
|
|
2406
|
-
function normalizeGenerateImageToolArgs(args) {
|
|
2499
|
+
function normalizeGenerateImageToolArgs(args, kind = "local") {
|
|
2500
|
+
if (kind === "cloud") return { args: { ...args } };
|
|
2407
2501
|
const next = { ...args };
|
|
2408
2502
|
const changes = [];
|
|
2409
2503
|
const originalSize = typeof args.width === "number" && typeof args.height === "number" ? `${args.width}x${args.height}` : void 0;
|
|
@@ -3178,6 +3272,9 @@ async function reanchorAfterEdit(args) {
|
|
|
3178
3272
|
}
|
|
3179
3273
|
}
|
|
3180
3274
|
|
|
3275
|
+
// src/relay-text.ts
|
|
3276
|
+
var PLAIN_WORDS_RELAY = "Use plain words; don't repeat task, project or craftbook ids.";
|
|
3277
|
+
|
|
3181
3278
|
// src/repo-intake-policy.ts
|
|
3182
3279
|
var GITHUB_REPO_URL_RE = /https?:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]*[A-Za-z0-9_-])(?:\.git)?(?:\/[^\s)"'`<>]*)?/i;
|
|
3183
3280
|
function extractGitHubRepoUrl(text) {
|
|
@@ -3743,42 +3840,6 @@ function hasTypeOnlyModifier(node) {
|
|
|
3743
3840
|
) ?? false;
|
|
3744
3841
|
}
|
|
3745
3842
|
|
|
3746
|
-
// src/task-ref.ts
|
|
3747
|
-
function strictParseTaskRef(ref) {
|
|
3748
|
-
const idx = ref.lastIndexOf("/");
|
|
3749
|
-
if (idx < 0) return null;
|
|
3750
|
-
const projectId2 = ref.slice(0, idx).trim();
|
|
3751
|
-
const numStr = ref.slice(idx + 1).trim();
|
|
3752
|
-
if (!projectId2) return null;
|
|
3753
|
-
const num = Number.parseInt(numStr, 10);
|
|
3754
|
-
if (!Number.isFinite(num) || num <= 0 || String(num) !== numStr) return null;
|
|
3755
|
-
return { projectId: projectId2, num };
|
|
3756
|
-
}
|
|
3757
|
-
function normalizeTaskRef(ref) {
|
|
3758
|
-
return ref.replace(/[`'"]/g, "").replace(/\s+/g, "").replace(/[#:](?=\d+$)/, "/");
|
|
3759
|
-
}
|
|
3760
|
-
function resolveTaskRef(ref, sessionTaskRef2) {
|
|
3761
|
-
const session = sessionTaskRef2?.trim() ? strictParseTaskRef(sessionTaskRef2.trim()) : null;
|
|
3762
|
-
const raw = (ref ?? "").trim();
|
|
3763
|
-
if (raw) {
|
|
3764
|
-
const bare = raw.replace(/^#/, "");
|
|
3765
|
-
if (session && /^\d+$/.test(bare)) {
|
|
3766
|
-
const num = Number.parseInt(bare, 10);
|
|
3767
|
-
if (num > 0) return { projectId: session.projectId, num };
|
|
3768
|
-
}
|
|
3769
|
-
const parsed = strictParseTaskRef(raw) ?? strictParseTaskRef(normalizeTaskRef(raw));
|
|
3770
|
-
if (parsed) {
|
|
3771
|
-
if (!session || parsed.projectId === session.projectId) return parsed;
|
|
3772
|
-
return session;
|
|
3773
|
-
}
|
|
3774
|
-
}
|
|
3775
|
-
if (session) return session;
|
|
3776
|
-
const hint = sessionTaskRef2?.trim() ? ` This session's task is "${sessionTaskRef2.trim()}".` : "";
|
|
3777
|
-
throw new Error(
|
|
3778
|
-
`invalid task ref "${ref ?? ""}" \u2014 expected projectId/num (e.g. "myproject/1").${hint}`
|
|
3779
|
-
);
|
|
3780
|
-
}
|
|
3781
|
-
|
|
3782
3843
|
// src/task-step-authority.ts
|
|
3783
3844
|
function taskStepMutationRejection(scope) {
|
|
3784
3845
|
const { taskRef, sessionStepId: sessionStepId2, activeStepId, transitionCompleted } = scope;
|
|
@@ -4850,12 +4911,19 @@ var sessionTaskNamingMode = {
|
|
|
4850
4911
|
...sessionId ? { launchSessionId: sessionId } : {}
|
|
4851
4912
|
};
|
|
4852
4913
|
var sessionTaskRef = process.env.GEZEL_TASK_REF ?? "";
|
|
4914
|
+
var receiptTaskRef = sessionTaskRef || (process.env.GEZEL_RECEIPT_TASK_REF ?? "");
|
|
4915
|
+
var taskTeammates = process.env.GEZEL_TASK_TEAMMATES === "1";
|
|
4853
4916
|
var sessionCraftbookId = process.env.GEZEL_CRAFTBOOK_ID ?? "";
|
|
4854
4917
|
var rawSessionContextWindow = Number(process.env.GEZEL_CONTEXT_WINDOW ?? "");
|
|
4855
4918
|
var sessionContextWindow = Number.isFinite(rawSessionContextWindow) && rawSessionContextWindow > 0 ? rawSessionContextWindow : void 0;
|
|
4856
4919
|
var certPath = process.env.GEZEL_CERT_PATH;
|
|
4857
4920
|
var fetchImpl = local?.fetch ?? (certPath ? createTrustingFetch({ cert: readFileSync(certPath, "utf8") }) : createPatientFetch());
|
|
4858
4921
|
var api = new GezelClient({ baseUrl, token, fetch: fetchImpl });
|
|
4922
|
+
var { resolveProjectId, resolveGezelId, availableGezelsHint, parseRef } = createEntityResolvers({
|
|
4923
|
+
api,
|
|
4924
|
+
projectId,
|
|
4925
|
+
sessionTaskRef
|
|
4926
|
+
});
|
|
4859
4927
|
async function pickFreshGezelName() {
|
|
4860
4928
|
const roster = await api.listGezels().then((response) => response.gezels).catch(() => []);
|
|
4861
4929
|
return pickUnusedGezelName(gezelNamesInUse(roster));
|
|
@@ -4995,10 +5063,15 @@ function draftEditApi(client, packId) {
|
|
|
4995
5063
|
};
|
|
4996
5064
|
}
|
|
4997
5065
|
var sessionTaskArtifactDir = (process.env.GEZEL_TASK_ARTIFACT_DIR ?? "").replace(/\/+$/, "");
|
|
5066
|
+
function sessionTaskArtifactPath(path) {
|
|
5067
|
+
if (!sessionTaskArtifactDir) return null;
|
|
5068
|
+
const p = path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
5069
|
+
return p === sessionTaskArtifactDir || p.startsWith(`${sessionTaskArtifactDir}/`) ? p : null;
|
|
5070
|
+
}
|
|
4998
5071
|
function assertNotTaskArtifactNamespace(target) {
|
|
4999
|
-
if (
|
|
5000
|
-
const p = target.path
|
|
5001
|
-
if (p
|
|
5072
|
+
if (target.kind !== "current") return;
|
|
5073
|
+
const p = sessionTaskArtifactPath(target.path);
|
|
5074
|
+
if (p) {
|
|
5002
5075
|
throw new Error(
|
|
5003
5076
|
`\`${p}\` is this task's working folder in the ARTIFACTS DRAWER, not the project workspace. Write it with \`write_artifact({ path: ${JSON.stringify(p)}, ... })\` and read it back with \`read_artifact\` \u2014 the workspace file tools cannot reach the drawer.`
|
|
5004
5077
|
);
|
|
@@ -6075,6 +6148,16 @@ server.tool(
|
|
|
6075
6148
|
async ({ path, content }) => {
|
|
6076
6149
|
const stale = await staleStepMutationResult();
|
|
6077
6150
|
if (stale) return stale;
|
|
6151
|
+
const drawerPath = sessionTaskArtifactPath(path);
|
|
6152
|
+
if (drawerPath && toolIsAuthorizedForThisSession("write_artifact")) {
|
|
6153
|
+
const written = await writeArtifactToolCall({ path: drawerPath, content });
|
|
6154
|
+
const notice = `[Rerouted write_file \u2192 write_artifact]
|
|
6155
|
+
${JSON.stringify(drawerPath)} is this task's working folder in the artifacts drawer, so it was written there. Use write_artifact and read_artifact for files in this folder.`;
|
|
6156
|
+
return {
|
|
6157
|
+
...written,
|
|
6158
|
+
content: [{ type: "text", text: notice }, ...written.content]
|
|
6159
|
+
};
|
|
6160
|
+
}
|
|
6078
6161
|
const raster = rasterImageWriteRefusal(path);
|
|
6079
6162
|
if (raster) return raster;
|
|
6080
6163
|
const scoped = await taskScopedWriteRefusal(path, "workspace");
|
|
@@ -6751,7 +6834,7 @@ server.tool(
|
|
|
6751
6834
|
...sessionId ? { sessionId } : {},
|
|
6752
6835
|
// Receipt attribution for commandEvidence gates — env-derived, so a
|
|
6753
6836
|
// model cannot stamp another step's receipt.
|
|
6754
|
-
...
|
|
6837
|
+
...receiptTaskRef ? { taskRef: receiptTaskRef } : {},
|
|
6755
6838
|
...sessionStepId ? { stepId: sessionStepId } : {}
|
|
6756
6839
|
});
|
|
6757
6840
|
return commandToolResult(`npm run ${script}`, res);
|
|
@@ -6776,7 +6859,7 @@ server.tool(
|
|
|
6776
6859
|
...timeoutMs ? { timeoutMs } : {},
|
|
6777
6860
|
...gezelId ? { gezelId } : {},
|
|
6778
6861
|
...sessionId ? { sessionId } : {},
|
|
6779
|
-
...
|
|
6862
|
+
...receiptTaskRef ? { taskRef: receiptTaskRef } : {},
|
|
6780
6863
|
...sessionStepId ? { stepId: sessionStepId } : {}
|
|
6781
6864
|
});
|
|
6782
6865
|
return commandToolResult(`npx ${bin}`, res);
|
|
@@ -7553,133 +7636,139 @@ server.tool(
|
|
|
7553
7636
|
"Bypass the workspace-collision and source-code-extension guards. Only set when you deliberately want to stash a code-looking file in artifacts (rare \u2014 a mock, a scratch experiment you're not shipping)."
|
|
7554
7637
|
)
|
|
7555
7638
|
}).shape,
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7639
|
+
(args) => writeArtifactToolCall(args)
|
|
7640
|
+
);
|
|
7641
|
+
async function writeArtifactToolCall({
|
|
7642
|
+
path,
|
|
7643
|
+
content: rawContent,
|
|
7644
|
+
jsonContent,
|
|
7645
|
+
force
|
|
7646
|
+
}) {
|
|
7647
|
+
const stale = await staleStepMutationResult();
|
|
7648
|
+
if (stale) return stale;
|
|
7649
|
+
const raster = rasterImageWriteRefusal(path);
|
|
7650
|
+
if (raster) return raster;
|
|
7651
|
+
const scoped = await taskScopedWriteRefusal(path, "artifacts");
|
|
7652
|
+
if (scoped) return scoped;
|
|
7653
|
+
if (rawContent === void 0 === (jsonContent === void 0)) {
|
|
7654
|
+
return errorResult(
|
|
7655
|
+
"Supply exactly one of content or jsonContent. Use jsonContent for a structured JSON report."
|
|
7656
|
+
);
|
|
7657
|
+
}
|
|
7658
|
+
const value = jsonContent ?? rawContent;
|
|
7659
|
+
const content = typeof value === "string" ? value : `${JSON.stringify(value, null, 2)}
|
|
7570
7660
|
`;
|
|
7571
|
-
|
|
7572
|
-
|
|
7661
|
+
const clean = normalizeArtifactPath(path);
|
|
7662
|
+
if (isReservedShadowArtifactPath(clean)) {
|
|
7663
|
+
return {
|
|
7664
|
+
content: [
|
|
7665
|
+
{
|
|
7666
|
+
type: "text",
|
|
7667
|
+
text: "artifacts/shadow/ is gezel's derived shadow-file cache (converted documents, image descriptions, transcripts), regenerated automatically by indexing \u2014 anything written there would be overwritten or swept. Write your artifact elsewhere, e.g. at the artifacts root or under reports/."
|
|
7668
|
+
}
|
|
7669
|
+
],
|
|
7670
|
+
isError: true
|
|
7671
|
+
};
|
|
7672
|
+
}
|
|
7673
|
+
if (isProtectedConnectorArtifactPath(clean)) {
|
|
7674
|
+
return {
|
|
7675
|
+
content: [
|
|
7676
|
+
{
|
|
7677
|
+
type: "text",
|
|
7678
|
+
text: "The artifacts/data directory contains read-only connector mirrors. Editing a synced record can cause permanent data loss because its cursor has already advanced. Write analysis elsewhere in artifacts, or use draft_connector_action to propose a source change for the user."
|
|
7679
|
+
}
|
|
7680
|
+
],
|
|
7681
|
+
isError: true
|
|
7682
|
+
};
|
|
7683
|
+
}
|
|
7684
|
+
if (!force) {
|
|
7685
|
+
const redirected = await redirectExpectedDeliverableWriteToWorkspace(
|
|
7686
|
+
clean,
|
|
7687
|
+
content,
|
|
7688
|
+
"write_artifact"
|
|
7689
|
+
);
|
|
7690
|
+
if (redirected) return redirected;
|
|
7691
|
+
}
|
|
7692
|
+
const verdict = !force ? classifyArtifactPath(clean) : { ok: true };
|
|
7693
|
+
if (!verdict.ok) {
|
|
7694
|
+
const normalizedContent = normalizeWorkspaceWriteContent(clean, content);
|
|
7695
|
+
const syntax = validateSourceContent(clean, normalizedContent);
|
|
7696
|
+
if (syntax && !syntax.ok) {
|
|
7697
|
+
return {
|
|
7698
|
+
content: [{ type: "text", text: syntax.message }],
|
|
7699
|
+
isError: true
|
|
7700
|
+
};
|
|
7701
|
+
}
|
|
7702
|
+
try {
|
|
7703
|
+
await api.writeProjectWorkspaceFile(projectId, {
|
|
7704
|
+
path: clean,
|
|
7705
|
+
content: normalizedContent,
|
|
7706
|
+
...gezelId ? { gezelId } : {},
|
|
7707
|
+
...sessionId ? { sessionId } : {}
|
|
7708
|
+
});
|
|
7573
7709
|
return {
|
|
7574
7710
|
content: [
|
|
7575
7711
|
{
|
|
7576
7712
|
type: "text",
|
|
7577
|
-
text:
|
|
7713
|
+
text: `Wrote ${clean} to the project workspace. Note: write_artifact is for scratch artifacts; use write_file directly for app/source deliverables.`
|
|
7578
7714
|
}
|
|
7579
|
-
]
|
|
7715
|
+
]
|
|
7716
|
+
};
|
|
7717
|
+
} catch (err) {
|
|
7718
|
+
return {
|
|
7719
|
+
content: [{ type: "text", text: explainWriteFailure(err) }],
|
|
7580
7720
|
isError: true
|
|
7581
7721
|
};
|
|
7582
7722
|
}
|
|
7583
|
-
|
|
7723
|
+
}
|
|
7724
|
+
if (!force) {
|
|
7725
|
+
const workspaceCollision = await workspaceCollisionForArtifactPath(clean);
|
|
7726
|
+
if (workspaceCollision) {
|
|
7584
7727
|
return {
|
|
7585
7728
|
content: [
|
|
7586
7729
|
{
|
|
7587
7730
|
type: "text",
|
|
7588
|
-
text: "
|
|
7731
|
+
text: `Refusing write_artifact({ path: "${clean}", ... }) because a workspace ${workspaceCollision.kind} already exists at that path. write_artifact would create a side-drawer copy, not update the project. Use write_file if you have workspace write access, or hand off to a developer. Set force: true only if you intentionally want an artifact copy with the same path.`
|
|
7589
7732
|
}
|
|
7590
7733
|
],
|
|
7591
7734
|
isError: true
|
|
7592
7735
|
};
|
|
7593
7736
|
}
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
const verdict = !force ? classifyArtifactPath(clean) : { ok: true };
|
|
7603
|
-
if (!verdict.ok) {
|
|
7604
|
-
const normalizedContent = normalizeWorkspaceWriteContent(clean, content);
|
|
7605
|
-
const syntax = validateSourceContent(clean, normalizedContent);
|
|
7606
|
-
if (syntax && !syntax.ok) {
|
|
7607
|
-
return {
|
|
7608
|
-
content: [{ type: "text", text: syntax.message }],
|
|
7609
|
-
isError: true
|
|
7610
|
-
};
|
|
7611
|
-
}
|
|
7612
|
-
try {
|
|
7613
|
-
await api.writeProjectWorkspaceFile(projectId, {
|
|
7614
|
-
path: clean,
|
|
7615
|
-
content: normalizedContent,
|
|
7616
|
-
...gezelId ? { gezelId } : {},
|
|
7617
|
-
...sessionId ? { sessionId } : {}
|
|
7618
|
-
});
|
|
7619
|
-
return {
|
|
7620
|
-
content: [
|
|
7621
|
-
{
|
|
7622
|
-
type: "text",
|
|
7623
|
-
text: `Wrote ${clean} to the project workspace. Note: write_artifact is for scratch artifacts; use write_file directly for app/source deliverables.`
|
|
7624
|
-
}
|
|
7625
|
-
]
|
|
7626
|
-
};
|
|
7627
|
-
} catch (err) {
|
|
7628
|
-
return {
|
|
7629
|
-
content: [{ type: "text", text: explainWriteFailure(err) }],
|
|
7630
|
-
isError: true
|
|
7631
|
-
};
|
|
7632
|
-
}
|
|
7633
|
-
}
|
|
7634
|
-
if (!force) {
|
|
7635
|
-
const workspaceCollision = await workspaceCollisionForArtifactPath(clean);
|
|
7636
|
-
if (workspaceCollision) {
|
|
7637
|
-
return {
|
|
7638
|
-
content: [
|
|
7639
|
-
{
|
|
7640
|
-
type: "text",
|
|
7641
|
-
text: `Refusing write_artifact({ path: "${clean}", ... }) because a workspace ${workspaceCollision.kind} already exists at that path. write_artifact would create a side-drawer copy, not update the project. Use write_file if you have workspace write access, or hand off to a developer. Set force: true only if you intentionally want an artifact copy with the same path.`
|
|
7642
|
-
}
|
|
7643
|
-
],
|
|
7644
|
-
isError: true
|
|
7645
|
-
};
|
|
7646
|
-
}
|
|
7647
|
-
}
|
|
7648
|
-
if (!force) {
|
|
7649
|
-
const syntax = validateSourceContent(clean, content);
|
|
7650
|
-
if (syntax && !syntax.ok) {
|
|
7651
|
-
return {
|
|
7652
|
-
content: [{ type: "text", text: syntax.message }],
|
|
7653
|
-
isError: true
|
|
7654
|
-
};
|
|
7655
|
-
}
|
|
7737
|
+
}
|
|
7738
|
+
if (!force) {
|
|
7739
|
+
const syntax = validateSourceContent(clean, content);
|
|
7740
|
+
if (syntax && !syntax.ok) {
|
|
7741
|
+
return {
|
|
7742
|
+
content: [{ type: "text", text: syntax.message }],
|
|
7743
|
+
isError: true
|
|
7744
|
+
};
|
|
7656
7745
|
}
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
}
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
}
|
|
7746
|
+
}
|
|
7747
|
+
if (clean.toLowerCase().endsWith(".json")) {
|
|
7748
|
+
try {
|
|
7749
|
+
JSON.parse(content);
|
|
7750
|
+
} catch (err) {
|
|
7751
|
+
return {
|
|
7752
|
+
content: [
|
|
7753
|
+
{
|
|
7754
|
+
type: "text",
|
|
7755
|
+
text: `Refusing to replace ${clean}: the new content is not valid JSON (${err instanceof Error ? err.message : String(err)}). The previous artifact was left unchanged. Re-emit one complete valid JSON value; if it cannot fit in one tool call, split the deliverable or use a deterministic script to assemble it.`
|
|
7756
|
+
}
|
|
7757
|
+
],
|
|
7758
|
+
isError: true
|
|
7759
|
+
};
|
|
7671
7760
|
}
|
|
7672
|
-
const stored = clean.endsWith(".md") ? normalizeMarkdown(content) : content;
|
|
7673
|
-
await api.writeProjectArtifact(projectId, clean, stored, {
|
|
7674
|
-
...gezelId ? { gezelId } : {},
|
|
7675
|
-
...sessionId ? { sessionId } : {}
|
|
7676
|
-
});
|
|
7677
|
-
const completionHint = sessionTaskRef && sessionStepId ? artifactCompletionHint(sessionStepCompletion, {
|
|
7678
|
-
checkedByStep: sessionStepCheckedArtifacts.includes(clean)
|
|
7679
|
-
}) : "";
|
|
7680
|
-
return { content: [{ type: "text", text: `Wrote ${clean}${completionHint}` }] };
|
|
7681
7761
|
}
|
|
7682
|
-
);
|
|
7762
|
+
const stored = clean.endsWith(".md") ? normalizeMarkdown(content) : content;
|
|
7763
|
+
await api.writeProjectArtifact(projectId, clean, stored, {
|
|
7764
|
+
...gezelId ? { gezelId } : {},
|
|
7765
|
+
...sessionId ? { sessionId } : {}
|
|
7766
|
+
});
|
|
7767
|
+
const completionHint = sessionTaskRef && sessionStepId ? artifactCompletionHint(sessionStepCompletion, {
|
|
7768
|
+
checkedByStep: sessionStepCheckedArtifacts.includes(clean)
|
|
7769
|
+
}) : "";
|
|
7770
|
+
return { content: [{ type: "text", text: `Wrote ${clean}${completionHint}` }] };
|
|
7771
|
+
}
|
|
7683
7772
|
server.tool(
|
|
7684
7773
|
"run_playwright_script",
|
|
7685
7774
|
"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.",
|
|
@@ -7960,7 +8049,7 @@ server.tool(
|
|
|
7960
8049
|
);
|
|
7961
8050
|
server.tool(
|
|
7962
8051
|
"apply_project_type",
|
|
7963
|
-
"Apply a custom project type to an EXISTING project \u2014 renders its about/mission, creates its gezel(s) and sets the
|
|
8052
|
+
"Apply a custom project type to an EXISTING project \u2014 renders its about/mission, creates its gezel(s) and sets the crew lead, installs its scripts, and seeds its workspace. Use this to retrofit a plain project into a typed one. To create a fresh typed project in one call, use start_project_from_type instead.",
|
|
7964
8053
|
{
|
|
7965
8054
|
typeId: z8.string().describe("Project type id (from list_project_types)."),
|
|
7966
8055
|
project: z8.string().optional().describe("Project id or name. Defaults to the current project."),
|
|
@@ -7974,7 +8063,7 @@ server.tool(
|
|
|
7974
8063
|
...params ? { params } : {}
|
|
7975
8064
|
});
|
|
7976
8065
|
const gz = applied.gezelsCreated.map(
|
|
7977
|
-
(g) => `${g.name}${g.voorman ? " (
|
|
8066
|
+
(g) => `${g.name}${g.voorman ? " (crew lead)" : ""}${g.reused ? " (already on the crew)" : ""}`
|
|
7978
8067
|
).join(", ");
|
|
7979
8068
|
return {
|
|
7980
8069
|
content: [
|
|
@@ -7996,12 +8085,12 @@ server.tool(
|
|
|
7996
8085
|
);
|
|
7997
8086
|
server.tool(
|
|
7998
8087
|
"start_project_from_type",
|
|
7999
|
-
`Create a fresh project from a custom project type in one call: makes the project, applies the type (its gezel becomes the
|
|
8088
|
+
`Create a fresh project from a custom project type in one call: makes the project, applies the type (its gezel becomes the crew lead, its scripts/seed/dashboard are installed), and notifies the crew lead to greet the user. Use when the user's goal matches a type from list_project_types (e.g. "I want to learn Spanish" \u2192 the language-trainer type). For a generic build of any size, use start_project.`,
|
|
8000
8089
|
{
|
|
8001
8090
|
name: z8.string().describe('Project name, e.g. "Learn Spanish".'),
|
|
8002
8091
|
typeId: z8.string().describe("Project type id (from list_project_types)."),
|
|
8003
8092
|
params: z8.record(z8.string(), z8.any()).optional().describe('Param values the type asks for (e.g. { "language": "Spanish" }).'),
|
|
8004
|
-
kickoffMessage: z8.string().optional().describe("Optional first message to send the
|
|
8093
|
+
kickoffMessage: z8.string().optional().describe("Optional first message to send the crew lead after setup.")
|
|
8005
8094
|
},
|
|
8006
8095
|
async ({ name, typeId, params, kickoffMessage }) => {
|
|
8007
8096
|
let manifestName = typeId;
|
|
@@ -8030,20 +8119,20 @@ server.tool(
|
|
|
8030
8119
|
const voorman = applied.gezelsCreated.find((g) => g.voorman) ?? applied.gezelsCreated[0];
|
|
8031
8120
|
let voormanNote = "";
|
|
8032
8121
|
if (voorman) {
|
|
8033
|
-
const text = kickoffMessage ?? `You're the
|
|
8122
|
+
const text = kickoffMessage ?? `You're the crew lead of the new "${name}" project (${manifestName}). Greet the user warmly, explain what you'll help with, and get them started.`;
|
|
8034
8123
|
await api.messageGezel(voorman.id, {
|
|
8035
8124
|
fromGezelId: gezelId,
|
|
8036
8125
|
...sessionId ? { fromSessionId: sessionId } : {},
|
|
8037
8126
|
projectId: project.id,
|
|
8038
8127
|
text
|
|
8039
8128
|
});
|
|
8040
|
-
voormanNote = ` ${voorman.name} is the
|
|
8129
|
+
voormanNote = ` ${voorman.name} is the crew lead and will greet the user in the next turn.`;
|
|
8041
8130
|
}
|
|
8042
8131
|
return {
|
|
8043
8132
|
content: [
|
|
8044
8133
|
{
|
|
8045
8134
|
type: "text",
|
|
8046
|
-
text: `Started "${name}" (${project.id}) from the ${manifestName} project type.${voormanNote} Installed ${applied.scriptsInstalled.length} script(s); seeded ${applied.workspaceSeeded.length} file(s). Tell the user their ${manifestName} project is ready
|
|
8135
|
+
text: `Started "${name}" (${project.id}) from the ${manifestName} project type.${voormanNote} Installed ${applied.scriptsInstalled.length} script(s); seeded ${applied.workspaceSeeded.length} file(s). Tell the user their ${manifestName} project is ready. ${PLAIN_WORDS_RELAY}`
|
|
8047
8136
|
}
|
|
8048
8137
|
]
|
|
8049
8138
|
};
|
|
@@ -8654,7 +8743,7 @@ async function runInvokeCraftbook({
|
|
|
8654
8743
|
}
|
|
8655
8744
|
},
|
|
8656
8745
|
{
|
|
8657
|
-
text: `Invoked craftbook "${craftbookId}" \u2014 task ${created.ref} (${stepCount} step(s)). Active step ${created.activeStepId ?? "(none)"} was dispatched to the recipe-selected specialist.${installedText}${versionText}${idempotentText}`
|
|
8746
|
+
text: `Invoked craftbook "${craftbookId}" \u2014 task ${created.ref} (${stepCount} step(s)). Active step ${created.activeStepId ?? "(none)"} was dispatched to the recipe-selected specialist.${installedText}${versionText}${idempotentText} Tell the person that ${taskPersonNoun(created)} is underway. ${PLAIN_WORDS_RELAY}`
|
|
8658
8747
|
}
|
|
8659
8748
|
);
|
|
8660
8749
|
} catch (err) {
|
|
@@ -9156,7 +9245,7 @@ server.tool(
|
|
|
9156
9245
|
);
|
|
9157
9246
|
server.tool(
|
|
9158
9247
|
"export_task_craftbook",
|
|
9159
|
-
"Promote a task's embedded craftbook into a reusable LOCAL craftbook template (the inverse of invoke_craftbook). Strips per-instance lifecycle state and mints a fresh template id. Use after the
|
|
9248
|
+
"Promote a task's embedded craftbook into a reusable LOCAL craftbook template (the inverse of invoke_craftbook). Strips per-instance lifecycle state and mints a fresh template id. Use after the crew lead has shaped a good craftbook on a task and you want to reuse it.",
|
|
9160
9249
|
{
|
|
9161
9250
|
task: z8.string().optional().describe("Task ref. Omit \u2192 session task."),
|
|
9162
9251
|
id: z8.string().optional().describe("Preferred template id (slugified; deduped on collision)."),
|
|
@@ -9177,7 +9266,7 @@ server.tool(
|
|
|
9177
9266
|
);
|
|
9178
9267
|
server.tool(
|
|
9179
9268
|
"list_project_local_gezels",
|
|
9180
|
-
"List this project's own gezels \u2014 the `@project` gezel derived from the workspace AGENTS.md/CLAUDE.md (the project's default
|
|
9269
|
+
"List this project's own gezels \u2014 the `@project` gezel derived from the workspace AGENTS.md/CLAUDE.md (the project's default crew lead) plus any others defined in the workspace `.gezel/` folder. Address the canonical one as `@project` in ask_gezel / message_gezel. These never appear in the global list_gezels roster.",
|
|
9181
9270
|
{
|
|
9182
9271
|
project: z8.string().optional().describe("Project id or name. Defaults to the current project.")
|
|
9183
9272
|
},
|
|
@@ -9518,7 +9607,7 @@ var ROLE_TO_JOB_TITLE = {
|
|
|
9518
9607
|
writer: "Copywriter",
|
|
9519
9608
|
planner: "Planner",
|
|
9520
9609
|
reviewer: "Reviewer",
|
|
9521
|
-
voorman: "
|
|
9610
|
+
voorman: "Crew Lead",
|
|
9522
9611
|
// Must match the `image-generator` template's role string verbatim
|
|
9523
9612
|
// so the role-tool-filter map keys hit and the gezel gets the
|
|
9524
9613
|
// `images` group. Display name renders as "Image Generator" in
|
|
@@ -9527,10 +9616,10 @@ var ROLE_TO_JOB_TITLE = {
|
|
|
9527
9616
|
};
|
|
9528
9617
|
server.tool(
|
|
9529
9618
|
"ask_specialist",
|
|
9530
|
-
"Quick role-shaped consultation. Picks (or auto-creates) a gezel matching `role` and synchronously asks them `question` \u2014 their answer comes back as the tool result, ready to use inline within this turn. ONE call replaces the `ensure_gezel` \u2192 `ask_gezel` sequence. Use this for domain answers you need to keep working: 'researcher' for facts and prior art, 'designer' for visual / UX feedback, 'developer' or 'builder' for technical implementation calls, 'writer' for copy, 'planner' for breaking work down, 'reviewer' for QA on a draft, 'voorman' for project-status questions. Do NOT use this for shippable file or image deliverables (`index.html`, `review.md`, `logo.png`): first call `ensure_gezel`, then `message_gezel` with `expectedDeliverable: { kind: \"file\", filePath: \"<path>\" }` so the specialist works asynchronously and writes/renders the file. `ask_specialist` rejects file-shaped expectedDeliverable hints. The chosen specialist auto-joins your current project so the user can switch to their chat for follow-ups. For a specific known gezel use `ask_gezel`; for fan-out / fire-and-forget pings use `message_gezel`.",
|
|
9619
|
+
"Quick role-shaped consultation. Picks (or auto-creates) a gezel matching `role` and synchronously asks them `question` \u2014 their answer comes back as the tool result, ready to use inline within this turn. ONE call replaces the `ensure_gezel` \u2192 `ask_gezel` sequence. Use this for domain answers you need to keep working: 'researcher' for facts and prior art, 'designer' for visual / UX feedback, 'developer' or 'builder' for technical implementation calls, 'writer' for copy, 'planner' for breaking work down, 'reviewer' for QA on a draft, 'voorman' (the crew lead) for project-status questions. Do NOT use this for shippable file or image deliverables (`index.html`, `review.md`, `logo.png`): first call `ensure_gezel`, then `message_gezel` with `expectedDeliverable: { kind: \"file\", filePath: \"<path>\" }` so the specialist works asynchronously and writes/renders the file. `ask_specialist` rejects file-shaped expectedDeliverable hints. The chosen specialist auto-joins your current project so the user can switch to their chat for follow-ups. For a specific known gezel use `ask_gezel`; for fan-out / fire-and-forget pings use `message_gezel`.",
|
|
9531
9620
|
{
|
|
9532
9621
|
role: SPECIALIST_ROLES.describe(
|
|
9533
|
-
"researcher = long-form analysis / facts / prior art (files a written report to disk by default), developer = team-oriented engineering, builder = solo product engineer, generalist = one gezel for a whole multi-step task of any craft, designer = visual/UX advice (does NOT render images), writer = copy/content, planner = strategy/decomposition, reviewer = QA/feedback (short structured verification reply by default), voorman = current
|
|
9622
|
+
"researcher = long-form analysis / facts / prior art (files a written report to disk by default), developer = team-oriented engineering, builder = solo product engineer, generalist = one gezel for a whole multi-step task of any craft, designer = visual/UX advice (does NOT render images), writer = copy/content, planner = strategy/decomposition, reviewer = QA/feedback (short structured verification reply by default), voorman = crew lead of the current project, image-generator = render an actual PNG via generate_image (use this when you need a real image asset, not just visual feedback)."
|
|
9534
9623
|
),
|
|
9535
9624
|
question: z8.string().min(1).describe(
|
|
9536
9625
|
"What you want them to answer. Be specific \u2014 they only see this question, not your prior conversation."
|
|
@@ -9690,12 +9779,48 @@ var DELEGATION_ROLE_SPECS = [
|
|
|
9690
9779
|
},
|
|
9691
9780
|
{
|
|
9692
9781
|
slug: "voorman",
|
|
9693
|
-
jobTitle: "
|
|
9694
|
-
label: "
|
|
9782
|
+
jobTitle: "Crew Lead",
|
|
9783
|
+
label: "crew lead",
|
|
9695
9784
|
hint: "project lead / coordination / status"
|
|
9696
9785
|
},
|
|
9697
9786
|
{ slug: "meester", jobTitle: "Meester", label: "meester", hint: "top-level orchestration" }
|
|
9698
9787
|
];
|
|
9788
|
+
function isOutcomeTeammateSlug(slug) {
|
|
9789
|
+
return OUTCOME_TEAMMATE_SLUGS.includes(slug);
|
|
9790
|
+
}
|
|
9791
|
+
async function consultTaskTeammate(slug, label, question, timeoutMs) {
|
|
9792
|
+
const parsed = await parseRef(sessionTaskRef);
|
|
9793
|
+
const ask = await api.askTaskTeammate(parsed.projectId, parsed.num, {
|
|
9794
|
+
fromGezelId: gezelId,
|
|
9795
|
+
fromSessionId: sessionId,
|
|
9796
|
+
role: slug,
|
|
9797
|
+
question,
|
|
9798
|
+
...typeof timeoutMs === "number" ? { timeoutMs } : {}
|
|
9799
|
+
});
|
|
9800
|
+
if (ask.outcome === "reply") {
|
|
9801
|
+
return {
|
|
9802
|
+
content: [
|
|
9803
|
+
{
|
|
9804
|
+
type: "text",
|
|
9805
|
+
text: `${ask.toGezelName} (${label}) answered:
|
|
9806
|
+
|
|
9807
|
+
${ask.text}
|
|
9808
|
+
|
|
9809
|
+
Check any file they say they wrote before you rely on it.`
|
|
9810
|
+
}
|
|
9811
|
+
]
|
|
9812
|
+
};
|
|
9813
|
+
}
|
|
9814
|
+
return {
|
|
9815
|
+
content: [
|
|
9816
|
+
{
|
|
9817
|
+
type: "text",
|
|
9818
|
+
text: JSON.stringify({ outcome: "error", reason: ask.reason, message: ask.message })
|
|
9819
|
+
}
|
|
9820
|
+
],
|
|
9821
|
+
isError: true
|
|
9822
|
+
};
|
|
9823
|
+
}
|
|
9699
9824
|
for (const { slug, jobTitle, label, hint } of DELEGATION_ROLE_SPECS) {
|
|
9700
9825
|
server.tool(
|
|
9701
9826
|
`delegate_${slug}`,
|
|
@@ -9765,7 +9890,7 @@ ${expectedDeliverable?.kind === "file" ? expectedDeliverable.filePath ?? "" : ""
|
|
|
9765
9890
|
);
|
|
9766
9891
|
server.tool(
|
|
9767
9892
|
`consult_${slug}`,
|
|
9768
|
-
`Ask a project's ${label} (${hint}) a question and get their answer back synchronously, this turn. Auto-creates a ${label} if none exists. For a project you created from Default, pass \`project\` so the answer uses the right files and memory. For handing off actual work or files, use \`delegate_${slug}\` instead.`,
|
|
9893
|
+
taskTeammates && isOutcomeTeammateSlug(slug) ? `Hand a self-contained piece of your task to a ${label} (${hint}) and get their answer back this turn. Auto-creates a ${label} if none exists. They work in this project and see only what you write here: name the files to read and the file to write. You stay responsible for the result, so check what they wrote.` : `Ask a project's ${label} (${hint}) a question and get their answer back synchronously, this turn. Auto-creates a ${label} if none exists. For a project you created from Default, pass \`project\` so the answer uses the right files and memory. For handing off actual work or files, use \`delegate_${slug}\` instead.`,
|
|
9769
9894
|
{
|
|
9770
9895
|
question: z8.string().min(1).describe(
|
|
9771
9896
|
`What you want the ${label} to answer. Be specific \u2014 they only see this question.`
|
|
@@ -9794,6 +9919,9 @@ ${expectedDeliverable?.kind === "file" ? expectedDeliverable.filePath ?? "" : ""
|
|
|
9794
9919
|
};
|
|
9795
9920
|
}
|
|
9796
9921
|
try {
|
|
9922
|
+
if (taskTeammates && sessionTaskRef && isOutcomeTeammateSlug(slug)) {
|
|
9923
|
+
return await consultTaskTeammate(slug, label, question, timeoutMs);
|
|
9924
|
+
}
|
|
9797
9925
|
const resolvedProject = project ? await resolveProjectId(project) : projectId;
|
|
9798
9926
|
const repoGuard = await repoIntakeGuardForProject({
|
|
9799
9927
|
tool: `consult_${slug}`,
|
|
@@ -10339,7 +10467,7 @@ ${idempotent.resultText}`
|
|
|
10339
10467
|
dispatchEntry: true
|
|
10340
10468
|
});
|
|
10341
10469
|
const entryName = await macroEntryAssigneeName(task, voorman.id, voorman.name);
|
|
10342
|
-
const resultText = `Started project "${brief.name}" (${project.id}). Recruited ${voorman.name} as
|
|
10470
|
+
const resultText = `Started project "${brief.name}" (${project.id}). Recruited ${voorman.name} as crew lead. Created task ${task.ref} ("${task.title}") and handed its entry step to ${entryName} \u2014 they are starting now in a task-scoped session. No reply lands in this thread; progress accrues on the task (get_task / read_task_notes when the user asks). Tell the user ${entryName} is on it; they can watch the work in the ${brief.name} project. ${PLAIN_WORDS_RELAY}`;
|
|
10343
10471
|
recordMacroResult("start_project", brief.name, project.id, resultText);
|
|
10344
10472
|
return {
|
|
10345
10473
|
content: [
|
|
@@ -10508,7 +10636,7 @@ Note from the meester: ${opts.kickoffMessage.trim()}` : "";
|
|
|
10508
10636
|
dispatchEntry: true
|
|
10509
10637
|
});
|
|
10510
10638
|
const role = (await api.getGezel(lead.id).catch(() => null))?.role;
|
|
10511
|
-
const resultText = `Started "${project.name}" (${project.id}) as a ${type.name} project. ${lead.name}${role ? ` (${
|
|
10639
|
+
const resultText = `Started "${project.name}" (${project.id}) as a ${type.name} project. ${lead.name}${role ? ` (${plainRoleTitle(role)})` : ""} leads it and is making the first draft now in a task-scoped session (task ${task.ref}); the project's Output page shows it as it fills in. No reply lands in this thread. Tell the person in a sentence or two that ${lead.name} is on it. ${PLAIN_WORDS_RELAY}`;
|
|
10512
10640
|
recordMacroResult(opts.cacheTool, brief.name, project.id, resultText);
|
|
10513
10641
|
return { content: [{ type: "text", text: resultText }] };
|
|
10514
10642
|
} catch (err) {
|
|
@@ -10568,7 +10696,7 @@ async function runStartProject(input, tool) {
|
|
|
10568
10696
|
content: [
|
|
10569
10697
|
{
|
|
10570
10698
|
type: "text",
|
|
10571
|
-
text: `[runtime] A \`${idempotent.tool}\` call for "${brief.name}" completed moments ago \u2014 replaying the original result instead of creating a duplicate. END YOUR TURN; the
|
|
10699
|
+
text: `[runtime] A \`${idempotent.tool}\` call for "${brief.name}" completed moments ago \u2014 replaying the original result instead of creating a duplicate. END YOUR TURN; the crew lead from the original call is already on it.
|
|
10572
10700
|
|
|
10573
10701
|
${idempotent.resultText}`
|
|
10574
10702
|
}
|
|
@@ -10630,7 +10758,7 @@ ${idempotent.resultText}`
|
|
|
10630
10758
|
dispatchEntry: true
|
|
10631
10759
|
});
|
|
10632
10760
|
const entryName = await macroEntryAssigneeName(task, voorman.id, voorman.name);
|
|
10633
|
-
const resultText = `Started project "${brief.name}" (${project.id}). Recruited ${voorman.name} as
|
|
10761
|
+
const resultText = `Started project "${brief.name}" (${project.id}). Recruited ${voorman.name} as crew lead. Created task ${task.ref} ("${task.title}") and handed its entry step to ${entryName} \u2014 they are starting now in a task-scoped session. No reply lands in this thread; progress accrues on the task (get_task / read_task_notes when the user asks). Tell the user ${entryName} is on it; they can watch the work in the ${brief.name} project. ${PLAIN_WORDS_RELAY}`;
|
|
10634
10762
|
recordMacroResult(tool, brief.name, project.id, resultText);
|
|
10635
10763
|
return {
|
|
10636
10764
|
content: [
|
|
@@ -10767,7 +10895,7 @@ server.tool(
|
|
|
10767
10895
|
"There is no request in this turn to start work for. Pass `details` with what the person asked for."
|
|
10768
10896
|
);
|
|
10769
10897
|
}
|
|
10770
|
-
const resolvedProject = project ? await resolveProjectId(project) : (await rankingForTurn(projectId, said).catch(() => null))?.projectId ?? projectId;
|
|
10898
|
+
const resolvedProject = project ? await resolveProjectId(project, ["start_work"]) : (await rankingForTurn(projectId, said).catch(() => null))?.projectId ?? projectId;
|
|
10771
10899
|
const parsed = parseWorkOptionId(option) ?? await resolveBareWorkOption(option, resolvedProject, said);
|
|
10772
10900
|
if (!parsed) {
|
|
10773
10901
|
const listed = await rankingForTurn(resolvedProject, said).catch(() => null);
|
|
@@ -10863,7 +10991,7 @@ async function toggleRecurringWork(project, key, pause) {
|
|
|
10863
10991
|
content: [
|
|
10864
10992
|
{
|
|
10865
10993
|
type: "text",
|
|
10866
|
-
text: `Paused "${item2.craftbookName ?? item2.craftbookId}"${item2.taskRef ? ` (host task ${item2.taskRef})` : ""}. Its history is kept; switching it back on resumes it. Tell the person it is off
|
|
10994
|
+
text: `Paused "${item2.craftbookName ?? item2.craftbookId}"${item2.taskRef ? ` (host task ${item2.taskRef})` : ""}. Its history is kept; switching it back on resumes it. Tell the person it is off. ${PLAIN_WORDS_RELAY}`
|
|
10867
10995
|
}
|
|
10868
10996
|
]
|
|
10869
10997
|
};
|
|
@@ -10874,7 +11002,7 @@ async function toggleRecurringWork(project, key, pause) {
|
|
|
10874
11002
|
content: [
|
|
10875
11003
|
{
|
|
10876
11004
|
type: "text",
|
|
10877
|
-
text: `Switched on "${item.craftbookName ?? item.craftbookId}" \u2014 it runs ${cadence}, host task ${task.ref}. Tell the person when it will first run
|
|
11005
|
+
text: `Switched on "${item.craftbookName ?? item.craftbookId}" \u2014 it runs ${cadence}, host task ${task.ref}. Tell the person when it will first run. ${PLAIN_WORDS_RELAY}`
|
|
10878
11006
|
}
|
|
10879
11007
|
]
|
|
10880
11008
|
};
|
|
@@ -11010,7 +11138,7 @@ ${idempotent.resultText}`
|
|
|
11010
11138
|
],
|
|
11011
11139
|
dispatchEntry: true
|
|
11012
11140
|
});
|
|
11013
|
-
const resultText = `Started project "${brief.name}" (${project.id}). Recruited ${builder.name} as lead (template: ${builder.templateId}). Created task ${task.ref} ("${task.title}") and handed ${builder.name} its entry step \u2014 they are starting now in a task-scoped session. No reply lands in this thread; progress accrues on the task (notes, gates, status \u2014 get_task / read_task_notes when the user asks). Tell the user ${builder.name} is on it and they can watch the work in the ${brief.name} project
|
|
11141
|
+
const resultText = `Started project "${brief.name}" (${project.id}). Recruited ${builder.name} as lead (template: ${builder.templateId}). Created task ${task.ref} ("${task.title}") and handed ${builder.name} its entry step \u2014 they are starting now in a task-scoped session. No reply lands in this thread; progress accrues on the task (notes, gates, status \u2014 get_task / read_task_notes when the user asks). Tell the user ${builder.name} is on it and they can watch the work in the ${brief.name} project. ${PLAIN_WORDS_RELAY}`;
|
|
11014
11142
|
recordMacroResult(cacheTool, brief.name, project.id, resultText);
|
|
11015
11143
|
return {
|
|
11016
11144
|
content: [
|
|
@@ -11226,7 +11354,7 @@ server.tool(
|
|
|
11226
11354
|
);
|
|
11227
11355
|
server.tool(
|
|
11228
11356
|
"remove_gezel_from_project",
|
|
11229
|
-
"Drop a gezel from a project's roster. Advisory only \u2014 doesn't tear down their existing chat sessions, task assignments, or the project's
|
|
11357
|
+
"Drop a gezel from a project's roster. Advisory only \u2014 doesn't tear down their existing chat sessions, task assignments, or the project's crew lead pointer; the gezel just stops showing up in the project's team list. Re-add via `add_gezel_to_project` (or any of the auto-add triggers will pull them back in).",
|
|
11230
11358
|
{
|
|
11231
11359
|
gezel: z8.string().describe("Gezel id or display name"),
|
|
11232
11360
|
project: z8.string().optional().describe("Project id or name \u2014 defaults to your current project")
|
|
@@ -11514,7 +11642,7 @@ server.tool(
|
|
|
11514
11642
|
ref: z8.string(),
|
|
11515
11643
|
title: z8.string().optional(),
|
|
11516
11644
|
description: z8.string().optional(),
|
|
11517
|
-
plan: z8.string().optional().describe("The
|
|
11645
|
+
plan: z8.string().optional().describe("The crew lead's evolving approach. Overwrites the existing plan."),
|
|
11518
11646
|
assignee: assigneeArg().optional(),
|
|
11519
11647
|
cron: z8.string().optional(),
|
|
11520
11648
|
cronOverlap: cronOverlapEnum.optional(),
|
|
@@ -12212,48 +12340,6 @@ ${why}`) },
|
|
|
12212
12340
|
);
|
|
12213
12341
|
}
|
|
12214
12342
|
);
|
|
12215
|
-
async function resolveProjectId(input) {
|
|
12216
|
-
try {
|
|
12217
|
-
const p = await api.getProject(input);
|
|
12218
|
-
return p.id;
|
|
12219
|
-
} catch {
|
|
12220
|
-
}
|
|
12221
|
-
let all;
|
|
12222
|
-
try {
|
|
12223
|
-
all = (await api.listProjects()).projects;
|
|
12224
|
-
} catch (err) {
|
|
12225
|
-
if (/\b403\b/.test(err instanceof Error ? err.message : String(err))) {
|
|
12226
|
-
return projectId;
|
|
12227
|
-
}
|
|
12228
|
-
throw err;
|
|
12229
|
-
}
|
|
12230
|
-
const match = findProjectByReference(all, input);
|
|
12231
|
-
if (match) return match.id;
|
|
12232
|
-
throw new Error(projectNotFoundMessage(input, all));
|
|
12233
|
-
}
|
|
12234
|
-
async function resolveGezelId(input) {
|
|
12235
|
-
const all = (await api.listGezels()).gezels;
|
|
12236
|
-
const match = findGezelInRoster(all, input);
|
|
12237
|
-
if (match) return match.id;
|
|
12238
|
-
try {
|
|
12239
|
-
const g = await api.getGezel(input);
|
|
12240
|
-
return g.id;
|
|
12241
|
-
} catch {
|
|
12242
|
-
}
|
|
12243
|
-
throw new Error(gezelNotFoundMessage(input, all));
|
|
12244
|
-
}
|
|
12245
|
-
async function availableGezelsHint() {
|
|
12246
|
-
try {
|
|
12247
|
-
return gezelRosterHint((await api.listGezels()).gezels);
|
|
12248
|
-
} catch {
|
|
12249
|
-
return "Call `list_gezels` for the roster.";
|
|
12250
|
-
}
|
|
12251
|
-
}
|
|
12252
|
-
async function parseRef(ref) {
|
|
12253
|
-
const parsed = resolveTaskRef(ref, sessionTaskRef);
|
|
12254
|
-
if (isSafeEntityId(parsed.projectId)) return parsed;
|
|
12255
|
-
return { ...parsed, projectId: await resolveProjectId(parsed.projectId) };
|
|
12256
|
-
}
|
|
12257
12343
|
server.tool(
|
|
12258
12344
|
"search_history",
|
|
12259
12345
|
'Search the history log \u2014 gezel / project creation, settings changes, tool calls, chat session summaries, document changes. Your first stop when debugging "why is this the way it is?" or tracing what has happened recently.',
|
|
@@ -12497,7 +12583,9 @@ server.tool(
|
|
|
12497
12583
|
},
|
|
12498
12584
|
async (args) => {
|
|
12499
12585
|
try {
|
|
12500
|
-
const
|
|
12586
|
+
const config = await api.getConfig();
|
|
12587
|
+
const cloud = !args.model?.startsWith("remote:") && ["copilot", "codex-cli", "google-ai", "openai"].includes(config.imageProvider ?? "sd-cpp");
|
|
12588
|
+
const normalized = normalizeGenerateImageToolArgs(args, cloud ? "cloud" : "local");
|
|
12501
12589
|
const imageArgs = normalized.args;
|
|
12502
12590
|
const saveAs = imageArgs.saveAs || inferGeneratedImageSaveAs(imageArgs.prompt);
|
|
12503
12591
|
const res = await api.generateImage({
|
|
@@ -12535,10 +12623,11 @@ To display this image in HTML, copy this exact tag verbatim \u2014 do not add an
|
|
|
12535
12623
|
|
|
12536
12624
|
If you are working on a website/logo task and an HTML file already exists, your next tool call should patch that HTML with this exact tag using \`replace_in_file\` or \`write_file\`. Do not call \`generate_image\` again for the same missing image; the image asset already exists.` : "\n\nNOTE: workspace copy was skipped (project has an external workingDir not approved for writes). To reference from HTML, copy the image into the workspace yourself first via `write_file`.";
|
|
12537
12625
|
const normalizedLine = normalized.note ? ` ${normalized.note}` : "";
|
|
12626
|
+
const settingsLine = meta.settingsNotes?.length ? ` Image settings: ${meta.settingsNotes.join(" ")}` : "";
|
|
12538
12627
|
const skippedLine = meta.img2imgSkippedReason ? ` NOTE: the source image was not used \u2014 ${meta.img2imgSkippedReason}; the image was generated from the prompt alone.` : "";
|
|
12539
12628
|
const guideLine = promptGuide && !promptGuidesShown.has(meta.model) ? ` For your next prompt: ${promptGuide}` : "";
|
|
12540
12629
|
if (promptGuide) promptGuidesShown.add(meta.model);
|
|
12541
|
-
const summary = `Generated ${meta.widthPx}\xD7${meta.heightPx} image with ${meta.model} (seed ${meta.seed}, ${meta.steps} steps, ${meta.durationMs}ms).${normalizedLine}${skippedLine}${guideLine} The user already sees this image inline below the tool call \u2014 DO NOT embed it again as Markdown (e.g. \`\`); just refer to it by name in your reply when needed. To iterate on it, pass \`{ inputImages: [{ artifactPath: "${artifactPath}" }] }\` to a follow-up generate_image call. To read its bytes, call \`read_artifact\` with path \`${artifactPath}\`.${workspaceLine}`;
|
|
12630
|
+
const summary = `Generated ${meta.widthPx}\xD7${meta.heightPx} image with ${meta.model} (seed ${meta.seed}, ${meta.steps} steps, ${meta.durationMs}ms).${normalizedLine}${settingsLine}${skippedLine}${guideLine} The user already sees this image inline below the tool call \u2014 DO NOT embed it again as Markdown (e.g. \`\`); just refer to it by name in your reply when needed. To iterate on it, pass \`{ inputImages: [{ artifactPath: "${artifactPath}" }] }\` to a follow-up generate_image call. To read its bytes, call \`read_artifact\` with path \`${artifactPath}\`.${workspaceLine}`;
|
|
12542
12631
|
const content = [{ type: "text", text: summary }];
|
|
12543
12632
|
if (b64Png) {
|
|
12544
12633
|
content.push({ type: "image", data: b64Png, mimeType: "image/png" });
|
|
@@ -12960,7 +13049,7 @@ ${body}` }] };
|
|
|
12960
13049
|
);
|
|
12961
13050
|
server.tool(
|
|
12962
13051
|
"file_review",
|
|
12963
|
-
"The
|
|
13052
|
+
"The Librarian's notes + health review for one file: what it does and how it flows, issues spotted (severity/category/message/line), and a 1-10 health score with its reason, judged against a per-file-type rubric. Call before deep-diving an unfamiliar file, or when outline_file shows low health. Issues are LEADS from a background model pass, not confirmed problems \u2014 verify each in the code.",
|
|
12964
13053
|
{
|
|
12965
13054
|
path: z8.string().min(1).describe("Workspace-relative file path, e.g. src/server.ts.")
|
|
12966
13055
|
},
|
|
@@ -12982,7 +13071,7 @@ ${tracked.join("\n")}`
|
|
|
12982
13071
|
]
|
|
12983
13072
|
};
|
|
12984
13073
|
}
|
|
12985
|
-
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
|
|
13074
|
+
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 Librarian has not reviewed this file yet (it studies files when idle or during Night Shift)" : "file is not in the index";
|
|
12986
13075
|
return {
|
|
12987
13076
|
content: [{ type: "text", text: `file_review: no review \u2014 ${why}.` }]
|
|
12988
13077
|
};
|
|
@@ -13015,7 +13104,7 @@ ${issues.join("\n")}` : "issues: none",
|
|
|
13015
13104
|
);
|
|
13016
13105
|
server.tool(
|
|
13017
13106
|
"get_file_issue",
|
|
13018
|
-
"Retrieve the durable metadata for one
|
|
13107
|
+
"Retrieve the durable metadata for one tracked 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.",
|
|
13019
13108
|
{
|
|
13020
13109
|
ref: z8.string().regex(/^BW-[1-9]\d*$/).describe("Project-scoped reference, e.g. BW-17.")
|
|
13021
13110
|
},
|
|
@@ -13046,7 +13135,7 @@ server.tool(
|
|
|
13046
13135
|
);
|
|
13047
13136
|
server.tool(
|
|
13048
13137
|
"set_file_issue_status",
|
|
13049
|
-
"Update a tracked
|
|
13138
|
+
"Update a tracked 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.",
|
|
13050
13139
|
{
|
|
13051
13140
|
ref: z8.string().regex(/^BW-[1-9]\d*$/).describe("Project-scoped reference, e.g. BW-17."),
|
|
13052
13141
|
status: z8.enum(["open", "in_progress", "resolved", "dismissed"]).optional(),
|
|
@@ -13479,7 +13568,7 @@ ${lines.join("\n") || "(none matched)"}` }
|
|
|
13479
13568
|
);
|
|
13480
13569
|
server.tool(
|
|
13481
13570
|
"list_file_issues",
|
|
13482
|
-
"Quality issues the
|
|
13571
|
+
"Quality issues the Librarian's review pass spotted across files (likely bugs, code smells, unclear naming; grammar/clarity in docs), filterable by severity, category, or path prefix. Severities are info|minor|major \u2014 a quality vocabulary, unrelated to security severities; use scan_findings for vulnerabilities. These are LEADS from a background model pass, not confirmed problems; verify each in the code.",
|
|
13483
13572
|
{
|
|
13484
13573
|
severity: z8.enum(["info", "minor", "major"]).optional(),
|
|
13485
13574
|
category: z8.string().optional().describe("e.g. bug, smell, error-handling, grammar, clarity."),
|