@plitzi/sdk-mcp 0.39.2 → 0.39.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.
- package/CHANGELOG.md +27 -0
- package/README.md +39 -39
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/modules/mcp/answerBudgets.d.ts +29 -0
- package/dist/modules/mcp/answerBudgets.js +37 -0
- package/dist/modules/mcp/apps/example/view/index.tsx +0 -1
- package/dist/modules/mcp/apps/render/view/index.tsx +0 -1
- package/dist/modules/mcp/helpers/guide/reference.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/reference.js +7 -2
- package/dist/modules/mcp/helpers/guide/structure.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/structure.js +1 -0
- package/dist/modules/mcp/helpers/opResult.d.ts +3 -1
- package/dist/modules/mcp/helpers/opResult.js +3 -1
- package/dist/modules/mcp/localScreenshotClient.d.ts +10 -0
- package/dist/modules/mcp/localScreenshotClient.js +46 -16
- package/dist/modules/mcp/previewClient.js +2 -2
- package/dist/modules/mcp/resources/canonical.js +2 -2
- package/dist/modules/mcp/server.d.ts +1 -1
- package/dist/modules/mcp/server.js +3 -2
- package/dist/modules/mcp/tools/activity.js +2 -2
- package/dist/modules/mcp/tools/apply/dispatch.js +7 -1
- package/dist/modules/mcp/tools/apply/index.d.ts +25 -1
- package/dist/modules/mcp/tools/apply/index.js +21 -5
- package/dist/modules/mcp/tools/describeOperation.js +1 -1
- package/dist/modules/mcp/tools/intents.js +26 -4
- package/dist/modules/mcp/tools/look.d.ts +1 -0
- package/dist/modules/mcp/tools/look.js +2 -1
- package/dist/modules/mcp/tools/operations/actions/deleteAction.js +1 -1
- package/dist/modules/mcp/tools/operations/actions/patchAction.js +3 -3
- package/dist/modules/mcp/tools/operations/actions/upsertAction.js +1 -1
- package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +1 -1
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +2 -2
- package/dist/modules/mcp/tools/operations/data/index.js +3 -3
- package/dist/modules/mcp/tools/operations/functions/index.js +2 -2
- package/dist/modules/mcp/tools/operations/index.d.ts +97 -4
- package/dist/modules/mcp/tools/operations/index.js +1 -0
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/components/deleteComponent.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/components/upsertComponent.js +8 -8
- package/dist/modules/mcp/tools/operations/schema/elements/addSpec.d.ts +29 -0
- package/dist/modules/mcp/tools/operations/schema/elements/addSpec.js +118 -0
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +2 -0
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +3 -3
- package/dist/modules/mcp/tools/operations/schema/flags/deleteFlag.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/index.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +25 -1
- package/dist/modules/mcp/tools/operations/schema/operations.js +2 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +14 -7
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +8 -1
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +9 -6
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +3 -2
- package/dist/modules/mcp/tools/operations/schema/write.js +3 -3
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +2 -1
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +1 -1
- package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +2 -2
- package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +1 -1
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +2 -1
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +1 -1
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +2 -1
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +1 -1
- package/dist/modules/mcp/tools/operations/style/validate.js +6 -6
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +3 -2
- package/dist/modules/mcp/tools/operations/style/write.js +1 -1
- package/dist/modules/mcp/tools/render.d.ts +24 -1
- package/dist/modules/mcp/tools/renderWidget.d.ts +24 -1
- package/dist/modules/mcp/tools/search.js +1 -1
- package/dist/modules/mcp/tools/shared/agentHtml.d.ts +8 -0
- package/dist/modules/mcp/tools/shared/agentHtml.js +18 -0
- package/dist/modules/mcp/tools/shared/lintDraft.js +1 -0
- package/dist/modules/mcp/tools/shared/look.d.ts +2 -0
- package/dist/modules/mcp/tools/shared/look.js +15 -8
- package/dist/modules/mcp/tools/shared/repeats.d.ts +1 -1
- package/dist/modules/mcp/tools/shared/repeats.js +1 -1
- package/dist/modules/mcp/tools/shared/tool.d.ts +2 -0
- package/dist/modules/mcp/tools/shared/validator/connectors.js +3 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +2 -0
- package/dist/modules/mcp/tools/shared/validator/elements.js +3 -0
- package/dist/modules/mcp/tools/shared/validator/index.js +39 -0
- package/dist/modules/mcp/tools/shared/validator/interactions.js +1 -0
- package/dist/modules/mcp/tools/shared/validator/refs.js +3 -0
- package/dist/modules/mcp/tools/tryFunction.js +2 -2
- package/dist/modules/mcp/types/aiSchema.d.ts +3 -0
- package/dist/modules/mcp/types/previewTypes.d.ts +9 -1
- package/dist/options.d.ts +1 -1
- package/dist/preview/createPreview.js +38 -7
- package/package.json +8 -8
|
@@ -21,8 +21,31 @@ var CONTENT_HEIGHT = () => {
|
|
|
21
21
|
* by then was not going to make the shot anyway, and a picture in a fallback beats no picture at all.
|
|
22
22
|
*/
|
|
23
23
|
var FONTS_READY = () => Promise.race([document.fonts.ready, new Promise((resolve) => setTimeout(resolve, 3e3))]);
|
|
24
|
-
/**
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* A capture shows the page, the same in the three places one is taken — this client, the screenshot service
|
|
26
|
+
* (`plitzi-platform` `cluster/services/screenshot`) and `plitzi-sdk-server`'s visual suite (`visual/helpers.ts`,
|
|
27
|
+
* `shoot`): drawn with `prefers-reduced-motion: reduce` (`emulateCaptureMedia`), so what reveals itself as it scrolls in
|
|
28
|
+
* rests at its end state; and a page taller than `ONE_SHOT_HEIGHT` in parts of at most `PART_HEIGHT` (`clip`), in order
|
|
29
|
+
* — Chromium paints nothing past 16,384 px of one capture. Never by scrolling: what sticks would be in every part.
|
|
30
|
+
*/
|
|
31
|
+
var ONE_SHOT_HEIGHT = 16e3;
|
|
32
|
+
var PART_HEIGHT = 8e3;
|
|
33
|
+
/** Guard against a runaway page: past this, its foot is not captured, and the capture says so in its last part. */
|
|
34
|
+
var MAX_HEIGHT = 32e3;
|
|
35
|
+
/** The regions a page of `height` is captured in: one, or parts of `PART_HEIGHT` each labelled with its place. */
|
|
36
|
+
var captureParts = (label, width, height) => {
|
|
37
|
+
if (height <= ONE_SHOT_HEIGHT) return [{ label }];
|
|
38
|
+
const count = Math.ceil(height / PART_HEIGHT);
|
|
39
|
+
return Array.from({ length: count }, (_, index) => ({
|
|
40
|
+
label: `${label} (${String(index + 1)}/${String(count)})`,
|
|
41
|
+
clip: {
|
|
42
|
+
x: 0,
|
|
43
|
+
y: index * PART_HEIGHT,
|
|
44
|
+
width,
|
|
45
|
+
height: Math.min(PART_HEIGHT, height - index * PART_HEIGHT)
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
26
49
|
var importDriver = async (name) => {
|
|
27
50
|
try {
|
|
28
51
|
const module = await import(
|
|
@@ -101,27 +124,34 @@ var createLocalScreenshotClient = async ({ renderBaseUrl, ignoreHttpsErrors = tr
|
|
|
101
124
|
message: `The page answered ${response.status()}.`
|
|
102
125
|
};
|
|
103
126
|
await page.evaluate(FONTS_READY);
|
|
127
|
+
let height = viewport.height;
|
|
104
128
|
if (fullPage) {
|
|
105
|
-
|
|
129
|
+
height = Math.min(await page.evaluate(CONTENT_HEIGHT), MAX_HEIGHT);
|
|
106
130
|
if (height > viewport.height) await setViewport(page, {
|
|
107
131
|
width: viewport.width,
|
|
108
132
|
height
|
|
109
133
|
});
|
|
110
134
|
}
|
|
111
135
|
if (views.includes("image")) {
|
|
112
|
-
const
|
|
136
|
+
const type = format === "webp" ? {
|
|
113
137
|
type: "webp",
|
|
114
|
-
quality
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
138
|
+
quality
|
|
139
|
+
} : { type: "png" };
|
|
140
|
+
for (const part of fullPage ? captureParts(viewport.label, viewport.width, height) : [{ label: viewport.label }]) {
|
|
141
|
+
const shot = await page.screenshot("clip" in part ? {
|
|
142
|
+
...type,
|
|
143
|
+
clip: part.clip,
|
|
144
|
+
captureBeyondViewport: true
|
|
145
|
+
} : {
|
|
146
|
+
...type,
|
|
147
|
+
fullPage
|
|
148
|
+
});
|
|
149
|
+
images.push({
|
|
150
|
+
label: part.label,
|
|
151
|
+
mimeType: format === "webp" ? "image/webp" : "image/png",
|
|
152
|
+
data: Buffer.from(shot).toString("base64")
|
|
153
|
+
});
|
|
154
|
+
}
|
|
125
155
|
}
|
|
126
156
|
const outline = views.includes("accessibility") ? await readOutline(page) : void 0;
|
|
127
157
|
if (outline !== void 0) accessibility.push({
|
|
@@ -145,4 +175,4 @@ var createLocalScreenshotClient = async ({ renderBaseUrl, ignoreHttpsErrors = tr
|
|
|
145
175
|
}
|
|
146
176
|
} };
|
|
147
177
|
};
|
|
148
|
-
export { createLocalScreenshotClient, resolveLocalBrowser };
|
|
178
|
+
export { captureParts, createLocalScreenshotClient, resolveLocalBrowser };
|
|
@@ -16,13 +16,13 @@ var createHttpPreviewClient = ({ url, secret, fetchImpl = fetch }) => ({ async r
|
|
|
16
16
|
} catch (err) {
|
|
17
17
|
return {
|
|
18
18
|
ok: false,
|
|
19
|
-
error: "
|
|
19
|
+
error: "unanswered",
|
|
20
20
|
message: `Preview endpoint unreachable: ${String(err)}`
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
if (!res.ok && res.status !== 422) return {
|
|
24
24
|
ok: false,
|
|
25
|
-
error: "
|
|
25
|
+
error: "unanswered",
|
|
26
26
|
message: `Preview endpoint returned ${res.status}.`
|
|
27
27
|
};
|
|
28
28
|
return await res.json();
|
|
@@ -15,12 +15,12 @@ var canonicalUri = (env, uri) => {
|
|
|
15
15
|
var resourceErrorMessage = (env, uri) => {
|
|
16
16
|
const canonical = canonicalUri(env, uri);
|
|
17
17
|
if (itemTemplates(env).some((tpl) => canonical.startsWith(tpl.slice(0, tpl.lastIndexOf("/") + 1)))) return JSON.stringify({
|
|
18
|
-
error: "
|
|
18
|
+
error: "missing",
|
|
19
19
|
message: `No resource at '${uri}'. Its shape is valid but the ref does not resolve.`,
|
|
20
20
|
hint: "It may have been deleted or your URI is stale. Re-list the parent resource (pages/definitions) to refresh."
|
|
21
21
|
});
|
|
22
22
|
return JSON.stringify({
|
|
23
|
-
error: "
|
|
23
|
+
error: "bad-value",
|
|
24
24
|
message: `'${uri}' matches no resource template.`,
|
|
25
25
|
hint: "Do not hand-build element URIs — take the ready-made uri from plitzi_search or a write response.",
|
|
26
26
|
validTemplates: [primerUri(env), ...itemTemplates(env)]
|
|
@@ -11,7 +11,7 @@ import { SSRAdapters, ServerLogger, SSRGrant } from '@plitzi/sdk-kernel/types';
|
|
|
11
11
|
export interface McpServerContext {
|
|
12
12
|
adapters: SSRAdapters;
|
|
13
13
|
getGrant: () => Promise<SSRGrant | undefined>;
|
|
14
|
-
/** How a look (plitzi_look, plitzi_apply's `look`) reaches the renderer. Absent → it
|
|
14
|
+
/** How a look (plitzi_look, plitzi_apply's `look`) reaches the renderer. Absent → it refuses with `not-allowed`, so an
|
|
15
15
|
* MCP-only deployment without a renderer still runs every other tool. */
|
|
16
16
|
preview?: PreviewClient;
|
|
17
17
|
/** The dedicated browser service a look takes an image or an accessibility outline with. Absent → a look answers
|
|
@@ -60,7 +60,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
60
60
|
...entitlements ? { entitlements } : {}
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
|
-
const { saveSchema, saveStyle, saveConnector, deleteConnector, saveAction, deleteAction, saveFunctions, tryFunction, runE2eTests, saveData, getActivity } = adapters;
|
|
63
|
+
const { saveSchema, saveStyle, saveConnector, deleteConnector, saveAction, deleteAction, saveFunctions, tryFunction, runE2eTests, saveData, getActivity, getRenderCredential } = adapters;
|
|
64
64
|
const write = {
|
|
65
65
|
userId: grant?.userId,
|
|
66
66
|
batch: randomUUID(),
|
|
@@ -81,7 +81,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
81
81
|
const getSpace = () => spacePromise ??= loadSpace();
|
|
82
82
|
const server = new McpServer({
|
|
83
83
|
name: "plitzi-mcp",
|
|
84
|
-
version: "0.39.
|
|
84
|
+
version: "0.39.4"
|
|
85
85
|
}, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
|
|
86
86
|
const { getChanges } = adapters;
|
|
87
87
|
registerResources(server, getSpace, MCP_ENV, log, hasSpace, getChanges ? (query) => getChanges(requireSpaceId(), MCP_ENV, query) : void 0);
|
|
@@ -99,6 +99,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
99
99
|
proxy: proxyForTool(proxy, tool.name),
|
|
100
100
|
...tryFunction ? { tryFunction: (task, params) => tryFunction(requireWritableSpaceId(), task, params, write) } : {},
|
|
101
101
|
...runE2eTests ? { runE2eTests: (ids) => runE2eTests(requireTestableSpaceId(), ids) } : {},
|
|
102
|
+
...getRenderCredential ? { renderCredential: () => getRenderCredential(requireSpaceId()) } : {},
|
|
102
103
|
...getActivity ? { activity: (query) => getActivity(requireSpaceId(), query, {
|
|
103
104
|
userId: grant?.userId,
|
|
104
105
|
origin: "mcp"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { defineTool } from "./shared/tool.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { ACTIVITY_LIMIT_MAX, ACTIVITY_WAIT_DEFAULT_SECONDS, ACTIVITY_WAIT_MAX_SECONDS } from "@plitzi/sdk-shared/activity";
|
|
3
|
+
import { ACTIVITY_LIMIT_DEFAULT, ACTIVITY_LIMIT_MAX, ACTIVITY_WAIT_DEFAULT_SECONDS, ACTIVITY_WAIT_MAX_SECONDS } from "@plitzi/sdk-shared/activity";
|
|
4
4
|
// src/modules/mcp/tools/activity.ts
|
|
5
5
|
var activityShape = {
|
|
6
6
|
after: z.string().optional().describe("The `cursor` last answered. Left out: the latest, at once"),
|
|
7
7
|
wait: z.number().min(0).max(ACTIVITY_WAIT_MAX_SECONDS).optional().describe(`Seconds to wait for something; default ${String(ACTIVITY_WAIT_DEFAULT_SECONDS)}`),
|
|
8
|
-
limit: z.number().int().min(1).max(ACTIVITY_LIMIT_MAX).optional(),
|
|
8
|
+
limit: z.number().int().min(1).max(ACTIVITY_LIMIT_MAX).optional().describe(`At most this many; default ${String(ACTIVITY_LIMIT_DEFAULT)}`),
|
|
9
9
|
mine: z.boolean().optional().describe("Include your own writes")
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -14,6 +14,7 @@ import { patchBinding } from "../operations/schema/bindings/patchBinding.js";
|
|
|
14
14
|
import { upsertBinding } from "../operations/schema/bindings/upsertBinding.js";
|
|
15
15
|
import { deleteComponent } from "../operations/schema/components/deleteComponent.js";
|
|
16
16
|
import { upsertComponent } from "../operations/schema/components/upsertComponent.js";
|
|
17
|
+
import { addSpec } from "../operations/schema/elements/addSpec.js";
|
|
17
18
|
import { deleteElement } from "../operations/schema/elements/deleteElement.js";
|
|
18
19
|
import { moveElement } from "../operations/schema/elements/moveElement.js";
|
|
19
20
|
import { patchElement } from "../operations/schema/elements/patchElement.js";
|
|
@@ -73,6 +74,7 @@ var executeOp = (space, env, op) => {
|
|
|
73
74
|
case "patchElement": return patchElement(space, env, op);
|
|
74
75
|
case "deleteElement": return deleteElement(space, env, op);
|
|
75
76
|
case "moveElement": return moveElement(space, env, op);
|
|
77
|
+
case "addSpec": return addSpec(space, env, op);
|
|
76
78
|
case "upsertPage": return upsertPage(space, env, op);
|
|
77
79
|
case "deletePage": return deletePage(space, env, op);
|
|
78
80
|
case "upsertLayout": return upsertLayout(space, env, op);
|
|
@@ -116,7 +118,7 @@ var executeOp = (space, env, op) => {
|
|
|
116
118
|
case "deleteFunctionFile": return deleteFunctionFile(space, env, op);
|
|
117
119
|
case "upsertDataFile": return upsertDataFile(space, env, op);
|
|
118
120
|
case "deleteDataFile": return deleteDataFile(space, env, op);
|
|
119
|
-
default: return fail("type", `Unknown operation "${op.type}"`, "
|
|
121
|
+
default: return fail("missing", "type", `Unknown operation "${op.type}"`, "plitzi_describe_operation lists every operation type");
|
|
120
122
|
}
|
|
121
123
|
};
|
|
122
124
|
/** Apply operations in order to the space (mutating it). Records which schema(s) changed so the caller can
|
|
@@ -181,6 +183,10 @@ var applyOperations = (space, env, ops) => {
|
|
|
181
183
|
case "deleteDataFile":
|
|
182
184
|
outcome.changedData = true;
|
|
183
185
|
break;
|
|
186
|
+
case "addSpec":
|
|
187
|
+
outcome.changedSchema = true;
|
|
188
|
+
if (Object.keys(op.classes ?? {}).length > 0) outcome.changedStyle = true;
|
|
189
|
+
break;
|
|
184
190
|
default: if (isStyleOp(op.type)) outcome.changedStyle = true;
|
|
185
191
|
else outcome.changedSchema = true;
|
|
186
192
|
}
|
|
@@ -72,6 +72,18 @@ export declare const applyShape: {
|
|
|
72
72
|
after: "after";
|
|
73
73
|
inside: "inside";
|
|
74
74
|
}>;
|
|
75
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
76
|
+
type: z.ZodLiteral<"addSpec">;
|
|
77
|
+
pageRef: z.ZodString;
|
|
78
|
+
parentRef: z.ZodOptional<z.ZodString>;
|
|
79
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
80
|
+
before: "before";
|
|
81
|
+
after: "after";
|
|
82
|
+
inside: "inside";
|
|
83
|
+
}>>;
|
|
84
|
+
replaces: z.ZodOptional<z.ZodString>;
|
|
85
|
+
spec: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
86
|
+
classes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
75
87
|
}, z.core.$strict>, z.ZodObject<{
|
|
76
88
|
type: z.ZodLiteral<"upsertPage">;
|
|
77
89
|
ref: z.ZodString;
|
|
@@ -87,6 +99,10 @@ export declare const applyShape: {
|
|
|
87
99
|
noBounce: "noBounce";
|
|
88
100
|
}>>>;
|
|
89
101
|
flag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
102
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
103
|
+
base: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
104
|
+
slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
105
|
+
}, z.core.$strip>>;
|
|
90
106
|
}, z.core.$strict>, z.ZodObject<{
|
|
91
107
|
type: z.ZodLiteral<"deletePage">;
|
|
92
108
|
ref: z.ZodString;
|
|
@@ -289,9 +305,16 @@ export declare const applyShape: {
|
|
|
289
305
|
dark: z.ZodOptional<z.ZodString>;
|
|
290
306
|
}, z.core.$strip>]>>;
|
|
291
307
|
robotsTxt: z.ZodOptional<z.ZodString>;
|
|
292
|
-
|
|
308
|
+
securityTxt: z.ZodOptional<z.ZodString>;
|
|
309
|
+
llmsTxt: z.ZodOptional<z.ZodString>;
|
|
310
|
+
blockAiCrawlers: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
311
|
+
training: "training";
|
|
312
|
+
assistants: "assistants";
|
|
313
|
+
search: "search";
|
|
314
|
+
}>>>;
|
|
293
315
|
viewTransitions: z.ZodOptional<z.ZodBoolean>;
|
|
294
316
|
withheldPage: z.ZodOptional<z.ZodString>;
|
|
317
|
+
wholeDocument: z.ZodOptional<z.ZodBoolean>;
|
|
295
318
|
channels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodObject<{
|
|
296
319
|
access: z.ZodObject<{
|
|
297
320
|
mode: z.ZodEnum<{
|
|
@@ -1736,6 +1759,7 @@ export declare const applyShape: {
|
|
|
1736
1759
|
both: "both";
|
|
1737
1760
|
}>>;
|
|
1738
1761
|
pageRef: z.ZodOptional<z.ZodString>;
|
|
1762
|
+
routeParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1739
1763
|
viewport: z.ZodOptional<z.ZodEnum<{
|
|
1740
1764
|
desktop: "desktop";
|
|
1741
1765
|
mobile: "mobile";
|
|
@@ -3,10 +3,11 @@ import { dataFileUri, dataUri, functionFileUri, functionsUri } from "../../helpe
|
|
|
3
3
|
import { environment, operations } from "../operations/index.js";
|
|
4
4
|
import { draftBatch } from "../shared/draftBatch.js";
|
|
5
5
|
import { effectsOf } from "../shared/effects.js";
|
|
6
|
-
import { fullPage, lookAt, pageRef, viewport } from "../shared/look.js";
|
|
6
|
+
import { fullPage, lookAt, pageRef, routeParams, viewport } from "../shared/look.js";
|
|
7
7
|
import { AGAIN, REPEATED, batchKey, forgetRefused, noteRefused, timesRefused } from "../shared/repeats.js";
|
|
8
8
|
import { defineTool, imageResult } from "../shared/tool.js";
|
|
9
9
|
import { z } from "zod";
|
|
10
|
+
import { deepEqual } from "@plitzi/sdk-shared/helpers";
|
|
10
11
|
import { generateCache } from "@plitzi/sdk-style";
|
|
11
12
|
// src/modules/mcp/tools/apply/index.ts
|
|
12
13
|
var applyShape = {
|
|
@@ -21,26 +22,38 @@ var applyShape = {
|
|
|
21
22
|
"both"
|
|
22
23
|
]).optional().describe("Also render the page: with dryRun, as the batch would leave it (nothing saved); without, as it was saved. \"html\" the markup, \"image\" a PNG, \"accessibility\" the outline a screen reader reads (text, far cheaper than an image), \"both\" image and outline. Check, look and then save with the same operations — written once."),
|
|
23
24
|
pageRef,
|
|
25
|
+
routeParams,
|
|
24
26
|
viewport,
|
|
25
27
|
fullPage
|
|
26
28
|
};
|
|
27
29
|
var NOTHING_CHANGED = "Nothing changed: every operation left the space as it was.";
|
|
28
30
|
var noWarnings = (warnings) => warnings.length > 0 ? warnings : void 0;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the batch left a store as the space holds it. A write sent again — a client that timed out and retried, an
|
|
33
|
+
* agent that lost the answer — reads the space as the first left it, and its operations change nothing: written again,
|
|
34
|
+
* it would be a second entry in the space's history for an edit nobody made. Strict the other way: any difference, an
|
|
35
|
+
* `undefined` beside a missing key included, is written.
|
|
36
|
+
*/
|
|
37
|
+
var unchanged = (before, after, skip) => deepEqual(before, after, "soft", { skip });
|
|
29
38
|
/** Why the platform did not save the functions, as the batch's errors: each problem where it is, or the refusal. */
|
|
30
39
|
var functionsErrors = (saved, env) => "problems" in saved ? saved.problems.map((problem) => ({
|
|
40
|
+
code: "bad-value",
|
|
31
41
|
path: problem.file ? `functions/${problem.file}${problem.line ? `:${String(problem.line)}` : ""}` : "functions",
|
|
32
42
|
message: problem.message,
|
|
33
43
|
hint: `Fix it with upsertFunctionFile; read ${functionFileUri(env, problem.file ?? "index.ts")} for the file`
|
|
34
44
|
})) : [{
|
|
45
|
+
code: "changed-since",
|
|
35
46
|
path: "functions",
|
|
36
47
|
message: saved.refusal.error,
|
|
37
48
|
hint: `Read ${functionsUri(env)} again and redo the change on the current files`
|
|
38
49
|
}];
|
|
39
50
|
var dataErrors = (saved, env) => "problems" in saved ? saved.problems.map((problem) => ({
|
|
51
|
+
code: "bad-value",
|
|
40
52
|
path: `data/${problem.file}`,
|
|
41
53
|
message: problem.message,
|
|
42
54
|
hint: `Fix it with upsertDataFile, or deleteDataFile; read ${dataFileUri(env, problem.file)} for the file`
|
|
43
55
|
})) : [{
|
|
56
|
+
code: "changed-since",
|
|
44
57
|
path: "data",
|
|
45
58
|
message: saved.refusal.error,
|
|
46
59
|
hint: `Read ${dataUri(env)} again and redo the change on the current files`
|
|
@@ -93,7 +106,7 @@ var apply = async (input, space, persisters) => {
|
|
|
93
106
|
suggestions: noWarnings(suggestions)
|
|
94
107
|
};
|
|
95
108
|
const unsaved = [];
|
|
96
|
-
if (outcome.changedFunctions && draft.functions) {
|
|
109
|
+
if (outcome.changedFunctions && draft.functions && !unchanged(space.functions?.files, draft.functions.files)) {
|
|
97
110
|
if (persisters?.saveFunctions) {
|
|
98
111
|
const saved = await persisters.saveFunctions(draft.functions.files, space.functions?.version ?? "");
|
|
99
112
|
if (!saved.ok) return {
|
|
@@ -110,7 +123,7 @@ var apply = async (input, space, persisters) => {
|
|
|
110
123
|
};
|
|
111
124
|
} else unsaved.push("the functions");
|
|
112
125
|
}
|
|
113
|
-
if (outcome.changedData && draft.data) {
|
|
126
|
+
if (outcome.changedData && draft.data && !unchanged(space.data?.files, draft.data.files)) {
|
|
114
127
|
if (persisters?.saveData) {
|
|
115
128
|
const saved = await persisters.saveData(draft.data.files, space.data?.version ?? "");
|
|
116
129
|
if (!saved.ok) return {
|
|
@@ -127,11 +140,11 @@ var apply = async (input, space, persisters) => {
|
|
|
127
140
|
};
|
|
128
141
|
} else unsaved.push("the data");
|
|
129
142
|
}
|
|
130
|
-
if (outcome.changedSchema) {
|
|
143
|
+
if (outcome.changedSchema && !unchanged(space.schema, draft.schema)) {
|
|
131
144
|
if (persisters?.schema) await persisters.schema(draft.schema);
|
|
132
145
|
else unsaved.push("the schema");
|
|
133
146
|
}
|
|
134
|
-
if (outcome.changedStyle) {
|
|
147
|
+
if (outcome.changedStyle && !unchanged(space.style, draft.style, ["cache"])) {
|
|
135
148
|
if (persisters?.style) {
|
|
136
149
|
draft.style.cache = generateCache(draft.style);
|
|
137
150
|
await persisters.style(draft.style);
|
|
@@ -139,6 +152,7 @@ var apply = async (input, space, persisters) => {
|
|
|
139
152
|
}
|
|
140
153
|
for (const id of outcome.changedConnectors) {
|
|
141
154
|
const entry = draft.connectors.find((item) => item.id === id);
|
|
155
|
+
if (entry && unchanged(space.connectors.find((item) => item.id === id), entry)) continue;
|
|
142
156
|
if (entry && persisters?.saveConnector) await persisters.saveConnector(entry);
|
|
143
157
|
else unsaved.push(`connector ${id}`);
|
|
144
158
|
}
|
|
@@ -146,6 +160,7 @@ var apply = async (input, space, persisters) => {
|
|
|
146
160
|
else unsaved.push(`the removal of connector ${id}`);
|
|
147
161
|
for (const id of outcome.changedActions) {
|
|
148
162
|
const entry = draft.actions.find((item) => item.id === id);
|
|
163
|
+
if (entry && unchanged(space.actions.find((item) => item.id === id), entry)) continue;
|
|
149
164
|
if (entry && persisters?.saveAction) await persisters.saveAction(entry);
|
|
150
165
|
else unsaved.push(`action ${id}`);
|
|
151
166
|
}
|
|
@@ -192,6 +207,7 @@ var applyTool = defineTool({
|
|
|
192
207
|
if (!input.look || !result.applied && !result.dryRun) return result;
|
|
193
208
|
const look = await lookAt(ctx, {
|
|
194
209
|
pageRef: input.pageRef,
|
|
210
|
+
routeParams: input.routeParams,
|
|
195
211
|
operations: result.dryRun ? input.operations : void 0,
|
|
196
212
|
view: input.look,
|
|
197
213
|
viewport: input.viewport,
|
|
@@ -16,7 +16,7 @@ var describeOperation = (type) => {
|
|
|
16
16
|
if (!schema) {
|
|
17
17
|
const nearest = closest(type, types);
|
|
18
18
|
return {
|
|
19
|
-
error: "
|
|
19
|
+
error: "missing",
|
|
20
20
|
message: `There is no "${type}" operation${nearest ? ` — did you mean "${nearest}"?` : ""}`,
|
|
21
21
|
...nearest ? { describe: { type: nearest } } : {},
|
|
22
22
|
types
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { apply } from "./apply/index.js";
|
|
2
|
-
import { findElementByRef } from "../helpers/space.js";
|
|
2
|
+
import { findElementByRef, findLayoutByRef, findRootByRef } from "../helpers/space.js";
|
|
3
3
|
import { scalar } from "./operations/schema/shared.js";
|
|
4
4
|
import { defineTool } from "./shared/tool.js";
|
|
5
5
|
import { closest } from "@plitzi/sdk-authoring";
|
|
@@ -13,10 +13,24 @@ var locate = (ctx, ref) => {
|
|
|
13
13
|
root: element.definition.rootId,
|
|
14
14
|
classes: element.definition.styleSelectors.base.split(/\s+/).filter(Boolean)
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
if (findRootByRef(ctx.space.schema, ref)) {
|
|
17
|
+
const kind = findLayoutByRef(ctx.space.schema, ref) ? "layout" : "page";
|
|
18
|
+
return {
|
|
19
|
+
done: false,
|
|
20
|
+
errors: [{
|
|
21
|
+
code: "bad-value",
|
|
22
|
+
path: "ref",
|
|
23
|
+
message: `"${ref}" is a ${kind}, not an element on one: this tool edits the elements inside it`,
|
|
24
|
+
hint: kind === "page" ? `plitzi://schema/{env}/pages/${ref} lists them by ref; plitzi_apply upsertPage { ref: "${ref}", style: { base: [...] } } gives the page its own classes` : `plitzi://schema/{env}/pages/${ref} lists them by ref; plitzi_apply upsertLayout edits the layout itself`
|
|
25
|
+
}]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const elements = Object.keys(ctx.space.schema.flat).filter((id) => findElementByRef(ctx.space.schema, id));
|
|
29
|
+
const nearest = closest(ref, elements);
|
|
17
30
|
return {
|
|
18
31
|
done: false,
|
|
19
32
|
errors: [{
|
|
33
|
+
code: "missing",
|
|
20
34
|
path: "ref",
|
|
21
35
|
message: `There is no element "${ref}"${nearest ? ` — did you mean "${nearest}"?` : ""}`,
|
|
22
36
|
hint: "plitzi_search finds an element by its words, type or class"
|
|
@@ -37,7 +51,12 @@ var run = async (ctx, operations, page, notes = []) => {
|
|
|
37
51
|
const warnings = [...notes, ...result.warnings ?? []];
|
|
38
52
|
if (!result.applied) return {
|
|
39
53
|
done: false,
|
|
40
|
-
errors: result.errors ?? (result.conflict ? [
|
|
54
|
+
errors: result.errors ?? (result.conflict ? [{
|
|
55
|
+
code: "changed-since",
|
|
56
|
+
path: "space",
|
|
57
|
+
message: result.conflict.message,
|
|
58
|
+
hint: "Someone changed it meanwhile: read it again and make the change on what it holds now"
|
|
59
|
+
}] : []),
|
|
41
60
|
...warnings.length > 0 ? { warnings } : {}
|
|
42
61
|
};
|
|
43
62
|
return {
|
|
@@ -68,6 +87,7 @@ var setAttributesTool = defineTool({
|
|
|
68
87
|
if (covered.length > 0) return {
|
|
69
88
|
done: false,
|
|
70
89
|
errors: covered.map((key) => ({
|
|
90
|
+
code: "not-allowed",
|
|
71
91
|
path: key,
|
|
72
92
|
message: `${key} of ${input.ref} is bound to ${String(bound.get(key))}: the page shows what the binding computes, not a value written here`,
|
|
73
93
|
hint: "plitzi_bind_attribute changes what it reads; to write a value instead, plitzi_apply deleteBinding first"
|
|
@@ -106,8 +126,10 @@ var setClassesTool = defineTool({
|
|
|
106
126
|
errors: absent.map((name) => {
|
|
107
127
|
const nearest = closest(name, at.classes);
|
|
108
128
|
return {
|
|
129
|
+
code: "missing",
|
|
109
130
|
path: "remove",
|
|
110
|
-
message: `${input.ref} does not wear "${name}"${nearest ? ` — did you mean "${nearest}"?` : ""}; it wears ${at.classes.join(", ") || "no class"}
|
|
131
|
+
message: `${input.ref} does not wear "${name}"${nearest ? ` — did you mean "${nearest}"?` : ""}; it wears ${at.classes.join(", ") || "no class"}`,
|
|
132
|
+
hint: "Take off a class it wears, as plitzi_read shows it"
|
|
111
133
|
};
|
|
112
134
|
})
|
|
113
135
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { fullPage, lookAt, pageRef, viewport } from "./shared/look.js";
|
|
1
|
+
import { fullPage, lookAt, pageRef, routeParams, viewport } from "./shared/look.js";
|
|
2
2
|
import { defineTool, imageResult } from "./shared/tool.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
// src/modules/mcp/tools/look.ts
|
|
5
5
|
var lookShape = {
|
|
6
6
|
pageRef,
|
|
7
|
+
routeParams,
|
|
7
8
|
view: z.enum([
|
|
8
9
|
"accessibility",
|
|
9
10
|
"html",
|
|
@@ -8,7 +8,7 @@ var deleteActionOp = z.object({
|
|
|
8
8
|
ref: z.string().describe("Identifier of the action to remove")
|
|
9
9
|
}).describe("Remove a server action. Destructive and not undoable: every step that runs it stops working, on published pages included, and a webhook pointing at it starts failing. Confirm with the user first.");
|
|
10
10
|
var deleteAction = (space, env, op) => {
|
|
11
|
-
if (!findActionEntry(space, op.ref)) return fail("ref", `Action "${op.ref}" does not exist`, `Read ${actionsUri(env)} for the actions this space has`, space.actions.map((item) => item.id));
|
|
11
|
+
if (!findActionEntry(space, op.ref)) return fail("missing", "ref", `Action "${op.ref}" does not exist`, `Read ${actionsUri(env)} for the actions this space has`, space.actions.map((item) => item.id));
|
|
12
12
|
space.actions = space.actions.filter((item) => item.id !== op.ref);
|
|
13
13
|
return {
|
|
14
14
|
...empty(),
|
|
@@ -25,12 +25,12 @@ var mergeMap = (current, patch) => {
|
|
|
25
25
|
};
|
|
26
26
|
var patchAction = (space, env, op) => {
|
|
27
27
|
const entry = findActionEntry(space, op.ref);
|
|
28
|
-
if (!entry) return fail("ref", `Action "${op.ref}" does not exist`, `Create it with upsertAction, or read ${actionsUri(env)} for the actions this space has`, space.actions.map((item) => item.id));
|
|
28
|
+
if (!entry) return fail("missing", "ref", `Action "${op.ref}" does not exist`, `Create it with upsertAction, or read ${actionsUri(env)} for the actions this space has`, space.actions.map((item) => item.id));
|
|
29
29
|
const { document } = entry;
|
|
30
30
|
const nodes = { ...document.nodes };
|
|
31
31
|
for (const node of op.nodes ?? []) {
|
|
32
32
|
if (node.remove) {
|
|
33
|
-
|
|
33
|
+
Reflect.deleteProperty(nodes, node.id);
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
const previous = nodes[node.id];
|
|
@@ -59,7 +59,7 @@ var patchAction = (space, env, op) => {
|
|
|
59
59
|
nodes
|
|
60
60
|
};
|
|
61
61
|
const report = validateActionDocument(patched);
|
|
62
|
-
if (!report.valid) return fail("nodes", `Invalid action: ${report.errors.map((issue) => issue.message).join("; ")}`, "", []);
|
|
62
|
+
if (!report.valid) return fail("bad-value", "nodes", `Invalid action: ${report.errors.map((issue) => issue.message).join("; ")}`, "Fix each step the message names: plitzi_describe_operation { type: \"patchAction\" } shows the fields a step takes", []);
|
|
63
63
|
entry.document = patched;
|
|
64
64
|
return {
|
|
65
65
|
...empty(),
|
|
@@ -58,7 +58,7 @@ var toDocument = (op) => ({
|
|
|
58
58
|
var upsertAction = (space, env, op) => {
|
|
59
59
|
const document = toDocument(op);
|
|
60
60
|
const report = validateActionDocument(document);
|
|
61
|
-
if (!report.valid) return fail("nodes", `Invalid action: ${report.errors.map((issue) => issue.message).join("; ")}`, "", []);
|
|
61
|
+
if (!report.valid) return fail("bad-value", "nodes", `Invalid action: ${report.errors.map((issue) => issue.message).join("; ")}`, "Fix each step the message names: plitzi_describe_operation { type: \"upsertAction\" } shows the fields a step takes", []);
|
|
62
62
|
const existing = findActionEntry(space, op.ref);
|
|
63
63
|
const stale = [actionsUri(env), actionUri(env, op.ref)];
|
|
64
64
|
if (existing) {
|
|
@@ -8,7 +8,7 @@ var deleteConnectorOp = z.object({
|
|
|
8
8
|
ref: z.string().describe("Identifier of the connector to remove")
|
|
9
9
|
}).describe("Remove a connector. Destructive and not undoable: every provider element pointing at it stops resolving and its page renders empty. Confirm with the user first.");
|
|
10
10
|
var deleteConnector = (space, env, op) => {
|
|
11
|
-
if (!findConnectorEntry(space, op.ref)) return fail("ref", `Connector "${op.ref}" does not exist`, `Read ${connectorsUri(env)} for the connectors this space has`, space.connectors.map((item) => item.id));
|
|
11
|
+
if (!findConnectorEntry(space, op.ref)) return fail("missing", "ref", `Connector "${op.ref}" does not exist`, `Read ${connectorsUri(env)} for the connectors this space has`, space.connectors.map((item) => item.id));
|
|
12
12
|
space.connectors = space.connectors.filter((item) => item.id !== op.ref);
|
|
13
13
|
return {
|
|
14
14
|
...empty(),
|
|
@@ -28,7 +28,7 @@ var mergeEndpoints = (current, patch) => {
|
|
|
28
28
|
};
|
|
29
29
|
var patchConnector = (space, env, op) => {
|
|
30
30
|
const entry = findConnectorEntry(space, op.ref);
|
|
31
|
-
if (!entry) return fail("ref", `Connector "${op.ref}" does not exist`, `Create it with upsertConnector, or read ${connectorsUri(env)} for the connectors this space has`, space.connectors.map((item) => item.id));
|
|
31
|
+
if (!entry) return fail("missing", "ref", `Connector "${op.ref}" does not exist`, `Create it with upsertConnector, or read ${connectorsUri(env)} for the connectors this space has`, space.connectors.map((item) => item.id));
|
|
32
32
|
const { manifest } = entry;
|
|
33
33
|
if (op.name !== void 0) entry.name = op.name;
|
|
34
34
|
if (op.baseUrl !== void 0) manifest.baseUrl = op.baseUrl;
|
|
@@ -43,7 +43,7 @@ var patchConnector = (space, env, op) => {
|
|
|
43
43
|
if (connection.projection !== void 0) manifest.projection = connection.projection;
|
|
44
44
|
const nextRead = mergeEndpoints(manifest.endpoints.read, op.endpoints?.read);
|
|
45
45
|
const nextWrite = mergeEndpoints(manifest.endpoints.write, op.endpoints?.write);
|
|
46
|
-
if (nextRead && Object.keys(nextRead).length === 0) return fail("endpoints.read", `This would leave connector "${op.ref}" with no read endpoint`, "A connector needs at least one read endpoint to feed an element. Delete the connector if that is the intent");
|
|
46
|
+
if (nextRead && Object.keys(nextRead).length === 0) return fail("bad-value", "endpoints.read", `This would leave connector "${op.ref}" with no read endpoint`, "A connector needs at least one read endpoint to feed an element. Delete the connector if that is the intent");
|
|
47
47
|
manifest.endpoints = {
|
|
48
48
|
read: nextRead ?? {},
|
|
49
49
|
...nextWrite === void 0 ? {} : { write: nextWrite }
|
|
@@ -11,7 +11,7 @@ var deleteDataFileOp = z.object({
|
|
|
11
11
|
type: z.literal("deleteDataFile"),
|
|
12
12
|
path: z.string()
|
|
13
13
|
}).describe("Remove one file of the space’s data.");
|
|
14
|
-
var unavailable = () => fail("type", "This deployment keeps no space data", "Read the data through a connector or a server action instead");
|
|
14
|
+
var unavailable = () => fail("not-allowed", "type", "This deployment keeps no space data", "Read the data through a connector or a server action instead");
|
|
15
15
|
/**
|
|
16
16
|
* The data is one store of files, saved whole: an op edits the draft's copy, and the batch saves the files it leaves —
|
|
17
17
|
* checked by the platform then (each path, the weight), which answers by file. A file that is not JSON is refused here,
|
|
@@ -22,7 +22,7 @@ var upsertDataFile = (space, env, op) => {
|
|
|
22
22
|
try {
|
|
23
23
|
JSON.parse(op.content);
|
|
24
24
|
} catch (error) {
|
|
25
|
-
return fail("content", `"${op.path}" is not JSON: ${error instanceof Error ? error.message : String(error)}`, "Write the whole file as JSON text — an object or a list");
|
|
25
|
+
return fail("bad-value", "content", `"${op.path}" is not JSON: ${error instanceof Error ? error.message : String(error)}`, "Write the whole file as JSON text — an object or a list");
|
|
26
26
|
}
|
|
27
27
|
const exists = Object.hasOwn(space.data.files, op.path);
|
|
28
28
|
space.data.files = {
|
|
@@ -37,7 +37,7 @@ var upsertDataFile = (space, env, op) => {
|
|
|
37
37
|
};
|
|
38
38
|
var deleteDataFile = (space, env, op) => {
|
|
39
39
|
if (!space.data) return unavailable();
|
|
40
|
-
if (!Object.hasOwn(space.data.files, op.path)) return fail("path", `The data has no file "${op.path}"`, `Read ${dataUri(env)} for the files it has`, Object.keys(space.data.files));
|
|
40
|
+
if (!Object.hasOwn(space.data.files, op.path)) return fail("missing", "path", `The data has no file "${op.path}"`, `Read ${dataUri(env)} for the files it has`, Object.keys(space.data.files));
|
|
41
41
|
const { [op.path]: _removed, ...files } = space.data.files;
|
|
42
42
|
space.data.files = files;
|
|
43
43
|
return {
|
|
@@ -11,7 +11,7 @@ var deleteFunctionFileOp = z.object({
|
|
|
11
11
|
type: z.literal("deleteFunctionFile"),
|
|
12
12
|
path: z.string()
|
|
13
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");
|
|
14
|
+
var unavailable = () => fail("not-allowed", "type", "This deployment runs no space functions", "Author the flow from the server tasks it offers instead");
|
|
15
15
|
/**
|
|
16
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
17
|
* leaves — built and checked by the platform then, which is where a problem in them is found and answered.
|
|
@@ -31,7 +31,7 @@ var upsertFunctionFile = (space, env, op) => {
|
|
|
31
31
|
};
|
|
32
32
|
var deleteFunctionFile = (space, env, op) => {
|
|
33
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));
|
|
34
|
+
if (!Object.hasOwn(space.functions.files, op.path)) return fail("bad-value", "path", `The functions have no file "${op.path}"`, `Read ${functionsUri(env)} for the files they have`, Object.keys(space.functions.files));
|
|
35
35
|
const { [op.path]: _removed, ...files } = space.functions.files;
|
|
36
36
|
space.functions.files = files;
|
|
37
37
|
return {
|