@plitzi/sdk-mcp 0.39.0 → 0.39.2
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 +29 -0
- package/README.md +5 -1
- package/dist/createServer.d.ts +3 -2
- package/dist/createServer.js +3 -13
- package/dist/index.js +8 -8
- package/dist/modules/mcp/accessibilityOutline.js +1 -2
- package/dist/modules/mcp/apps/index.js +3 -4
- package/dist/modules/mcp/apps/render/index.js +3 -7
- package/dist/modules/mcp/apps/render/styles.js +2 -3
- package/dist/modules/mcp/apps/shared/assets.d.ts +6 -0
- package/dist/modules/mcp/apps/shared/assets.js +15 -4
- package/dist/modules/mcp/apps/shared/bundle.js +3 -4
- package/dist/modules/mcp/apps/shared/index.d.ts +1 -1
- package/dist/modules/mcp/apps/shared/page.js +3 -5
- package/dist/modules/mcp/apps/shared/registerApp.js +1 -2
- package/dist/modules/mcp/apps/shared/resolve.js +1 -2
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +1 -2
- package/dist/modules/mcp/catalogs/observed.js +1 -2
- package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +1 -1
- package/dist/modules/mcp/catalogs/pluginCatalog.js +1 -2
- package/dist/modules/mcp/catalogs/registry.d.ts +2 -1
- package/dist/modules/mcp/catalogs/registry.js +1 -2
- package/dist/modules/mcp/handler.d.ts +1 -1
- package/dist/modules/mcp/handler.js +1 -2
- package/dist/modules/mcp/helpers/callToolResult.js +1 -2
- package/dist/modules/mcp/helpers/components.js +1 -2
- package/dist/modules/mcp/helpers/computeVersion.js +1 -2
- package/dist/modules/mcp/helpers/guide/index.js +1 -2
- package/dist/modules/mcp/helpers/guide/instructions.js +1 -2
- package/dist/modules/mcp/helpers/guide/logic.js +1 -2
- package/dist/modules/mcp/helpers/guide/practice.js +5 -5
- package/dist/modules/mcp/helpers/guide/reference.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/reference.js +3 -3
- package/dist/modules/mcp/helpers/guide/server.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/server.js +3 -4
- package/dist/modules/mcp/helpers/guide/structure.d.ts +1 -1
- package/dist/modules/mcp/helpers/guide/structure.js +3 -2
- package/dist/modules/mcp/helpers/guide/styling.js +1 -2
- package/dist/modules/mcp/helpers/guide/values.js +1 -2
- package/dist/modules/mcp/helpers/interactions.js +1 -2
- package/dist/modules/mcp/helpers/log.d.ts +1 -1
- package/dist/modules/mcp/helpers/log.js +2 -3
- package/dist/modules/mcp/helpers/opResult.js +1 -2
- package/dist/modules/mcp/helpers/space.d.ts +2 -1
- package/dist/modules/mcp/helpers/space.js +1 -2
- package/dist/modules/mcp/helpers/uris.js +1 -2
- package/dist/modules/mcp/localScreenshotClient.js +9 -6
- package/dist/modules/mcp/previewClient.js +1 -2
- package/dist/modules/mcp/proxy/config.d.ts +1 -1
- package/dist/modules/mcp/proxy/config.js +2 -3
- package/dist/modules/mcp/proxy/fetch.js +1 -2
- package/dist/modules/mcp/proxy/grant.js +1 -2
- package/dist/modules/mcp/proxy/guard.js +2 -3
- package/dist/modules/mcp/proxy/handler.d.ts +1 -1
- package/dist/modules/mcp/proxy/handler.js +2 -3
- package/dist/modules/mcp/proxy/payload.js +1 -2
- package/dist/modules/mcp/proxy/rewrite.js +1 -2
- package/dist/modules/mcp/proxy/sign.js +1 -2
- package/dist/modules/mcp/proxy/types.js +1 -2
- package/dist/modules/mcp/resources/actions.js +2 -3
- package/dist/modules/mcp/resources/canonical.js +1 -2
- package/dist/modules/mcp/resources/connectors.js +2 -3
- package/dist/modules/mcp/resources/core.js +4 -5
- package/dist/modules/mcp/resources/data.js +1 -2
- package/dist/modules/mcp/resources/envelope.js +1 -2
- package/dist/modules/mcp/resources/explain.js +1 -2
- package/dist/modules/mcp/resources/functions.js +1 -2
- package/dist/modules/mcp/resources/primer.js +7 -8
- package/dist/modules/mcp/resources/register.d.ts +1 -1
- package/dist/modules/mcp/resources/register.js +6 -7
- package/dist/modules/mcp/resources/renderGuide.js +2 -3
- package/dist/modules/mcp/resources/router.js +3 -4
- package/dist/modules/mcp/resources/schema.js +3 -4
- package/dist/modules/mcp/resources/style.js +2 -3
- package/dist/modules/mcp/screenshotClient.js +6 -5
- package/dist/modules/mcp/server.d.ts +1 -1
- package/dist/modules/mcp/server.js +4 -5
- package/dist/modules/mcp/tools/activity.js +1 -2
- package/dist/modules/mcp/tools/apply/dispatch.js +4 -5
- package/dist/modules/mcp/tools/apply/index.d.ts +5 -0
- package/dist/modules/mcp/tools/apply/index.js +3 -4
- package/dist/modules/mcp/tools/apply/writeResult.js +1 -2
- package/dist/modules/mcp/tools/describeOperation.js +2 -3
- package/dist/modules/mcp/tools/index.js +1 -2
- package/dist/modules/mcp/tools/intents.js +3 -4
- package/dist/modules/mcp/tools/look.js +2 -3
- package/dist/modules/mcp/tools/operations/actions/deleteAction.js +2 -3
- package/dist/modules/mcp/tools/operations/actions/document.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/actions/document.js +4 -3
- package/dist/modules/mcp/tools/operations/actions/index.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/actions/index.js +1 -2
- package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/actions/patchAction.js +3 -4
- package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/actions/upsertAction.js +3 -4
- package/dist/modules/mcp/tools/operations/closed.js +1 -2
- package/dist/modules/mcp/tools/operations/connectors/deleteConnector.js +2 -3
- package/dist/modules/mcp/tools/operations/connectors/index.js +1 -2
- package/dist/modules/mcp/tools/operations/connectors/manifest.js +1 -2
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.js +3 -4
- package/dist/modules/mcp/tools/operations/connectors/upsertConnector.js +3 -4
- package/dist/modules/mcp/tools/operations/data/index.js +1 -2
- package/dist/modules/mcp/tools/operations/functions/index.js +2 -3
- package/dist/modules/mcp/tools/operations/index.d.ts +12 -0
- package/dist/modules/mcp/tools/operations/index.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/components/deleteComponent.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/components/upsertComponent.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/flags/deleteFlag.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/flags/upsertFlag.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +3 -4
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +3 -3
- package/dist/modules/mcp/tools/operations/schema/shared.js +1 -2
- package/dist/modules/mcp/tools/operations/schema/translator.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +2 -3
- package/dist/modules/mcp/tools/operations/schema/write.js +3 -4
- package/dist/modules/mcp/tools/operations/schemaIds.js +1 -2
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +1 -2
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +2 -3
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +1 -2
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +1 -2
- package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +2 -3
- package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +2 -3
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +1 -2
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +2 -3
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +1 -2
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +1 -2
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +2 -3
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +1 -2
- package/dist/modules/mcp/tools/operations/style/operations.js +1 -2
- package/dist/modules/mcp/tools/operations/style/shared.js +1 -2
- package/dist/modules/mcp/tools/operations/style/translator.js +1 -2
- package/dist/modules/mcp/tools/operations/style/validate.js +1 -2
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +2 -3
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +2 -3
- package/dist/modules/mcp/tools/operations/style/write.js +2 -3
- package/dist/modules/mcp/tools/read.js +2 -3
- package/dist/modules/mcp/tools/render.d.ts +1 -0
- package/dist/modules/mcp/tools/render.js +3 -4
- package/dist/modules/mcp/tools/renderWidget.d.ts +1 -0
- package/dist/modules/mcp/tools/renderWidget.js +2 -3
- package/dist/modules/mcp/tools/search.js +2 -3
- package/dist/modules/mcp/tools/shared/draftBatch.js +2 -3
- package/dist/modules/mcp/tools/shared/effects.js +1 -2
- package/dist/modules/mcp/tools/shared/expandOperations.js +1 -2
- package/dist/modules/mcp/tools/shared/interactionReport.js +1 -2
- package/dist/modules/mcp/tools/shared/lintDraft.js +1 -2
- package/dist/modules/mcp/tools/shared/look.js +1 -2
- package/dist/modules/mcp/tools/shared/newSuggestions.js +1 -2
- package/dist/modules/mcp/tools/shared/normalizeOperations.js +1 -2
- package/dist/modules/mcp/tools/shared/repeats.js +1 -2
- package/dist/modules/mcp/tools/shared/tool.js +1 -2
- package/dist/modules/mcp/tools/shared/validator/batch.js +1 -2
- package/dist/modules/mcp/tools/shared/validator/bindings.js +1 -2
- package/dist/modules/mcp/tools/shared/validator/connectors.js +2 -3
- package/dist/modules/mcp/tools/shared/validator/context.js +1 -2
- package/dist/modules/mcp/tools/shared/validator/css.js +2 -3
- package/dist/modules/mcp/tools/shared/validator/elements.js +2 -3
- package/dist/modules/mcp/tools/shared/validator/index.js +20 -10
- package/dist/modules/mcp/tools/shared/validator/interactions.js +2 -3
- package/dist/modules/mcp/tools/shared/validator/refs.js +1 -2
- package/dist/modules/mcp/tools/test.js +1 -2
- package/dist/modules/mcp/tools/tryFunction.js +1 -2
- package/dist/modules/mcp/types/aiSchema.d.ts +2 -0
- package/dist/modules/mcp/types/screenshotTypes.d.ts +8 -0
- package/dist/options.d.ts +1 -1
- package/dist/pipeline.d.ts +2 -1
- package/dist/pipeline.js +4 -3
- package/dist/preview/createPreview.d.ts +1 -1
- package/dist/preview/createPreview.js +1 -2
- package/dist/preview.d.ts +7 -0
- package/dist/preview.js +1 -0
- package/dist/render.js +1 -1
- package/dist/server.js +3 -3
- package/dist/stages/mcp.d.ts +1 -1
- package/dist/stages/mcp.js +2 -3
- package/dist/stages/preview.d.ts +2 -1
- package/dist/stages/preview.js +3 -4
- package/dist/stages/proxy.d.ts +1 -1
- package/dist/stages/proxy.js +2 -3
- package/package.json +23 -16
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { noSpaceErrorCode, unauthorizedSpaceMessage } from "../helpers/space.js";
|
|
2
|
-
import { resourceErrorMessage } from "../resources/canonical.js";
|
|
3
2
|
import { RENDER_GUIDE_URI, RENDER_TYPES_URI } from "../resources/renderGuide.js";
|
|
4
3
|
import { readPublicResource, readResource } from "../resources/router.js";
|
|
4
|
+
import { resourceErrorMessage } from "../resources/canonical.js";
|
|
5
5
|
import { defineTool } from "./shared/tool.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
|
|
7
|
+
// src/modules/mcp/tools/read.ts
|
|
8
8
|
var readShape = { uris: z.array(z.string()).min(1).max(50).describe("Resource URIs to read in one batch (max 50). Use the ready-made uris from search / write responses.") };
|
|
9
9
|
var read = (input, space, env) => {
|
|
10
10
|
return { results: input.uris.map((uri) => {
|
|
@@ -47,5 +47,4 @@ var readTool = defineTool({
|
|
|
47
47
|
run: (input, ctx) => read(input, ctx.space, ctx.env),
|
|
48
48
|
runPublic: readPublic
|
|
49
49
|
});
|
|
50
|
-
//#endregion
|
|
51
50
|
export { read, readPublic, readShape, readTool };
|
|
@@ -255,6 +255,7 @@ export declare const renderShape: {
|
|
|
255
255
|
transientState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
256
256
|
keptState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
257
257
|
paintedState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
258
|
+
browserState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
258
259
|
userProvider: z.ZodOptional<z.ZodString>;
|
|
259
260
|
tokenStorage: z.ZodOptional<z.ZodEnum<{
|
|
260
261
|
"": "";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { compactDocumentOperations } from "./operations/index.js";
|
|
2
|
+
import { render, renderWidgetShape } from "./renderWidget.js";
|
|
1
3
|
import { iconFontCss } from "../apps/render/styles.js";
|
|
2
4
|
import { RENDER_APP_URI } from "../apps/render/index.js";
|
|
3
5
|
import { defineTool } from "./shared/tool.js";
|
|
4
|
-
import { compactDocumentOperations } from "./operations/index.js";
|
|
5
|
-
import { render, renderWidgetShape } from "./renderWidget.js";
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
|
|
8
|
+
// src/modules/mcp/tools/render.ts
|
|
9
9
|
var renderShape = {
|
|
10
10
|
...renderWidgetShape,
|
|
11
11
|
patch: z.boolean().optional().describe("Set true to CHANGE a widget you already rendered instead of rebuilding it: send its `renderId` and ONLY the operations that differ (patchDefinition, patchElement, deleteElement, a new repeatElement…). The widget merges them into the batch it was built from and reports back what it applied. The refs it already has (card-1, blk-2-3) are the ones to address. If that widget cannot be recovered — a surface that renders none, a host that keeps no storage — the answer says so and you re-send the whole batch."),
|
|
@@ -103,5 +103,4 @@ var renderTool = defineTool({
|
|
|
103
103
|
ui: { resourceUri: RENDER_APP_URI },
|
|
104
104
|
run: (input, ctx) => input.patch === true ? toPatchResult(input.operations, input.renderId) : toRenderResult(render(input, { proxy: ctx.proxy }), input.renderId ?? newRenderId())
|
|
105
105
|
});
|
|
106
|
-
//#endregion
|
|
107
106
|
export { renderShape, renderTool };
|
|
@@ -260,6 +260,7 @@ export declare const renderWidgetShape: {
|
|
|
260
260
|
transientState: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodString>>;
|
|
261
261
|
keptState: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodString>>;
|
|
262
262
|
paintedState: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodString>>;
|
|
263
|
+
browserState: import('zod').ZodOptional<import('zod').ZodArray<import('zod').ZodString>>;
|
|
263
264
|
userProvider: import('zod').ZodOptional<import('zod').ZodString>;
|
|
264
265
|
tokenStorage: import('zod').ZodOptional<import('zod').ZodEnum<{
|
|
265
266
|
"": "";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { documentOperations } from "./operations/index.js";
|
|
1
2
|
import { emptySpace } from "../helpers/space.js";
|
|
2
3
|
import { proxifyResources } from "../proxy/rewrite.js";
|
|
3
|
-
import { documentOperations } from "./operations/index.js";
|
|
4
4
|
import { draftBatch } from "./shared/draftBatch.js";
|
|
5
5
|
import { interactionReport } from "./shared/interactionReport.js";
|
|
6
6
|
import { generateCache } from "@plitzi/sdk-style";
|
|
7
|
-
|
|
7
|
+
// src/modules/mcp/tools/renderWidget.ts
|
|
8
8
|
/**
|
|
9
9
|
* A widget built from an agent's operations, with no space and no backend: the engine behind `plitzi_render`, apart
|
|
10
10
|
* from the MCP tool — so a project's own agent can draw the same widgets in its own pages (`@plitzi/sdk-mcp/render`).
|
|
@@ -63,5 +63,4 @@ var render = (input, options = {}) => {
|
|
|
63
63
|
warnings: noWarnings(warnings)
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
|
-
//#endregion
|
|
67
66
|
export { HOST_PAGE_REF, render, renderWidgetShape };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { computeVersion } from "../helpers/computeVersion.js";
|
|
2
|
-
import { getPageElements, isPageElement, nameOf, pageRefOfElement } from "../helpers/space.js";
|
|
3
2
|
import { elementUri, pageUri } from "../helpers/uris.js";
|
|
3
|
+
import { getPageElements, isPageElement, nameOf, pageRefOfElement } from "../helpers/space.js";
|
|
4
4
|
import { definitionRefs, definitionToAI } from "./operations/style/translator.js";
|
|
5
5
|
import { elementView, pageSkeletonToAI } from "./operations/schema/translator.js";
|
|
6
6
|
import { defineTool } from "./shared/tool.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
|
|
8
|
+
// src/modules/mcp/tools/search.ts
|
|
9
9
|
var searchShape = {
|
|
10
10
|
query: z.string().describe("Case-insensitive match on label, type and attribute values"),
|
|
11
11
|
filters: z.object({
|
|
@@ -111,5 +111,4 @@ var searchTool = defineTool({
|
|
|
111
111
|
access: "read",
|
|
112
112
|
run: (input, ctx) => search(input, ctx.space, ctx.env)
|
|
113
113
|
});
|
|
114
|
-
//#endregion
|
|
115
114
|
export { search, searchShape, searchTool };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { cloneSpace } from "../../helpers/space.js";
|
|
2
1
|
import { expandOperations } from "./expandOperations.js";
|
|
3
2
|
import { fixTouched, lintDraft } from "./lintDraft.js";
|
|
4
3
|
import { newSuggestions } from "./newSuggestions.js";
|
|
5
4
|
import { normalizeOperations } from "./normalizeOperations.js";
|
|
6
5
|
import { validateOperations } from "./validator/index.js";
|
|
6
|
+
import { cloneSpace } from "../../helpers/space.js";
|
|
7
7
|
import { applyOperations } from "../apply/dispatch.js";
|
|
8
|
-
|
|
8
|
+
// src/modules/mcp/tools/shared/draftBatch.ts
|
|
9
9
|
/**
|
|
10
10
|
* A batch run on a copy of the space and read back — the one way every tool that takes operations handles them, so
|
|
11
11
|
* a `dryRun` answers exactly what `plitzi_apply` would save, and `plitzi_render` holds a widget to the same rules.
|
|
@@ -67,5 +67,4 @@ var draftBatch = (space, env, operations, mode = "space") => {
|
|
|
67
67
|
suggestions: newSuggestions(prepared.space, draft)
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
-
//#endregion
|
|
71
70
|
export { draftBatch };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { canonicalJson, isRecord } from "@plitzi/sdk-shared/helpers";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/effects.ts
|
|
3
3
|
/**
|
|
4
4
|
* What a write did to the space, read off the documents before and after it — never off what was asked. An agent
|
|
5
5
|
* that is told only what it asked for cannot see the element a shared class also restyled, the child a move took with
|
|
@@ -150,5 +150,4 @@ var effectsOf = (before, after) => {
|
|
|
150
150
|
differences("data", before.data, after.data, out);
|
|
151
151
|
return out.length > LIMIT ? [...out.slice(0, LIMIT), `… and ${String(out.length - LIMIT)} more changes: read the resources listed in \`changed\``] : out;
|
|
152
152
|
};
|
|
153
|
-
//#endregion
|
|
154
153
|
export { effectsOf };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expandRepeat } from "../operations/schema/elements/repeatElement.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/expandOperations.ts
|
|
3
3
|
/** Rewrites the sugar ops into the vocabulary the rest of the pipeline knows, BEFORE validation — today that is
|
|
4
4
|
* `repeatElement`, which stands for the `upsertElement` its template + rows expand to. Everything downstream
|
|
5
5
|
* (validator, dispatch, audit, versions) therefore stays unaware of it, and a row that renders a bad element is
|
|
@@ -40,5 +40,4 @@ var expandOperations = (ops) => {
|
|
|
40
40
|
errors
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
|
-
//#endregion
|
|
44
43
|
export { expandOperations };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { flowsFromInteractions } from "../../helpers/interactions.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/interactionReport.ts
|
|
3
3
|
var TRIGGER = "trigger";
|
|
4
4
|
var stepLabel = (step) => {
|
|
5
5
|
if (step.nodeType !== "callback") return step.action;
|
|
@@ -44,5 +44,4 @@ var interactionReport = (space) => {
|
|
|
44
44
|
warnings: nestingWarnings(space)
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
|
-
//#endregion
|
|
48
47
|
export { interactionReport };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { findElementByRef, findPageByRef } from "../../helpers/space.js";
|
|
2
2
|
import { styleWithoutTag, validateSchema } from "@plitzi/sdk-schema";
|
|
3
3
|
import { authoringCodeEntry, elementSourceTypes, fixSpace, lintSpace } from "@plitzi/sdk-authoring";
|
|
4
|
-
|
|
4
|
+
// src/modules/mcp/tools/shared/lintDraft.ts
|
|
5
5
|
/** The elements a batch touches, by the ref each op names — what the lint of the result is held to. */
|
|
6
6
|
var touchedRefs = (ops) => {
|
|
7
7
|
const refs = /* @__PURE__ */ new Set();
|
|
@@ -155,5 +155,4 @@ var lintDraft = (draft, ops, before) => {
|
|
|
155
155
|
warnings
|
|
156
156
|
};
|
|
157
157
|
};
|
|
158
|
-
//#endregion
|
|
159
158
|
export { fixTouched, lintDraft };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { unnamedControls } from "../../accessibilityOutline.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
3
|
+
// src/modules/mcp/tools/shared/look.ts
|
|
4
4
|
/**
|
|
5
5
|
* How a page looks — as HTML, as a picture, or as a screen reader and a browser agent read it — rendered from the saved
|
|
6
6
|
* space or from a batch that was never saved.
|
|
@@ -124,5 +124,4 @@ var lookAt = async (ctx, request) => {
|
|
|
124
124
|
images: request.view === "accessibility" ? [] : shot.images
|
|
125
125
|
};
|
|
126
126
|
};
|
|
127
|
-
//#endregion
|
|
128
127
|
export { fullPage, lookAt, pageRef, viewport };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { suggestSpace } from "@plitzi/sdk-authoring";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/newSuggestions.ts
|
|
3
3
|
/**
|
|
4
4
|
* What a suggestion is about, one key each: its elements together, or — for one about declarations, which names many
|
|
5
5
|
* at once — each class, token or component on its own, so the one a batch just left unused is new beside the ones the
|
|
@@ -21,5 +21,4 @@ var newSuggestions = (before, after) => {
|
|
|
21
21
|
style: after.style
|
|
22
22
|
}).filter((suggestion) => keysOf(suggestion).some((key) => !had.has(key))).map(({ code, message, saves }) => `[${code}] ${message}${saves > 0 ? ` (saves ${String(saves)} element${saves === 1 ? "" : "s"})` : ""}`);
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
24
|
export { newSuggestions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildTypeRegistry } from "../../catalogs/registry.js";
|
|
2
2
|
import { elementTypeNames } from "../../catalogs/index.js";
|
|
3
|
-
|
|
3
|
+
// src/modules/mcp/tools/shared/normalizeOperations.ts
|
|
4
4
|
/**
|
|
5
5
|
* What a batch wrote that has one reading, read that way and said: an element type spelt with other capitals
|
|
6
6
|
* (`Heading`) is the type the catalog spells (`heading`). A guess between two names is never made here — a name with a
|
|
@@ -33,5 +33,4 @@ var normalizeOperations = (space, operations) => {
|
|
|
33
33
|
notes
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
-
//#endregion
|
|
37
36
|
export { normalizeOperations };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/repeats.ts
|
|
3
3
|
/**
|
|
4
4
|
* The same batch refused again — an agent going round in circles, which a model is not trusted to notice. Counted per
|
|
5
5
|
* process, as a hint and never a lock: a call that lands on another worker only loses the hint.
|
|
@@ -34,5 +34,4 @@ var REPEATED = {
|
|
|
34
34
|
error: "REPEATED_BATCH",
|
|
35
35
|
message: "This exact batch was refused twice, and was not run again. Change what the errors named, or ask the person."
|
|
36
36
|
};
|
|
37
|
-
//#endregion
|
|
38
37
|
export { AGAIN, REPEATED, batchKey, forgetRefused, noteRefused, timesRefused };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/tool.ts
|
|
3
3
|
/** Build the MCP CallToolResult for an image-returning tool: a text meta block followed by one image block per
|
|
4
4
|
* PNG, so a vision-capable agent (or MCP client) sees the render directly. */
|
|
5
5
|
var imageResult = (images, meta) => ({ content: [{
|
|
@@ -31,5 +31,4 @@ var defineTool = (spec) => {
|
|
|
31
31
|
...runPublic ? { executePublic: (args, env) => runPublic(parse(args), env) } : {}
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
//#endregion
|
|
35
34
|
export { defineTool, imageResult };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { slugRouteParams } from "../../../helpers/space.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/validator/batch.ts
|
|
3
3
|
var batchDeclaredVars = (ops) => {
|
|
4
4
|
const names = [];
|
|
5
5
|
for (const op of ops) if (op.type === "upsertVariable") names.push(op.name);
|
|
@@ -44,5 +44,4 @@ var batchDeclaredElements = (ops) => {
|
|
|
44
44
|
for (const op of ops) if (op.type === "upsertElement") walk(op.element);
|
|
45
45
|
return refs;
|
|
46
46
|
};
|
|
47
|
-
//#endregion
|
|
48
47
|
export { batchDeclaredElements, batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { warnOnce } from "./context.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/validator/bindings.ts
|
|
3
3
|
var checkBindingTarget = (ref, category, to, path, ctx) => {
|
|
4
4
|
if (category !== "attributes" && category !== "initialState") return;
|
|
5
5
|
const type = ctx.elementType(ref);
|
|
@@ -7,5 +7,4 @@ var checkBindingTarget = (ref, category, to, path, ctx) => {
|
|
|
7
7
|
if (!targets || targets.size === 0 || targets.has(to)) return;
|
|
8
8
|
warnOnce(ctx, `Binding target "${to}" at ${path} is not among the "${category}" targets the type "${type}" declares (${[...targets].sort().join(", ")}). Verify against plitzi://data-sources; it may still be valid.`);
|
|
9
9
|
};
|
|
10
|
-
//#endregion
|
|
11
10
|
export { checkBindingTarget };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { warnOnce } from "./context.js";
|
|
1
2
|
import { findConnectorEntry } from "../../../helpers/space.js";
|
|
2
3
|
import { toManifest } from "../../operations/connectors/upsertConnector.js";
|
|
3
|
-
import { warnOnce } from "./context.js";
|
|
4
4
|
import { validateConnectorManifest } from "@plitzi/sdk-shared/connectors";
|
|
5
|
-
|
|
5
|
+
// src/modules/mcp/tools/shared/validator/connectors.ts
|
|
6
6
|
/** Run the one shared manifest validator and fold its report into the batch result. Errors reject the batch;
|
|
7
7
|
* warnings ride along — notably "reads {{credential.…}} but names no credential", which is expected here: the
|
|
8
8
|
* agent authors the manifest and the space owner attaches the secret afterwards. */
|
|
@@ -71,5 +71,4 @@ var checkProviderElement = (space, ctx, ref, runtime, props, batchConnectors, ba
|
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
|
-
//#endregion
|
|
75
74
|
export { batchDeclaredConnectors, checkConnectorOp, checkProviderElement };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/tools/shared/validator/context.ts
|
|
2
2
|
var VAR_REF = /\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/g;
|
|
3
3
|
var CSS_VAR = /var\(\s*--([A-Za-z_][\w-]*)\s*\)/g;
|
|
4
4
|
var RAW_CODE_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -31,5 +31,4 @@ var checkObservedName = (value, observed, kind, resource, path, ctx) => {
|
|
|
31
31
|
if (!value || observed.size === 0 || observed.has(value)) return;
|
|
32
32
|
warnOnce(ctx, `${kind} "${value}" at ${path} was not seen in this space. Verify against ${resource}; it may still be valid.`);
|
|
33
33
|
};
|
|
34
|
-
//#endregion
|
|
35
34
|
export { RAW_CODE_TYPES, checkObservedName, checkStyleVarRefs, checkVarRefs, warnOnce };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ambiguousShorthands, expandShorthand, isCssProperty, suggestCssProperty } from "../../../catalogs/index.js";
|
|
2
1
|
import { checkStyleVarRefs, checkVarRefs } from "./context.js";
|
|
3
|
-
|
|
2
|
+
import { ambiguousShorthands, expandShorthand, isCssProperty, suggestCssProperty } from "../../../catalogs/index.js";
|
|
3
|
+
// src/modules/mcp/tools/shared/validator/css.ts
|
|
4
4
|
var checkCss = (css, path, ctx) => {
|
|
5
5
|
if (!css) return;
|
|
6
6
|
const declared = {};
|
|
@@ -40,5 +40,4 @@ var checkSlotCss = (slot, path, ctx) => {
|
|
|
40
40
|
checkCss(dm.mobile, `${path}.variants.${name}.mobile`, ctx);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
//#endregion
|
|
44
43
|
export { checkCss, checkSlotCss };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { definitionVariantNames } from "../../operations/style/translator.js";
|
|
2
1
|
import { RAW_CODE_TYPES, warnOnce } from "./context.js";
|
|
3
2
|
import { checkIdRef } from "./refs.js";
|
|
4
|
-
|
|
3
|
+
import { definitionVariantNames } from "../../operations/style/translator.js";
|
|
4
|
+
// src/modules/mcp/tools/shared/validator/elements.ts
|
|
5
5
|
var checkTypeProps = (type, props, path, ctx) => {
|
|
6
6
|
const meta = ctx.typeMeta.get(type);
|
|
7
7
|
if (!props || RAW_CODE_TYPES.has(type) || meta?.custom === false) return;
|
|
@@ -51,5 +51,4 @@ var checkElementInput = (element, path, ctx, seen) => {
|
|
|
51
51
|
checkElementProps(element, path, ctx);
|
|
52
52
|
element.children?.forEach((child, i) => checkElementInput(child, `${path}.children[${i}]`, ctx, seen));
|
|
53
53
|
};
|
|
54
|
-
//#endregion
|
|
55
54
|
export { checkElementInput, checkRawMarkup, checkTypeProps, checkVariantApplication };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { componentView, findComponentByRef } from "../../../helpers/components.js";
|
|
2
|
-
import { findElementByRef, findFolderByRef, findPageByRef, findRootByRef, folderAncestorIds, getLayoutElements, getPageElements, pageFoldersOf, resolveRef, routeParamNames } from "../../../helpers/space.js";
|
|
3
|
-
import { observedDataSources, observedInteractionActions } from "../../../catalogs/observed.js";
|
|
4
|
-
import { buildTypeRegistry } from "../../../catalogs/registry.js";
|
|
5
|
-
import { MAX_OPS } from "../../operations/index.js";
|
|
6
1
|
import { batchDeclaredElements, batchDeclaredFolders, batchDeclaredPages, batchDeclaredVariants, batchDeclaredVars } from "./batch.js";
|
|
7
|
-
import { checkObservedName, warnOnce } from "./context.js";
|
|
8
2
|
import { checkBindingTarget } from "./bindings.js";
|
|
9
3
|
import { batchDeclaredConnectors, checkConnectorOp, checkProviderElement } from "./connectors.js";
|
|
4
|
+
import { checkObservedName, warnOnce } from "./context.js";
|
|
10
5
|
import { checkSlotCss } from "./css.js";
|
|
11
|
-
import { checkRef } from "./refs.js";
|
|
12
6
|
import { checkElementInput, checkRawMarkup, checkTypeProps, checkVariantApplication } from "./elements.js";
|
|
13
7
|
import { checkInteractionNode } from "./interactions.js";
|
|
8
|
+
import { checkRef } from "./refs.js";
|
|
9
|
+
import { observedDataSources, observedInteractionActions } from "../../../catalogs/observed.js";
|
|
10
|
+
import { buildTypeRegistry } from "../../../catalogs/registry.js";
|
|
11
|
+
import { componentView, findComponentByRef } from "../../../helpers/components.js";
|
|
12
|
+
import { findElementByRef, findFolderByRef, findPageByRef, findRootByRef, folderAncestorIds, getLayoutElements, getPageElements, pageFoldersOf, resolveRef, routeParamNames } from "../../../helpers/space.js";
|
|
13
|
+
import { MAX_OPS } from "../../operations/index.js";
|
|
14
14
|
import { isValidElementId, treeOf } from "@plitzi/sdk-schema";
|
|
15
15
|
import { closest } from "@plitzi/sdk-authoring";
|
|
16
|
-
|
|
16
|
+
// src/modules/mcp/tools/shared/validator/index.ts
|
|
17
17
|
var STYLE_CATEGORIES = [
|
|
18
18
|
"color",
|
|
19
19
|
"spacing",
|
|
@@ -287,7 +287,11 @@ var validateOperations = (space, ops, mode = "space") => {
|
|
|
287
287
|
checkRef(op.ref, `${base}.ref`, ctx);
|
|
288
288
|
break;
|
|
289
289
|
case "patchSettings":
|
|
290
|
-
[
|
|
290
|
+
[
|
|
291
|
+
"transientState",
|
|
292
|
+
"paintedState",
|
|
293
|
+
"browserState"
|
|
294
|
+
].forEach((setting) => {
|
|
291
295
|
(op[setting] ?? []).forEach((key, index) => {
|
|
292
296
|
if (key.trim() === "" || key.includes(".")) ctx.errors.push({
|
|
293
297
|
path: `${base}.${setting}[${index}]`,
|
|
@@ -303,6 +307,13 @@ var validateOperations = (space, ops, mode = "space") => {
|
|
|
303
307
|
hint: "A painted key is kept so the server can draw with it; a transient one never is — remove it from one"
|
|
304
308
|
});
|
|
305
309
|
});
|
|
310
|
+
(op.browserState ?? []).forEach((key, index) => {
|
|
311
|
+
if (op.transientState?.includes(key)) ctx.errors.push({
|
|
312
|
+
path: `${base}.browserState[${index}]`,
|
|
313
|
+
message: `"${key}" is in both browserState and transientState`,
|
|
314
|
+
hint: "A key of the browser’s is a kept one that no change of account takes away; a transient one is never kept — remove it from one"
|
|
315
|
+
});
|
|
316
|
+
});
|
|
306
317
|
break;
|
|
307
318
|
case "deleteInteraction":
|
|
308
319
|
checkRef(op.ref, `${base}.ref`, ctx);
|
|
@@ -319,5 +330,4 @@ var validateOperations = (space, ops, mode = "space") => {
|
|
|
319
330
|
warnings: ctx.warnings
|
|
320
331
|
};
|
|
321
332
|
};
|
|
322
|
-
//#endregion
|
|
323
333
|
export { validateOperations };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { checkObservedName, warnOnce } from "./context.js";
|
|
1
2
|
import { getElementCallback, getGlobalCallback, getUtility, hiddenParams, reconcileParams } from "../../../catalogs/index.js";
|
|
2
3
|
import { NULLISH_ELEMENT_IDS } from "../../../helpers/interactions.js";
|
|
3
|
-
|
|
4
|
-
//#region src/modules/mcp/tools/shared/validator/interactions.ts
|
|
4
|
+
// src/modules/mcp/tools/shared/validator/interactions.ts
|
|
5
5
|
var ELEMENT_FIELD_ACTIONS = /* @__PURE__ */ new Set(["setState", "toggleState"]);
|
|
6
6
|
var checkParams = (label, action, params, spec, base, ctx) => {
|
|
7
7
|
const unknown = Object.keys(params).filter((key) => !(key in spec));
|
|
@@ -78,5 +78,4 @@ var checkInteractionNode = (node, base, ctx, hostRef) => {
|
|
|
78
78
|
case "utility": checkUtility(node, base, ctx);
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
-
//#endregion
|
|
82
81
|
export { checkInteractionNode };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isValidElementId } from "@plitzi/sdk-schema";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/tools/shared/validator/refs.ts
|
|
3
3
|
var REF_RE = /^[a-zA-Z0-9._-]+$/;
|
|
4
4
|
var checkRef = (ref, path, ctx) => {
|
|
5
5
|
if (!ref || ref.trim().length === 0) {
|
|
@@ -24,5 +24,4 @@ var checkIdRef = (ref, path, ctx) => {
|
|
|
24
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
|
-
//#endregion
|
|
28
27
|
export { REF_RE, checkIdRef, checkRef };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineTool } from "./shared/tool.js";
|
|
2
2
|
import { e2eTestProblems, journeyStartWarnings, readSpaceTests, runUnitTests, testAccountWarnings, unitTestProblems } from "@plitzi/sdk-authoring";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
|
|
4
|
+
// src/modules/mcp/tools/test.ts
|
|
5
5
|
var testShape = {
|
|
6
6
|
action: z.enum([
|
|
7
7
|
"list",
|
|
@@ -81,5 +81,4 @@ var testTool = defineTool({
|
|
|
81
81
|
access: "write",
|
|
82
82
|
run: (input, ctx) => test(input, ctx)
|
|
83
83
|
});
|
|
84
|
-
//#endregion
|
|
85
84
|
export { test, testShape, testTool };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineTool } from "./shared/tool.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
3
|
+
// src/modules/mcp/tools/tryFunction.ts
|
|
4
4
|
var tryFunctionShape = {
|
|
5
5
|
task: z.string().describe("`<namespace>.<action>`"),
|
|
6
6
|
params: z.record(z.string(), z.unknown()).optional(),
|
|
@@ -39,5 +39,4 @@ var tryFunctionTool = defineTool({
|
|
|
39
39
|
access: "write",
|
|
40
40
|
run: (input, ctx) => tryFunction(input, ctx)
|
|
41
41
|
});
|
|
42
|
-
//#endregion
|
|
43
42
|
export { tryFunction, tryFunctionShape, tryFunctionTool };
|
|
@@ -284,6 +284,8 @@ export interface AISettings {
|
|
|
284
284
|
keptState?: string[];
|
|
285
285
|
/** Kept keys the first paint shows, kept in a cookie too so the server renders with them. Small values only. */
|
|
286
286
|
paintedState?: string[];
|
|
287
|
+
/** Kept keys that are the browser's rather than the account's, which no change of account takes away. */
|
|
288
|
+
browserState?: string[];
|
|
287
289
|
/** `basic` covers any HTTP+JSON backend by configuration; anything else is a name someone registered. */
|
|
288
290
|
userProvider?: 'basic' | 'custom' | '' | (string & {});
|
|
289
291
|
tokenStorage?: 'localStorage' | 'sessionStorage' | '';
|
|
@@ -43,6 +43,14 @@ export type ScreenshotInput = {
|
|
|
43
43
|
* `accessibility`, and the caller says so rather than failing.
|
|
44
44
|
*/
|
|
45
45
|
views?: CaptureView[];
|
|
46
|
+
/**
|
|
47
|
+
* How the picture is encoded: `png` when left out — what a check that compares pixels needs — or `webp`, for a picture
|
|
48
|
+
* a person is shown, at a tenth of the size (a full-page thumbnail was 2 MB of PNG). A browser service that cannot
|
|
49
|
+
* answers PNG, and the image's `mimeType` says which it got.
|
|
50
|
+
*/
|
|
51
|
+
format?: 'png' | 'webp';
|
|
52
|
+
/** WebP's quality, 1–100. Default 80. */
|
|
53
|
+
quality?: number;
|
|
46
54
|
};
|
|
47
55
|
/** How a look reaches the headless-browser service. The consumer injects an implementation (an HTTP
|
|
48
56
|
* client to the dedicated browser pod); absent, or a capture that fails (pod down) and answers `ok:false` rather than
|
package/dist/options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OAuthConfig } from '@plitzi/sdk-
|
|
1
|
+
import { OAuthConfig } from '@plitzi/sdk-kernel/types';
|
|
2
2
|
/** How a rendered widget reaches ANYTHING outside its sandbox — images, media, fonts, and the endpoints an
|
|
3
3
|
* apiContainer fetches. A widget runs in an iframe under a CSP the host builds from the origins this server
|
|
4
4
|
* declares on its `ui://` resource, which is read before any widget exists (and the spec allows no per-call CSP),
|
package/dist/pipeline.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { McpOptions } from './options';
|
|
2
|
-
import { BaseContext,
|
|
2
|
+
import { BaseContext, Stage } from '@plitzi/sdk-kernel/http';
|
|
3
|
+
import { PipelineExtensions } from '@plitzi/sdk-server';
|
|
3
4
|
export declare const buildMCPPipeline: (options?: McpOptions) => Stage<BaseContext>[];
|
|
4
5
|
/** What this package contributes to somebody else's PAGE server: the MCP endpoint alongside SSR on one port.
|
|
5
6
|
* Every stage here gates itself — MCP is self-authenticating, the widget proxy must stay reachable without a
|
package/dist/pipeline.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createMcpOnlyStage, createMcpStage } from "./stages/mcp.js";
|
|
2
2
|
import { previewStage } from "./stages/preview.js";
|
|
3
3
|
import { createWidgetProxyStage } from "./stages/proxy.js";
|
|
4
|
-
import { configStaticStage, healthStage } from "@plitzi/sdk-
|
|
4
|
+
import { configStaticStage, healthStage } from "@plitzi/sdk-kernel/http";
|
|
5
|
+
import { statsStage } from "@plitzi/sdk-kernel/stats";
|
|
5
6
|
import { createOAuthGuardStage, createOAuthStage } from "@plitzi/sdk-server/oauth";
|
|
6
|
-
|
|
7
|
+
// src/pipeline.ts
|
|
7
8
|
var buildMCPPipeline = (options = {}) => [
|
|
8
9
|
healthStage,
|
|
10
|
+
statsStage,
|
|
9
11
|
configStaticStage,
|
|
10
12
|
createWidgetProxyStage(options),
|
|
11
13
|
createOAuthStage(options.oauth),
|
|
@@ -25,5 +27,4 @@ var mcpExtensions = (options = {}) => ({ preAuth: [
|
|
|
25
27
|
createMcpStage(options),
|
|
26
28
|
previewStage
|
|
27
29
|
] });
|
|
28
|
-
//#endregion
|
|
29
30
|
export { buildMCPPipeline, mcpExtensions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PreviewRequestBody, PreviewResult } from '../modules/mcp/types';
|
|
2
|
+
import { SSRPageServerConfig, SSRTemplateFn } from '@plitzi/sdk-server';
|
|
2
3
|
import { PluginManager, ServerCaches } from '@plitzi/sdk-server/ssr';
|
|
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
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
6
|
* render at `?__pt=<token>`. With no operations it previews persisted state.
|
|
@@ -3,7 +3,7 @@ import { findPageByRef, getPageElements } from "../modules/mcp/helpers/space.js"
|
|
|
3
3
|
import { draftBatch } from "../modules/mcp/tools/shared/draftBatch.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { buildBody } from "@plitzi/sdk-server/ssr";
|
|
6
|
-
|
|
6
|
+
// src/preview/createPreview.ts
|
|
7
7
|
var resolvePagePath = (schema, pageRef) => {
|
|
8
8
|
const pages = getPageElements(schema);
|
|
9
9
|
const page = pageRef ? findPageByRef(schema, pageRef) : pages.find((p) => p.attributes.default) ?? pages[0];
|
|
@@ -83,5 +83,4 @@ var createPreview = async (body, config, renderFn, pluginManager, caches) => {
|
|
|
83
83
|
...token ? { expiresInMs: ttlMs } : {}
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
//#endregion
|
|
87
86
|
export { createPreview };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The draft-preview endpoint alone, for the page server that mounts it: `POST /__preview` applies unsaved operations
|
|
2
|
+
* to a copy of the draft and renders it.
|
|
3
|
+
*
|
|
4
|
+
* Import it as `@plitzi/sdk-mcp/preview`. The package root carries the MCP server too — its SDK, its tools, its
|
|
5
|
+
* resources — which a page server never runs; and what a preview itself needs (the operations, their lint, the
|
|
6
|
+
* render) is loaded by the first preview the process is asked for, not when it starts. */
|
|
7
|
+
export { previewStage } from './stages/preview';
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { previewStage } from "./stages/preview.js";
|
package/dist/render.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics } from "./modules/mcp/resources/renderGuide.js";
|
|
2
1
|
import { HOST_PAGE_REF, render, renderWidgetShape } from "./modules/mcp/tools/renderWidget.js";
|
|
2
|
+
import { renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics } from "./modules/mcp/resources/renderGuide.js";
|
|
3
3
|
export { HOST_PAGE_REF as RENDER_ROOT_REF, render, renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics, renderWidgetShape };
|
package/dist/server.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createMcpServer } from "./modules/mcp/server.js";
|
|
2
|
+
import { createServer } from "./createServer.js";
|
|
3
|
+
import { buildMCPPipeline } from "./pipeline.js";
|
|
2
4
|
import { handleMcp, readMcpBody, serveMcp } from "./modules/mcp/handler.js";
|
|
3
5
|
import { createHttpPreviewClient } from "./modules/mcp/previewClient.js";
|
|
6
|
+
import { pluginCatalog, stringDeclarations } from "./modules/mcp/catalogs/pluginCatalog.js";
|
|
4
7
|
import { createHttpScreenshotClient } from "./modules/mcp/screenshotClient.js";
|
|
5
|
-
import { buildMCPPipeline } from "./pipeline.js";
|
|
6
|
-
import { createServer } from "./createServer.js";
|
|
7
8
|
import { createLocalScreenshotClient, resolveLocalBrowser } from "./modules/mcp/localScreenshotClient.js";
|
|
8
|
-
import { pluginCatalog, stringDeclarations } from "./modules/mcp/catalogs/pluginCatalog.js";
|
|
9
9
|
export { buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpServer, createServer, handleMcp, pluginCatalog, readMcpBody, resolveLocalBrowser, serveMcp, stringDeclarations };
|
package/dist/stages/mcp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { McpOptions } from '../options';
|
|
2
|
-
import { Stage } from '@plitzi/sdk-
|
|
2
|
+
import { Stage } from '@plitzi/sdk-kernel/http';
|
|
3
3
|
export declare const createMcpStage: (options?: McpOptions) => Stage;
|
|
4
4
|
export declare const createMcpOnlyStage: (options?: McpOptions) => Stage;
|
package/dist/stages/mcp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { requestProxy } from "../modules/mcp/proxy/config.js";
|
|
2
1
|
import { handleMcp } from "../modules/mcp/handler.js";
|
|
3
2
|
import { createHttpPreviewClient } from "../modules/mcp/previewClient.js";
|
|
3
|
+
import { requestProxy } from "../modules/mcp/proxy/config.js";
|
|
4
4
|
import { createHttpScreenshotClient } from "../modules/mcp/screenshotClient.js";
|
|
5
|
-
|
|
5
|
+
// src/stages/mcp.ts
|
|
6
6
|
var DEFAULT_PATH = "/mcp";
|
|
7
7
|
var serveMcp = async (ctx, options) => {
|
|
8
8
|
const { previewClient, screenshot } = options;
|
|
@@ -26,5 +26,4 @@ var createMcpOnlyStage = (options = {}) => async (ctx) => {
|
|
|
26
26
|
await serveMcp(ctx, options);
|
|
27
27
|
return true;
|
|
28
28
|
};
|
|
29
|
-
//#endregion
|
|
30
29
|
export { createMcpOnlyStage, createMcpStage };
|
package/dist/stages/preview.d.ts
CHANGED