@plitzi/sdk-mcp 0.37.2 → 0.37.4

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 (94) hide show
  1. package/CHANGELOG.md +1182 -0
  2. package/README.md +6 -2
  3. package/dist/createServer.js +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +2 -1
  6. package/dist/modules/mcp/accessibilityOutline.d.ts +38 -0
  7. package/dist/modules/mcp/accessibilityOutline.js +75 -0
  8. package/dist/modules/mcp/accessibilityOutline.test.d.ts +1 -0
  9. package/dist/modules/mcp/catalogs/index.d.ts +2 -2
  10. package/dist/modules/mcp/catalogs/index.js +2 -2
  11. package/dist/modules/mcp/catalogs/observed.js +2 -2
  12. package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +6 -3
  13. package/dist/modules/mcp/catalogs/pluginCatalog.js +12 -7
  14. package/dist/modules/mcp/helpers/agentPrompt.js +22 -5
  15. package/dist/modules/mcp/helpers/guide.d.ts +2 -2
  16. package/dist/modules/mcp/helpers/guide.js +212 -48
  17. package/dist/modules/mcp/helpers/interactions.d.ts +2 -1
  18. package/dist/modules/mcp/helpers/interactions.js +2 -0
  19. package/dist/modules/mcp/helpers/space.d.ts +6 -4
  20. package/dist/modules/mcp/helpers/space.js +7 -20
  21. package/dist/modules/mcp/helpers/uris.d.ts +3 -1
  22. package/dist/modules/mcp/helpers/uris.js +4 -1
  23. package/dist/modules/mcp/index.d.ts +2 -0
  24. package/dist/modules/mcp/localScreenshotClient.d.ts +11 -0
  25. package/dist/modules/mcp/localScreenshotClient.js +24 -9
  26. package/dist/modules/mcp/proxy/guard.d.ts +6 -0
  27. package/dist/modules/mcp/proxy/guard.js +8 -12
  28. package/dist/modules/mcp/resources/functions.d.ts +8 -0
  29. package/dist/modules/mcp/resources/functions.js +35 -0
  30. package/dist/modules/mcp/resources/register.d.ts +2 -1
  31. package/dist/modules/mcp/resources/register.js +49 -2
  32. package/dist/modules/mcp/resources/renderGuide.js +3 -2
  33. package/dist/modules/mcp/resources/router.js +3 -1
  34. package/dist/modules/mcp/screenshotClient.js +12 -4
  35. package/dist/modules/mcp/server.js +20 -10
  36. package/dist/modules/mcp/tests/guide.test.d.ts +1 -0
  37. package/dist/modules/mcp/tools/apply/dispatch.js +9 -1
  38. package/dist/modules/mcp/tools/apply/index.d.ts +34 -0
  39. package/dist/modules/mcp/tools/apply/index.js +35 -70
  40. package/dist/modules/mcp/tools/index.js +4 -2
  41. package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +0 -1
  42. package/dist/modules/mcp/tools/operations/functions/functions.test.d.ts +1 -0
  43. package/dist/modules/mcp/tools/operations/functions/index.d.ts +31 -0
  44. package/dist/modules/mcp/tools/operations/functions/index.js +48 -0
  45. package/dist/modules/mcp/tools/operations/index.d.ts +122 -2
  46. package/dist/modules/mcp/tools/operations/index.js +4 -3
  47. package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +5 -6
  48. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +3 -11
  49. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +6 -9
  50. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +5 -0
  51. package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +3 -1
  52. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +5 -0
  53. package/dist/modules/mcp/tools/operations/schema/operations.d.ts +27 -0
  54. package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +6 -5
  55. package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +6 -5
  56. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +17 -0
  57. package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +34 -5
  58. package/dist/modules/mcp/tools/operations/schema/shared.d.ts +6 -0
  59. package/dist/modules/mcp/tools/operations/schema/shared.js +5 -0
  60. package/dist/modules/mcp/tools/operations/schema/translator.js +3 -2
  61. package/dist/modules/mcp/tools/operations/schema/write.d.ts +10 -5
  62. package/dist/modules/mcp/tools/operations/schema/write.js +16 -16
  63. package/dist/modules/mcp/tools/preview.d.ts +27 -0
  64. package/dist/modules/mcp/tools/render.d.ts +27 -0
  65. package/dist/modules/mcp/tools/render.js +7 -43
  66. package/dist/modules/mcp/tools/screenshot.d.ts +39 -0
  67. package/dist/modules/mcp/tools/screenshot.js +40 -5
  68. package/dist/modules/mcp/tools/shared/draftBatch.d.ts +25 -0
  69. package/dist/modules/mcp/tools/shared/draftBatch.js +58 -0
  70. package/dist/modules/mcp/tools/shared/draftBatch.test.d.ts +1 -0
  71. package/dist/modules/mcp/tools/shared/lintDraft.d.ts +30 -0
  72. package/dist/modules/mcp/tools/shared/lintDraft.js +142 -0
  73. package/dist/modules/mcp/tools/shared/lintDraft.test.d.ts +1 -0
  74. package/dist/modules/mcp/tools/shared/tool.d.ts +4 -0
  75. package/dist/modules/mcp/tools/shared/validator/bindings.d.ts +0 -4
  76. package/dist/modules/mcp/tools/shared/validator/bindings.js +1 -60
  77. package/dist/modules/mcp/tools/shared/validator/elements.js +3 -15
  78. package/dist/modules/mcp/tools/shared/validator/index.d.ts +1 -4
  79. package/dist/modules/mcp/tools/shared/validator/index.js +25 -20
  80. package/dist/modules/mcp/tools/shared/validator/interactions.js +3 -58
  81. package/dist/modules/mcp/tools/tryFunction.d.ts +18 -0
  82. package/dist/modules/mcp/tools/tryFunction.js +43 -0
  83. package/dist/modules/mcp/tools/validate.d.ts +34 -0
  84. package/dist/modules/mcp/tools/validate.js +9 -26
  85. package/dist/modules/mcp/types/aiSchema.d.ts +8 -1
  86. package/dist/modules/mcp/types/previewTypes.d.ts +6 -0
  87. package/dist/modules/mcp/types/screenshotTypes.d.ts +16 -0
  88. package/dist/modules/mcp/types/toolTypes.d.ts +5 -1
  89. package/dist/preview/createPreview.js +5 -4
  90. package/dist/stages/preview.js +15 -1
  91. package/package.json +11 -10
  92. package/skills/plitzi-render/SKILL.md +1 -2
  93. package/dist/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
  94. package/dist/modules/mcp/tools/shared/validator/audit.js +0 -127
@@ -1,13 +1,9 @@
1
- import { cloneSpace } from "../../helpers/space.js";
2
- import { environment, operations } from "../operations/index.js";
3
- import { applyOperations } from "./dispatch.js";
1
+ import { functionFileUri, functionsUri } from "../../helpers/uris.js";
4
2
  import { changedResources, conflictMessage, detectConflicts, resolvedElements } from "./writeResult.js";
5
- import { expandOperations } from "../shared/expandOperations.js";
3
+ import { environment, operations } from "../operations/index.js";
4
+ import { draftBatch } from "../shared/draftBatch.js";
6
5
  import { defineTool } from "../shared/tool.js";
7
- import { validateOperations } from "../shared/validator/index.js";
8
- import { auditResources } from "../shared/validator/audit.js";
9
6
  import { z } from "zod";
10
- import { validateSchema } from "@plitzi/sdk-schema/helpers/schemaValidator";
11
7
  import { generateCache } from "@plitzi/sdk-style/StyleHelper";
12
8
  //#region src/modules/mcp/tools/apply/index.ts
13
9
  var applyShape = {
@@ -17,39 +13,18 @@ var applyShape = {
17
13
  operations
18
14
  };
19
15
  var noWarnings = (warnings) => warnings.length > 0 ? warnings : void 0;
20
- var schemaErrorToValidation = (error) => ({
21
- path: error.elementId ? `schema.${error.elementId}` : "schema",
22
- message: error.message,
23
- hint: "This batch would leave the schema inconsistent (broken parent/child link or a cycle); nothing was applied."
24
- });
16
+ /** Why the platform did not save the functions, as the batch's errors: each problem where it is, or the refusal. */
17
+ var functionsErrors = (saved, env) => "problems" in saved ? saved.problems.map((problem) => ({
18
+ path: problem.file ? `functions/${problem.file}${problem.line ? `:${String(problem.line)}` : ""}` : "functions",
19
+ message: problem.message,
20
+ hint: `Fix it with upsertFunctionFile; read ${functionFileUri(env, problem.file ?? "index.ts")} for the file`
21
+ })) : [{
22
+ path: "functions",
23
+ message: saved.refusal.error,
24
+ hint: `Read ${functionsUri(env)} again and redo the change on the current files`
25
+ }];
25
26
  var apply = async (input, space, persisters) => {
26
27
  const env = input.environment ?? "main";
27
- const expansion = expandOperations(input.operations);
28
- if (expansion.errors.length > 0) return {
29
- applied: false,
30
- persisted: false,
31
- summary: {
32
- created: 0,
33
- updated: 0,
34
- deleted: 0
35
- },
36
- changed: [],
37
- errors: expansion.errors
38
- };
39
- const ops = expansion.operations;
40
- const validation = validateOperations(space, ops);
41
- if (!validation.valid) return {
42
- applied: false,
43
- persisted: false,
44
- summary: {
45
- created: 0,
46
- updated: 0,
47
- deleted: 0
48
- },
49
- changed: [],
50
- errors: validation.errors,
51
- warnings: noWarnings(validation.warnings)
52
- };
53
28
  const conflicts = detectConflicts(space, env, input.expectedResourceVersions);
54
29
  if (conflicts.length > 0) return {
55
30
  applied: false,
@@ -65,9 +40,8 @@ var apply = async (input, space, persisters) => {
65
40
  conflicts
66
41
  }
67
42
  };
68
- const draft = cloneSpace(space);
69
- const outcome = applyOperations(draft, env, ops);
70
- if (outcome.errors.length > 0) return {
43
+ const result = draftBatch(space, env, input.operations);
44
+ if (!result.ok) return {
71
45
  applied: false,
72
46
  persisted: false,
73
47
  summary: {
@@ -76,36 +50,10 @@ var apply = async (input, space, persisters) => {
76
50
  deleted: 0
77
51
  },
78
52
  changed: [],
79
- errors: outcome.errors,
80
- warnings: noWarnings(validation.warnings)
81
- };
82
- const integrity = validateSchema(draft.schema);
83
- if (!integrity.valid) return {
84
- applied: false,
85
- persisted: false,
86
- summary: {
87
- created: 0,
88
- updated: 0,
89
- deleted: 0
90
- },
91
- changed: [],
92
- errors: integrity.errors.map(schemaErrorToValidation),
93
- warnings: noWarnings(validation.warnings)
94
- };
95
- const audit = auditResources(draft, ops);
96
- const warnings = [...validation.warnings, ...audit.warnings];
97
- if (audit.errors.length > 0) return {
98
- applied: false,
99
- persisted: false,
100
- summary: {
101
- created: 0,
102
- updated: 0,
103
- deleted: 0
104
- },
105
- changed: [],
106
- errors: audit.errors,
107
- warnings: noWarnings(warnings)
53
+ errors: result.errors,
54
+ warnings: noWarnings(result.warnings)
108
55
  };
56
+ const { draft, outcome, warnings } = result;
109
57
  if (input.dryRun) return {
110
58
  applied: false,
111
59
  dryRun: true,
@@ -119,6 +67,23 @@ var apply = async (input, space, persisters) => {
119
67
  warnings: noWarnings(warnings)
120
68
  };
121
69
  let persisted = true;
70
+ if (outcome.changedFunctions && draft.functions) {
71
+ if (persisters?.saveFunctions) {
72
+ const saved = await persisters.saveFunctions(draft.functions.files, space.functions?.version ?? "");
73
+ if (!saved.ok) return {
74
+ applied: false,
75
+ persisted: false,
76
+ summary: {
77
+ created: 0,
78
+ updated: 0,
79
+ deleted: 0
80
+ },
81
+ changed: [],
82
+ errors: functionsErrors(saved, env),
83
+ warnings: noWarnings(warnings)
84
+ };
85
+ } else persisted = false;
86
+ }
122
87
  if (outcome.changedSchema) {
123
88
  if (persisters?.schema) await persisters.schema(draft.schema);
124
89
  else persisted = false;
@@ -1,12 +1,13 @@
1
1
  import { operation } from "./operations/index.js";
2
- import { applyOperations } from "./apply/dispatch.js";
3
2
  import { validateOperations } from "./shared/validator/index.js";
3
+ import { applyOperations } from "./apply/dispatch.js";
4
4
  import { apply, applyShape, applyTool } from "./apply/index.js";
5
5
  import { previewTool } from "./preview.js";
6
6
  import { read, readShape, readTool } from "./read.js";
7
7
  import { renderTool } from "./render.js";
8
8
  import { screenshotTool } from "./screenshot.js";
9
9
  import { search, searchShape, searchTool } from "./search.js";
10
+ import { tryFunctionTool } from "./tryFunction.js";
10
11
  import { validate, validateShape, validateTool } from "./validate.js";
11
12
  //#region src/modules/mcp/tools/index.ts
12
13
  /** The MCP tool registry — the single source both hosts (the standalone server and the in-process AI bridge)
@@ -18,7 +19,8 @@ var tools = [
18
19
  readTool,
19
20
  renderTool,
20
21
  previewTool,
21
- screenshotTool
22
+ screenshotTool,
23
+ tryFunctionTool
22
24
  ];
23
25
  //#endregion
24
26
  export { apply, applyOperations, applyShape, operation, read, readShape, search, searchShape, tools, validate, validateOperations, validateShape };
@@ -86,4 +86,3 @@ export declare const connectorConnection: z.ZodObject<{
86
86
  }>>>;
87
87
  projection: z.ZodOptional<z.ZodLiteral<"full">>;
88
88
  }, z.core.$strip>;
89
- export type ConnectorConnectionInput = z.infer<typeof connectorConnection>;
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ import { OpResult, Space } from '../../../helpers';
3
+ import { Env } from '../../../types';
4
+ export declare const upsertFunctionFileOp: z.ZodObject<{
5
+ type: z.ZodLiteral<"upsertFunctionFile">;
6
+ path: z.ZodString;
7
+ content: z.ZodString;
8
+ }, z.core.$strip>;
9
+ export declare const deleteFunctionFileOp: z.ZodObject<{
10
+ type: z.ZodLiteral<"deleteFunctionFile">;
11
+ path: z.ZodString;
12
+ }, z.core.$strip>;
13
+ export type UpsertFunctionFile = z.infer<typeof upsertFunctionFileOp>;
14
+ export type DeleteFunctionFile = z.infer<typeof deleteFunctionFileOp>;
15
+ /**
16
+ * The functions are one store of files, saved whole: an op edits the draft's copy, and the batch saves the files it
17
+ * leaves — built and checked by the platform then, which is where a problem in them is found and answered.
18
+ */
19
+ export declare const upsertFunctionFile: (space: Space, env: Env, op: UpsertFunctionFile) => OpResult;
20
+ export declare const deleteFunctionFile: (space: Space, env: Env, op: DeleteFunctionFile) => OpResult;
21
+ export declare const functionOps: {
22
+ upsertFunctionFile: z.ZodObject<{
23
+ type: z.ZodLiteral<"upsertFunctionFile">;
24
+ path: z.ZodString;
25
+ content: z.ZodString;
26
+ }, z.core.$strip>;
27
+ deleteFunctionFile: z.ZodObject<{
28
+ type: z.ZodLiteral<"deleteFunctionFile">;
29
+ path: z.ZodString;
30
+ }, z.core.$strip>;
31
+ };
@@ -0,0 +1,48 @@
1
+ import { functionFileUri, functionsUri } from "../../../helpers/uris.js";
2
+ import { empty, fail } from "../../../helpers/opResult.js";
3
+ import { z } from "zod";
4
+ //#region src/modules/mcp/tools/operations/functions/index.ts
5
+ var upsertFunctionFileOp = z.object({
6
+ type: z.literal("upsertFunctionFile"),
7
+ path: z.string().describe("e.g. \"index.ts\", \"lib/feed.ts\""),
8
+ content: z.string().describe("The whole file")
9
+ }).describe("Write one file of the space’s functions (its own server code), whole. See plitzi://guide.");
10
+ var deleteFunctionFileOp = z.object({
11
+ type: z.literal("deleteFunctionFile"),
12
+ path: z.string()
13
+ }).describe("Remove one file of the space’s functions.");
14
+ var unavailable = () => fail("type", "This deployment runs no space functions", "Author the flow from the server tasks it offers instead");
15
+ /**
16
+ * The functions are one store of files, saved whole: an op edits the draft's copy, and the batch saves the files it
17
+ * leaves — built and checked by the platform then, which is where a problem in them is found and answered.
18
+ */
19
+ var upsertFunctionFile = (space, env, op) => {
20
+ if (!space.functions) return unavailable();
21
+ const exists = Object.hasOwn(space.functions.files, op.path);
22
+ space.functions.files = {
23
+ ...space.functions.files,
24
+ [op.path]: op.content
25
+ };
26
+ return {
27
+ ...empty(),
28
+ ...exists ? { updated: 1 } : { created: 1 },
29
+ staleResources: [functionsUri(env), functionFileUri(env, op.path)]
30
+ };
31
+ };
32
+ var deleteFunctionFile = (space, env, op) => {
33
+ if (!space.functions) return unavailable();
34
+ if (!Object.hasOwn(space.functions.files, op.path)) return fail("path", `The functions have no file "${op.path}"`, `Read ${functionsUri(env)} for the files they have`, Object.keys(space.functions.files));
35
+ const { [op.path]: _removed, ...files } = space.functions.files;
36
+ space.functions.files = files;
37
+ return {
38
+ ...empty(),
39
+ deleted: 1,
40
+ staleResources: [functionsUri(env), functionFileUri(env, op.path)]
41
+ };
42
+ };
43
+ var functionOps = {
44
+ upsertFunctionFile: upsertFunctionFileOp,
45
+ deleteFunctionFile: deleteFunctionFileOp
46
+ };
47
+ //#endregion
48
+ export { deleteFunctionFile, deleteFunctionFileOp, functionOps, upsertFunctionFile, upsertFunctionFileOp };
@@ -187,6 +187,11 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
187
187
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
188
188
  enabled: z.ZodOptional<z.ZodBoolean>;
189
189
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
190
+ whileRunning: z.ZodOptional<z.ZodEnum<{
191
+ skip: "skip";
192
+ parallel: "parallel";
193
+ queue: "queue";
194
+ }>>;
190
195
  elementId: z.ZodOptional<z.ZodString>;
191
196
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
192
197
  }, z.core.$strip>>;
@@ -200,6 +205,11 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
200
205
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
201
206
  enabled: z.ZodOptional<z.ZodBoolean>;
202
207
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
208
+ whileRunning: z.ZodOptional<z.ZodEnum<{
209
+ skip: "skip";
210
+ parallel: "parallel";
211
+ queue: "queue";
212
+ }>>;
203
213
  elementId: z.ZodOptional<z.ZodString>;
204
214
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
205
215
  }, z.core.$strip>, z.ZodObject<{
@@ -216,6 +226,8 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
216
226
  localStorage: "localStorage";
217
227
  sessionStorage: "sessionStorage";
218
228
  }>>;
229
+ transientState: z.ZodOptional<z.ZodArray<z.ZodString>>;
230
+ paintedState: z.ZodOptional<z.ZodArray<z.ZodString>>;
219
231
  userProvider: z.ZodOptional<z.ZodString>;
220
232
  tokenStorage: z.ZodOptional<z.ZodEnum<{
221
233
  "": "";
@@ -238,6 +250,21 @@ export declare const documentOperation: z.ZodDiscriminatedUnion<readonly [z.ZodO
238
250
  strict: "strict";
239
251
  }>>;
240
252
  sessionRevalidateSeconds: z.ZodOptional<z.ZodNumber>;
253
+ channels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
254
+ access: z.ZodObject<{
255
+ mode: z.ZodEnum<{
256
+ public: "public";
257
+ session: "session";
258
+ role: "role";
259
+ }>;
260
+ permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
261
+ }, z.core.$strip>;
262
+ publish: z.ZodOptional<z.ZodEnum<{
263
+ server: "server";
264
+ clients: "clients";
265
+ }>>;
266
+ presence: z.ZodOptional<z.ZodBoolean>;
267
+ }, z.core.$strip>>>>;
241
268
  }, z.core.$strip>, z.ZodObject<{
242
269
  desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
243
270
  tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
@@ -917,6 +944,11 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
917
944
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
918
945
  enabled: z.ZodOptional<z.ZodBoolean>;
919
946
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
947
+ whileRunning: z.ZodOptional<z.ZodEnum<{
948
+ skip: "skip";
949
+ parallel: "parallel";
950
+ queue: "queue";
951
+ }>>;
920
952
  elementId: z.ZodOptional<z.ZodString>;
921
953
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
922
954
  }, z.core.$strip>>;
@@ -930,6 +962,11 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
930
962
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
931
963
  enabled: z.ZodOptional<z.ZodBoolean>;
932
964
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
965
+ whileRunning: z.ZodOptional<z.ZodEnum<{
966
+ skip: "skip";
967
+ parallel: "parallel";
968
+ queue: "queue";
969
+ }>>;
933
970
  elementId: z.ZodOptional<z.ZodString>;
934
971
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
935
972
  }, z.core.$strip>, z.ZodObject<{
@@ -946,6 +983,8 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
946
983
  localStorage: "localStorage";
947
984
  sessionStorage: "sessionStorage";
948
985
  }>>;
986
+ transientState: z.ZodOptional<z.ZodArray<z.ZodString>>;
987
+ paintedState: z.ZodOptional<z.ZodArray<z.ZodString>>;
949
988
  userProvider: z.ZodOptional<z.ZodString>;
950
989
  tokenStorage: z.ZodOptional<z.ZodEnum<{
951
990
  "": "";
@@ -968,6 +1007,21 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
968
1007
  strict: "strict";
969
1008
  }>>;
970
1009
  sessionRevalidateSeconds: z.ZodOptional<z.ZodNumber>;
1010
+ channels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
1011
+ access: z.ZodObject<{
1012
+ mode: z.ZodEnum<{
1013
+ public: "public";
1014
+ session: "session";
1015
+ role: "role";
1016
+ }>;
1017
+ permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
1018
+ }, z.core.$strip>;
1019
+ publish: z.ZodOptional<z.ZodEnum<{
1020
+ server: "server";
1021
+ clients: "clients";
1022
+ }>>;
1023
+ presence: z.ZodOptional<z.ZodBoolean>;
1024
+ }, z.core.$strip>>>>;
971
1025
  }, z.core.$strip>, z.ZodObject<{
972
1026
  desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
973
1027
  tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
@@ -1720,12 +1774,17 @@ export declare const operation: z.ZodDiscriminatedUnion<[z.ZodObject<{
1720
1774
  }, z.core.$strip>, z.ZodObject<{
1721
1775
  type: z.ZodLiteral<"deleteAction">;
1722
1776
  ref: z.ZodString;
1777
+ }, z.core.$strip>, z.ZodObject<{
1778
+ type: z.ZodLiteral<"upsertFunctionFile">;
1779
+ path: z.ZodString;
1780
+ content: z.ZodString;
1781
+ }, z.core.$strip>, z.ZodObject<{
1782
+ type: z.ZodLiteral<"deleteFunctionFile">;
1783
+ path: z.ZodString;
1723
1784
  }, z.core.$strip>], "type">;
1724
1785
  export type Operation = z.infer<typeof operation>;
1725
1786
  export type OperationType = Operation['type'];
1726
1787
  export declare const isStyleOp: (type: OperationType) => boolean;
1727
- export declare const isConnectorOp: (type: OperationType) => boolean;
1728
- export declare const isActionOp: (type: OperationType) => boolean;
1729
1788
  export declare const MAX_OPS = 1000;
1730
1789
  export declare const environment: z.ZodOptional<z.ZodString>;
1731
1790
  export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1914,6 +1973,11 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
1914
1973
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1915
1974
  enabled: z.ZodOptional<z.ZodBoolean>;
1916
1975
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
1976
+ whileRunning: z.ZodOptional<z.ZodEnum<{
1977
+ skip: "skip";
1978
+ parallel: "parallel";
1979
+ queue: "queue";
1980
+ }>>;
1917
1981
  elementId: z.ZodOptional<z.ZodString>;
1918
1982
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1919
1983
  }, z.core.$strip>>;
@@ -1927,6 +1991,11 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
1927
1991
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1928
1992
  enabled: z.ZodOptional<z.ZodBoolean>;
1929
1993
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
1994
+ whileRunning: z.ZodOptional<z.ZodEnum<{
1995
+ skip: "skip";
1996
+ parallel: "parallel";
1997
+ queue: "queue";
1998
+ }>>;
1930
1999
  elementId: z.ZodOptional<z.ZodString>;
1931
2000
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1932
2001
  }, z.core.$strip>, z.ZodObject<{
@@ -1943,6 +2012,8 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
1943
2012
  localStorage: "localStorage";
1944
2013
  sessionStorage: "sessionStorage";
1945
2014
  }>>;
2015
+ transientState: z.ZodOptional<z.ZodArray<z.ZodString>>;
2016
+ paintedState: z.ZodOptional<z.ZodArray<z.ZodString>>;
1946
2017
  userProvider: z.ZodOptional<z.ZodString>;
1947
2018
  tokenStorage: z.ZodOptional<z.ZodEnum<{
1948
2019
  "": "";
@@ -1965,6 +2036,21 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
1965
2036
  strict: "strict";
1966
2037
  }>>;
1967
2038
  sessionRevalidateSeconds: z.ZodOptional<z.ZodNumber>;
2039
+ channels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
2040
+ access: z.ZodObject<{
2041
+ mode: z.ZodEnum<{
2042
+ public: "public";
2043
+ session: "session";
2044
+ role: "role";
2045
+ }>;
2046
+ permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
2047
+ }, z.core.$strip>;
2048
+ publish: z.ZodOptional<z.ZodEnum<{
2049
+ server: "server";
2050
+ clients: "clients";
2051
+ }>>;
2052
+ presence: z.ZodOptional<z.ZodBoolean>;
2053
+ }, z.core.$strip>>>>;
1968
2054
  }, z.core.$strip>, z.ZodObject<{
1969
2055
  desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
1970
2056
  tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
@@ -2717,6 +2803,13 @@ export declare const operations: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject
2717
2803
  }, z.core.$strip>, z.ZodObject<{
2718
2804
  type: z.ZodLiteral<"deleteAction">;
2719
2805
  ref: z.ZodString;
2806
+ }, z.core.$strip>, z.ZodObject<{
2807
+ type: z.ZodLiteral<"upsertFunctionFile">;
2808
+ path: z.ZodString;
2809
+ content: z.ZodString;
2810
+ }, z.core.$strip>, z.ZodObject<{
2811
+ type: z.ZodLiteral<"deleteFunctionFile">;
2812
+ path: z.ZodString;
2720
2813
  }, z.core.$strip>], "type">>;
2721
2814
  export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<readonly [z.ZodObject<{
2722
2815
  type: z.ZodLiteral<"upsertElement">;
@@ -2904,6 +2997,11 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
2904
2997
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2905
2998
  enabled: z.ZodOptional<z.ZodBoolean>;
2906
2999
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
3000
+ whileRunning: z.ZodOptional<z.ZodEnum<{
3001
+ skip: "skip";
3002
+ parallel: "parallel";
3003
+ queue: "queue";
3004
+ }>>;
2907
3005
  elementId: z.ZodOptional<z.ZodString>;
2908
3006
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2909
3007
  }, z.core.$strip>>;
@@ -2917,6 +3015,11 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
2917
3015
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2918
3016
  enabled: z.ZodOptional<z.ZodBoolean>;
2919
3017
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
3018
+ whileRunning: z.ZodOptional<z.ZodEnum<{
3019
+ skip: "skip";
3020
+ parallel: "parallel";
3021
+ queue: "queue";
3022
+ }>>;
2920
3023
  elementId: z.ZodOptional<z.ZodString>;
2921
3024
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2922
3025
  }, z.core.$strip>, z.ZodObject<{
@@ -2933,6 +3036,8 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
2933
3036
  localStorage: "localStorage";
2934
3037
  sessionStorage: "sessionStorage";
2935
3038
  }>>;
3039
+ transientState: z.ZodOptional<z.ZodArray<z.ZodString>>;
3040
+ paintedState: z.ZodOptional<z.ZodArray<z.ZodString>>;
2936
3041
  userProvider: z.ZodOptional<z.ZodString>;
2937
3042
  tokenStorage: z.ZodOptional<z.ZodEnum<{
2938
3043
  "": "";
@@ -2955,6 +3060,21 @@ export declare const documentOperations: z.ZodArray<z.ZodDiscriminatedUnion<read
2955
3060
  strict: "strict";
2956
3061
  }>>;
2957
3062
  sessionRevalidateSeconds: z.ZodOptional<z.ZodNumber>;
3063
+ channels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
3064
+ access: z.ZodObject<{
3065
+ mode: z.ZodEnum<{
3066
+ public: "public";
3067
+ session: "session";
3068
+ role: "role";
3069
+ }>;
3070
+ permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
3071
+ }, z.core.$strip>;
3072
+ publish: z.ZodOptional<z.ZodEnum<{
3073
+ server: "server";
3074
+ clients: "clients";
3075
+ }>>;
3076
+ presence: z.ZodOptional<z.ZodBoolean>;
3077
+ }, z.core.$strip>>>>;
2958
3078
  }, z.core.$strip>, z.ZodObject<{
2959
3079
  desktop: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
2960
3080
  tablet: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
@@ -1,5 +1,6 @@
1
1
  import { actionOps } from "./actions/index.js";
2
2
  import { connectorOps } from "./connectors/index.js";
3
+ import { functionOps } from "./functions/index.js";
3
4
  import { elementOps } from "./schema/operations.js";
4
5
  import { registerSharedSchemaIds } from "./schemaIds.js";
5
6
  import { styleOps } from "./style/operations.js";
@@ -50,11 +51,11 @@ var operation = z.discriminatedUnion("type", [
50
51
  connectorOps.deleteConnector,
51
52
  actionOps.upsertAction,
52
53
  actionOps.patchAction,
53
- actionOps.deleteAction
54
+ actionOps.deleteAction,
55
+ functionOps.upsertFunctionFile,
56
+ functionOps.deleteFunctionFile
54
57
  ]);
55
58
  var STYLE_OP_TYPES = new Set(Object.keys(styleOps));
56
- new Set(Object.keys(connectorOps));
57
- new Set(Object.keys(actionOps));
58
59
  var isStyleOp = (type) => STYLE_OP_TYPES.has(type);
59
60
  var MAX_OPS = 1e3;
60
61
  var environment = z.string().optional().describe("Environment; default main");
@@ -1,8 +1,9 @@
1
- import { descendantIds, findRootByRef, indexRemoveElements, resolveRef } from "../../../../helpers/space.js";
1
+ import { findRootByRef, indexRemoveElements, resolveRef } from "../../../../helpers/space.js";
2
2
  import { pageUri } from "../../../../helpers/uris.js";
3
3
  import { empty, fail } from "../../../../helpers/opResult.js";
4
- import { removeFromParent } from "../write.js";
4
+ import { descendants } from "@plitzi/sdk-schema/helpers/elementTree";
5
5
  import { z } from "zod";
6
+ import FlatMap from "@plitzi/sdk-schema/helpers/FlatMap";
6
7
  //#region src/modules/mcp/tools/operations/schema/elements/deleteElement.ts
7
8
  var deleteElementOp = z.object({
8
9
  type: z.literal("deleteElement"),
@@ -14,10 +15,8 @@ var deleteElement = (space, env, op) => {
14
15
  if (!page) return fail("pageRef", `Page or layout "${op.pageRef}" not found`, "Read the pages resource for valid refs");
15
16
  const el = resolveRef(space.schema, page, op.ref);
16
17
  if (!el || el.id === page.id) return fail("ref", `Element "${op.ref}" not found in page "${op.pageRef}"`, "Read the page resource for valid refs");
17
- const ids = [...descendantIds(space.schema, el.id), el.id];
18
- const removed = ids.map((id) => space.schema.flat[id]);
19
- for (const id of ids) Reflect.deleteProperty(space.schema.flat, id);
20
- removeFromParent(space, el);
18
+ const removed = [el.id, ...descendants(space.schema.flat, el.id)].map((id) => space.schema.flat[id]);
19
+ new FlatMap({ flat: space.schema.flat }).removeElement(el.id);
21
20
  indexRemoveElements(space.schema, removed);
22
21
  return {
23
22
  ...empty(),
@@ -2,8 +2,9 @@ import { findRootByRef, indexInvalidateDetails, resolveRef } from "../../../../h
2
2
  import { pageUri } from "../../../../helpers/uris.js";
3
3
  import { empty, fail } from "../../../../helpers/opResult.js";
4
4
  import { position } from "../shared.js";
5
- import { placeChild, removeFromParent } from "../write.js";
5
+ import { DROP_POSITION } from "../write.js";
6
6
  import { z } from "zod";
7
+ import FlatMap from "@plitzi/sdk-schema/helpers/FlatMap";
7
8
  //#region src/modules/mcp/tools/operations/schema/elements/moveElement.ts
8
9
  var moveElementOp = z.object({
9
10
  type: z.literal("moveElement"),
@@ -19,16 +20,7 @@ var moveElement = (space, env, op) => {
19
20
  const anchor = resolveRef(space.schema, page, op.toParentRef);
20
21
  if (!el || el.id === page.id) return fail("ref", `Element "${op.ref}" not found`, "Read the page resource for valid refs");
21
22
  if (!anchor) return fail("toParentRef", `Target "${op.toParentRef}" not found`, "Read the page resource for valid refs");
22
- removeFromParent(space, el);
23
- let parent = anchor;
24
- let index;
25
- if (op.position === "before" || op.position === "after") {
26
- parent = anchor.definition.parentId ? space.schema.flat[anchor.definition.parentId] ?? page : page;
27
- const at = (parent.definition.items ?? []).indexOf(anchor.id);
28
- index = at < 0 ? void 0 : op.position === "after" ? at + 1 : at;
29
- }
30
- el.definition.parentId = parent.id;
31
- placeChild(parent, el.id, index);
23
+ if (!new FlatMap({ flat: space.schema.flat }).moveElement(el.definition.parentId ?? page.id, anchor.id, el.id, DROP_POSITION[op.position])) return fail("toParentRef", `"${op.ref}" cannot move ${op.position} "${op.toParentRef}"`, "An element cannot move inside itself or one of its own descendants, and before/after needs an anchor that has a parent.");
32
24
  indexInvalidateDetails(space.schema);
33
25
  return {
34
26
  ...empty(),
@@ -2,7 +2,7 @@ import { findRootByRef, resolveRef } from "../../../../helpers/space.js";
2
2
  import { pageUri } from "../../../../helpers/uris.js";
3
3
  import { empty, fail } from "../../../../helpers/opResult.js";
4
4
  import { elementInput, position } from "../shared.js";
5
- import { collectInputRefs, createElement, guardNewRef, writeInitialState } from "../write.js";
5
+ import { DROP_POSITION, collectInputRefs, createElement, guardNewRef, writeInitialState } from "../write.js";
6
6
  import { z } from "zod";
7
7
  //#region src/modules/mcp/tools/operations/schema/elements/upsertElement.ts
8
8
  var upsertElementOp = z.object({
@@ -43,18 +43,15 @@ var upsertElement = (space, env, op) => {
43
43
  const guard = guardNewRef(space, ref, "element.ref");
44
44
  if (guard) return guard;
45
45
  }
46
- let parent = page;
47
- let index;
46
+ let anchorId = page.id;
47
+ let drop = "inside";
48
48
  if (op.parentRef) {
49
49
  const anchor = resolveRef(space.schema, page, op.parentRef);
50
50
  if (!anchor) return fail("parentRef", `Parent "${op.parentRef}" not found in page "${op.pageRef}"`, "Use an existing ref");
51
- if (op.position === "before" || op.position === "after") {
52
- parent = anchor.definition.parentId ? space.schema.flat[anchor.definition.parentId] : page;
53
- const at = (parent.definition.items ?? []).indexOf(anchor.id);
54
- index = at < 0 ? void 0 : op.position === "after" ? at + 1 : at;
55
- } else parent = anchor;
51
+ anchorId = anchor.id;
52
+ drop = DROP_POSITION[op.position ?? "inside"];
56
53
  }
57
- createElement(space, page, op.element, parent, index);
54
+ if (!createElement(space, page, op.element, anchorId, drop)) return fail("parentRef", `"${op.element.ref}" cannot be placed ${op.position ?? "inside"} "${op.parentRef ?? op.pageRef}"`, "An element goes inside an element that holds children, or before/after one that has a parent — a page has no siblings.");
58
55
  return {
59
56
  ...empty(),
60
57
  created: 1,
@@ -11,6 +11,11 @@ export declare const patchInteractionNodeOp: z.ZodObject<{
11
11
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
12
12
  enabled: z.ZodOptional<z.ZodBoolean>;
13
13
  when: z.ZodOptional<z.ZodType<import('@plitzi/sdk-shared').RuleGroup, unknown, z.core.$ZodTypeInternals<import('@plitzi/sdk-shared').RuleGroup, unknown>>>;
14
+ whileRunning: z.ZodOptional<z.ZodEnum<{
15
+ skip: "skip";
16
+ parallel: "parallel";
17
+ queue: "queue";
18
+ }>>;
14
19
  elementId: z.ZodOptional<z.ZodString>;
15
20
  preview: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
16
21
  }, z.core.$strip>;
@@ -5,7 +5,7 @@ import { interactionNode } from "../shared.js";
5
5
  import { resolveElement, resolveTargetRef } from "../write.js";
6
6
  import { z } from "zod";
7
7
  //#region src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.ts
8
- var { title, action, params, enabled, when, elementId, preview } = interactionNode.shape;
8
+ var { title, action, params, enabled, when, whileRunning, elementId, preview } = interactionNode.shape;
9
9
  var patchInteractionNodeOp = z.object({
10
10
  type: z.literal("patchInteractionNode"),
11
11
  pageRef: z.string().describe("The page, by name"),
@@ -16,6 +16,7 @@ var patchInteractionNodeOp = z.object({
16
16
  params: params.describe("Merged onto the node params: listed keys change, others are preserved"),
17
17
  enabled,
18
18
  when,
19
+ whileRunning,
19
20
  elementId,
20
21
  preview
21
22
  }).describe("Partially update ONE step of a flow (found by nodeId): only the fields you pass change, the order/links are untouched. This is how you DISABLE a step without removing it — { enabled: false } keeps it in the flow. deleteInteraction is for actually removing one. Fails if the node does not exist.");
@@ -32,6 +33,7 @@ var patchInteractionNode = (space, env, op) => {
32
33
  };
33
34
  if (op.enabled !== void 0) node.enabled = op.enabled;
34
35
  if (op.when !== void 0) node.when = op.when;
36
+ if (op.whileRunning !== void 0) node.whileRunning = op.whileRunning;
35
37
  if (op.elementId !== void 0) node.elementId = resolveTargetRef(space, op.elementId);
36
38
  if (node.type === "utility") node.elementId = null;
37
39
  else if (typeof node.elementId === "string" && NULLISH_ELEMENT_IDS.has(node.elementId)) node.elementId = null;