@centrali-io/centrali-mcp 7.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { CentraliSDK } from "@centrali-io/centrali-sdk";
3
- export declare function registerPageTools(server: McpServer, sdk: CentraliSDK, centraliUrl: string, workspaceId: string): void;
@@ -1,512 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.registerPageTools = registerPageTools;
16
- const zod_1 = require("zod");
17
- const _register_js_1 = require("./_register.js");
18
- const axios_1 = __importDefault(require("axios"));
19
- /**
20
- * Derives the pages API base URL from the CENTRALI_URL.
21
- * Pattern: https://centrali.io -> https://api.centrali.io/pages
22
- * Or uses CENTRALI_PAGES_URL env var if explicitly set.
23
- */
24
- function getPagesBaseUrl(centraliUrl) {
25
- const override = process.env.CENTRALI_PAGES_URL;
26
- if (override)
27
- return override.replace(/\/$/, "");
28
- const url = new URL(centraliUrl);
29
- const hostname = url.hostname.startsWith("api.")
30
- ? url.hostname
31
- : `api.${url.hostname}`;
32
- return `${url.protocol}//${hostname}/pages`;
33
- }
34
- /**
35
- * Ensures the SDK has a valid token by making a lightweight SDK call.
36
- * The SDK's internal axios interceptor handles client-credentials token
37
- * fetch and 401 refresh automatically — we just need to trigger it.
38
- */
39
- function ensureToken(sdk) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- let token = sdk.getToken();
42
- if (token)
43
- return token;
44
- // Token not yet fetched — trigger the SDK's internal auth flow
45
- // by making a lightweight call. The SDK will fetch and cache the token.
46
- try {
47
- yield sdk.functions.list({ limit: 1 });
48
- }
49
- catch (_a) {
50
- // Ignore errors — we only need the token refresh side effect
51
- }
52
- return sdk.getToken();
53
- });
54
- }
55
- /**
56
- * Creates an axios instance for the pages API that uses the SDK's token.
57
- * Auth is handled through the SDK's public getToken() API — no internal casting.
58
- */
59
- function createPagesClient(sdk, centraliUrl, workspaceId) {
60
- const baseURL = getPagesBaseUrl(centraliUrl);
61
- const client = axios_1.default.create({ baseURL, proxy: false });
62
- // Attach the SDK's bearer token to every request
63
- client.interceptors.request.use((config) => __awaiter(this, void 0, void 0, function* () {
64
- const token = yield ensureToken(sdk);
65
- if (token) {
66
- config.headers.Authorization = `Bearer ${token}`;
67
- }
68
- return config;
69
- }));
70
- // Retry on 401/403 after refreshing the token via the SDK
71
- client.interceptors.response.use((response) => response, (error) => __awaiter(this, void 0, void 0, function* () {
72
- var _a, _b;
73
- const originalRequest = error.config;
74
- const isAuthError = ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 || ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 403;
75
- if (isAuthError && !originalRequest._hasRetried) {
76
- originalRequest._hasRetried = true;
77
- // Force a fresh token by making an SDK call (triggers internal 401 refresh)
78
- try {
79
- yield sdk.functions.list({ limit: 1 });
80
- }
81
- catch (_c) {
82
- // Ignore — we only need the token refresh side effect
83
- }
84
- const token = sdk.getToken();
85
- if (token) {
86
- originalRequest.headers.Authorization = `Bearer ${token}`;
87
- return client.request(originalRequest);
88
- }
89
- }
90
- return Promise.reject(error);
91
- }));
92
- return { client, workspaceId };
93
- }
94
- function registerPageTools(server, sdk, centraliUrl, workspaceId) {
95
- const { client } = createPagesClient(sdk, centraliUrl, workspaceId);
96
- const basePath = `/ws/${workspaceId}/api/v1/pages`;
97
- // ── Page CRUD ──────────────────────────────────────────────────────
98
- (0, _register_js_1.registerTool)(server, "list_pages", "List all pages in the workspace. Pages are pre-built UI views (lists, detail views, forms, dashboards) that surface data from collections.", {
99
- page: zod_1.z.number().optional().describe("Page number (1-indexed, default: 1)"),
100
- pageSize: zod_1.z.number().optional().describe("Items per page (default: 20)"),
101
- pageType: zod_1.z
102
- .enum(["list", "detail", "form", "dashboard"])
103
- .optional()
104
- .describe("Filter by page type"),
105
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ page, pageSize, pageType }) {
106
- try {
107
- const params = {};
108
- if (page !== undefined)
109
- params.page = page;
110
- if (pageSize !== undefined)
111
- params.pageSize = pageSize;
112
- if (pageType)
113
- params.pageType = pageType;
114
- const resp = yield client.get(basePath, { params });
115
- return {
116
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
117
- };
118
- }
119
- catch (error) {
120
- return {
121
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "listing pages") }],
122
- isError: true,
123
- };
124
- }
125
- }));
126
- (0, _register_js_1.registerTool)(server, "get_page", "Get a page by its ID. Returns the page metadata including name, slug, type, and description.", {
127
- pageId: zod_1.z.string().describe("The page ID (UUID)"),
128
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId }) {
129
- try {
130
- const resp = yield client.get(`${basePath}/${pageId}`);
131
- return {
132
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
133
- };
134
- }
135
- catch (error) {
136
- return {
137
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `getting page '${pageId}'`) }],
138
- isError: true,
139
- };
140
- }
141
- }));
142
- (0, _register_js_1.registerTool)(server, "create_page", `Create a new page in the workspace. A page is a UI view backed by data from collections. Specify the page type: 'list' for data tables, 'detail' for single-record views, 'form' for data entry, 'dashboard' for metrics and charts.
143
-
144
- Navigate-to-page actions can use config.useQueryParams: true to pass selected row fields as URL query params to the target page. Pair with paramConfig: { source: 'row', mode: 'selected', selectedFields: ['id'] } to control which fields are passed. Use config.paramMapping: { sourceField: 'targetParam' } to rename fields in the URL (e.g., { requestId: 'id' } passes ?id=<value> instead of ?requestId=<value>). The target detail page can then use variable bindings with { source: 'url', param: 'id' } to read those params.`, {
145
- name: zod_1.z.string().describe("Display name for the page (e.g., 'Customer List')"),
146
- slug: zod_1.z.string().describe("URL-safe slug (e.g., 'customer-list')"),
147
- pageType: zod_1.z
148
- .enum(["list", "detail", "form", "dashboard"])
149
- .describe("The type of page to create"),
150
- description: zod_1.z.string().optional().describe("Optional description of the page's purpose"),
151
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ name, slug, pageType, description }) {
152
- try {
153
- const resp = yield client.post(basePath, { name, slug, pageType, description });
154
- return {
155
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
156
- };
157
- }
158
- catch (error) {
159
- return {
160
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "creating page") }],
161
- isError: true,
162
- };
163
- }
164
- }));
165
- (0, _register_js_1.registerTool)(server, "update_page", "Update a page's metadata (name, slug, description). Does not modify the page definition — use save_page_draft for that.", {
166
- pageId: zod_1.z.string().describe("The page ID (UUID) to update"),
167
- name: zod_1.z.string().optional().describe("New display name"),
168
- slug: zod_1.z.string().optional().describe("New URL slug"),
169
- description: zod_1.z.string().optional().describe("New description"),
170
- showInNavShell: zod_1.z.boolean().optional().describe("Whether to show this page in the navigation shell"),
171
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId, name, slug, description, showInNavShell }) {
172
- try {
173
- const body = {};
174
- if (name !== undefined)
175
- body.name = name;
176
- if (slug !== undefined)
177
- body.slug = slug;
178
- if (description !== undefined)
179
- body.description = description;
180
- if (showInNavShell !== undefined)
181
- body.showInNavShell = showInNavShell;
182
- const resp = yield client.patch(`${basePath}/${pageId}`, body);
183
- return {
184
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
185
- };
186
- }
187
- catch (error) {
188
- return {
189
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `updating page '${pageId}'`) }],
190
- isError: true,
191
- };
192
- }
193
- }));
194
- (0, _register_js_1.registerTool)(server, "delete_page", "Soft-delete a page by its ID. The page will no longer be accessible but can potentially be restored.", {
195
- pageId: zod_1.z.string().describe("The page ID (UUID) to delete"),
196
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId }) {
197
- try {
198
- yield client.delete(`${basePath}/${pageId}`);
199
- return {
200
- content: [{ type: "text", text: `Page '${pageId}' deleted successfully.` }],
201
- };
202
- }
203
- catch (error) {
204
- return {
205
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `deleting page '${pageId}'`) }],
206
- isError: true,
207
- };
208
- }
209
- }));
210
- // ── Drafts & Versions ─────────────────────────────────────────────
211
- (0, _register_js_1.registerTool)(server, "save_page_draft", `Save or update the draft definition for a page. The definition describes the page's layout: sections, blocks, data sources, actions, and presentation. This does NOT publish the page — use publish_page after saving.
212
-
213
- Each block's dataSource can include an optional 'variables' map for runtime variable binding:
214
- variables: { [varName]: { source, param?, field?, value? } }
215
-
216
- Variable binding sources:
217
- - { source: 'url', param: 'id' } — read from URL query param
218
- - { source: 'auth', field: 'userId' | 'email' | 'name' } — from authenticated user
219
- - { source: 'record', field: 'fieldName' } — from page's primary record (detail pages)
220
- - { source: 'static', value: 'active' } — literal default value
221
-
222
- For query data sources: variables substitute into smart query {{placeholders}}.
223
- For structure data sources: variables become equality filters. IMPORTANT: variable name 'id' is special — it fetches the record BY its system UUID. All other variable names filter against data.<fieldName> in the JSONB column (e.g., variable 'requestId' → filters on data.requestId). Reference fields between collections store system UUIDs.
224
-
225
- Common patterns:
226
- - Detail page primary record: { id: { source: 'url', param: 'id' } } — fetches single record by system ID
227
- - Detail page related list: { requestId: { source: 'url', param: 'id' } } — filters where data.requestId = URL param
228
- - User-scoped view: { assigneeId: { source: 'auth', field: 'userId' } }
229
- - Navigate with params: action config { useQueryParams: true } + paramConfig { source: 'row', mode: 'selected', selectedFields: ['id'] }
230
- - Rename params: action config { useQueryParams: true, paramMapping: { requestId: 'id' } } — passes ?id=<value> instead of ?requestId=<value>`, {
231
- pageId: zod_1.z.string().describe("The page ID (UUID)"),
232
- definition: zod_1.z
233
- .record(zod_1.z.string(), zod_1.z.any())
234
- .describe("The page definition object containing sections with blocks. Each section has: id, kind (content|metrics|exceptions|actions|hero|supporting), title, layout (single-column|two-column|metric-strip|stack), and blocks array."),
235
- changeSummary: zod_1.z.string().optional().describe("Summary of changes in this draft"),
236
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId, definition, changeSummary }) {
237
- try {
238
- const body = { definition };
239
- if (changeSummary)
240
- body.changeSummary = changeSummary;
241
- const resp = yield client.put(`${basePath}/${pageId}/draft`, body);
242
- return {
243
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
244
- };
245
- }
246
- catch (error) {
247
- return {
248
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `saving draft for page '${pageId}'`) }],
249
- isError: true,
250
- };
251
- }
252
- }));
253
- (0, _register_js_1.registerTool)(server, "get_page_draft", "Get the current draft version of a page, including its full definition (sections, blocks, data sources).", {
254
- pageId: zod_1.z.string().describe("The page ID (UUID)"),
255
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId }) {
256
- try {
257
- const resp = yield client.get(`${basePath}/${pageId}/draft`);
258
- return {
259
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
260
- };
261
- }
262
- catch (error) {
263
- return {
264
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `getting draft for page '${pageId}'`) }],
265
- isError: true,
266
- };
267
- }
268
- }));
269
- (0, _register_js_1.registerTool)(server, "list_page_versions", "List all versions of a page. Each version captures a snapshot of the page definition at a point in time.", {
270
- pageId: zod_1.z.string().describe("The page ID (UUID)"),
271
- page: zod_1.z.number().optional().describe("Page number (1-indexed, default: 1)"),
272
- pageSize: zod_1.z.number().optional().describe("Items per page (default: 20)"),
273
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId, page, pageSize }) {
274
- try {
275
- const params = {};
276
- if (page !== undefined)
277
- params.page = page;
278
- if (pageSize !== undefined)
279
- params.pageSize = pageSize;
280
- const resp = yield client.get(`${basePath}/${pageId}/versions`, { params });
281
- return {
282
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
283
- };
284
- }
285
- catch (error) {
286
- return {
287
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `listing versions for page '${pageId}'`) }],
288
- isError: true,
289
- };
290
- }
291
- }));
292
- // ── Publishing ────────────────────────────────────────────────────
293
- (0, _register_js_1.registerTool)(server, "validate_page", "Run validation checks on a page's current draft to determine if it is ready to publish. Returns a list of issues (errors and warnings) that must be resolved before publishing.", {
294
- pageId: zod_1.z.string().describe("The page ID (UUID) to validate"),
295
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId }) {
296
- try {
297
- const resp = yield client.post(`${basePath}/${pageId}/validate`);
298
- return {
299
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
300
- };
301
- }
302
- catch (error) {
303
- return {
304
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `validating page '${pageId}'`) }],
305
- isError: true,
306
- };
307
- }
308
- }));
309
- (0, _register_js_1.registerTool)(server, "publish_page", "Publish the current draft of a page, making it accessible at its runtime URL. Validates the draft first — if there are errors, publishing is rejected with details. Returns the publication record and the public runtime URL.", {
310
- pageId: zod_1.z.string().describe("The page ID (UUID) to publish"),
311
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId }) {
312
- try {
313
- const resp = yield client.post(`${basePath}/${pageId}/publish`);
314
- return {
315
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
316
- };
317
- }
318
- catch (error) {
319
- return {
320
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `publishing page '${pageId}'`) }],
321
- isError: true,
322
- };
323
- }
324
- }));
325
- (0, _register_js_1.registerTool)(server, "unpublish_page", "Unpublish a page, making it no longer accessible at its runtime URL. The page definition is preserved and can be re-published later.", {
326
- pageId: zod_1.z.string().describe("The page ID (UUID) to unpublish"),
327
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId }) {
328
- try {
329
- const resp = yield client.post(`${basePath}/${pageId}/unpublish`);
330
- return {
331
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
332
- };
333
- }
334
- catch (error) {
335
- return {
336
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `unpublishing page '${pageId}'`) }],
337
- isError: true,
338
- };
339
- }
340
- }));
341
- // ── Access Policy ─────────────────────────────────────────────────
342
- (0, _register_js_1.registerTool)(server, "set_page_access_policy", "Set the access policy for a page. Controls who can view the published page: 'public' (anyone), 'authenticated' (logged-in users), or 'role-gated' (users with specific roles).", {
343
- pageId: zod_1.z.string().describe("The page ID (UUID)"),
344
- accessMode: zod_1.z
345
- .enum(["public", "authenticated", "role-gated"])
346
- .describe("Access control mode"),
347
- requiredRoles: zod_1.z
348
- .array(zod_1.z.string())
349
- .optional()
350
- .describe("Required roles (only used when accessMode is 'role-gated')"),
351
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ pageId, accessMode, requiredRoles }) {
352
- try {
353
- const body = { accessMode };
354
- if (requiredRoles)
355
- body.requiredRoles = requiredRoles;
356
- const resp = yield client.put(`${basePath}/${pageId}/access-policy`, body);
357
- return {
358
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
359
- };
360
- }
361
- catch (error) {
362
- return {
363
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, `setting access policy for page '${pageId}'`) }],
364
- isError: true,
365
- };
366
- }
367
- }));
368
- // ── Theme ─────────────────────────────────────────────────────────
369
- (0, _register_js_1.registerTool)(server, "get_page_theme", "Get the workspace theme configuration used by published pages. Includes primary color, accent color, optional logo URL, and font family.", {}, () => __awaiter(this, void 0, void 0, function* () {
370
- try {
371
- const resp = yield client.get(`${basePath}/theme`);
372
- return {
373
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
374
- };
375
- }
376
- catch (error) {
377
- return {
378
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "getting page theme") }],
379
- isError: true,
380
- };
381
- }
382
- }));
383
- (0, _register_js_1.registerTool)(server, "set_page_theme", "Set the workspace theme for published pages. Controls the visual branding of all published pages.", {
384
- primaryColor: zod_1.z.string().describe("Primary brand color (hex, e.g., '#1a73e8')"),
385
- accentColor: zod_1.z.string().describe("Accent color (hex, e.g., '#ff6d00')"),
386
- logoUrl: zod_1.z.string().optional().describe("URL to the workspace logo"),
387
- fontFamily: zod_1.z.string().optional().describe("Font family name (e.g., 'Inter', 'Roboto')"),
388
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ primaryColor, accentColor, logoUrl, fontFamily }) {
389
- try {
390
- const config = { primaryColor, accentColor };
391
- if (logoUrl !== undefined)
392
- config.logoUrl = logoUrl;
393
- if (fontFamily !== undefined)
394
- config.fontFamily = fontFamily;
395
- const resp = yield client.put(`${basePath}/theme`, { config });
396
- return {
397
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
398
- };
399
- }
400
- catch (error) {
401
- return {
402
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "setting page theme") }],
403
- isError: true,
404
- };
405
- }
406
- }));
407
- // ── Navigation ────────────────────────────────────────────────────
408
- (0, _register_js_1.registerTool)(server, "get_navigation", "Get the workspace navigation configuration. Controls the sidebar/nav shell that wraps published pages.", {}, () => __awaiter(this, void 0, void 0, function* () {
409
- try {
410
- const resp = yield client.get(`${basePath}/navigation`);
411
- return {
412
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
413
- };
414
- }
415
- catch (error) {
416
- return {
417
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "getting navigation config") }],
418
- isError: true,
419
- };
420
- }
421
- }));
422
- (0, _register_js_1.registerTool)(server, "set_navigation", "Set the workspace navigation configuration. Defines the sidebar items, branding, and grouping for the page navigation shell.", {
423
- config: zod_1.z
424
- .record(zod_1.z.string(), zod_1.z.any())
425
- .describe("Navigation config object with: enabled (boolean), branding ({ logoUrl, displayName }), items (array of nav items with pageId, label, icon, group)"),
426
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ config }) {
427
- try {
428
- const resp = yield client.put(`${basePath}/navigation`, { config });
429
- return {
430
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
431
- };
432
- }
433
- catch (error) {
434
- return {
435
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "setting navigation config") }],
436
- isError: true,
437
- };
438
- }
439
- }));
440
- (0, _register_js_1.registerTool)(server, "delete_navigation", "Delete the workspace navigation configuration. Pages revert to standalone rendering without a sidebar/nav shell.", {}, () => __awaiter(this, void 0, void 0, function* () {
441
- try {
442
- yield client.delete(`${basePath}/navigation`);
443
- return {
444
- content: [{ type: "text", text: "Navigation config deleted. Pages will render standalone." }],
445
- };
446
- }
447
- catch (error) {
448
- return {
449
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "deleting navigation config") }],
450
- isError: true,
451
- };
452
- }
453
- }));
454
- // ── Assembly (AI-assisted page generation) ────────────────────────
455
- (0, _register_js_1.registerTool)(server, "generate_starter_pages", "Generate page proposals from collection IDs. Uses guided assembly to create page definitions (list, detail, form, dashboard) tailored to the data schema. Returns proposals that can be reviewed and accepted.", {
456
- collectionIds: zod_1.z
457
- .array(zod_1.z.string())
458
- .describe("Array of collection IDs (UUIDs) to generate pages for. Get these from list_collections → id field."),
459
- goals: zod_1.z
460
- .array(zod_1.z.string())
461
- .optional()
462
- .describe("Optional goals to guide page generation (e.g., 'customer management dashboard', 'order tracking')"),
463
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ collectionIds, goals }) {
464
- try {
465
- const body = { structureIds: collectionIds };
466
- if (goals)
467
- body.goals = goals;
468
- const resp = yield client.post(`${basePath}/generate-starter-pages`, body);
469
- return {
470
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
471
- };
472
- }
473
- catch (error) {
474
- return {
475
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "generating starter pages") }],
476
- isError: true,
477
- };
478
- }
479
- }));
480
- (0, _register_js_1.registerTool)(server, "accept_page_proposal", "Accept a generated page proposal and create the page with its initial draft definition. Use after reviewing proposals from generate_starter_pages.", {
481
- name: zod_1.z.string().describe("Display name for the page"),
482
- slug: zod_1.z.string().describe("URL-safe slug for the page"),
483
- pageType: zod_1.z
484
- .enum(["list", "detail", "form", "dashboard"])
485
- .describe("Page type"),
486
- definition: zod_1.z
487
- .record(zod_1.z.string(), zod_1.z.any())
488
- .describe("The page definition from the proposal"),
489
- generationSource: zod_1.z
490
- .string()
491
- .describe("The source that generated this proposal (from the proposal object)"),
492
- }, (_a) => __awaiter(this, [_a], void 0, function* ({ name, slug, pageType, definition, generationSource }) {
493
- try {
494
- const resp = yield client.post(`${basePath}/accept-proposal`, {
495
- name,
496
- slug,
497
- pageType,
498
- definition,
499
- generationSource,
500
- });
501
- return {
502
- content: [{ type: "text", text: JSON.stringify(resp.data, null, 2) }],
503
- };
504
- }
505
- catch (error) {
506
- return {
507
- content: [{ type: "text", text: (0, _register_js_1.formatError)(error, "accepting page proposal") }],
508
- isError: true,
509
- };
510
- }
511
- }));
512
- }