@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,7 +1,7 @@
|
|
|
1
|
-
import { isBlockedHost } from "@plitzi/sdk-server/kernel";
|
|
2
1
|
import { lookup } from "node:dns/promises";
|
|
3
2
|
import { isIP } from "node:net";
|
|
4
|
-
|
|
3
|
+
import { isBlockedHost } from "@plitzi/sdk-kernel/outbound";
|
|
4
|
+
// src/modules/mcp/proxy/guard.ts
|
|
5
5
|
/**
|
|
6
6
|
* Whether an ADDRESS is never the public internet. The ranges are sdk-server's, the same rule its `http.request` task
|
|
7
7
|
* and connector engine follow: this module used to keep its own copy, and the copy judged `::ffff:7f00:1` — the form a
|
|
@@ -30,5 +30,4 @@ var isPublicHost = async (hostname) => {
|
|
|
30
30
|
return false;
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
//#endregion
|
|
34
33
|
export { isPrivateAddress, isPublicHost };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ResourceProxySettings } from './types';
|
|
2
|
-
import { SSRRequest, SSRResponseHelpers } from '@plitzi/sdk-
|
|
2
|
+
import { SSRRequest, SSRResponseHelpers } from '@plitzi/sdk-kernel/types';
|
|
3
3
|
/** Serve one external resource on behalf of a widget: check the grant this server signed, fetch the target, and
|
|
4
4
|
* stream it back under this origin — the one the CSP declares. Read-only, credential-free and CORS-open, because
|
|
5
5
|
* it answers the host's sandboxed iframe: a browser that has no origin of its own and can present nothing. The
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { grantingProxy } from "./config.js";
|
|
2
|
-
import { readGrant } from "./grant.js";
|
|
3
2
|
import { fetchResource } from "./fetch.js";
|
|
3
|
+
import { readGrant } from "./grant.js";
|
|
4
4
|
import { rewritablePayload, rewritePayload } from "./payload.js";
|
|
5
|
-
|
|
5
|
+
// src/modules/mcp/proxy/handler.ts
|
|
6
6
|
var CACHE_CONTROL = {
|
|
7
7
|
asset: "public, max-age=86400, immutable",
|
|
8
8
|
data: "no-store"
|
|
@@ -95,5 +95,4 @@ var handleProxyRequest = async (req, res, settings) => {
|
|
|
95
95
|
res.end();
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
-
//#endregion
|
|
99
98
|
export { handleProxyRequest };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { grantUrl, isGranted, isRemote } from "./grant.js";
|
|
2
2
|
import { looksLikeAsset } from "./rewrite.js";
|
|
3
|
-
|
|
3
|
+
// src/modules/mcp/proxy/payload.ts
|
|
4
4
|
var JSON_TYPES = ["application/json", "application/ld+json"];
|
|
5
5
|
var ASSET_FIELD = /(image|img|thumb|photo|picture|avatar|icon|logo|cover|banner|poster|artwork|media|src)/i;
|
|
6
6
|
/** Is this what the endpoint fetched a body it can rewrite? Only JSON: it is what an apiContainer binds against,
|
|
@@ -25,5 +25,4 @@ var rewritePayload = (body, proxy) => {
|
|
|
25
25
|
return body;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
28
|
export { rewritablePayload, rewritePayload };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { grantUrl, isGranted, isRemote } from "./grant.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/proxy/rewrite.ts
|
|
3
3
|
var URL_ATTRIBUTES = ["src", "poster"];
|
|
4
4
|
var MARKUP_ATTRIBUTES = ["content", "html"];
|
|
5
5
|
var FETCHING_TYPE = "apiContainer";
|
|
@@ -148,5 +148,4 @@ var proxifyResources = (space, proxy) => {
|
|
|
148
148
|
rewriteStyle(space.style, proxy);
|
|
149
149
|
return warnings;
|
|
150
150
|
};
|
|
151
|
-
//#endregion
|
|
152
151
|
export { looksLikeAsset, proxifyResources, rewriteText };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/proxy/sign.ts
|
|
3
3
|
var SIGNATURE_LENGTH = 22;
|
|
4
4
|
var sign = (payload, secret) => createHmac("sha256", secret).update(payload).digest("base64url").slice(0, SIGNATURE_LENGTH);
|
|
5
5
|
var verify = (payload, signature, secret) => {
|
|
@@ -11,5 +11,4 @@ var verify = (payload, signature, secret) => {
|
|
|
11
11
|
* Derived through the same secret, so it identifies without echoing any part of the token; a request with no
|
|
12
12
|
* credential (the public widgets surface) gets the shared anonymous identity. */
|
|
13
13
|
var connectionId = (authorization, secret) => authorization ? sign(`id:${authorization}`, secret).slice(0, 10) : "anon";
|
|
14
|
-
//#endregion
|
|
15
14
|
export { connectionId, sign, verify };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// src/modules/mcp/proxy/types.ts
|
|
2
2
|
/** The tools a proxy may be handed to. `plitzi_render` alone by default, and that default is a guard, not a
|
|
3
3
|
* convenience: a render is a THROWAWAY widget, so rewriting its URLs changes nothing that outlives the call —
|
|
4
4
|
* while plitzi_apply writes to the user's real space, where a rewritten URL would be PERSISTED and the space
|
|
5
5
|
* would come to depend on this server's endpoint for content it owns. Nothing else should be added here without
|
|
6
6
|
* that being the intention. */
|
|
7
7
|
var DEFAULT_PROXY_TOOLS = ["plitzi_render"];
|
|
8
|
-
//#endregion
|
|
9
8
|
export { DEFAULT_PROXY_TOOLS };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { findActionEntry } from "../helpers/space.js";
|
|
2
1
|
import { actionTasksUri, actionUri, actionsUri, afterPrefix } from "../helpers/uris.js";
|
|
2
|
+
import { findActionEntry } from "../helpers/space.js";
|
|
3
3
|
import { envelope } from "./envelope.js";
|
|
4
4
|
import { actionTriggers, isActionEnabled, triggerAccess, triggerInput } from "@plitzi/sdk-shared/actions";
|
|
5
|
-
|
|
5
|
+
// src/modules/mcp/resources/actions.ts
|
|
6
6
|
/**
|
|
7
7
|
* What a `runServerAction` step needs to know without opening the flow: what the action is called, whether it can
|
|
8
8
|
* run at all, and — per way in — who may use it and what it takes. The steps themselves are one read away: they
|
|
@@ -50,5 +50,4 @@ var readActionResource = (space, env, uri) => {
|
|
|
50
50
|
document: entry.document
|
|
51
51
|
}) : null;
|
|
52
52
|
};
|
|
53
|
-
//#endregion
|
|
54
53
|
export { actionSummaries, readActionResource };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { afterPrefix, aliasedRoots, itemTemplates, primerUri } from "../helpers/uris.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/resources/canonical.ts
|
|
3
3
|
var canonicalUri = (env, uri) => {
|
|
4
4
|
const rest = afterPrefix(uri, `plitzi://schema/${env}/`);
|
|
5
5
|
if (rest === void 0) return uri;
|
|
@@ -26,5 +26,4 @@ var resourceErrorMessage = (env, uri) => {
|
|
|
26
26
|
validTemplates: [primerUri(env), ...itemTemplates(env)]
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
-
//#endregion
|
|
30
29
|
export { canonicalUri, resourceErrorMessage };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { findConnectorEntry } from "../helpers/space.js";
|
|
2
1
|
import { afterPrefix, connectorUri, connectorsUri } from "../helpers/uris.js";
|
|
2
|
+
import { findConnectorEntry } from "../helpers/space.js";
|
|
3
3
|
import { envelope } from "./envelope.js";
|
|
4
4
|
import { connectorPresets, connectorTokens } from "@plitzi/sdk-shared/connectors";
|
|
5
|
-
|
|
5
|
+
// src/modules/mcp/resources/connectors.ts
|
|
6
6
|
/** What a provider element needs to know about a connector without opening it: which endpoints it can address,
|
|
7
7
|
* which operators its filters may use, and which fields it publishes. The listing carries this for every
|
|
8
8
|
* connector so choosing one — and wiring an apiContainer to it — takes a single read. */
|
|
@@ -42,5 +42,4 @@ var readConnectorResource = (space, env, uri) => {
|
|
|
42
42
|
manifest: entry.manifest
|
|
43
43
|
}) : null;
|
|
44
44
|
};
|
|
45
|
-
//#endregion
|
|
46
45
|
export { connectorSummaries, readConnectorResource };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { envelope } from "./envelope.js";
|
|
2
|
+
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
3
|
+
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
1
4
|
import "../helpers/uris.js";
|
|
2
5
|
import { guideText } from "../helpers/guide/index.js";
|
|
3
|
-
|
|
4
|
-
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
5
|
-
import { envelope } from "./envelope.js";
|
|
6
|
-
//#region src/modules/mcp/resources/core.ts
|
|
6
|
+
// src/modules/mcp/resources/core.ts
|
|
7
7
|
/** Space-independent singletons: the usage guide, the observed type registry and the CSS property catalog.
|
|
8
8
|
* Returns undefined when the URI is not one of these, so the router falls through to the next resolver. */
|
|
9
9
|
var readCoreResource = (space, uri) => {
|
|
@@ -14,5 +14,4 @@ var readCoreResource = (space, uri) => {
|
|
|
14
14
|
shorthands: cssShorthands
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { readCoreResource };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { afterPrefix, dataFileUri, dataUri } from "../helpers/uris.js";
|
|
2
2
|
import { envelope } from "./envelope.js";
|
|
3
|
-
|
|
3
|
+
// src/modules/mcp/resources/data.ts
|
|
4
4
|
/**
|
|
5
5
|
* The space's own data: JSON its server providers read (`query: '/data/<file>'`, `runtime: 'server'`), never served.
|
|
6
6
|
* The listing says which files there are, so an agent reads the one it needs; a file reads whole — parsed, so its
|
|
@@ -42,5 +42,4 @@ var readDataResource = (space, env, uri) => {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
//#endregion
|
|
46
45
|
export { readDataResource };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computeVersion } from "../helpers/computeVersion.js";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/resources/envelope.ts
|
|
3
3
|
/** Wrap any read projection with the version its optimistic-concurrency checks key on. */
|
|
4
4
|
var envelope = (data) => ({
|
|
5
5
|
stateVersion: computeVersion(data),
|
|
@@ -10,5 +10,4 @@ var jsonContents = (uri, data) => ({ contents: [{
|
|
|
10
10
|
mimeType: "application/json",
|
|
11
11
|
text: JSON.stringify(data)
|
|
12
12
|
}] });
|
|
13
|
-
//#endregion
|
|
14
13
|
export { envelope, jsonContents };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EXPLAIN_KINDS, explain, explainKindOf, explainList, explanationText } from "@plitzi/sdk-authoring";
|
|
2
|
-
|
|
2
|
+
// src/modules/mcp/resources/explain.ts
|
|
3
3
|
/** `plitzi://explain/{name}`: what a name means when authoring, or every name of a kind (`plitzi://explain/steps`). */
|
|
4
4
|
var EXPLAIN_URI_TEMPLATE = "plitzi://explain/{name}";
|
|
5
5
|
var PREFIX = "plitzi://explain/";
|
|
@@ -18,5 +18,4 @@ var explainResource = (uri) => {
|
|
|
18
18
|
text: explanations.map(explanationText).join("\n\n")
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
//#endregion
|
|
22
21
|
export { EXPLAIN_URI_TEMPLATE, explainResource };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { afterPrefix, functionFileUri, functionsUri } from "../helpers/uris.js";
|
|
2
2
|
import { envelope } from "./envelope.js";
|
|
3
|
-
|
|
3
|
+
// src/modules/mcp/resources/functions.ts
|
|
4
4
|
/**
|
|
5
5
|
* The space's own functions: the listing says what they declare and which files they are, so an agent knows where to
|
|
6
6
|
* look before it reads one; a file reads whole. Server-side code — never a browser payload — and it holds no secret: a
|
|
@@ -31,5 +31,4 @@ var readFunctionsResource = (space, env, uri) => {
|
|
|
31
31
|
content
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
//#endregion
|
|
35
34
|
export { readFunctionsResource };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { connectorSummaries } from "./connectors.js";
|
|
2
|
+
import { envelope } from "./envelope.js";
|
|
3
|
+
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
4
|
+
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
5
|
+
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
1
6
|
import { componentSummariesToAI } from "../helpers/components.js";
|
|
2
7
|
import { componentsUri, connectorsUri, dataSourcesUri, defsUri, flagsUri, foldersUri, fontsUri, interactionsUri, layoutsUri, pagesUri, primerUri, schemaVarsUri, settingsUri, styleVarsUri, typesUri } from "../helpers/uris.js";
|
|
3
8
|
import { guideQuickstart } from "../helpers/guide/instructions.js";
|
|
4
|
-
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
5
|
-
import { buildTypeRegistry } from "../catalogs/registry.js";
|
|
6
|
-
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
7
|
-
import { envelope } from "./envelope.js";
|
|
8
|
-
import { connectorSummaries } from "./connectors.js";
|
|
9
|
-
import { definitionRefs, fontsToAI, styleVariablesToAI } from "../tools/operations/style/translator.js";
|
|
10
9
|
import { foldersToAI, layoutSummariesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
|
|
11
|
-
|
|
10
|
+
import { definitionRefs, fontsToAI, styleVariablesToAI } from "../tools/operations/style/translator.js";
|
|
11
|
+
// src/modules/mcp/resources/primer.ts
|
|
12
12
|
/**
|
|
13
13
|
* How much of the cold-start bundle the SPACE may fill, in characters of JSON.
|
|
14
14
|
*
|
|
@@ -209,5 +209,4 @@ var readPrimerResource = (space, env, uri) => {
|
|
|
209
209
|
} } : {}
|
|
210
210
|
});
|
|
211
211
|
};
|
|
212
|
-
//#endregion
|
|
213
212
|
export { readPrimerResource };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpLog, Space } from '../helpers';
|
|
2
2
|
import { Env } from '../types';
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
-
import { SSRChangePage, SSRChangeQuery } from '@plitzi/sdk-
|
|
4
|
+
import { SSRChangePage, SSRChangeQuery } from '@plitzi/sdk-kernel/types';
|
|
5
5
|
/** Register every resource on the MCP server: fixed listings plus templated per-item reads. The space is
|
|
6
6
|
* loaded lazily via getSpace, so listing resources never touches the store — only reading one does.
|
|
7
7
|
*
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { changesUri } from "../helpers/uris.js";
|
|
2
|
-
import { guideText } from "../helpers/guide/index.js";
|
|
3
|
-
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
4
|
-
import { envelope, jsonContents } from "./envelope.js";
|
|
5
1
|
import { resourceErrorMessage } from "./canonical.js";
|
|
2
|
+
import { envelope, jsonContents } from "./envelope.js";
|
|
3
|
+
import { EXPLAIN_URI_TEMPLATE, explainResource } from "./explain.js";
|
|
6
4
|
import { registerRenderResources } from "./renderGuide.js";
|
|
7
5
|
import { readResource } from "./router.js";
|
|
8
|
-
import {
|
|
6
|
+
import { cssProperties, cssShorthands } from "../catalogs/index.js";
|
|
7
|
+
import { guideText } from "../helpers/guide/index.js";
|
|
8
|
+
import { changesUri } from "../helpers/uris.js";
|
|
9
9
|
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
-
|
|
10
|
+
// src/modules/mcp/resources/register.ts
|
|
11
11
|
/** A page an agent can read in one go: each change carries whole elements before and after. */
|
|
12
12
|
var CHANGES_PAGE = 20;
|
|
13
13
|
/** Register every resource on the MCP server: fixed listings plus templated per-item reads. The space is
|
|
@@ -288,5 +288,4 @@ var registerResources = (server, getSpace, env, log, hasSpace, readChanges) => {
|
|
|
288
288
|
mimeType: "application/json"
|
|
289
289
|
}, (uri) => emit(uri.href));
|
|
290
290
|
};
|
|
291
|
-
//#endregion
|
|
292
291
|
export { registerResources };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { elementCatalog } from "../catalogs/index.js";
|
|
2
1
|
import { envelope, jsonContents } from "./envelope.js";
|
|
2
|
+
import { elementCatalog } from "../catalogs/index.js";
|
|
3
3
|
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
4
|
import { STYLE_STATES } from "@plitzi/sdk-shared/style";
|
|
5
|
-
|
|
5
|
+
// src/modules/mcp/resources/renderGuide.ts
|
|
6
6
|
var RENDER_GUIDE_URI = "plitzi://render/guide";
|
|
7
7
|
var RENDER_TYPES_URI = "plitzi://render/types";
|
|
8
8
|
var RENDER_TYPE_CATEGORIES = /* @__PURE__ */ new Set([
|
|
@@ -577,5 +577,4 @@ var registerRenderResources = (server, log) => {
|
|
|
577
577
|
return contents;
|
|
578
578
|
});
|
|
579
579
|
};
|
|
580
|
-
//#endregion
|
|
581
580
|
export { RENDER_GUIDE_URI, RENDER_TYPES_URI, readRenderResource, registerRenderResources, renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { emptySpace } from "../helpers/space.js";
|
|
2
|
-
import "../helpers/uris.js";
|
|
3
1
|
import { readActionResource } from "./actions.js";
|
|
4
2
|
import { canonicalUri } from "./canonical.js";
|
|
5
3
|
import { readConnectorResource } from "./connectors.js";
|
|
@@ -10,7 +8,9 @@ import { readPrimerResource } from "./primer.js";
|
|
|
10
8
|
import { readRenderResource } from "./renderGuide.js";
|
|
11
9
|
import { readSchemaResource } from "./schema.js";
|
|
12
10
|
import { readStyleResource } from "./style.js";
|
|
13
|
-
|
|
11
|
+
import { emptySpace } from "../helpers/space.js";
|
|
12
|
+
import "../helpers/uris.js";
|
|
13
|
+
// src/modules/mcp/resources/router.ts
|
|
14
14
|
var resolvers = [
|
|
15
15
|
(space, _env, uri) => readCoreResource(space, uri),
|
|
16
16
|
(_space, _env, uri) => readRenderResource(uri),
|
|
@@ -41,5 +41,4 @@ var readPublicResource = (env, rawUri) => {
|
|
|
41
41
|
};
|
|
42
42
|
/** Current version of a resource, for optimistic-concurrency checks. Null when the URI is unknown. */
|
|
43
43
|
var resourceVersion = (space, env, uri) => readResource(space, env, uri)?.stateVersion ?? null;
|
|
44
|
-
//#endregion
|
|
45
44
|
export { readPublicResource, readResource, resourceVersion };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { afterPrefix, componentsUri, dataSourcesUri, elementUri, flagsUri, folderUri, foldersUri, interactionsUri, layoutsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../helpers/uris.js";
|
|
1
2
|
import { componentSummariesToAI, componentView, findComponentByRef } from "../helpers/components.js";
|
|
2
3
|
import { findElementByRef, findRootByRef } from "../helpers/space.js";
|
|
3
|
-
import { afterPrefix, componentsUri, dataSourcesUri, elementUri, flagsUri, folderUri, foldersUri, interactionsUri, layoutsUri, pageUri, pagesUri, schemaVarsUri, settingsUri } from "../helpers/uris.js";
|
|
4
|
-
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
5
4
|
import { envelope } from "./envelope.js";
|
|
5
|
+
import { buildDataSourceCatalog, buildInteractionCatalog } from "../catalogs/observed.js";
|
|
6
6
|
import { elementView, folderRefToAI, foldersToAI, layoutSummariesToAI, pageSkeletonToAI, pageStylesToAI, pageSummariesToAI, schemaVariablesToAI, settingsToAI } from "../tools/operations/schema/translator.js";
|
|
7
7
|
import { treeOf } from "@plitzi/sdk-schema";
|
|
8
|
-
|
|
8
|
+
// src/modules/mcp/resources/schema.ts
|
|
9
9
|
/** Element-schema reads: page listings/skeletons/styles, folders, single elements and schema variables. Returns
|
|
10
10
|
* undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
|
|
11
11
|
var readSchemaResource = (space, env, uri) => {
|
|
@@ -47,5 +47,4 @@ var readSchemaResource = (space, env, uri) => {
|
|
|
47
47
|
if (uri === interactionsUri(env)) return envelope(buildInteractionCatalog(space.schema));
|
|
48
48
|
if (uri === dataSourcesUri(env)) return envelope(buildDataSourceCatalog(space.schema));
|
|
49
49
|
};
|
|
50
|
-
//#endregion
|
|
51
50
|
export { readSchemaResource };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { afterPrefix, defUri, defsUri, fontUri, fontsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from "../helpers/uris.js";
|
|
2
1
|
import { envelope } from "./envelope.js";
|
|
2
|
+
import { afterPrefix, defUri, defsUri, fontUri, fontsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from "../helpers/uris.js";
|
|
3
3
|
import { definitionRefs, definitionToAI, fontsToAI, globalStyleToAI, globalStyleTypes, idStyleIds, idStyleToAI, styleVariablesToAI } from "../tools/operations/style/translator.js";
|
|
4
|
-
|
|
4
|
+
// src/modules/mcp/resources/style.ts
|
|
5
5
|
/** Style-schema reads: definitions, global (per-type) styles, design-token variables by category, and the fonts
|
|
6
6
|
* the space declares. Returns
|
|
7
7
|
* undefined when the URI belongs to another domain, null when the shape is ours but the ref does not resolve. */
|
|
@@ -37,5 +37,4 @@ var readStyleResource = (space, env, uri) => {
|
|
|
37
37
|
return envelope(Object.hasOwn(byCategory, category) ? byCategory[category] : []);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
//#endregion
|
|
41
40
|
export { readStyleResource };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { outlineOfTree } from "./accessibilityOutline.js";
|
|
2
|
-
import { PREVIEW_TOKEN_PARAM } from "@plitzi/sdk-
|
|
3
|
-
|
|
2
|
+
import { PREVIEW_TOKEN_PARAM } from "@plitzi/sdk-kernel/identity";
|
|
3
|
+
// src/modules/mcp/screenshotClient.ts
|
|
4
4
|
var composeUrl = (base, pagePath, token) => {
|
|
5
5
|
const url = new URL(pagePath, base);
|
|
6
6
|
if (token) url.searchParams.set(PREVIEW_TOKEN_PARAM, token);
|
|
@@ -24,7 +24,7 @@ var readRefusal = async (res) => {
|
|
|
24
24
|
/** Default `ScreenshotClient`: composes the navigable preview URL (renderBaseUrl + pagePath + `?__pt=token`) and
|
|
25
25
|
* POSTs it to the browser service. Any network/HTTP failure surfaces as `ok:false` so the tool can fall back to
|
|
26
26
|
* the HTML preview instead of hard-failing. */
|
|
27
|
-
var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch }) => ({ async capture({ pagePath, token, viewports, fullPage, colorScheme, views = ["image"] }) {
|
|
27
|
+
var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch }) => ({ async capture({ pagePath, token, viewports, fullPage, colorScheme, views = ["image"], format, quality }) {
|
|
28
28
|
const url = composeUrl(renderBaseUrl, pagePath, token);
|
|
29
29
|
let res;
|
|
30
30
|
try {
|
|
@@ -36,7 +36,9 @@ var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch
|
|
|
36
36
|
viewports,
|
|
37
37
|
fullPage,
|
|
38
38
|
colorScheme,
|
|
39
|
-
views
|
|
39
|
+
views,
|
|
40
|
+
format,
|
|
41
|
+
quality
|
|
40
42
|
})
|
|
41
43
|
});
|
|
42
44
|
} catch (err) {
|
|
@@ -76,5 +78,4 @@ var createHttpScreenshotClient = ({ serviceUrl, renderBaseUrl, fetchImpl = fetch
|
|
|
76
78
|
...accessibility ? { accessibility } : {}
|
|
77
79
|
};
|
|
78
80
|
} });
|
|
79
|
-
//#endregion
|
|
80
81
|
export { createHttpScreenshotClient };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { ResourceProxy } from './proxy';
|
|
3
3
|
import { PreviewClient, ScreenshotClient } from './types';
|
|
4
|
-
import { SSRAdapters, ServerLogger, SSRGrant } from '@plitzi/sdk-
|
|
4
|
+
import { SSRAdapters, ServerLogger, SSRGrant } from '@plitzi/sdk-kernel/types';
|
|
5
5
|
/** The MCP service is stateless: every request resolves its own `spaceId` (from the request JWT) and reads the
|
|
6
6
|
* space fresh through the adapters — schema and style are two documents, read/written independently. The spaceId
|
|
7
7
|
* is resolved once per request, up front, because it decides what this connection IS: with a space, the full
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { registerApps } from "./apps/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createMcpLog } from "./helpers/log.js";
|
|
3
3
|
import { NoSpaceError, ReadOnlyGrantError, emptySpace, emptySpaceMessage, noSpaceErrorCode, readOnlyGrantErrorCode } from "./helpers/space.js";
|
|
4
|
+
import { isCallToolResult } from "./helpers/callToolResult.js";
|
|
4
5
|
import { serverInstructions, widgetsOnlyInstructions } from "./helpers/guide/instructions.js";
|
|
5
|
-
import { createMcpLog } from "./helpers/log.js";
|
|
6
6
|
import { proxyForTool } from "./proxy/config.js";
|
|
7
7
|
import { registerResources } from "./resources/register.js";
|
|
8
8
|
import { tools } from "./tools/index.js";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import { registerAppTool } from "@modelcontextprotocol/ext-apps/server";
|
|
11
11
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
-
|
|
12
|
+
// src/modules/mcp/server.ts
|
|
13
13
|
var MCP_ENV = "main";
|
|
14
14
|
var asText = (data) => ({ content: [{
|
|
15
15
|
type: "text",
|
|
@@ -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.2"
|
|
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);
|
|
@@ -162,5 +162,4 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
|
|
|
162
162
|
}
|
|
163
163
|
return server;
|
|
164
164
|
};
|
|
165
|
-
//#endregion
|
|
166
165
|
export { createMcpServer };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineTool } from "./shared/tool.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { 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)}`),
|
|
@@ -32,5 +32,4 @@ var activityTool = defineTool({
|
|
|
32
32
|
documents: false,
|
|
33
33
|
run: (input, ctx) => activity(input, ctx)
|
|
34
34
|
});
|
|
35
|
-
//#endregion
|
|
36
35
|
export { activity, activityShape, activityTool };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { componentView, findComponentByRef } from "../../helpers/components.js";
|
|
2
|
-
import { pageUri } from "../../helpers/uris.js";
|
|
3
2
|
import { fail } from "../../helpers/opResult.js";
|
|
3
|
+
import { pageUri } from "../../helpers/uris.js";
|
|
4
4
|
import { deleteAction } from "../operations/actions/deleteAction.js";
|
|
5
5
|
import { patchAction } from "../operations/actions/patchAction.js";
|
|
6
6
|
import { upsertAction } from "../operations/actions/upsertAction.js";
|
|
7
7
|
import { deleteConnector } from "../operations/connectors/deleteConnector.js";
|
|
8
8
|
import { patchConnector } from "../operations/connectors/patchConnector.js";
|
|
9
9
|
import { upsertConnector } from "../operations/connectors/upsertConnector.js";
|
|
10
|
+
import { isStyleOp } from "../operations/index.js";
|
|
10
11
|
import { deleteDataFile, upsertDataFile } from "../operations/data/index.js";
|
|
11
|
-
import { deleteFunctionFile, upsertFunctionFile } from "../operations/functions/index.js";
|
|
12
12
|
import { deleteBinding } from "../operations/schema/bindings/deleteBinding.js";
|
|
13
13
|
import { patchBinding } from "../operations/schema/bindings/patchBinding.js";
|
|
14
14
|
import { upsertBinding } from "../operations/schema/bindings/upsertBinding.js";
|
|
@@ -46,8 +46,8 @@ import { patchIdStyle } from "../operations/style/idStyles/patchIdStyle.js";
|
|
|
46
46
|
import { upsertIdStyle } from "../operations/style/idStyles/upsertIdStyle.js";
|
|
47
47
|
import { deleteStyleVariable } from "../operations/style/variables/deleteStyleVariable.js";
|
|
48
48
|
import { upsertStyleVariable } from "../operations/style/variables/upsertStyleVariable.js";
|
|
49
|
-
import {
|
|
50
|
-
|
|
49
|
+
import { deleteFunctionFile, upsertFunctionFile } from "../operations/functions/index.js";
|
|
50
|
+
// src/modules/mcp/tools/apply/dispatch.ts
|
|
51
51
|
var isRooted = (op) => "pageRef" in op;
|
|
52
52
|
/**
|
|
53
53
|
* An element op names its root with `pageRef`, and a component is one: the op runs on the component's tree as if it
|
|
@@ -198,5 +198,4 @@ var applyOperations = (space, env, ops) => {
|
|
|
198
198
|
outcome.deletedActions = Array.from(droppedActions);
|
|
199
199
|
return outcome;
|
|
200
200
|
};
|
|
201
|
-
//#endregion
|
|
202
201
|
export { applyOperations };
|
|
@@ -257,6 +257,7 @@ export declare const applyShape: {
|
|
|
257
257
|
transientState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
258
258
|
keptState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
259
259
|
paintedState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
260
|
+
browserState: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
260
261
|
userProvider: z.ZodOptional<z.ZodString>;
|
|
261
262
|
tokenStorage: z.ZodOptional<z.ZodEnum<{
|
|
262
263
|
"": "";
|
|
@@ -1663,6 +1664,8 @@ export declare const applyShape: {
|
|
|
1663
1664
|
streamTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1664
1665
|
maxNodes: z.ZodOptional<z.ZodNumber>;
|
|
1665
1666
|
maxRequests: z.ZodOptional<z.ZodNumber>;
|
|
1667
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
1668
|
+
maxRunBytes: z.ZodOptional<z.ZodNumber>;
|
|
1666
1669
|
}, z.core.$strip>>;
|
|
1667
1670
|
}, z.core.$strict>, z.ZodObject<{
|
|
1668
1671
|
type: z.ZodLiteral<"patchAction">;
|
|
@@ -1705,6 +1708,8 @@ export declare const applyShape: {
|
|
|
1705
1708
|
streamTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1706
1709
|
maxNodes: z.ZodOptional<z.ZodNumber>;
|
|
1707
1710
|
maxRequests: z.ZodOptional<z.ZodNumber>;
|
|
1711
|
+
maxResponseBytes: z.ZodOptional<z.ZodNumber>;
|
|
1712
|
+
maxRunBytes: z.ZodOptional<z.ZodNumber>;
|
|
1708
1713
|
}, z.core.$strip>>;
|
|
1709
1714
|
}, z.core.$strict>, z.ZodObject<{
|
|
1710
1715
|
type: z.ZodLiteral<"deleteAction">;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { dataFileUri, dataUri, functionFileUri, functionsUri } from "../../helpers/uris.js";
|
|
2
|
-
import { defineTool, imageResult } from "../shared/tool.js";
|
|
3
1
|
import { changedResources, conflictMessage, detectConflicts, resolvedElements } from "./writeResult.js";
|
|
2
|
+
import { dataFileUri, dataUri, functionFileUri, functionsUri } from "../../helpers/uris.js";
|
|
4
3
|
import { environment, operations } from "../operations/index.js";
|
|
5
4
|
import { draftBatch } from "../shared/draftBatch.js";
|
|
6
5
|
import { effectsOf } from "../shared/effects.js";
|
|
7
6
|
import { fullPage, lookAt, pageRef, viewport } from "../shared/look.js";
|
|
8
7
|
import { AGAIN, REPEATED, batchKey, forgetRefused, noteRefused, timesRefused } from "../shared/repeats.js";
|
|
8
|
+
import { defineTool, imageResult } from "../shared/tool.js";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
import { generateCache } from "@plitzi/sdk-style";
|
|
11
|
-
|
|
11
|
+
// src/modules/mcp/tools/apply/index.ts
|
|
12
12
|
var applyShape = {
|
|
13
13
|
environment,
|
|
14
14
|
dryRun: z.boolean().optional().describe("Validate and apply in memory only, WITHOUT persisting. Returns the same result (changed versions + full element detail) so you can inspect the outcome and decide on more changes before committing for real."),
|
|
@@ -210,5 +210,4 @@ var applyTool = defineTool({
|
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
|
-
//#endregion
|
|
214
213
|
export { NOTHING_CHANGED, apply, applyShape, applyTool };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { elementUri } from "../../helpers/uris.js";
|
|
2
2
|
import { readResource, resourceVersion } from "../../resources/router.js";
|
|
3
|
-
|
|
3
|
+
// src/modules/mcp/tools/apply/writeResult.ts
|
|
4
4
|
var detectConflicts = (space, env, expected) => {
|
|
5
5
|
if (!expected) return [];
|
|
6
6
|
const conflicts = [];
|
|
@@ -33,5 +33,4 @@ var resolvedElements = (space, env, refs) => {
|
|
|
33
33
|
return elements.length > 0 ? elements : void 0;
|
|
34
34
|
};
|
|
35
35
|
var conflictMessage = "Cannot apply: your data is stale. Re-read the changed resources and retry.";
|
|
36
|
-
//#endregion
|
|
37
36
|
export { changedResources, conflictMessage, detectConflicts, resolvedElements };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineTool } from "./shared/tool.js";
|
|
2
1
|
import { OPERATIONS_BY_TYPE } from "./operations/index.js";
|
|
2
|
+
import { defineTool } from "./shared/tool.js";
|
|
3
3
|
import { closest } from "@plitzi/sdk-authoring";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
|
|
5
|
+
// src/modules/mcp/tools/describeOperation.ts
|
|
6
6
|
var describeOperationShape = { type: z.string().optional().describe("The operation type, as in a batch: \"upsertElement\", \"patchDefinition\"… Left out, every type is listed.") };
|
|
7
7
|
/**
|
|
8
8
|
* One operation's schema, by its type — the low level asked for one piece at a time, so a connection does not have to
|
|
@@ -36,5 +36,4 @@ var describeOperationTool = defineTool({
|
|
|
36
36
|
spaceless: true,
|
|
37
37
|
run: (input) => describeOperation(input.type)
|
|
38
38
|
});
|
|
39
|
-
//#endregion
|
|
40
39
|
export { describeOperation, describeOperationShape, describeOperationTool };
|
|
@@ -10,7 +10,7 @@ import { renderTool } from "./render.js";
|
|
|
10
10
|
import { search, searchShape, searchTool } from "./search.js";
|
|
11
11
|
import { testTool } from "./test.js";
|
|
12
12
|
import { tryFunctionTool } from "./tryFunction.js";
|
|
13
|
-
|
|
13
|
+
// src/modules/mcp/tools/index.ts
|
|
14
14
|
/** The MCP tool registry — the single source the server registers from. Adding a tool is: create its file with a
|
|
15
15
|
* ToolDef descriptor and append it here. */
|
|
16
16
|
var tools = [
|
|
@@ -29,5 +29,4 @@ var tools = [
|
|
|
29
29
|
testTool,
|
|
30
30
|
activityTool
|
|
31
31
|
];
|
|
32
|
-
//#endregion
|
|
33
32
|
export { apply, applyShape, operation, read, readShape, search, searchShape, tools };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { apply } from "./apply/index.js";
|
|
1
2
|
import { findElementByRef } from "../helpers/space.js";
|
|
2
|
-
import { defineTool } from "./shared/tool.js";
|
|
3
3
|
import { scalar } from "./operations/schema/shared.js";
|
|
4
|
-
import {
|
|
4
|
+
import { defineTool } from "./shared/tool.js";
|
|
5
5
|
import { closest } from "@plitzi/sdk-authoring";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
|
|
7
|
+
// src/modules/mcp/tools/intents.ts
|
|
8
8
|
/** The element a ref names, with the page or layout it is on — or the nearest ref there is. */
|
|
9
9
|
var locate = (ctx, ref) => {
|
|
10
10
|
const element = findElementByRef(ctx.space.schema, ref);
|
|
@@ -197,5 +197,4 @@ var addPageTool = defineTool({
|
|
|
197
197
|
...input.layout ? { layout: input.layout } : {}
|
|
198
198
|
}], input.ref)
|
|
199
199
|
});
|
|
200
|
-
//#endregion
|
|
201
200
|
export { addPageTool, bindAttributeTool, placeComponentTool, setAttributesTool, setClassesTool };
|