import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; import { CplaceApiClient } from '../api.js'; export declare const LayoutContextSchema: z.ZodEffects; pageUID: z.ZodString; }, "strip", z.ZodTypeAny, { type: "page"; pageUID: string; }, { type: "page"; pageUID: string; }>, z.ZodObject<{ type: z.ZodLiteral<"type">; workspaceId: z.ZodString; typeInternalName: z.ZodString; alternativeLayoutName: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }>]>, { type: "page"; pageUID: string; } | { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, unknown>; export type LayoutContext = z.infer; export declare const LAYOUT_TOOL_DEFINITIONS: { readonly cplace_execute_layout_script: { readonly description: "Execute a layout script — either a full layout.define() replacement or per-widget edit verbs.\n\nTWO MODES (determined by script content):\n\nMODE 1 — FULL REPLACE (layout.define):\n- Script calls layout.define() exactly once to declare the complete layout structure\n- Replaces the entire layout atomically\n- Same behavior as before\n\nMODE 2 — EDIT VERBS (per-widget):\n- Script calls one or more edit methods: layout.updateWidget(), layout.addWidget(), layout.removeWidget(), layout.moveWidget(), layout.addRow(), layout.compact()\n- Each call collects an operation; all operations commit atomically or fail together\n- Cannot mix layout.define() with edit verbs in the same script\n\nEDIT VERBS:\n layout.updateWidget(\"widgetId\", { \"cf.cplace.x\": newValue }) — partial config merge (only specified keys change)\n layout.addWidget({ widgetType: \"cf.platform.wiki\", position: { rowIndex: 0, columnIndex: 0, widgetIndex: 0 }, configuration: { ... } })\n layout.removeWidget(\"widgetId\")\n layout.moveWidget(\"widgetId\", { rowIndex: 1, columnIndex: 0, widgetIndex: 0 })\n layout.addRow(rowIndex, [6, 6]) — column proportions must be one of the layout templates (listed in the script parameter description)\n layout.compact() — remove empty rows\n\nWORKFLOW for per-widget edit:\n1. Read: cplace_get_layout_script with widgetIds to get layout.updateWidget() fragments\n2. Edit: modify the config values in the fragment\n3. Execute: post the modified script via this tool\n\nKEY BEHAVIORS (for layout.define mode):\n- The script must call layout.define() exactly once\n- The entire layout is atomically replaced — previous layout is fully overwritten\n- Script timeout: 30 seconds\n- Widget IDs: MUST be omitted from layout.define. Ids are assigned by the server and returned in the response. Use the returned id in subsequent layout.updateWidget() calls.\n- ID PRESERVATION: edit verbs (updateWidget/addWidget/removeWidget/moveWidget/addRow/compact) look widgets up by id and mutate in place — they PRESERVE the IDs of every widget you don't touch. This is the only safe path for cross-referenced widgets (e.g. a Low-Code Button's tableWidgetId). By contrast, layout.define — and cplace_edit_layout, which round-trips through layout.define — REGENERATES every widget id.\n\nRESPONSE OUTCOMES:\n- VALID_COMPLETE: Layout saved, all widgets fully configured\n- VALID_INCOMPLETE: Layout saved, but some widgets have missing optional configuration (warnings returned)\n- Validation errors: Layout NOT saved — structural or widget errors returned with details\n- Generic errors: Entity not found, permission denied, script errors\n\nVALIDATION FEEDBACK:\n- Structural errors: column proportions that are not a layout template\n- Widget errors: unknown widget types, invalid configurations\n- Property value errors: a widget property value outside its allowed domain (e.g. a heading `size` other than h1-h6) is rejected — for top-level layout widgets and for embedded properties alike. Only the property names you submit are checked; omitted required properties are reported as warnings, not errors.\n- Warnings: widgets saved but missing optional configuration (e.g., search filter not set)\n\nTIP: After a VALID_INCOMPLETE response, re-run layout.define() with corrected widget configuration to resolve warnings.\n\nON A SyntaxError / SCRIPT ERROR: the response carries the parser message with a caret (^) under the\noffending token. Correct THAT line before re-submitting — never resend the identical script,\nincluding after a \"Session expired\" reconnect. A blind retry reproduces the same error.\n\nCOMMON WIDGET TYPES (platform, always available):\ncf.platform.attributes, cf.cplace.platform.attributesGroup,\ncf.platform.wiki, cf.platform.richString, cf.cplace.demoWidgets.demoRichString,\ncf.platform.embeddedSearchAsTable, cf.cplace.platform.tableWidget,\ncf.platform.connectedBarChart, cf.platform.connectedPieChart,\ncf.platform.connectedMatrix, cf.platform.connectedTableFilter,\ncf.platform.incomingReferences, cf.platform.comments, cf.platform.files,\ncf.cplace.visualizations.scriptingHighcharts\n\nFor app-dependent widgets not in this list, call cplace_list_widget_definitions with embeddingContext \"AS_WIDGET\".\n\nRICHSTRING WIDGETS AND EMBEDDED WIDGETS (decoded form):\nRichString widgets (cf.platform.richString, cf.cplace.demoWidgets.demoRichString)\nhold HTML in their 'content' config. Embedded widgets inside that HTML are\nexpressed in decoded form:\n {\"properties\":{\"attribute\":\"name\"}}\n\nSemantics when submitting a script:\n • Tag with an existing id + same type → update (properties replace current)\n • Tag without id → insert new embedded widget (backend assigns id)\n • Existing id omitted from new content → delete\n • Unknown id, duplicate id, or type change for same id → error on cplace_richstring_* tools; NOT checked on layout-script and page writes, which treat richstring markup as fully-replaced client-authored text\n\nRaw base64 BASE64 tags are REJECTED on writes.\nFetch current decoded form via cplace_get_layout_script.\n\nIMPORTANT: Decoded tags must appear directly inline in a content: value.\nDo NOT build the tag in a variable and pass it — the parser rejects tags outside content: literals.\n ✅ layout.updateWidget(\"id\", { content: '...' });\n ❌ var tag = '...'; layout.updateWidget(\"id\", { content: tag });\n\nEMBEDDED WIDGET SCRIPT ATTRIBUTES — PLACEHOLDER WORKFLOW (REQUIRED):\nFor script-typed attributes on embedded widgets (e.g. cf.cplace.lowCodeWidgets.lowCodeTextWidget.script),\ninitialize the value to a minimal placeholder body inside the inline JSON, then fill the\nreal script body afterward via cplace_richstring_set_widget_script (full replace) or\ncplace_richstring_edit_widget_script (str-replace diff). Authoring a non-trivial script body inline\nforces it through four nested encoding layers (HTML → JSON → JS string literal → MCP wire) and is a\ndocumented source of escape-bug churn — the dedicated tools take the script as a plain string in a\nstructured argument and avoid all four layers.\n\nSafe placeholder for cf.cplace.lowCodeWidgets.lowCodeText: return '';\nOther script-bearing widget types: pick any runtime-valid placeholder for that widget.\n\nNon-script attributes (strings, numbers, references, lists) do NOT have this problem and are authored\ninline as normal JSON properties on the tag.\n\nFor atomic single-embedded-widget edits without rewriting the full script,\nsee cplace_layout_richstring_* and cplace_richstring_*_widget_script tools."; readonly inputSchema: { readonly context: z.ZodEffects; pageUID: z.ZodString; }, "strip", z.ZodTypeAny, { type: "page"; pageUID: string; }, { type: "page"; pageUID: string; }>, z.ZodObject<{ type: z.ZodLiteral<"type">; workspaceId: z.ZodString; typeInternalName: z.ZodString; alternativeLayoutName: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }>]>, { type: "page"; pageUID: string; } | { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, unknown>; readonly script: z.ZodString; }; readonly annotations: { readonly title: "Execute Layout Script"; }; }; readonly cplace_get_layout_overview: { readonly description: "Get layout structure for page or type. Provides an overview of the layout grid including rows, columns, and widget summaries for both page and type layouts."; readonly inputSchema: { readonly context: z.ZodEffects; pageUID: z.ZodString; }, "strip", z.ZodTypeAny, { type: "page"; pageUID: string; }, { type: "page"; pageUID: string; }>, z.ZodObject<{ type: z.ZodLiteral<"type">; workspaceId: z.ZodString; typeInternalName: z.ZodString; alternativeLayoutName: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }>]>, { type: "page"; pageUID: string; } | { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, unknown>; }; readonly annotations: { readonly title: "Get Layout Overview"; }; }; readonly cplace_get_layout_widget_details: { readonly description: "Get detailed widget configuration from page or type layout. Extracts specific widget information from the layout structure.\n\nRichString widget content appears in decoded form: `{\"properties\":{…}}` — no base64."; readonly inputSchema: { readonly context: z.ZodEffects; pageUID: z.ZodString; }, "strip", z.ZodTypeAny, { type: "page"; pageUID: string; }, { type: "page"; pageUID: string; }>, z.ZodObject<{ type: z.ZodLiteral<"type">; workspaceId: z.ZodString; typeInternalName: z.ZodString; alternativeLayoutName: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }>]>, { type: "page"; pageUID: string; } | { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, unknown>; readonly widgetId: z.ZodString; }; readonly annotations: { readonly title: "Get Layout Widget Details"; }; }; readonly cplace_get_layout_script: { readonly description: "Get the current layout as an executable script for a page or type layout.\n\nTWO MODES (determined by widgetIds parameter):\n\nWITHOUT widgetIds: Returns the full layout as a layout.define({...}) script (same as before).\n\nWITH widgetIds: Returns layout.updateWidget(\"id\", {config}) fragments for just the specified widgets.\nThe output is directly executable — post it back via cplace_execute_layout_script.\n\nROUND-TRIP WORKFLOW:\n1. GET: Use this tool (with widgetIds for selective read, without for full layout)\n2. EDIT: Modify the script as needed\n3. APPLY: Use cplace_execute_layout_script to apply\n\nRichString widget content is returned in decoded form:\n {\"properties\":{…}}\nThe output is directly executable — base64 tags are never emitted."; readonly inputSchema: { readonly context: z.ZodEffects; pageUID: z.ZodString; }, "strip", z.ZodTypeAny, { type: "page"; pageUID: string; }, { type: "page"; pageUID: string; }>, z.ZodObject<{ type: z.ZodLiteral<"type">; workspaceId: z.ZodString; typeInternalName: z.ZodString; alternativeLayoutName: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }>]>, { type: "page"; pageUID: string; } | { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, unknown>; readonly widgetIds: z.ZodOptional>; }; readonly annotations: { readonly title: "Get Layout Script"; }; }; readonly cplace_edit_layout: { readonly description: string; readonly inputSchema: { readonly context: z.ZodEffects; pageUID: z.ZodString; }, "strip", z.ZodTypeAny, { type: "page"; pageUID: string; }, { type: "page"; pageUID: string; }>, z.ZodObject<{ type: z.ZodLiteral<"type">; workspaceId: z.ZodString; typeInternalName: z.ZodString; alternativeLayoutName: z.ZodOptional; }, "strip", z.ZodTypeAny, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }>]>, { type: "page"; pageUID: string; } | { type: "type"; workspaceId: string; typeInternalName: string; alternativeLayoutName?: string | undefined; }, unknown>; readonly old_str: z.ZodString; readonly new_str: z.ZodString; readonly replace_all: z.ZodDefault>; }; readonly annotations: { readonly title: "Edit Layout"; }; }; }; export declare function registerLayoutTools(server: McpServer, client: CplaceApiClient): void; //# sourceMappingURL=layout.d.ts.map