@plitzi/sdk-mcp 0.38.19 → 0.38.20

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 CHANGED
@@ -1,5 +1,70 @@
1
1
  # @plitzi/sdk-mcp
2
2
 
3
+ ## 0.38.20
4
+
5
+ ### Patch Changes
6
+
7
+ - c7c241a: ## Security
8
+
9
+ - **The `Origin` fallback reads the request's own authority before a forwarded one** (`@plitzi/sdk-server`): 0.38.19
10
+ took `X-Forwarded-Host` first, and with no proxy in front a client could send one naming this host on another port,
11
+ making that port's `Origin` this server's own. Now `:authority` or `Host` decide whenever they name the host the
12
+ request is answered as; `X-Forwarded-Host` only when they do not — a host that took its hostname from the header
13
+ (Express's `trust proxy`) trusts the proxy that wrote it. No option to set: what the host resolved says which one it
14
+ believes. The write guard (`crossSiteWrites`), the sign-in's login-CSRF check and `createOriginGuardMiddleware`
15
+ share it.
16
+
17
+ ## Server
18
+ - **`ctx.oauth`: OAuth 2.0 for a space's code, any provider** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): a
19
+ connection is data in `defineFunctions({ oauth: { calendar: { issuer | authorizeUrl + tokenUrl, credential, scopes,
20
+ authorizeParams, clientAuth } } })` — an OpenID provider by its `issuer` (endpoints discovered), any other by its
21
+ endpoints; none is known to the platform by name. `ctx.oauth.connect(name, { returnTo, owner? })` answers the
22
+ consent URL (authorization code with PKCE); the platform answers `/fn/oauth/callback` — the one address to register
23
+ with every provider — exchanges the code with the app's id and secret from the named credential, and sends the
24
+ visitor back to `returnTo` with `?oauth=<name>&oauth_result=connected` (or `&oauth_error=`). `ctx.oauth.fetch(name,
25
+ url)` writes the token in, renewed before it lapses and once more on a 401, only to `allow.hosts`; `status` and
26
+ `disconnect` (revoked where the provider says). A token is a signed-in visitor's own by default, `{ owner: 'space' }`
27
+ the space's, or a key of the code's own; it is kept in the space's `kv` sealed with a key of the space's that no
28
+ `ctx.sign` reaches, so the code never holds one. In the sandbox, natively and in a space's runtime alike; a plugin's
29
+ functions declare and reach none. Needs `signingSecret`. Runs also carry the `origin` of the request that started
30
+ them (`ctx.origin` of a task context), what the callback address is made of.
31
+
32
+ ## Packages
33
+ - **No path a package does not export is written anywhere in the packages** (`@plitzi/plitzi-sdk`,
34
+ `@plitzi/sdk-shared`): two JSDoc comments sent readers to `@plitzi/sdk-authoring/testing`, which is not an entry —
35
+ `inspectRenders` is exported by `@plitzi/sdk-authoring`. `yarn check:specifiers` (in CI after the build) reads every
36
+ `@plitzi/<package>/<path>` the workspace writes — the code, its built declarations, JSDoc, skills and docs — against
37
+ what that package exports, so an import somebody would copy into a project and get `ERR_MODULE_NOT_FOUND` from cannot
38
+ be published again.
39
+
40
+ - **The packages that run in Node say which Node** (`@plitzi/sdk-server`, `@plitzi/cli`, `@plitzi/sdk-mcp`,
41
+ `@plitzi/sdk-authoring`): `"engines": { "node": ">=22.18" }`, the floor every project the CLI makes already declares —
42
+ installed on an older Node they now say so, instead of failing on the first API it lacks (`--env-file-if-exists`,
43
+ `--permission`, `Set#union`). The browser's packages declare none: a bundler reads them.
44
+
45
+ - **A short render guide, and each part of it alone** (`@plitzi/sdk-mcp`): `renderGuideText` stays the whole guide
46
+ (~30k characters); `renderGuideCore` is a third of it for an agent that counts its tokens — a voice assistant, a small
47
+ model — with the model of a render, the element types, the host's theme and what to do on a refusal, and the address
48
+ of every other section; `renderGuideTopics[topic]` and `renderGuideTopicUri(topic)` (`plitzi://render/guide/repeat`,
49
+ `…/data`…) serve each one, cut from the one text. The MCP server answers them as resources and through `plitzi_read`.
50
+
51
+ ## CLI
52
+ - **What Plitzi decided reaches the agent writing a report** (`@plitzi/cli`): `plitzi feedback`'s brief lists what was
53
+ reported and kept as it is — with why, and what to do instead — so a report files it under `changed` as `decided`
54
+ rather than carrying it as open, and the page has that status.
55
+
56
+ - **The CLI skill says what `ERR_MODULE_NOT_FOUND` into a `@plitzi` package's `dist` is** (`@plitzi/cli`): an import of
57
+ a path the package does not export — a file rather than its folder — with `plitzi doctor` to name each one and
58
+ `plitzi upgrade migrations --write` to rewrite it.
59
+
60
+ - Updated dependencies [c7c241a]
61
+ - @plitzi/plitzi-sdk@0.38.20
62
+ - @plitzi/sdk-server@0.38.20
63
+ - @plitzi/sdk-authoring@0.38.20
64
+ - @plitzi/sdk-schema@0.38.20
65
+ - @plitzi/sdk-shared@0.38.20
66
+ - @plitzi/sdk-style@0.38.20
67
+
3
68
  ## 0.38.19
4
69
 
5
70
  ### Patch Changes
package/README.md CHANGED
@@ -155,6 +155,12 @@ if (answer.rendered) {
155
155
  `base` is the style of the space that shows the widget: its tokens in both themes, its classes and its fonts come
156
156
  with it, so the widget looks like the page around it. Left out, the widget starts from nothing, as one in a chat does.
157
157
 
158
+ The guide is long (~30k characters) because it teaches everything a widget can do. An agent that counts its tokens — a
159
+ voice assistant, a small model — is handed `renderGuideCore` instead (a third of it: the model of a render, the
160
+ element types, the host's theme, what to do on a refusal) and reads the rest when a widget needs it: each section is
161
+ `renderGuideTopics[topic]`, addressed `renderGuideTopicUri(topic)` (`plitzi://render/guide/repeat`, `…/data`…), which
162
+ the core names. On this package's own server those addresses are resources, read with `plitzi_read`.
163
+
158
164
  ## Draft preview
159
165
 
160
166
  The two halves live in different packages, joined by a one-shot token:
@@ -5,8 +5,37 @@ export declare const RENDER_GUIDE_URI = "plitzi://render/guide";
5
5
  export declare const RENDER_TYPES_URI = "plitzi://render/types";
6
6
  /** How a widget is authored: what an agent reads before its first render, whichever server hands it the tool. */
7
7
  export declare const renderGuideText: string;
8
+ /** Each section of the guide by a name of its own, matched by how its heading starts. */
9
+ declare const RENDER_GUIDE_TOPIC_HEADINGS: {
10
+ readonly 'one-call': "Build the whole widget in ONE upsertElement";
11
+ readonly repeat: "Repeating rows";
12
+ readonly classes: "Style with reusable classes";
13
+ readonly layout: "Fit the panel";
14
+ readonly theme: "Match the host theme";
15
+ readonly types: "Element types";
16
+ readonly svg: "Draw with inline SVG";
17
+ readonly small: "Keep the call small";
18
+ readonly example: "Full worked example";
19
+ readonly data: "Data & interactivity";
20
+ readonly fails: "When it fails";
21
+ };
22
+ export type RenderGuideTopic = keyof typeof RENDER_GUIDE_TOPIC_HEADINGS;
23
+ /**
24
+ * The guide's sections, each readable alone (`plitzi://render/guide/<topic>`) — cut from the one text, so the whole guide
25
+ * and its parts cannot say different things. A heading no topic names fails here, at load, not in an agent's reading.
26
+ */
27
+ export declare const renderGuideTopics: Readonly<Record<RenderGuideTopic, string>>;
28
+ /** Where a topic is read: a resource of its own, and through `plitzi_read`. */
29
+ export declare const renderGuideTopicUri: (topic: RenderGuideTopic) => string;
30
+ /**
31
+ * The guide for a host that counts its tokens — a voice assistant, a small model: the model of a render, the sections a
32
+ * first widget cannot do without, and every other section by name and address, to read when the widget needs it.
33
+ * `renderGuideText` stays the whole guide, and is what a host with room should hand over.
34
+ */
35
+ export declare const renderGuideCore: string;
8
36
  /** The same two documents through the READ path (the router, hence plitzi_read), not only as MCP resources: an
9
37
  * agent that reaches for the batch-read tool — the reflex the guide itself teaches — must not be told its own
10
38
  * authoring guide does not exist. Space-independent, like the core singletons. */
11
39
  export declare const readRenderResource: (uri: string) => ResourceEnvelope<unknown> | undefined;
12
40
  export declare const registerRenderResources: (server: McpServer, log: McpLog) => void;
41
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { elementCatalog } from "../catalogs/index.js";
2
2
  import { envelope, jsonContents } from "./envelope.js";
3
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
3
4
  import { STYLE_STATES } from "@plitzi/sdk-shared/style";
4
5
  //#region src/modules/mcp/resources/renderGuide.ts
5
6
  var RENDER_GUIDE_URI = "plitzi://render/guide";
@@ -473,11 +474,69 @@ them; if both are needed, the render warns you and names the pair.
473
474
  The tool returns \`rendered: false\` with \`errors: [{ path, message, hint }]\`. Read the hint, fix that one op, and
474
475
  retry — you never lose the rest of the batch.
475
476
  `;
477
+ /** Each section of the guide by a name of its own, matched by how its heading starts. */
478
+ var RENDER_GUIDE_TOPIC_HEADINGS = {
479
+ "one-call": "Build the whole widget in ONE upsertElement",
480
+ repeat: "Repeating rows",
481
+ classes: "Style with reusable classes",
482
+ layout: "Fit the panel",
483
+ theme: "Match the host theme",
484
+ types: "Element types",
485
+ svg: "Draw with inline SVG",
486
+ small: "Keep the call small",
487
+ example: "Full worked example",
488
+ data: "Data & interactivity",
489
+ fails: "When it fails"
490
+ };
491
+ var [renderGuideIntro, ...renderGuideSections] = renderGuideText.split(/\n(?=## )/);
492
+ /**
493
+ * The guide's sections, each readable alone (`plitzi://render/guide/<topic>`) — cut from the one text, so the whole guide
494
+ * and its parts cannot say different things. A heading no topic names fails here, at load, not in an agent's reading.
495
+ */
496
+ var renderGuideTopics = (() => {
497
+ const topics = {};
498
+ for (const section of renderGuideSections) {
499
+ const heading = section.slice(3, section.indexOf("\n"));
500
+ const entry = Object.entries(RENDER_GUIDE_TOPIC_HEADINGS).find(([, start]) => heading.startsWith(start));
501
+ if (!entry) throw new Error(`[render guide] the section "${heading}" has no topic: name it in RENDER_GUIDE_TOPIC_HEADINGS`);
502
+ topics[entry[0]] = section.trim();
503
+ }
504
+ const missing = Object.keys(RENDER_GUIDE_TOPIC_HEADINGS).filter((topic) => !(topic in topics));
505
+ if (missing.length > 0) throw new Error(`[render guide] no section for the topic(s) ${missing.join(", ")}`);
506
+ return topics;
507
+ })();
508
+ /** Where a topic is read: a resource of its own, and through `plitzi_read`. */
509
+ var renderGuideTopicUri = (topic) => `${RENDER_GUIDE_URI}/${topic}`;
510
+ /** What the core carries whole: enough to render a correct, themed widget in one call and recover from a refusal. */
511
+ var CORE_TOPICS = [
512
+ "one-call",
513
+ "theme",
514
+ "types",
515
+ "small",
516
+ "fails"
517
+ ];
518
+ /**
519
+ * The guide for a host that counts its tokens — a voice assistant, a small model: the model of a render, the sections a
520
+ * first widget cannot do without, and every other section by name and address, to read when the widget needs it.
521
+ * `renderGuideText` stays the whole guide, and is what a host with room should hand over.
522
+ */
523
+ var renderGuideCore = [
524
+ renderGuideIntro.trim(),
525
+ ...CORE_TOPICS.map((topic) => renderGuideTopics[topic]),
526
+ [
527
+ "## More, when the widget needs it",
528
+ "Each is a section of the full guide (`plitzi://render/guide`), read on its own with `plitzi_read`:",
529
+ "",
530
+ ...Object.entries(RENDER_GUIDE_TOPIC_HEADINGS).filter(([topic]) => !CORE_TOPICS.some((core) => core === topic)).map(([topic, heading]) => `- \`${RENDER_GUIDE_URI}/${topic}\` — ${heading}`)
531
+ ].join("\n")
532
+ ].join("\n\n");
476
533
  /** The same two documents through the READ path (the router, hence plitzi_read), not only as MCP resources: an
477
534
  * agent that reaches for the batch-read tool — the reflex the guide itself teaches — must not be told its own
478
535
  * authoring guide does not exist. Space-independent, like the core singletons. */
479
536
  var readRenderResource = (uri) => {
480
537
  if (uri === "plitzi://render/guide") return envelope(renderGuideText);
538
+ const topic = uri.startsWith(`plitzi://render/guide/`) ? uri.slice(22) : void 0;
539
+ if (topic !== void 0 && Object.hasOwn(renderGuideTopics, topic)) return envelope(renderGuideTopics[topic]);
481
540
  if (uri === "plitzi://render/types") return envelope(renderTypes());
482
541
  };
483
542
  var registerRenderResources = (server, log) => {
@@ -494,6 +553,20 @@ var registerRenderResources = (server, log) => {
494
553
  log.resourceRead(RENDER_GUIDE_URI, performance.now() - start);
495
554
  return contents;
496
555
  });
556
+ server.registerResource("Render guide section", new ResourceTemplate(`${RENDER_GUIDE_URI}/{topic}`, { list: void 0 }), {
557
+ description: `One section of the render guide: ${Object.keys(RENDER_GUIDE_TOPIC_HEADINGS).join(", ")}.`,
558
+ mimeType: "text/markdown"
559
+ }, (uri) => {
560
+ const start = performance.now();
561
+ const topic = uri.href.slice(22);
562
+ const text = Object.hasOwn(renderGuideTopics, topic) ? renderGuideTopics[topic] : `No section "${topic}" in the render guide: ${Object.keys(RENDER_GUIDE_TOPIC_HEADINGS).join(", ")}.`;
563
+ log.resourceRead(uri.href, performance.now() - start);
564
+ return { contents: [{
565
+ uri: uri.href,
566
+ mimeType: "text/markdown",
567
+ text
568
+ }] };
569
+ });
497
570
  server.registerResource("Render element types", RENDER_TYPES_URI, {
498
571
  description: "Built-in element types a plitzi_render widget can use, with descriptions.",
499
572
  mimeType: "application/json"
@@ -505,4 +578,4 @@ var registerRenderResources = (server, log) => {
505
578
  });
506
579
  };
507
580
  //#endregion
508
- export { RENDER_GUIDE_URI, RENDER_TYPES_URI, readRenderResource, registerRenderResources, renderGuideText };
581
+ export { RENDER_GUIDE_URI, RENDER_TYPES_URI, readRenderResource, registerRenderResources, renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics };
@@ -0,0 +1 @@
1
+ export {};
@@ -73,7 +73,7 @@ var createMcpServer = async ({ adapters, getGrant, preview, screenshot, logger,
73
73
  const getSpace = () => spacePromise ??= loadSpace();
74
74
  const server = new McpServer({
75
75
  name: "plitzi-mcp",
76
- version: "0.38.19"
76
+ version: "0.38.20"
77
77
  }, { instructions: hasSpace ? serverInstructions : widgetsOnlyInstructions });
78
78
  const { getChanges } = adapters;
79
79
  registerResources(server, getSpace, MCP_ENV, log, hasSpace, getChanges ? (query) => getChanges(requireSpaceId(), MCP_ENV, query) : void 0);
package/dist/render.d.ts CHANGED
@@ -2,9 +2,11 @@
2
2
  * space, no OAuth.
3
3
  *
4
4
  * Import it as `@plitzi/sdk-mcp/render` in a project whose own agent draws UI in its own pages: register `render` as
5
- * a tool of the project's MCP server with `renderWidgetShape` as its input and `renderGuideText` for the agent to read,
5
+ * a tool of the project's MCP server with `renderWidgetShape` as its input and `renderGuideText` for the agent to read
6
+ * (`renderGuideCore` when it counts its tokens, with `renderGuideTopics` to serve the rest on demand),
6
7
  * hand it `base` — the style of the project's space — so the widget looks like the page around it, and draw the
7
8
  * answer with the `plitziSdk` element (its `offlineData`). */
8
9
  export { HOST_PAGE_REF as RENDER_ROOT_REF, render, renderWidgetShape } from './modules/mcp/tools/renderWidget';
9
- export { renderGuideText } from './modules/mcp/resources/renderGuide';
10
+ export { renderGuideCore, renderGuideText, renderGuideTopics, renderGuideTopicUri } from './modules/mcp/resources/renderGuide';
11
+ export type { RenderGuideTopic } from './modules/mcp/resources/renderGuide';
10
12
  export type { RenderOptions, RenderResponse, RenderWidgetInput } from './modules/mcp/tools/renderWidget';
package/dist/render.js CHANGED
@@ -1,3 +1,3 @@
1
- import { renderGuideText } from "./modules/mcp/resources/renderGuide.js";
1
+ import { renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics } from "./modules/mcp/resources/renderGuide.js";
2
2
  import { HOST_PAGE_REF, render, renderWidgetShape } from "./modules/mcp/tools/renderWidget.js";
3
- export { HOST_PAGE_REF as RENDER_ROOT_REF, render, renderGuideText, renderWidgetShape };
3
+ export { HOST_PAGE_REF as RENDER_ROOT_REF, render, renderGuideCore, renderGuideText, renderGuideTopicUri, renderGuideTopics, renderWidgetShape };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-mcp",
3
- "version": "0.38.19",
3
+ "version": "0.38.20",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -34,16 +34,19 @@
34
34
  "url": "https://github.com/plitzi/plitzi-workspace.git"
35
35
  },
36
36
  "type": "module",
37
+ "engines": {
38
+ "node": ">=22.18"
39
+ },
37
40
  "sideEffects": false,
38
41
  "dependencies": {
39
42
  "@modelcontextprotocol/ext-apps": "^1.7.5",
40
43
  "@modelcontextprotocol/sdk": "^1.32.1",
41
- "@plitzi/plitzi-sdk": "0.38.19",
42
- "@plitzi/sdk-authoring": "0.38.19",
43
- "@plitzi/sdk-schema": "0.38.19",
44
- "@plitzi/sdk-server": "0.38.19",
45
- "@plitzi/sdk-shared": "0.38.19",
46
- "@plitzi/sdk-style": "0.38.19",
44
+ "@plitzi/plitzi-sdk": "0.38.20",
45
+ "@plitzi/sdk-authoring": "0.38.20",
46
+ "@plitzi/sdk-schema": "0.38.20",
47
+ "@plitzi/sdk-server": "0.38.20",
48
+ "@plitzi/sdk-shared": "0.38.20",
49
+ "@plitzi/sdk-style": "0.38.20",
47
50
  "ejs": "^7.0.2",
48
51
  "esbuild": "^0.28.2",
49
52
  "zod": "^4.6.7"