@plitzi/sdk-mcp 0.38.13 → 0.38.15

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,8 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { ResourceProxy } from '../proxy';
3
- import { Operation } from './operations';
4
- import { OfflineDataRaw } from '@plitzi/sdk-shared';
2
+ import { RenderWidgetInput } from './renderWidget';
5
3
  export declare const renderShape: {
4
+ patch: z.ZodOptional<z.ZodBoolean>;
5
+ renderId: z.ZodOptional<z.ZodString>;
6
6
  operations: z.ZodArray<z.ZodDiscriminatedUnion<readonly [z.ZodObject<{
7
7
  type: z.ZodLiteral<"upsertElement">;
8
8
  pageRef: z.ZodString;
@@ -80,6 +80,10 @@ export declare const renderShape: {
80
80
  layout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
81
81
  layoutContainer: z.ZodOptional<z.ZodNullable<z.ZodString>>;
82
82
  enabled: z.ZodOptional<z.ZodBoolean>;
83
+ documentScroll: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
84
+ locked: "locked";
85
+ noBounce: "noBounce";
86
+ }>>>;
83
87
  flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
88
  }, z.core.$strict>, z.ZodObject<{
85
89
  type: z.ZodLiteral<"deletePage">;
@@ -286,6 +290,10 @@ export declare const renderShape: {
286
290
  clients: "clients";
287
291
  }>>;
288
292
  presence: z.ZodOptional<z.ZodBoolean>;
293
+ grant: z.ZodOptional<z.ZodBoolean>;
294
+ retain: z.ZodOptional<z.ZodBoolean>;
295
+ maxMessageBytes: z.ZodOptional<z.ZodNumber>;
296
+ messagesPerSecond: z.ZodOptional<z.ZodNumber>;
289
297
  }, z.core.$strip>>>>;
290
298
  }, z.core.$strict>, z.ZodObject<{
291
299
  type: z.ZodLiteral<"upsertComponent">;
@@ -1421,40 +1429,9 @@ export declare const renderShape: {
1421
1429
  type: z.ZodLiteral<"deleteFont">;
1422
1430
  family: z.ZodString;
1423
1431
  }, z.core.$strict>], "type">>;
1424
- patch: z.ZodOptional<z.ZodBoolean>;
1425
- renderId: z.ZodOptional<z.ZodString>;
1426
1432
  };
1427
- export type RenderInput = {
1428
- operations: Operation[];
1433
+ export type RenderInput = RenderWidgetInput & {
1429
1434
  patch?: boolean;
1430
1435
  renderId?: string;
1431
1436
  };
1432
- /** What the render needs from its host beyond the operations. Optional: a host that wires no resource endpoint
1433
- * still renders a widget — one whose external URLs travel as authored and load only where the surface allows
1434
- * their origin. */
1435
- export type RenderOptions = {
1436
- proxy?: ResourceProxy;
1437
- };
1438
- export type RenderResponse = {
1439
- rendered: false;
1440
- errors: {
1441
- path: string;
1442
- message: string;
1443
- hint?: string;
1444
- }[];
1445
- warnings?: string[];
1446
- } | {
1447
- rendered: true;
1448
- rootRef: string;
1449
- elementCount: number;
1450
- offlineData: OfflineDataRaw;
1451
- /** The batch this render was built from, EXPANDED (repeats already unrolled). The view keeps it so a later
1452
- * patch has something to merge into; it is never shown to the model. */
1453
- operations: Operation[];
1454
- /** One line per interaction flow the widget actually stored — what got wired to what. Absent when the
1455
- * widget has no flows, which is most of them. */
1456
- interactions?: string[];
1457
- warnings?: string[];
1458
- };
1459
- export declare const render: (input: RenderInput, options?: RenderOptions) => RenderResponse;
1460
1437
  export declare const renderTool: import('.').ToolDef;
@@ -1,68 +1,16 @@
1
1
  import { iconFontCss } from "../apps/render/styles.js";
2
2
  import { RENDER_APP_URI } from "../apps/render/index.js";
3
- import { emptySpace } from "../helpers/space.js";
4
- import { proxifyResources } from "../proxy/rewrite.js";
5
- import { compactDocumentOperations, documentOperations } from "./operations/index.js";
6
- import { draftBatch } from "./shared/draftBatch.js";
3
+ import { compactDocumentOperations } from "./operations/index.js";
7
4
  import { defineTool } from "./shared/tool.js";
8
- import { interactionReport } from "./shared/interactionReport.js";
5
+ import { render, renderWidgetShape } from "./renderWidget.js";
9
6
  import { randomUUID } from "node:crypto";
10
7
  import { z } from "zod";
11
- import { generateCache } from "@plitzi/sdk-style/StyleHelper";
12
8
  //#region src/modules/mcp/tools/render.ts
13
- var HOST_PAGE_REF = "render";
14
- var seedSpace = () => {
15
- const space = emptySpace();
16
- space.schema.definition.name = "Widget";
17
- space.schema.flat[HOST_PAGE_REF] = {
18
- id: HOST_PAGE_REF,
19
- attributes: {
20
- slug: "",
21
- name: "Render",
22
- default: true
23
- },
24
- definition: {
25
- rootId: HOST_PAGE_REF,
26
- label: "Page",
27
- type: "page",
28
- items: [],
29
- styleSelectors: { base: "" }
30
- }
31
- };
32
- space.schema.pages = [HOST_PAGE_REF];
33
- return space;
34
- };
35
- var noWarnings = (warnings) => warnings.length > 0 ? warnings : void 0;
36
9
  var renderShape = {
37
- operations: documentOperations,
10
+ ...renderWidgetShape,
38
11
  patch: z.boolean().optional().describe("Set true to CHANGE a widget you already rendered instead of rebuilding it: send its `renderId` and ONLY the operations that differ (patchDefinition, patchElement, deleteElement, a new repeatElement…). The widget merges them into the batch it was built from and reports back what it applied. The refs it already has (card-1, blk-2-3) are the ones to address. If that widget cannot be recovered — a surface that renders none, a host that keeps no storage — the answer says so and you re-send the whole batch."),
39
12
  renderId: z.string().optional().describe("Handle returned by a previous render. Required with patch:true; it names the widget being changed.")
40
13
  };
41
- var render = (input, options = {}) => {
42
- const result = draftBatch(seedSpace(), "main", input.operations, "widget");
43
- if (!result.ok) return {
44
- rendered: false,
45
- errors: result.errors,
46
- warnings: noWarnings(result.warnings)
47
- };
48
- const { ops, draft: space } = result;
49
- const behaviour = interactionReport(space);
50
- const warnings = [...result.warnings, ...behaviour.warnings];
51
- if (options.proxy) warnings.push(...proxifyResources(space, options.proxy));
52
- space.style.cache = generateCache(space.style);
53
- return {
54
- rendered: true,
55
- operations: ops,
56
- ...behaviour.flows ? { interactions: behaviour.flows } : {},
57
- rootRef: HOST_PAGE_REF,
58
- elementCount: Object.keys(space.schema.flat).length - 1,
59
- offlineData: {
60
- schema: space.schema,
61
- style: space.style
62
- },
63
- warnings: noWarnings(warnings)
64
- };
65
- };
66
14
  /** A patch is not rendered here — it CANNOT be: this server keeps nothing between calls (no session, no store,
67
15
  * any replica answers any request), so the previous widget only exists on the host side. The delta therefore
68
16
  * travels as a courier result: the model pays for the delta alone, the view recovers the batch that widget was
@@ -156,4 +104,4 @@ var renderTool = defineTool({
156
104
  run: (input, ctx) => input.patch === true ? toPatchResult(input.operations, input.renderId) : toRenderResult(render(input, { proxy: ctx.proxy }), input.renderId ?? newRenderId())
157
105
  });
158
106
  //#endregion
159
- export { render, renderShape, renderTool };
107
+ export { renderShape, renderTool };