@plitzi/sdk-mcp 0.33.2 → 0.34.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.
Files changed (187) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.js +3 -2
  4. package/dist/modules/mcp/catalogs/index.d.ts +2 -7
  5. package/dist/modules/mcp/catalogs/index.js +4 -0
  6. package/dist/modules/mcp/catalogs/observed.d.ts +1 -1
  7. package/dist/modules/mcp/catalogs/observed.js +2 -5
  8. package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +17 -0
  9. package/dist/modules/mcp/catalogs/pluginCatalog.js +91 -0
  10. package/dist/modules/mcp/catalogs/registry.js +2 -3
  11. package/dist/modules/mcp/helpers/agentPrompt.js +9 -9
  12. package/dist/modules/mcp/helpers/guide.d.ts +2 -2
  13. package/dist/modules/mcp/helpers/guide.js +117 -50
  14. package/dist/modules/mcp/helpers/interactions.d.ts +5 -1
  15. package/dist/modules/mcp/helpers/interactions.js +15 -6
  16. package/dist/modules/mcp/helpers/space.d.ts +45 -28
  17. package/dist/modules/mcp/helpers/space.js +87 -87
  18. package/dist/modules/mcp/helpers/uris.d.ts +9 -0
  19. package/dist/modules/mcp/helpers/uris.js +10 -1
  20. package/dist/modules/mcp/index.d.ts +2 -0
  21. package/dist/modules/mcp/localScreenshotClient.d.ts +51 -0
  22. package/dist/modules/mcp/localScreenshotClient.js +106 -0
  23. package/dist/modules/mcp/proxy/rewrite.js +15 -1
  24. package/dist/modules/mcp/resources/actions.d.ts +25 -0
  25. package/dist/modules/mcp/resources/actions.js +54 -0
  26. package/dist/modules/mcp/resources/canonical.d.ts +1 -1
  27. package/dist/modules/mcp/resources/canonical.js +1 -1
  28. package/dist/modules/mcp/resources/connectors.d.ts +1 -1
  29. package/dist/modules/mcp/resources/core.js +1 -1
  30. package/dist/modules/mcp/resources/index.d.ts +1 -0
  31. package/dist/modules/mcp/resources/primer.d.ts +8 -1
  32. package/dist/modules/mcp/resources/primer.js +139 -15
  33. package/dist/modules/mcp/resources/register.js +24 -4
  34. package/dist/modules/mcp/resources/renderGuide.js +66 -14
  35. package/dist/modules/mcp/resources/router.js +3 -1
  36. package/dist/modules/mcp/resources/schema.js +6 -5
  37. package/dist/modules/mcp/resources/style.d.ts +2 -1
  38. package/dist/modules/mcp/resources/style.js +10 -3
  39. package/dist/modules/mcp/screenshotClient.js +3 -2
  40. package/dist/modules/mcp/server.js +12 -6
  41. package/dist/modules/mcp/tests/agentRoundtrip.test.d.ts +1 -0
  42. package/dist/modules/mcp/tests/layouts.test.d.ts +1 -0
  43. package/dist/modules/mcp/tools/apply/dispatch.js +30 -1
  44. package/dist/modules/mcp/tools/apply/index.d.ts +149 -15
  45. package/dist/modules/mcp/tools/apply/index.js +12 -2
  46. package/dist/modules/mcp/tools/operations/actions/actions.test.d.ts +1 -0
  47. package/dist/modules/mcp/tools/operations/actions/deleteAction.d.ts +9 -0
  48. package/dist/modules/mcp/tools/operations/actions/deleteAction.js +20 -0
  49. package/dist/modules/mcp/tools/operations/actions/document.d.ts +69 -0
  50. package/dist/modules/mcp/tools/operations/actions/document.js +73 -0
  51. package/dist/modules/mcp/tools/operations/actions/index.d.ts +90 -0
  52. package/dist/modules/mcp/tools/operations/actions/index.js +12 -0
  53. package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +45 -0
  54. package/dist/modules/mcp/tools/operations/actions/patchAction.js +71 -0
  55. package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +47 -0
  56. package/dist/modules/mcp/tools/operations/actions/upsertAction.js +83 -0
  57. package/dist/modules/mcp/tools/operations/connectors/index.d.ts +10 -10
  58. package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +5 -5
  59. package/dist/modules/mcp/tools/operations/connectors/patchConnector.d.ts +5 -5
  60. package/dist/modules/mcp/tools/operations/connectors/upsertConnector.d.ts +5 -5
  61. package/dist/modules/mcp/tools/operations/index.d.ts +415 -40
  62. package/dist/modules/mcp/tools/operations/index.js +11 -2
  63. package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +2 -2
  64. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +1 -1
  65. package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +2 -2
  66. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +1 -1
  67. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +4 -4
  68. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +5 -5
  69. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +6 -6
  70. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +1 -1
  71. package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +11 -12
  72. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +1 -1
  73. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +4 -4
  74. package/dist/modules/mcp/tools/operations/schema/index.d.ts +2 -0
  75. package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +2 -2
  76. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +1 -1
  77. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +2 -2
  78. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +1 -1
  79. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +4 -4
  80. package/dist/modules/mcp/tools/operations/schema/operations.d.ts +28 -5
  81. package/dist/modules/mcp/tools/operations/schema/operations.js +4 -0
  82. package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.d.ts +9 -0
  83. package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +33 -0
  84. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +1 -1
  85. package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.d.ts +22 -0
  86. package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.js +61 -0
  87. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +2 -0
  88. package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +53 -18
  89. package/dist/modules/mcp/tools/operations/schema/shared.d.ts +5 -1
  90. package/dist/modules/mcp/tools/operations/schema/shared.js +2 -2
  91. package/dist/modules/mcp/tools/operations/schema/translator.d.ts +2 -1
  92. package/dist/modules/mcp/tools/operations/schema/translator.js +21 -9
  93. package/dist/modules/mcp/tools/operations/schema/write.d.ts +9 -22
  94. package/dist/modules/mcp/tools/operations/schema/write.js +23 -43
  95. package/dist/modules/mcp/tools/operations/schemaIds.js +7 -1
  96. package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.d.ts +9 -0
  97. package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +21 -0
  98. package/dist/modules/mcp/tools/operations/style/fonts/fonts.test.d.ts +1 -0
  99. package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.d.ts +35 -0
  100. package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +66 -0
  101. package/dist/modules/mcp/tools/operations/style/index.d.ts +2 -0
  102. package/dist/modules/mcp/tools/operations/style/operations.d.ts +34 -0
  103. package/dist/modules/mcp/tools/operations/style/operations.js +5 -1
  104. package/dist/modules/mcp/tools/operations/style/translator.d.ts +13 -1
  105. package/dist/modules/mcp/tools/operations/style/translator.js +18 -1
  106. package/dist/modules/mcp/tools/operations/style/write.js +1 -1
  107. package/dist/modules/mcp/tools/preview.d.ts +58 -5
  108. package/dist/modules/mcp/tools/preview.js +1 -1
  109. package/dist/modules/mcp/tools/render.d.ts +61 -5
  110. package/dist/modules/mcp/tools/render.js +10 -3
  111. package/dist/modules/mcp/tools/screenshot.d.ts +151 -16
  112. package/dist/modules/mcp/tools/screenshot.js +22 -13
  113. package/dist/modules/mcp/tools/search.js +3 -3
  114. package/dist/modules/mcp/tools/shared/interactionReport.d.ts +7 -0
  115. package/dist/modules/mcp/tools/shared/interactionReport.js +48 -0
  116. package/dist/modules/mcp/tools/shared/validator/audit.js +4 -4
  117. package/dist/modules/mcp/tools/shared/validator/batch.d.ts +1 -0
  118. package/dist/modules/mcp/tools/shared/validator/batch.js +11 -2
  119. package/dist/modules/mcp/tools/shared/validator/bindings.js +6 -6
  120. package/dist/modules/mcp/tools/shared/validator/connectors.js +1 -1
  121. package/dist/modules/mcp/tools/shared/validator/context.d.ts +3 -0
  122. package/dist/modules/mcp/tools/shared/validator/css.js +1 -1
  123. package/dist/modules/mcp/tools/shared/validator/index.js +29 -9
  124. package/dist/modules/mcp/tools/shared/validator/interactions.js +41 -7
  125. package/dist/modules/mcp/tools/shared/validator/refs.js +4 -4
  126. package/dist/modules/mcp/tools/validate.d.ts +149 -15
  127. package/dist/modules/mcp/types/aiSchema.d.ts +33 -4
  128. package/dist/modules/mcp/types/previewTypes.d.ts +19 -0
  129. package/dist/modules/mcp/types/screenshotTypes.d.ts +1 -0
  130. package/dist/modules/mcp/types/toolTypes.d.ts +6 -1
  131. package/dist/pipeline.js +1 -1
  132. package/dist/preview/createPreview.d.ts +4 -2
  133. package/dist/preview/createPreview.js +16 -6
  134. package/dist/server.d.ts +3 -0
  135. package/dist/server.js +3 -1
  136. package/dist/stages/preview.js +20 -1
  137. package/dist/tests/httpRequest.d.ts +2 -0
  138. package/package.json +20 -16
  139. package/skills/plitzi-render/SKILL.md +84 -11
  140. package/dist/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -19
  141. package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -139
  142. package/dist/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
  143. package/dist/modules/mcp/catalogs/builtinComponents.js +0 -165
  144. package/dist/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -17
  145. package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
  146. package/dist/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
  147. package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
  148. package/dist/modules/mcp/catalogs/builtinUtilities.d.ts +0 -15
  149. package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
  150. package/dist/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
  151. package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
  152. package/dist/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
  153. package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
  154. package/dist/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
  155. package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
  156. package/dist/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -18
  157. package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
  158. package/dist/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
  159. package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -99
  160. package/dist/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
  161. package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -147
  162. package/dist/modules/mcp/catalogs/paramSpec.d.ts +0 -39
  163. package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
  164. package/dist/modules/oauth/authorize.d.ts +0 -7
  165. package/dist/modules/oauth/authorize.js +0 -177
  166. package/dist/modules/oauth/challenge.d.ts +0 -11
  167. package/dist/modules/oauth/challenge.js +0 -33
  168. package/dist/modules/oauth/consentPage.d.ts +0 -7
  169. package/dist/modules/oauth/consentPage.js +0 -118
  170. package/dist/modules/oauth/metadata.d.ts +0 -40
  171. package/dist/modules/oauth/metadata.js +0 -69
  172. package/dist/modules/oauth/params.d.ts +0 -5
  173. package/dist/modules/oauth/params.js +0 -5
  174. package/dist/modules/oauth/pkce.d.ts +0 -6
  175. package/dist/modules/oauth/pkce.js +0 -15
  176. package/dist/modules/oauth/records.d.ts +0 -71
  177. package/dist/modules/oauth/records.js +0 -46
  178. package/dist/modules/oauth/register.d.ts +0 -5
  179. package/dist/modules/oauth/register.js +0 -55
  180. package/dist/modules/oauth/respond.d.ts +0 -13
  181. package/dist/modules/oauth/respond.js +0 -44
  182. package/dist/modules/oauth/token.d.ts +0 -5
  183. package/dist/modules/oauth/token.js +0 -100
  184. package/dist/stages/oauth.d.ts +0 -19
  185. package/dist/stages/oauth.js +0 -114
  186. /package/dist/modules/mcp/catalogs/{builtinTransformers.test.d.ts → pluginCatalog.test.d.ts} +0 -0
  187. /package/dist/modules/mcp/{catalogs/cssCatalog/cssCatalog.test.d.ts → localScreenshotClient.test.d.ts} +0 -0
@@ -1,10 +1,8 @@
1
- import { hiddenParams, invalidParams, missingRequiredParams, reconcileParams } from "../../../catalogs/paramSpec.js";
2
- import { getGlobalCallback } from "../../../catalogs/builtinCallbacks.js";
3
- import { getElementCallback } from "../../../catalogs/builtinElementCallbacks.js";
4
- import { getUtility } from "../../../catalogs/builtinUtilities.js";
1
+ import { getElementCallback, getGlobalCallback, getUtility, hiddenParams, invalidParams, missingRequiredParams, reconcileParams } from "../../../catalogs/index.js";
5
2
  import { NULLISH_ELEMENT_IDS } from "../../../helpers/interactions.js";
6
3
  import { checkObservedName, warnOnce } from "./context.js";
7
4
  //#region src/modules/mcp/tools/shared/validator/interactions.ts
5
+ var ELEMENT_FIELD_ACTIONS = /* @__PURE__ */ new Set(["setState", "toggleState"]);
8
6
  var describeType = (type) => {
9
7
  switch (type) {
10
8
  case "boolean": return "a boolean";
@@ -42,7 +40,7 @@ var checkGlobalCallback = (node, base, ctx) => {
42
40
  if (node.elementId !== void 0 && node.elementId !== builtin.source) warnOnce(ctx, `Global callback "${node.action}" at ${base} is registered on "${builtin.source}", not on "${node.elementId}". Omit elementId (the MCP sets "${builtin.source}") or set it to "${builtin.source}".`);
43
41
  if (node.params && builtin.strictParams) checkParams("Global callback", node.action, node.params, builtin.params, base, ctx);
44
42
  };
45
- var checkSetStateKey = (node, base, ctx, hostRef) => {
43
+ var checkElementFieldKey = (node, base, ctx, hostRef) => {
46
44
  const key = node.params?.key;
47
45
  if (typeof key !== "string" || key === "") return;
48
46
  const targetRef = typeof node.elementId === "string" && node.elementId !== "" ? node.elementId : hostRef;
@@ -54,7 +52,7 @@ var checkSetStateKey = (node, base, ctx, hostRef) => {
54
52
  if (validKeys.size === 0 || validKeys.has(key)) return;
55
53
  const kind = state ? "state" : "attribute";
56
54
  const valid = [...validKeys].sort();
57
- const detail = `Element setState at ${base} sets ${kind} "${key}" on type "${type}", which has no such ${kind} key`;
55
+ const detail = `Element ${node.action} at ${base} names ${kind} "${key}" on type "${type}", which has no such ${kind} key`;
58
56
  if (!meta.custom) ctx.errors.push({
59
57
  path: base,
60
58
  message: detail,
@@ -63,7 +61,35 @@ var checkSetStateKey = (node, base, ctx, hostRef) => {
63
61
  });
64
62
  else warnOnce(ctx, `${detail} (${valid.join(", ")}). It may still be valid — verify against plitzi://types.`);
65
63
  };
64
+ /**
65
+ * The step names another element to act on — and that element does not exist.
66
+ *
67
+ * This is the failure with NO symptom: the runtime resolves a callback as `callbacksAvailables[elementId][action]`,
68
+ * so a dangling target finds nothing and the step does nothing, while the flow, the render and the apply all
69
+ * report success. Nothing else in the pipeline catches it — the field-key check below needs the element's type to
70
+ * say anything, so an unresolvable ref used to make it return in silence.
71
+ *
72
+ * A `widget` batch is the whole world (plitzi_render seeds an empty space), so a target that is neither in it nor
73
+ * created by it is certainly wrong: a hard error. A space may carry legacy flows pointing at elements deleted long
74
+ * ago, and the post-apply audit re-checks the stored interactions of every element the batch touches — erroring
75
+ * there would block edits on debris the agent did not write, so in `space` mode this warns.
76
+ */
77
+ var checkCallbackTarget = (node, base, ctx) => {
78
+ const target = node.elementId;
79
+ if (target === void 0 || target === "" || NULLISH_ELEMENT_IDS.has(target) || ctx.elementExists(target)) return;
80
+ const detail = `Element callback "${node.action}" at ${base} targets elementId "${target}", which is not an element in this widget`;
81
+ if (ctx.mode === "widget") {
82
+ ctx.errors.push({
83
+ path: `${base}.elementId`,
84
+ message: detail,
85
+ hint: "The runtime looks the callback up on that element, so the step silently does nothing. Use the ref of an element the batch authors, or omit elementId to act on the flow host."
86
+ });
87
+ return;
88
+ }
89
+ warnOnce(ctx, `Element callback "${node.action}" at ${base} targets elementId "${target}", which is not an element in this space — the step resolves to nothing and does nothing. Point it at a real element ref, or omit elementId to act on the flow host.`);
90
+ };
66
91
  var checkElementCallback = (node, base, ctx, hostRef) => {
92
+ checkCallbackTarget(node, base, ctx);
67
93
  const builtin = getElementCallback(node.action);
68
94
  if (!builtin) {
69
95
  if (getUtility(node.action)) warnOnce(ctx, `"${node.action}" at ${base} is a utility, not an element callback — use nodeType "utility".`);
@@ -74,7 +100,7 @@ var checkElementCallback = (node, base, ctx, hostRef) => {
74
100
  return;
75
101
  }
76
102
  if (node.params && builtin.strictParams) checkParams("Element callback", node.action, node.params, builtin.params, base, ctx);
77
- if (node.action === "setState") checkSetStateKey(node, base, ctx, hostRef);
103
+ if (ELEMENT_FIELD_ACTIONS.has(node.action)) checkElementFieldKey(node, base, ctx, hostRef);
78
104
  };
79
105
  var checkUtility = (node, base, ctx) => {
80
106
  if (node.elementId && !NULLISH_ELEMENT_IDS.has(node.elementId)) warnOnce(ctx, `Utility "${node.action}" at ${base} has elementId "${node.elementId}" — a utility takes NO element (it is resolved by its action alone). Omit elementId; the MCP stores null. Pointing it at an element is a no-op.`);
@@ -87,6 +113,14 @@ var checkUtility = (node, base, ctx) => {
87
113
  if (node.params && utility.strictParams) checkParams("Utility", node.action, node.params, utility.params, base, ctx);
88
114
  };
89
115
  var checkInteractionNode = (node, base, ctx, hostRef) => {
116
+ if (node.nodeType === "task") {
117
+ ctx.errors.push({
118
+ path: `${base}.nodeType`,
119
+ message: `Step "${node.action}" is a server task, which cannot run in a page flow`,
120
+ hint: "Put it in a server action (upsertAction) and call that action from this flow"
121
+ });
122
+ return;
123
+ }
90
124
  checkObservedName(node.action, ctx.observedActions, "Interaction action", "plitzi://interactions", `${base}.action`, ctx);
91
125
  if (node.elementId === "undefined" || node.elementId === "null") warnOnce(ctx, `Node "${node.action}" at ${base} has the literal string elementId "${node.elementId}" — a stringified nullish value. Re-save the step: elementId must be a real element ref, a source module, or empty for a utility.`);
92
126
  switch (node.nodeType) {
@@ -1,4 +1,4 @@
1
- import { isValidIdRef } from "@plitzi/sdk-schema/helpers/idRef";
1
+ import { isValidElementId } from "@plitzi/sdk-schema/helpers/elementId";
2
2
  //#region src/modules/mcp/tools/shared/validator/refs.ts
3
3
  var REF_RE = /^[a-zA-Z0-9._-]+$/;
4
4
  var checkRef = (ref, path, ctx) => {
@@ -18,10 +18,10 @@ var checkRef = (ref, path, ctx) => {
18
18
  };
19
19
  var checkIdRef = (ref, path, ctx) => {
20
20
  checkRef(ref, path, ctx);
21
- if (ref && REF_RE.test(ref) && !isValidIdRef(ref)) ctx.errors.push({
21
+ if (ref && REF_RE.test(ref) && !isValidElementId(ref)) ctx.errors.push({
22
22
  path,
23
- message: `Ref "${ref}" is not a valid idRef`,
24
- hint: "Use only letters, numbers, hyphens and underscores (e.g. \"hero-cta\" or \"my_list_card\"). This ref becomes the element idRef, which the runtime embeds in source names like `apiContainer_<idRef>.field` and in interaction targets — a dot would break those paths."
23
+ message: `"${ref}" is not a valid element name`,
24
+ hint: "Use only letters, numbers, hyphens and underscores (e.g. \"hero-cta\" or \"my_list_card\"). The name IS the element id, which the runtime embeds in source names like `apiContainer_<id>.field` and in interaction targets — a dot would break those paths."
25
25
  });
26
26
  };
27
27
  //#endregion
@@ -34,7 +34,7 @@ export declare const validateShape: {
34
34
  type: import('zod').ZodLiteral<"patchElement">;
35
35
  pageRef: import('zod').ZodString;
36
36
  ref: import('zod').ZodString;
37
- idRef: import('zod').ZodOptional<import('zod').ZodString>;
37
+ rename: import('zod').ZodOptional<import('zod').ZodString>;
38
38
  label: import('zod').ZodOptional<import('zod').ZodString>;
39
39
  subType: import('zod').ZodOptional<import('zod').ZodString>;
40
40
  props: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
@@ -72,10 +72,31 @@ export declare const validateShape: {
72
72
  slug: import('zod').ZodOptional<import('zod').ZodString>;
73
73
  folder: import('zod').ZodOptional<import('zod').ZodNullable<import('zod').ZodString>>;
74
74
  default: import('zod').ZodOptional<import('zod').ZodBoolean>;
75
+ layout: import('zod').ZodOptional<import('zod').ZodNullable<import('zod').ZodString>>;
76
+ layoutContainer: import('zod').ZodOptional<import('zod').ZodNullable<import('zod').ZodString>>;
75
77
  enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
76
78
  }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
77
79
  type: import('zod').ZodLiteral<"deletePage">;
78
80
  ref: import('zod').ZodString;
81
+ }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
82
+ type: import('zod').ZodLiteral<"upsertLayout">;
83
+ ref: import('zod').ZodString;
84
+ label: import('zod').ZodOptional<import('zod').ZodString>;
85
+ subType: import('zod').ZodOptional<import('zod').ZodEnum<{
86
+ footer: "footer";
87
+ main: "main";
88
+ header: "header";
89
+ div: "div";
90
+ nav: "nav";
91
+ section: "section";
92
+ article: "article";
93
+ aside: "aside";
94
+ address: "address";
95
+ figure: "figure";
96
+ }>>;
97
+ }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
98
+ type: import('zod').ZodLiteral<"deleteLayout">;
99
+ ref: import('zod').ZodString;
79
100
  }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
80
101
  type: import('zod').ZodLiteral<"upsertFolder">;
81
102
  ref: import('zod').ZodString;
@@ -116,7 +137,7 @@ export declare const validateShape: {
116
137
  params: import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>;
117
138
  enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
118
139
  }, import('zod/v4/core').$strip>>>;
119
- when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown>>>;
140
+ when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
120
141
  enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
121
142
  }, import('zod/v4/core').$strip>;
122
143
  }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
@@ -136,7 +157,7 @@ export declare const validateShape: {
136
157
  params: import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>;
137
158
  enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
138
159
  }, import('zod/v4/core').$strip>>>;
139
- when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown>>>;
160
+ when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
140
161
  enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
141
162
  }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
142
163
  type: import('zod').ZodLiteral<"deleteBinding">;
@@ -166,7 +187,7 @@ export declare const validateShape: {
166
187
  action: import('zod').ZodString;
167
188
  params: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
168
189
  enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
169
- when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown>>>;
190
+ when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
170
191
  elementId: import('zod').ZodOptional<import('zod').ZodString>;
171
192
  preview: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
172
193
  }, import('zod/v4/core').$strip>>;
@@ -179,7 +200,7 @@ export declare const validateShape: {
179
200
  action: import('zod').ZodOptional<import('zod').ZodString>;
180
201
  params: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
181
202
  enabled: import('zod').ZodOptional<import('zod').ZodBoolean>;
182
- when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/plitzi-ui/components/QueryBuilder').RuleGroup, unknown>>>;
203
+ when: import('zod').ZodOptional<import('zod').ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, import('zod/v4/core').$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
183
204
  elementId: import('zod').ZodOptional<import('zod').ZodString>;
184
205
  preview: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
185
206
  }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
@@ -468,6 +489,38 @@ export declare const validateShape: {
468
489
  custom: "custom";
469
490
  }>;
470
491
  name: import('zod').ZodString;
492
+ }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
493
+ type: import('zod').ZodLiteral<"upsertFont">;
494
+ family: import('zod').ZodString;
495
+ source: import('zod').ZodEnum<{
496
+ system: "system";
497
+ hosted: "hosted";
498
+ google: "google";
499
+ remote: "remote";
500
+ }>;
501
+ fallback: import('zod').ZodString;
502
+ weights: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodNumber>>;
503
+ styles: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodEnum<{
504
+ normal: "normal";
505
+ italic: "italic";
506
+ }>>>;
507
+ stylesheet: import('zod').ZodOptional<import('zod').ZodString>;
508
+ files: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodObject<{
509
+ weight: import('zod').ZodNumber;
510
+ style: import('zod').ZodEnum<{
511
+ normal: "normal";
512
+ italic: "italic";
513
+ }>;
514
+ format: import('zod').ZodEnum<{
515
+ woff2: "woff2";
516
+ woff: "woff";
517
+ }>;
518
+ url: import('zod').ZodOptional<import('zod').ZodString>;
519
+ path: import('zod').ZodOptional<import('zod').ZodString>;
520
+ }, import('zod/v4/core').$strip>>>;
521
+ }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
522
+ type: import('zod').ZodLiteral<"deleteFont">;
523
+ family: import('zod').ZodString;
471
524
  }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
472
525
  type: import('zod').ZodLiteral<"upsertConnector">;
473
526
  ref: import('zod').ZodString;
@@ -486,8 +539,8 @@ export declare const validateShape: {
486
539
  headers: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>>;
487
540
  pagination: import('zod').ZodOptional<import('zod').ZodEnum<{
488
541
  page: "page";
489
- cursor: "cursor";
490
542
  offset: "offset";
543
+ cursor: "cursor";
491
544
  }>>;
492
545
  operators: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>>;
493
546
  mediaBaseUrl: import('zod').ZodOptional<import('zod').ZodString>;
@@ -496,14 +549,14 @@ export declare const validateShape: {
496
549
  file: "file";
497
550
  text: "text";
498
551
  color: "color";
499
- link: "link";
500
- image: "image";
501
- video: "video";
502
552
  switch: "switch";
503
553
  email: "email";
504
554
  date: "date";
505
555
  richText: "richText";
556
+ image: "image";
506
557
  multiImage: "multiImage";
558
+ video: "video";
559
+ link: "link";
507
560
  phone: "phone";
508
561
  option: "option";
509
562
  }>>>;
@@ -530,8 +583,8 @@ export declare const validateShape: {
530
583
  body: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>>;
531
584
  pagination: import('zod').ZodOptional<import('zod').ZodEnum<{
532
585
  page: "page";
533
- cursor: "cursor";
534
586
  offset: "offset";
587
+ cursor: "cursor";
535
588
  }>>;
536
589
  }, import('zod/v4/core').$strip>>;
537
590
  write: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodObject<{
@@ -574,8 +627,8 @@ export declare const validateShape: {
574
627
  headers: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>>;
575
628
  pagination: import('zod').ZodOptional<import('zod').ZodEnum<{
576
629
  page: "page";
577
- cursor: "cursor";
578
630
  offset: "offset";
631
+ cursor: "cursor";
579
632
  }>>;
580
633
  operators: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>>;
581
634
  mediaBaseUrl: import('zod').ZodOptional<import('zod').ZodString>;
@@ -584,14 +637,14 @@ export declare const validateShape: {
584
637
  file: "file";
585
638
  text: "text";
586
639
  color: "color";
587
- link: "link";
588
- image: "image";
589
- video: "video";
590
640
  switch: "switch";
591
641
  email: "email";
592
642
  date: "date";
593
643
  richText: "richText";
644
+ image: "image";
594
645
  multiImage: "multiImage";
646
+ video: "video";
647
+ link: "link";
595
648
  phone: "phone";
596
649
  option: "option";
597
650
  }>>>;
@@ -618,8 +671,8 @@ export declare const validateShape: {
618
671
  body: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodString>>;
619
672
  pagination: import('zod').ZodOptional<import('zod').ZodEnum<{
620
673
  page: "page";
621
- cursor: "cursor";
622
674
  offset: "offset";
675
+ cursor: "cursor";
623
676
  }>>;
624
677
  }, import('zod/v4/core').$strip>>>>;
625
678
  write: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodNullable<import('zod').ZodObject<{
@@ -647,6 +700,87 @@ export declare const validateShape: {
647
700
  }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
648
701
  type: import('zod').ZodLiteral<"deleteConnector">;
649
702
  ref: import('zod').ZodString;
703
+ }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
704
+ type: import('zod').ZodLiteral<"upsertAction">;
705
+ ref: import('zod').ZodString;
706
+ name: import('zod').ZodString;
707
+ description: import('zod').ZodOptional<import('zod').ZodString>;
708
+ output: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodObject<{
709
+ type: import('zod').ZodEnum<{
710
+ number: "number";
711
+ boolean: "boolean";
712
+ file: "file";
713
+ json: "json";
714
+ text: "text";
715
+ date: "date";
716
+ }>;
717
+ required: import('zod').ZodOptional<import('zod').ZodBoolean>;
718
+ defaultValue: import('zod').ZodOptional<import('zod').ZodUnion<readonly [import('zod').ZodString, import('zod').ZodNumber, import('zod').ZodBoolean]>>;
719
+ label: import('zod').ZodOptional<import('zod').ZodString>;
720
+ }, import('zod/v4/core').$strip>>>;
721
+ nodes: import('zod').ZodArray<import('zod').ZodObject<{
722
+ id: import('zod').ZodString;
723
+ title: import('zod').ZodString;
724
+ type: import('zod').ZodEnum<{
725
+ trigger: "trigger";
726
+ task: "task";
727
+ }>;
728
+ action: import('zod').ZodString;
729
+ params: import('zod').ZodDefault<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
730
+ afterNode: import('zod').ZodDefault<import('zod').ZodString>;
731
+ beforeNode: import('zod').ZodDefault<import('zod').ZodString>;
732
+ enabled: import('zod').ZodDefault<import('zod').ZodBoolean>;
733
+ when: import('zod').ZodOptional<import('zod').ZodUnknown>;
734
+ remove: import('zod').ZodOptional<import('zod').ZodBoolean>;
735
+ }, import('zod/v4/core').$strip>>;
736
+ limits: import('zod').ZodOptional<import('zod').ZodObject<{
737
+ timeoutMs: import('zod').ZodOptional<import('zod').ZodNumber>;
738
+ streamTimeoutMs: import('zod').ZodOptional<import('zod').ZodNumber>;
739
+ maxNodes: import('zod').ZodOptional<import('zod').ZodNumber>;
740
+ maxRequests: import('zod').ZodOptional<import('zod').ZodNumber>;
741
+ }, import('zod/v4/core').$strip>>;
742
+ }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
743
+ type: import('zod').ZodLiteral<"patchAction">;
744
+ ref: import('zod').ZodString;
745
+ name: import('zod').ZodOptional<import('zod').ZodString>;
746
+ description: import('zod').ZodOptional<import('zod').ZodString>;
747
+ output: import('zod').ZodOptional<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodNullable<import('zod').ZodObject<{
748
+ type: import('zod').ZodEnum<{
749
+ number: "number";
750
+ boolean: "boolean";
751
+ file: "file";
752
+ json: "json";
753
+ text: "text";
754
+ date: "date";
755
+ }>;
756
+ required: import('zod').ZodOptional<import('zod').ZodBoolean>;
757
+ defaultValue: import('zod').ZodOptional<import('zod').ZodUnion<readonly [import('zod').ZodString, import('zod').ZodNumber, import('zod').ZodBoolean]>>;
758
+ label: import('zod').ZodOptional<import('zod').ZodString>;
759
+ }, import('zod/v4/core').$strip>>>>;
760
+ nodes: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodObject<{
761
+ id: import('zod').ZodString;
762
+ title: import('zod').ZodString;
763
+ type: import('zod').ZodEnum<{
764
+ trigger: "trigger";
765
+ task: "task";
766
+ }>;
767
+ action: import('zod').ZodString;
768
+ params: import('zod').ZodDefault<import('zod').ZodRecord<import('zod').ZodString, import('zod').ZodUnknown>>;
769
+ afterNode: import('zod').ZodDefault<import('zod').ZodString>;
770
+ beforeNode: import('zod').ZodDefault<import('zod').ZodString>;
771
+ enabled: import('zod').ZodDefault<import('zod').ZodBoolean>;
772
+ when: import('zod').ZodOptional<import('zod').ZodUnknown>;
773
+ remove: import('zod').ZodOptional<import('zod').ZodBoolean>;
774
+ }, import('zod/v4/core').$strip>>>;
775
+ limits: import('zod').ZodOptional<import('zod').ZodObject<{
776
+ timeoutMs: import('zod').ZodOptional<import('zod').ZodNumber>;
777
+ streamTimeoutMs: import('zod').ZodOptional<import('zod').ZodNumber>;
778
+ maxNodes: import('zod').ZodOptional<import('zod').ZodNumber>;
779
+ maxRequests: import('zod').ZodOptional<import('zod').ZodNumber>;
780
+ }, import('zod/v4/core').$strip>>;
781
+ }, import('zod/v4/core').$strip>, import('zod').ZodObject<{
782
+ type: import('zod').ZodLiteral<"deleteAction">;
783
+ ref: import('zod').ZodString;
650
784
  }, import('zod/v4/core').$strip>], "type">>;
651
785
  };
652
786
  export declare const validate: (input: ValidateInput, space: Space) => ValidationResult;
@@ -1,7 +1,9 @@
1
+ import { CssProps } from '@plitzi/sdk-authoring';
1
2
  import { ElementRuntime, Environment } from '@plitzi/sdk-shared';
2
3
  export type Env = Environment;
3
- /** CSS declarations for one selector state. Keys are kebab-case CSS properties (see plitzi://css-properties). */
4
- export type CssProps = Record<string, string | number>;
4
+ /** CSS declarations for one selector state. Keys are kebab-case CSS properties (see plitzi://css-properties).
5
+ * Owned by the style engine, which is also what expands the shorthands an agent is allowed to write. */
6
+ export type { CssProps };
5
7
  export interface DisplayModeCss {
6
8
  desktop?: CssProps;
7
9
  tablet?: CssProps;
@@ -25,9 +27,29 @@ export interface AIPageSummary {
25
27
  enabled: boolean;
26
28
  /** The ref of the folder this page lives in (a PageFolder id), or undefined for a root-level page. */
27
29
  folder?: string;
30
+ /** The layout shell this page renders inside, if any — read it as a page: `pages/{layout}`. */
31
+ layout?: string;
32
+ /** The container INSIDE that shell where this page's own body is placed. */
33
+ layoutSlot?: string;
28
34
  elementCount: number;
29
35
  }
30
- /** A page folder in the sidebar tree. `ref` is the folder's id (there is no separate idRef); pages reference it
36
+ /**
37
+ * A shared layout shell: the header/sidebar/footer several pages render inside.
38
+ *
39
+ * It is a root of its own — not in the page list, owned by nobody — and a page points at it by `layout`. Its
40
+ * elements are read and edited exactly like a page's: `pages/{ref}` for the skeleton, and `pageRef: "{ref}"` on
41
+ * any element/binding/interaction op.
42
+ */
43
+ export interface AILayoutSummary {
44
+ ref: string;
45
+ label: string;
46
+ /** The pages rendered inside this shell. */
47
+ usedBy: string[];
48
+ /** Where each of those pages puts its own body — the container inside this shell. */
49
+ slots: string[];
50
+ elementCount: number;
51
+ }
52
+ /** A page folder in the sidebar tree. `ref` is the folder's id; pages reference it
31
53
  * by that id via their `folder`, and nested folders via `parentId`. */
32
54
  export interface AIFolder {
33
55
  ref: string;
@@ -98,7 +120,14 @@ export interface AIBinding {
98
120
  /** Data bindings on an element, grouped by what they feed: element props (`attributes`), style values (`style`),
99
121
  * or initial-state keys (`initialState`). */
100
122
  export type AIBindings = Partial<Record<'attributes' | 'style' | 'initialState', AIBinding[]>>;
101
- export type AIInteractionNodeType = 'trigger' | 'globalCallback' | 'callback' | 'utility';
123
+ /**
124
+ * What a stored step is.
125
+ *
126
+ * `task` only ever belongs to a SERVER ACTION, and the write vocabulary for element flows (`interactionNodeType`)
127
+ * deliberately does not offer it. It is here because a read projects what is stored, and a page flow that somehow
128
+ * holds one should say so rather than being shown as something it is not — the validator flags it.
129
+ */
130
+ export type AIInteractionNodeType = 'trigger' | 'globalCallback' | 'callback' | 'utility' | 'task';
102
131
  /** One step of an interaction flow, projected from the stored doubly-linked node. Order is conveyed by the
103
132
  * position in `AIInteractionFlow.nodes`; the stored beforeNode/afterNode/flowId links are computed on write. */
104
133
  export interface AIInteractionNode {
@@ -5,6 +5,24 @@ export type PreviewRequestBody = {
5
5
  env?: string;
6
6
  pageRef?: string;
7
7
  operations?: Operation[];
8
+ /**
9
+ * Whether the response should carry the rendered HTML. Default true.
10
+ *
11
+ * Rendering it is the expensive half of a preview, and a caller on the way to a screenshot does not read it:
12
+ * the browser fetches the same draft at `?__pt=<token>` and renders it again. `false` asks for the token and
13
+ * the page path only — one server render instead of two. An older SSR ignores the field and still renders,
14
+ * which costs time but never correctness.
15
+ */
16
+ includeHtml?: boolean;
17
+ /**
18
+ * What the token minted for this preview is FOR.
19
+ *
20
+ * `once` — the default — is the capture path: the browser opens the URL, the render happens, the token is spent.
21
+ * `session` is somebody iterating: the URL keeps working until it expires, the draft follows them from page to
22
+ * page, and their refreshes are neither billed nor cached. Ask for a session only when a person is going to look
23
+ * at it, and end it with `DELETE` when they stop.
24
+ */
25
+ mode?: 'once' | 'session';
8
26
  };
9
27
  export type PreviewResult = {
10
28
  ok: true;
@@ -12,6 +30,7 @@ export type PreviewResult = {
12
30
  pagePath: string;
13
31
  html: string;
14
32
  stateVersion: string;
33
+ expiresInMs?: number;
15
34
  } | {
16
35
  ok: false;
17
36
  error: string;
@@ -20,6 +20,7 @@ export type ScreenshotInput = {
20
20
  pagePath: string;
21
21
  token?: string;
22
22
  viewports: Viewport[];
23
+ fullPage?: boolean;
23
24
  };
24
25
  /** How plitzi_screenshot reaches the headless-browser service. The consumer injects an implementation (an HTTP
25
26
  * client to the dedicated browser pod); absent → the tool is not registered. A capture that fails (pod down)
@@ -1,6 +1,6 @@
1
1
  import { AIDefinition, AIElementDetail, ValidationError } from './aiSchema';
2
2
  import { Operation } from '../tools/operations';
3
- import { ConnectorEntry, Schema, Style } from '@plitzi/sdk-shared';
3
+ import { ActionEntry, ConnectorEntry, Schema, Style } from '@plitzi/sdk-shared';
4
4
  /** The element schema, the style schema and the connectors persist independently (Space model / Style model / one
5
5
  * row per connector), so each has its own optional persister. When one is absent, that store is applied in memory
6
6
  * but reported unsaved. Connectors save and delete a row at a time — a batch touching two of them saves those two
@@ -10,6 +10,8 @@ export interface Persisters {
10
10
  style?: (style: Style) => Promise<void>;
11
11
  saveConnector?: (entry: ConnectorEntry) => Promise<void>;
12
12
  deleteConnector?: (connectorId: string) => Promise<void>;
13
+ saveAction?: (entry: ActionEntry) => Promise<void>;
14
+ deleteAction?: (actionId: string) => Promise<void>;
13
15
  }
14
16
  export interface Conflict {
15
17
  resourceUri: string;
@@ -61,6 +63,9 @@ export interface MutationOutcome {
61
63
  /** Ids of the connectors the batch created or updated, and of those it removed — each persists as its own row. */
62
64
  changedConnectors: string[];
63
65
  deletedConnectors: string[];
66
+ /** The same, for actions: one row each, so a batch writes exactly the ones it touched. */
67
+ changedActions: string[];
68
+ deletedActions: string[];
64
69
  }
65
70
  export interface ApplyInput {
66
71
  environment?: string;
package/dist/pipeline.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createMcpOnlyStage, createMcpStage } from "./stages/mcp.js";
2
- import { createOAuthGuardStage, createOAuthStage } from "./stages/oauth.js";
3
2
  import { previewStage } from "./stages/preview.js";
4
3
  import { createWidgetProxyStage } from "./stages/proxy.js";
5
4
  import { configStaticStage, healthStage } from "@plitzi/sdk-server/kernel";
5
+ import { createOAuthGuardStage, createOAuthStage } from "@plitzi/sdk-server/oauth";
6
6
  //#region src/pipeline.ts
7
7
  var buildMCPPipeline = (options = {}) => [
8
8
  healthStage,
@@ -2,8 +2,10 @@ import { PreviewRequestBody, PreviewResult } from '../modules/mcp/types';
2
2
  import { PluginManager, ServerCaches } from '@plitzi/sdk-server/ssr';
3
3
  import { SSRPageServerConfig, SSRTemplateFn } from '@plitzi/sdk-shared';
4
4
  /** Build a preview of a page: apply any unsaved `operations` to a clone (never persisted), render the resulting
5
- * draft to full HTML via the SSR pipeline, and stash the draft under a one-shot token so a browser can fetch
6
- * the exact same render at `?__pt=<token>` (for screenshots). With no operations it previews persisted state.
5
+ * draft to full HTML via the SSR pipeline, and stash the draft under a token so a browser can fetch the exact same
6
+ * render at `?__pt=<token>`. With no operations it previews persisted state.
7
+ *
8
+ * The token is one-shot unless `mode: 'session'` asks for one somebody can iterate against — see `mode`.
7
9
  *
8
10
  * Renders through the host page server's own singletons, which is why it takes them as arguments rather than
9
11
  * building any: this runs as a stage INSIDE an SSR server, not in the MCP process that calls it over HTTP. */
@@ -23,8 +23,10 @@ var syntheticRequest = (pagePath) => ({
23
23
  ctx: {}
24
24
  });
25
25
  /** Build a preview of a page: apply any unsaved `operations` to a clone (never persisted), render the resulting
26
- * draft to full HTML via the SSR pipeline, and stash the draft under a one-shot token so a browser can fetch
27
- * the exact same render at `?__pt=<token>` (for screenshots). With no operations it previews persisted state.
26
+ * draft to full HTML via the SSR pipeline, and stash the draft under a token so a browser can fetch the exact same
27
+ * render at `?__pt=<token>`. With no operations it previews persisted state.
28
+ *
29
+ * The token is one-shot unless `mode: 'session'` asks for one somebody can iterate against — see `mode`.
28
30
  *
29
31
  * Renders through the host page server's own singletons, which is why it takes them as arguments rather than
30
32
  * building any: this runs as a stage INSIDE an SSR server, not in the MCP process that calls it over HTTP. */
@@ -42,7 +44,8 @@ var createPreview = async (body, config, renderFn, pluginManager, caches) => {
42
44
  const draft = cloneSpace({
43
45
  schema: offlineData.schema,
44
46
  style: offlineData.style,
45
- connectors: []
47
+ connectors: [],
48
+ actions: []
46
49
  });
47
50
  const validation = validateOperations(draft, body.operations);
48
51
  if (!validation.valid) return {
@@ -65,18 +68,25 @@ var createPreview = async (body, config, renderFn, pluginManager, caches) => {
65
68
  };
66
69
  }
67
70
  const pagePath = resolvePagePath(draftOffline.schema, body.pageRef);
68
- const { body: html } = await buildBody(syntheticRequest(pagePath), config, body.spaceId, env, revision, renderFn, pluginManager, caches.offlineData, void 0, draftOffline);
71
+ let html;
72
+ if (body.includeHtml !== false) ({body: html} = await buildBody(syntheticRequest(pagePath), config, body.spaceId, env, revision, renderFn, pluginManager, caches.offlineData, void 0, draftOffline));
73
+ const reusable = body.mode === "session";
74
+ const ttlMs = reusable ? config.preview?.sessionTtlMs ?? 9e5 : config.preview?.ttlMs ?? 6e4;
69
75
  let token;
70
76
  if (config.draftStore) {
71
77
  token = randomUUID();
72
- await config.draftStore.put(token, draftOffline, config.preview?.ttlMs ?? 6e4);
78
+ await config.draftStore.put(token, draftOffline, {
79
+ ttlMs,
80
+ reusable
81
+ });
73
82
  }
74
83
  return {
75
84
  ok: true,
76
85
  token,
77
86
  pagePath,
78
87
  html: html ?? "",
79
- stateVersion: computeVersion(draftOffline)
88
+ stateVersion: computeVersion(draftOffline),
89
+ ...token ? { expiresInMs: ttlMs } : {}
80
90
  };
81
91
  };
82
92
  //#endregion
package/dist/server.d.ts CHANGED
@@ -8,7 +8,10 @@ export { createServer } from './createServer';
8
8
  export { buildMCPPipeline } from './pipeline';
9
9
  export { createMcpServer, handleMcp, serveMcp, readMcpBody } from './modules/mcp/handler';
10
10
  export { createHttpPreviewClient } from './modules/mcp/previewClient';
11
+ export { pluginCatalog, stringDeclarations } from './modules/mcp/catalogs/pluginCatalog';
11
12
  export { createHttpScreenshotClient } from './modules/mcp/screenshotClient';
13
+ export { createLocalScreenshotClient, resolveLocalBrowser } from './modules/mcp/localScreenshotClient';
14
+ export type { LocalScreenshotClientConfig } from './modules/mcp/localScreenshotClient';
12
15
  export type { McpRequestOptions } from './modules/mcp/handler';
13
16
  export type { McpServerContext } from './modules/mcp/server';
14
17
  export type { PreviewClient, ScreenshotClient } from './modules/mcp/types';
package/dist/server.js CHANGED
@@ -4,4 +4,6 @@ import { createHttpPreviewClient } from "./modules/mcp/previewClient.js";
4
4
  import { createHttpScreenshotClient } from "./modules/mcp/screenshotClient.js";
5
5
  import { buildMCPPipeline } from "./pipeline.js";
6
6
  import { createServer } from "./createServer.js";
7
- export { buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createMcpServer, createServer, handleMcp, readMcpBody, serveMcp };
7
+ import { createLocalScreenshotClient, resolveLocalBrowser } from "./modules/mcp/localScreenshotClient.js";
8
+ import { pluginCatalog, stringDeclarations } from "./modules/mcp/catalogs/pluginCatalog.js";
9
+ export { buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpServer, createServer, handleMcp, pluginCatalog, readMcpBody, resolveLocalBrowser, serveMcp, stringDeclarations };