@plitzi/sdk-mcp 0.33.2 → 0.34.1
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 +77 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/modules/mcp/catalogs/index.d.ts +2 -7
- package/dist/modules/mcp/catalogs/index.js +4 -0
- package/dist/modules/mcp/catalogs/observed.d.ts +1 -1
- package/dist/modules/mcp/catalogs/observed.js +2 -5
- package/dist/modules/mcp/catalogs/pluginCatalog.d.ts +17 -0
- package/dist/modules/mcp/catalogs/pluginCatalog.js +91 -0
- package/dist/modules/mcp/catalogs/registry.js +2 -3
- package/dist/modules/mcp/helpers/agentPrompt.js +9 -9
- package/dist/modules/mcp/helpers/guide.d.ts +2 -2
- package/dist/modules/mcp/helpers/guide.js +117 -50
- package/dist/modules/mcp/helpers/interactions.d.ts +5 -1
- package/dist/modules/mcp/helpers/interactions.js +15 -6
- package/dist/modules/mcp/helpers/space.d.ts +45 -28
- package/dist/modules/mcp/helpers/space.js +87 -87
- package/dist/modules/mcp/helpers/uris.d.ts +9 -0
- package/dist/modules/mcp/helpers/uris.js +10 -1
- package/dist/modules/mcp/index.d.ts +2 -0
- package/dist/modules/mcp/localScreenshotClient.d.ts +51 -0
- package/dist/modules/mcp/localScreenshotClient.js +106 -0
- package/dist/modules/mcp/proxy/rewrite.js +15 -1
- package/dist/modules/mcp/resources/actions.d.ts +25 -0
- package/dist/modules/mcp/resources/actions.js +54 -0
- package/dist/modules/mcp/resources/canonical.d.ts +1 -1
- package/dist/modules/mcp/resources/canonical.js +1 -1
- package/dist/modules/mcp/resources/connectors.d.ts +1 -1
- package/dist/modules/mcp/resources/core.js +1 -1
- package/dist/modules/mcp/resources/index.d.ts +1 -0
- package/dist/modules/mcp/resources/primer.d.ts +8 -1
- package/dist/modules/mcp/resources/primer.js +139 -15
- package/dist/modules/mcp/resources/register.js +24 -4
- package/dist/modules/mcp/resources/renderGuide.js +66 -14
- package/dist/modules/mcp/resources/router.js +3 -1
- package/dist/modules/mcp/resources/schema.js +6 -5
- package/dist/modules/mcp/resources/style.d.ts +2 -1
- package/dist/modules/mcp/resources/style.js +10 -3
- package/dist/modules/mcp/screenshotClient.js +3 -2
- package/dist/modules/mcp/server.js +12 -6
- package/dist/modules/mcp/tests/agentRoundtrip.test.d.ts +1 -0
- package/dist/modules/mcp/tests/layouts.test.d.ts +1 -0
- package/dist/modules/mcp/tools/apply/dispatch.js +30 -1
- package/dist/modules/mcp/tools/apply/index.d.ts +149 -15
- package/dist/modules/mcp/tools/apply/index.js +12 -2
- package/dist/modules/mcp/tools/operations/actions/actions.test.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/actions/deleteAction.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/actions/deleteAction.js +20 -0
- package/dist/modules/mcp/tools/operations/actions/document.d.ts +69 -0
- package/dist/modules/mcp/tools/operations/actions/document.js +73 -0
- package/dist/modules/mcp/tools/operations/actions/index.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/actions/index.js +12 -0
- package/dist/modules/mcp/tools/operations/actions/patchAction.d.ts +45 -0
- package/dist/modules/mcp/tools/operations/actions/patchAction.js +71 -0
- package/dist/modules/mcp/tools/operations/actions/upsertAction.d.ts +47 -0
- package/dist/modules/mcp/tools/operations/actions/upsertAction.js +83 -0
- package/dist/modules/mcp/tools/operations/connectors/index.d.ts +10 -10
- package/dist/modules/mcp/tools/operations/connectors/manifest.d.ts +5 -5
- package/dist/modules/mcp/tools/operations/connectors/patchConnector.d.ts +5 -5
- package/dist/modules/mcp/tools/operations/connectors/upsertConnector.d.ts +5 -5
- package/dist/modules/mcp/tools/operations/index.d.ts +415 -40
- package/dist/modules/mcp/tools/operations/index.js +11 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +5 -5
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +6 -6
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +11 -12
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/index.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +4 -4
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +28 -5
- package/dist/modules/mcp/tools/operations/schema/operations.js +4 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deleteLayout.js +33 -0
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +1 -1
- package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.d.ts +22 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertLayout.js +61 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +53 -18
- package/dist/modules/mcp/tools/operations/schema/shared.d.ts +5 -1
- package/dist/modules/mcp/tools/operations/schema/shared.js +2 -2
- package/dist/modules/mcp/tools/operations/schema/translator.d.ts +2 -1
- package/dist/modules/mcp/tools/operations/schema/translator.js +21 -9
- package/dist/modules/mcp/tools/operations/schema/write.d.ts +9 -22
- package/dist/modules/mcp/tools/operations/schema/write.js +23 -43
- package/dist/modules/mcp/tools/operations/schemaIds.js +7 -1
- package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.d.ts +9 -0
- package/dist/modules/mcp/tools/operations/style/fonts/deleteFont.js +21 -0
- package/dist/modules/mcp/tools/operations/style/fonts/fonts.test.d.ts +1 -0
- package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.d.ts +35 -0
- package/dist/modules/mcp/tools/operations/style/fonts/upsertFont.js +66 -0
- package/dist/modules/mcp/tools/operations/style/index.d.ts +2 -0
- package/dist/modules/mcp/tools/operations/style/operations.d.ts +34 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +5 -1
- package/dist/modules/mcp/tools/operations/style/translator.d.ts +13 -1
- package/dist/modules/mcp/tools/operations/style/translator.js +18 -1
- package/dist/modules/mcp/tools/operations/style/write.js +1 -1
- package/dist/modules/mcp/tools/preview.d.ts +58 -5
- package/dist/modules/mcp/tools/preview.js +1 -1
- package/dist/modules/mcp/tools/render.d.ts +61 -5
- package/dist/modules/mcp/tools/render.js +10 -3
- package/dist/modules/mcp/tools/screenshot.d.ts +151 -16
- package/dist/modules/mcp/tools/screenshot.js +22 -13
- package/dist/modules/mcp/tools/search.js +3 -3
- package/dist/modules/mcp/tools/shared/interactionReport.d.ts +7 -0
- package/dist/modules/mcp/tools/shared/interactionReport.js +48 -0
- package/dist/modules/mcp/tools/shared/validator/audit.js +4 -4
- package/dist/modules/mcp/tools/shared/validator/batch.d.ts +1 -0
- package/dist/modules/mcp/tools/shared/validator/batch.js +11 -2
- package/dist/modules/mcp/tools/shared/validator/bindings.js +6 -6
- package/dist/modules/mcp/tools/shared/validator/connectors.js +1 -1
- package/dist/modules/mcp/tools/shared/validator/context.d.ts +3 -0
- package/dist/modules/mcp/tools/shared/validator/css.js +1 -1
- package/dist/modules/mcp/tools/shared/validator/index.js +29 -9
- package/dist/modules/mcp/tools/shared/validator/interactions.js +41 -7
- package/dist/modules/mcp/tools/shared/validator/refs.js +4 -4
- package/dist/modules/mcp/tools/validate.d.ts +149 -15
- package/dist/modules/mcp/types/aiSchema.d.ts +33 -4
- package/dist/modules/mcp/types/previewTypes.d.ts +19 -0
- package/dist/modules/mcp/types/screenshotTypes.d.ts +1 -0
- package/dist/modules/mcp/types/toolTypes.d.ts +6 -1
- package/dist/pipeline.js +1 -1
- package/dist/preview/createPreview.d.ts +4 -2
- package/dist/preview/createPreview.js +16 -6
- package/dist/server.d.ts +3 -0
- package/dist/server.js +3 -1
- package/dist/stages/preview.js +20 -1
- package/dist/tests/httpRequest.d.ts +2 -0
- package/package.json +20 -16
- package/skills/plitzi-render/SKILL.md +84 -11
- package/dist/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -19
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -139
- package/dist/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
- package/dist/modules/mcp/catalogs/builtinComponents.js +0 -165
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -17
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
- package/dist/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
- package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
- package/dist/modules/mcp/catalogs/builtinUtilities.d.ts +0 -15
- package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
- package/dist/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
- package/dist/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
- package/dist/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -18
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
- package/dist/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -99
- package/dist/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -147
- package/dist/modules/mcp/catalogs/paramSpec.d.ts +0 -39
- package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
- package/dist/modules/oauth/authorize.d.ts +0 -7
- package/dist/modules/oauth/authorize.js +0 -177
- package/dist/modules/oauth/challenge.d.ts +0 -11
- package/dist/modules/oauth/challenge.js +0 -33
- package/dist/modules/oauth/consentPage.d.ts +0 -7
- package/dist/modules/oauth/consentPage.js +0 -118
- package/dist/modules/oauth/metadata.d.ts +0 -40
- package/dist/modules/oauth/metadata.js +0 -69
- package/dist/modules/oauth/params.d.ts +0 -5
- package/dist/modules/oauth/params.js +0 -5
- package/dist/modules/oauth/pkce.d.ts +0 -6
- package/dist/modules/oauth/pkce.js +0 -15
- package/dist/modules/oauth/records.d.ts +0 -71
- package/dist/modules/oauth/records.js +0 -46
- package/dist/modules/oauth/register.d.ts +0 -5
- package/dist/modules/oauth/register.js +0 -55
- package/dist/modules/oauth/respond.d.ts +0 -13
- package/dist/modules/oauth/respond.js +0 -44
- package/dist/modules/oauth/token.d.ts +0 -5
- package/dist/modules/oauth/token.js +0 -100
- package/dist/stages/oauth.d.ts +0 -19
- package/dist/stages/oauth.js +0 -114
- /package/dist/modules/mcp/catalogs/{builtinTransformers.test.d.ts → pluginCatalog.test.d.ts} +0 -0
- /package/dist/modules/mcp/{catalogs/cssCatalog/cssCatalog.test.d.ts → localScreenshotClient.test.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,82 @@
|
|
|
1
1
|
# @plitzi/sdk-mcp
|
|
2
2
|
|
|
3
|
+
## 0.34.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- v0.34.1
|
|
8
|
+
- Updated dependencies [cba7b8b]
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @plitzi/plitzi-sdk@0.34.1
|
|
11
|
+
- @plitzi/sdk-elements@0.34.1
|
|
12
|
+
- @plitzi/sdk-interactions@0.34.1
|
|
13
|
+
- @plitzi/sdk-schema@0.34.1
|
|
14
|
+
- @plitzi/sdk-server@0.34.1
|
|
15
|
+
- @plitzi/sdk-shared@0.34.1
|
|
16
|
+
- @plitzi/sdk-style@0.34.1
|
|
17
|
+
|
|
18
|
+
## 0.34.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- v0.34.0
|
|
23
|
+
- 5aceda0: Draft previews you can iterate against, and a `DraftStore` contract that says so.
|
|
24
|
+
|
|
25
|
+
A preview token was one-shot: spent by the render that used it. That is right for a capture and wrong for a
|
|
26
|
+
person — reloading showed the saved space again, so "look at the change, adjust it, look again" meant minting a
|
|
27
|
+
new token for every look. `POST /__preview` now takes `mode: 'session'`, which mints a token that stays
|
|
28
|
+
resolvable until it expires (`preview.sessionTtlMs`, 15 minutes by default) or until `POST /__preview/end` ends
|
|
29
|
+
it. The token is remembered in an `HttpOnly` cookie on the first render, so the draft follows a navigation —
|
|
30
|
+
the page after a link carries no query parameter.
|
|
31
|
+
|
|
32
|
+
A draft render, either mode, is never cached, never metered and answers `Cache-Control: no-store` plus
|
|
33
|
+
`X-Robots-Tag: noindex`. Data refreshes (`/_rsc`) made from inside a session are excluded from metering and
|
|
34
|
+
caching too — without that, an open preview tab would be billed as live traffic.
|
|
35
|
+
|
|
36
|
+
**Breaking, for anyone who implements `DraftStore`** (a shared store for a multi-replica deployment). The
|
|
37
|
+
default in-memory store is unaffected; a custom one needs three changes:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// before
|
|
41
|
+
put(token, data, ttlMs)
|
|
42
|
+
take(token): OfflineDataRaw | undefined
|
|
43
|
+
|
|
44
|
+
// after
|
|
45
|
+
put(token, data, { ttlMs, reusable }) // `reusable` is a session; absent is one-shot
|
|
46
|
+
take(token): { data, reusable } | undefined // consume unless reusable — and say which it was
|
|
47
|
+
drop(token) // end a session before its TTL
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`take` reports which kind it resolved because the render that resolves a session is the one that has to remember
|
|
51
|
+
it for the rest of the visit, and only the store knows whether the token survived the read.
|
|
52
|
+
|
|
53
|
+
- 5aceda0: Capture a page without standing up a browser service.
|
|
54
|
+
|
|
55
|
+
`createHttpScreenshotClient` talks to a dedicated browser pod, which is the right answer in a cluster and the
|
|
56
|
+
wrong one everywhere else: somebody self-hosting had to deploy a second service before they could look at
|
|
57
|
+
anything. `createLocalScreenshotClient` resolves a browser at run time from whatever the host already has —
|
|
58
|
+
Playwright, then Puppeteer — and returns `undefined` when it has neither, so a caller can decide once not to
|
|
59
|
+
offer the tool rather than fail on every call.
|
|
60
|
+
|
|
61
|
+
Nothing is added to this package's dependency tree and nothing is imported until the client is asked for. It
|
|
62
|
+
implements the same `ScreenshotClient` interface as the HTTP one, so the two are interchangeable at the call
|
|
63
|
+
site, and it grows the window to the SDK's inner scroller before it shoots — which is the difference between a
|
|
64
|
+
whole page and one viewport of it.
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Updated dependencies [5aceda0]
|
|
69
|
+
- Updated dependencies
|
|
70
|
+
- Updated dependencies [5aceda0]
|
|
71
|
+
- Updated dependencies [9c3292c]
|
|
72
|
+
- @plitzi/sdk-shared@0.34.0
|
|
73
|
+
- @plitzi/sdk-elements@0.34.0
|
|
74
|
+
- @plitzi/plitzi-sdk@0.34.0
|
|
75
|
+
- @plitzi/sdk-interactions@0.34.0
|
|
76
|
+
- @plitzi/sdk-schema@0.34.0
|
|
77
|
+
- @plitzi/sdk-server@0.34.0
|
|
78
|
+
- @plitzi/sdk-style@0.34.0
|
|
79
|
+
|
|
3
80
|
## 0.33.2
|
|
4
81
|
|
|
5
82
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
export { createServer } from './createServer';
|
|
7
7
|
export { buildMCPPipeline, mcpExtensions } from './pipeline';
|
|
8
8
|
export { createMcpOnlyStage, createMcpStage } from './stages/mcp';
|
|
9
|
-
export { createOAuthGuardStage, createOAuthStage } from '
|
|
9
|
+
export { createOAuthGuardStage, createOAuthStage } from '@plitzi/sdk-server/oauth';
|
|
10
10
|
export { previewStage } from './stages/preview';
|
|
11
11
|
export { createWidgetProxyStage } from './stages/proxy';
|
|
12
12
|
export { createPreview } from './preview/createPreview';
|
|
13
13
|
export { AIEngine, toolResponseOk, toolResponseErr, zodToJsonSchema, getAllowedModes, bindTools, isToolActive, resolveToolHandler, isCallToolResult, toolResponseFromResult } from './modules/ai';
|
|
14
|
-
export { createMcpServer, handleMcp, serveMcp, readMcpBody, buildAgentGuide, createHttpPreviewClient, createHttpScreenshotClient } from './modules/mcp';
|
|
14
|
+
export { createMcpServer, handleMcp, serveMcp, readMcpBody, buildAgentGuide, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, resolveLocalBrowser } from './modules/mcp';
|
|
15
15
|
export { apply, search, read, validate, applyShape, searchShape, readShape, validateShape, operation, tools } from './modules/mcp/tools';
|
|
16
16
|
export type { McpServerContext, McpRequestOptions, PreviewClient, PreviewRequestBody, PreviewResult, HttpPreviewClientConfig, ScreenshotClient, ScreenshotImage, ScreenshotResult, Viewport, HttpScreenshotClientConfig } from './modules/mcp';
|
|
17
17
|
export type { ApplyInput, SearchInput, SearchResponse, SearchHit, ReadInput, ReadResponse, ReadHit, ValidateInput, WriteResponse, WriteElement, Persisters, Operation, ToolDef, ToolContext } from './modules/mcp/tools';
|
package/dist/index.js
CHANGED
|
@@ -11,11 +11,12 @@ import { handleMcp, readMcpBody, serveMcp } from "./modules/mcp/handler.js";
|
|
|
11
11
|
import { createHttpPreviewClient } from "./modules/mcp/previewClient.js";
|
|
12
12
|
import { createHttpScreenshotClient } from "./modules/mcp/screenshotClient.js";
|
|
13
13
|
import { createMcpOnlyStage, createMcpStage } from "./stages/mcp.js";
|
|
14
|
-
import { createOAuthGuardStage, createOAuthStage } from "./stages/oauth.js";
|
|
15
14
|
import { createPreview } from "./preview/createPreview.js";
|
|
16
15
|
import { previewStage } from "./stages/preview.js";
|
|
17
16
|
import { createWidgetProxyStage } from "./stages/proxy.js";
|
|
18
17
|
import { buildMCPPipeline, mcpExtensions } from "./pipeline.js";
|
|
19
18
|
import { createServer } from "./createServer.js";
|
|
20
19
|
import AIEngine from "./modules/ai/AIEngine.js";
|
|
21
|
-
|
|
20
|
+
import { createLocalScreenshotClient, resolveLocalBrowser } from "./modules/mcp/localScreenshotClient.js";
|
|
21
|
+
import { createOAuthGuardStage, createOAuthStage } from "@plitzi/sdk-server/oauth";
|
|
22
|
+
export { AIEngine, apply, applyShape, bindTools, buildAgentGuide, buildMCPPipeline, createHttpPreviewClient, createHttpScreenshotClient, createLocalScreenshotClient, createMcpOnlyStage, createMcpServer, createMcpStage, createOAuthGuardStage, createOAuthStage, createPreview, createServer, createWidgetProxyStage, getAllowedModes, handleMcp, isCallToolResult, isToolActive, mcpExtensions, operation, previewStage, read, readMcpBody, readShape, resolveLocalBrowser, resolveToolHandler, search, searchShape, serveMcp, toolResponseErr, toolResponseFromResult, toolResponseOk, tools, validate, validateShape, zodToJsonSchema };
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export * from './builtinElementCallbacks';
|
|
4
|
-
export * from './builtinUtilities';
|
|
5
|
-
export * from './builtinTransformers';
|
|
6
|
-
export * from './builtinComponents';
|
|
7
|
-
export * from './cssCatalog';
|
|
1
|
+
export { BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS, BUILTIN_TRANSFORMERS, BUILTIN_UTILITIES, applyBuiltinCallback, applyElementCallback, applyUtility, cssProperties, cssShorthands, elementCatalog, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getTransformer, getUtility, hiddenParams, invalidParams, isCssProperty, missingRequiredParams, reconcileParams, shorthandLonghands, suggestCssProperty, suggestTransformer, transformerCatalog } from '@plitzi/sdk-authoring';
|
|
2
|
+
export type { BuiltinElementCallback, BuiltinGlobalCallback, BuiltinParam, BuiltinParamType, BuiltinTransformer, BuiltinUtility, CssPatch, ElementSemantics, InvalidParam, ParamSpec, TransformerInfo } from '@plitzi/sdk-authoring';
|
|
8
3
|
export * from './observed';
|
|
9
4
|
export * from './registry';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { buildDataSourceCatalog, buildInteractionCatalog, observedDataSources, observedInteractionActions } from "./observed.js";
|
|
2
|
+
import { buildTypeRegistry } from "./registry.js";
|
|
3
|
+
import { BUILTIN_ELEMENT_CALLBACKS as BUILTIN_ELEMENT_CALLBACKS$1, BUILTIN_GLOBAL_CALLBACKS as BUILTIN_GLOBAL_CALLBACKS$1, BUILTIN_UTILITIES as BUILTIN_UTILITIES$1, applyBuiltinCallback, applyElementCallback, applyUtility, cssProperties as cssProperties$1, cssShorthands, elementCatalog as elementCatalog$1, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getTransformer, getUtility, hiddenParams, invalidParams, isCssProperty, missingRequiredParams, reconcileParams, suggestCssProperty, suggestTransformer } from "@plitzi/sdk-authoring";
|
|
4
|
+
export { BUILTIN_ELEMENT_CALLBACKS$1 as BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS$1 as BUILTIN_GLOBAL_CALLBACKS, BUILTIN_UTILITIES$1 as BUILTIN_UTILITIES, applyBuiltinCallback, applyElementCallback, applyUtility, buildDataSourceCatalog, buildInteractionCatalog, buildTypeRegistry, cssProperties$1 as cssProperties, cssShorthands, elementCatalog$1 as elementCatalog, elementTypeNames, expandShorthand, expandShorthandPatch, getElementCallback, getGlobalCallback, getTransformer, getUtility, hiddenParams, invalidParams, isCssProperty, missingRequiredParams, observedDataSources, observedInteractionActions, reconcileParams, suggestCssProperty, suggestTransformer };
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { BUILTIN_GLOBAL_CALLBACKS } from "
|
|
2
|
-
import { BUILTIN_ELEMENT_CALLBACKS } from "./builtinElementCallbacks.js";
|
|
3
|
-
import { BUILTIN_UTILITIES } from "./builtinUtilities.js";
|
|
4
|
-
import { transformerCatalog } from "./builtinTransformers.js";
|
|
1
|
+
import { BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS, BUILTIN_UTILITIES, transformerCatalog } from "@plitzi/sdk-authoring";
|
|
5
2
|
//#region src/modules/mcp/catalogs/observed.ts
|
|
6
3
|
var INTERACTION_NOTE = "Interaction actions observed on this space, grouped by node type. A flow is a trigger followed by ordered callbacks/utilities; write one with upsertInteractionFlow. Names not listed may still be valid plugin actions.";
|
|
7
4
|
var GLOBAL_CALLBACKS_NOTE = "Built-in global callbacks always available in every space. A globalCallback is registered on its SOURCE MODULE, so its node `elementId` is the listed `source` (e.g. \"space\" for addNotification) — NOT the element that hosts the flow. Omit `elementId` and the MCP sets the right source and fills the param defaults for you. Use ONLY the params listed under each callback (with the exact spelling shown) — for addNotification the visible text goes in `content`; there is no title/message/type param. When strictParams is true, any other key is rejected.";
|
|
@@ -35,7 +32,7 @@ var builtinUtilities = () => Object.entries(BUILTIN_UTILITIES).map(([action, { t
|
|
|
35
32
|
params: toParamInfo(params)
|
|
36
33
|
}));
|
|
37
34
|
var DATA_SOURCE_NOTE = "Data-source paths and binding targets observed on this space. Bind a source to an element field with upsertBinding (category attributes|style|initialState). Paths not listed may still be valid. A binding may post-process its value through `transformers` (see below) and be gated by a `when` QueryBuilder guard.";
|
|
38
|
-
var DATA_SOURCE_SCOPE_NOTE = "SCOPE: an element source named `<type>_<
|
|
35
|
+
var DATA_SOURCE_SCOPE_NOTE = "SCOPE: an element source named `<type>_<id>` (e.g. `apiContainer_products`, `list_food-list`) is provided by that element to its DESCENDANTS ONLY — the provider wraps its subtree in the source’s scope, so only elements INSIDE the provider can bind to it. Binding a sibling or unrelated element to it is schema-valid but broken at runtime (the source is not in scope), and validate/apply REJECT it as an error. To consume `apiContainer_x.data`, the bound element must live under that apiContainer. Module sources (no `<type>_<id>` head — e.g. state/space/navigation/auth/collection) are global and bindable anywhere.";
|
|
39
36
|
var TRANSFORMERS_NOTE = "Built-in transformers that post-process a binding value before it reaches the field: `source → t₁ → t₂ → field`. Set them on a binding as `transformers: [{ action, params }]` (params are strings). The runtime resolves each by its `action` alone, so an UNKNOWN action is silently skipped (the value passes through unchanged) — use the exact action names below. Common formatting is `twigTemplate` (the value is the {{source}} token, not {{value}}).";
|
|
40
37
|
var buildInteractionCatalog = (schema) => {
|
|
41
38
|
const actions = {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentCatalog } from '@plitzi/sdk-shared';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps only string css declarations from a `base.default` block — dropping nested states and variants, and any
|
|
4
|
+
* non-scalar value — so the catalog carries a flat `prop: value` map an agent can read as the element's starting
|
|
5
|
+
* styles.
|
|
6
|
+
*/
|
|
7
|
+
export declare const stringDeclarations: (block: Record<string, unknown> | undefined) => Record<string, string> | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Builds the plugin half of a component catalog from a space's installed plugins, keyed by schema `type`.
|
|
10
|
+
*
|
|
11
|
+
* A plugin whose manifest cannot be read yields `{ custom: true }` with no metadata rather than failing the whole
|
|
12
|
+
* catalog — the agent then sees the type exists but learns nothing more about it, which is strictly better than
|
|
13
|
+
* being told the space has no plugins at all.
|
|
14
|
+
*/
|
|
15
|
+
export declare const pluginCatalog: (plugins: Record<string, {
|
|
16
|
+
resource: string;
|
|
17
|
+
}> | undefined) => Promise<ComponentCatalog>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region src/modules/mcp/catalogs/pluginCatalog.ts
|
|
2
|
+
/**
|
|
3
|
+
* The catalog entries for a space's PLUGIN (custom) element types, read from each plugin's published manifest.
|
|
4
|
+
*
|
|
5
|
+
* All of this was consumer code, in every deployment that served plugins: fetch `<resource>/plugin-manifest.json`,
|
|
6
|
+
* cache it, then walk the manifest into a `ComponentCatalogEntry`. None of it is a deployment's own knowledge —
|
|
7
|
+
* `PluginManifest` and `ComponentCatalogEntry` are both shared types and the mapping between them has one right
|
|
8
|
+
* answer, which is what makes it this package's. What a deployment knows, and all it now supplies, is which plugins
|
|
9
|
+
* the space has.
|
|
10
|
+
*
|
|
11
|
+
* The BUILT-IN types are not here: their structural half (attributes, style selectors, default styles) comes from
|
|
12
|
+
* `@plitzi/sdk-elements`, which this package deliberately does not depend on — a React element library is the
|
|
13
|
+
* heaviest possible import for a server that renders nothing. Deployments merge those in themselves; the curated
|
|
14
|
+
* semantics for them live in `builtinComponents.ts`.
|
|
15
|
+
*/
|
|
16
|
+
var MANIFEST_TTL_MS = 6e5;
|
|
17
|
+
var manifestCache = /* @__PURE__ */ new Map();
|
|
18
|
+
var fetchManifest = async (resource) => {
|
|
19
|
+
const cached = manifestCache.get(resource);
|
|
20
|
+
if (cached && cached.expiresAt > Date.now()) return cached.manifest;
|
|
21
|
+
let manifest = null;
|
|
22
|
+
try {
|
|
23
|
+
const res = await fetch(`${resource}/plugin-manifest.json`);
|
|
24
|
+
if (res.ok) manifest = await res.json();
|
|
25
|
+
} catch {
|
|
26
|
+
manifest = null;
|
|
27
|
+
}
|
|
28
|
+
manifestCache.set(resource, {
|
|
29
|
+
manifest,
|
|
30
|
+
expiresAt: Date.now() + MANIFEST_TTL_MS
|
|
31
|
+
});
|
|
32
|
+
return manifest;
|
|
33
|
+
};
|
|
34
|
+
var strOrUndefined = (value) => typeof value === "string" && value !== "" ? value : void 0;
|
|
35
|
+
var keysOf = (record) => record ? Object.keys(record) : [];
|
|
36
|
+
/** `bindingsAllowed` stores each target as `{ path, label }`; the catalog only needs the paths. */
|
|
37
|
+
var pathsOf = (list) => list && list.length > 0 ? list.map((item) => item.path) : void 0;
|
|
38
|
+
/**
|
|
39
|
+
* Keeps only string css declarations from a `base.default` block — dropping nested states and variants, and any
|
|
40
|
+
* non-scalar value — so the catalog carries a flat `prop: value` map an agent can read as the element's starting
|
|
41
|
+
* styles.
|
|
42
|
+
*/
|
|
43
|
+
var stringDeclarations = (block) => {
|
|
44
|
+
if (!block) return;
|
|
45
|
+
const out = {};
|
|
46
|
+
for (const [prop, value] of Object.entries(block)) if (typeof value === "string") out[prop] = value;
|
|
47
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
48
|
+
};
|
|
49
|
+
var entryFromManifest = (type, manifest) => {
|
|
50
|
+
const pluginSchema = manifest.pluginSchema[type];
|
|
51
|
+
const elementDef = pluginSchema?.definition;
|
|
52
|
+
const label = strOrUndefined(elementDef?.label) ?? strOrUndefined(manifest.definition.name);
|
|
53
|
+
const description = strOrUndefined(elementDef?.description);
|
|
54
|
+
const bindingsAllowed = pluginSchema?.defaultStyle.bindingsAllowed;
|
|
55
|
+
const attributesTargets = pathsOf(bindingsAllowed?.attributes);
|
|
56
|
+
const initialStateTargets = pathsOf(bindingsAllowed?.initialState);
|
|
57
|
+
const pluginBase = (pluginSchema?.defaultStyle)?.style?.base?.default;
|
|
58
|
+
const defaultStyle = stringDeclarations(pluginBase);
|
|
59
|
+
return {
|
|
60
|
+
label,
|
|
61
|
+
description,
|
|
62
|
+
category: strOrUndefined(manifest.definition.category),
|
|
63
|
+
custom: true,
|
|
64
|
+
attributes: keysOf(pluginSchema?.attributes),
|
|
65
|
+
styleSelectors: keysOf(elementDef?.styleSelectors),
|
|
66
|
+
...defaultStyle ? { defaultStyle } : {},
|
|
67
|
+
...attributesTargets || initialStateTargets ? { bindingsAllowed: {
|
|
68
|
+
attributes: attributesTargets,
|
|
69
|
+
initialState: initialStateTargets
|
|
70
|
+
} } : {}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Builds the plugin half of a component catalog from a space's installed plugins, keyed by schema `type`.
|
|
75
|
+
*
|
|
76
|
+
* A plugin whose manifest cannot be read yields `{ custom: true }` with no metadata rather than failing the whole
|
|
77
|
+
* catalog — the agent then sees the type exists but learns nothing more about it, which is strictly better than
|
|
78
|
+
* being told the space has no plugins at all.
|
|
79
|
+
*/
|
|
80
|
+
var pluginCatalog = async (plugins) => {
|
|
81
|
+
const catalog = {};
|
|
82
|
+
if (!plugins) return catalog;
|
|
83
|
+
const entries = await Promise.all(Object.entries(plugins).map(async ([type, { resource }]) => {
|
|
84
|
+
const manifest = await fetchManifest(resource);
|
|
85
|
+
return [type, manifest ? entryFromManifest(type, manifest) : { custom: true }];
|
|
86
|
+
}));
|
|
87
|
+
for (const [type, entry] of entries) catalog[type] = entry;
|
|
88
|
+
return catalog;
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { pluginCatalog, stringDeclarations };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { cssProperties } from "./cssCatalog/index.js";
|
|
1
|
+
import { cssProperties, elementCatalog } from "@plitzi/sdk-authoring";
|
|
3
2
|
//#region src/modules/mcp/catalogs/registry.ts
|
|
4
3
|
var enrichType = (typeName, info, catalog) => {
|
|
5
4
|
const entry = catalog?.[typeName];
|
|
@@ -16,7 +15,7 @@ var enrichType = (typeName, info, catalog) => {
|
|
|
16
15
|
for (const slot of entry.styleSelectors ?? []) if (!info.slots.includes(slot)) info.slots.push(slot);
|
|
17
16
|
return;
|
|
18
17
|
}
|
|
19
|
-
const builtin =
|
|
18
|
+
const builtin = elementCatalog[typeName];
|
|
20
19
|
if (builtin) {
|
|
21
20
|
info.label = builtin.label;
|
|
22
21
|
info.description = builtin.description;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { BUILTIN_GLOBAL_CALLBACKS } from "../catalogs/
|
|
2
|
-
import { BUILTIN_ELEMENT_CALLBACKS } from "../catalogs/builtinElementCallbacks.js";
|
|
3
|
-
import { BUILTIN_UTILITIES } from "../catalogs/builtinUtilities.js";
|
|
1
|
+
import { BUILTIN_ELEMENT_CALLBACKS, BUILTIN_GLOBAL_CALLBACKS, BUILTIN_UTILITIES } from "../catalogs/index.js";
|
|
4
2
|
//#region src/modules/mcp/helpers/agentPrompt.ts
|
|
5
3
|
var EDITING_MODEL = [
|
|
6
4
|
"━━ PLITZI MCP — EDITING MODEL ━━",
|
|
@@ -10,21 +8,23 @@ var EDITING_MODEL = [
|
|
|
10
8
|
"To style an element: write a definition AND attach it via the element’s style.base in the same batch.",
|
|
11
9
|
"style.base is a LIST — an element can attach several classes (plus non-base slots); ALL of them apply together",
|
|
12
10
|
"(they cascade), so when a style looks wrong inspect EVERY attached class + its global/id styles, not just one.",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
11
|
+
"Every element and page has ONE name, which IS its id: you choose it ([A-Za-z0-9_-] starting with a letter,",
|
|
12
|
+
"unique in the space), you address it by it, and the runtime wires by it (a provider source is",
|
|
13
|
+
"`<type>_<id>.<field>` — a dot is not allowed in a name, an underscore is). Nothing hands out opaque ids, so",
|
|
14
|
+
"never invent one: name the thing. CSS is kebab-case; style vars are var(--name), schema",
|
|
16
15
|
"vars are {{name}}. Use patchElement/patchDefinition to change SOME props/CSS; the upsert variants replace them all.",
|
|
17
16
|
"Reads are cheap by design — list to navigate, read one item for detail; never fetch a whole tree you do not need."
|
|
18
17
|
].join("\n");
|
|
19
18
|
var TOOLS = [
|
|
20
19
|
"━━ MCP TOOLS ━━",
|
|
21
|
-
"• plitzi_search — find
|
|
20
|
+
"• plitzi_search — find elements by label/type/attribute; a hit carries the NAME every op takes (include:\"detail\"",
|
|
21
|
+
" also returns its style + versions).",
|
|
22
22
|
"• plitzi_read — batch-read one or more resource URIs you already hold (from search or a write response).",
|
|
23
23
|
"• plitzi_validate — check a batch of operations without executing; returns teachable errors and warnings.",
|
|
24
24
|
"• plitzi_apply — persist a batch of operations. Pass dryRun to preview the full diff without writing, and",
|
|
25
25
|
" expectedResourceVersions to guard against concurrent edits (apply and search hand back the versions you need).",
|
|
26
26
|
"• plitzi_preview / plitzi_screenshot — render an element/page already in the schema (HTML / image).",
|
|
27
|
-
"Discover → browse resources. Find a
|
|
27
|
+
"Discover → browse resources. Find a name → plitzi_search. Fetch known URIs → plitzi_read. Do not confuse them."
|
|
28
28
|
].join("\n");
|
|
29
29
|
var RESOURCES = [
|
|
30
30
|
"━━ MCP RESOURCES (read) ━━",
|
|
@@ -68,7 +68,7 @@ var INTERACTIONS = () => [
|
|
|
68
68
|
"deleteInteraction is destructive — confirm with the user first.",
|
|
69
69
|
"Pick the RIGHT node type for an action: the wrong type resolves against nothing and the step silently no-ops.",
|
|
70
70
|
"Any param VALUE can be a data-binding token {{ source }} — e.g. addNotification content",
|
|
71
|
-
"\"{{ list_<
|
|
71
|
+
"\"{{ list_<name>.item.name }}\" shows the clicked row’s field; it resolves at runtime just like a prop binding.",
|
|
72
72
|
"",
|
|
73
73
|
"globalCallback (nodeType \"globalCallback\") — provided by a SOURCE MODULE, not the host element: OMIT elementId",
|
|
74
74
|
"and the MCP pins the right source and fills the builder’s param defaults. Use ONLY each callback’s declared",
|