@dversum/mcp-server 2.9.1 → 2.11.1
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/src/client.d.ts +11 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +51 -0
- package/dist/src/client.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/tools/calendar.d.ts +15 -0
- package/dist/src/tools/calendar.d.ts.map +1 -1
- package/dist/src/tools/calendar.js +27 -2
- package/dist/src/tools/calendar.js.map +1 -1
- package/dist/src/tools/clients.d.ts.map +1 -1
- package/dist/src/tools/clients.js +4 -0
- package/dist/src/tools/clients.js.map +1 -1
- package/dist/src/tools/request-bodies.spec.d.ts +2 -0
- package/dist/src/tools/request-bodies.spec.d.ts.map +1 -0
- package/dist/src/tools/request-bodies.spec.js +45 -0
- package/dist/src/tools/request-bodies.spec.js.map +1 -0
- package/dist/src/tools/time.d.ts +13 -0
- package/dist/src/tools/time.d.ts.map +1 -1
- package/dist/src/tools/time.js +27 -6
- package/dist/src/tools/time.js.map +1 -1
- package/dist/src/tools/universum.d.ts +4 -0
- package/dist/src/tools/universum.d.ts.map +1 -0
- package/dist/src/tools/universum.js +48 -0
- package/dist/src/tools/universum.js.map +1 -0
- package/dist/src/tools/whiteboard-compose.d.ts +4 -0
- package/dist/src/tools/whiteboard-compose.d.ts.map +1 -0
- package/dist/src/tools/whiteboard-compose.js +383 -0
- package/dist/src/tools/whiteboard-compose.js.map +1 -0
- package/dist/src/tools/whiteboards.d.ts.map +1 -1
- package/dist/src/tools/whiteboards.js +150 -7
- package/dist/src/tools/whiteboards.js.map +1 -1
- package/dist/src/whiteboard/elements.d.ts +171 -0
- package/dist/src/whiteboard/elements.d.ts.map +1 -0
- package/dist/src/whiteboard/elements.js +121 -0
- package/dist/src/whiteboard/elements.js.map +1 -0
- package/dist/src/whiteboard/link.d.ts +22 -0
- package/dist/src/whiteboard/link.d.ts.map +1 -0
- package/dist/src/whiteboard/link.js +56 -0
- package/dist/src/whiteboard/link.js.map +1 -0
- package/dist/src/whiteboard/measure.d.ts +26 -0
- package/dist/src/whiteboard/measure.d.ts.map +1 -0
- package/dist/src/whiteboard/measure.js +64 -0
- package/dist/src/whiteboard/measure.js.map +1 -0
- package/dist/src/whiteboard/sections.d.ts +352 -0
- package/dist/src/whiteboard/sections.d.ts.map +1 -0
- package/dist/src/whiteboard/sections.js +879 -0
- package/dist/src/whiteboard/sections.js.map +1 -0
- package/dist/src/whiteboard/sections.spec.d.ts +2 -0
- package/dist/src/whiteboard/sections.spec.d.ts.map +1 -0
- package/dist/src/whiteboard/sections.spec.js +608 -0
- package/dist/src/whiteboard/sections.spec.js.map +1 -0
- package/dist/src/whiteboard/stock.d.ts +39 -0
- package/dist/src/whiteboard/stock.d.ts.map +1 -0
- package/dist/src/whiteboard/stock.js +91 -0
- package/dist/src/whiteboard/stock.js.map +1 -0
- package/dist/src/whiteboard/stock.spec.d.ts +2 -0
- package/dist/src/whiteboard/stock.spec.d.ts.map +1 -0
- package/dist/src/whiteboard/stock.spec.js +69 -0
- package/dist/src/whiteboard/stock.spec.js.map +1 -0
- package/dist/src/whiteboard/styles.d.ts +65 -0
- package/dist/src/whiteboard/styles.d.ts.map +1 -0
- package/dist/src/whiteboard/styles.js +63 -0
- package/dist/src/whiteboard/styles.js.map +1 -0
- package/dist/src/whiteboard/tokens.d.ts +114 -0
- package/dist/src/whiteboard/tokens.d.ts.map +1 -0
- package/dist/src/whiteboard/tokens.js +105 -0
- package/dist/src/whiteboard/tokens.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { composeBoard, composeSlides, composeNarrow, CANVAS_MARGIN, } from "../whiteboard/sections.js";
|
|
3
|
+
import { SECTION_GAP } from "../whiteboard/tokens.js";
|
|
4
|
+
import { findPhoto, StockUnavailable } from "../whiteboard/stock.js";
|
|
5
|
+
/** Existing content comes back in one of three shapes across board ages. */
|
|
6
|
+
function normalize(raw) {
|
|
7
|
+
const blank = () => ({
|
|
8
|
+
version: 2,
|
|
9
|
+
pages: [{ id: `page-${Date.now()}`, title: "Page 1", elements: [], layerOrder: [] }],
|
|
10
|
+
});
|
|
11
|
+
if (!raw || typeof raw !== "object")
|
|
12
|
+
return blank();
|
|
13
|
+
const obj = raw;
|
|
14
|
+
if (Array.isArray(obj.pages) && obj.pages.length) {
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
if (Array.isArray(obj.elements)) {
|
|
18
|
+
return {
|
|
19
|
+
version: 2,
|
|
20
|
+
pages: [{
|
|
21
|
+
id: `page-${Date.now()}`,
|
|
22
|
+
title: "Page 1",
|
|
23
|
+
elements: obj.elements,
|
|
24
|
+
layerOrder: obj.layerOrder ?? [],
|
|
25
|
+
}],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return blank();
|
|
29
|
+
}
|
|
30
|
+
/** Lowest occupied point on a page, so appended sections clear it. */
|
|
31
|
+
function contentBottom(page) {
|
|
32
|
+
let bottom = 0;
|
|
33
|
+
for (const el of page.elements ?? []) {
|
|
34
|
+
const y = typeof el.y === "number" ? el.y : 0;
|
|
35
|
+
const h = typeof el.height === "number" ? el.height : 0;
|
|
36
|
+
bottom = Math.max(bottom, y + h);
|
|
37
|
+
}
|
|
38
|
+
return bottom;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Swap every { kind: "stock", query } visual for a real photo.
|
|
42
|
+
*
|
|
43
|
+
* Attribution is a licence condition, not a nicety, so the credits come
|
|
44
|
+
* back with the result and the caller puts them on the board. A lookup
|
|
45
|
+
* that fails degrades to an art-directed placeholder rather than failing
|
|
46
|
+
* the whole compose: a board with a labelled gap still ships.
|
|
47
|
+
*/
|
|
48
|
+
async function resolveStockVisuals(sections) {
|
|
49
|
+
const credits = [];
|
|
50
|
+
const notes = [];
|
|
51
|
+
const slots = [];
|
|
52
|
+
const walk = (node) => {
|
|
53
|
+
if (!node || typeof node !== "object")
|
|
54
|
+
return;
|
|
55
|
+
if (Array.isArray(node))
|
|
56
|
+
return void node.forEach(walk);
|
|
57
|
+
const obj = node;
|
|
58
|
+
if (obj.kind === "stock" && typeof obj.query === "string")
|
|
59
|
+
slots.push(obj);
|
|
60
|
+
for (const v of Object.values(obj))
|
|
61
|
+
walk(v);
|
|
62
|
+
};
|
|
63
|
+
sections.forEach(walk);
|
|
64
|
+
if (!slots.length)
|
|
65
|
+
return { credits, notes };
|
|
66
|
+
await Promise.all(slots.map(async (slot) => {
|
|
67
|
+
const query = String(slot.query);
|
|
68
|
+
try {
|
|
69
|
+
const photo = await findPhoto(query, {
|
|
70
|
+
orientation: slot.orientation === "portrait" || slot.orientation === "squarish"
|
|
71
|
+
? slot.orientation
|
|
72
|
+
: "landscape",
|
|
73
|
+
});
|
|
74
|
+
delete slot.query;
|
|
75
|
+
delete slot.orientation;
|
|
76
|
+
slot.kind = "image";
|
|
77
|
+
slot.src = photo.src;
|
|
78
|
+
slot.alt = photo.alt;
|
|
79
|
+
credits.push(photo.credit);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
const why = err instanceof StockUnavailable ? err.message : String(err);
|
|
83
|
+
delete slot.query;
|
|
84
|
+
delete slot.orientation;
|
|
85
|
+
slot.kind = "placeholder";
|
|
86
|
+
slot.brief = `Photograph: ${query}.`;
|
|
87
|
+
notes.push(`No photo for "${query}": ${why} A placeholder was used instead.`);
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
return { credits, notes };
|
|
91
|
+
}
|
|
92
|
+
/** Attribution belongs on the board, in one predictable place. */
|
|
93
|
+
function appendCredits(sections, credits) {
|
|
94
|
+
if (!credits.length)
|
|
95
|
+
return;
|
|
96
|
+
const unique = [...new Set(credits)];
|
|
97
|
+
const footer = [...sections].reverse().find((s) => s.type === "footerMeta");
|
|
98
|
+
if (footer) {
|
|
99
|
+
const content = footer.content;
|
|
100
|
+
content.items = [...content.items, ...unique];
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
sections.push({ type: "footerMeta", content: { items: unique } });
|
|
104
|
+
}
|
|
105
|
+
const DESCRIPTION = `Build a whiteboard as a STACK OF SECTIONS, the way a landing page is a stack of bands. Prefer this over set_whiteboard_content whenever the board is meant to be read rather than drawn on.
|
|
106
|
+
|
|
107
|
+
ASK FIRST, THEN BUILD
|
|
108
|
+
|
|
109
|
+
Before composing, ask the user which of the two layouts they want, in one short question, and wait for the answer. Do not guess and do not build both. Skip the question only when they have already said which they want.
|
|
110
|
+
|
|
111
|
+
page One long column, scrolled top to bottom like a web page. When
|
|
112
|
+
shared, the board fits the reader's window and moves only up and
|
|
113
|
+
down. Best for a pitch, a report, a summary, anything read alone.
|
|
114
|
+
|
|
115
|
+
slides The same sections broken across screen-sized pages, each one
|
|
116
|
+
filling a window, stepped through with the page tabs. Best for
|
|
117
|
+
presenting to a room.
|
|
118
|
+
|
|
119
|
+
Phrase it as a real choice, for example: \"Do you want this as one long scrolling page, or split into slides you can click through?\"
|
|
120
|
+
|
|
121
|
+
PICK A STYLE
|
|
122
|
+
|
|
123
|
+
A style decides the typeface, what sits above the hero headline, the alignment, how cards are treated and how loudly the accent speaks. One choice, applied to the whole board, so it stays coherent. They are genuinely different from each other, so choose on the subject rather than defaulting:
|
|
124
|
+
|
|
125
|
+
product Software, dashboards, anything that should look like a product page. Sans, a short accent rule above the headline, white cards lifted off the page, figures on a dark panel.
|
|
126
|
+
|
|
127
|
+
editorial Reports, essays, strategy documents, anything read slowly. Serif headlines, no rule at all, features separated by hairlines rather than boxed, figures sitting on the page.
|
|
128
|
+
|
|
129
|
+
statement A launch, a manifesto, one idea that has to land first. Oversized centred headline, muted panels, figures on an accent panel.
|
|
130
|
+
|
|
131
|
+
technical Architecture, process, specifications, anything an engineer reads. Monospaced body, a full-width hairline above the headline, flat panels, no shadows.
|
|
132
|
+
|
|
133
|
+
Say which style you used when you report back, so the user can ask for a different one. Do not ask about the style; choose it and name it. The layout question is the only one worth interrupting for.
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
You choose the section order and write the words. The layout engine owns every coordinate, so spacing, alignment, type hierarchy and colour are correct by construction. Do NOT pass x/y/width/height anywhere: there is nowhere to put them.
|
|
137
|
+
|
|
138
|
+
THE TWELVE SECTIONS
|
|
139
|
+
|
|
140
|
+
hero { headline, subline?, visual?, cta? }
|
|
141
|
+
Use ONCE, at the top. In page layout it claims a whole screen with its content centred in it, the way a landing page opens. It is the only section with display-size type.
|
|
142
|
+
|
|
143
|
+
Write the headline as the one claim the reader should leave with, not a description of the product. Give it a subline and a cta whenever there is a real destination.
|
|
144
|
+
|
|
145
|
+
featureGrid { items: [{ icon, title, body }], columns?: 2|3|4, title?, intro? }
|
|
146
|
+
Cards of equal height, with an optional heading above them. icon is a Lucide name in PascalCase (Receipt, Timer, Landmark, ShieldCheck, Zap, Users). The workhorse for capabilities, benefits, modules.
|
|
147
|
+
|
|
148
|
+
GIVE IT A TITLE. A bare grid of cards with no line saying what you are looking at is the clearest way a board reads as a document rather than a page.
|
|
149
|
+
|
|
150
|
+
statBand { stats: [{ value, label, delta?: { text, tone?: "up"|"down" } }] }
|
|
151
|
+
Three or four figures on a dark panel. Use for the numbers you want remembered. value is a display string, so write "4.2 days" or "47.500 EUR", not a raw number.
|
|
152
|
+
|
|
153
|
+
split { title, body, visual, side?: "left"|"right" }
|
|
154
|
+
Text one side, chart or image the other. When you use it twice, alternate side so the page does not stack two identical rows.
|
|
155
|
+
|
|
156
|
+
steps { steps: [{ title, body? }], title?, intro? }
|
|
157
|
+
A numbered sequence joined by connectors. Only for content that really is sequential: a process, an onboarding, a workflow.
|
|
158
|
+
|
|
159
|
+
quote { quote, attribution? }
|
|
160
|
+
One statement, large, serif, on a muted panel. Use at most once. Its power is that it is the only one.
|
|
161
|
+
|
|
162
|
+
chartPanel { title, caption?, chart, chartHeight? }
|
|
163
|
+
A chart in a card with a title above and a caption below. Use when the chart IS the point, rather than supporting text.
|
|
164
|
+
|
|
165
|
+
ctaBand { headline, buttonLabel, note?, href? }
|
|
166
|
+
Accent strip with a real button. Last or near-last. Write buttonLabel as the action itself ("Open a workspace"), never "Learn more", and never append an arrow.
|
|
167
|
+
|
|
168
|
+
comparisonTable { columns: [...], rows: [[...], ...] }
|
|
169
|
+
First column is the row label. Pass an empty string as the first column heading.
|
|
170
|
+
|
|
171
|
+
timeline { events: [{ date, title, body? }] }
|
|
172
|
+
Horizontal rail with dated markers. For roadmaps and history.
|
|
173
|
+
|
|
174
|
+
logoRow { label?, items: [{ kind: "icon", iconName } | { kind: "image", src, alt? }] }
|
|
175
|
+
A quiet row of marks. Keep the label short and factual.
|
|
176
|
+
|
|
177
|
+
footerMeta { items: ["...", "..."] }
|
|
178
|
+
Hairline divider and small muted items. Sources, dates, ownership.
|
|
179
|
+
|
|
180
|
+
imageBand { visual, caption?, height? }
|
|
181
|
+
A full-width picture with an optional caption. Wide and short on purpose.
|
|
182
|
+
|
|
183
|
+
VISUALS
|
|
184
|
+
|
|
185
|
+
A visual is one of:
|
|
186
|
+
{ kind: "chart", chartType, title?, subtitle?, data, style? }
|
|
187
|
+
{ kind: "placeholder", brief }
|
|
188
|
+
{ kind: "image", src, alt? }
|
|
189
|
+
{ kind: "stock", query, orientation? }
|
|
190
|
+
|
|
191
|
+
chartType is one of bar, line, area, stacked_bar, horizontal_bar, donut, kpi, progress, gauge. Chart data matches the shape add_chart_to_whiteboard uses.
|
|
192
|
+
|
|
193
|
+
BUTTONS ARE REAL LINKS
|
|
194
|
+
|
|
195
|
+
hero takes cta: { label, href } and ctaBand takes href. Both render a button that a reader can actually click in a shared board or an export, so give them a real destination whenever one exists. Only http, https and mailto are accepted; anything else is dropped without failing the board.
|
|
196
|
+
|
|
197
|
+
End the page with a ctaBand. Closing on the action you want is what a landing page is for, and a page that just stops reads as unfinished. The only exception is a board that is genuinely a report, where there is nothing to ask for.
|
|
198
|
+
|
|
199
|
+
A hero button and a closing button pointing at the SAME destination is normal and good practice, not a duplicate. What to avoid is two DIFFERENT competing actions on one page, because then the reader has to choose and usually chooses neither.
|
|
200
|
+
|
|
201
|
+
PICTURES: PLACEHOLDER IS THE DEFAULT
|
|
202
|
+
|
|
203
|
+
When a board wants a photograph, reserve the space and write the art direction into it with { kind: "placeholder", brief }. Do NOT fetch a photo unless the user asked for real images.
|
|
204
|
+
|
|
205
|
+
The brief is a direction to whoever fills the slot, so write it like one: what is in frame, the mood or light, and the crop. \"Wide shot of a desk with paper invoices and a laptop, warm daylight, shot from above, 16:9\" is useful. \"Image here\" and \"placeholder\" are not, and neither is a brief that just repeats the section heading.
|
|
206
|
+
|
|
207
|
+
Use { kind: "stock", query } ONLY when the user asked for real photos. It fetches from Unsplash and needs UNSPLASH_ACCESS_KEY on the server; without it, or if the search finds nothing, the slot falls back to a placeholder and the result says so. Photographer credits are added to the board automatically, because the licence requires them.
|
|
208
|
+
|
|
209
|
+
Reach for a picture where one earns its place: a hero, a split, a full-width imageBand between two dense sections. A board where every section has a photo reads as a template.
|
|
210
|
+
|
|
211
|
+
COMPOSING WELL
|
|
212
|
+
|
|
213
|
+
Pick a shape for the board before you pick sections. A pitch is hero, statBand, featureGrid, split, quote, ctaBand, footerMeta. A report is hero, statBand, chartPanel, split, comparisonTable, footerMeta. A plan is hero, steps, timeline, featureGrid, ctaBand.
|
|
214
|
+
|
|
215
|
+
Note that every shape above except the report ends on ctaBand.
|
|
216
|
+
|
|
217
|
+
Six to nine sections is a page. Twelve is a document and reads as one.
|
|
218
|
+
|
|
219
|
+
Title the middle sections. A page names what each part of it is; only the hero and the closing call to action stand without a heading.
|
|
220
|
+
|
|
221
|
+
Do not repeat a section back to back. Two featureGrids in a row is the single clearest sign that a board was generated rather than composed. Put something with a different weight between them.
|
|
222
|
+
|
|
223
|
+
Write real sentences. The layout is only as good as the words in it, and placeholder copy is what makes an otherwise correct board look empty.
|
|
224
|
+
|
|
225
|
+
AFTERWARDS
|
|
226
|
+
Call render_whiteboard and look at the result. Section geometry is guaranteed; whether the board says the right thing in the right order is not.`;
|
|
227
|
+
export function registerWhiteboardComposeTools(server, client) {
|
|
228
|
+
server.tool("compose_whiteboard", DESCRIPTION, {
|
|
229
|
+
id: z.string().describe("The whiteboard UUID"),
|
|
230
|
+
sections: z
|
|
231
|
+
.array(z.object({
|
|
232
|
+
type: z
|
|
233
|
+
.enum([
|
|
234
|
+
"hero", "featureGrid", "statBand", "split", "steps", "quote",
|
|
235
|
+
"chartPanel", "ctaBand", "comparisonTable", "timeline", "logoRow", "footerMeta",
|
|
236
|
+
"imageBand",
|
|
237
|
+
])
|
|
238
|
+
.describe("Which section preset to render"),
|
|
239
|
+
content: z.any().describe("The content object for this section type"),
|
|
240
|
+
}))
|
|
241
|
+
.min(1)
|
|
242
|
+
.describe("Ordered sections, top to bottom"),
|
|
243
|
+
style: z
|
|
244
|
+
.enum(["product", "editorial", "statement", "technical"])
|
|
245
|
+
.optional()
|
|
246
|
+
.describe('The board\'s look. Pick the one that suits the subject; they are genuinely different, not four shades of one. Defaults to "product".'),
|
|
247
|
+
layout: z
|
|
248
|
+
.enum(["page", "slides"])
|
|
249
|
+
.optional()
|
|
250
|
+
.describe('"page" is one long scrolling column, "slides" splits the same sections across screen-sized pages. Ask the user which they want before calling. Defaults to "page".'),
|
|
251
|
+
page_index: z
|
|
252
|
+
.number()
|
|
253
|
+
.int()
|
|
254
|
+
.min(0)
|
|
255
|
+
.optional()
|
|
256
|
+
.describe("Which page to write to. Defaults to the first page."),
|
|
257
|
+
page_title: z.string().optional().describe("Rename the target page"),
|
|
258
|
+
column_width: z
|
|
259
|
+
.number()
|
|
260
|
+
.optional()
|
|
261
|
+
.describe("Content column width in canvas units. Defaults to 1200. Use 720 for a narrow, document-like board."),
|
|
262
|
+
append: z
|
|
263
|
+
.boolean()
|
|
264
|
+
.optional()
|
|
265
|
+
.describe("Add the sections below whatever is already on the page instead of replacing it. Defaults to false."),
|
|
266
|
+
}, async ({ id, sections, style, layout, page_index, page_title, column_width, append }) => {
|
|
267
|
+
const specs = sections;
|
|
268
|
+
const { credits, notes } = await resolveStockVisuals(specs);
|
|
269
|
+
appendCredits(specs, credits);
|
|
270
|
+
const current = await client.get(`/whiteboards/${id}`);
|
|
271
|
+
const content = normalize(current?.content);
|
|
272
|
+
const mode = layout ?? "page";
|
|
273
|
+
// Slides replace the whole board: packing sections into screens is a
|
|
274
|
+
// decision about the entire deck, not about one page of it.
|
|
275
|
+
if (mode === "slides") {
|
|
276
|
+
const slides = composeSlides(specs, {
|
|
277
|
+
...(column_width !== undefined ? { columnWidth: column_width } : {}),
|
|
278
|
+
...(style !== undefined ? { style: style } : {}),
|
|
279
|
+
});
|
|
280
|
+
content.layoutMode = "canvas";
|
|
281
|
+
// Slides step through pages rather than scrolling, but the sections
|
|
282
|
+
// are painted in the same light tokens, so the ground must not
|
|
283
|
+
// follow the reader's dark theme either.
|
|
284
|
+
content.canvasBg = "light-plain";
|
|
285
|
+
content.pages = slides.map((slide, i) => ({
|
|
286
|
+
id: `page-${Date.now()}-${i}`,
|
|
287
|
+
title: page_title ? `${page_title} ${i + 1}` : `Page ${i + 1}`,
|
|
288
|
+
elements: slide.elements,
|
|
289
|
+
layerOrder: slide.layerOrder,
|
|
290
|
+
}));
|
|
291
|
+
await client.put(`/whiteboards/${id}/content`, { content });
|
|
292
|
+
return {
|
|
293
|
+
content: [{
|
|
294
|
+
type: "text",
|
|
295
|
+
text: [
|
|
296
|
+
`Composed ${specs.length} section(s) across ${slides.length} slide(s) in the "${style ?? "product"}" style.`,
|
|
297
|
+
`Sections: ${specs.map((x) => x.type).join(", ")}.`,
|
|
298
|
+
...notes,
|
|
299
|
+
`Call render_whiteboard to look at it.`,
|
|
300
|
+
].join("\n"),
|
|
301
|
+
}],
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const index = page_index ?? 0;
|
|
305
|
+
while (content.pages.length <= index) {
|
|
306
|
+
content.pages.push({
|
|
307
|
+
id: `page-${Date.now()}-${content.pages.length}`,
|
|
308
|
+
title: `Page ${content.pages.length + 1}`,
|
|
309
|
+
elements: [],
|
|
310
|
+
layerOrder: [],
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
const page = content.pages[index];
|
|
314
|
+
const margin = append && page.elements.length
|
|
315
|
+
? contentBottom(page) + SECTION_GAP
|
|
316
|
+
: CANVAS_MARGIN;
|
|
317
|
+
const composed = composeBoard(specs, {
|
|
318
|
+
...(column_width !== undefined ? { columnWidth: column_width } : {}),
|
|
319
|
+
...(style !== undefined ? { style: style } : {}),
|
|
320
|
+
margin,
|
|
321
|
+
});
|
|
322
|
+
// margin doubles as the left inset, so an appended stack would drift
|
|
323
|
+
// right. Pull it back to the standard column position.
|
|
324
|
+
if (margin !== CANVAS_MARGIN) {
|
|
325
|
+
for (const el of composed.elements) {
|
|
326
|
+
el.x = el.x - margin + CANVAS_MARGIN;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (append) {
|
|
330
|
+
page.elements = [...page.elements, ...composed.elements];
|
|
331
|
+
page.layerOrder = [...(page.layerOrder ?? []), ...composed.layerOrder];
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
page.elements = composed.elements;
|
|
335
|
+
page.layerOrder = composed.layerOrder;
|
|
336
|
+
}
|
|
337
|
+
if (page_title)
|
|
338
|
+
page.title = page_title;
|
|
339
|
+
// Shared views read this to scroll vertically only, like a web page.
|
|
340
|
+
content.layoutMode = "page";
|
|
341
|
+
// Compose the same sections again for a phone. Only when replacing:
|
|
342
|
+
// appending onto an existing page means the narrow variant no longer
|
|
343
|
+
// describes the whole board, and a half-right variant is worse than
|
|
344
|
+
// none, because the viewer would show it in preference to the real one.
|
|
345
|
+
if (!append) {
|
|
346
|
+
const phone = composeNarrow(specs, {
|
|
347
|
+
...(style !== undefined ? { style: style } : {}),
|
|
348
|
+
});
|
|
349
|
+
content.variants = {
|
|
350
|
+
...(content.variants ?? {}),
|
|
351
|
+
narrow: {
|
|
352
|
+
width: phone.width,
|
|
353
|
+
height: phone.height,
|
|
354
|
+
elements: phone.elements,
|
|
355
|
+
layerOrder: phone.layerOrder,
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
else if (content.variants?.narrow) {
|
|
360
|
+
delete content.variants.narrow;
|
|
361
|
+
}
|
|
362
|
+
// The sections are painted in light tokens, so the board carries a
|
|
363
|
+
// light ground rather than inheriting the reader's dark theme.
|
|
364
|
+
content.canvasBg = "light-plain";
|
|
365
|
+
await client.put(`/whiteboards/${id}/content`, { content });
|
|
366
|
+
return {
|
|
367
|
+
content: [{
|
|
368
|
+
type: "text",
|
|
369
|
+
text: [
|
|
370
|
+
`Composed ${specs.length} section(s) onto page ${index + 1} as one scrolling page in the "${style ?? "product"}" style.`,
|
|
371
|
+
`${composed.elements.length} elements, ${composed.width} wide, ${composed.height} tall.`,
|
|
372
|
+
append
|
|
373
|
+
? `Appended, so the phone layout was dropped: it can only describe a whole board.`
|
|
374
|
+
: `A phone layout was composed alongside it, so a shared link is readable on mobile.`,
|
|
375
|
+
`Sections: ${specs.map((x) => x.type).join(", ")}.`,
|
|
376
|
+
...notes,
|
|
377
|
+
`Call render_whiteboard to look at it.`,
|
|
378
|
+
].join("\n"),
|
|
379
|
+
}],
|
|
380
|
+
};
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
//# sourceMappingURL=whiteboard-compose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whiteboard-compose.js","sourceRoot":"","sources":["../../../src/tools/whiteboard-compose.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,GAEd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,gBAA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,EACjB,MAAM,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"whiteboards.d.ts","sourceRoot":"","sources":["../../../src/tools/whiteboards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,aAAa,QAmetB"}
|
|
@@ -14,7 +14,7 @@ export function registerWhiteboardTools(server, client) {
|
|
|
14
14
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
15
15
|
};
|
|
16
16
|
});
|
|
17
|
-
server.tool("create_whiteboard", "Create a new whiteboard.", {
|
|
17
|
+
server.tool("create_whiteboard", "Create a new whiteboard. To fill it with something meant to be read, follow up with compose_whiteboard rather than placing elements by hand.", {
|
|
18
18
|
name: z.string().describe("Whiteboard name"),
|
|
19
19
|
project_id: z.string().optional().describe("Project UUID (for project-scoped whiteboards)"),
|
|
20
20
|
}, async ({ name, ...rest }) => {
|
|
@@ -54,7 +54,11 @@ export function registerWhiteboardTools(server, client) {
|
|
|
54
54
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
55
55
|
};
|
|
56
56
|
});
|
|
57
|
-
server.tool("set_whiteboard_content", `
|
|
57
|
+
server.tool("set_whiteboard_content", `START HERE: if the board is meant to be READ — a pitch, a report, an overview, a plan, a summary, anything with a top and a bottom — use compose_whiteboard instead. It lays out landing-page-quality sections and owns every coordinate, so alignment, spacing and type hierarchy are correct by construction. Placing elements by hand is what makes a board look machine-made.
|
|
58
|
+
|
|
59
|
+
Use THIS tool only for freeform work where position carries meaning: diagrams, flowcharts, org charts, maps, mind maps, annotating an existing canvas.
|
|
60
|
+
|
|
61
|
+
Set the full content of a whiteboard with precisely positioned elements. Use this to draw diagrams, org charts, flowcharts, timelines, or any complex visual layout.
|
|
58
62
|
|
|
59
63
|
ELEMENT TYPES: rectangle, ellipse, triangle, text, sticky_note, line, arrow, connector, frame
|
|
60
64
|
|
|
@@ -65,7 +69,65 @@ For connector: set fromElementId, toElementId with anchor points (top/right/bott
|
|
|
65
69
|
Content must be v2 multi-page format:
|
|
66
70
|
{ "version": 2, "pages": [{ "id": "page-uuid", "title": "Page 1", "elements": [...], "layerOrder": ["id1","id2"] }], "boardElements": [...optional...], "boardLayerOrder": [...optional...] }
|
|
67
71
|
|
|
68
|
-
OPTIONAL boardElements + boardLayerOrder render an element on EVERY page (Looker Studio "report level"). Use for footers, watermarks, persistent legends. Same element shape as page elements. The dVersum UI shows a green pin badge on these
|
|
72
|
+
OPTIONAL boardElements + boardLayerOrder render an element on EVERY page (Looker Studio "report level"). Use for footers, watermarks, persistent legends. Same element shape as page elements. The dVersum UI shows a green pin badge on these.\n\nAfter changing a board, call render_whiteboard to look at the result and fix spacing or overlaps before reporting back.
|
|
73
|
+
|
|
74
|
+
DESIGN BRIEF — read before placing anything.
|
|
75
|
+
|
|
76
|
+
A board that reads as machine-made has these tells: a row of five identical
|
|
77
|
+
boxes, every card the same size, one column running top to bottom, a flat
|
|
78
|
+
invented colour used at full strength, and prose stuffed into rectangles.
|
|
79
|
+
Avoid all of them.
|
|
80
|
+
|
|
81
|
+
Compose, do not fill a grid:
|
|
82
|
+
- Decide the ONE thing the reader must take away and make it visually
|
|
83
|
+
dominant: bigger, or alone in its own space, or the only thing carrying
|
|
84
|
+
an accent colour. Everything else supports it.
|
|
85
|
+
- Vary size deliberately. Equal weight everywhere means no hierarchy and
|
|
86
|
+
the eye has nowhere to land.
|
|
87
|
+
- Leave real whitespace. Crowding is what makes a board feel generated.
|
|
88
|
+
- Align to a small number of x positions and gutters. Ragged edges and
|
|
89
|
+
near-misses read as sloppy.
|
|
90
|
+
|
|
91
|
+
Use the whole vocabulary, not just rectangles and text:
|
|
92
|
+
- icon Lucide glyphs (PascalCase: TrendingDown, AlertTriangle, Package,
|
|
93
|
+
Truck, Percent, Target, ShoppingCart). One icon next to a
|
|
94
|
+
heading or a KPI does more than another box.
|
|
95
|
+
- connector Draw the actual relationship between two elements: cause to
|
|
96
|
+
effect, step to step, problem to fix. A board with no
|
|
97
|
+
connectors is a list, not a diagram.
|
|
98
|
+
- chart Any number that has a comparison, a trend or a target belongs
|
|
99
|
+
in a chart (kpi, progress, gauge, bar, line, donut), not in a
|
|
100
|
+
rectangle with a big font size.
|
|
101
|
+
- frame Group related elements and label the group, instead of
|
|
102
|
+
repeating a heading above every card.
|
|
103
|
+
- table Real tabular data. Never fake a table out of rectangles.
|
|
104
|
+
- image Logos and pictures; crop them rather than resizing to fit.
|
|
105
|
+
- sticky_note Short human notes and open questions, not body copy.
|
|
106
|
+
|
|
107
|
+
Colour, with restraint:
|
|
108
|
+
- Brand accent #45e59f (darker #2bc97e). Canvas ink #0c1f16.
|
|
109
|
+
- At most two accents on a board, and reserve the strongest for the focal
|
|
110
|
+
point. Semantic use only: red #ef4444 for a real problem, amber #eab308
|
|
111
|
+
for a warning, green for the good case.
|
|
112
|
+
- Sticky pastels: yellow #fef08a, pink #fbcfe8, blue #bfdbfe, green
|
|
113
|
+
#bbf7d0, purple #ddd6fe, orange #fed7aa.
|
|
114
|
+
- Do not paint five blocks the same saturated colour. Tint the surface and
|
|
115
|
+
let type and icons carry the meaning.
|
|
116
|
+
|
|
117
|
+
Depth:
|
|
118
|
+
- shadow on the focal element only, soft, e.g. { x: 0, y: 6, blur: 18,
|
|
119
|
+
color: "#0c1f16", opacity: 0.18 }. A shadow on everything is a shadow on
|
|
120
|
+
nothing.
|
|
121
|
+
|
|
122
|
+
Then LOOK at it: call render_whiteboard, judge the image the way a designer
|
|
123
|
+
would, and fix what is wrong before reporting back. Spacing, alignment,
|
|
124
|
+
hierarchy and colour restraint are all visible in the render and almost
|
|
125
|
+
never right on the first attempt.
|
|
126
|
+
|
|
127
|
+
Optional on ANY element except text:
|
|
128
|
+
- shadow: { x, y, blur, color, opacity } — a real drop shadow, e.g. { x: 0, y: 6, blur: 18, color: "#0c1f16", opacity: 0.25 }. Use it sparingly to lift cards off the canvas; it survives PNG/PDF/SVG export.
|
|
129
|
+
Optional on image only:
|
|
130
|
+
- crop: { x, y, width, height } as FRACTIONS of the source, 0..1 — e.g. { x: 0.25, y: 0, width: 0.5, height: 1 } shows the middle half. Non-destructive; the file is never re-encoded.`, {
|
|
69
131
|
id: z.string().describe("The whiteboard UUID"),
|
|
70
132
|
content: z.any().describe("Full whiteboard content in v2 multi-page JSON format"),
|
|
71
133
|
}, async ({ id, content }) => {
|
|
@@ -103,7 +165,7 @@ DATA SHAPES (must match chart_type):
|
|
|
103
165
|
- kpi: data = { value: 245000, delta: 26200, deltaPercent: 12, deltaLabel: "vs. Vorjahr" }
|
|
104
166
|
- progress: data = { value: 75000, max: 100000, label: "Q3-Ziel" }
|
|
105
167
|
|
|
106
|
-
For monetary values set style.format="currency" + style.currency="EUR". Position defaults to "below existing content".`, {
|
|
168
|
+
For monetary values set style.format="currency" + style.currency="EUR". Position defaults to "below existing content".\n\nAfter changing a board, call render_whiteboard to look at the result and fix spacing or overlaps before reporting back.`, {
|
|
107
169
|
whiteboard_id: z.string().describe("The whiteboard UUID"),
|
|
108
170
|
chart_type: z.enum(["bar", "line", "donut", "kpi", "progress", "area", "stacked_bar", "horizontal_bar", "gauge"]).describe("Which chart visual to render"),
|
|
109
171
|
title: z.string().optional().describe("Headline shown above the chart"),
|
|
@@ -135,7 +197,7 @@ For monetary values set style.format="currency" + style.currency="EUR". Position
|
|
|
135
197
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
136
198
|
};
|
|
137
199
|
});
|
|
138
|
-
server.tool("add_charts_to_whiteboard", `Bulk variant of add_chart_to_whiteboard — adds N charts in ONE call. PREFER this when adding 2+ charts to the same whiteboard. Each item in 'charts' uses the same schema as add_chart_to_whiteboard (minus whiteboard_id). Auto-stacks below existing content.`, {
|
|
200
|
+
server.tool("add_charts_to_whiteboard", `Bulk variant of add_chart_to_whiteboard — adds N charts in ONE call. PREFER this when adding 2+ charts to the same whiteboard. Each item in 'charts' uses the same schema as add_chart_to_whiteboard (minus whiteboard_id). Auto-stacks below existing content.\n\nAfter changing a board, call render_whiteboard to look at the result and fix spacing or overlaps before reporting back.`, {
|
|
139
201
|
whiteboard_id: z.string().describe("The whiteboard UUID"),
|
|
140
202
|
charts: z
|
|
141
203
|
.array(z.object({
|
|
@@ -171,7 +233,11 @@ For monetary values set style.format="currency" + style.currency="EUR". Position
|
|
|
171
233
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
172
234
|
};
|
|
173
235
|
});
|
|
174
|
-
server.tool("add_elements_to_whiteboard", `
|
|
236
|
+
server.tool("add_elements_to_whiteboard", `START HERE: if the board is meant to be READ — a pitch, a report, an overview, a plan, a summary, anything with a top and a bottom — use compose_whiteboard instead. It lays out landing-page-quality sections and owns every coordinate, so alignment, spacing and type hierarchy are correct by construction. Placing elements by hand is what makes a board look machine-made.
|
|
237
|
+
|
|
238
|
+
Use THIS tool only for freeform work where position carries meaning: diagrams, flowcharts, org charts, maps, mind maps, annotating an existing canvas.
|
|
239
|
+
|
|
240
|
+
Bulk-add ANY mix of whiteboard elements in ONE call — text, sticky_note, rectangle, ellipse, triangle, line, arrow, connector, frame, table, icon, image, chart. This is the catch-all for building comprehensive dashboards from MCP without making N separate calls or overwriting the whole board with set_whiteboard_content.
|
|
175
241
|
|
|
176
242
|
Per-element required fields by type:
|
|
177
243
|
- text: { type, x, y, width, height, text, fontSize, fontWeight?, color?, textAlign? }
|
|
@@ -186,9 +252,67 @@ Per-element required fields by type:
|
|
|
186
252
|
- chart: { type, x, y, width, height, chartType, data, style, title?, subtitle? }
|
|
187
253
|
(chartType: bar | line | donut | kpi | progress | area | stacked_bar | horizontal_bar | gauge)
|
|
188
254
|
|
|
255
|
+
DESIGN BRIEF — read before placing anything.
|
|
256
|
+
|
|
257
|
+
A board that reads as machine-made has these tells: a row of five identical
|
|
258
|
+
boxes, every card the same size, one column running top to bottom, a flat
|
|
259
|
+
invented colour used at full strength, and prose stuffed into rectangles.
|
|
260
|
+
Avoid all of them.
|
|
261
|
+
|
|
262
|
+
Compose, do not fill a grid:
|
|
263
|
+
- Decide the ONE thing the reader must take away and make it visually
|
|
264
|
+
dominant: bigger, or alone in its own space, or the only thing carrying
|
|
265
|
+
an accent colour. Everything else supports it.
|
|
266
|
+
- Vary size deliberately. Equal weight everywhere means no hierarchy and
|
|
267
|
+
the eye has nowhere to land.
|
|
268
|
+
- Leave real whitespace. Crowding is what makes a board feel generated.
|
|
269
|
+
- Align to a small number of x positions and gutters. Ragged edges and
|
|
270
|
+
near-misses read as sloppy.
|
|
271
|
+
|
|
272
|
+
Use the whole vocabulary, not just rectangles and text:
|
|
273
|
+
- icon Lucide glyphs (PascalCase: TrendingDown, AlertTriangle, Package,
|
|
274
|
+
Truck, Percent, Target, ShoppingCart). One icon next to a
|
|
275
|
+
heading or a KPI does more than another box.
|
|
276
|
+
- connector Draw the actual relationship between two elements: cause to
|
|
277
|
+
effect, step to step, problem to fix. A board with no
|
|
278
|
+
connectors is a list, not a diagram.
|
|
279
|
+
- chart Any number that has a comparison, a trend or a target belongs
|
|
280
|
+
in a chart (kpi, progress, gauge, bar, line, donut), not in a
|
|
281
|
+
rectangle with a big font size.
|
|
282
|
+
- frame Group related elements and label the group, instead of
|
|
283
|
+
repeating a heading above every card.
|
|
284
|
+
- table Real tabular data. Never fake a table out of rectangles.
|
|
285
|
+
- image Logos and pictures; crop them rather than resizing to fit.
|
|
286
|
+
- sticky_note Short human notes and open questions, not body copy.
|
|
287
|
+
|
|
288
|
+
Colour, with restraint:
|
|
289
|
+
- Brand accent #45e59f (darker #2bc97e). Canvas ink #0c1f16.
|
|
290
|
+
- At most two accents on a board, and reserve the strongest for the focal
|
|
291
|
+
point. Semantic use only: red #ef4444 for a real problem, amber #eab308
|
|
292
|
+
for a warning, green for the good case.
|
|
293
|
+
- Sticky pastels: yellow #fef08a, pink #fbcfe8, blue #bfdbfe, green
|
|
294
|
+
#bbf7d0, purple #ddd6fe, orange #fed7aa.
|
|
295
|
+
- Do not paint five blocks the same saturated colour. Tint the surface and
|
|
296
|
+
let type and icons carry the meaning.
|
|
297
|
+
|
|
298
|
+
Depth:
|
|
299
|
+
- shadow on the focal element only, soft, e.g. { x: 0, y: 6, blur: 18,
|
|
300
|
+
color: "#0c1f16", opacity: 0.18 }. A shadow on everything is a shadow on
|
|
301
|
+
nothing.
|
|
302
|
+
|
|
303
|
+
Then LOOK at it: call render_whiteboard, judge the image the way a designer
|
|
304
|
+
would, and fix what is wrong before reporting back. Spacing, alignment,
|
|
305
|
+
hierarchy and colour restraint are all visible in the render and almost
|
|
306
|
+
never right on the first attempt.
|
|
307
|
+
|
|
308
|
+
Optional on ANY element except text:
|
|
309
|
+
- shadow: { x, y, blur, color, opacity } — a real drop shadow, e.g. { x: 0, y: 6, blur: 18, color: "#0c1f16", opacity: 0.25 }. Use it sparingly to lift cards off the canvas; it survives PNG/PDF/SVG export.
|
|
310
|
+
Optional on image only:
|
|
311
|
+
- crop: { x, y, width, height } as FRACTIONS of the source, 0..1 — e.g. { x: 0.25, y: 0, width: 0.5, height: 1 } shows the middle half. Non-destructive; the file is never re-encoded.
|
|
312
|
+
|
|
189
313
|
System fills in: id (UUID), zIndex, rotation 0, opacity 1, locked false.
|
|
190
314
|
|
|
191
|
-
For a fully branded multi-page dashboard, prefer create_whiteboard_from_template first, then use this tool to layer extra elements on top.`, {
|
|
315
|
+
For a fully branded multi-page dashboard, prefer create_whiteboard_from_template first, then use this tool to layer extra elements on top.\n\nAfter changing a board, call render_whiteboard to look at the result and fix spacing or overlaps before reporting back.`, {
|
|
192
316
|
whiteboard_id: z.string().describe("The whiteboard UUID"),
|
|
193
317
|
elements: z.array(z.record(z.any())).min(1).describe("Array of element JSON. Each must have a 'type' field."),
|
|
194
318
|
}, async ({ whiteboard_id, elements }) => {
|
|
@@ -229,6 +353,25 @@ For a fully branded multi-page dashboard, prefer create_whiteboard_from_template
|
|
|
229
353
|
const data = await client.post(`/report-templates/${template_id}/instantiate`, { vars: vars || {} });
|
|
230
354
|
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
231
355
|
});
|
|
356
|
+
server.tool("render_whiteboard", `Render one page of a whiteboard to a PNG and return the image, so you can SEE what you built. Call this after composing or changing a board, look at the result, and fix what is wrong: elements overlapping, cramped or uneven spacing, columns that do not line up, text that wraps badly, charts too small to read. Repeat until the page looks like something you would hand to a client.`, {
|
|
357
|
+
id: z.string().describe("The whiteboard UUID"),
|
|
358
|
+
page: z.number().int().min(0).optional().describe("0-based page index (default 0)"),
|
|
359
|
+
scale: z.number().min(1).max(3).optional().describe("Resolution multiplier, 1-3 (default 1)"),
|
|
360
|
+
}, async ({ id, page = 0, scale = 1 }) => {
|
|
361
|
+
const { bytes, contentType, headers } = await client.postBinary(`/whiteboards/${id}/render`, { page, format: "png", scale, background: "light" });
|
|
362
|
+
const pageCount = headers.get("x-whiteboard-pages") ?? "?";
|
|
363
|
+
const width = headers.get("x-render-width") ?? "?";
|
|
364
|
+
const height = headers.get("x-render-height") ?? "?";
|
|
365
|
+
return {
|
|
366
|
+
content: [
|
|
367
|
+
{ type: "image", data: bytes.toString("base64"), mimeType: contentType },
|
|
368
|
+
{
|
|
369
|
+
type: "text",
|
|
370
|
+
text: `Page ${page + 1} of ${pageCount} — ${width}x${height}px`,
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
};
|
|
374
|
+
});
|
|
232
375
|
server.tool("import_excalidraw", "Import an Excalidraw JSON file or clipboard data as a new whiteboard. Converts Excalidraw elements (rectangles, ellipses, text, arrows, lines) to dVersum whiteboard format.", {
|
|
233
376
|
title: z.string().optional().describe("Whiteboard title (default: 'Imported from Excalidraw')"),
|
|
234
377
|
excalidraw_data: z.any().describe("Excalidraw JSON data (clipboard format or file format with 'elements' array)"),
|